Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x3domlet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
x3domlet
Commits
eb32da4a
Commit
eb32da4a
authored
7 years ago
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor structure changes: 1. setViewpoint 2. get distance/angle ...
parent
64db9f96
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
143 deletions
+104
-143
ui_init.js
js/ui_init.js
+8
-69
x3dom_functions.js
js/x3dom_functions.js
+88
-58
x3dom_init.js
js/x3dom_init.js
+8
-16
No files found.
js/ui_init.js
View file @
eb32da4a
...
...
@@ -256,7 +256,6 @@ function deep_init(){
function
x3d_initial_camera_placement
(){
// Roll compensation
var
heading
=
Data
.
camera
.
heading
*
Math
.
PI
/
180
;
var
tilt
=
(
Data
.
camera
.
tilt
-
90
)
*
Math
.
PI
/
180
;
var
roll
=
Data
.
camera
.
roll
*
Math
.
PI
/
180
;
...
...
@@ -290,29 +289,12 @@ function x3d_initial_camera_placement(){
var
RC_w
=
R0
.
inverse
().
mult
(
RC0_rw
);
// store matrices
Data
.
camera
.
Matrices
=
{
Ah
:
heading
,
At
:
tilt
,
Ar
:
roll
,
R_h_eul
:
Mh
,
R_t_eul
:
Mt
,
R_r_eul
:
Mr
,
R0
:
R0
,
Up0
:
RC_w
.
e1
(),
RC_w
:
RC_w
,
};
// set view
var
Q
=
new
x3dom
.
fields
.
Quaternion
(
0
,
0
,
1
,
0
);
Q
.
setValue
(
RC_w
);
var
AA
=
Q
.
toAxisAngle
();
var
viewpoint
=
$
(
Scene
.
element
).
find
(
"Viewpoint"
);
viewpoint
.
attr
(
"orientation"
,
AA
[
0
].
toString
()
+
" "
+
AA
[
1
]);
viewpoint
.
attr
(
"position"
,
RC_w
.
e3
().
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
RC_w
.
e3
().
toString
());
// update every time
Data
.
camera
.
Matrices
.
RC_w
=
RC_w
;
x3dom_setViewpoint
(
RC_w
);
}
...
...
@@ -487,19 +469,13 @@ function leaf_events(){
var
p1_ll
=
Camera
.
_latlng
;
var
p2_ll
=
Lm
.
_latlng
;
//var azimuth = getAzimuth(p1_ll,p2_ll);
var
azimuth
=
getAzimuth
(
p1_ll
,
p2_ll
);
//var initial_heading = Data.camera.Matrices.Ah*180/Math.PI;
var
angle
=
azimuth
-
Data
.
camera
.
Matrices
.
Ah
*
180
/
Math
.
PI
;
var
distance
=
p1_ll
.
distanceTo
(
p2_ll
);
//console.log("angle from lat lng: "+angle
);
p_w
=
x3dom_delta_map2scene
(
p1_ll
,
p2_ll
);
mark
.
x
=
distance
*
Math
.
sin
(
Math
.
PI
/
180
*
angle
)
;
mark
.
y
=
0
;
mark
.
z
=
-
distance
*
Math
.
cos
(
Math
.
PI
/
180
*
angle
)
;
mark
.
x
=
p_w
.
x
;
mark
.
y
=
p_w
.
y
;
mark
.
z
=
p_w
.
z
;
mark
.
d_map
=
distance
;
mark
.
d_x3d
=
"<font style='color:red;'>drag over 3D</font>"
;
...
...
@@ -644,43 +620,6 @@ function leaf_translation_v1(p0,p1){
function
x3d_mouseMove
(){
var
Camera
=
Map
.
marker
;
var
mat
=
Scene
.
element
.
runtime
.
viewMatrix
().
inverse
();
var
R0
=
Data
.
camera
.
Matrices
.
R0
;
var
T
=
x3dom_toYawPitchRoll
();
var
m_rw
=
T
.
mult
(
R0
).
mult
(
mat
).
mult
(
T
.
inverse
());
var
ypr
=
x3dom_YawPitchRoll_degs
(
m_rw
);
var
heading
=
ypr
.
yaw
;
Map
.
marker
.
setHeading
(
heading
);
var
dp_w
=
mat
.
e3
();
if
(
Scene
.
old_view_translation
!=
null
){
dp_w
=
dp_w
.
subtract
(
Scene
.
old_view_translation
);
}
// from w to rw
dp_rw
=
R0
.
multMatrixVec
(
dp_w
);
var
distance
=
Math
.
sqrt
(
dp_rw
.
x
*
dp_rw
.
x
+
dp_rw
.
z
*
dp_rw
.
z
);
var
angle
=
180
/
Math
.
PI
*
Math
.
atan2
(
dp_rw
.
x
,
-
dp_rw
.
z
);
var
initial_coordinates
=
[
Data
.
camera
.
latitude
,
Data
.
camera
.
longitude
];
var
p0
=
new
L
.
LatLng
(
initial_coordinates
[
0
],
initial_coordinates
[
1
]);
//Camera._latlng;
var
p1
=
p0
.
CoordinatesOf
(
angle
,
distance
);
Map
.
marker
.
setBasePoint
(
p1
);
Map
.
marker
.
_syncMeasureMarkersToBasePoint
();
Data
.
camera
.
latitude
=
p1
.
lat
;
Data
.
camera
.
longitude
=
p1
.
lng
;
Data
.
camera
.
heading
=
heading
;
Scene
.
old_view_translation
=
mat
.
e3
();
x3dom_update_map
();
}
This diff is collapsed.
Click to expand it.
js/x3dom_functions.js
View file @
eb32da4a
...
...
@@ -229,34 +229,15 @@ function x3dom_setUpRight(){
var
from
=
mat
.
e3
();
var
at
=
from
.
subtract
(
mat
.
e2
());
//var up = new x3dom.fields.SFVec3f(0, 1, 0);
var
up
=
Data
.
camera
.
Matrices
.
Up0
;
var
s
=
mat
.
e2
().
cross
(
up
).
normalize
();
var
newup
=
mat
.
e2
().
cross
(
s
).
normalize
().
negate
();
//at = from.add(v);
mat
=
x3dom
.
fields
.
SFMatrix4f
.
lookAt
(
from
,
at
,
newup
);
//mat = mat.inverse();
//var m1 = x3dom.fields.SFMatrix4f.translation(from);
//var m1n = x3dom.fields.SFMatrix4f.translation(from.negate());
//mat = m1.mult(mat).mult(m1n);
var
Q
=
new
x3dom
.
fields
.
Quaternion
(
0
,
0
,
1
,
0
);
Q
.
setValue
(
mat
);
var
AA
=
Q
.
toAxisAngle
();
var
viewpoint
=
$
(
Scene
.
element
).
find
(
"Viewpoint"
);
viewpoint
.
attr
(
"position"
,
mat
.
e3
().
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
mat
.
e3
().
toString
());
viewpoint
.
attr
(
"orientation"
,
AA
[
0
].
toString
()
+
" "
+
AA
[
1
]);
Data
.
camera
.
Matrices
.
RC_w
=
mat
;
x3dom_setViewpoint
(
mat
)
;
}
...
...
@@ -293,17 +274,7 @@ function x3dom_rotation(delta_a){
newmat
=
x3dom
.
fields
.
SFMatrix4f
.
lookAt
(
from
,
newat
,
up
);
var
Q
=
new
x3dom
.
fields
.
Quaternion
(
0
,
0
,
1
,
0
);
//Q.setValue(newmat.inverse());
Q
.
setValue
(
newmat
);
var
AA
=
Q
.
toAxisAngle
();
var
viewpoint
=
$
(
Scene
.
element
).
find
(
"Viewpoint"
);
viewpoint
.
attr
(
"orientation"
,
AA
[
0
].
toString
()
+
" "
+
AA
[
1
]);
viewpoint
.
attr
(
"position"
,
from
.
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
from
.
toString
());
Data
.
camera
.
Matrices
.
RC_w
=
newmat
;
x3dom_setViewpoint
(
newmat
);
}
...
...
@@ -330,24 +301,12 @@ function x3dom_translation(dx,dy,dz){
var
newmat
=
x3dom
.
fields
.
SFMatrix4f
.
lookAt
(
newfrom
,
newat
,
up
);
var
Q
=
new
x3dom
.
fields
.
Quaternion
(
0
,
0
,
1
,
0
);
//Q.setValue(newmat.inverse());
Q
.
setValue
(
newmat
);
var
AA
=
Q
.
toAxisAngle
();
var
viewpoint
=
$
(
Scene
.
element
).
find
(
"Viewpoint"
);
viewpoint
.
attr
(
"orientation"
,
AA
[
0
].
toString
()
+
" "
+
AA
[
1
]);
viewpoint
.
attr
(
"position"
,
newfrom
.
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
newfrom
.
toString
());
Data
.
camera
.
Matrices
.
RC_w
=
newmat
;
x3dom_setViewpoint
(
newmat
);
}
function
x3dom_altelev
(
alt
,
elev
){
console
.
log
(
elev
);
//x3dom_matrix_test();
var
mat
=
Scene
.
element
.
runtime
.
viewMatrix
().
inverse
();
...
...
@@ -377,16 +336,8 @@ function x3dom_altelev(alt,elev){
var
newmat
=
matt
.
mult
(
R_w
);
var
Q
=
new
x3dom
.
fields
.
Quaternion
(
0
,
0
,
1
,
0
);
Q
.
setValue
(
newmat
);
var
AA
=
Q
.
toAxisAngle
();
x3dom_setViewpoint
(
newmat
);
var
viewpoint
=
$
(
Scene
.
element
).
find
(
"Viewpoint"
);
viewpoint
.
attr
(
"position"
,
newmat
.
e3
().
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
newmat
.
e3
().
toString
());
viewpoint
.
attr
(
"orientation"
,
AA
[
0
].
toString
()
+
" "
+
AA
[
1
]);
Data
.
camera
.
Matrices
.
RC_w
=
newmat
;
}
/**
...
...
@@ -537,3 +488,82 @@ function x3dom_delta_map2scene(p0,p1){
return
dp_w
;
}
// x,y,z - x3dom internal coords
function
x3dom_getDistAngle
(
x
,
y
,
z
){
var
R0
=
Data
.
camera
.
Matrices
.
R0
;
var
p_w
=
new
x3dom
.
fields
.
SFVec3f
(
x
,
y
,
z
);
var
p_rw
=
R0
.
multMatrixVec
(
p_w
);
var
d
=
Math
.
sqrt
(
p_rw
.
x
*
p_rw
.
x
+
p_rw
.
z
*
p_rw
.
z
);
var
a
=
Math
.
atan2
(
p_rw
.
x
,
-
p_rw
.
z
)
*
180
/
Math
.
PI
;
return
Array
(
d
,
a
);
}
function
x3dom_update_map
(){
var
Camera
=
Map
.
marker
;
// real world ypr from viewmatrix
var
mat
=
Scene
.
element
.
runtime
.
viewMatrix
().
inverse
();
var
R0
=
Data
.
camera
.
Matrices
.
R0
;
var
T
=
x3dom_toYawPitchRoll
();
var
m_rw
=
T
.
mult
(
R0
).
mult
(
mat
).
mult
(
T
.
inverse
());
var
ypr
=
x3dom_YawPitchRoll_degs
(
m_rw
);
var
heading
=
ypr
.
yaw
;
Map
.
marker
.
setHeading
(
heading
);
// real world angle distance of some point
var
dp_w
=
mat
.
e3
();
if
(
Scene
.
old_view_translation
!=
null
){
dp_w
=
dp_w
.
subtract
(
Scene
.
old_view_translation
);
}
// from w to rw
dp_rw
=
R0
.
multMatrixVec
(
dp_w
);
var
distance
=
Math
.
sqrt
(
dp_rw
.
x
*
dp_rw
.
x
+
dp_rw
.
z
*
dp_rw
.
z
);
var
angle
=
180
/
Math
.
PI
*
Math
.
atan2
(
dp_rw
.
x
,
-
dp_rw
.
z
);
var
initial_coordinates
=
[
Data
.
camera
.
latitude
,
Data
.
camera
.
longitude
];
var
p0
=
new
L
.
LatLng
(
initial_coordinates
[
0
],
initial_coordinates
[
1
]);
//Camera._latlng;
var
p1
=
p0
.
CoordinatesOf
(
angle
,
distance
);
Map
.
marker
.
setBasePoint
(
p1
);
Map
.
marker
.
_syncMeasureMarkersToBasePoint
();
Data
.
camera
.
latitude
=
p1
.
lat
;
Data
.
camera
.
longitude
=
p1
.
lng
;
Data
.
camera
.
heading
=
heading
;
Scene
.
old_view_translation
=
mat
.
e3
();
}
// uses globals
function
x3dom_setViewpoint
(
m
){
var
Q
=
new
x3dom
.
fields
.
Quaternion
(
0
,
0
,
1
,
0
);
Q
.
setValue
(
m
);
var
AA
=
Q
.
toAxisAngle
();
var
viewpoint
=
$
(
Scene
.
element
).
find
(
"Viewpoint"
);
viewpoint
.
attr
(
"orientation"
,
AA
[
0
].
toString
()
+
" "
+
AA
[
1
]);
viewpoint
.
attr
(
"position"
,
m
.
e3
().
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
m
.
e3
().
toString
());
// update every time
Data
.
camera
.
Matrices
.
RC_w
=
m
;
}
This diff is collapsed.
Click to expand it.
js/x3dom_init.js
View file @
eb32da4a
...
...
@@ -862,14 +862,9 @@ X3DOMObject.Marker.drag = function(dx,dy){
X3DOMObject
.
Marker
.
slide
=
function
(
index
,
x
,
y
,
z
){
var
R0
=
Data
.
camera
.
Matrices
.
R0
;
//var T = x3dom_toYawPitchRoll();
var
p_w
=
new
x3dom
.
fields
.
SFVec3f
(
x
,
y
,
z
);
var
p_rw
=
R0
.
multMatrixVec
(
p_w
);
var
distance
=
Math
.
sqrt
(
p_rw
.
x
*
p_rw
.
x
+
p_rw
.
z
*
p_rw
.
z
);
var
angle
=
Math
.
atan2
(
p_rw
.
x
,
-
p_rw
.
z
)
*
180
/
Math
.
PI
;
var
da
=
x3dom_getDistAngle
(
x
,
y
,
z
);
var
distance
=
da
[
0
];
var
angle
=
da
[
1
];
var
p1_ll
=
Map
.
marker
.
_latlng
;
var
p2_ll
=
p1_ll
.
CoordinatesOf
(
angle
,
distance
);
...
...
@@ -974,14 +969,11 @@ X3DOMObject.PointerMarker.prototype._registerEvents = function(){
// Create marker on the scene
new
X3DOMObject
.
Marker
(
mark
.
x
,
mark
.
y
,
mark
.
z
);
// Create marker on the map
var
R0
=
Data
.
camera
.
Matrices
.
R0
;
var
p_w
=
new
x3dom
.
fields
.
SFVec3f
(
mark
.
x
,
mark
.
y
,
mark
.
z
);
var
p_rw
=
R0
.
multMatrixVec
(
p_w
);
var
distance
=
Math
.
sqrt
(
p_rw
.
x
*
p_rw
.
x
+
p_rw
.
z
*
p_rw
.
z
);
var
angle
=
Math
.
atan2
(
p_rw
.
x
,
-
p_rw
.
z
)
*
180
/
Math
.
PI
;
var
da
=
x3dom_getDistAngle
(
mark
.
x
,
mark
.
y
,
mark
.
z
);
var
distance
=
da
[
0
];
var
angle
=
da
[
1
];
// Create marker on the map
Camera
.
createMeasureMarker
(
angle
,
distance
);
var
map_mark
=
Camera
.
_measureMarkers
[
Camera
.
_measureMarkers
.
length
-
1
];
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment