LCCObject::getBounds
獲取 LCC 模型場景的 AABB 包圍盒(Bounding Box)。
版本要求
SDK v0.4.0+
引擎支持
Three.js / CesiumJS
API
LCCObject::getBounds(): BoundingBox
參數
無
返回值
返回包圍盒對象,包含以下屬性:
Three.js
| 屬性 | 類型 | 描述 |
|---|---|---|
min | { x: number, y: number, z: number } | 包圍盒最小點坐標。 |
max | { x: number, y: number, z: number } | 包圍盒最大點坐標。 |
CesiumJS
| 屬性 | 類型 | 描述 |
|---|---|---|
min | { x: number, y: number, z: number } | 包圍盒最小點坐標。 |
max | { x: number, y: number, z: number } | 包圍盒最大點坐標。 |
origin | { x: number, y: number, z: number } | 場景基準點坐標(WGS84 笛卡爾坐標系)。 |
使用示例
Three.js
const box = lccObject.getBounds();
console.log('min: ', box.min.x, box.min.y, box.min.z);
console.log('max: ', box.max.x, box.max.y, box.max.z);
CesiumJS
const box = lccObject.getBounds();
console.log('min: ', box.min.x, box.min.y, box.min.z);
console.log('max: ', box.max.x, box.max.y, box.max.z);
console.log('origin: ', box.origin.x, box.origin.y, box.origin.z);
注意事項
- 此接口需在
LCCRender.load()的成功回調函數觸發後調用。 - Three.js 中獲取的包圍盒基於 LCC 模型的局部坐標系。
- CesiumJS 中,非 RTK 數據獲取的包圍盒基於 LCC 模型的局部坐標系;RTK 數據獲取的包圍盒基於投影坐標系。
origin為 WGS84 笛卡爾坐標系。
相關 API
LCCObject::getProjectionCoordinateSystemInfos()