UNPKG

@giro3d/giro3d

Version:

A JS/WebGL framework for 3D geospatial data visualization

113 lines (98 loc) 2.57 kB
/* * Copyright (c) 2015-2018, IGN France. * Copyright (c) 2018-2026, Giro3D team. * SPDX-License-Identifier: MIT */ import { EventDispatcher, MathUtils } from 'three'; import { nonNull } from '../utils/tsutils'; /** * Contains lightweight metadata about the source, such as point count. */ /** * A point cloud hierarchy node. */ /** * Performs a depth-first traversal of the node hierarchy, applying the callback to each traversed node. * If the callback returns `false` for a given node, the children of this node are not traversed. */ export function traverseNode(root, callback) { if (!root) { return; } const stack = [root]; while (stack.length > 0) { const currentNode = nonNull(stack.pop()); const shouldContinue = callback(currentNode); if (shouldContinue && currentNode.children) { for (let i = currentNode.children.length - 1; i >= 0; i--) { const child = currentNode.children[i]; if (child) { stack.push(child); } } } } } /** * Contains data for a single {@link PointCloudNode}. */ /** * Default event map. */ /** * Provides point cloud data. */ /** * Base class for sources that provide point cloud data. */ export class PointCloudSourceBase extends EventDispatcher { isMemoryUsage = true; /** Read-only flag to indicate that this object is a PointCloudSource. */ isPointCloudSource = true; /** An auto-generated UUID used internally to create unique keys for various purposes. */ id = MathUtils.generateUUID(); _initializePromise = null; _ready = false; get ready() { return this._ready; } /** * Initialize this source. * As long as this source is not initialized, it cannot be used. */ initialize() { if (!this._initializePromise) { this._initializePromise = this.initializeOnce(); this._initializePromise.then(() => { this._ready = true; this.dispatchEvent({ type: 'initialized' }); }); } return this._initializePromise; } /** * Raises an event to reload the source. */ update() { this.dispatchEvent({ type: 'updated' }); } /** * Implement by subclasses to initialize the source. This is automatically called by {@link initialize}. */ /** * Gets the hierarchy of this point cloud. * * Note: this does not provide point cloud data itself. */ /** * Gets the metadata of this source. */ /** * Loads buffer data for the specific {@link PointCloudNode}. * @param params - Options. */ }