Function: placeObjectAtIntersectionFacingTarget()
placeObjectAtIntersectionFacingTarget(
obj
,intersection
,target
):Object3D
<Object3DEventMap
>
Defined in: src/utils/ObjectPlacement.ts:32
Places and orients an object at a specific intersection point on another object's surface. The placed object's 'up' direction will align with the surface normal at the intersection, and its 'forward' direction will point towards a specified target object (e.g., the camera), but constrained to the surface plane.
This is useful for placing objects on walls or floors so they sit flat against the surface but still turn to face the user.
Parameters
obj
The object to be placed and oriented.
intersection
Intersection
The intersection data from a raycast, containing the point and normal of the surface. The normal is assumed to be in local space.
target
The object that obj
should face (e.g., the
camera).
Returns
Object3D
<Object3DEventMap
>
The modified obj
.