Continuing the discussion from Multiple placement webAR Not working:
let me give you everything to check:
this is my hierarchy.
the xr has the webXRPlaneTracking component from needle ts.
the ARSpawner has this script:
import { Behaviour, serializable, IPointerClickHandler, PointerEventData } from "@needle-tools/engine";
import { Object3D, Vector3 } from "three";
export class ARObjectSpawner extends Behaviour implements IPointerClickHandler {
// Assign your prefab in the Unity Inspector
@serializable(Object3D)
public objectPrefab: Object3D | null = null;
// Called on tap/click events in the AR scene
onPointerClick(event: PointerEventData): void {
if (!this.objectPrefab) return;
// Clone the prefab instance
const newObject = this.objectPrefab.clone();
// Optionally, if the event contains a world position (for example, using a raycast hit point), use it:
const targetPos = (event as any).hitPoint || new Vector3(0, 0, 0);
newObject.position.copy(targetPos);
// Add the new object as a child to this gameObject to keep it in the scene
this.gameObject.add(newObject);
}
// Method to allow UI button to place an object at a given position
public placeObjectAtPosition(position: Vector3): void {
if (!this.objectPrefab) return;
const newObject = this.objectPrefab.clone();
newObject.position.copy(position);
this.gameObject.add(newObject);
}
}
the raycaster have a object raycaster component also from needle.
and the Placeable object is the prefab.
it works only one time to place on the gizmo on place tracking. then nothing.