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
65c3858d
Commit
65c3858d
authored
Jul 26, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. update pointer marker pars 2. camera dragging over map != dragging over scene?
parent
760d94bb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
136 deletions
+99
-136
ui_init.js
js/ui_init.js
+22
-20
x3dom_functions.js
js/x3dom_functions.js
+36
-35
x3dom_init.js
js/x3dom_init.js
+41
-81
No files found.
js/ui_init.js
View file @
65c3858d
...
@@ -51,7 +51,7 @@ var SETTINGS = {
...
@@ -51,7 +51,7 @@ var SETTINGS = {
'moreinfo'
:
true
,
'moreinfo'
:
true
,
'crosshair'
:
false
,
'crosshair'
:
false
,
'shiftspeed'
:
0.01
,
'shiftspeed'
:
0.01
,
'markersize'
:
2
,
'markersize'
:
1
,
'markercolor'
:
"#1f1"
,
'markercolor'
:
"#1f1"
,
'slidingdrag'
:
true
,
'slidingdrag'
:
true
,
'basepath'
:
"models"
,
'basepath'
:
"models"
,
...
@@ -474,8 +474,7 @@ function x3d_events(){
...
@@ -474,8 +474,7 @@ function x3d_events(){
elem
.
addEventListener
(
'keydown'
,
function
(
e
){
elem
.
addEventListener
(
'keydown'
,
function
(
e
){
//console.log("scene keydown");
// 'shift' is for shapes toggling
if
((
e
.
key
==
"Shift"
)
||
(
SETTINGS
.
highlight
&&!
SETTINGS
.
pointer
)){
if
((
e
.
key
==
"Shift"
)
||
(
SETTINGS
.
highlight
&&!
SETTINGS
.
pointer
)){
// select shape
// select shape
var
sr
=
elem
.
runtime
.
shootRay
(
e
.
path
[
0
].
mouse_drag_x
,
e
.
path
[
0
].
mouse_drag_y
);
var
sr
=
elem
.
runtime
.
shootRay
(
e
.
path
[
0
].
mouse_drag_x
,
e
.
path
[
0
].
mouse_drag_y
);
...
@@ -487,8 +486,11 @@ function x3d_events(){
...
@@ -487,8 +486,11 @@ function x3d_events(){
}
}
// sliding marker
if
(
e
.
key
==
"Control"
){
if
(
e
.
key
==
"Control"
){
X3DOMObject
.
PointerMarker
.
updatePars
();
Scene
.
_ctrlKey
=
true
;
Scene
.
_ctrlKey
=
true
;
var
x
,
y
,
z
;
var
x
,
y
,
z
;
...
@@ -501,7 +503,10 @@ function x3d_events(){
...
@@ -501,7 +503,10 @@ function x3d_events(){
dist
=
parseFloat
(
mouse
.
d_xz
);
dist
=
parseFloat
(
mouse
.
d_xz
);
X3DOMObject
.
Marker
.
place
(
mouse
.
x
,
mouse
.
y
,
mouse
.
z
,
"sliding_sphere"
);
X3DOMObject
.
Marker
.
place
(
mouse
.
x
,
mouse
.
y
,
mouse
.
z
,
"sliding_sphere"
);
if
(
Scene
.
highlighted_marker_index
==
null
)
$
(
"#sliding_sphere"
).
find
(
"switch"
).
attr
(
"whichChoice"
,
0
);
if
(
Scene
.
highlighted_marker_index
==
null
)
{
$
(
"#sliding_sphere"
).
find
(
"switch"
).
attr
(
"whichChoice"
,
0
);
}
}
}
...
@@ -513,8 +518,8 @@ function x3d_events(){
...
@@ -513,8 +518,8 @@ function x3d_events(){
elem
.
addEventListener
(
'keyup'
,
function
(
e
){
elem
.
addEventListener
(
'keyup'
,
function
(
e
){
// 'shift' is for shapes toggling
if
(
e
.
key
==
"Shift"
){
if
(
e
.
key
==
"Shift"
){
// select shape
var
sr
=
elem
.
runtime
.
shootRay
(
e
.
path
[
0
].
mouse_drag_x
,
e
.
path
[
0
].
mouse_drag_y
);
var
sr
=
elem
.
runtime
.
shootRay
(
e
.
path
[
0
].
mouse_drag_x
,
e
.
path
[
0
].
mouse_drag_y
);
X3DOMObject
.
Shape
.
dehighlight
(
sr
.
pickObject
);
X3DOMObject
.
Shape
.
dehighlight
(
sr
.
pickObject
);
}
}
...
@@ -558,9 +563,11 @@ function x3d_events(){
...
@@ -558,9 +563,11 @@ function x3d_events(){
//2: new
//2: new
if
(
!
e
.
target
)
e
.
target
=
Scene
.
element
;
if
(
!
e
.
target
)
e
.
target
=
Scene
.
element
;
var
mouse_position
=
Scene
.
element
.
runtime
.
mousePosition
(
e
);
var
mouse_position
=
Scene
.
element
.
runtime
.
mousePosition
(
e
);
var
camera
=
x3dom_getCameraPosOr
(
mouse_position
[
0
],
mouse_position
[
1
],
false
);
var
camera
=
x3dom_getCameraPosOr
(
mouse_position
[
0
],
mouse_position
[
1
],
false
);
// these functions belong to 'leaflet.camera-view-marker.js'
Map
.
marker
.
setAltitude
(
camera
.
y
);
Map
.
marker
.
setAltitude
(
camera
.
y
);
Map
.
marker
.
setElevation
(
camera
.
e
*
Math
.
PI
/
180
);
Map
.
marker
.
setElevation
(
camera
.
e
*
Math
.
PI
/
180
);
...
@@ -569,29 +576,22 @@ function x3d_events(){
...
@@ -569,29 +576,22 @@ function x3d_events(){
if
(
SETTINGS
.
highlight
&&!
SETTINGS
.
pointer
){
if
(
SETTINGS
.
highlight
&&!
SETTINGS
.
pointer
){
var
sr
=
elem
.
runtime
.
shootRay
(
e
.
path
[
0
].
mouse_drag_x
,
e
.
path
[
0
].
mouse_drag_y
);
// this is for highlighting, no need to correct zNear bug
X3DOMObject
.
Shape
.
highlight
(
sr
.
pickObject
);
var
sr
=
elem
.
runtime
.
shootRay
(
e
.
path
[
0
].
mouse_drag_x
,
e
.
path
[
0
].
mouse_drag_y
);
X3DOMObject
.
Shape
.
highlight
(
sr
.
pickObject
);
}
}
if
((
Scene
.
_ctrlKey
)
||
(
SETTINGS
.
pointer
)){
if
((
Scene
.
_ctrlKey
)
||
(
SETTINGS
.
pointer
)){
// show shadow marker
// sliding marker
//1: old
var
mouse
=
x3dom_getXYPosOr
(
mouse_position
[
0
],
mouse_position
[
1
],
false
);
//var mouse = x3dom_getXYPosOr(e.clientX,e.clientY,false);
var
dist
=
parseFloat
(
mouse
.
d_xz
)
||
1116
;
Map
.
marker
.
placeSlidingMarker
(
mouse
.
a
,
dist
);
//2: new
//if (!e.target) e.target = Scene.element;
//var mouse_position = Scene.element.runtime.mousePosition(e);
var
mouse
=
x3dom_getXYPosOr
(
mouse_position
[
0
],
mouse_position
[
1
],
false
);
var
dist
=
parseFloat
(
mouse
.
d_xz
)
||
1116
;
Map
.
marker
.
placeSlidingMarker
(
mouse
.
a
,
dist
);
}
else
{
}
else
{
// hide s
hadow
marker
// hide s
liding
marker
Map
.
marker
.
removeSlidingMarker
();
Map
.
marker
.
removeSlidingMarker
();
}
}
...
@@ -685,6 +685,7 @@ function leaf_events(){
...
@@ -685,6 +685,7 @@ function leaf_events(){
X3DOMObject
.
displayMarkInfo
(
Data
.
markers
.
length
-
1
);
X3DOMObject
.
displayMarkInfo
(
Data
.
markers
.
length
-
1
);
// note: the 2nd place where marker is created is in x3dom_init.js (createNewMarker)
//new X3DOMObject.Marker(mark.x,mark.y,mark.z,true);
//new X3DOMObject.Marker(mark.x,mark.y,mark.z,true);
new
X3DOMObject
.
Marker
(
mark
.
x
,
mark
.
y
,
mark
.
z
,
false
);
new
X3DOMObject
.
Marker
(
mark
.
x
,
mark
.
y
,
mark
.
z
,
false
);
...
@@ -731,6 +732,7 @@ function leaf_mouseup(e){
...
@@ -731,6 +732,7 @@ function leaf_mouseup(e){
function
leaf_mousemove
(
e
){
function
leaf_mousemove
(
e
){
var
Camera
=
Map
.
marker
;
var
Camera
=
Map
.
marker
;
if
(
Camera
.
draggedMarker
.
_index
!=
null
){
if
(
Camera
.
draggedMarker
.
_index
!=
null
){
var
index
=
Camera
.
draggedMarker
.
_index
;
var
index
=
Camera
.
draggedMarker
.
_index
;
var
elem
=
$
(
"#my-sph-"
+
index
);
var
elem
=
$
(
"#my-sph-"
+
index
);
...
...
js/x3dom_functions.js
View file @
65c3858d
...
@@ -52,23 +52,26 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
...
@@ -52,23 +52,26 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
var
elem
=
Scene
.
element
;
var
elem
=
Scene
.
element
;
var
x
,
y
,
z
;
var
x
,
y
,
z
;
var
xc
,
yc
,
zc
;
var
az
,
el
,
sk
;
var
az
,
el
,
sk
;
var
id
;
var
id
;
var
dist_xyz
=
1112
;
var
dist_xyz
=
1112
;
var
dist_xz
=
1113
;
var
dist_xz
=
1113
;
//console.log("That event:");
var
valid_distance
;
//console.log(Scene._stored_x3dom_event);
// camera coordinates, not correcting with zNear
var
campos
=
x3dom_getCameraPosOr
();
var
campos
=
x3dom_getCameraPosOr
();
var
xc
=
campos
.
x
;
xc
=
campos
.
x
;
var
yc
=
campos
.
y
;
yc
=
campos
.
y
;
var
zc
=
campos
.
z
;
zc
=
campos
.
z
;
// shoot ray based on canvas coordinates
// if hits a shape > .pickPosition and .pickObject
var
shootRay
=
elem
.
runtime
.
shootRay
(
cnvx
,
cnvy
);
var
shootRay
=
elem
.
runtime
.
shootRay
(
cnvx
,
cnvy
);
var
valid_distance
=
true
;
// check infinity shape
// check infinity shape
if
(
shootRay
.
pickPosition
!=
null
){
if
(
shootRay
.
pickPosition
!=
null
){
if
(
$
(
shootRay
.
pickObject
).
hasClass
(
'INFINITY'
)){
if
(
$
(
shootRay
.
pickObject
).
hasClass
(
'INFINITY'
)){
...
@@ -80,75 +83,70 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
...
@@ -80,75 +83,70 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
var
index
=
Scene
.
highlighted_marker_index
;
var
index
=
Scene
.
highlighted_marker_index
;
// didn't hit a marker?
if
(
index
==
null
){
if
(
index
==
null
){
// some marker being dragged but the mouse is not over it. If yes - update index
if
((
Scene
.
draggedTransformNode
!=
undefined
)
&&
(
Scene
.
draggedTransformNode
!=
null
)){
if
((
Scene
.
draggedTransformNode
!=
undefined
)
&&
(
Scene
.
draggedTransformNode
!=
null
)){
var
sphere
=
Scene
.
draggedTransformNode
.
parent
().
parent
();
var
sphere
=
Scene
.
draggedTransformNode
.
parent
().
parent
();
index
=
parseInt
(
sphere
.
attr
(
"id"
).
substr
(
7
));
index
=
parseInt
(
sphere
.
attr
(
"id"
).
substr
(
7
));
}
}
}
}
// didn't hit marker
if
((
index
==
null
)
||
(
Data
.
markers
[
index
]
==
undefined
)){
if
((
index
==
null
)
||
(
Data
.
markers
[
index
]
==
undefined
)){
x
=
shootRay
.
pickPosition
.
x
;
// needs zNear bug correction
y
=
shootRay
.
pickPosition
.
y
;
var
xyz
=
zNear_bug_correction
([
shootRay
.
pickPosition
.
x
,
shootRay
.
pickPosition
.
y
,
shootRay
.
pickPosition
.
z
]);
z
=
shootRay
.
pickPosition
.
z
;
var
xyz
=
zNear_bug_correction
([
x
,
y
,
z
]);
x
=
xyz
[
0
];
x
=
xyz
[
0
];
y
=
xyz
[
1
];
y
=
xyz
[
1
];
z
=
xyz
[
2
];
z
=
xyz
[
2
];
//dist_xz = Math.sqrt(Math.pow(x-xc,2)+Math.pow(z-zc,2));
}
else
{
}
else
{
// zNear bug is already corrected
x
=
Data
.
markers
[
index
].
x
;
x
=
Data
.
markers
[
index
].
x
;
y
=
Data
.
markers
[
index
].
y
;
y
=
Data
.
markers
[
index
].
y
;
z
=
Data
.
markers
[
index
].
z
;
z
=
Data
.
markers
[
index
].
z
;
/*
dist_xz = Data.markers[index].d_x3d;
if (isNaN(dist_xz)){
dist_xz = Math.sqrt(Math.pow(x-xc,2)+Math.pow(z-zc,2));;
}
*/
}
}
//dist_xyz = Math.sqrt(Math.pow(y-yc,2)+Math.pow(dist_xz,2));
id
=
$
(
shootRay
.
pickObject
).
attr
(
"id"
);
id
=
$
(
shootRay
.
pickObject
).
attr
(
"id"
);
valid_distance
=
true
;
}
else
{
}
else
{
// returns a |1| viewing direction based on canvas coordinates
var
viewingRay
=
elem
.
runtime
.
getViewingRay
(
cnvx
,
cnvy
);
var
viewingRay
=
elem
.
runtime
.
getViewingRay
(
cnvx
,
cnvy
);
x
=
viewingRay
.
dir
.
x
;
x
=
viewingRay
.
dir
.
x
;
y
=
viewingRay
.
dir
.
y
;
y
=
viewingRay
.
dir
.
y
;
z
=
viewingRay
.
dir
.
z
;
z
=
viewingRay
.
dir
.
z
;
//dist_xz = null;
//dist_xyz = null;
valid_distance
=
false
;
valid_distance
=
false
;
}
}
// to get XZ(horizontal) distance - convert to real world coordinates
var
R0
=
Data
.
camera
.
Matrices
.
R0
;
var
R0
=
Data
.
camera
.
Matrices
.
R0
;
var
p_w
=
new
x3dom
.
fields
.
SFVec3f
(
x
-
xc
,
y
-
yc
,
z
-
zc
);
var
p_w
=
new
x3dom
.
fields
.
SFVec3f
(
x
-
xc
,
y
-
yc
,
z
-
zc
);
var
p_rw
=
R0
.
multMatrixVec
(
p_w
);
var
p_rw
=
R0
.
multMatrixVec
(
p_w
);
if
(
valid_distance
){
if
(
valid_distance
){
dist_xz
=
Math
.
sqrt
(
p_rw
.
x
*
p_rw
.
x
+
p_rw
.
z
*
p_rw
.
z
);
dist_xz
=
Math
.
sqrt
(
Math
.
pow
(
p_rw
.
x
,
2
)
+
Math
.
pow
(
p_rw
.
z
,
2
)
);
dist_xyz
=
Math
.
sqrt
(
p_rw
.
y
*
p_rw
.
y
+
dist_xz
*
dist_xz
);
dist_xyz
=
Math
.
sqrt
(
Math
.
pow
(
p_rw
.
y
,
2
)
+
Math
.
pow
(
dist_xz
,
2
)
);
}
else
{
}
else
{
dist_xz
=
null
;
dist_xz
=
null
;
dist_xyz
=
null
;
dist_xyz
=
null
;
}
}
// azimuth, elevation and skew are relative to the camera location
az
=
Math
.
atan2
(
p_rw
.
x
,
-
p_rw
.
z
)
*
180
/
Math
.
PI
;
az
=
Math
.
atan2
(
p_rw
.
x
,
-
p_rw
.
z
)
*
180
/
Math
.
PI
;
az
=
(
az
+
360
)
%
360
;
az
=
(
az
+
360
)
%
360
;
el
=
Math
.
atan2
(
p_rw
.
y
,
Math
.
sqrt
(
p_rw
.
x
*
p_rw
.
x
+
p_rw
.
z
*
p_rw
.
z
))
*
180
/
Math
.
PI
;
el
=
Math
.
atan2
(
p_rw
.
y
,
Math
.
sqrt
(
p_rw
.
x
*
p_rw
.
x
+
p_rw
.
z
*
p_rw
.
z
))
*
180
/
Math
.
PI
;
sk
=
0
;
sk
=
0
;
// fill out the output
var
result
=
{
var
result
=
{
x
:
!
round
?
x
:
x
.
toFixed
(
2
),
x
:
!
round
?
x
:
x
.
toFixed
(
2
),
y
:
!
round
?
y
:
y
.
toFixed
(
2
),
y
:
!
round
?
y
:
y
.
toFixed
(
2
),
...
@@ -180,8 +178,6 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
...
@@ -180,8 +178,6 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
*/
*/
function
x3dom_getCameraPosOr
(
round
){
function
x3dom_getCameraPosOr
(
round
){
//console.log("Getting PosOr");
var
elem
=
Scene
.
element
;
var
elem
=
Scene
.
element
;
var
m
=
elem
.
runtime
.
viewMatrix
().
inverse
();
var
m
=
elem
.
runtime
.
viewMatrix
().
inverse
();
...
@@ -203,20 +199,24 @@ function x3dom_getCameraPosOr(round){
...
@@ -203,20 +199,24 @@ function x3dom_getCameraPosOr(round){
//x3dom_matrix_test();
//x3dom_matrix_test();
var
x
=
tr
.
x
;
var
y
=
tr
.
y
;
var
z
=
tr
.
z
;
if
(
!
round
){
if
(
!
round
){
return
{
return
{
x
:
tr
.
x
,
x
:
x
,
y
:
tr
.
y
,
y
:
y
,
z
:
tr
.
z
,
z
:
z
,
a
:
ypr
.
yaw
,
a
:
ypr
.
yaw
,
e
:
ypr
.
pitch
,
e
:
ypr
.
pitch
,
s
:
ypr
.
roll
s
:
ypr
.
roll
};
};
}
else
{
}
else
{
return
{
return
{
x
:
tr
.
x
.
toFixed
(
2
),
x
:
x
.
toFixed
(
2
),
y
:
tr
.
y
.
toFixed
(
2
),
y
:
y
.
toFixed
(
2
),
z
:
tr
.
z
.
toFixed
(
2
),
z
:
z
.
toFixed
(
2
),
a
:
ypr
.
yaw
.
toFixed
(
1
),
a
:
ypr
.
yaw
.
toFixed
(
1
),
e
:
ypr
.
pitch
.
toFixed
(
1
),
e
:
ypr
.
pitch
.
toFixed
(
1
),
s
:
ypr
.
roll
.
toFixed
(
1
)
s
:
ypr
.
roll
.
toFixed
(
1
)
...
@@ -244,6 +244,7 @@ function zNear_bug_correction(xyz){
...
@@ -244,6 +244,7 @@ function zNear_bug_correction(xyz){
z
=
z1
;
z
=
z1
;
return
[
x
,
y
,
z
];
return
[
x
,
y
,
z
];
//return xyz;
}
}
...
...
js/x3dom_init.js
View file @
65c3858d
...
@@ -317,9 +317,7 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
...
@@ -317,9 +317,7 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
if
(
self
.
_ctrlKey
||
SETTINGS
.
pointer
){
if
(
self
.
_ctrlKey
||
SETTINGS
.
pointer
){
// place pointer marker
// place pointer marker
$
(
"#sliding_sphere"
).
find
(
'material'
).
attr
(
"diffuseColor"
,
convert_color_l2x
(
SETTINGS
.
markercolor
));
X3DOMObject
.
PointerMarker
.
updatePars
();
$
(
"#sliding_sphere"
).
find
(
'material'
).
attr
(
"transparency"
,
"0.2"
);
$
(
"#sliding_sphere"
).
find
(
'Sphere'
).
attr
(
"radius"
,
SETTINGS
.
markersize
/
2
);
X3DOMObject
.
Marker
.
place
(
x
,
y
,
z
,
"sliding_sphere"
);
X3DOMObject
.
Marker
.
place
(
x
,
y
,
z
,
"sliding_sphere"
);
$
(
"#sliding_sphere"
).
find
(
"switch"
).
attr
(
"whichChoice"
,
0
);
$
(
"#sliding_sphere"
).
find
(
"switch"
).
attr
(
"whichChoice"
,
0
);
...
@@ -362,7 +360,17 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
...
@@ -362,7 +360,17 @@ X3DOMObject.Shape.prototype._registerEvents = function(){
if
(
self
.
_ctrlKey
){
if
(
self
.
_ctrlKey
){
X3DOMObject
.
createNewMarker
(
e
.
originalEvent
.
worldX
,
e
.
originalEvent
.
worldY
,
e
.
originalEvent
.
worldZ
);
var
x
=
e
.
originalEvent
.
worldX
;
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
];
X3DOMObject
.
createNewMarker
(
x
,
y
,
z
);
}
}
...
@@ -451,6 +459,9 @@ X3DOMObject.Shape.deselect = function(elem){
...
@@ -451,6 +459,9 @@ X3DOMObject.Shape.deselect = function(elem){
}
}
/**
* Create marker at x,y,z (need global)
*/
X3DOMObject
.
prototype
.
createMarker
=
function
(
x
,
y
,
z
,
id
){
X3DOMObject
.
prototype
.
createMarker
=
function
(
x
,
y
,
z
,
id
){
var
self
=
this
;
var
self
=
this
;
...
@@ -530,6 +541,7 @@ X3DOMObject.Marker = function(x,y,z,ylevel){
...
@@ -530,6 +541,7 @@ X3DOMObject.Marker = function(x,y,z,ylevel){
X3DOMObject
.
Marker
.
prototype
.
init
=
function
(){
X3DOMObject
.
Marker
.
prototype
.
init
=
function
(){
// this branch is experimental and inactive
if
(
this
.
_ylevel
){
if
(
this
.
_ylevel
){
//console.log(this._x+" "+this._y+" "+this._z);
//console.log(this._x+" "+this._y+" "+this._z);
...
@@ -572,81 +584,6 @@ X3DOMObject.Marker.prototype.init = function(){
...
@@ -572,81 +584,6 @@ X3DOMObject.Marker.prototype.init = function(){
}
}
/*
//var from = new x3dom.fields.SFVec3f(this._x, 100, this._z);
var from = new x3dom.fields.SFVec3f(0, 0, 0);
//var at = new x3dom.fields.SFVec3f(this._x, -100, this._z);
var dir = new x3dom.fields.SFVec3f(0, -0, -1);//at.subtract(from);
// dir gets auto normalized
var vray = new x3dom.fields.Ray(from, dir);
//var vray = Scene.element.runtime.getViewingRay(0,0);
console.log(vray);
var scene = Scene.element.runtime.canvas.doc._scene;
var info = Scene.element.runtime.canvas.doc._viewarea._pickingInfo;
console.log(Scene.element.runtime.pickMode());
//console.log(Scene.element.runtime.changePickMode('idbuf'));
//console.log(Scene.element.runtime.changePickMode('color'));
console.log(Scene.element.runtime.changePickMode('texcoord'));
//console.log(Scene.element.runtime.changePickMode('box'));
console.log(Scene.element.runtime.pickMode());
var isect = scene.doIntersect(vray);
console.log(info);
console.log("vr");
console.log(vray);
if (vray.hitObject!=null){
console.log($(vray.hitObject._xmlNode).parent().find("ImageTexture").attr("url"));
var el = $(vray.hitObject._xmlNode).parent();
var bbox = Scene.element.runtime.getSceneBBox();
console.log(bbox);
this._x = vray.hitPoint.x;
this._y = vray.hitPoint.y;
this._z = vray.hitPoint.z;
}
*/
/*
// sane output
console.log("scene bbox");
var bbox = Scene.element.runtime.getSceneBBox();
console.log(bbox);
*/
/*
var sr = Scene.element.runtime.shootRay(1000,450);
console.log("sr");
console.log(sr);
*/
/*
//while(vray.hitPoint.y>-100){
var n=0;
while(n<1000){
var from = new x3dom.fields.SFVec3f(vray.hitPoint.x,vray.hitPoint.y-0.1,vray.hitPoint.z);
var at = new x3dom.fields.SFVec3f(vray.hitPoint.x, -100, vray.hitPoint.z);
var dir = at.subtract(from).normalize();
var vray = new x3dom.fields.Ray(from, dir);
var isect = scene.doIntersect(vray);
console.log(vray);
n++;
}
*/
//do intersect
//hitobject
//get y
}
}
this
.
_elem
=
Scene
.
createMarker
(
this
.
_x
,
this
.
_y
,
this
.
_z
);
this
.
_elem
=
Scene
.
createMarker
(
this
.
_x
,
this
.
_y
,
this
.
_z
);
...
@@ -892,6 +829,7 @@ X3DOMObject.Marker.mouseMove = function(event){
...
@@ -892,6 +829,7 @@ X3DOMObject.Marker.mouseMove = function(event){
var
sphere
=
Scene
.
draggedTransformNode
.
parent
().
parent
();
var
sphere
=
Scene
.
draggedTransformNode
.
parent
().
parent
();
var
index
=
parseInt
(
sphere
.
attr
(
"id"
).
substr
(
7
));
var
index
=
parseInt
(
sphere
.
attr
(
"id"
).
substr
(
7
));
// zNear bug correction
var
xyz
=
[
sr
.
pickPosition
.
x
,
sr
.
pickPosition
.
y
,
sr
.
pickPosition
.
z
];
var
xyz
=
[
sr
.
pickPosition
.
x
,
sr
.
pickPosition
.
y
,
sr
.
pickPosition
.
z
];
xyz
=
zNear_bug_correction
(
xyz
);
xyz
=
zNear_bug_correction
(
xyz
);
...
@@ -932,7 +870,13 @@ X3DOMObject.Marker.drag = function(dx,dy){
...
@@ -932,7 +870,13 @@ X3DOMObject.Marker.drag = function(dx,dy){
X3DOMObject
.
Marker
.
slide
=
function
(
index
,
x
,
y
,
z
){
X3DOMObject
.
Marker
.
slide
=
function
(
index
,
x
,
y
,
z
){
var
da
=
x3dom_getDistAngle
(
x
,
y
,
z
);
// camera coordinates, not correcting with zNear
var
campos
=
x3dom_getCameraPosOr
();
xc
=
campos
.
x
;
yc
=
campos
.
y
;
zc
=
campos
.
z
;
var
da
=
x3dom_getDistAngle
(
x
-
xc
,
y
-
yc
,
z
-
zc
);
var
distance
=
da
[
0
];
var
distance
=
da
[
0
];
var
angle
=
da
[
1
];
var
angle
=
da
[
1
];
...
@@ -1013,6 +957,15 @@ X3DOMObject.PointerMarker.prototype._init = function(){
...
@@ -1013,6 +957,15 @@ X3DOMObject.PointerMarker.prototype._init = function(){
}
}
X3DOMObject
.
PointerMarker
.
updatePars
=
function
(){
// place pointer marker
$
(
"#sliding_sphere"
).
find
(
'material'
).
attr
(
"diffuseColor"
,
convert_color_l2x
(
SETTINGS
.
markercolor
));
$
(
"#sliding_sphere"
).
find
(
'material'
).
attr
(
"transparency"
,
"0.2"
);
$
(
"#sliding_sphere"
).
find
(
'Sphere'
).
attr
(
"radius"
,
SETTINGS
.
markersize
/
2
);
}
X3DOMObject
.
PointerMarker
.
prototype
.
_registerEvents
=
function
(){
X3DOMObject
.
PointerMarker
.
prototype
.
_registerEvents
=
function
(){
var
self
=
this
;
var
self
=
this
;
...
@@ -1413,7 +1366,14 @@ X3DOMObject.createNewMarker = function(x,y,z){
...
@@ -1413,7 +1366,14 @@ X3DOMObject.createNewMarker = function(x,y,z){
// Create marker on the scene
// Create marker on the scene
new
X3DOMObject
.
Marker
(
mark
.
x
,
mark
.
y
,
mark
.
z
);
new
X3DOMObject
.
Marker
(
mark
.
x
,
mark
.
y
,
mark
.
z
);
var
da
=
x3dom_getDistAngle
(
mark
.
x
,
mark
.
y
,
mark
.
z
);
// camera coordinates, not correcting with zNear
var
campos
=
x3dom_getCameraPosOr
();
xc
=
campos
.
x
;
yc
=
campos
.
y
;
zc
=
campos
.
z
;
// calculate relative to the camera base
var
da
=
x3dom_getDistAngle
(
mark
.
x
-
xc
,
mark
.
y
-
yc
,
mark
.
z
-
zc
);
var
distance
=
da
[
0
];
var
distance
=
da
[
0
];
var
angle
=
da
[
1
];
var
angle
=
da
[
1
];
...
...
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