@@ -46,6 +46,7 @@ export class BookScene {
4646 private raycaster : THREE . Raycaster = new THREE . Raycaster ( ) ;
4747 private mouse : THREE . Vector2 = new THREE . Vector2 ( ) ;
4848 private isFluttering : boolean = false ;
49+ private isHoveringCover = false ;
4950
5051 constructor ( container : HTMLDivElement ) {
5152 this . container = container ;
@@ -77,10 +78,10 @@ export class BookScene {
7778 this . renderer . setClearColor ( palette . bg [ 0 ] ) ;
7879 this . container . appendChild ( this . renderer . domElement ) ;
7980
80- this . setUpLight ( ) ;
81+ this . setupLight ( ) ;
8182 // this.setupLightControls();
8283 this . setupLoadingManager ( ) ;
83- this . setUpPositionAndRotation ( ) ;
84+ this . setupPositionAndRotation ( ) ;
8485 this . setupHoverInteraction ( ) ;
8586
8687 window . addEventListener ( 'resize' , ( ) => this . handleResize ( ) ) ;
@@ -94,6 +95,7 @@ export class BookScene {
9495 private setupLoadingManager ( ) {
9596 const loadingOverlay = document . getElementById ( 'loading-overlay' ) ;
9697 const loadingBar = document . getElementById ( 'loading-bar' ) ;
98+ const dog = loadingBar . firstChild ;
9799
98100 if ( ! loadingOverlay || ! loadingBar ) {
99101 console . error ( 'Loading screen elements not found in the DOM.' ) ;
@@ -106,7 +108,7 @@ export class BookScene {
106108 } ;
107109
108110 this . loadingManager . onLoad = ( ) => {
109- ( loadingBar as HTMLElement ) . classList . add ( "done" ) ;
111+ ( dog as HTMLElement ) . classList . add ( "done" ) ;
110112
111113 setTimeout ( ( ) => {
112114 this . renderable = true ;
@@ -123,7 +125,7 @@ export class BookScene {
123125 } ;
124126 }
125127
126- private setUpLight ( ) {
128+ private setupLight ( ) {
127129 this . scene . add ( this . ambientLight ) ;
128130
129131 const rLight = new THREE . DirectionalLight ( 0xffffff , 0.6 ) ;
@@ -163,6 +165,7 @@ export class BookScene {
163165 this . renderer . domElement . addEventListener ( 'mousemove' , this . _onMouseMove . bind ( this ) , false ) ;
164166 }
165167
168+
166169 private _onMouseMove ( event : MouseEvent ) {
167170 if ( this . openingAnimationStatus !== 'none' || this . isFluttering || this . isMobile ) {
168171 return ;
@@ -178,7 +181,12 @@ export class BookScene {
178181 const intersects = this . raycaster . intersectObject ( cover , true ) ;
179182
180183 if ( intersects . length > 0 ) {
181- this . _playFlutterAnimation ( ) ;
184+ if ( ! this . isHoveringCover ) {
185+ this . _playFlutterAnimation ( ) ;
186+ this . isHoveringCover = true ;
187+ }
188+ } else {
189+ this . isHoveringCover = false ;
182190 }
183191 }
184192
@@ -207,7 +215,7 @@ export class BookScene {
207215 }
208216
209217
210- private setUpPositionAndRotation ( ) {
218+ private setupPositionAndRotation ( ) {
211219 this . camera . position . add ( this . initialCameraOffset ) ;
212220 this . camera . up . copy ( this . initialCameraUp ) ;
213221
@@ -514,8 +522,8 @@ export class BookScene {
514522 zooGroup . position . set ( config . pageWidth , 0.2 , config . pageHeight * 0.8 ) ;
515523 zooGroup . rotation . y = - Math . PI / 2 ;
516524 } else {
517- zooGroup . position . set ( config . pageWidth * 0.5 , 0 , 0 ) ;
518- zooGroup . rotation . y = - Math . PI / 12 ;
525+ zooGroup . position . set ( config . pageWidth * 0.6 , 0 , 0 ) ;
526+ zooGroup . rotation . y = - Math . PI / 6 ;
519527 }
520528 this . homeGroup . add ( zooGroup ) ;
521529
@@ -553,7 +561,7 @@ export class BookScene {
553561 doubanGroup . position . set ( config . pageWidth / 2 , 0 , 0 ) ;
554562 doubanGroup . rotation . x = - Math . PI / 16 ;
555563 } else {
556- doubanGroup . position . set ( - config . pageWidth / 3 , 0 , 0 ) ;
564+ doubanGroup . position . set ( - config . pageWidth / 4 , 0 , 0 ) ;
557565 doubanGroup . rotation . y = Math . PI / 16 ;
558566 }
559567 this . homeGroup . add ( doubanGroup ) ;
@@ -564,7 +572,7 @@ export class BookScene {
564572
565573 this . book . add ( this . homeGroup ) ;
566574
567- const dropHeight = 10 ;
575+ const dropHeight = 6 ;
568576 const textTargetY = ( boxGeo : THREE . BoxGeometry ) => boxGeo . parameters . height / 2 + 0.4 ;
569577
570578 // Initial positions
@@ -574,14 +582,14 @@ export class BookScene {
574582 doubanText . position . y = dropHeight + textTargetY ( doubanBoxGeo ) ;
575583
576584 const tl = gsap . timeline ( {
577- defaults : { duration : 1 , ease : 'bounce.out' }
585+ defaults : { duration : 1.2 , ease : 'bounce.out' }
578586 } ) ;
579587
580588 tl . to ( zooBox . position , { y : 0 } , 0 ) ;
581- tl . to ( doubanBox . position , { y : 0 } , 0.3 ) ;
589+ tl . to ( doubanBox . position , { y : 0 } , 0.2 ) ;
582590
583- tl . to ( zooText . position , { y : textTargetY ( zooBoxGeo ) } , 1.2 ) ;
584- tl . to ( doubanText . position , { y : textTargetY ( doubanBoxGeo ) } , 1.4 ) ;
591+ tl . to ( zooText . position , { y : textTargetY ( zooBoxGeo ) } , 1 ) ;
592+ tl . to ( doubanText . position , { y : textTargetY ( doubanBoxGeo ) } , 1.2 ) ;
585593 } ) ;
586594 }
587595}
0 commit comments