|
@@ -48,17 +48,45 @@ class ExtendView extends View {
|
|
|
|
|
|
|
|
|
copy(a){
|
|
|
- Common.CopyClassObject(this, a)
|
|
|
+ Common.CopyClassObject(this, a, {ignoreList: ['_listeners']})
|
|
|
}
|
|
|
|
|
|
clone () {
|
|
|
- return Common.CloneClassObject(this)
|
|
|
+ return Common.CloneClassObject(this, {ignoreList: ['_listeners']})
|
|
|
}
|
|
|
|
|
|
//----------
|
|
|
|
|
|
|
|
|
-
|
|
|
+ setCubeView(dir) {
|
|
|
+
|
|
|
+ switch(dir) {
|
|
|
+ case "front":
|
|
|
+ this.yaw = 0;
|
|
|
+ this.pitch = 0;
|
|
|
+ break;
|
|
|
+ case "back":
|
|
|
+ this.yaw = Math.PI;
|
|
|
+ this.pitch = 0;
|
|
|
+ break;
|
|
|
+ case "left":
|
|
|
+ this.yaw = -Math.PI / 2;
|
|
|
+ this.pitch = 0;
|
|
|
+ break;
|
|
|
+ case "right":
|
|
|
+ this.yaw = Math.PI / 2;
|
|
|
+ this.pitch = 0;
|
|
|
+ break;
|
|
|
+ case "top":
|
|
|
+ this.yaw = 0;
|
|
|
+ this.pitch = -Math.PI / 2;
|
|
|
+ break;
|
|
|
+ case "bottom":
|
|
|
+ this.yaw = -Math.PI;
|
|
|
+ this.pitch = Math.PI / 2;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -102,7 +130,9 @@ class ExtendView extends View {
|
|
|
|
|
|
this.position = this.position.add(t);
|
|
|
|
|
|
- x != 0 && y != 0 && z != 0 && /* t.lengthSq()!=0 && */Potree.settings.displayMode != 'showPanos' && this.cancelFlying('pos')
|
|
|
+ if((!math.closeTo(x, 0, 1e-4) || !math.closeTo(y, 0, 1e-4) || !math.closeTo(z, 0, 1e-4)) && Potree.settings.displayMode != 'showPanos'){
|
|
|
+ this.cancelFlying('pos')
|
|
|
+ }
|
|
|
|
|
|
this.restrictPos()
|
|
|
}
|
|
@@ -110,7 +140,10 @@ class ExtendView extends View {
|
|
|
translateWorld (x, y, z) {
|
|
|
super.translateWorld(x, y, z)
|
|
|
|
|
|
- x != 0 && y != 0 && z != 0 && Potree.settings.displayMode != 'showPanos' && this.cancelFlying('pos')
|
|
|
+ if((!math.closeTo(x, 0, 1e-4) || !math.closeTo(y, 0, 1e-4) || !math.closeTo(z, 0, 1e-4)) && Potree.settings.displayMode != 'showPanos'){
|
|
|
+ this.cancelFlying('pos')
|
|
|
+ }
|
|
|
+
|
|
|
this.restrictPos()
|
|
|
}
|
|
|
|
|
@@ -120,53 +153,19 @@ class ExtendView extends View {
|
|
|
(position || this.position).clamp(this.limitBound.min, this.limitBound.max)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- setCubeView(dir) {
|
|
|
-
|
|
|
- switch(dir) {
|
|
|
- case "front":
|
|
|
- this.yaw = 0;
|
|
|
- this.pitch = 0;
|
|
|
- break;
|
|
|
- case "back":
|
|
|
- this.yaw = Math.PI;
|
|
|
- this.pitch = 0;
|
|
|
- break;
|
|
|
- case "left":
|
|
|
- this.yaw = -Math.PI / 2;
|
|
|
- this.pitch = 0;
|
|
|
- break;
|
|
|
- case "right":
|
|
|
- this.yaw = Math.PI / 2;
|
|
|
- this.pitch = 0;
|
|
|
- break;
|
|
|
- case "top":
|
|
|
- this.yaw = 0;
|
|
|
- this.pitch = -Math.PI / 2;
|
|
|
- break;
|
|
|
- case "bottom":
|
|
|
- this.yaw = -Math.PI;
|
|
|
- this.pitch = Math.PI / 2;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
isFlying(type='all'){
|
|
|
let a = transitions.getById(this.FlyTransition).length > 0
|
|
|
let b = transitions.getById(this.LookTransition).length > 0
|
|
|
|
|
|
- return type == 'pos' ? a : type == 'rotate' ? b : a && b
|
|
|
+ return type == 'pos' ? a : type == 'rotate' ? b : (a || b)
|
|
|
}
|
|
|
|
|
|
cancelFlying(type='all'){//外界只能通过这个来cancel
|
|
|
type == 'pos' ? transitions.cancelById(this.FlyTransition, true )
|
|
|
: type == 'rotate' ? transitions.cancelById(this.LookTransition, true )
|
|
|
: (transitions.cancelById(this.FlyTransition, true ), transitions.cancelById(this.LookTransition, true ))
|
|
|
-
|
|
|
+ //console.log('cancelFlying ' , this.sid, type)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -175,9 +174,11 @@ class ExtendView extends View {
|
|
|
setView( info = {}){
|
|
|
// position, target, duration = 0, callback = null, onUpdate = null, Easing='', cancelFun
|
|
|
this.cancelFlying()
|
|
|
- let finished
|
|
|
+ let posWaitDone, rotWaitDone
|
|
|
+
|
|
|
let posDone = ()=>{
|
|
|
- done()
|
|
|
+ rotWaitDone || done()
|
|
|
+ posWaitDone = false
|
|
|
}
|
|
|
let rotDone = ()=>{
|
|
|
if(endTarget){
|
|
@@ -185,10 +186,12 @@ class ExtendView extends View {
|
|
|
}else if(endQuaternion){
|
|
|
this.rotation = new THREE.Euler().setFromQuaternion(endQuaternion)
|
|
|
}
|
|
|
- done()
|
|
|
+ posWaitDone || done()
|
|
|
+ rotWaitDone = false
|
|
|
}
|
|
|
- let done = ()=>{
|
|
|
- if(finished)return
|
|
|
+
|
|
|
+ let done = ()=>{ //一定要旋转和位移都结束了才能执行
|
|
|
+
|
|
|
let f = ()=>{
|
|
|
info.callback && info.callback()
|
|
|
this.dispatchEvent('flyingDone')
|
|
@@ -198,7 +201,7 @@ class ExtendView extends View {
|
|
|
}else{
|
|
|
f() //有的需要迅速执行回调
|
|
|
}
|
|
|
- finished = true
|
|
|
+
|
|
|
}
|
|
|
|
|
|
let endPosition = new THREE.Vector3().copy(info.position)
|
|
@@ -213,7 +216,7 @@ class ExtendView extends View {
|
|
|
endQuaternion = info.quaternion.clone()
|
|
|
}
|
|
|
|
|
|
- if(endQuaternion){
|
|
|
+ if(endQuaternion){
|
|
|
startQuaternion = new THREE.Quaternion().setFromEuler(this.rotation)
|
|
|
/* const startTarget = this.getPivot();
|
|
|
let startQuaternion = math.getQuaFromPosAim(startPosition,startTarget) */
|
|
@@ -224,32 +227,50 @@ class ExtendView extends View {
|
|
|
if(!info.duration){
|
|
|
this.position.copy(endPosition);
|
|
|
this.restrictPos()
|
|
|
-
|
|
|
+ posWaitDone = true, rotWaitDone = true
|
|
|
info.onUpdate && info.onUpdate(1)
|
|
|
posDone()
|
|
|
rotDone()
|
|
|
}else{
|
|
|
+ info.onUpdate && info.onUpdate(0) //初始化progress
|
|
|
+
|
|
|
let posChange = !this.position.equals(endPosition)
|
|
|
if(posChange){
|
|
|
+ posWaitDone = true
|
|
|
transitions.start(lerp.vector(this.position, endPosition, (pos, progress)=>{
|
|
|
|
|
|
info.onUpdate && info.onUpdate(progress)
|
|
|
|
|
|
- }), info.duration, posDone/* done */, 0, info.Easing ? easing[info.Easing] : easing.easeInOutSine /*easeInOutQuad */,null, this.FlyTransition, info.cancelFun);
|
|
|
-
|
|
|
+ }), info.duration, posDone , 0, info.Easing ? easing[info.Easing] : easing.easeInOutSine ,null, this.FlyTransition, ()=>{
|
|
|
+ //中途取消
|
|
|
+ if(endTarget ){
|
|
|
+ /* endPosition = new THREE.Vector3().copy(this.position)//更改旋转的endQuaternion
|
|
|
+ endQuaternion = math.getQuaFromPosAim(endPosition,endTarget) */
|
|
|
+ //直接改变endQuaternion会突变,所以还是cancel吧
|
|
|
+ this.cancelFlying('rotate')
|
|
|
+ }
|
|
|
+ posWaitDone = false
|
|
|
+ info.cancelFun && info.cancelFun()
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- endQuaternion && transitions.start( (progress)=>{
|
|
|
-
|
|
|
- let quaternion = (new THREE.Quaternion()).copy(startQuaternion)
|
|
|
- lerp.quaternion(quaternion, endQuaternion)(progress),
|
|
|
- this.rotation = new THREE.Euler().setFromQuaternion(quaternion)
|
|
|
-
|
|
|
- posChange || info.onUpdate && info.onUpdate(progress)
|
|
|
+ if(endQuaternion){
|
|
|
+ rotWaitDone = true
|
|
|
+ transitions.start( (progress)=>{
|
|
|
|
|
|
- }, info.duration, rotDone/* posChange?done:null */, 0, info.Easing ? easing[info.Easing] : easing.easeInOutSine ,null, this.LookTransition, info.cancelFun);
|
|
|
-
|
|
|
+ let quaternion = (new THREE.Quaternion()).copy(startQuaternion)
|
|
|
+ lerp.quaternion(quaternion, endQuaternion)(progress),
|
|
|
+ this.rotation = new THREE.Euler().setFromQuaternion(quaternion)
|
|
|
+
|
|
|
+ //posChange || info.onUpdate && info.onUpdate(progress) //位置没变化uniforms不需要变progress
|
|
|
+
|
|
|
+ }, info.duration, rotDone , 0, info.Easing ? easing[info.Easing] : easing.easeInOutSine ,null, this.LookTransition, ()=>{
|
|
|
+ //中途取消
|
|
|
+ rotWaitDone = false
|
|
|
+ info.cancelFun && info.cancelFun()
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|