@@ -116,6 +116,7 @@ export function createPhoneScene(texture: Texture, layout: ReturnType<typeof pho
116116 new ShapeGeometry ( roundedPath ( width - 0.012 , height - 0.012 , 0.14 ) , 16 ) ,
117117 backMaterial ,
118118 ) ;
119+ back . name = "device-back" ;
119120 back . rotation . y = Math . PI ;
120121 back . position . z = - 0.075 ;
121122 orientation . add ( back ) ;
@@ -147,6 +148,14 @@ export function createPhoneScene(texture: Texture, layout: ReturnType<typeof pho
147148 button . position . set ( x ! , y ! , - 0.01 ) ;
148149 orientation . add ( button ) ;
149150 }
151+ // Rear components share a surface-relative coordinate system, with outward positive Z.
152+ const rearCamera = new Group ( ) ;
153+ rearCamera . name = "rear-camera" ;
154+ rearCamera . position . set ( width / 2 - 0.25 , height / 2 - 0.29 , back . position . z + 0.001 ) ;
155+ rearCamera . rotation . y = Math . PI ;
156+ orientation . add ( rearCamera ) ;
157+ const plateFront = 0.025 + 0.007 ;
158+ const ringDepth = 0.025 ;
150159 const cameraPlate = new Mesh (
151160 new ExtrudeGeometry ( roundedPath ( 0.39 , 0.44 , 0.095 ) , {
152161 depth : 0.025 ,
@@ -157,26 +166,25 @@ export function createPhoneScene(texture: Texture, layout: ReturnType<typeof pho
157166 } ) ,
158167 backMaterial ,
159168 ) ;
160- cameraPlate . position . set ( - width / 2 + 0.25 , height / 2 - 0.29 , - 0.1 ) ;
161- cameraPlate . rotation . y = Math . PI ;
162- orientation . add ( cameraPlate ) ;
169+ cameraPlate . name = "camera-plate" ;
170+ rearCamera . add ( cameraPlate ) ;
163171 for ( const [ x , y ] of [
164172 [ - 0.08 , 0.095 ] ,
165173 [ 0.08 , - 0.095 ] ,
166174 ] ) {
167175 const ring = new Mesh ( new CylinderGeometry ( 0.082 , 0.082 , 0.025 , 32 ) , metal ) ;
168176 ring . rotation . x = Math . PI / 2 ;
169- ring . position . set ( cameraPlate . position . x + x ! , cameraPlate . position . y + y ! , - 0.143 ) ;
170- orientation . add ( ring ) ;
177+ ring . name = "camera-ring" ;
178+ ring . position . set ( x ! , y ! , plateFront + ringDepth / 2 - 0.003 ) ;
179+ rearCamera . add ( ring ) ;
171180 const lens = new Mesh ( new CircleGeometry ( 0.068 , 32 ) , lensMaterial ) ;
172- lens . rotation . y = Math . PI ;
173- lens . position . set ( ring . position . x , ring . position . y , - 0.158 ) ;
174- orientation . add ( lens ) ;
181+ lens . name = "camera-lens" ;
182+ lens . position . set ( x ! , y ! , ring . position . z + ringDepth / 2 + 0.0005 ) ;
183+ rearCamera . add ( lens ) ;
175184 }
176185 const flash = new Mesh ( new CircleGeometry ( 0.022 , 20 ) , new MeshBasicMaterial ( { color : 0xf2ead6 } ) ) ;
177- flash . position . set ( cameraPlate . position . x + 0.085 , cameraPlate . position . y + 0.11 , - 0.139 ) ;
178- flash . rotation . y = Math . PI ;
179- orientation . add ( flash ) ;
186+ flash . position . set ( 0.085 , 0.11 , plateFront + 0.0005 ) ;
187+ rearCamera . add ( flash ) ;
180188
181189 const raycaster = new Raycaster ( ) ;
182190 const pointer = new Vector2 ( ) ;
0 commit comments