LCCObject::intersectsRayFromOriginExt
Collision-body-based raycasting with custom origin and direction.
Version Requirement
SDK v0.5.0+
Engine Support
Three.js
API
LCCObject::intersectsRayFromOriginExt(param: IntersectsRayFromOriginExtParam): IntersectsResult | null
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
param.origin | { x: number, y: number, z: number } | Yes | - | Ray origin. |
param.direction | { x: number, y: number, z: number } | Yes | - | Ray direction. |
param.maxDistance | number | Yes | - | Detection distance, in meters. |
Return Value
Returns an object containing point and normal on success; returns null on failure.
| Property | Type | Description |
|---|---|---|
point | { x: number, y: number, z: number } | Collision point coordinates in world space. |
normal | { x: number, y: number, z: number } | Collision point normal in world space. |
Usage Example
const ret = lccObject.hasCollision();
if (ret) {
const origin = { x: 10, y: 10, z: 10 };
const direction = { x: 1, y: 0, z: 0 };
const maxDistance = 10;
let result = lccObject.intersectsRayFromOriginExt({ origin, direction, maxDistance });
if (result) {
console.log('point: ', result.point.x, result.point.y, result.point.z);
console.log('normal: ', result.normal.x, result.normal.y, result.normal.z);
} else {
// No point detected
}
} else {
// Collision function not supported
}
Notes
- This method must be called after the success callback of
LCCRender.load()has been triggered. - Check collision support via
hasCollision()before use. - The SDK only loads collision data within the vicinity of the camera position.
Related APIs
LCCObject::hasCollision()LCCObject::intersectsRayExt()LCCObject::raycastFromOrigin()