@@ -63,7 +63,15 @@ function initializeSkull(geometry) {
6363 myMesh . position . set ( 0 , 0 , 0 ) ;
6464 myMesh . rotation . x = 0.2 ;
6565
66- camera . position . x = bbox . max . x * 9 ;
66+ if ( window . innerWidth < window . innerHeight ) {
67+ myMesh . rotation . x = 0.2 - Math . PI / 2 ;
68+ }
69+
70+ const screenArea = window . innerWidth * window . innerHeight ;
71+ const referenceArea = 1920 * 1080 ;
72+ const scaleFactor = Math . sqrt ( screenArea / referenceArea ) ;
73+
74+ camera . position . x = ( bbox . max . x * ( window . innerWidth < window . innerHeight ? 4 : 6 ) ) / scaleFactor ;
6775 camera . position . y = 0 ;
6876 camera . position . z = 0 ;
6977 camera . lookAt ( 0 , 0 , 0 ) ;
@@ -91,4 +99,18 @@ window.addEventListener('resize', function () {
9199 camera . updateProjectionMatrix ( ) ;
92100 renderer . setSize ( window . innerWidth , window . innerHeight ) ;
93101 effect . setSize ( window . innerWidth , window . innerHeight ) ;
102+
103+ if ( window . innerWidth < window . innerHeight ) {
104+ myMesh . rotation . x = 0.2 - Math . PI / 2 ;
105+ } else {
106+ myMesh . rotation . x = 0.2 ;
107+ }
108+
109+ if ( myMesh . geometry ) {
110+ const bbox = myMesh . geometry . boundingBox ;
111+ const screenArea = window . innerWidth * window . innerHeight ;
112+ const referenceArea = 1920 * 1080 ;
113+ const scaleFactor = Math . sqrt ( screenArea / referenceArea ) ;
114+ camera . position . x = ( bbox . max . x * ( window . innerWidth < window . innerHeight ? 4 : 6 ) ) / scaleFactor ;
115+ }
94116} ) ;
0 commit comments