@@ -100,6 +100,7 @@ export class Viewer {
100100 this . camera ! ,
101101 this . renderer ! . domElement
102102 ) ;
103+ this . cameraControls . maxPolarAngle = Math . PI / 2 ;
103104 }
104105
105106 protected initScene ( ) {
@@ -129,7 +130,7 @@ export class Viewer {
129130 this . scene ?. add ( light1 ) ;
130131
131132 const light2 = new THREE . DirectionalLight ( 0xffffff , 1 ) ;
132- light2 . position . set ( 0.5 , 0 , 0.866 ) . multiplyScalar ( 300 ) ; // ~60º
133+ light2 . position . set ( 0.5 , 1 , 0.866 ) . multiplyScalar ( 300 ) ; // ~60º
133134 light2 . name = "main_light" ;
134135 this . scene ?. add ( light2 ) ;
135136 }
@@ -187,6 +188,7 @@ export class Viewer {
187188 this . animiteObject ( frontDoor ) ;
188189 const backDoor = this . rackObject . getObjectByName ( "rack-back-door" ) ! ;
189190 this . animiteObject ( backDoor ) ;
191+ this . rackObject = undefined ;
190192 }
191193 this . clearHighlight ( ) ;
192194 this . cameraControls ?. reset ( true ) ;
@@ -236,16 +238,15 @@ export class Viewer {
236238 const position = lookAt . clone ( ) . add ( direction . multiplyScalar ( distance ! ) ) ;
237239
238240 // 飞向机柜门正面
239- return this . cameraControls
240- ?. setLookAt (
241- position . x ,
242- position . y ,
243- position . z ,
244- lookAt . x ,
245- lookAt . y ,
246- lookAt . z ,
247- true
248- ) ;
241+ return this . cameraControls ?. setLookAt (
242+ position . x ,
243+ position . y ,
244+ position . z ,
245+ lookAt . x ,
246+ lookAt . y ,
247+ lookAt . z ,
248+ true
249+ ) ;
249250 }
250251
251252 protected animiteObject ( object : THREE . Object3D ) {
@@ -383,16 +384,34 @@ export class Viewer {
383384 // @ts -ignore
384385 private createPathFlight ( ) {
385386 const points = [
386- [ - 2108.1056622497044 , 0 , - 1768.2852733169518 ] ,
387- [ - 2090.8022641659068 , 0 , - 8.999541340935856 ] ,
388- [ 252.92217113182915 , 0 , - 21.646393904821025 ] ,
389- [ 2579.693282778835 , 0 , - 16.824099103697677 ] ,
390- [ 2488.183270612835 , 0 , 1271.4025633512294 ] ,
391- [ 321.0467169543589 , 0 , 1261.9262629538507 ] ,
392- [ - 2131.2017368499573 , 0 , 1230.3146832488842 ] ,
387+ [ - 2108.1056622497044 , 140 , - 1768.2852733169518 ] ,
388+ [ - 2090.8022641659068 , 140 , - 8.999541340935856 ] ,
389+ [ 252.92217113182915 , 140 , - 21.646393904821025 ] ,
390+ [ 2579.693282778835 , 140 , - 16.824099103697677 ] ,
391+ [ 2488.183270612835 , 140 , 1271.4025633512294 ] ,
392+ [ 321.0467169543589 , 140 , 1261.9262629538507 ] ,
393+ [ - 2131.2017368499573 , 140 , 1230.3146832488842 ] ,
393394 ] ;
394395 const vectors = points . map ( ( p ) => new THREE . Vector3 ( p [ 0 ] , p [ 1 ] , p [ 2 ] ) ) ;
395- const curve = new THREE . CatmullRomCurve3 ( vectors ) ;
396+ const curve = new THREE . CatmullRomCurve3 ( vectors , false , "catmullrom" , 0.1 ) ;
397+
398+ new Tween ( { t : 0 } , this . tween )
399+ . to ( { t : 0.99 } , 20 * 1000 )
400+ . easing ( Easing . Linear . Out )
401+ . onUpdate ( ( v ) => {
402+ const eye = curve . getPointAt ( v . t ) ;
403+ const lookAt = curve . getPointAt ( v . t + 0.01 ) ;
404+ this . cameraControls ?. setLookAt (
405+ eye . x ,
406+ eye . y ,
407+ eye . z ,
408+ lookAt . x ,
409+ lookAt . y ,
410+ lookAt . z ,
411+ false
412+ ) ;
413+ } )
414+ . start ( ) ;
396415
397416 const tubeGeometry = new THREE . TubeGeometry ( curve , 100 , 20 , 5 , false ) ;
398417 const material = new THREE . MeshLambertMaterial ( { color : 0xff00ff } ) ;
0 commit comments