x3d - X3DOM Custom Navigation -


does x3dom have proper way of implementing custom camera navigation? zoom when user drags zoom slider , pan when user drags across screen. x3dom have api calling pan(), zoom(), or rotate() funcitons?

so far think of 3 workarounds, not ideal solutions:

  1. change viewpoint attributes manually:

    document.getelementbyid("the_viewpoint").setattribute("orientation", "some numbers here");

  2. keep viewpoint fixed , change position/rotation of <transform>, contains whole 3d world

  3. reroute events. example, when user slides zoom slider, fire mousewheel event zoom.

looks this functionality added recently, has yet documented

the pr includes example:

var d = function(selector) { return document.queryselector(selector)}  x3dom.runtime.ready = function() {     var x3d = d('x3d');     var viewpoint = d('viewpoint');     var x3dcanvas = x3d.runtime.canvas;      var _onmousewheel = x3dcanvas.onmousewheel;      x3dcanvas.onmousewheel = function(event) {         if(event.altkey) {             var offset = .01             var fov = parsefloat(viewpoint.getattribute('fieldofview')) || 1.571;              if(event.wheeldelta < 0) offset = -offset;             fov = math.min(2, math.max(0, fov+offset));              viewpoint.setattribute('fieldofview', fov)          } else {             _onmousewheel.call(this, event);         }     }      x3dcanvas.canvas.removeeventlistener('mousewheel', _onmousewheel); // unable unbind when handler anonymous function      x3dcanvas.canvas.addeventlistener('mousewheel', x3dcanvas.onmousewheel); } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -