|
@@ -53745,8 +53745,8 @@
|
|
|
|
|
|
if(dir.x === 0 && dir.y === 0){
|
|
|
this.pitch = Math.PI / 2 * Math.sign(dir.z);
|
|
|
- this.yaw = 0; //add:还是要指定一下, 否则不统一
|
|
|
-
|
|
|
+ //this.yaw = 0
|
|
|
+ //console.log('yaw没变',this.yaw)
|
|
|
}else {
|
|
|
let yaw = Math.atan2(dir.y, dir.x) - Math.PI / 2;
|
|
|
let pitch = Math.atan2(dir.z, Math.sqrt(dir.x * dir.x + dir.y * dir.y));
|
|
@@ -53939,7 +53939,7 @@
|
|
|
}
|
|
|
|
|
|
set quaternion(q){
|
|
|
- this.direction = new Vector3(0,0,-1).applyQuaternion(q);
|
|
|
+ this.direction = new Vector3(0,0,-1).applyQuaternion(q); //注意如果得到的dir.x==dir.y==0, yaw不会变为0, 导致算的quaternion和q不一致
|
|
|
}
|
|
|
|
|
|
copy(a){
|
|
@@ -54069,7 +54069,7 @@
|
|
|
setView( info = {}){
|
|
|
// position, target, duration = 0, callback = null, onUpdate = null, Easing='', cancelFun
|
|
|
this.cancelFlying();
|
|
|
- let posWaitDone, rotWaitDone;
|
|
|
+ let posWaitDone, rotWaitDone , dir;
|
|
|
|
|
|
let posDone = ()=>{
|
|
|
rotWaitDone || done();
|
|
@@ -54077,10 +54077,14 @@
|
|
|
};
|
|
|
let rotDone = ()=>{
|
|
|
if(endTarget){
|
|
|
- this.lookAt(endTarget); //compute radius for orbitcontrol
|
|
|
+ this.lookAt(endTarget); //compute radius for orbitcontrol
|
|
|
}else if(endQuaternion){
|
|
|
this.rotation = new Euler().setFromQuaternion(endQuaternion);
|
|
|
+ }else if(endYaw != void 0){
|
|
|
+ this.yaw = endYaw, this.pitch = endPitch;
|
|
|
}
|
|
|
+ //if(dir.x == 0 && dir.y == 0)this.yaw = 0 //统一一下 朝上的话是正的。朝下的一般不是0,会保留一个接近0的小数所以不用管
|
|
|
+
|
|
|
posWaitDone || done();
|
|
|
rotWaitDone = false;
|
|
|
};
|
|
@@ -54101,31 +54105,27 @@
|
|
|
|
|
|
let endPosition = new Vector3().copy(info.position);
|
|
|
let startPosition = this.position.clone();
|
|
|
- let startQuaternion, endQuaternion, endTarget = null, needRot;
|
|
|
+ let startQuaternion, endQuaternion, endTarget = null,
|
|
|
+ endYaw = info.endYaw, startYaw, endPitch = info.endPitch, startPitch ;
|
|
|
+
|
|
|
+
|
|
|
this.restrictPos(endPosition);
|
|
|
|
|
|
- if(info.target ){
|
|
|
+
|
|
|
+ if(endYaw != void 0) {
|
|
|
+ startYaw = this.yaw;
|
|
|
+ startPitch = this.pitch;
|
|
|
+ }else if(info.target ){
|
|
|
endTarget = new Vector3().copy(info.target);
|
|
|
endQuaternion = math.getQuaFromPosAim(endPosition,endTarget); //若为垂直,会自动偏向x负的方向
|
|
|
- let dir = new Vector3().subVectors(endTarget, endPosition).normalize();
|
|
|
- //console.log(dir, this.direction)
|
|
|
-
|
|
|
- let view = this.clone();
|
|
|
- view.direction = dir;
|
|
|
- console.log(view.yaw, view.pitch, this.yaw, this.pitch);
|
|
|
-
|
|
|
-
|
|
|
+ dir = new Vector3().subVectors(endTarget, endPosition).normalize();
|
|
|
+ //console.log(dir, this.direction)
|
|
|
}else if(info.quaternion){
|
|
|
endQuaternion = info.quaternion.clone();
|
|
|
}
|
|
|
|
|
|
if(endQuaternion){
|
|
|
- startQuaternion = new Quaternion().setFromEuler(this.rotation);
|
|
|
- needRot = endQuaternion;
|
|
|
- /* const startTarget = this.getPivot();
|
|
|
- let startQuaternion = math.getQuaFromPosAim(startPosition,startTarget) */
|
|
|
- //console.log('startQuaternion',startQuaternion, this.rotation)
|
|
|
- //console.log('endQuaternion', endQuaternion, new THREE.Euler().setFromQuaternion(endQuaternion))
|
|
|
+ startQuaternion = this.quaternion;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -54160,16 +54160,19 @@
|
|
|
}, info.ignoreFirstFrame);
|
|
|
}
|
|
|
|
|
|
- if(endQuaternion){
|
|
|
+ if(endQuaternion || endYaw != void 0){
|
|
|
rotWaitDone = true;
|
|
|
transitions.start( (progress, delta )=>{
|
|
|
-
|
|
|
- let quaternion = (new Quaternion()).copy(startQuaternion);
|
|
|
- lerp.quaternion(quaternion, endQuaternion)(progress); //在垂直的视角下的角度突变的厉害,这时候可能渐变yaw比较好
|
|
|
-
|
|
|
- //this.rotation = new THREE.Euler().setFromQuaternion(quaternion)
|
|
|
- this.quaternion = quaternion;
|
|
|
-
|
|
|
+ if(endYaw != void 0){
|
|
|
+ this.yaw = startYaw * (1-progress) + endYaw * progress;
|
|
|
+ this.pitch = startPitch * (1-progress) + endPitch * progress;
|
|
|
+ }else {
|
|
|
+ let quaternion = (new Quaternion()).copy(startQuaternion);
|
|
|
+ lerp.quaternion(quaternion, endQuaternion)(progress); //在垂直的视角下的角度突变的厉害,这时候可能渐变yaw比较好
|
|
|
+ //console.log(quaternion)
|
|
|
+ //this.rotation = new THREE.Euler().setFromQuaternion(quaternion)
|
|
|
+ this.quaternion = quaternion;
|
|
|
+ }
|
|
|
posChange || info.onUpdate && info.onUpdate(progress, delta);
|
|
|
|
|
|
}, info.duration, rotDone , 0, info.Easing ? easing[info.Easing] : easing.easeInOutSine ,null, this.LookTransition, ()=>{
|
|
@@ -54309,8 +54312,9 @@
|
|
|
info.onUpdate = (progress, delta)=>{
|
|
|
lerp.matrix4(info.midCamera.projectionMatrix, info.endCamera.projectionMatrix)(progress);
|
|
|
|
|
|
- console.log('matrixWorld', viewport.camera.position.toArray(), viewport.camera.matrixWorld.toArray());
|
|
|
- console.log('projectionMatrix', info.endCamera.zoom, viewport.camera.projectionMatrix.toArray());
|
|
|
+ /* console.log('matrixWorld', viewport.camera.position.toArray(), viewport.camera.matrixWorld.toArray())
|
|
|
+ console.log('projectionMatrix', info.endCamera.zoom, viewport.camera.projectionMatrix.toArray())
|
|
|
+ */
|
|
|
onUpdate && onUpdate(progress, delta);
|
|
|
};
|
|
|
|
|
@@ -91290,13 +91294,19 @@ void main()
|
|
|
|
|
|
buildFaces() {
|
|
|
const directions = {
|
|
|
- Top : new Vector3(0,0,-1),
|
|
|
- Bottom : new Vector3(0,0,1),
|
|
|
- Left : new Vector3(1,0,0),
|
|
|
- Right : new Vector3(-1,0,0),
|
|
|
- Front : new Vector3(0,1,0),
|
|
|
- Back : new Vector3(0,-1,0),
|
|
|
- };
|
|
|
+ Top : {dir: new Vector3(0,0,-1)},
|
|
|
+ Bottom : {dir: new Vector3(0,0,1)},
|
|
|
+ Left : {dir: new Vector3(1,0,0)},
|
|
|
+ Right : {dir: new Vector3(-1,0,0)},
|
|
|
+ Front : {dir: new Vector3(0,1,0)},
|
|
|
+ Back : {dir: new Vector3(0,-1,0)},
|
|
|
+ };
|
|
|
+ let view = new ExtendView();
|
|
|
+ for(let i in directions){
|
|
|
+ view.direction = directions[i].dir;
|
|
|
+ directions[i].yaw = view.yaw, directions[i].pitch = view.pitch;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
let texturesLoaded = 0;
|
|
|
let create = (n)=>{
|
|
@@ -91330,7 +91340,7 @@ void main()
|
|
|
faceMesh.addEventListener('click', (e)=>{
|
|
|
this.changingView = true;
|
|
|
faceMesh.material.uniforms.faceColor.value.set(Colors.blue);
|
|
|
- navCubeViewer.switchView('ortho', directions[name].clone(),()=>{
|
|
|
+ navCubeViewer.switchView('ortho', directions[name] , ()=>{
|
|
|
this.changingView = false;
|
|
|
faceMesh.material.uniforms.faceColor.value.set(Colors.black);
|
|
|
});
|
|
@@ -91496,6 +91506,7 @@ void main()
|
|
|
updateCamera(){
|
|
|
let view = this.listenViewport.view;
|
|
|
this.view.quaternion = view.quaternion; //this.view.rotation = view.rotation
|
|
|
+ this.view.yaw = view.yaw;
|
|
|
var dir = view.direction; //相机朝向
|
|
|
this.view.position.copy(dir.multiplyScalar(this.view.radius).negate()); //相机绕着指南针中心(000)转动
|
|
|
|
|
@@ -91561,7 +91572,7 @@ void main()
|
|
|
}
|
|
|
}
|
|
|
} */
|
|
|
- switchView(type, dir, done){
|
|
|
+ switchView(type, {yaw, pitch, dir}={}, done){
|
|
|
let view = viewer.mainViewport.view;
|
|
|
if(type == 'ortho'){
|
|
|
let startCamera, endCamera;
|
|
@@ -91587,9 +91598,9 @@ void main()
|
|
|
}
|
|
|
|
|
|
viewer.focusOnObject(viewer.bound, 'boundingBox', 1000, {
|
|
|
- dir , startCamera, endCamera
|
|
|
+ endPitch: pitch, endYaw: yaw , dir, startCamera, endCamera
|
|
|
}).promise.done(()=>{
|
|
|
- console.log('回2', name);
|
|
|
+
|
|
|
done && done();
|
|
|
navCubeViewer.dispatchEvent('content_changed');
|
|
|
});
|
|
@@ -129157,7 +129168,7 @@ ENDSEC
|
|
|
});
|
|
|
|
|
|
const KHR_TECHNIQUES_WEBGL = 'KHR_techniques_webgl';
|
|
|
- const name$7 = KHR_TECHNIQUES_WEBGL;
|
|
|
+ const name = KHR_TECHNIQUES_WEBGL;
|
|
|
async function decode(gltfData) {
|
|
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
|
const {
|
|
@@ -129225,7 +129236,7 @@ ENDSEC
|
|
|
|
|
|
var KHR_techniques_webgl = /*#__PURE__*/Object.freeze({
|
|
|
__proto__: null,
|
|
|
- name: name$7,
|
|
|
+ name: name,
|
|
|
decode: decode,
|
|
|
encode: encode
|
|
|
});
|
|
@@ -139302,40 +139313,35 @@ ENDSEC
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /*} else if(dimension == 2){//线
|
|
|
-
|
|
|
- }else if(dimension == 3){//面
|
|
|
-
|
|
|
- }else{//立体
|
|
|
-
|
|
|
- } */
|
|
|
+
|
|
|
if(o.startCamera && o.endCamera){
|
|
|
viewer.scene.view.tranCamera(this.mainViewport, { endPosition:position, target ,
|
|
|
boundSize,
|
|
|
callback:()=>{
|
|
|
//console.log('focusOnObjectSuccess: '+object.name, type)
|
|
|
deferred.resolve();
|
|
|
- }, startCamera:o.startCamera, endCamera:o.endCamera, midCamera:this.scene.cameraBasic
|
|
|
+ }, startCamera:o.startCamera, endCamera:o.endCamera, midCamera:this.scene.cameraBasic,
|
|
|
+ endYaw:o.endYaw, endPitch:o.endPitch
|
|
|
}, duration);
|
|
|
|
|
|
}else if(camera.type == "OrthographicCamera"){
|
|
|
viewer.scene.view.moveOrthoCamera(this.mainViewport, { endPosition:position, target ,
|
|
|
boundSize,
|
|
|
+ endYaw:o.endYaw, endPitch:o.endPitch,
|
|
|
callback:()=>{
|
|
|
//console.log('focusOnObjectSuccess: '+object.name, type)
|
|
|
deferred.resolve();
|
|
|
- }
|
|
|
+ },
|
|
|
}, duration);
|
|
|
}else {
|
|
|
- viewer.scene.view.setView({position, target, duration, callback:()=>{
|
|
|
+ viewer.scene.view.setView({position, target, duration,
|
|
|
+ endYaw:o.endYaw, endPitch:o.endPitch,
|
|
|
+ callback:()=>{
|
|
|
//console.log('focusOnObjectSuccess: '+object.name, type)
|
|
|
deferred.resolve();
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
+ );}
|
|
|
|
|
|
|
|
|
|