Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openbim-components

Package Overview
Dependencies
Maintainers
2
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openbim-components - npm Package Compare versions

Comparing version 0.0.37 to 0.0.38

visibility/postproduction/postproduction-renderer.d.ts

3

cameras/orto-perspective-camera/ortho-perspective-camera.d.ts

@@ -27,2 +27,4 @@ import * as THREE from "three";

constructor(components: Components);
/** {@link Disposable.dispose} */
dispose(): void;
/**

@@ -76,2 +78,3 @@ * Similar to {@link Component.get}, but with an optional argument

private setOrthoCameraAspect;
private toggleEvents;
}

24

cameras/orto-perspective-camera/ortho-perspective-camera.js

@@ -29,8 +29,11 @@ import * as THREE from "three";

this.currentMode.toggle(true, { preventTargetAdjustment: true });
const modes = Object.values(this._navigationModes);
for (const mode of modes) {
mode.projectionChanged.on(this.projectionChanged.trigger);
}
this.toggleEvents(true);
this._projectionManager = new ProjectionManager(components, this);
}
/** {@link Disposable.dispose} */
dispose() {
super.dispose();
this.toggleEvents(false);
this._orthoCamera.removeFromParent();
}
/**

@@ -63,3 +66,3 @@ * Similar to {@link Component.get}, but with an optional argument

const newProjection = projection === "Perspective" ? "Orthographic" : "Perspective";
this.setProjection(newProjection);
await this.setProjection(newProjection);
}

@@ -181,3 +184,14 @@ /**

}
toggleEvents(active) {
const modes = Object.values(this._navigationModes);
for (const mode of modes) {
if (active) {
mode.projectionChanged.on(this.projectionChanged.trigger);
}
else {
mode.projectionChanged.reset();
}
}
}
}
//# sourceMappingURL=ortho-perspective-camera.js.map

@@ -11,4 +11,5 @@ import * as THREE from "three";

this._camera = camera;
this._currentCamera = camera.get("Perspective");
this._currentProjection = "Perspective";
const perspective = "Perspective";
this._currentCamera = camera.get(perspective);
this._currentProjection = perspective;
}

@@ -15,0 +16,0 @@ get projection() {

@@ -43,2 +43,3 @@ import * as THREE from "three";

private _clock;
private _enabled;
/**

@@ -45,0 +46,0 @@ * The [Three.js renderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer)

@@ -36,3 +36,6 @@ import * as THREE from "three";

this.meshes = [];
this._enabled = true;
this.update = () => {
if (!this._enabled)
return;
const delta = this._clock.getDelta();

@@ -191,3 +194,10 @@ Components.update(this.scene, delta);

dispose() {
// TODO: Implement memory disposal for the whole library
this._enabled = false;
this.tools.dispose();
if (this.renderer.isDisposeable())
this.renderer.dispose();
if (this.scene.isDisposeable())
this.scene.dispose();
if (this.camera.isDisposeable())
this.camera.dispose();
}

@@ -194,0 +204,0 @@ static update(component, delta) {

@@ -37,3 +37,7 @@ /**

};
/**
* Gets rid of all the suscribed events.
*/
reset(): void;
private handlers;
}

@@ -35,3 +35,9 @@ /**

}
/**
* Gets rid of all the suscribed events.
*/
reset() {
this.handlers.length = 0;
}
}
//# sourceMappingURL=event.js.map

@@ -5,3 +5,3 @@ import * as THREE from "three";

import { Event } from "./event";
import { Updateable } from "./base-types";
import { Disposable, Updateable } from "./base-types";
import { Component } from "./base-components";

@@ -14,3 +14,3 @@ /**

*/
export declare class SimpleCamera extends Component<THREE.PerspectiveCamera | THREE.OrthographicCamera> implements Updateable {
export declare class SimpleCamera extends Component<THREE.PerspectiveCamera | THREE.OrthographicCamera> implements Updateable, Disposable {
components: Components;

@@ -42,2 +42,4 @@ /** {@link Component.name} */

get(): THREE.PerspectiveCamera | THREE.OrthographicCamera;
/** {@link Disposable.dispose} */
dispose(): void;
/** {@link Updateable.update} */

@@ -44,0 +46,0 @@ update(_delta: number): void;

@@ -40,2 +40,10 @@ import * as THREE from "three";

}
/** {@link Disposable.dispose} */
dispose() {
this.enabled = false;
this.beforeUpdate.reset();
this.afterUpdate.reset();
this._perspectiveCamera.removeFromParent();
this.controls.dispose();
}
/** {@link Updateable.update} */

@@ -42,0 +50,0 @@ update(_delta) {

@@ -8,3 +8,3 @@ import * as THREE from "three";

/**
* An lightweight component to easily create and handle
* A lightweight component to easily create and handle
* [clipping planes](https://threejs.org/docs/#api/en/materials/Material.clippingPlanes).

@@ -11,0 +11,0 @@ *

@@ -5,3 +5,3 @@ import * as THREE from "three";

/**
* An lightweight component to easily create and handle
* A lightweight component to easily create and handle
* [clipping planes](https://threejs.org/docs/#api/en/materials/Material.clippingPlanes).

@@ -98,2 +98,3 @@ *

dispose() {
this._enabled = false;
for (const plane of this._planes) {

@@ -103,3 +104,5 @@ plane.dispose();

this._planes.length = 0;
this.components = null;
this._material.dispose();
this.onStartDragging.reset();
this.onEndDragging.reset();
}

@@ -106,0 +109,0 @@ /** {@link Createable.create} */

@@ -48,2 +48,3 @@ import * as THREE from "three";

constructor(components: Components, origin: THREE.Vector3, normal: THREE.Vector3, size: number, material: THREE.Material, isPlan: boolean);
/** {@link Updateable.update} */
update(): void;

@@ -50,0 +51,0 @@ /** {@link Component.get} */

@@ -77,8 +77,9 @@ import * as THREE from "three";

}
/** {@link Updateable.update} */
update() {
if (this._enabled) {
this.beforeUpdate.trigger(this._plane);
this._plane.setFromNormalAndCoplanarPoint(this._normal, this._helper.position);
this.afterUpdate.trigger(this._plane);
}
if (!this._enabled)
return;
this.beforeUpdate.trigger(this._plane);
this._plane.setFromNormalAndCoplanarPoint(this._normal, this._helper.position);
this.afterUpdate.trigger(this._plane);
}

@@ -91,4 +92,7 @@ /** {@link Component.get} */

dispose() {
this.onStartDragging = null;
this.onEndDragging = null;
this._enabled = false;
this.beforeUpdate.reset();
this.afterUpdate.reset();
this.onStartDragging.reset();
this.onEndDragging.reset();
this._helper.removeFromParent();

@@ -98,8 +102,5 @@ this._components.renderer.togglePlane(false, this._plane);

this._arrowBoundBox.geometry.dispose();
this._arrowBoundBox = undefined;
this._planeMesh.geometry.dispose();
this._planeMesh.geometry = undefined;
this._controls.removeFromParent();
this._controls.dispose();
this._helper.removeFromParent();
}

@@ -106,0 +107,0 @@ newTransformControls() {

@@ -47,12 +47,6 @@ import * as THREE from "three";

this.visible = false;
this._components = null;
this._disposer.dispose(this._root);
this._root = null;
this._line.material = null;
this._disposer.dispose(this._line);
this._line = null;
for (const mesh of this._endpoints) {
mesh.removeFromParent();
mesh.material = null;
mesh.geometry = null;
}

@@ -62,6 +56,4 @@ this._endpoints.length = 0;

this.label.element.remove();
this.label = null;
if (this.boundingBox) {
this._disposer.dispose(this.boundingBox);
this.boundingBox = null;
}

@@ -68,0 +60,0 @@ }

@@ -108,11 +108,9 @@ import * as THREE from "three";

dispose() {
this.components = null;
this.enabled = false;
this._dimensions.forEach((dim) => dim.dispose());
this._dimensions = null;
this._dimensions = [];
this._disposer.dispose(this._endpointMesh);
this._endpointMesh = null;
this._temp.dimension = null;
this._endpointMesh.removeFromParent();
this.previewElement.removeFromParent();
this.previewElement.element.remove();
this.previewElement = null;
}

@@ -119,0 +117,0 @@ /** {@link Updateable.update} */

import * as THREE from "three";
import { Hideable } from "./base-types";
import { Disposable, Hideable } from "./base-types";
import { Components } from "../components";

@@ -9,3 +9,3 @@ import { Component } from "./base-components";

*/
export declare class SimpleGrid extends Component<THREE.GridHelper> implements Hideable {
export declare class SimpleGrid extends Component<THREE.GridHelper> implements Hideable, Disposable {
/** {@link Component.name} */

@@ -20,5 +20,8 @@ name: string;

private readonly _grid;
private _disposer;
constructor(components: Components);
/** {@link Component.get} */
get(): THREE.GridHelper;
/** {@link Disposable.dispose} */
dispose(): void;
}
import * as THREE from "three";
import { Component } from "./base-components";
import { Disposer } from "./utils";
/**

@@ -14,2 +15,3 @@ * A basic

this.enabled = true;
this._disposer = new Disposer();
this._grid = new THREE.GridHelper(50, 50);

@@ -31,3 +33,7 @@ const scene = components.scene.get();

}
/** {@link Disposable.dispose} */
dispose() {
this._disposer.dispose(this._grid);
}
}
//# sourceMappingURL=simple-grid.js.map

@@ -27,3 +27,3 @@ import * as THREE from "three";

antialias: true,
alpha: true
alpha: true,
});

@@ -53,7 +53,7 @@ this._renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));

dispose() {
this.enabled = false;
this._renderer.domElement.remove();
this._renderer.dispose();
this._renderer = null;
this._renderer2D = null;
this.container = null;
this.afterUpdate.reset();
this.beforeUpdate.reset();
}

@@ -60,0 +60,0 @@ /** {@link Resizeable.getSize}. */

import * as THREE from "three";
import { Components } from "../components";
import { Component } from "./base-components";
import { Disposable } from "./base-types";
/**

@@ -8,3 +9,3 @@ * A basic 3D [scene](https://threejs.org/docs/#api/en/scenes/Scene) to add

*/
export declare class SimpleScene extends Component<THREE.Scene> {
export declare class SimpleScene extends Component<THREE.Scene> implements Disposable {
/** {@link Component.enabled} */

@@ -15,5 +16,8 @@ enabled: boolean;

private readonly _scene;
private readonly _disposer;
constructor(_components: Components);
/** {@link Component.get} */
get(): THREE.Scene;
/** {@link Disposable.dispose} */
dispose(): void;
}
import * as THREE from "three";
import { Component } from "./base-components";
import { Disposer } from "./utils";
/**

@@ -14,2 +15,3 @@ * A basic 3D [scene](https://threejs.org/docs/#api/en/scenes/Scene) to add

this.name = "SimpleScene";
this._disposer = new Disposer();
this._scene = new THREE.Scene();

@@ -22,3 +24,13 @@ this._scene.background = new THREE.Color(0xcccccc);

}
/** {@link Disposable.dispose} */
dispose() {
for (const child of this._scene.children) {
const mesh = child;
if (mesh.geometry) {
this._disposer.dispose(mesh);
}
}
this._scene.children = [];
}
}
//# sourceMappingURL=simple-scene.js.map
import { Component } from "./base-components";
import { Disposable } from "./base-types";
/**

@@ -7,4 +8,4 @@ * An object to easily handle all the tools used (e.g. updating them, retrieving

*/
export declare class ToolComponents {
readonly tools: Component<any>[];
export declare class ToolComponents implements Disposable {
tools: Component<any>[];
/**

@@ -33,15 +34,5 @@ * Registers a new tool component.

/**
* Sets the {@link Component.enabled} property of one or multiple components.
* @param enabled - Whether to enable or disable the components.
* @param name - The {@link Component.name} of the tool to enable or disable.
* If undefined, all components will be enabled or disabled.
* Disposes all the memory used by all the tools.
*/
enable(enabled: boolean, name?: string): void;
/**
* Shows or hides one or multiple components.
* @param visible - Whether to show or hide the tool components.
* @param name - The {@link Component.name} of the tool to show or hide.
* If undefined, all components will be enabled or disabled.
*/
toggle(visible: boolean, name?: string): void;
dispose(): void;
}

@@ -50,40 +50,14 @@ /**

/**
* Sets the {@link Component.enabled} property of one or multiple components.
* @param enabled - Whether to enable or disable the components.
* @param name - The {@link Component.name} of the tool to enable or disable.
* If undefined, all components will be enabled or disabled.
* Disposes all the memory used by all the tools.
*/
enable(enabled, name) {
if (name) {
const tool = this.get(name);
if (tool) {
tool.enabled = enabled;
}
return;
}
dispose() {
for (const tool of this.tools) {
tool.enabled = enabled;
}
}
/**
* Shows or hides one or multiple components.
* @param visible - Whether to show or hide the tool components.
* @param name - The {@link Component.name} of the tool to show or hide.
* If undefined, all components will be enabled or disabled.
*/
toggle(visible, name) {
if (name) {
const tool = this.get(name);
if (tool && tool.isHideable()) {
tool.visible = visible;
tool.enabled = false;
if (tool.isDisposeable()) {
tool.dispose();
}
return;
}
for (const tool of this.tools) {
if (tool.isHideable()) {
tool.visible = visible;
}
}
this.tools = [];
}
}
//# sourceMappingURL=tools-components.js.map
import * as THREE from "three";
export interface Item3D extends THREE.Object3D {
geometry: THREE.BufferGeometry;
material: THREE.Material | THREE.Material[];
}
/**

@@ -19,3 +23,3 @@ * A class to safely remove meshes and geometries from memory to

*/
dispose(mesh: THREE.Mesh, materials?: boolean, recursive?: boolean): void;
dispose(mesh: Item3D, materials?: boolean, recursive?: boolean): void;
/**

@@ -22,0 +26,0 @@ * Disposes a geometry from memory.

@@ -5,4 +5,4 @@ import * as THREE from "three";

import { Components } from "../components";
import { Event } from "../core";
export declare class FragmentCulling {
import { Disposable, Event } from "../core";
export declare class FragmentCulling implements Disposable {
private components;

@@ -17,3 +17,2 @@ private fragment;

readonly bufferSize: number;
readonly buffer: Uint8Array;
readonly materialCache: Map<string, THREE.MeshBasicMaterial>;

@@ -24,12 +23,14 @@ readonly worker: Worker;

needsUpdate: boolean;
exclusions: Map<string, Fragment>;
fragmentColorMap: Map<string, Fragment>;
renderDebugFrame: boolean;
readonly meshes: Map<string, THREE.InstancedMesh<THREE.BufferGeometry, THREE.Material | THREE.Material[]>>;
visibleFragments: Fragment[];
private readonly previouslyVisibleMeshes;
private readonly transparentMat;
private colors;
private readonly scene;
meshes: Map<string, THREE.InstancedMesh<THREE.BufferGeometry, THREE.Material | THREE.Material[]>>;
private readonly _previouslyVisibleMeshes;
private readonly _transparentMat;
private _disposer;
private _buffer;
private _colors;
private readonly _scene;
constructor(components: Components, fragment: Fragments, updateInterval?: number, rtWidth?: number, rtHeight?: number, autoUpdate?: boolean);
dispose(): void;
add(fragment: Fragment): void;

@@ -36,0 +37,0 @@ updateVisibility: (force?: boolean) => void;

import * as THREE from "three";
import { Event } from "../core";
import { Disposer, Event } from "../core";
// TODO: Clean up and document
export class FragmentCulling {

@@ -14,15 +15,15 @@ constructor(components, fragment, updateInterval = 1000, rtWidth = 512, rtHeight = 512, autoUpdate = true) {

this.needsUpdate = false;
this.exclusions = new Map();
this.fragmentColorMap = new Map();
this.renderDebugFrame = false;
this.visibleFragments = [];
this.meshes = new Map();
this.visibleFragments = [];
this.previouslyVisibleMeshes = new Set();
this.transparentMat = new THREE.MeshBasicMaterial({
this._previouslyVisibleMeshes = new Set();
this._transparentMat = new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
});
this.colors = { r: 0, g: 0, b: 0, i: 0 };
this._disposer = new Disposer();
this._colors = { r: 0, g: 0, b: 0, i: 0 };
// Alternative scene and meshes to make the visibility check
this.scene = new THREE.Scene();
this._scene = new THREE.Scene();
this.updateVisibility = (force) => {

@@ -37,10 +38,10 @@ if (!this.enabled)

this.renderer.setRenderTarget(this.renderTarget);
this.renderer.render(this.scene, camera);
this.renderer.readRenderTargetPixels(this.renderTarget, 0, 0, this.rtWidth, this.rtHeight, this.buffer);
this.renderer.render(this._scene, camera);
this.renderer.readRenderTargetPixels(this.renderTarget, 0, 0, this.rtWidth, this.rtHeight, this._buffer);
this.renderer.setRenderTarget(null);
if (this.renderDebugFrame) {
this.renderer.render(this.scene, camera);
this.renderer.render(this._scene, camera);
}
this.worker.postMessage({
buffer: this.buffer,
buffer: this._buffer,
});

@@ -52,4 +53,4 @@ this.needsUpdate = false;

const colors = event.data.colors;
const meshesThatJustDisappeared = new Set(this.previouslyVisibleMeshes);
this.previouslyVisibleMeshes.clear();
const meshesThatJustDisappeared = new Set(this._previouslyVisibleMeshes);
this._previouslyVisibleMeshes.clear();
this.visibleFragments = [];

@@ -62,3 +63,3 @@ // Make found meshes visible

fragment.mesh.visible = true;
this.previouslyVisibleMeshes.add(fragment.id);
this._previouslyVisibleMeshes.add(fragment.id);
meshesThatJustDisappeared.delete(fragment.id);

@@ -70,3 +71,3 @@ this.cullEdges(fragment, true);

for (const id of meshesThatJustDisappeared) {
const fragment = this.fragment.fragments[id];
const fragment = this.fragment.list[id];
fragment.mesh.visible = false;

@@ -81,3 +82,3 @@ this.cullEdges(fragment, false);

this.bufferSize = rtWidth * rtHeight * 4;
this.buffer = new Uint8Array(this.bufferSize);
this._buffer = new Uint8Array(this.bufferSize);
this.materialCache = new Map();

@@ -104,2 +105,28 @@ const code = `

}
dispose() {
this.enabled = false;
this._scene.children.length = 0;
this.viewUpdated.reset();
this.worker.terminate();
this.renderer.dispose();
this.renderTarget.dispose();
this._buffer = null;
this._transparentMat.dispose();
this.viewUpdated.reset();
this.fragmentColorMap.clear();
this.visibleFragments = [];
for (const id in this.materialCache) {
const material = this.materialCache.get(id);
if (material) {
material.dispose();
}
}
for (const id in this.meshes) {
const mesh = this.meshes.get(id);
if (mesh) {
this._disposer.dispose(mesh);
}
}
this.meshes.clear();
}
add(fragment) {

@@ -115,3 +142,3 @@ const { geometry, material } = fragment.mesh;

if (this.isTransparent(mat)) {
matArray.push(this.transparentMat);
matArray.push(this._transparentMat);
}

@@ -144,3 +171,3 @@ else {

mesh.updateMatrix();
this.scene.add(mesh);
this._scene.add(mesh);
this.meshes.set(fragment.id, mesh);

@@ -165,30 +192,30 @@ }

getNextColor() {
if (this.colors.i === 0) {
this.colors.b++;
if (this.colors.b === 256) {
this.colors.b = 0;
this.colors.i = 1;
if (this._colors.i === 0) {
this._colors.b++;
if (this._colors.b === 256) {
this._colors.b = 0;
this._colors.i = 1;
}
}
if (this.colors.i === 1) {
this.colors.g++;
this.colors.i = 0;
if (this.colors.g === 256) {
this.colors.g = 0;
this.colors.i = 2;
if (this._colors.i === 1) {
this._colors.g++;
this._colors.i = 0;
if (this._colors.g === 256) {
this._colors.g = 0;
this._colors.i = 2;
}
}
if (this.colors.i === 2) {
this.colors.r++;
this.colors.i = 1;
if (this.colors.r === 256) {
this.colors.r = 0;
this.colors.i = 0;
if (this._colors.i === 2) {
this._colors.r++;
this._colors.i = 1;
if (this._colors.r === 256) {
this._colors.r = 0;
this._colors.i = 0;
}
}
return {
r: this.colors.r,
g: this.colors.g,
b: this.colors.b,
code: `${this.colors.r}${this.colors.g}${this.colors.b}`,
r: this._colors.r,
g: this._colors.g,
b: this._colors.b,
code: `${this._colors.r}${this._colors.g}${this._colors.b}`,
};

@@ -195,0 +222,0 @@ }

import { InstancedBufferGeometry, LineBasicMaterial, LineSegments } from "three";
import { Fragment } from "bim-fragment";
import { Components } from "../components";
export declare class FragmentEdges {
private components;
import { Disposable } from "../core";
export declare class FragmentEdges implements Disposable {
edgesList: {

@@ -11,9 +11,12 @@ [guid: string]: LineSegments;

threshold: number;
private mat4;
private dummy;
private pos;
private rot;
private scl;
private _mat4;
private _dummy;
private _pos;
private _rot;
private _scl;
private lineMat;
private _components;
private disposer;
constructor(components: Components);
dispose(): void;
generate(fragment: Fragment): LineSegments<InstancedBufferGeometry, LineBasicMaterial>;

@@ -20,0 +23,0 @@ private updateInstancedEdges;

import { EdgesGeometry, InstancedBufferAttribute, InstancedBufferGeometry, LineBasicMaterial, LineSegments, Matrix4, Object3D, } from "three";
import { Disposer } from "../core";
// TODO: Clean up and document
export class FragmentEdges {
constructor(components) {
this.components = components;
this.edgesList = {};
this.edgesToUpdate = new Set();
this.threshold = 80;
this.mat4 = new Matrix4();
this.dummy = new Object3D();
this.pos = [];
this.rot = [];
this.scl = [];
this._mat4 = new Matrix4();
this._dummy = new Object3D();
this._pos = [];
this._rot = [];
this._scl = [];
this.lineMat = new LineBasicMaterial({

@@ -35,3 +36,14 @@ color: 0x555555,

});
this.disposer = new Disposer();
this._components = components;
}
dispose() {
for (const guid in this.edgesList) {
const edges = this.edgesList[guid];
this.disposer.dispose(edges, true);
}
this.lineMat.dispose();
this.edgesList = {};
this.edgesToUpdate.clear();
}
generate(fragment) {

@@ -52,3 +64,3 @@ if (this.edgesList[fragment.id]) {

lines.frustumCulled = false;
const scene = this.components.scene.get();
const scene = this._components.scene.get();
scene.add(lines);

@@ -62,22 +74,22 @@ this.edgesList[fragment.id] = lines;

for (let i = 0; i < fragment.mesh.count; i++) {
fragment.mesh.getMatrixAt(i, this.mat4);
this.mat4.decompose(this.dummy.position, this.dummy.quaternion, this.dummy.scale);
this.linesTRS(i, this.dummy, lineGeom);
fragment.mesh.getMatrixAt(i, this._mat4);
this._mat4.decompose(this._dummy.position, this._dummy.quaternion, this._dummy.scale);
this.linesTRS(i, this._dummy, lineGeom);
}
}
setAttributes(lineGeom) {
lineGeom.setAttribute("instT", new InstancedBufferAttribute(new Float32Array(this.pos), 3));
lineGeom.setAttribute("instR", new InstancedBufferAttribute(new Float32Array(this.rot), 4));
lineGeom.setAttribute("instS", new InstancedBufferAttribute(new Float32Array(this.scl), 3));
this.pos.length = 0;
this.rot.length = 0;
this.scl.length = 0;
lineGeom.setAttribute("instT", new InstancedBufferAttribute(new Float32Array(this._pos), 3));
lineGeom.setAttribute("instR", new InstancedBufferAttribute(new Float32Array(this._rot), 4));
lineGeom.setAttribute("instS", new InstancedBufferAttribute(new Float32Array(this._scl), 3));
this._pos.length = 0;
this._rot.length = 0;
this._scl.length = 0;
}
getInstanceTransforms(fragment) {
for (let i = 0; i < fragment.mesh.count; i++) {
fragment.getInstance(i, this.dummy.matrix);
this.dummy.updateMatrix();
this.pos.push(this.dummy.position.x, this.dummy.position.y, this.dummy.position.z);
this.rot.push(this.dummy.quaternion.x, this.dummy.quaternion.y, this.dummy.quaternion.z, this.dummy.quaternion.w);
this.scl.push(this.dummy.scale.x, this.dummy.scale.y, this.dummy.scale.z);
fragment.getInstance(i, this._dummy.matrix);
this._dummy.updateMatrix();
this._pos.push(this._dummy.position.x, this._dummy.position.y, this._dummy.position.z);
this._rot.push(this._dummy.quaternion.x, this._dummy.quaternion.y, this._dummy.quaternion.z, this._dummy.quaternion.w);
this._scl.push(this._dummy.scale.x, this._dummy.scale.y, this._dummy.scale.z);
}

@@ -84,0 +96,0 @@ }

import { Fragments } from "./fragment";
export declare class FragmentExploder {
import { Disposable } from "../core";
export declare class FragmentExploder implements Disposable {
fragments: Fragments;

@@ -10,2 +11,3 @@ height: number;

constructor(fragments: Fragments);
dispose(): void;
explode(): void;

@@ -12,0 +14,0 @@ reset(): void;

import * as THREE from "three";
// TODO: Clean up and document
export class FragmentExploder {
// private transformedFragments = new Set<string>();
constructor(fragments) {

@@ -12,2 +12,5 @@ this.fragments = fragments;

}
dispose() {
this.explodedFragments.clear();
}
explode() {

@@ -32,3 +35,3 @@ this.initialized = true;

for (const fragID in groups[groupName]) {
const fragment = this.fragments.fragments[fragID];
const fragment = this.fragments.list[fragID];
const customID = groupName + fragID;

@@ -35,0 +38,0 @@ if (!fragment) {

@@ -1,2 +0,3 @@

import { Fragments } from './fragment';
import { Fragments } from "./fragment";
import { Disposable } from "../core";
export interface ItemGroupSystems {

@@ -14,6 +15,7 @@ [systemName: string]: {

}
export declare class FragmentGrouper {
export declare class FragmentGrouper implements Disposable {
groupSystems: GroupSystems;
fragments: Fragments;
private _fragments;
constructor(fragments: Fragments);
dispose(): void;
add(guid: string, groupsSystems: ItemGroupSystems): void;

@@ -27,3 +29,2 @@ setVisibility(systemName: string, groupName: string, visible: boolean): void;

};
update(_delta: number): void;
}

@@ -7,4 +7,7 @@ export class FragmentGrouper {

};
this.fragments = fragments;
this._fragments = fragments;
}
dispose() {
this.groupSystems = {};
}
add(guid, groupsSystems) {

@@ -28,3 +31,3 @@ for (const system in groupsSystems) {

for (const fragmentId in fragmentsMap) {
const fragment = this.fragments.fragments[fragmentId];
const fragment = this._fragments.list[fragmentId];
const ids = fragmentsMap[fragmentId];

@@ -59,4 +62,3 @@ fragment.setVisibility(ids, visible);

}
update(_delta) { }
}
//# sourceMappingURL=fragment-grouper.js.map

@@ -5,3 +5,4 @@ import * as THREE from "three";

import { Fragments } from ".";
export declare class FragmentHighlighter {
import { Disposable } from "../core";
export declare class FragmentHighlighter implements Disposable {
private components;

@@ -16,2 +17,3 @@ private fragments;

constructor(components: Components, fragments: Fragments);
dispose(): void;
add(name: string, material?: THREE.Material[]): void;

@@ -18,0 +20,0 @@ update(): void;

import * as THREE from "three";
// TODO: Clean up and document
export class FragmentHighlighter {

@@ -11,2 +12,11 @@ constructor(components, fragments) {

}
dispose() {
for (const matID in this.highlightMats) {
const mats = this.highlightMats[matID] || [];
for (const mat of mats) {
mat.dispose();
}
}
this.highlightMats = {};
}
add(name, material) {

@@ -21,4 +31,4 @@ if (this.highlightMats[name]) {

update() {
for (const fragmentID in this.fragments.fragments) {
const fragment = this.fragments.fragments[fragmentID];
for (const fragmentID in this.fragments.list) {
const fragment = this.fragments.list[fragmentID];
this.addHighlightToFragment(fragment);

@@ -32,3 +42,3 @@ }

this.checkSelection(name);
const meshes = this.fragments.fragmentMeshes;
const meshes = this.fragments.meshes;
const result = this.components.raycaster.castRay(meshes);

@@ -52,3 +62,3 @@ if (!result) {

}
const fragment = this.fragments.fragments[mesh.uuid];
const fragment = this.fragments.list[mesh.uuid];
const blockID = fragment.getVertexBlockID(geometry, index);

@@ -86,3 +96,3 @@ const itemID = fragment.getItemID(instanceID, blockID);

for (const fragID in this.selection[name]) {
const fragment = this.fragments.fragments[fragID];
const fragment = this.fragments.list[fragID];
if (!fragment)

@@ -99,3 +109,3 @@ continue;

const ids = this.selection[name][fragmentID];
const fragment = this.fragments.fragments[fragmentID];
const fragment = this.fragments.list[fragmentID];
if (!fragment)

@@ -102,0 +112,0 @@ return;

@@ -17,3 +17,3 @@ import * as WEBIFC from "web-ifc";

private readonly _materials;
private readonly _spatialStructure;
private readonly _spatialTree;
private readonly _settings;

@@ -20,0 +20,0 @@ constructor(items: IfcToFragmentItems, materials: MaterialList, settings: Settings);

@@ -21,3 +21,3 @@ import * as THREE from "three";

this._propertyExporter = new IfcJsonExporter();
this._spatialStructure = new SpatialStructure();
this._spatialTree = new SpatialStructure();
this._items = items;

@@ -34,3 +34,3 @@ this._materials = materials;

cleanUp() {
this._spatialStructure.cleanUp();
this._spatialTree.cleanUp();
this._categories = {};

@@ -48,3 +48,3 @@ this._model = new FragmentGroup();

await this._units.setUp(webIfc);
await this._spatialStructure.setupFloors(webIfc, this._units);
await this._spatialTree.setupFloors(webIfc, this._units);
this.processAllFragmentsData();

@@ -59,4 +59,4 @@ this.processAllUniqueItems();

this._model.expressIDFragmentIDMap = this._expressIDfragmentIDMap;
this._model.levelRelationships = this._spatialStructure.itemsByFloor;
this._model.floorsProperties = this._spatialStructure.floorProperties;
this._model.levelRelationships = this._spatialTree.itemsByFloor;
this._model.floorsProperties = this._spatialTree.floorProperties;
this._model.allTypes = IfcCategoryMap;

@@ -95,3 +95,3 @@ this._model.itemTypes = this._categories;

const isInstanced = this._settings.instancedCategories.has(categoryID);
const noFloors = Object.keys(this._spatialStructure.itemsByFloor).length === 0;
const noFloors = Object.keys(this._spatialTree.itemsByFloor).length === 0;
if (!isUnique || isInstanced || noFloors) {

@@ -108,3 +108,3 @@ this.processInstancedItems(data);

const category = this._categories[instance.id];
const level = this._spatialStructure.itemsByFloor[instance.id];
const level = this._spatialTree.itemsByFloor[instance.id];
this.initializeItem(data, category, level, matID);

@@ -111,0 +111,0 @@ this.applyTransformToMergedGeometries(data, category, level, matID);

import * as WEBIFC from "web-ifc";
import { IfcToFragmentItems, MaterialList } from "./base-types";
export declare class Geometry {
private webIfc;
private referenceMatrix;
private isFirstMatrix;
private _materials;
private _referenceMatrix;
private _isFirstMatrix;
private _voids;
private _geometriesByMaterial;
private _webIfc;
private readonly _items;
private readonly _materials;
constructor(webIfc: WEBIFC.IfcAPI, items: IfcToFragmentItems, materials: MaterialList);

@@ -12,0 +12,0 @@ streamMesh(webifc: WEBIFC.IfcAPI, mesh: WEBIFC.FlatMesh): void;

import * as THREE from "three";
export class Geometry {
constructor(webIfc, items, materials) {
this.referenceMatrix = new THREE.Matrix4();
this.isFirstMatrix = true;
this._referenceMatrix = new THREE.Matrix4();
this._isFirstMatrix = true;
this._voids = new Set();
this._geometriesByMaterial = {};
this._items = {};
this.webIfc = webIfc;
this._webIfc = webIfc;
this._items = items;

@@ -33,5 +33,6 @@ this._materials = materials;

this._geometriesByMaterial = {};
this.referenceMatrix = new THREE.Matrix4();
this.isFirstMatrix = true;
this.webIfc = webifc;
this._referenceMatrix = new THREE.Matrix4();
this._isFirstMatrix = true;
this._webIfc = null;
this._webIfc = webifc;
}

@@ -71,3 +72,3 @@ getGeometryTransformation(mesh, geometryID) {

geometriesByMaterial: this._geometriesByMaterial,
referenceMatrix: this.referenceMatrix,
referenceMatrix: this._referenceMatrix,
};

@@ -98,3 +99,3 @@ }

opacity: color.w,
side: THREE.DoubleSide
side: THREE.DoubleSide,
});

@@ -109,9 +110,9 @@ }

// later to the rest of the instances
if (this.isFirstMatrix) {
this.referenceMatrix = new THREE.Matrix4().copy(matrix).invert();
this.isFirstMatrix = false;
if (this._isFirstMatrix) {
this._referenceMatrix = new THREE.Matrix4().copy(matrix).invert();
this._isFirstMatrix = false;
}
}
getBufferGeometry(expressID) {
const geometry = this.webIfc.GetGeometry(0, expressID);
const geometry = this._webIfc.GetGeometry(0, expressID);
const verts = this.getVertices(geometry);

@@ -129,7 +130,7 @@ if (!verts.length)

getIndices(geometryData) {
const indices = this.webIfc.GetIndexArray(geometryData.GetIndexData(), geometryData.GetIndexDataSize());
const indices = this._webIfc.GetIndexArray(geometryData.GetIndexData(), geometryData.GetIndexDataSize());
return indices;
}
getVertices(geometryData) {
const verts = this.webIfc.GetVertexArray(geometryData.GetVertexData(), geometryData.GetVertexDataSize());
const verts = this._webIfc.GetVertexArray(geometryData.GetVertexData(), geometryData.GetVertexDataSize());
return verts;

@@ -136,0 +137,0 @@ }

import { Settings } from "./settings";
import { Disposable } from "../../core";
import { Fragments } from "../fragment";
/**
* Reads all the geometry of the IFC file and generates an optimized `THREE.Mesh`.
* Reads all the geometry of the IFC file and generates a set of
* [fragments](https://github.com/ifcjs/fragment).
*/
export declare class IfcFragmentLoader {
export declare class IfcFragmentLoader implements Disposable {
/** Configuration of the IFC-fragment conversion. */
settings: Settings;
private _fragments;
private _webIfc;
private _progress;
private _items;

@@ -13,3 +17,6 @@ private _materials;

private readonly _converter;
get progress(): import("../..").Event<import("../..").Progress>;
constructor(fragments: Fragments);
/** {@link Disposable.dispose} */
dispose(): void;
/** Loads the IFC file and converts it to a set of fragments. */
load(ifcURL: URL): Promise<import("./base-types").FragmentGroup>;

@@ -25,2 +32,5 @@ private initializeWebIfc;

private resetObject;
private disposeWebIfc;
private disposeMaterials;
private disposeItems;
}
import * as WEBIFC from "web-ifc";
import { Settings } from "./settings";
import { LoadProgress } from "./load-progress";
import { Geometry } from "./geometry";
import { DataConverter } from "./data-converter";
/**
* Reads all the geometry of the IFC file and generates an optimized `THREE.Mesh`.
* Reads all the geometry of the IFC file and generates a set of
* [fragments](https://github.com/ifcjs/fragment).
*/
export class IfcFragmentLoader {
constructor() {
constructor(fragments) {
/** Configuration of the IFC-fragment conversion. */
this.settings = new Settings();
this._webIfc = new WEBIFC.IfcAPI();
this._progress = new LoadProgress();
this._items = {};

@@ -18,6 +18,15 @@ this._materials = {};

this._converter = new DataConverter(this._items, this._materials, this.settings);
this._fragments = fragments;
}
get progress() {
return this._progress.event;
/** {@link Disposable.dispose} */
dispose() {
this.disposeWebIfc();
this.disposeMaterials();
this.disposeItems();
this._geometry.cleanUp();
this._geometry = null;
this._converter.cleanUp();
this._converter = null;
}
/** Loads the IFC file and converts it to a set of fragments. */
async load(ifcURL) {

@@ -37,7 +46,8 @@ await this.initializeWebIfc();

async loadAllGeometry() {
await this._progress.setupLoadProgress(this._webIfc);
await this.loadAllCategories();
const model = await this._converter.generateFragmentData(this._webIfc);
this._progress.updateLoadProgress();
this.cleanUp();
for (const fragment of model.fragments) {
this._fragments.list[fragment.id] = fragment;
}
return model;

@@ -53,3 +63,2 @@ }

this._webIfc.StreamAllMeshes(0, (mesh) => {
this._progress.updateLoadProgress();
this._geometry.streamMesh(this._webIfc, mesh);

@@ -68,4 +77,4 @@ });

}
// Some categories (like IfcSpace) need to be set explicitly
loadOptionalCategories() {
// Some categories (like IfcSpace) need to be set explicitly
const optionals = this.settings.optionalCategories;

@@ -85,3 +94,3 @@ const callback = (mesh) => {

resetWebIfc() {
this._webIfc = null;
this.disposeWebIfc();
this._webIfc = new WEBIFC.IfcAPI();

@@ -95,3 +104,21 @@ }

}
disposeWebIfc() {
this._webIfc = null;
}
disposeMaterials() {
for (const materialID in this._materials) {
this._materials[materialID].dispose();
}
}
disposeItems() {
for (const geometryID in this._items) {
const geometriesByMat = this._items[geometryID].geometriesByMaterial;
for (const matID in geometriesByMat) {
for (const geom of geometriesByMat[matID]) {
geom.dispose();
}
}
}
}
}
//# sourceMappingURL=ifc-fragment-loader.js.map
export * from "./ifc-fragment-loader";
export * from "./data-converter";
export * from "./geometry";
export * from "./load-progress";
export * from "./settings";
export * from "./spatial-structure";
export * from "./base-types";
export * from "./ifc-fragment-loader";
export * from "./data-converter";
export * from "./geometry";
export * from "./load-progress";
export * from "./settings";

@@ -6,0 +5,0 @@ export * from "./spatial-structure";

import * as WEBIFC from "web-ifc";
/** Configuration of the IFC-fragment conversion. */
export declare class Settings {
/** Categories that always will be instanced. */
instancedCategories: Set<number>;
/** Whether to extract the IFC properties into a JSON. */
includeProperties: boolean;
/** Generate the geometry for categories that are not included by default. */
optionalCategories: number[];
/** Path of the WASM for [web-ifc](https://github.com/ifcjs/web-ifc). */
wasm: {

@@ -10,5 +15,5 @@ path: string;

};
instanceLimit: number;
/** Loader settings for [web-ifc](https://github.com/ifcjs/web-ifc). */
webIfc: WEBIFC.LoaderSettings;
constructor();
}
import * as WEBIFC from "web-ifc";
/** Configuration of the IFC-fragment conversion. */
export class Settings {
constructor() {
// Categories that always will be instanced
/** Categories that always will be instanced. */
this.instancedCategories = new Set();
/** Whether to extract the IFC properties into a JSON. */
this.includeProperties = true;
/** Generate the geometry for categories that are not included by default. */
this.optionalCategories = [WEBIFC.IFCSPACE];
/** Path of the WASM for [web-ifc](https://github.com/ifcjs/web-ifc). */
this.wasm = {

@@ -12,3 +16,3 @@ path: "",

};
this.instanceLimit = 5;
/** Loader settings for [web-ifc](https://github.com/ifcjs/web-ifc). */
this.webIfc = {

@@ -15,0 +19,0 @@ COORDINATE_TO_ORIGIN: true,

@@ -1,12 +0,15 @@

import { Material } from "three";
import * as THREE from "three";
import { Fragments } from ".";
export declare class FragmentMaterials {
import { Disposable } from "../core";
export declare class FragmentMaterials implements Disposable {
private fragments;
originals: {
[guid: string]: Material[];
[guid: string]: THREE.Material[];
};
materials: Set<THREE.Material>;
constructor(fragments: Fragments);
apply(material: Material, fragmentIDs?: string[]): void;
dispose(): void;
apply(material: THREE.Material, fragmentIDs?: string[]): void;
reset(fragmentIDs?: string[]): void;
private save;
}

@@ -0,1 +1,2 @@

// TODO: Clean up and document
export class FragmentMaterials {

@@ -5,6 +6,14 @@ constructor(fragments) {

this.originals = {};
this.materials = new Set();
}
apply(material, fragmentIDs = Object.keys(this.fragments.fragments)) {
dispose() {
for (const mat of this.materials) {
mat.dispose();
}
this.materials.clear();
}
apply(material, fragmentIDs = Object.keys(this.fragments.list)) {
this.materials.add(material);
for (const guid of fragmentIDs) {
const fragment = this.fragments.fragments[guid];
const fragment = this.fragments.list[guid];
this.save(fragment);

@@ -14,5 +23,5 @@ fragment.mesh.material = material;

}
reset(fragmentIDs = Object.keys(this.fragments.fragments)) {
reset(fragmentIDs = Object.keys(this.fragments.list)) {
for (const guid of fragmentIDs) {
const fragment = this.fragments.fragments[guid];
const fragment = this.fragments.list[guid];
const originalMats = this.originals[guid];

@@ -19,0 +28,0 @@ if (originalMats) {

@@ -1,2 +0,3 @@

export declare class FragmentProperties {
import { Disposable } from "../core";
export declare class FragmentProperties implements Disposable {
properties: {

@@ -6,2 +7,3 @@ [guid: string]: any;

fragmentGuid: Map<string, string>;
dispose(): void;
add(properties: any): any;

@@ -8,0 +10,0 @@ assign(guid: string, fragmentID: string): void;

@@ -0,1 +1,2 @@

// TODO: Clean up and document
export class FragmentProperties {

@@ -6,2 +7,6 @@ constructor() {

}
dispose() {
this.properties = {};
this.fragmentGuid.clear();
}
add(properties) {

@@ -8,0 +13,0 @@ const project = Object.values(properties).find((item) => item.type === "IFCPROJECT");

@@ -13,3 +13,3 @@ import { FragmentProperties } from "./fragment-properties";

generate(guid: string): Node;
constructSpatialNode(guid: string, item: Node, contains: any[], spatials: any[]): void;
private constructSpatialNode;
}

@@ -1,2 +0,1 @@

import { FragmentLoader } from "bim-fragment/fragment-loader";
import { Fragment } from "bim-fragment";

@@ -12,29 +11,62 @@ import * as THREE from "three";

import { Components } from "../components";
import { Component } from "../core";
import { Component, Disposable } from "../core";
import { IfcFragmentLoader } from "./fragment-ifc-importer";
import { MemoryCulling } from "./memory-culling";
import { FragmentExploder } from "./fragment-exploder";
export declare class Fragments extends Component<Fragment[]> {
/**
* Main object that manages all the components related to the
* [fragment geometric system](https://github.com/ifcjs/fragment).
*/
export declare class Fragments extends Component<Fragment[]> implements Disposable {
private components;
/** {@link Component.name} */
name: string;
/** {@link Component.enabled} */
enabled: boolean;
/** {@link Component.get} */
get(): Fragment[];
fragments: {
/** The list of meshes of the created fragments. */
get meshes(): THREE.Mesh<THREE.BufferGeometry, THREE.Material | THREE.Material[]>[];
/** All the created [fragments](https://github.com/ifcjs/fragment). */
list: {
[guid: string]: Fragment;
};
fragmentMeshes: THREE.Mesh[];
/** Helper object to convert IFC files to fragment. */
ifcLoader: IfcFragmentLoader;
loader: FragmentLoader;
/** Helper object to index and store fragments. */
groups: FragmentGrouper;
/** Helper object to index and store fragments. */
properties: FragmentProperties;
/** Helper object to easily work with fragment properties. */
tree: FragmentSpatialTree;
/** Helper object to easily apply a highlight color to fragments. */
highlighter: FragmentHighlighter;
/** Helper object to vertically explode fragments per floorplan. */
exploder: FragmentExploder;
/** Helper object to apply
* [edges](https://threejs.org/docs/#api/en/geometries/EdgesGeometry). */
edges: FragmentEdges;
/** Helper object to easily override/restore materials globally. */
materials: FragmentMaterials;
/**
* Fragment manager to add/removefragments from the scene depending
* on whether they are visible.
*/
culler: FragmentCulling;
/**
* Fragment manager to add/remove fragments from memory depending
* on whether they are visible.
*/
memoryCuller: MemoryCulling;
private _loader;
constructor(components: Components);
load(geometryURL: string, dataURL: string, matrix?: THREE.Matrix4): Promise<Fragment>;
add(fragment: Fragment): void;
/** {@link Component.get} */
dispose(): void;
/**
* Adds a new fragment into the scene.
*
* @param geometryURL - the URL of the geometry of the fragment.
* @param dataURL - the URL of the json data of the fragment.
*/
load(geometryURL: string, dataURL: string): Promise<Fragment>;
}
import { FragmentLoader } from "bim-fragment/fragment-loader";
import * as THREE from "three";
import { FragmentHighlighter } from "./fragment-highlighter";

@@ -14,3 +13,6 @@ import { FragmentCulling } from "./fragment-culling";

import { FragmentExploder } from "./fragment-exploder";
// TODO: Clean up and document all this folder
/**
* Main object that manages all the components related to the
* [fragment geometric system](https://github.com/ifcjs/fragment).
*/
export class Fragments extends Component {

@@ -20,11 +22,17 @@ constructor(components) {

this.components = components;
/** {@link Component.name} */
this.name = "Fragments";
/** {@link Component.enabled} */
this.enabled = true;
this.fragments = {};
this.fragmentMeshes = [];
this.ifcLoader = new IfcFragmentLoader();
this.loader = new FragmentLoader();
/** All the created [fragments](https://github.com/ifcjs/fragment). */
this.list = {};
/** Helper object to convert IFC files to fragment. */
this.ifcLoader = new IfcFragmentLoader(this);
/** Helper object to index and store fragments. */
this.groups = new FragmentGrouper(this);
/** Helper object to index and store fragments. */
this.properties = new FragmentProperties();
/** Helper object to easily work with fragment properties. */
this.tree = new FragmentSpatialTree(this.properties);
this._loader = new FragmentLoader();
this.highlighter = new FragmentHighlighter(components, this);

@@ -37,23 +45,46 @@ this.exploder = new FragmentExploder(this);

}
/** {@link Component.get} */
get() {
return Object.values(this.fragments);
return Object.values(this.list);
}
async load(geometryURL, dataURL, matrix = new THREE.Matrix4()) {
const fragment = await this.loader.load(geometryURL, dataURL);
if (matrix) {
fragment.mesh.applyMatrix4(matrix);
/** The list of meshes of the created fragments. */
get meshes() {
const allMeshes = [];
for (const fragID in this.list) {
allMeshes.push(this.list[fragID].mesh);
}
this.add(fragment);
return fragment;
return allMeshes;
}
add(fragment) {
var _a;
this.fragments[fragment.id] = fragment;
this.components.meshes.push(fragment.mesh);
this.fragmentMeshes.push(fragment.mesh);
(_a = this.culler) === null || _a === void 0 ? void 0 : _a.add(fragment);
/** {@link Component.get} */
dispose() {
for (const fragID in this.list) {
const fragment = this.list[fragID];
fragment.dispose(true);
}
this.list = {};
this.ifcLoader.dispose();
this.groups.dispose();
this.properties.dispose();
this.highlighter.dispose();
this.edges.dispose();
this.exploder.dispose();
this.materials.dispose();
this.culler.dispose();
this.memoryCuller.dispose();
}
/**
* Adds a new fragment into the scene.
*
* @param geometryURL - the URL of the geometry of the fragment.
* @param dataURL - the URL of the json data of the fragment.
*/
async load(geometryURL, dataURL) {
const fragment = await this._loader.load(geometryURL, dataURL);
this.list[fragment.id] = fragment;
this.culler.add(fragment);
const scene = this.components.scene.get();
scene.add(fragment.mesh);
return fragment;
}
}
//# sourceMappingURL=fragment.js.map
import * as THREE from "three";
import { Fragment } from "bim-fragment";
import { Components } from "../components";
import { Event } from "../core";
import { Disposable, Event } from "../core";
export interface FragmentsByModel {
[model: string]: string[];
}
export declare class MemoryCulling {
export declare class MemoryCulling implements Disposable {
private components;

@@ -18,4 +18,2 @@ readonly updateInterval: number;

readonly bufferSize: number;
readonly buffer: Uint8Array;
readonly materialCache: Map<string, THREE.MeshBasicMaterial>;
readonly worker: Worker;

@@ -44,2 +42,4 @@ readonly fragmentsDiscovered: Event<FragmentsByModel>;

visibleExpressId: string[];
private _buffer;
private _disposer;
private readonly scaleFactor;

@@ -49,2 +49,3 @@ private readonly invisibleBoxes;

constructor(components: Components, updateInterval?: number, rtWidth?: number, rtHeight?: number, autoUpdate?: boolean);
dispose(): void;
updateVisibility: (force?: boolean) => void;

@@ -51,0 +52,0 @@ getNextColor(): {

import * as THREE from "three";
import { Event } from "../core";
import { Disposer, Event } from "../core";
// TODO: Clean up and document
export class MemoryCulling {

@@ -12,5 +13,3 @@ constructor(components, updateInterval = 1000, rtWidth = 512, rtHeight = 512, autoUpdate = true) {

this.scene = new THREE.Scene();
this.materialCache = new Map();
this.fragmentsDiscovered = new Event();
// TODO: Document and clean up data structures
this.enabled = true;

@@ -30,2 +29,3 @@ this.opaqueMeshes = [];

this.visibleExpressId = [];
this._disposer = new Disposer();
this.scaleFactor = 0.00001;

@@ -46,5 +46,5 @@ this.invisibleBoxes = new Set();

this.renderer.render(this.scene, camera);
this.renderer.readRenderTargetPixels(this.renderTarget, 0, 0, this.rtWidth, this.rtHeight, this.buffer);
this.renderer.readRenderTargetPixels(this.renderTarget, 0, 0, this.rtWidth, this.rtHeight, this._buffer);
this.worker.postMessage({
buffer: this.buffer,
buffer: this._buffer,
});

@@ -55,5 +55,5 @@ for (const mesh of this.transparentMeshes) {

this.renderer.render(this.scene, camera);
this.renderer.readRenderTargetPixels(this.renderTarget, 0, 0, this.rtWidth, this.rtHeight, this.buffer);
this.renderer.readRenderTargetPixels(this.renderTarget, 0, 0, this.rtWidth, this.rtHeight, this._buffer);
this.worker.postMessage({
buffer: this.buffer,
buffer: this._buffer,
});

@@ -84,3 +84,3 @@ this.renderer.setRenderTarget(null);

this.bufferSize = rtWidth * rtHeight * 4;
this.buffer = new Uint8Array(this.bufferSize);
this._buffer = new Uint8Array(this.bufferSize);
const code = `

@@ -106,2 +106,32 @@ addEventListener("message", (event) => {

}
dispose() {
this.enabled = false;
this.worker.terminate();
this.fragmentsDiscovered.reset();
this.renderTarget.dispose();
this.renderer.dispose();
this.scene.children.length = 0;
for (const mesh of this.transparentMeshes) {
this._disposer.dispose(mesh);
}
for (const mesh of this.opaqueMeshes) {
this._disposer.dispose(mesh);
}
for (const fragID in this.fragmentMeshMap) {
for (const itemID in this.fragmentMeshMap[fragID]) {
const mesh = this.fragmentMeshMap[fragID][itemID].mesh;
this._disposer.dispose(mesh);
}
}
this.fragmentMeshMap = {};
this.transparentMeshes = [];
this.opaqueMeshes = [];
this._buffer = null;
this.exclusions.clear();
this.discoveredFragments.clear();
this.undiscoveredFragments.clear();
this.previouslyDiscoveredFragments.clear();
this.fragmentColorMap.clear();
this.invisibleBoxes.clear();
}
getNextColor() {

@@ -108,0 +138,0 @@ if (this.colors.i === 0) {

@@ -14,2 +14,6 @@ import * as THREE from "three";

enabled: boolean;
/** {@link Updateable.beforeUpdate} */
beforeUpdate: Event<MapboxRenderer>;
/** {@link Updateable.afterUpdate} */
afterUpdate: Event<MapboxRenderer>;
/**

@@ -25,3 +29,3 @@ * The renderer can only be initialized once Mapbox' map has been loaded. This

private _components;
private readonly initError;
private readonly _initError;
private _modelTransform;

@@ -28,0 +32,0 @@ constructor(components: Components, map: any, coords: any, rotation?: THREE.Vector3);

@@ -16,2 +16,6 @@ import * as THREE from "three";

this.enabled = true;
/** {@link Updateable.beforeUpdate} */
this.beforeUpdate = new Event();
/** {@link Updateable.afterUpdate} */
this.afterUpdate = new Event();
/**

@@ -25,3 +29,3 @@ * The renderer can only be initialized once Mapbox' map has been loaded. This

this._renderer = new THREE.WebGLRenderer();
this.initError = "Mapbox scene isn't initialized yet!";
this._initError = "Mapbox scene isn't initialized yet!";
this.updateLabelRendererSize = () => {

@@ -46,3 +50,3 @@ var _a;

if (!this._renderer) {
throw new Error(this.initError);
throw new Error(this._initError);
}

@@ -55,3 +59,7 @@ return new THREE.Vector2(this._renderer.domElement.clientWidth, this._renderer.domElement.clientHeight);

dispose() {
this.enabled = false;
window.removeEventListener("resize", this.updateLabelRendererSize);
this._renderer.dispose();
this._map.remove();
this._map = null;
}

@@ -101,4 +109,5 @@ initialize(context) {

render(scene, matrix) {
if (!this._renderer)
if (!this._renderer || !this.enabled)
return;
this.beforeUpdate.trigger(this);
const rotationX = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(1, 0, 0), this._modelTransform.rotateX);

@@ -120,2 +129,3 @@ const rotationY = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(0, 1, 0), this._modelTransform.rotateY);

this._map.triggerRepaint();
this.afterUpdate.trigger(this);
}

@@ -122,0 +132,0 @@ initializeLabelRenderer() {

{
"name": "openbim-components",
"main": "dist/index.js",
"version": "0.0.37",
"version": "0.0.38",
"packageManager": "yarn@3.2.1",

@@ -6,0 +6,0 @@ "scripts": {

import * as THREE from "three";
import { EdgesPlane } from "../visibility";
export interface PlanViewConfig {
import { SimplePlane } from "../core";
/**
* Necessary data to create a new floor plan in the navigator.
*/
export interface PlanView {
/** The identifier for this floor plan. */
id: string;
/** Whether the camera of the navigator should be orthogonal */
ortho: boolean;
/** The rotation of the clipping plane */
normal: THREE.Vector3;
/** The position of the clipping plane */
point: THREE.Vector3;
rotation?: number;
data: any;
/** The clipping plane object that cuts the model. */
plane?: SimplePlane;
}
export interface PlanView extends PlanViewConfig {
plane?: EdgesPlane;
}
import { EdgesClipper } from "../visibility";
import { OrthoPerspectiveCamera } from "../cameras";
import { PlanView, PlanViewConfig } from "./base-types";
import { Component } from "../core";
import { PlanView } from "./base-types";
import { Component, Disposable } from "../core";
export interface Plans {
[id: string]: PlanView;
}
export declare class PlanNavigator extends Component<Plans> {
/**
* Helper to control the camera and easily define and navigate 2D floor plans.
*/
export declare class PlanNavigator extends Component<Plans> implements Disposable {
private clipper;
private camera;
name: string;
/** {@link Component.enabled} */
enabled: boolean;
/** The floorplan that is currently selected. */
currentPlan?: PlanView;
/** The offset from the clipping planes to their respective floor plan elevation. */
defaultSectionOffset: number;
/** The offset of the 2D camera to the floor plan elevation. */
defaultCameraOffset: number;
/** The created floor plans. */
storeys: {

@@ -24,7 +32,25 @@ [modelID: number]: any[];

private previousProjection;
/** {@link Component.get} */
get(): Plans;
constructor(clipper: EdgesClipper, camera: OrthoPerspectiveCamera);
/** {@link Disposable.dispose} */
dispose(): void;
create(config: PlanViewConfig): Promise<void>;
/**
* Creates a new floor plan in the navigator.
*
* @param config - Necessary data to initialize the floor plan.
*/
create(config: PlanView): Promise<void>;
/**
* Make the navigator go to the specified floor plan.
*
* @param id - Floor plan to go to.
* @param animate - Whether to animate the camera transition.
*/
goTo(id: string, animate?: boolean): Promise<void>;
/**
* Deactivate navigator and go back to the previous view.
*
* @param animate - Whether to animate the camera transition.
*/
exitPlanView(animate?: boolean): Promise<void>;

@@ -31,0 +57,0 @@ private storeCameraPosition;

import * as THREE from "three";
import { Component } from "../core";
// TODO: Clean up and document this
/**
* Helper to control the camera and easily define and navigate 2D floor plans.
*/
export class PlanNavigator extends Component {

@@ -10,5 +12,9 @@ constructor(clipper, camera) {

this.name = "PlanNavigator";
/** {@link Component.enabled} */
this.enabled = false;
/** The offset from the clipping planes to their respective floor plan elevation. */
this.defaultSectionOffset = 1.5;
/** The offset of the 2D camera to the floor plan elevation. */
this.defaultCameraOffset = 30;
/** The created floor plans. */
this.storeys = [];

@@ -21,9 +27,17 @@ this.plans = {};

}
/** {@link Component.get} */
get() {
return this.plans;
}
/** {@link Disposable.dispose} */
dispose() {
this.storeys = null;
this.plans = null;
this.storeys = [];
this.plans = {};
this.clipper.dispose();
}
/**
* Creates a new floor plan in the navigator.
*
* @param config - Necessary data to initialize the floor plan.
*/
async create(config) {

@@ -36,2 +50,8 @@ if (this.plans[config.id]) {

}
/**
* Make the navigator go to the specified floor plan.
*
* @param id - Floor plan to go to.
* @param animate - Whether to animate the camera transition.
*/
async goTo(id, animate = false) {

@@ -51,2 +71,7 @@ var _a;

}
/**
* Deactivate navigator and go back to the previous view.
*
* @param animate - Whether to animate the camera transition.
*/
async exitPlanView(animate = false) {

@@ -53,0 +78,0 @@ if (!this.enabled)

@@ -10,2 +10,5 @@ import * as THREE from "three";

};
/**
* The edges that are drawn when the {@link EdgesPlane} sections a mesh.
*/
export declare class ClippingEdges extends Component<Edges> implements Hideable, Disposable, Updateable {

@@ -12,0 +15,0 @@ /** {@link Component.name} */

@@ -6,2 +6,5 @@ import * as THREE from "three";

import { Component, Event } from "../../core";
/**
* The edges that are drawn when the {@link EdgesPlane} sections a mesh.
*/
export class ClippingEdges extends Component {

@@ -65,4 +68,2 @@ constructor(components, plane, styles) {

ClippingEdges._basicEdges = new THREE.LineSegments();
this._edges = null;
this._plane = null;
}

@@ -69,0 +70,0 @@ // Initializes the helper geometry used to compute the vertices

@@ -16,2 +16,4 @@ import * as THREE from "three";

constructor(components: Components, PlaneType: new (...args: any) => EdgesPlane);
/** {@link Component.get} */
dispose(): void;
/**

@@ -18,0 +20,0 @@ * Updates all the lines of the {@link ClippingEdges}.

@@ -14,2 +14,7 @@ import { SimpleClipper } from "../../core";

}
/** {@link Component.get} */
dispose() {
super.dispose();
this.styles.dispose();
}
/**

@@ -19,2 +24,4 @@ * Updates all the lines of the {@link ClippingEdges}.

updateEdges() {
if (!this.enabled)
return;
for (const plane of this._planes) {

@@ -21,0 +28,0 @@ plane.update();

@@ -13,5 +13,8 @@ import * as THREE from "three";

constructor(components: Components, origin: THREE.Vector3, normal: THREE.Vector3, size: number, material: THREE.Material, isPlan: boolean, styles: EdgesStyles);
/** {@link Disposable.dispose} */
set enabled(state: boolean);
/** {@link Disposable.dispose} */
dispose(): void;
/** {@link Updateable.update} */
update(): void;
}

@@ -12,2 +12,3 @@ import { SimplePlane } from "../../core";

}
/** {@link Disposable.dispose} */
set enabled(state) {

@@ -17,7 +18,8 @@ super.enabled = state;

}
/** {@link Disposable.dispose} */
dispose() {
super.dispose();
this.edges.dispose();
this.edges = null;
}
/** {@link Updateable.update} */
update() {

@@ -24,0 +26,0 @@ super.update();

export * from "./postproduction";
export * from "./PostproductionRenderer";
export * from "./postproduction-renderer";
export * from "./postproduction";
export * from "./PostproductionRenderer";
export * from "./postproduction-renderer";
//# sourceMappingURL=index.js.map

@@ -119,19 +119,6 @@ import * as THREE from "three";

this.renderTarget.dispose();
this.renderTarget = null;
(_a = this.depthTexture) === null || _a === void 0 ? void 0 : _a.dispose();
this.depthTexture = null;
(_b = this.customOutline) === null || _b === void 0 ? void 0 : _b.dispose();
this.customOutline = null;
this.composer = null;
this.excludedItems.clear();
this.excludedItems = null;
this.composer = null;
this.htmlOverlay.remove();
this.htmlOverlay = null;
this.outlineParams = null;
this.components = null;
this.renderer = null;
this.saoPass = null;
this.outlineUniforms = null;
this.scene = null;
}

@@ -138,0 +125,0 @@ setSize(width, height) {

import * as THREE from "three";
import { Component } from "../../core";
import { Component, Disposable } from "../../core";
import { Components } from "../../components";

@@ -14,3 +14,3 @@ export interface Shadow {

}
export declare class ShadowDropper extends Component<Shadows> {
export declare class ShadowDropper extends Component<Shadows> implements Disposable {
private components;

@@ -32,5 +32,18 @@ name: string;

constructor(components: Components);
/** {@link Component.get} */
get(): Shadows;
/** {@link Disposable.dispose} */
dispose(): void;
/**
* Creates a blurred dropped shadow of the given mesh.
*
* @param model - the mesh whose shadow to generate.
* @param id - the name of this shadow.
*/
renderShadow(model: THREE.Mesh[], id: string): THREE.Group;
/**
* Deletes the specified shadow (if it exists).
*
* @param id - the name of this shadow.
*/
deleteShadow(id: string): void;

@@ -37,0 +50,0 @@ private createPlanes;

@@ -26,15 +26,19 @@ import * as THREE from "three";

}
/** {@link Component.get} */
get() {
return this.shadows;
}
/** {@link Disposable.dispose} */
dispose() {
const shadowIDs = Object.keys(this.shadows);
shadowIDs.forEach((shadowID) => this.deleteShadow(shadowID));
this.shadows = null;
this.tempMaterial.dispose();
this.tempMaterial = null;
this.depthMaterial.dispose();
this.depthMaterial = null;
this.components = null;
}
/**
* Creates a blurred dropped shadow of the given mesh.
*
* @param model - the mesh whose shadow to generate.
* @param id - the name of this shadow.
*/
renderShadow(model, id) {

@@ -51,2 +55,7 @@ if (this.shadows[id]) {

}
/**
* Deletes the specified shadow (if it exists).
*
* @param id - the name of this shadow.
*/
deleteShadow(id) {

@@ -53,0 +62,0 @@ const shadow = this.shadows[id];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc