Skip to content
TREN
Atlıhan Harita

LCC for Web User Manual · API Reference

LCCObject::raycastFromOrigin

Chapter 06.21 / 07Manual version v0.6.4English

Custom origin and direction raycasting.

Supports custom origin and direction for raycasting against LCC model data in world space.

Version Requirement

SDK v0.3.0+

Engine Support

Three.js / CesiumJS

API

LCCObject::raycastFromOrigin(param: RaycastFromOriginParam): IPoint3 | null

Parameters

ParameterTypeRequiredDefaultDescription
param.origin{ x: number, y: number, z: number }Yes-Ray origin in world space coordinates.
param.direction{ x: number, y: number, z: number }Yes-Ray direction; can be normalized or unnormalized.
param.maxDistancenumberYes-Detection distance, in meters.
param.radiusnumberYes-Detection precision, in meters.
param.opacityThresholdnumberNo0.5Opacity threshold for high-precision detection, range [0, 1]. Only effective when usePrecisionRaycast is true. SDK v0.6.3+

Return Value

IPoint3 | null — Detected point coordinates (x, y, z) in world space. Returns null if no point is detected.

Usage Example

const origin = { x: 10, y: 10, z: 10 };
const startPos = { x: 10, y: 10, z: 10 };
const endPos = { x: 50, y: 50, z: 50 };
const direction = {
    x: endPos.x - startPos.x,
    y: endPos.y - startPos.y,
    z: endPos.z - startPos.z
};
const maxDistance = 100;
const radius = 0.01;

let checkPos = lccObject.raycastFromOrigin({ origin, direction, maxDistance, radius });
if (checkPos) {
    console.log('checkPos: ', checkPos.x, checkPos.y, checkPos.z);
} else {
    // No point detected
}

Notes

  • This method must be called after the success callback of LCCRender.load() has been triggered.
  • direction can be a normalized or unnormalized vector.
  • A smaller radius gives higher detection precision but lower hit rate. For high-precision measurements, 0.1 is recommended; increase further if no data is detected.
  • LCCObject::raycast()
  • LCCObject::intersectsRayFromOriginExt()

This chapter is from the official XGRIDS user manual. Official source (opens in a new tab) · Updated:

XGRIDS Türkiye

We're With You During Setup and in the Field

Atlıhan Harita provides training and technical support for device setup, firmware updates, software use, and field applications. Send us your question and our specialist will get back to you.

+90 216 546 0804