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
401fc593
Commit
401fc593
authored
Jun 07, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed jumping: map-drag cam - scene-drag cam
parent
47d7e72e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
19 deletions
+45
-19
ui_init.js
js/ui_init.js
+18
-11
x3dom_functions.js
js/x3dom_functions.js
+27
-8
No files found.
js/ui_init.js
View file @
401fc593
...
...
@@ -7,6 +7,7 @@ var Data = {
var
Scene
;
var
Map
;
// this var needs to go
var
INIT_HEADING
=
0
;
var
SETTINGS
=
{
...
...
@@ -505,6 +506,7 @@ function leaf_mousemove_nohc(e){
var
p0
=
new
L
.
LatLng
(
Data
.
camera
.
latitude
,
Data
.
camera
.
longitude
);
var
p1
=
new
L
.
LatLng
(
Camera
.
_latlng
.
lat
,
Camera
.
_latlng
.
lng
);
//update Data
Data
.
camera
.
latitude
=
Camera
.
_latlng
.
lat
;
Data
.
camera
.
longitude
=
Camera
.
_latlng
.
lng
;
...
...
@@ -514,15 +516,15 @@ function leaf_mousemove_nohc(e){
Data
.
camera
.
heading
=
Camera
.
_heading
*
180
/
Math
.
PI
;
var
newheading
=
Data
.
camera
.
heading
;
//
- INIT_HEADING;
var
newheading
=
Data
.
camera
.
heading
-
INIT_HEADING
;
if
((
p0
.
lat
!=
p1
.
lat
)
||
(
p0
.
lng
!=
p1
.
lng
)){
console
.
log
(
"translation"
);
leaf_translation_v1
(
p0
,
p1
);
}
else
{
//leaf_rotation_v1(newheading,dh);
x3dom_rotation
(
dh
);
}
//leaf_rotation_v1(newheading,dh);
x3dom_rotation
(
dh
);
X3DOMObject
.
displayViewInfo
({});
...
...
@@ -586,17 +588,22 @@ function leaf_translation_v1(p0,p1){
dz
=
-
dz
;
}
var
da
=
Math
.
atan2
(
dz
,
dx
);
//transform to camera coordinates
var
A
=
Math
.
PI
/
180
*
INIT_HEADING
;
var
a
=
Math
.
atan2
(
dx
,
dz
);
var
A
=
Math
.
PI
/
180
*
INIT_HEADING
;
console
.
log
(
A
)
;
dx
=
dl
*
Math
.
sin
(
A
-
d
a
);
dz
=
-
dl
*
Math
.
cos
(
A
-
d
a
);
console
.
log
(
"dx="
+
dx
+
" dy="
+
dy
+
" dz="
+
dz
+
" A="
+
A
+
" da="
+
da
);
dx
=
-
dl
*
Math
.
sin
(
A
-
a
);
dz
=
-
dl
*
Math
.
cos
(
A
-
a
);
console
.
log
(
"dx="
+
dx
+
" dy="
+
dy
+
" dz="
+
dz
);
// translation over map = xz
x3dom_translation
(
dx
,
dy
,
dz
)
x3dom_translation
(
dx
,
dy
,
dz
);
// if not updated then moving in 3D scene will make it jump
Scene
.
old_view_translation
=
x3dom_getViewTranslation
(
Scene
.
element
);
}
...
...
js/x3dom_functions.js
View file @
401fc593
...
...
@@ -243,23 +243,42 @@ function x3dom_rotation(delta_a){
viewpoint
.
attr
(
"orientation"
,
AA
[
0
].
toString
()
+
" "
+
AA
[
1
]);
viewpoint
.
attr
(
"position"
,
from
.
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
from
.
toString
());
}
// horizontal?
function
x3dom_translation
(
dx
,
dy
,
dz
){
var
delta
=
new
x3dom
.
fields
.
SFVec3f
(
dx
,
dy
,
dz
);
var
mat
=
Scene
.
element
.
runtime
.
viewMatrix
().
inverse
();
var
tr
=
mat
.
e3
();
var
x
=
tr
.
x
+
dx
;
var
y
=
tr
.
y
+
dy
;
var
z
=
tr
.
z
+
dz
;
var
from
=
mat
.
e3
();
var
at
=
from
.
subtract
(
mat
.
e2
());
console
.
log
(
from
.
toString
());
var
newfrom
=
from
.
add
(
delta
);
console
.
log
(
newfrom
.
toString
());
var
newat
=
newfrom
.
subtract
(
mat
.
e2
());
var
up
=
mat
.
e1
();
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
(
"position"
,
x
+
" "
+
y
+
" "
+
z
);
viewpoint
.
attr
(
"centerOfRotation"
,
x
+
" "
+
y
+
" "
+
z
);
viewpoint
.
attr
(
"orientation"
,
AA
[
0
].
toString
()
+
" "
+
AA
[
1
]);
viewpoint
.
attr
(
"position"
,
newfrom
.
toString
());
viewpoint
.
attr
(
"centerOfRotation"
,
newfrom
.
toString
());
}
function
x3dom_altelev
(
alt
,
elev
){
...
...
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