Skip to content
TREN
Atlıhan Harita

LCC for Web User Manual · API Reference

LCCObject::raycast

Chapter 06.20 / 07Manual version v0.6.4English

Screen-click-based raycasting.

Can be used for annotation, measurement, ground detection (digital humans), and more.

Version Requirement

SDK v0.3.0+

Engine Support

Three.js / CesiumJS

API

LCCObject::raycast(param: RaycastParam): IPoint3 | null

Parameters

ParameterTypeRequiredDefaultDescription
param.evtMouseEvent / PointerEventYes-Mouse click event, e.g., mousedown.
param.maxDistancenumberYes-Maximum detection distance, in meters.
param.radiusnumberYes-Detection precision; adjust based on the actual scenario, 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

Three.js

document.addEventListener('mousedown', (evt) => {
    let checkPos = lccObject.raycast({ evt: evt, maxDistance: 100, radius: 0.1 });
    if (checkPos) {
        console.log(checkPos.x, checkPos.y, checkPos.z);
    } else {
        // No point detected
    }
});

CesiumJS

viewer.scene.canvas.addEventListener('pointerdown', (evt) => {
    let checkPos = lccObject.raycast({ evt: evt, maxDistance: 100, radius: 0.1 });
    if (checkPos) {
        console.log(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.
  • In Cesium, listen to the canvas pointerdown event, not document's mousedown.
  • The returned coordinates are in world space.
  • LCCObject::raycastFromOrigin()
  • LCCObject::intersectsRayExt()

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