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
38c56432
Commit
38c56432
authored
Jul 26, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed zNear x3dom 1.7.2 bug?
parent
f7519622
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
6 deletions
+56
-6
x3dom_functions.js
js/x3dom_functions.js
+35
-3
x3dom_init.js
js/x3dom_init.js
+18
-2
viewer.html
viewer.html
+3
-1
No files found.
js/x3dom_functions.js
View file @
38c56432
...
...
@@ -60,6 +60,10 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
//console.log("That event:");
//console.log(Scene._stored_x3dom_event);
var
campos
=
x3dom_getCameraPosOr
();
var
xc
=
campos
.
x
;
var
yc
=
campos
.
y
;
var
zc
=
campos
.
z
;
var
shootRay
=
elem
.
runtime
.
shootRay
(
cnvx
,
cnvy
);
...
...
@@ -89,7 +93,13 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
y
=
shootRay
.
pickPosition
.
y
;
z
=
shootRay
.
pickPosition
.
z
;
dist_xz
=
Math
.
sqrt
(
x
*
x
+
z
*
z
);
var
xyz
=
zNear_bug_correction
([
x
,
y
,
z
]);
x
=
xyz
[
0
];
y
=
xyz
[
1
];
z
=
xyz
[
2
];
dist_xz
=
Math
.
sqrt
(
Math
.
pow
(
x
-
xc
,
2
)
+
Math
.
pow
(
z
-
zc
,
2
));
}
else
{
...
...
@@ -99,11 +109,11 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
dist_xz
=
Data
.
markers
[
index
].
d_x3d
;
if
(
isNaN
(
dist_xz
)){
dist_xz
=
Math
.
sqrt
(
x
*
x
+
z
*
z
)
;
dist_xz
=
Math
.
sqrt
(
Math
.
pow
(
x
-
xc
,
2
)
+
Math
.
pow
(
z
-
zc
,
2
));
;
}
}
dist_xyz
=
Math
.
sqrt
(
y
*
y
+
dist_xz
*
dist_xz
);
dist_xyz
=
Math
.
sqrt
(
Math
.
pow
(
y
-
yc
,
2
)
+
Math
.
pow
(
dist_xz
,
2
)
);
id
=
$
(
shootRay
.
pickObject
).
attr
(
"id"
);
...
...
@@ -214,6 +224,28 @@ function x3dom_getCameraPosOr(round){
}
/**
* Fix a bug with zNear in x3dom 1.7.2
*/
function
zNear_bug_correction
(
xyz
){
var
zNear
=
Scene
.
element
.
runtime
.
viewpoint
().
getNear
();
var
x
=
xyz
[
0
];
var
y
=
xyz
[
1
];
var
z
=
xyz
[
2
];
var
z1
=
z
+
zNear
;
var
zratio
=
z1
/
z
;
x
=
zratio
*
x
;
y
=
zratio
*
y
;
z
=
z1
;
return
[
x
,
y
,
z
];
}
// this upright is for world coordinates, not the camera's
// the up vector should be taken from the initial camera orientation in kml.
function
x3dom_setUpRight
(){
...
...
js/x3dom_init.js
View file @
38c56432
...
...
@@ -305,6 +305,12 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
var
y
=
e
.
originalEvent
.
worldY
;
var
z
=
e
.
originalEvent
.
worldZ
;
var
xyz
=
zNear_bug_correction
([
x
,
y
,
z
]);
x
=
xyz
[
0
];
y
=
xyz
[
1
];
z
=
xyz
[
2
];
// (not used atm) store x3dom event to use in normal events
self
.
_stored_x3dom_event
=
e
.
originalEvent
;
...
...
@@ -547,6 +553,13 @@ X3DOMObject.Marker.prototype.init = function(){
x
=
sr
.
pickPosition
.
x
;
y
=
sr
.
pickPosition
.
y
;
z
=
sr
.
pickPosition
.
z
;
var
xyz
=
zNear_bug_correction
([
x
,
y
,
z
]);
x
=
xyz
[
0
];
y
=
xyz
[
1
];
z
=
xyz
[
2
];
d1
=
Math
.
sqrt
(
x
*
x
+
z
*
z
);
if
((
d1
-
d0
)
<
0.1
){
...
...
@@ -879,10 +892,13 @@ X3DOMObject.Marker.mouseMove = function(event){
var
sphere
=
Scene
.
draggedTransformNode
.
parent
().
parent
();
var
index
=
parseInt
(
sphere
.
attr
(
"id"
).
substr
(
7
));
X3DOMObject
.
Marker
.
place
(
sr
.
pickPosition
.
x
,
sr
.
pickPosition
.
y
,
sr
.
pickPosition
.
z
,
"my-sph-"
+
index
);
var
xyz
=
[
sr
.
pickPosition
.
x
,
sr
.
pickPosition
.
y
,
sr
.
pickPosition
.
z
];
xyz
=
zNear_bug_correction
(
xyz
);
X3DOMObject
.
Marker
.
place
(
xyz
[
0
],
xyz
[
1
],
xyz
[
2
],
"my-sph-"
+
index
);
//console.log("got shape");
//Scene.draggedTransformNode
X3DOMObject
.
Marker
.
slide
(
index
,
sr
.
pickPosition
.
x
,
sr
.
pickPosition
.
y
,
sr
.
pickPosition
.
z
);
X3DOMObject
.
Marker
.
slide
(
index
,
xyz
[
0
],
xyz
[
1
],
xyz
[
2
]
);
X3DOMObject
.
displayInfo
(
event
);
X3DOMObject
.
displayViewInfo
(
event
);
...
...
viewer.html
View file @
38c56432
...
...
@@ -55,7 +55,9 @@
<x3d
id=
"x3d_id"
width=
'1600px'
height=
'800px'
showProgress=
"true"
showStat=
"false"
showLog=
"false"
disableDoubleClick=
"true"
keysEnabled=
"true"
>
<scene>
<navigationInfo
id=
"navInfo"
type=
'"examine"'
speed=
'0.01'
></navigationInfo>
<Viewpoint
fieldOfView=
'1'
position=
'0 0 0'
orientation=
'0 0 1 0'
></Viewpoint>
<Viewpoint
fieldOfView=
'1'
position=
'0 0 0'
orientation=
'0 0 1 0'
></Viewpoint>
<!-- in x3dom 1.7.2 - big zNear does not work properly -->
<!--<Viewpoint fieldOfView='1' position='0 0 0' orientation='0 0 1 0' zNear='2'></Viewpoint>-->
<!-- <group>
<inline name="back" namespacename="back" url="models/m1/v1/background.x3d"/>
</group>-->
...
...
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