diff --git a/packages/core/package.json b/packages/core/package.json index b01080b9..5bf73f09 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@thatopen/components", "description": "Collection of core functionalities to author BIM apps.", - "version": "2.1.13", + "version": "2.1.14", "author": "That Open Company", "contributors": [ "Antonio Gonzalez Viegas (https://github.com/agviegas)", diff --git a/packages/core/src/core/Cullers/index.ts b/packages/core/src/core/Cullers/index.ts index 66c1fff5..965128f0 100644 --- a/packages/core/src/core/Cullers/index.ts +++ b/packages/core/src/core/Cullers/index.ts @@ -1,3 +1,4 @@ +import * as THREE from "three"; import { Components } from "../Components"; import { MeshCullerRenderer, CullerRendererSettings } from "./src"; import { Component, Event, Disposable, World } from "../Types"; @@ -91,4 +92,17 @@ export class Cullers extends Component implements Disposable { } this.list.clear(); } + + /** + * Updates the given instanced meshes inside the all the cullers. You should use this if you change the count property, e.g. when changing the visibility of fragments. + * + * @param meshes - The meshes to update. + * + * @returns {void} + */ + updateInstanced(meshes: Iterable) { + for (const [, culler] of this.list) { + culler.updateInstanced(meshes); + } + } } diff --git a/packages/core/src/core/Cullers/src/mesh-culler-renderer.ts b/packages/core/src/core/Cullers/src/mesh-culler-renderer.ts index ce884314..5e47caf0 100644 --- a/packages/core/src/core/Cullers/src/mesh-culler-renderer.ts +++ b/packages/core/src/core/Cullers/src/mesh-culler-renderer.ts @@ -215,6 +215,23 @@ export class MeshCullerRenderer extends CullerRenderer implements Disposable { this.isProcessing = false; } + /** + * Updates the given instanced meshes inside the culler. You should use this if you change the count property, e.g. when changing the visibility of fragments. + * + * @param meshes - The meshes to update. + * + * @returns {void} + */ + updateInstanced(meshes: Iterable) { + for (const mesh of meshes) { + const colorMesh = this.colorMeshes.get(mesh.uuid); + if (!colorMesh) { + continue; + } + colorMesh.count = mesh.count; + } + } + private handleWorkerMessage = async (event: MessageEvent) => { if (this.isProcessing) { return;