Variable: EnvironmentRaycastTarget
constEnvironmentRaycastTarget:Component<{inputSource: {default:any;type:Object; };maxDistance: {default:number;type:Float32; };offsetPosition: {default:any;type:Object; };offsetQuaternion: {default:any;type:Object; };space: {default:"right";enum: {Left:"left";Right:"right";Screen:"screen";Viewer:"viewer"; };type:Enum; };xrHitTestResult: {default:any;type:Object; }; }>
Defined in: packages/core/src/environment-raycast/raycast-target.ts:56
Component that makes an entity follow environment raycast hit points.
Remarks
The entity's Object3D is automatically positioned at the raycast hit point and oriented to match the surface normal. When there's no hit, the Object3D is hidden.
Use offsetPosition and offsetQuaternion to offset the ray from the space origin. This is useful for one-shot raycasts where you want to cast from a specific position/orientation relative to the controller.
Examples
const reticle = world.createTransformEntity(reticleMesh);
reticle.addComponent(EnvironmentRaycastTarget, { space: RaycastSpace.Right });
// Reticle automatically moves to where controller pointsconst xrResult = entity.getValue(EnvironmentRaycastTarget, 'xrHitTestResult');
if (xrResult && gamepad.getSelectStart()) {
spawnObject(entity.object3D.position.clone());
}