@thatopen/components 1.5.0 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/core/Clipper/index.d.ts +104 -0
  2. package/dist/core/Clipper/src/index.d.ts +1 -0
  3. package/dist/core/Clipper/src/simple-plane.d.ts +61 -0
  4. package/dist/core/Components/index.d.ts +52 -0
  5. package/dist/core/Cullers/index.d.ts +23 -0
  6. package/dist/core/Cullers/src/culler-renderer.d.ts +66 -0
  7. package/dist/core/Cullers/src/index.d.ts +3 -0
  8. package/dist/core/Cullers/src/mesh-culler-renderer.d.ts +27 -0
  9. package/dist/core/Cullers/src/screen-culler-helper.d.ts +1 -0
  10. package/dist/core/Disposer/index.d.ts +43 -0
  11. package/dist/core/Grids/index.d.ts +13 -0
  12. package/dist/core/Grids/src/index.d.ts +1 -0
  13. package/dist/core/Grids/src/simple-grid.d.ts +48 -0
  14. package/dist/core/Materials/index.d.ts +61 -0
  15. package/dist/core/Raycasters/index.d.ts +13 -0
  16. package/dist/core/Raycasters/src/index.d.ts +2 -0
  17. package/dist/core/Raycasters/src/mouse.d.ts +26 -0
  18. package/dist/core/Raycasters/src/simple-raycaster.d.ts +36 -0
  19. package/dist/core/Types/index.d.ts +1 -0
  20. package/dist/core/Types/src/base-camera.d.ts +11 -0
  21. package/dist/core/Types/src/base-renderer.d.ts +40 -0
  22. package/dist/core/Types/src/base-scene.d.ts +13 -0
  23. package/dist/core/Types/src/base-world-item.d.ts +17 -0
  24. package/dist/core/Types/src/base.d.ts +19 -0
  25. package/dist/core/Types/src/component.d.ts +18 -0
  26. package/dist/core/Types/src/event.d.ts +34 -0
  27. package/dist/core/Types/src/index.d.ts +9 -0
  28. package/dist/core/Types/src/interfaces.d.ts +134 -0
  29. package/dist/core/Types/src/world.d.ts +12 -0
  30. package/dist/core/Worlds/index.d.ts +17 -0
  31. package/dist/core/Worlds/src/index.d.ts +4 -0
  32. package/dist/core/Worlds/src/simple-camera.d.ts +46 -0
  33. package/dist/core/Worlds/src/simple-renderer.d.ts +32 -0
  34. package/dist/core/Worlds/src/simple-scene.d.ts +30 -0
  35. package/dist/core/Worlds/src/simple-world.d.ts +26 -0
  36. package/dist/core/index.d.ts +9 -0
  37. package/dist/fragments/FragmentBoundingBox/index.d.ts +36 -0
  38. package/dist/fragments/FragmentClassifier/index.d.ts +30 -0
  39. package/dist/fragments/FragmentExploder/index.d.ts +15 -0
  40. package/dist/fragments/FragmentIfcLoader/index.d.ts +33 -0
  41. package/dist/fragments/FragmentIfcLoader/src/civil-reader.d.ts +15 -0
  42. package/dist/fragments/FragmentIfcLoader/src/ifc-fragment-settings.d.ts +27 -0
  43. package/dist/fragments/FragmentIfcLoader/src/ifc-metadata-reader.d.ts +4 -0
  44. package/dist/fragments/FragmentIfcLoader/src/index.d.ts +3 -0
  45. package/dist/fragments/FragmentIfcLoader/src/spatial-structure.d.ts +8 -0
  46. package/dist/fragments/FragmentIfcLoader/src/transform-helper.d.ts +5 -0
  47. package/dist/fragments/FragmentIfcLoader/src/units.d.ts +10 -0
  48. package/dist/fragments/FragmentIfcStreamer/index.d.ts +1 -0
  49. package/dist/fragments/FragmentIfcStreamer/src/base-types.d.ts +15 -0
  50. package/dist/fragments/FragmentIfcStreamer/src/fragment-ifc-stream-converter.d.ts +41 -0
  51. package/dist/fragments/FragmentIfcStreamer/src/fragment-props-stream-converter.d.ts +27 -0
  52. package/dist/fragments/FragmentIfcStreamer/src/index.d.ts +4 -0
  53. package/dist/fragments/FragmentIfcStreamer/src/streaming-settings.d.ts +10 -0
  54. package/dist/fragments/FragmentManager/index.d.ts +44 -0
  55. package/dist/fragments/index.d.ts +5 -0
  56. package/dist/ifc/IfcJsonExporter/index.d.ts +16 -0
  57. package/dist/ifc/IfcJsonExporter/src/ifc-geometry-types.d.ts +1 -0
  58. package/dist/ifc/IfcPropertiesFinder/index.d.ts +37 -0
  59. package/dist/ifc/IfcPropertiesFinder/src/types.d.ts +23 -0
  60. package/dist/ifc/IfcPropertiesIndexer/index.d.ts +31 -0
  61. package/dist/ifc/IfcPropertiesManager/index.d.ts +73 -0
  62. package/dist/ifc/Utils/ifc-categories.d.ts +7 -0
  63. package/dist/ifc/Utils/ifc-category-map.d.ts +3 -0
  64. package/dist/ifc/Utils/ifc-elements-map.d.ts +3 -0
  65. package/dist/ifc/Utils/index.d.ts +4 -0
  66. package/dist/ifc/Utils/properties-utils.d.ts +25 -0
  67. package/dist/ifc/index.d.ts +5 -0
  68. package/dist/index.cjs +88 -0
  69. package/dist/index.d.ts +4 -0
  70. package/dist/index.mjs +9024 -0
  71. package/dist/namespace.d.ts +1744 -0
  72. package/dist/navigation/OrthoPerspectiveCamera/index.d.ts +49 -0
  73. package/dist/navigation/OrthoPerspectiveCamera/src/first-person-mode.d.ts +16 -0
  74. package/dist/navigation/OrthoPerspectiveCamera/src/index.d.ts +5 -0
  75. package/dist/navigation/OrthoPerspectiveCamera/src/orbit-mode.d.ts +16 -0
  76. package/dist/navigation/OrthoPerspectiveCamera/src/plan-mode.d.ts +20 -0
  77. package/dist/navigation/OrthoPerspectiveCamera/src/projections.d.ts +37 -0
  78. package/dist/navigation/OrthoPerspectiveCamera/src/types.d.ts +27 -0
  79. package/dist/navigation/index.d.ts +1 -0
  80. package/dist/utils/bbox.d.ts +7 -0
  81. package/dist/utils/geometry.d.ts +1 -0
  82. package/dist/utils/index.d.ts +4 -0
  83. package/dist/utils/materials.d.ts +4 -0
  84. package/dist/utils/uuid.d.ts +6 -0
  85. package/package.json +10 -5
@@ -0,0 +1,104 @@
1
+ import * as THREE from "three";
2
+ import { Component, Createable, Disposable, Event, Hideable, World } from "../Types";
3
+ import { SimplePlane } from "./src";
4
+ import { Components } from "../Components";
5
+ export * from "./src";
6
+ /**
7
+ * A lightweight component to easily create and handle
8
+ * [clipping planes](https://threejs.org/docs/#api/en/materials/Material.clippingPlanes).
9
+ *
10
+ * @param components - the instance of {@link Components} used.
11
+ * @param planeType - the type of plane to be used by the clipper.
12
+ * E.g. {@link SimplePlane}.
13
+ */
14
+ export declare class Clipper<T extends SimplePlane> extends Component implements Createable, Disposable, Hideable {
15
+ static readonly uuid: "66290bc5-18c4-4cd1-9379-2e17a0617611";
16
+ /** {@link Createable.onAfterCreate} */
17
+ readonly onAfterCreate: Event<T>;
18
+ /** {@link Createable.onAfterDelete} */
19
+ readonly onAfterDelete: Event<T>;
20
+ /** Event that fires when the user starts dragging a clipping plane. */
21
+ readonly onBeforeDrag: Event<void>;
22
+ /** Event that fires when the user stops dragging a clipping plane. */
23
+ readonly onAfterDrag: Event<void>;
24
+ readonly onBeforeCreate: Event<unknown>;
25
+ readonly onBeforeCancel: Event<unknown>;
26
+ readonly onAfterCancel: Event<unknown>;
27
+ readonly onBeforeDelete: Event<unknown>;
28
+ /** {@link Disposable.onDisposed} */
29
+ readonly onDisposed: Event<string>;
30
+ /**
31
+ * Whether to force the clipping plane to be orthogonal in the Y direction
32
+ * (up). This is desirable when clipping a building horizontally and a
33
+ * clipping plane is created in its roof, which might have a slight
34
+ * slope for draining purposes.
35
+ */
36
+ orthogonalY: boolean;
37
+ /**
38
+ * The tolerance that determines whether an almost-horizontal clipping plane
39
+ * will be forced to be orthogonal to the Y direction. {@link orthogonalY}
40
+ * has to be `true` for this to apply.
41
+ */
42
+ toleranceOrthogonalY: number;
43
+ list: T[];
44
+ protected PlaneType: new (...args: any) => SimplePlane | T;
45
+ /** The material used in all the clipping planes. */
46
+ protected _material: THREE.Material;
47
+ private _size;
48
+ private _enabled;
49
+ private _visible;
50
+ /** {@link Component.enabled} */
51
+ get enabled(): boolean;
52
+ /** {@link Component.enabled} */
53
+ set enabled(state: boolean);
54
+ /** {@link Hideable.visible } */
55
+ get visible(): boolean;
56
+ /** {@link Hideable.visible } */
57
+ set visible(state: boolean);
58
+ /** The material of the clipping plane representation. */
59
+ get material(): THREE.Material;
60
+ /** The material of the clipping plane representation. */
61
+ set material(material: THREE.Material);
62
+ /** The size of the geometric representation of the clippings planes. */
63
+ get size(): number;
64
+ /** The size of the geometric representation of the clippings planes. */
65
+ set size(size: number);
66
+ constructor(components: Components);
67
+ endCreation(): void;
68
+ cancelCreation(): void;
69
+ /** {@link Disposable.dispose} */
70
+ dispose(): void;
71
+ /** {@link Createable.create} */
72
+ create(world: World): void;
73
+ /**
74
+ * Creates a plane in a certain place and with a certain orientation,
75
+ * without the need of the mouse.
76
+ *
77
+ * @param world - the world where this plane should be created.
78
+ * @param normal - the orientation of the clipping plane.
79
+ * @param point - the position of the clipping plane.
80
+ * navigation.
81
+ */
82
+ createFromNormalAndCoplanarPoint(world: World, normal: THREE.Vector3, point: THREE.Vector3): T;
83
+ /**
84
+ * {@link Createable.delete}
85
+ *
86
+ * @param world - the world where the plane to delete is.
87
+ * @param plane - the plane to delete. If undefined, the first plane
88
+ * found under the cursor will be deleted.
89
+ */
90
+ delete(world: World, plane?: T): void;
91
+ /** Deletes all the existing clipping planes. */
92
+ deleteAll(): void;
93
+ private deletePlane;
94
+ private pickPlane;
95
+ private getAllPlaneMeshes;
96
+ private createPlaneFromIntersection;
97
+ private getWorldNormal;
98
+ private normalizePlaneDirectionY;
99
+ private newPlane;
100
+ protected newPlaneInstance(world: World, point: THREE.Vector3, normal: THREE.Vector3): T;
101
+ private updateMaterialsAndPlanes;
102
+ private _onStartDragging;
103
+ private _onEndDragging;
104
+ }
@@ -0,0 +1 @@
1
+ export * from "./simple-plane";
@@ -0,0 +1,61 @@
1
+ import * as THREE from "three";
2
+ import { Hideable, Disposable, Event, World } from "../../Types";
3
+ import { Components } from "../../Components";
4
+ /**
5
+ * Each of the planes created by {@link SimpleClipper}.
6
+ */
7
+ export declare class SimplePlane implements Disposable, Hideable {
8
+ /** Event that fires when the user starts dragging a clipping plane. */
9
+ readonly onDraggingStarted: Event<unknown>;
10
+ /** Event that fires when the user stops dragging a clipping plane. */
11
+ readonly onDraggingEnded: Event<unknown>;
12
+ /** {@link Disposable.onDisposed} */
13
+ readonly onDisposed: Event<unknown>;
14
+ readonly normal: THREE.Vector3;
15
+ readonly origin: THREE.Vector3;
16
+ readonly three: THREE.Plane;
17
+ protected readonly _helper: THREE.Object3D;
18
+ protected _visible: boolean;
19
+ protected _enabled: boolean;
20
+ components: Components;
21
+ world: World;
22
+ private _controlsActive;
23
+ private readonly _arrowBoundBox;
24
+ private readonly _planeMesh;
25
+ private readonly _controls;
26
+ private readonly _hiddenMaterial;
27
+ get enabled(): boolean;
28
+ /** {@link Component.enabled} */
29
+ set enabled(state: boolean);
30
+ /** {@link Hideable.visible } */
31
+ get visible(): boolean;
32
+ /** {@link Hideable.visible } */
33
+ set visible(state: boolean);
34
+ /** The meshes used for raycasting */
35
+ get meshes(): THREE.Mesh[];
36
+ /** The material of the clipping plane representation. */
37
+ get planeMaterial(): THREE.Material | THREE.Material[];
38
+ /** The material of the clipping plane representation. */
39
+ set planeMaterial(material: THREE.Material | THREE.Material[]);
40
+ /** The size of the clipping plane representation. */
41
+ get size(): number;
42
+ /** Sets the size of the clipping plane representation. */
43
+ set size(size: number);
44
+ get helper(): THREE.Object3D<THREE.Object3DEventMap>;
45
+ constructor(components: Components, world: World, origin: THREE.Vector3, normal: THREE.Vector3, material: THREE.Material, size?: number, activateControls?: boolean);
46
+ setFromNormalAndCoplanarPoint(normal: THREE.Vector3, point: THREE.Vector3): Promise<void>;
47
+ /** {@link Updateable.update} */
48
+ update: () => Promise<void>;
49
+ /** {@link Disposable.dispose} */
50
+ dispose(): void;
51
+ private reset;
52
+ protected toggleControls(state: boolean): void;
53
+ private newTransformControls;
54
+ private initializeControls;
55
+ private createArrowBoundingBox;
56
+ private changeDrag;
57
+ private notifyDraggingChanged;
58
+ private preventCameraMovement;
59
+ private newHelper;
60
+ private static newPlaneMesh;
61
+ }
@@ -0,0 +1,52 @@
1
+ import { Component, Disposable, Event } from "../Types";
2
+ /**
3
+ * The entry point of the Components library.
4
+ * It can:
5
+ * - Create and access all the components of the library.
6
+ * - Update all the updatable components automatically.
7
+ * - Dispose all the components, preventing memory leaks.
8
+ */
9
+ export declare class Components implements Disposable {
10
+ static readonly release = "1.4.21";
11
+ /** {@link Disposable.onDisposed} */
12
+ readonly onDisposed: Event<void>;
13
+ /** The list of components created in this app. */
14
+ readonly list: Map<string, Component>;
15
+ /** If disabled, the animation loop will be stopped. */
16
+ enabled: boolean;
17
+ private _clock;
18
+ add(uuid: string, instance: Component): void;
19
+ /**
20
+ * Retrieves a component. If it already exists in this app, it returns the instance of the component. If it
21
+ * doesn't exist, it will instance it automatically.
22
+ *
23
+ * @param Component - The component to get or create.
24
+ */
25
+ get<U extends Component>(Component: new (components: Components) => U): U;
26
+ constructor();
27
+ /**
28
+ * Initializes the library. It should be called at the start of the app after
29
+ * initializing the scene, the renderer and the
30
+ * camera. Additionally, if any component that need a raycaster is
31
+ * used, the {@link raycaster} will need to be initialized.
32
+ */
33
+ init(): void;
34
+ /**
35
+ * Disposes the memory of all the components and tools of this instance of
36
+ * the library. A memory leak will be created if:
37
+ *
38
+ * - An instance of the library ends up out of scope and this function isn't
39
+ * called. This is especially relevant in Single Page Applications (React,
40
+ * Angular, Vue, etc).
41
+ *
42
+ * - Any of the objects of this instance (meshes, geometries, etc) is
43
+ * referenced by a reference type (object or array).
44
+ *
45
+ * You can learn more about how Three.js handles memory leaks
46
+ * [here](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects).
47
+ *
48
+ */
49
+ dispose(): void;
50
+ private update;
51
+ private static setupBVH;
52
+ }
@@ -0,0 +1,23 @@
1
+ import { Components } from "../Components";
2
+ import { MeshCullerRenderer, CullerRendererSettings } from "./src";
3
+ import { Component, Event, Disposable, World } from "../Types";
4
+ export * from "./src";
5
+ /**
6
+ * A tool to handle big scenes efficiently by automatically hiding the objects
7
+ * that are not visible to the camera.
8
+ */
9
+ export declare class Cullers extends Component implements Disposable {
10
+ static readonly uuid: "69f2a50d-c266-44fc-b1bd-fa4d34be89e6";
11
+ private _enabled;
12
+ list: Map<string, MeshCullerRenderer>;
13
+ /** {@link Disposable.onDisposed} */
14
+ readonly onDisposed: Event<unknown>;
15
+ /** {@link Component.enabled} */
16
+ get enabled(): boolean;
17
+ set enabled(value: boolean);
18
+ constructor(components: Components);
19
+ create(world: World, config?: Partial<CullerRendererSettings>): MeshCullerRenderer;
20
+ delete(world: World): void;
21
+ /** {@link Disposable.dispose} */
22
+ dispose(): void;
23
+ }
@@ -0,0 +1,66 @@
1
+ import * as THREE from "three";
2
+ import { Components } from "../../Components";
3
+ import { Event, World } from "../../Types";
4
+ export interface CullerRendererSettings {
5
+ updateInterval?: number;
6
+ width?: number;
7
+ height?: number;
8
+ autoUpdate?: boolean;
9
+ }
10
+ /**
11
+ * A base renderer to determine visibility on screen
12
+ */
13
+ export declare class CullerRenderer {
14
+ /** {@link Disposable.onDisposed} */
15
+ readonly onDisposed: Event<string>;
16
+ /**
17
+ * Fires after making the visibility check to the meshes. It lists the
18
+ * meshes that are currently visible, and the ones that were visible
19
+ * just before but not anymore.
20
+ */
21
+ readonly onViewUpdated: Event<any>;
22
+ /** {@link Component.enabled} */
23
+ enabled: boolean;
24
+ /**
25
+ * Needs to check whether there are objects that need to be hidden or shown.
26
+ * You can bind this to the camera movement, to a certain interval, etc.
27
+ */
28
+ needsUpdate: boolean;
29
+ /**
30
+ * Render the internal scene used to determine the object visibility. Used
31
+ * for debugging purposes.
32
+ */
33
+ renderDebugFrame: boolean;
34
+ components: Components;
35
+ readonly world: World;
36
+ readonly renderer: THREE.WebGLRenderer;
37
+ protected autoUpdate: boolean;
38
+ protected updateInterval: number;
39
+ protected readonly worker: Worker;
40
+ protected readonly scene: THREE.Scene;
41
+ private _width;
42
+ private _height;
43
+ private _availableColor;
44
+ private readonly renderTarget;
45
+ private readonly bufferSize;
46
+ private readonly _buffer;
47
+ constructor(components: Components, world: World, settings?: CullerRendererSettings);
48
+ /** {@link Disposable.dispose} */
49
+ dispose(): void;
50
+ /**
51
+ * The function that the culler uses to reprocess the scene. Generally it's
52
+ * better to call needsUpdate, but you can also call this to force it.
53
+ * @param force if true, it will refresh the scene even if needsUpdate is
54
+ * not true.
55
+ */
56
+ updateVisibility: (force?: boolean) => Promise<void>;
57
+ protected getAvailableColor(): {
58
+ r: number;
59
+ g: number;
60
+ b: number;
61
+ code: string;
62
+ };
63
+ protected increaseColor(): void;
64
+ protected decreaseColor(): void;
65
+ private applySettings;
66
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./culler-renderer";
2
+ export * from "./mesh-culler-renderer";
3
+ export * from "./screen-culler-helper";
@@ -0,0 +1,27 @@
1
+ import * as THREE from "three";
2
+ import { CullerRenderer, CullerRendererSettings } from "./culler-renderer";
3
+ import { Components } from "../../Components";
4
+ import { Event, World } from "../../Types";
5
+ /**
6
+ * A renderer to determine a mesh visibility on screen
7
+ */
8
+ export declare class MeshCullerRenderer extends CullerRenderer {
9
+ threshold: number;
10
+ readonly onViewUpdated: Event<{
11
+ seen: Set<THREE.Mesh>;
12
+ unseen: Set<THREE.Mesh>;
13
+ }>;
14
+ colorMeshes: Map<string, THREE.InstancedMesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[]>>;
15
+ isProcessing: boolean;
16
+ private _colorCodeMeshMap;
17
+ private _meshIDColorCodeMap;
18
+ private _currentVisibleMeshes;
19
+ private _recentlyHiddenMeshes;
20
+ private readonly _transparentMat;
21
+ constructor(components: Components, world: World, settings?: CullerRendererSettings);
22
+ dispose(): void;
23
+ add(mesh: THREE.Mesh | THREE.InstancedMesh): void;
24
+ remove(mesh: THREE.Mesh | THREE.InstancedMesh): void;
25
+ private handleWorkerMessage;
26
+ private getAvailableMaterial;
27
+ }
@@ -0,0 +1 @@
1
+ export declare function readPixelsAsync(gl: WebGL2RenderingContext, x: number, y: number, w: number, h: number, format: any, type: any, dest: ArrayBufferView): Promise<ArrayBufferView>;
@@ -0,0 +1,43 @@
1
+ import * as THREE from "three";
2
+ import { Components } from "../Components";
3
+ import { Component } from "../Types";
4
+ /**
5
+ * A tool to safely remove meshes and geometries from memory to
6
+ * [prevent memory leaks](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects).
7
+ */
8
+ export declare class Disposer extends Component {
9
+ private _disposedComponents;
10
+ /** {@link Component.enabled} */
11
+ enabled: boolean;
12
+ static readonly uuid: "76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe";
13
+ constructor(components: Components);
14
+ /**
15
+ * {@link Component.uuid}.
16
+ * @return the list of UUIDs of deleted components.
17
+ */
18
+ get(): Set<string>;
19
+ /**
20
+ * Removes a mesh, its geometry and its materials from memory. If you are
21
+ * using any of these in other parts of the application, make sure that you
22
+ * remove them from the mesh before disposing it.
23
+ *
24
+ * @param object - the [object](https://threejs.org/docs/#api/en/core/Object3D)
25
+ * to remove.
26
+ *
27
+ * @param materials - whether to dispose the materials of the mesh.
28
+ *
29
+ * @param recursive - whether to recursively dispose the children of the mesh.
30
+ */
31
+ destroy(object: THREE.Object3D, materials?: boolean, recursive?: boolean): void;
32
+ /**
33
+ * Disposes a geometry from memory.
34
+ *
35
+ * @param geometry - the
36
+ * [geometry](https://threejs.org/docs/#api/en/core/BufferGeometry)
37
+ * to remove.
38
+ */
39
+ disposeGeometry(geometry: THREE.BufferGeometry): void;
40
+ private disposeGeometryAndMaterials;
41
+ private disposeChildren;
42
+ private static disposeMaterial;
43
+ }
@@ -0,0 +1,13 @@
1
+ import { Component, Disposable, World, Event } from "../Types";
2
+ import { GridConfig, SimpleGrid } from "./src";
3
+ export declare class Grids extends Component implements Disposable {
4
+ static readonly uuid: "d1e814d5-b81c-4452-87a2-f039375e0489";
5
+ list: Map<string, SimpleGrid>;
6
+ onDisposed: Event<unknown>;
7
+ config: Required<GridConfig>;
8
+ /** {@link Component.enabled} */
9
+ enabled: boolean;
10
+ create(world: World): void;
11
+ delete(world: World): void;
12
+ dispose(): void;
13
+ }
@@ -0,0 +1 @@
1
+ export * from "./simple-grid";
@@ -0,0 +1,48 @@
1
+ /// <reference types="node" />
2
+ import * as THREE from "three";
3
+ import { Hideable, Event, World } from "../../Types";
4
+ import { Components } from "../../Components";
5
+ export interface GridConfig {
6
+ color: THREE.Color;
7
+ size1: number;
8
+ size2: number;
9
+ distance: number;
10
+ }
11
+ /**
12
+ * An infinite grid. Created by
13
+ * [fyrestar](https://github.com/Fyrestar/THREE.InfiniteGridHelper)
14
+ * and translated to typescript by
15
+ * [dkaraush](https://github.com/dkaraush/THREE.InfiniteGridHelper/blob/master/InfiniteGridHelper.ts).
16
+ */
17
+ export declare class SimpleGrid implements Hideable, Disposable {
18
+ /** {@link Disposable.onDisposed} */
19
+ readonly onDisposed: Event<unknown>;
20
+ world: World;
21
+ components: Components;
22
+ /** {@link Hideable.visible} */
23
+ get visible(): boolean;
24
+ /** {@link Hideable.visible} */
25
+ set visible(visible: boolean);
26
+ /** The material of the grid. */
27
+ get material(): THREE.ShaderMaterial;
28
+ /**
29
+ * Whether the grid should fade away with distance. Recommended to be true for
30
+ * perspective cameras and false for orthographic cameras.
31
+ */
32
+ get fade(): boolean;
33
+ /**
34
+ * Whether the grid should fade away with distance. Recommended to be true for
35
+ * perspective cameras and false for orthographic cameras.
36
+ */
37
+ set fade(active: boolean);
38
+ private readonly _grid;
39
+ private _fade;
40
+ constructor(components: Components, world: World, config: GridConfig);
41
+ [Symbol.dispose](): void;
42
+ /** {@link Component.get} */
43
+ get(): THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>;
44
+ /** {@link Disposable.dispose} */
45
+ dispose(): void;
46
+ private setupEvents;
47
+ private updateZoom;
48
+ }
@@ -0,0 +1,61 @@
1
+ import * as THREE from "three";
2
+ import { Component, Disposable, Event, World } from "../Types";
3
+ import { Components } from "../Components";
4
+ /**
5
+ * A tool to easily handle the materials of massive amounts of
6
+ * objects and scene background easily.
7
+ */
8
+ export declare class Materials extends Component implements Disposable {
9
+ static readonly uuid: "24989d27-fa2f-4797-8b08-35918f74e502";
10
+ /** {@link Component.enabled} */
11
+ enabled: boolean;
12
+ private _originalBackground;
13
+ /** {@link Disposable.onDisposed} */
14
+ readonly onDisposed: Event<string>;
15
+ list: {
16
+ [id: string]: {
17
+ material: THREE.Material;
18
+ meshes: Set<THREE.Mesh | THREE.InstancedMesh>;
19
+ };
20
+ };
21
+ private _originals;
22
+ constructor(components: Components);
23
+ /**
24
+ * Turns the specified material styles on or off.
25
+ *
26
+ * @param active whether to turn it on or off.
27
+ * @param ids the ids of the style to turn on or off.
28
+ */
29
+ set(active: boolean, ids?: string[]): void;
30
+ /** {@link Disposable.dispose} */
31
+ dispose(): void;
32
+ /**
33
+ * Sets the color of the background of the scene.
34
+ *
35
+ * @param color: the color to apply.
36
+ */
37
+ setBackgroundColor(color: THREE.Color, world: World): void;
38
+ /**
39
+ * Resets the scene background to the color that was being used
40
+ * before applying the material manager.
41
+ */
42
+ resetBackgroundColor(world: World): void;
43
+ /**
44
+ * Creates a new material style.
45
+ * @param id the identifier of the style to create.
46
+ * @param material the material of the style.
47
+ */
48
+ addMaterial(id: string, material: THREE.Material): void;
49
+ /**
50
+ * Assign meshes to a certain style.
51
+ * @param id the identifier of the style.
52
+ * @param meshes the meshes to assign to the style.
53
+ */
54
+ addMeshes(id: string, meshes: THREE.Mesh[]): void;
55
+ /**
56
+ * Remove meshes from a certain style.
57
+ * @param id the identifier of the style.
58
+ * @param meshes the meshes to assign to the style.
59
+ */
60
+ removeMeshes(id: string, meshes: THREE.Mesh[]): void;
61
+ }
@@ -0,0 +1,13 @@
1
+ import { Component, Disposable, World, Event } from "../Types";
2
+ import { SimpleRaycaster } from "./src";
3
+ import { Components } from "../Components";
4
+ export declare class Raycasters extends Component implements Disposable {
5
+ static readonly uuid: "d5d8bdf0-db25-4952-b951-b643af207ace";
6
+ enabled: boolean;
7
+ list: Map<string, SimpleRaycaster>;
8
+ onDisposed: Event<unknown>;
9
+ constructor(components: Components);
10
+ get(world: World): SimpleRaycaster;
11
+ delete(world: World): void;
12
+ dispose(): void;
13
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./mouse";
2
+ export * from "./simple-raycaster";
@@ -0,0 +1,26 @@
1
+ import * as THREE from "three";
2
+ import { Disposable, Event } from "../../Types";
3
+ /**
4
+ * A helper to easily get the real position of the mouse in the Three.js canvas
5
+ * to work with tools like the
6
+ * [raycaster](https://threejs.org/docs/#api/en/core/Raycaster), even if it has
7
+ * been transformed through CSS or doesn't occupy the whole screen.
8
+ */
9
+ export declare class Mouse implements Disposable {
10
+ dom: HTMLCanvasElement;
11
+ private _event?;
12
+ private _position;
13
+ /** {@link Disposable.onDisposed} */
14
+ readonly onDisposed: Event<unknown>;
15
+ constructor(dom: HTMLCanvasElement);
16
+ /**
17
+ * The real position of the mouse of the Three.js canvas.
18
+ */
19
+ get position(): THREE.Vector2;
20
+ /** {@link Disposable.dispose} */
21
+ dispose(): void;
22
+ private getPositionY;
23
+ private getPositionX;
24
+ private updateMouseInfo;
25
+ private setupEvents;
26
+ }
@@ -0,0 +1,36 @@
1
+ import * as THREE from "three";
2
+ import { Components } from "../../Components";
3
+ import { Event, World, Disposable } from "../../Types";
4
+ import { Mouse } from "./mouse";
5
+ /**
6
+ * A simple [raycaster](https://threejs.org/docs/#api/en/core/Raycaster)
7
+ * that allows to easily get items from the scene using the mouse and touch
8
+ * events.
9
+ */
10
+ export declare class SimpleRaycaster implements Disposable {
11
+ /** {@link Component.enabled} */
12
+ enabled: boolean;
13
+ components: Components;
14
+ /** {@link Disposable.onDisposed} */
15
+ readonly onDisposed: Event<unknown>;
16
+ /** The position of the mouse in the screen. */
17
+ readonly mouse: Mouse;
18
+ readonly three: THREE.Raycaster;
19
+ world: World;
20
+ constructor(components: Components, world: World);
21
+ /** {@link Disposable.dispose} */
22
+ dispose(): void;
23
+ /**
24
+ * Throws a ray from the camera to the mouse or touch event point and returns
25
+ * the first item found. This also takes into account the clipping planes
26
+ * used by the renderer.
27
+ *
28
+ * @param items - the [meshes](https://threejs.org/docs/#api/en/objects/Mesh)
29
+ * to query. If not provided, it will query all the meshes stored in
30
+ * {@link Components.meshes}.
31
+ */
32
+ castRay(items?: THREE.Mesh[]): THREE.Intersection | null;
33
+ castRayFromVector(origin: THREE.Vector3, direction: THREE.Vector3, items?: THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>[]): THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>> | null;
34
+ private intersect;
35
+ private filterClippingPlanes;
36
+ }
@@ -0,0 +1 @@
1
+ export * from "./src";
@@ -0,0 +1,11 @@
1
+ import * as THREE from "three";
2
+ import CameraControls from "camera-controls";
3
+ import { BaseWorldItem } from "./base-world-item";
4
+ import { CameraControllable } from "./interfaces";
5
+ export declare abstract class BaseCamera extends BaseWorldItem {
6
+ abstract enabled: boolean;
7
+ abstract three: THREE.Camera;
8
+ abstract controls?: CameraControls;
9
+ /** Whether is instance is {@link CameraControllable}. */
10
+ hasCameraControls: () => this is CameraControllable;
11
+ }
@@ -0,0 +1,40 @@
1
+ import * as THREE from "three";
2
+ import { Vector2 } from "three";
3
+ import { Event } from "./event";
4
+ import { BaseWorldItem } from "./base-world-item";
5
+ import { Disposable, Resizeable, Updateable } from "./interfaces";
6
+ export declare abstract class BaseRenderer extends BaseWorldItem implements Updateable, Disposable, Resizeable {
7
+ abstract three: THREE.WebGLRenderer;
8
+ /** {@link Updateable.onBeforeUpdate} */
9
+ onAfterUpdate: Event<unknown>;
10
+ /** {@link Updateable.onAfterUpdate} */
11
+ onBeforeUpdate: Event<unknown>;
12
+ /** {@link Disposable.onDisposed} */
13
+ readonly onDisposed: Event<undefined>;
14
+ readonly onResize: Event<THREE.Vector2>;
15
+ /**
16
+ * Event that fires when there has been a change to the list of clipping
17
+ * planes used by the active renderer.
18
+ */
19
+ readonly onClippingPlanesUpdated: Event<unknown>;
20
+ abstract update(delta?: number): void | Promise<void>;
21
+ abstract dispose(): void;
22
+ abstract getSize(): Vector2;
23
+ abstract resize(size: Vector2 | undefined): void;
24
+ /**
25
+ * The list of [clipping planes](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.clippingPlanes) used by this
26
+ * instance of the renderer.
27
+ */
28
+ clippingPlanes: THREE.Plane[];
29
+ /**
30
+ * Forces the update of the clipping planes and all components that depend
31
+ * on them that are subscribed to `onClippingPlanesUpdated`.
32
+ */
33
+ updateClippingPlanes(): void;
34
+ /**
35
+ * Adds or removes a
36
+ * [clipping plane](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.clippingPlanes)
37
+ * to the renderer.
38
+ */
39
+ setPlane(active: boolean, plane: THREE.Plane, isLocal?: boolean): void;
40
+ }