X3DOM是否有一种实现自定义相机导航的正确方法?当用户拖动缩放滑块时,我想放大,当用户拖过屏幕时,我想放大。X3DOM是否有调用pan()、缩放()或旋转()功能的API?
到目前为止,我可以想到三个解决方案,它们不是理想的解决方案:
document.getElementById("the_viewpoint").setAttribute("orientation", "some numbers here");<transform>的位置/旋转发布于 2017-01-27 05:53:47
看起来像此功能是最近添加的。,但是还没有得到适当的记录
公共关系包括以下例子:
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 to unbind when handler is anonymous function
x3dCanvas.canvas.addEventListener('mousewheel', x3dCanvas.onMouseWheel);
}https://stackoverflow.com/questions/30929849
复制相似问题