LCCObject::intersectsRayExt
Collision-body-based raycasting that supports obtaining coordinate positions via screen clicks.
Version Requirement
SDK v0.5.0+
Engine Support
Three.js
API
LCCObject::intersectsRayExt(param: IntersectsRayExtParam): IntersectsResult | null
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
param.evt | MouseEvent / PointerEvent | Yes | - | Mouse click event. |
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 cond = lccObject.hasCollision();
if (cond) {
document.addEventListener('mousedown', (evt) => {
let ret = lccObject.intersectsRayExt({ evt: evt, maxDistance: 10 });
if (ret) {
console.log('point: ', ret.point.x, ret.point.y, ret.point.z);
console.log('normal: ', ret.normal.x, ret.normal.y, ret.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::intersectsRayFromOriginExt()LCCObject::raycast()