@@ -328,11 +328,18 @@ export class ARRenderer extends EventDispatcher<
328
328
this . yawDamper . setDecayTime ( DECAY ) ;
329
329
this . pitchDamper . setDecayTime ( DECAY ) ;
330
330
this . rollDamper . setDecayTime ( DECAY ) ;
331
+ this . scaleDamper . setDecayTime ( DECAY ) ;
331
332
}
332
333
333
334
this . currentSession = currentSession ;
334
335
this . placementBox =
335
336
new PlacementBox ( scene , this . placeOnWall ? 'back' : 'bottom' ) ;
337
+
338
+ // Set screen space mode for proper positioning
339
+ if ( this . placementBox ) {
340
+ this . placementBox . setScreenSpaceMode ( this . xrMode === XRMode . SCREEN_SPACE ) ;
341
+ }
342
+
336
343
this . placementComplete = false ;
337
344
338
345
if ( this . xrMode !== XRMode . SCREEN_SPACE ) {
@@ -561,9 +568,11 @@ export class ARRenderer extends EventDispatcher<
561
568
562
569
onUpdateScene = ( ) => {
563
570
if ( this . placementBox != null && this . isPresenting ) {
564
- this . placementBox ! . dispose ( ) ;
565
- this . placementBox = new PlacementBox (
566
- this . presentedScene ! , this . placeOnWall ? 'back' : 'bottom' ) ;
571
+ // Update the existing placement box with new model dimensions instead of recreating
572
+ this . placementBox ! . updateFromModelChanges ( ) ;
573
+
574
+ // Ensure screen space mode is maintained
575
+ this . placementBox ! . setScreenSpaceMode ( this . xrMode === XRMode . SCREEN_SPACE ) ;
567
576
}
568
577
if ( this . xrMode !== XRMode . SCREEN_SPACE ) {
569
578
if ( this . menuPanel ) {
@@ -1162,7 +1171,17 @@ export class ARRenderer extends EventDispatcher<
1162
1171
}
1163
1172
1164
1173
private updatePlacementBoxOpacity ( box : PlacementBox , delta : number ) {
1165
- box . updateOpacity ( delta ) ;
1174
+ // Use the new enhanced update method that includes distance scaling and visual state
1175
+ const camera = this . presentedScene ! . getCamera ( ) ;
1176
+ box . update ( delta , camera . position ) ;
1177
+
1178
+ // Update interaction state based on hover
1179
+ const over1 = this . hover ( this . xrController1 ! ) ;
1180
+ const over2 = this . hover ( this . xrController2 ! ) ;
1181
+ const isHovered = ( over1 || over2 ) && ! this . isTwoHandInteraction ;
1182
+
1183
+ // Set interaction state for visual feedback
1184
+ box . setInteractionState ( this . isTranslating || this . isRotating , isHovered ) ;
1166
1185
}
1167
1186
1168
1187
private updateTwoHandInteractionState ( ) {
@@ -1186,7 +1205,13 @@ export class ARRenderer extends EventDispatcher<
1186
1205
private updateXRControllerHover ( ) {
1187
1206
const over1 = this . hover ( this . xrController1 ! ) ;
1188
1207
const over2 = this . hover ( this . xrController2 ! ) ;
1189
- this . placementBox ! . show = ( over1 || over2 ) && ! this . isTwoHandInteraction ;
1208
+ const isHovered = ( over1 || over2 ) && ! this . isTwoHandInteraction ;
1209
+
1210
+ // Use the new interaction state system
1211
+ if ( this . placementBox ) {
1212
+ this . placementBox . setInteractionState ( this . isTranslating || this . isRotating , isHovered ) ;
1213
+ this . placementBox . show = isHovered ;
1214
+ }
1190
1215
}
1191
1216
1192
1217
0 commit comments