|
@@ -48,7 +48,7 @@ export class InputHandler extends EventDispatcher {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+ this.touches = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -94,66 +94,133 @@ export class InputHandler extends EventDispatcher {
|
|
return ib - ia;
|
|
return ib - ia;
|
|
});
|
|
});
|
|
} */
|
|
} */
|
|
-
|
|
|
|
|
|
+ //统一跟第一个触碰的viewport相同
|
|
|
|
+ updateTouchesInfo(e){
|
|
|
|
+ var viewport, pointer, camera
|
|
|
|
+ let oldTouches = this.touches
|
|
|
|
+
|
|
|
|
+ this.touches = Array.from(e.touches).map(touch=>{
|
|
|
|
+ let touch_ = oldTouches.find(a=>a.touch.identifier == touch.identifier)
|
|
|
|
+ let pointer = touch_ && touch_.pointer //复制原先的值
|
|
|
|
+ return {
|
|
|
|
+ touch, pointer,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ if(e.touches.length > 0){
|
|
|
|
+ Array.from(e.changedTouches).forEach(touch=>{ //修改changedTouches的
|
|
|
|
+ let touch_ = this.touches.find(a=>a.touch.identifier == touch.identifier)
|
|
|
|
+ if(touch_){
|
|
|
|
+ var a = this.getPointerInViewport(touch.pageX, touch.pageY, this.dragViewport||viewport, new THREE.Vector2)
|
|
|
|
+ touch_.pointer = a.pointer.clone()
|
|
|
|
+ viewport = a.viewport; camera = a.camera
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ this.pointer = this.touches[0].pointer.clone() //更新,使用当前touches中的第一个
|
|
|
|
+ //console.log('更新pointer1',this.pointer.toArray())
|
|
|
|
+ return {viewport, camera/* , pointer:this.pointer */}
|
|
|
|
+ }
|
|
|
|
+ //console.log(this.touches)
|
|
|
|
+ }
|
|
|
|
+
|
|
onTouchStart (e) {
|
|
onTouchStart (e) {
|
|
if (this.logMessages) console.log(this.constructor.name + ': onTouchStart');
|
|
if (this.logMessages) console.log(this.constructor.name + ': onTouchStart');
|
|
|
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
-
|
|
|
|
- if (e.touches.length === 1) { //changedTouches?
|
|
|
|
|
|
+
|
|
|
|
+ if (e.touches.length === 1 || !this.drag) { //!this.drag代表一次性下了两个指头
|
|
let rect = this.domElement.getBoundingClientRect();
|
|
let rect = this.domElement.getBoundingClientRect();
|
|
let x = e.touches[0].pageX
|
|
let x = e.touches[0].pageX
|
|
- let y = e.touches[0].pageY
|
|
|
|
-
|
|
|
|
- this.dealPointerDown(x,y,e,true)
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ let y = e.touches[0].pageY
|
|
|
|
+ this.dealPointerDown(x,y,e,true)
|
|
|
|
+ }else{
|
|
|
|
+ this.updateTouchesInfo(e)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
- this.viewer.dispatchEvent({
|
|
|
|
- type: /* "global_"+ */e.type, // global_ 是否加上
|
|
|
|
- touches: e.touches,
|
|
|
|
- changedTouches: e.changedTouches
|
|
|
|
- });
|
|
|
|
|
|
+ this.viewer.dispatchEvent($.extend(
|
|
|
|
+ this.getEventDesc(e,true),
|
|
|
|
+ {
|
|
|
|
+ type: 'global_' + e.type,
|
|
|
|
+ changedTouches: e.changedTouches
|
|
|
|
+ }
|
|
|
|
+ ));
|
|
|
|
|
|
-
|
|
|
|
- //add
|
|
|
|
- this.mouseDownMouse = this.mouse.clone()
|
|
|
|
|
|
+ /* console.log('targetTouches :', Array.from(e.targetTouches).map(e=>'| identifier: '+ e.identifier),
|
|
|
|
+ 'changedTouches :', Array.from(e.changedTouches).map(e=>'| identifier: '+ e.identifier)
|
|
|
|
+ ) */
|
|
|
|
+ //console.log('')
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ onTouchMove (e) {
|
|
|
|
+ if (this.logMessages) console.log(this.constructor.name + ': onTouchMove');
|
|
|
|
+
|
|
|
|
+ e.preventDefault();
|
|
|
|
+
|
|
|
|
+ if (e.touches.length === 1) {
|
|
|
|
+ let rect = this.domElement.getBoundingClientRect();
|
|
|
|
+ let x = e.touches[0].pageX;
|
|
|
|
+ let y = e.touches[0].pageY;
|
|
|
|
+ console.log('onTouchMove touches.length === 1')
|
|
|
|
+ this.dealPointerMove(x, y, e, true)
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ this.updateTouchesInfo(e)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ this.viewer.dispatchEvent($.extend(
|
|
|
|
+ this.getEventDesc(e,true),
|
|
|
|
+ {
|
|
|
|
+ type: 'global_' + e.type,
|
|
|
|
+ changedTouches: e.changedTouches
|
|
|
|
+ }
|
|
|
|
+ ));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /* console.log('targetTouches :', Array.from(e.targetTouches).map(e=>'| identifier: '+ e.identifier),
|
|
|
|
+ 'changedTouches :', Array.from(e.changedTouches).map(e=>'| identifier: '+ e.identifier)
|
|
|
|
+ ) */
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
onTouchEnd (e) {
|
|
onTouchEnd (e) {
|
|
if (this.logMessages) console.log(this.constructor.name + ': onTouchEnd');
|
|
if (this.logMessages) console.log(this.constructor.name + ': onTouchEnd');
|
|
|
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
|
|
+ //console.log('onTouchEnd')
|
|
|
|
+ this.updateTouchesInfo(e)
|
|
|
|
|
|
- /* this.viewer.dispatchEvent({
|
|
|
|
- type: 'global_drop',
|
|
|
|
- drag: this.drag,
|
|
|
|
- viewer: this.viewer
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- this.drag = null;
|
|
|
|
|
|
|
|
- this.viewer.dispatchEvent({
|
|
|
|
- type: 'global_' + e.type,
|
|
|
|
- touches: e.touches,
|
|
|
|
- changedTouches: e.changedTouches
|
|
|
|
- }); */
|
|
|
|
|
|
+
|
|
if (e.touches.length === 0) {
|
|
if (e.touches.length === 0) {
|
|
let rect = this.domElement.getBoundingClientRect();
|
|
let rect = this.domElement.getBoundingClientRect();
|
|
let x = e.changedTouches[0].pageX //万一一次松开两个指头的怎么办
|
|
let x = e.changedTouches[0].pageX //万一一次松开两个指头的怎么办
|
|
let y = e.changedTouches[0].pageY
|
|
let y = e.changedTouches[0].pageY
|
|
-
|
|
|
|
|
|
+
|
|
this.dealPointerUp(x,y,e,true)
|
|
this.dealPointerUp(x,y,e,true)
|
|
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ }else if(e.touches.length == 1){
|
|
|
|
+ this.drag.end.copy(this.pointer)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.viewer.dispatchEvent($.extend(
|
|
|
|
+ this.getEventDesc(e,true),
|
|
|
|
+ {
|
|
|
|
+ type: 'global_' + e.type,
|
|
|
|
+ }
|
|
|
|
+ ));
|
|
|
|
+ console.log('touchend length '+e.touches.length, this.touches.length)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -161,64 +228,9 @@ export class InputHandler extends EventDispatcher {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- onTouchMove (e) {
|
|
|
|
- if (this.logMessages) console.log(this.constructor.name + ': onTouchMove');
|
|
|
|
|
|
|
|
- e.preventDefault();
|
|
|
|
-
|
|
|
|
- if (e.touches.length === 1) {
|
|
|
|
- let rect = this.domElement.getBoundingClientRect();
|
|
|
|
- let x = e.touches[0].pageX;
|
|
|
|
- let y = e.touches[0].pageY;
|
|
|
|
- //this.mouse.set(x, y);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- this.dealPointerMove(x, y, e, true)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /* var { camera, viewport } = this.getPointerInViewport(x, y )
|
|
|
|
- this.hoverViewport = viewport
|
|
|
|
- if(!viewport)return
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (this.drag) {
|
|
|
|
- this.drag.mouse = 1; //why??非左键也非右键的意思?
|
|
|
|
-
|
|
|
|
- this.drag.pointerDelta.set(this.pointer.x - this.drag.end.x, this.pointer.y - this.drag.end.y );
|
|
|
|
- this.drag.end.set(this.pointer.x, this.pointer.y);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (this.logMessages) console.log(this.constructor.name + ': drag: ');
|
|
|
|
- this.viewer.dispatchEvent({
|
|
|
|
- type: 'global_drag',
|
|
|
|
- drag: this.drag,
|
|
|
|
- viewer: this.viewer
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- } */
|
|
|
|
- }
|
|
|
|
|
|
|
|
- /* for (let inputListener of this.getSortedListeners()) {
|
|
|
|
- inputListener. */this.viewer.dispatchEvent({
|
|
|
|
- type: e.type,
|
|
|
|
- touches: e.touches,
|
|
|
|
- changedTouches: e.changedTouches
|
|
|
|
- });
|
|
|
|
- //}
|
|
|
|
|
|
|
|
- // DEBUG CODE
|
|
|
|
- // let debugTouches = [...e.touches, {
|
|
|
|
- // pageX: this.domElement.clientWidth / 2,
|
|
|
|
- // pageY: this.domElement.clientHeight / 2}];
|
|
|
|
- // for(let inputListener of this.getSortedListeners()){
|
|
|
|
- // inputListener.dispatchEvent({
|
|
|
|
- // type: e.type,
|
|
|
|
- // touches: debugTouches,
|
|
|
|
- // changedTouches: e.changedTouches
|
|
|
|
- // });
|
|
|
|
- // }
|
|
|
|
- }
|
|
|
|
|
|
|
|
onKeyDown (e) {
|
|
onKeyDown (e) {
|
|
if (this.logMessages) console.log(this.constructor.name + ': onKeyDown');
|
|
if (this.logMessages) console.log(this.constructor.name + ': onKeyDown');
|
|
@@ -299,12 +311,21 @@ export class InputHandler extends EventDispatcher {
|
|
|
|
|
|
|
|
|
|
dealPointerDown(x,y,e,isTouch){
|
|
dealPointerDown(x,y,e,isTouch){
|
|
|
|
+ e.preventDefault();
|
|
|
|
+
|
|
//重新获取一下pointer, 因点击了浏览器的按钮展开列表时 move回来不会触发onmousemove,所以pointer是旧的
|
|
//重新获取一下pointer, 因点击了浏览器的按钮展开列表时 move回来不会触发onmousemove,所以pointer是旧的
|
|
- var { camera, viewport } = this.getPointerInViewport(x, y )
|
|
|
|
|
|
+
|
|
|
|
+ if(isTouch){
|
|
|
|
+ var { camera, viewport } = this.updateTouchesInfo(e)
|
|
|
|
+ }else{
|
|
|
|
+ var { camera, viewport } = this.getPointerInViewport(x, y )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
this.hoverViewport = viewport
|
|
this.hoverViewport = viewport
|
|
if(!viewport)return
|
|
if(!viewport)return
|
|
|
|
|
|
- e.preventDefault();
|
|
|
|
|
|
+
|
|
|
|
|
|
//this.onMouseMove(e)//add 重新获取一下mouse, 因在此前canvas可能失去侦听(不记得是什么了。如果一定要的话再写个加侦听的函数,但是直接调用mousemove的话会发送drag,导致magnifier停止渲染)
|
|
//this.onMouseMove(e)//add 重新获取一下mouse, 因在此前canvas可能失去侦听(不记得是什么了。如果一定要的话再写个加侦听的函数,但是直接调用mousemove的话会发送drag,导致magnifier停止渲染)
|
|
|
|
|
|
@@ -350,8 +371,8 @@ export class InputHandler extends EventDispatcher {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- //add
|
|
|
|
- this.drag.pointerDragStart = this.pointer.clone()
|
|
|
|
|
|
+
|
|
|
|
+
|
|
this.drag.intersectStart = this.intersectPoint;
|
|
this.drag.intersectStart = this.intersectPoint;
|
|
this.mouseDownMouse = this.mouse.clone()
|
|
this.mouseDownMouse = this.mouse.clone()
|
|
this.dragViewport = this.hoverViewport;
|
|
this.dragViewport = this.hoverViewport;
|
|
@@ -370,19 +391,26 @@ export class InputHandler extends EventDispatcher {
|
|
|
|
|
|
|
|
|
|
getEventDesc(e,isTouch){//搜集dispatchEvent要给的一般数据
|
|
getEventDesc(e,isTouch){//搜集dispatchEvent要给的一般数据
|
|
- return {
|
|
|
|
|
|
+ let o = {
|
|
viewer: this.viewer,
|
|
viewer: this.viewer,
|
|
mouse: this.mouse,
|
|
mouse: this.mouse,
|
|
pointer:this.pointer,
|
|
pointer:this.pointer,
|
|
- drag :this.drag,
|
|
|
|
- isAtDomElement: e.target == this.domElement,
|
|
|
|
|
|
+ drag :this.drag,
|
|
dragViewport : this.dragViewport,
|
|
dragViewport : this.dragViewport,
|
|
hoverViewport: this.hoverViewport,
|
|
hoverViewport: this.hoverViewport,
|
|
- button: isTouch ? 0 : e.button,
|
|
|
|
- buttons: isTouch ? e.touches.length : e.buttons,
|
|
|
|
|
|
+ // button: isTouch ? 0 : e.button,
|
|
isTouch,
|
|
isTouch,
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if(e){
|
|
|
|
+ o.isAtDomElement = e.target == this.domElement
|
|
|
|
+ }
|
|
|
|
+ if(isTouch){
|
|
|
|
+ o.touches = this.touches
|
|
|
|
+ }else if(e){
|
|
|
|
+ o.button = e.button
|
|
|
|
+ o.buttons = e.buttons
|
|
|
|
+ }
|
|
|
|
+ return o;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -496,7 +524,7 @@ export class InputHandler extends EventDispatcher {
|
|
});
|
|
});
|
|
} */
|
|
} */
|
|
this.drag = null;
|
|
this.drag = null;
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
this.dragViewport = null
|
|
this.dragViewport = null
|
|
@@ -534,13 +562,13 @@ export class InputHandler extends EventDispatcher {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- getPointerInViewport(clientX, clientY, viewForceAt ){
|
|
|
|
|
|
+ getPointerInViewport(clientX, clientY, viewForceAt, pointer ){
|
|
let rect = this.domElement.getBoundingClientRect();
|
|
let rect = this.domElement.getBoundingClientRect();
|
|
let x = clientX - rect.left;
|
|
let x = clientX - rect.left;
|
|
let y = clientY - rect.top;
|
|
let y = clientY - rect.top;
|
|
let camera
|
|
let camera
|
|
let viewport
|
|
let viewport
|
|
-
|
|
|
|
|
|
+ pointer = pointer ||this.pointer
|
|
//if(this.viewer.viewports || viewForceAt){
|
|
//if(this.viewer.viewports || viewForceAt){
|
|
var getDimension = (view)=>{
|
|
var getDimension = (view)=>{
|
|
var left = Math.floor(this.domElement.clientWidth * view.left)
|
|
var left = Math.floor(this.domElement.clientWidth * view.left)
|
|
@@ -552,7 +580,8 @@ export class InputHandler extends EventDispatcher {
|
|
}
|
|
}
|
|
var getView = (view, left, bottom, width, height, top)=>{
|
|
var getView = (view, left, bottom, width, height, top)=>{
|
|
this.mouse.set(x-left, y - top )
|
|
this.mouse.set(x-left, y - top )
|
|
- Utils.convertScreenPositionToNDC(this.pointer, this.mouse, width, height);
|
|
|
|
|
|
+ Utils.convertScreenPositionToNDC(pointer, this.mouse, width, height);
|
|
|
|
+ //console.log('更新pointer2',this.pointer.toArray())
|
|
camera = view.camera;
|
|
camera = view.camera;
|
|
viewport = view
|
|
viewport = view
|
|
}
|
|
}
|
|
@@ -582,13 +611,9 @@ export class InputHandler extends EventDispatcher {
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
- /*} else{
|
|
|
|
- camera = this.viewer.scene.getActiveCamera()
|
|
|
|
- this.mouse.set(x , y )
|
|
|
|
- Utils.convertScreenPositionToNDC(this.pointer, this.mouse, this.domElement.clientWidth, this.domElement.clientHeight);
|
|
|
|
- } */
|
|
|
|
|
|
+
|
|
return {
|
|
return {
|
|
- camera, viewport
|
|
|
|
|
|
+ camera, viewport, pointer
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -598,8 +623,12 @@ export class InputHandler extends EventDispatcher {
|
|
}
|
|
}
|
|
|
|
|
|
dealPointerMove(x, y, e, isTouch){
|
|
dealPointerMove(x, y, e, isTouch){
|
|
-
|
|
|
|
- var { camera, viewport } = this.getPointerInViewport(x, y, this.dragViewport)
|
|
|
|
|
|
+ if(isTouch){
|
|
|
|
+ var { camera, viewport } = this.updateTouchesInfo(e)
|
|
|
|
+ }else{
|
|
|
|
+ var { camera, viewport } = this.getPointerInViewport(x, y , this.dragViewport)
|
|
|
|
+ }
|
|
|
|
+
|
|
this.hoverViewport = viewport
|
|
this.hoverViewport = viewport
|
|
if(!viewport)return//刚变化viewport时会找不到
|
|
if(!viewport)return//刚变化viewport时会找不到
|
|
|
|
|
|
@@ -609,7 +638,7 @@ export class InputHandler extends EventDispatcher {
|
|
let names = hoveredElements.map(h => h.object.name).join(", ");
|
|
let names = hoveredElements.map(h => h.object.name).join(", ");
|
|
if (this.logMessages) console.log(`${this.constructor.name}: onMouseMove; hovered: '${names}'`);
|
|
if (this.logMessages) console.log(`${this.constructor.name}: onMouseMove; hovered: '${names}'`);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//add
|
|
//add
|
|
let intersectPoint = viewport.noPointcloud? null : Utils.getMousePointCloudIntersection(
|
|
let intersectPoint = viewport.noPointcloud? null : Utils.getMousePointCloudIntersection(
|
|
viewport,
|
|
viewport,
|
|
@@ -638,9 +667,9 @@ export class InputHandler extends EventDispatcher {
|
|
|
|
|
|
if (this.drag) {//有拖拽(不一定拖拽了物体, 也不一定按下了鼠标)
|
|
if (this.drag) {//有拖拽(不一定拖拽了物体, 也不一定按下了鼠标)
|
|
this.drag.mouse = isTouch ? 1 : e.buttons;
|
|
this.drag.mouse = isTouch ? 1 : e.buttons;
|
|
- this.drag.hoverViewport = this.hoverViewport
|
|
|
|
- this.drag.pointerDelta.set(this.pointer.x - this.drag.end.x, this.pointer.y - this.drag.end.y )
|
|
|
|
- this.drag.end.set(this.pointer.x, this.pointer.y);
|
|
|
|
|
|
+ this.drag.hoverViewport = this.hoverViewport
|
|
|
|
+ this.drag.pointerDelta.subVectors(this.pointer, this.drag.end)
|
|
|
|
+ this.drag.end.copy(this.pointer)
|
|
|
|
|
|
|
|
|
|
if (this.drag.object && (e.buttons == Buttons.NONE || !this.drag.notPressMouse )){//add notPressMouse 如果标记是不需要按鼠标的拖拽,则一旦按下鼠标,就暂停拖拽物体(改为拖拽场景):(如添加测量时突然拖拽画面)
|
|
if (this.drag.object && (e.buttons == Buttons.NONE || !this.drag.notPressMouse )){//add notPressMouse 如果标记是不需要按鼠标的拖拽,则一旦按下鼠标,就暂停拖拽物体(改为拖拽场景):(如添加测量时突然拖拽画面)
|
|
@@ -805,7 +834,13 @@ export class InputHandler extends EventDispatcher {
|
|
let ndelta = Math.sign(delta);
|
|
let ndelta = Math.sign(delta);
|
|
|
|
|
|
// this.wheelDelta += Math.sign(delta);
|
|
// this.wheelDelta += Math.sign(delta);
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(!this.hoverViewport){//调试手机版时会无
|
|
|
|
+ var { viewport } = this.getPointerInViewport(e.clientX, e.clientY )
|
|
|
|
+ this.hoverViewport = viewport
|
|
|
|
+ }
|
|
|
|
+
|
|
if (this.hoveredElement) {
|
|
if (this.hoveredElement) {
|
|
this.hoveredElement.object.dispatchEvent($.extend(
|
|
this.hoveredElement.object.dispatchEvent($.extend(
|
|
this.getEventDesc(e,isTouch),
|
|
this.getEventDesc(e,isTouch),
|
|
@@ -841,23 +876,22 @@ export class InputHandler extends EventDispatcher {
|
|
dragViewport : this.hoverViewport, //开始之后就不会变了
|
|
dragViewport : this.hoverViewport, //开始之后就不会变了
|
|
hoverViewport: this.hoverViewport //会变化
|
|
hoverViewport: this.hoverViewport //会变化
|
|
};
|
|
};
|
|
-
|
|
|
|
-
|
|
|
|
- this.viewer.dispatchEvent({
|
|
|
|
- type: "startDragging",
|
|
|
|
- drag: this.drag,
|
|
|
|
- hoverViewport: this.hoverViewport
|
|
|
|
- })
|
|
|
|
- /* console.log('startDragging')
|
|
|
|
- console.log(this.drag.end) */
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (args) {
|
|
|
|
|
|
+ if (args) {
|
|
for (let key of Object.keys(args)) {
|
|
for (let key of Object.keys(args)) {
|
|
this.drag[key] = args[key];
|
|
this.drag[key] = args[key];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ this.viewer.dispatchEvent($.extend(
|
|
|
|
+ this.getEventDesc(/*e ,true */),
|
|
|
|
+ {
|
|
|
|
+ type: 'startDragging'
|
|
|
|
+ }
|
|
|
|
+ ));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/* getMousePointCloudIntersection (mouse) {
|
|
/* getMousePointCloudIntersection (mouse) {
|
|
@@ -1065,10 +1099,11 @@ export class InputHandler extends EventDispatcher {
|
|
return mouseDelta;
|
|
return mouseDelta;
|
|
} */
|
|
} */
|
|
|
|
|
|
- getMouseDirection() {//add
|
|
|
|
|
|
+ getMouseDirection(pointer) {//add
|
|
|
|
+ pointer = pointer || this.pointer
|
|
let camera = this.hoverViewport.camera
|
|
let camera = this.hoverViewport.camera
|
|
- var t = new THREE.Vector3(this.pointer.x, this.pointer.y, -1).unproject(camera),
|
|
|
|
- i = new THREE.Vector3(this.pointer.x, this.pointer.y, 1).unproject(camera);
|
|
|
|
|
|
+ var t = new THREE.Vector3(pointer.x, pointer.y, -1).unproject(camera),
|
|
|
|
+ i = new THREE.Vector3(pointer.x, pointer.y, 1).unproject(camera);
|
|
|
|
|
|
return {origin: t, direction:i.clone().sub(t).normalize() }
|
|
return {origin: t, direction:i.clone().sub(t).normalize() }
|
|
|
|
|