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
43da7d62
Commit
43da7d62
authored
Jun 09, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
subbing INIT_HEADING to matrix mults
parent
233e7e28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
54 deletions
+78
-54
ui_init.js
js/ui_init.js
+29
-47
x3dom_functions.js
js/x3dom_functions.js
+49
-7
No files found.
js/ui_init.js
View file @
43da7d62
...
...
@@ -289,22 +289,30 @@ function x3d_initial_camera_placement(){
// rw = real world with North
// w = virtual world = x3dom frame reference
var
R
_rw2
w
=
T
.
inverse
().
mult
(
R
).
mult
(
T
);
var
R
w_r
w
=
T
.
inverse
().
mult
(
R
).
mult
(
T
);
var
M_rw2w
=
R
_rw2
w
.
inverse
();
var
M_rw2w
=
R
w_r
w
.
inverse
();
var
Rmap_rw
=
T
.
inverse
().
mult
(
Mh
).
mult
(
T
);
// _rw - real world
// _w - virt world
var
Rc_rw
=
T
.
inverse
().
mult
(
Mh
).
mult
(
T
);
var
Rc_w
=
M_rw2w
.
mult
(
T
.
inverse
()).
mult
(
Mh
).
mult
(
T
);
var
Rc_w
=
M_rw2w
.
mult
(
Rc_rw
);
//var Rm_w = M_rw2w.mult(Rm_rw);
// store matrices
Data
.
camera
.
Matrices
=
{
Ah
:
heading
,
At
:
tilt
,
Ar
:
roll
,
R_h_eul
:
Mh
,
R_t_eul
:
Mt
,
R_r_eul
:
Mr
,
R
_rw2w
:
R_rw2
w
,
R
w_rw
:
Rw_r
w
,
M_rw2w
:
M_rw2w
,
V_trueUp_w
:
Rc_w
.
e1
()
V_trueUp_w
:
Rc_w
.
e1
(),
Rc_w
:
Rc_w
,
//Rm_w: Rm_w
};
// set view
...
...
@@ -317,6 +325,9 @@ function x3d_initial_camera_placement(){
viewpoint
.
attr
(
"position"
,
Rc_w
.
e3
().
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
Rc_w
.
e3
().
toString
());
// update every time
Data
.
camera
.
Matrices
.
Rc_w
=
Rc_w
;
}
function
x3d_events
(){
...
...
@@ -493,9 +504,9 @@ function leaf_events(){
//var azimuth = getAzimuth(p1_ll,p2_ll);
var
azimuth
=
getAzimuth
(
p1_ll
,
p2_ll
);
var
initial_heading
=
INIT_HEADING
;
//var initial_heading = Data.camera.Matrices.Ah*180/Math.PI
;
var
angle
=
azimuth
-
initial_heading
;
var
angle
=
azimuth
-
Data
.
camera
.
Matrices
.
Ah
*
180
/
Math
.
PI
;
var
distance
=
p1_ll
.
distanceTo
(
p2_ll
);
//console.log("angle from lat lng: "+angle);
...
...
@@ -595,7 +606,7 @@ function leaf_mousemove_nohc(e){
var
newheading
=
Data
.
camera
.
heading
-
INIT_HEADING
;
if
((
p0
.
lat
!=
p1
.
lat
)
||
(
p0
.
lng
!=
p1
.
lng
)){
console
.
log
(
"translation"
);
//
console.log("translation");
leaf_translation_v1
(
p0
,
p1
);
}
else
{
//leaf_rotation_v1(newheading,dh);
...
...
@@ -625,58 +636,29 @@ function leaf_drag_marker(){
mark
.
latitude
=
p2_ll
.
lat
;
mark
.
longitude
=
p2_ll
.
lng
;
var
azimuth
=
getAzimuth
(
p1_ll
,
p2_ll
);
//var initial_heading = Data.camera.heading;
var
angle
=
azimuth
-
INIT_HEADING
;
var
distance
=
p1_ll
.
distanceTo
(
p2_ll
);
mark
.
x
=
distance
*
Math
.
sin
(
Math
.
PI
/
180
*
angle
);
mark
.
z
=
-
distance
*
Math
.
cos
(
Math
.
PI
/
180
*
angle
);
var
dp_w
=
x3dom_delta_map2scene
(
p1_ll
,
p2_ll
);
mark
.
x
=
dp_w
.
x
;
mark
.
z
=
dp_w
.
z
;
mark
.
d_map
=
distance
;
X3DOMObject
.
displayMarkInfo
(
index
);
X3DOMObject
.
Marker
.
place
(
mark
.
x
,
mark
.
y
,
mark
.
z
,
"my-sph-"
+
index
);
}
}
function
leaf_translation_v1
(
p0
,
p1
){
var
pi
=
new
L
.
LatLng
(
p0
.
lat
,
p1
.
lng
);
var
dx
=
p0
.
distanceTo
(
pi
);
var
dy
=
0
;
var
dz
=
p1
.
distanceTo
(
pi
);
var
dl
=
p0
.
distanceTo
(
p1
);
//console.log(dx+" "+dz+" "+dl);
if
(
p1
.
lng
<
p0
.
lng
){
dx
=
-
dx
;
}
if
(
p1
.
lat
<
p0
.
lat
){
dz
=
-
dz
;
}
//transform to camera coordinates
var
A
=
Math
.
PI
/
180
*
INIT_HEADING
;
var
a
=
Math
.
atan2
(
dx
,
dz
);
console
.
log
(
A
);
dx
=
-
dl
*
Math
.
sin
(
A
-
a
);
dz
=
-
dl
*
Math
.
cos
(
A
-
a
);
console
.
log
(
"dx="
+
dx
+
" dy="
+
dy
+
" dz="
+
dz
);
var
dp_w
=
x3dom_delta_map2scene
(
p0
,
p1
);
// translation over map = xz
x3dom_translation
(
dx
,
dy
,
dz
);
x3dom_translation
(
dp_w
.
x
,
dp_w
.
y
,
dp_w
.
z
);
// if not updated then moving in 3D scene will make it jump
Scene
.
old_view_translation
=
x3dom_getViewTranslation
(
Scene
.
element
);
...
...
@@ -687,7 +669,7 @@ function x3d_mouseMove(){
var
Camera
=
Map
.
marker
;
var
initial_heading
=
Data
.
camera
.
heading
;
//
var initial_heading = Data.camera.heading;
//var initial_heading = INIT_HEADING;
var
heading
=
x3dom_getViewDirection
(
Scene
.
element
);
...
...
js/x3dom_functions.js
View file @
43da7d62
...
...
@@ -162,6 +162,8 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
*/
function
x3dom_getCameraPosOr
(
round
){
//console.log("Getting PosOr");
var
elem
=
Scene
.
element
;
var
vm
=
elem
.
runtime
.
viewMatrix
().
inverse
();
...
...
@@ -173,14 +175,26 @@ function x3dom_getCameraPosOr(round){
var
z
=
tr
.
z
;
var
R
=
vm
;
// double check below, random correct result?
var
az
=
Math
.
atan2
(
R
.
_02
,
R
.
_22
)
*
180
/
Math
.
PI
;
//var mat = Data.camera.Matrices.Rw_rw;
var
mat
=
Data
.
camera
.
Matrices
.
M_rw2w
;
var
T
=
x3dom_C2E
();
az
=
(
az
+
INIT_HEADING
+
360
)
%
360
;
mat
=
T
.
mult
(
mat
).
mult
(
vm
).
mult
(
T
.
inverse
())
;
var
el
=
-
Math
.
asin
(
R
.
_12
)
*
180
/
Math
.
PI
;
var
test
=
x3dom_YawPitchRoll
(
mat
)
;
var
sk
=
Math
.
atan2
(
R
.
_10
,
R
.
_11
);
test
.
yaw
=
(
-
180
/
Math
.
PI
*
test
.
yaw
+
360
)
%
360
;
test
.
pitch
*=
180
/
Math
.
PI
;
test
.
roll
*=
180
/
Math
.
PI
;
//console.log(test);
az
=
test
.
yaw
;
el
=
test
.
pitch
;
sk
=
test
.
roll
;
if
(
!
round
){
return
{
...
...
@@ -238,6 +252,8 @@ function x3dom_setUpRight(){
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
;
}
...
...
@@ -283,6 +299,8 @@ function x3dom_rotation(delta_a){
viewpoint
.
attr
(
"orientation"
,
AA
[
0
].
toString
()
+
" "
+
AA
[
1
]);
viewpoint
.
attr
(
"position"
,
from
.
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
from
.
toString
());
Data
.
camera
.
Matrices
.
Rc_w
=
newmat
;
}
...
...
@@ -297,11 +315,11 @@ function x3dom_translation(dx,dy,dz){
var
from
=
mat
.
e3
();
var
at
=
from
.
subtract
(
mat
.
e2
());
console
.
log
(
from
.
toString
());
//
console.log(from.toString());
var
newfrom
=
from
.
add
(
delta
);
console
.
log
(
newfrom
.
toString
());
//
console.log(newfrom.toString());
var
newat
=
newfrom
.
subtract
(
mat
.
e2
());
...
...
@@ -319,6 +337,8 @@ function x3dom_translation(dx,dy,dz){
viewpoint
.
attr
(
"position"
,
newfrom
.
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
newfrom
.
toString
());
Data
.
camera
.
Matrices
.
Rc_w
=
newmat
;
}
function
x3dom_altelev
(
alt
,
elev
){
...
...
@@ -352,6 +372,7 @@ function x3dom_altelev(alt,elev){
viewpoint
.
attr
(
"centerOfRotation"
,
newmat
.
e3
().
toString
());
viewpoint
.
attr
(
"orientation"
,
AA
[
0
].
toString
()
+
" "
+
AA
[
1
]);
Data
.
camera
.
Matrices
.
Rc_w
=
newmat
;
}
/**
...
...
@@ -420,7 +441,7 @@ function x3dom_C2E(){
}
function
x3dom_E2C
(){
return
x3dom_
W2C
().
inverse
();
return
x3dom_
C2E
().
inverse
();
}
function
x3dom_YawPitchRoll
(
m
){
...
...
@@ -435,3 +456,24 @@ function x3dom_YawPitchRoll(m){
roll
:
roll
};
}
function
x3dom_delta_map2scene
(
p0
,
p1
){
var
pi
=
new
L
.
LatLng
(
p0
.
lat
,
p1
.
lng
);
var
dx
=
p0
.
distanceTo
(
pi
);
var
dy
=
0
;
var
dz
=
p1
.
distanceTo
(
pi
);
var
dp_rw
=
new
x3dom
.
fields
.
SFVec3f
(
dx
,
dy
,
dz
);
if
(
p1
.
lng
<
p0
.
lng
)
dp_rw
.
x
=
-
dp_rw
.
x
;
if
(
p1
.
lat
>
p0
.
lat
)
dp_rw
.
z
=
-
dp_rw
.
z
;
// rotate, not transform - because rotated is the camera
var
mat
=
Data
.
camera
.
Matrices
.
Rw_rw
;
var
dp_w
=
mat
.
multMatrixVec
(
dp_rw
);
return
dp_w
;
}
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