UNPKG

@loaders.gl/3d-tiles

Version:

3D Tiles, an open standard for streaming massive heterogeneous 3D geospatial datasets.

33 lines (32 loc) 1.86 kB
// loaders.gl // SPDX-License-Identifier: MIT AND Apache-2.0 // Copyright vis.gl contributors // This file is derived from the Cesium code base under Apache 2 license // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md import { TILE3D_TYPE } from "../constants.js"; import { getMagicString } from "./helpers/parse-utils.js"; import { parsePointCloud3DTile } from "./parse-3d-tile-point-cloud.js"; import { parseBatchedModel3DTile } from "./parse-3d-tile-batched-model.js"; import { parseInstancedModel3DTile } from "./parse-3d-tile-instanced-model.js"; import { parseComposite3DTile } from "./parse-3d-tile-composite.js"; import { parseGltf3DTile } from "./parse-3d-tile-gltf.js"; // Extracts export async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = { shape: 'tile3d' }) { tile.byteOffset = byteOffset; tile.type = getMagicString(arrayBuffer, byteOffset); switch (tile.type) { case TILE3D_TYPE.COMPOSITE: // Note: We pass this function as argument so that embedded tiles can be parsed recursively return await parseComposite3DTile(tile, arrayBuffer, byteOffset, options, context, parse3DTile); case TILE3D_TYPE.BATCHED_3D_MODEL: return await parseBatchedModel3DTile(tile, arrayBuffer, byteOffset, options, context); case TILE3D_TYPE.GLTF: return await parseGltf3DTile(tile, arrayBuffer, options, context); case TILE3D_TYPE.INSTANCED_3D_MODEL: return await parseInstancedModel3DTile(tile, arrayBuffer, byteOffset, options, context); case TILE3D_TYPE.POINT_CLOUD: return await parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, context); default: throw new Error(`3DTileLoader: unknown type ${tile.type}`); // eslint-disable-line } }