Commit 7ac7ac50 authored by Rurik Bugdanov's avatar Rurik Bugdanov

Place a marker in the scene on map ctrl-click

(using view._scene._nameSpace.doc.ctx.pickValue())

The problem is that after changing the viewpoint the scene must be
rendered before calling pickValue() and that I do not know how to use
an offscreen scene with x3dom.

The workaround I found is to change the viewpoint on ctrl-mousemove over the
map, so that when the map is clicked, the scene needed for pickValue() is
already rendererd and pickvalue cam return the proper coordinates.

- change the viewpoint on keydown ctrl over the map (dont wait mousemove)
- implement code related to issue #4
- restore the original viewpoint when ctrl is released or
  on mouseleave map
- ...
parent 2beb976d
......@@ -546,6 +546,9 @@ function leaf_events(){
//console.log("map mousemove");
if (e.originalEvent.ctrlKey) {
......@@ -504,7 +504,7 @@ function x3dom_delta_map2scene(p0,p1){
var pi = new L.LatLng(,p1.lng);
var dx = p0.distanceTo(pi);
var dy = 0;
var dy = 10;
var dz = p1.distanceTo(pi);
var dp_rw = new x3dom.fields.SFVec3f(dx,dy,dz);
......@@ -513,9 +513,32 @@ function x3dom_delta_map2scene(p0,p1){
if (> dp_rw.z = -dp_rw.z;
var M0 =;
var dp_w = M0.multMatrixVec(dp_rw);
var dp_w0 = M0.multMatrixVec(dp_rw);
return dp_w;
var dp_w1 = M0.multMatrixVec(dp_rw);
var dir=dp_w0.subtract(dp_w1).normalize();
var up=new x3dom.fields.SFVec3f(0,0,-1);
var viewMat = x3dom.fields.SFMatrix4f.lookAt(dp_w0, dp_w1, M0.multMatrixVec(up));
var view=Scene.element.runtime.canvas.doc._viewarea;
var viewPoint=view._scene.getViewpoint();
var markers=$('.shapemarker');
view._scene._nameSpace.doc.ctx.pickValue(view, view._width/2, view._height/2);
if (view._pickingInfo.pickObj) {
var dist = view._pickingInfo.pickPos.subtract(dp_w0).length();
return M0.multMatrixVec(dp_rw);
return dp_w0;
......@@ -610,4 +633,3 @@ function x3dom_setViewpoint(m){ = m;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment