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
5746e1ca
Commit
5746e1ca
authored
Jul 28, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zNear fix
parent
8a308371
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
1 deletion
+75
-1
ui_init.js
js/ui_init.js
+32
-0
x3dom_functions.js
js/x3dom_functions.js
+39
-1
x3dom_init.js
js/x3dom_init.js
+4
-0
No files found.
js/ui_init.js
View file @
5746e1ca
...
...
@@ -489,6 +489,8 @@ function x3d_events(){
// sliding marker
if
(
e
.
key
==
"Control"
){
//console.log("Control!");
X3DOMObject
.
PointerMarker
.
updatePars
();
Scene
.
_ctrlKey
=
true
;
...
...
@@ -512,6 +514,36 @@ function x3d_events(){
Map
.
marker
.
placeSlidingMarker
(
mouse
.
a
,
dist
);
/*
// Debugging
console.log("Canvas event:");
console.log(e);
console.log("Page coordinates: x:"+e.path[0].mouse_drag_x+" y:"+e.path[0].mouse_drag_y);
//shoot a ray
var cnvx = e.path[0].mouse_drag_x;
var cnvy = e.path[0].mouse_drag_y;
var shootRay = elem.runtime.shootRay(cnvx,cnvy);
var pickPos = shootRay.pickPosition;
console.log("Shoot ray: "+pickPos.toString());
var tmp0 = elem.runtime.calcCanvasPos(pickPos.x,pickPos.y,pickPos.z);
console.log("calcCanvasPos from x,y,z = "+tmp0.toString());
var mat1 = elem.runtime.getWorldToCameraCoordinatesMatrix();
var mat2 = elem.runtime.getCameraToWorldCoordinatesMatrix();
//var w =;
var vr = elem.runtime.getViewingRay(cnvx,cnvy);
console.log("Viewing ray: "+vr.toString());
*/
}
},
true
);
...
...
js/x3dom_functions.js
View file @
5746e1ca
...
...
@@ -230,8 +230,25 @@ function x3dom_getCameraPosOr(round){
*/
function
zNear_bug_correction
(
xyz
){
//var mat = Scene.element.runtime.viewMatrix().inverse();
var
mat
=
Scene
.
element
.
runtime
.
viewMatrix
();
var
mat1
=
Scene
.
element
.
runtime
.
getWorldToCameraCoordinatesMatrix
();
var
mat2
=
Scene
.
element
.
runtime
.
getCameraToWorldCoordinatesMatrix
();
/*
console.log("wctocc");
console.log(mat1.toString());
console.log("cctowc");
console.log(mat2.toString());
*/
var
zNear
=
Scene
.
element
.
runtime
.
viewpoint
().
getNear
();
//console.log("zNear: "+zNear);
var
vec
=
new
x3dom
.
fields
.
SFVec3f
(
xyz
[
0
],
xyz
[
1
],
xyz
[
2
]);
var
x
=
xyz
[
0
];
var
y
=
xyz
[
1
];
var
z
=
xyz
[
2
];
...
...
@@ -243,7 +260,28 @@ function zNear_bug_correction(xyz){
y
=
zratio
*
y
;
z
=
z1
;
return
[
x
,
y
,
z
];
// console.log("v1: "+x+" "+y+" "+z);
var
vec_cam
=
mat
.
multFullMatrixPnt
(
vec
);
var
z1
=
vec_cam
.
z
+
zNear
;
var
zratio
=
z1
/
vec_cam
.
z
;
// console.log("initial coordinates: "+vec.toString());
// console.log("camera coordinates: "+vec_cam.toString());
//console.log("z1: "+z1+" zratio: "+zratio);
vec_cam
.
x
=
zratio
*
vec_cam
.
x
;
vec_cam
.
y
=
zratio
*
vec_cam
.
y
;
vec_cam
.
z
=
z1
;
vec_w
=
mat
.
inverse
().
multFullMatrixPnt
(
vec_cam
);
//console.log("world coordinates: "+vec_w.toString());
return
[
vec_w
.
x
,
vec_w
.
y
,
vec_w
.
z
];
//return [x,y,z];
//return xyz;
}
...
...
js/x3dom_init.js
View file @
5746e1ca
...
...
@@ -374,6 +374,10 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
}
console
.
log
(
"Shape event: "
);
console
.
log
(
" canvas: x= "
+
e
.
originalEvent
.
layerX
+
" y= "
+
e
.
originalEvent
.
layerY
);
console
.
log
(
" scene: x= "
+
e
.
originalEvent
.
worldX
+
" y= "
+
e
.
originalEvent
.
worldY
+
" z="
+
e
.
originalEvent
.
worldZ
);
});
$
(
this
.
_elem
).
on
(
"mouseover"
,
function
(
e
){
...
...
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