Hi Astuce, it sounds like your session is ālocking inā the initial scene placementāonce the first object is spawned, the AR session (or its plane-tracking component) marks the scene as placed and hides the plane-tracking gizmo, which in turn prevents additional objects from being added.
In Needle Engine the default behavior (for example, via WebARSessionRoot or similar components) is to finalize placement on the first hit. To allow multiple placements you can try the following:
⢠Ensure your WebXRPlaneTracking (or similar) component isnāt automatically disabling itself or its gizmo after the first placement. In many cases the AR system hides the reticle once a placement is confirmed.
⢠Separate your AR scene placement logic from your spawner logic. For example, perform an initial scene placement (using autoPlace or manual placement) and then use a dedicated spawnerādriven by its own raycaster for hit-testingāto let you add objects.
⢠Make sure that your spawned objects are not blocking pointer events. You may need to assign them to a layer or disable their own pointer interactions so that the AR plane remains āclickable.ā
Below is an example of a simplified spawner component that listens for pointer clicks and spawns a clone of a prefab at the clicked position. (You may need to adjust the code to use the hit-test results from your AR session rather than simply using a pointer position.)
import { Behaviour, serializable, IPointerClickHandler, PointerEventData } from "@needle-tools/engine";
import { Object3D } from "three";
export class MultiplePlacementSpawner extends Behaviour implements IPointerClickHandler {
// A reference to the prefab to spawn
@serializable(Object3D)
prefab: Object3D | null = null;
// This method is triggered on pointer (or AR hit) events
onPointerClick(event: PointerEventData) {
if (!this.prefab) return;
// Clone the prefab
const clone = this.prefab.clone();
// Here, use the AR hit test result to set the position.
// For demonstration, we copy the pointer hit's world position.
// You may need to use event.ray or your AR hit-test result instead.
clone.position.copy(event.ray.origin);
// Add the spawned object to the scene
this.gameObject.scene.add(clone);
console.log("Spawned an object at", clone.position);
}
}
Make sure that your spawner script isnāt triggering any āplacement lockedā flag. Also, review your XR objectās WebXRPlaneTracking for any logic that disables the gizmo after the first placement. By keeping the plane-tracking active (or by re-enabling it after each spawn) and ensuring that the spawned objects donāt block raycaster events, you should be able to perform multiple placements.
If you continue to have trouble, could you please share your spawner script and any custom configurations on your XR object? That way we can dig deeper into what might be causing the gizmo to disappear after the first placement.
Happy coding!
0 replies left - Become PRO for more replies.
thread_XC8mbN94SirOqpnenpzlizXx
Reply to this post directly if you need further help (bottom right button)