UNPKG

@giro3d/giro3d

Version:

A JS/WebGL framework for 3D geospatial data visualization

42 lines (40 loc) 963 B
/* * Copyright (c) 2015-2018, IGN France. * Copyright (c) 2018-2026, Giro3D team. * SPDX-License-Identifier: MIT */ import { Object3D } from 'three'; import { isPointMesh } from './PointMesh'; export default class MultiPointMesh extends Object3D { isSimpleGeometryMesh = true; isMultiPointMesh = true; type = 'MultiPointMesh'; userData = {}; constructor(points) { super(); this.add(...points); } set opacity(opacity) { this.traversePoints(p => p.opacity = opacity); } /** * Executes the callback on all the {@link PointMesh}es of this mesh. * @param callback - The callback to execute. */ traversePoints(callback) { this.traverse(obj => { if (isPointMesh(obj)) { callback(obj); } }); } dispose() { this.traversePoints(p => p.dispose()); this.dispatchEvent({ type: 'dispose' }); } } export function isMultiPointMesh(obj) { return obj?.isMultiPointMesh ?? false; }