@thatopen/components 2.0.8 → 2.0.10
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.
- package/dist/core/Clipper/index.d.ts +34 -6
- package/dist/core/Clipper/src/simple-plane.d.ts +40 -4
- package/dist/core/Components/index.d.ts +42 -18
- package/dist/core/Cullers/index.d.ts +23 -27
- package/dist/core/Cullers/src/culler-renderer.d.ts +26 -2
- package/dist/core/Cullers/src/mesh-culler-renderer.d.ts +32 -4
- package/dist/core/Disposer/index.d.ts +6 -4
- package/dist/core/Grids/index.d.ts +35 -1
- package/dist/core/Grids/src/simple-grid.d.ts +3 -0
- package/dist/core/MiniMap/index.d.ts +31 -0
- package/dist/core/MiniMap/src/index.d.ts +55 -0
- package/dist/core/OrthoPerspectiveCamera/index.d.ts +19 -6
- package/dist/core/OrthoPerspectiveCamera/src/first-person-mode.d.ts +1 -2
- package/dist/core/OrthoPerspectiveCamera/src/orbit-mode.d.ts +1 -2
- package/dist/core/OrthoPerspectiveCamera/src/plan-mode.d.ts +1 -2
- package/dist/core/OrthoPerspectiveCamera/src/projections.d.ts +10 -2
- package/dist/core/OrthoPerspectiveCamera/src/types.d.ts +1 -2
- package/dist/core/Raycasters/index.d.ts +29 -0
- package/dist/core/Raycasters/src/simple-raycaster.d.ts +18 -0
- package/dist/core/Types/src/async-event.d.ts +1 -7
- package/dist/core/Types/src/base-camera.d.ts +18 -1
- package/dist/core/Types/src/base-renderer.d.ts +34 -9
- package/dist/core/Types/src/base-scene.d.ts +7 -0
- package/dist/core/Types/src/base-world-item.d.ts +8 -2
- package/dist/core/Types/src/base.d.ts +1 -1
- package/dist/core/Types/src/component.d.ts +1 -6
- package/dist/core/Types/src/event.d.ts +1 -7
- package/dist/core/Types/src/interfaces.d.ts +9 -24
- package/dist/core/Types/src/world.d.ts +21 -0
- package/dist/core/Worlds/index.d.ts +31 -15
- package/dist/core/Worlds/src/simple-camera.d.ts +22 -6
- package/dist/core/Worlds/src/simple-renderer.d.ts +25 -3
- package/dist/core/Worlds/src/simple-scene.d.ts +13 -4
- package/dist/core/Worlds/src/simple-world.d.ts +57 -6
- package/dist/fragments/BoundingBoxer/index.d.ts +1 -2
- package/dist/fragments/FragmentsManager/index.d.ts +22 -2
- package/dist/ifc/IfcRelationsIndexer/index.d.ts +2 -2
- package/dist/index.cjs +5 -5
- package/dist/index.mjs +1805 -1325
- package/dist/namespace.d.ts +1396 -894
- package/package.json +1 -1
|
@@ -4,23 +4,36 @@ import { SimpleCamera } from "..";
|
|
|
4
4
|
import { NavigationMode, NavModeID, ProjectionManager } from "./src";
|
|
5
5
|
export * from "./src";
|
|
6
6
|
/**
|
|
7
|
-
* A flexible camera that uses
|
|
8
|
-
* [yomotsu's cameracontrols](https://github.com/yomotsu/camera-controls) to
|
|
9
|
-
* easily control the camera in 2D and 3D. It supports multiple navigation
|
|
10
|
-
* modes, such as 2D floor plan navigation, first person and 3D orbit.
|
|
7
|
+
* A flexible camera that uses [yomotsu's cameracontrols](https://github.com/yomotsu/camera-controls) to easily control the camera in 2D and 3D. It supports multiple navigation modes, such as 2D floor plan navigation, first person and 3D orbit. This class extends the SimpleCamera class and adds additional functionality for managing different camera projections and navigation modes.
|
|
11
8
|
*/
|
|
12
9
|
export declare class OrthoPerspectiveCamera extends SimpleCamera {
|
|
13
10
|
/**
|
|
14
|
-
*
|
|
11
|
+
* A ProjectionManager instance that manages the projection modes of the camera.
|
|
15
12
|
*/
|
|
16
|
-
_mode: NavigationMode | null;
|
|
17
13
|
readonly projection: ProjectionManager;
|
|
14
|
+
/**
|
|
15
|
+
* A THREE.OrthographicCamera instance that represents the orthographic camera.
|
|
16
|
+
* This camera is used when the projection mode is set to orthographic.
|
|
17
|
+
*/
|
|
18
18
|
readonly threeOrtho: THREE.OrthographicCamera;
|
|
19
|
+
/**
|
|
20
|
+
* A THREE.PerspectiveCamera instance that represents the perspective camera.
|
|
21
|
+
* This camera is used when the projection mode is set to perspective.
|
|
22
|
+
*/
|
|
19
23
|
readonly threePersp: THREE.PerspectiveCamera;
|
|
20
24
|
protected readonly _userInputButtons: any;
|
|
21
25
|
protected readonly _frustumSize = 50;
|
|
22
26
|
protected readonly _navigationModes: Map<NavModeID, NavigationMode>;
|
|
27
|
+
protected _mode: NavigationMode | null;
|
|
23
28
|
private previousSize;
|
|
29
|
+
/**
|
|
30
|
+
* Getter for the current navigation mode.
|
|
31
|
+
* Throws an error if the mode is not found or the camera is not initialized.
|
|
32
|
+
*
|
|
33
|
+
* @returns {NavigationMode} The current navigation mode.
|
|
34
|
+
*
|
|
35
|
+
* @throws {Error} Throws an error if the mode is not found or the camera is not initialized.
|
|
36
|
+
*/
|
|
24
37
|
get mode(): NavigationMode;
|
|
25
38
|
constructor(components: Components);
|
|
26
39
|
/** {@link Disposable.dispose} */
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { NavigationMode } from "./types";
|
|
2
2
|
import { OrthoPerspectiveCamera } from "../index";
|
|
3
3
|
/**
|
|
4
|
-
* A {@link NavigationMode} that allows first person navigation,
|
|
5
|
-
* simulating FPS video games.
|
|
4
|
+
* A {@link NavigationMode} that allows first person navigation, simulating FPS video games.
|
|
6
5
|
*/
|
|
7
6
|
export declare class FirstPersonMode implements NavigationMode {
|
|
8
7
|
private camera;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { NavigationMode } from "./types";
|
|
2
2
|
import { OrthoPerspectiveCamera } from "../index";
|
|
3
3
|
/**
|
|
4
|
-
* A {@link NavigationMode} that allows 3D navigation and panning
|
|
5
|
-
* like in many 3D and CAD softwares.
|
|
4
|
+
* A {@link NavigationMode} that allows 3D navigation and panning like in many 3D and CAD softwares.
|
|
6
5
|
*/
|
|
7
6
|
export declare class OrbitMode implements NavigationMode {
|
|
8
7
|
camera: OrthoPerspectiveCamera;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { NavigationMode } from "./types";
|
|
2
2
|
import { OrthoPerspectiveCamera } from "../index";
|
|
3
3
|
/**
|
|
4
|
-
* A {@link NavigationMode} that allows to navigate floorplans in 2D,
|
|
5
|
-
* like many BIM tools.
|
|
4
|
+
* A {@link NavigationMode} that allows to navigate floorplans in 2D, like many BIM tools.
|
|
6
5
|
*/
|
|
7
6
|
export declare class PlanMode implements NavigationMode {
|
|
8
7
|
private camera;
|
|
@@ -10,12 +10,20 @@ export declare class ProjectionManager {
|
|
|
10
10
|
* Event that fires when the {@link CameraProjection} changes.
|
|
11
11
|
*/
|
|
12
12
|
readonly onChanged: Event<THREE.PerspectiveCamera | THREE.OrthographicCamera>;
|
|
13
|
+
/**
|
|
14
|
+
* Current projection mode of the camera.
|
|
15
|
+
* Default is "Perspective".
|
|
16
|
+
*/
|
|
13
17
|
current: CameraProjection;
|
|
18
|
+
/**
|
|
19
|
+
* The camera controlled by this ProjectionManager.
|
|
20
|
+
* It can be either a PerspectiveCamera or an OrthographicCamera.
|
|
21
|
+
*/
|
|
14
22
|
camera: THREE.PerspectiveCamera | THREE.OrthographicCamera;
|
|
15
|
-
private _component;
|
|
16
|
-
private _previousDistance;
|
|
17
23
|
/** Match Ortho zoom with Perspective distance when changing projection mode */
|
|
18
24
|
matchOrthoDistanceEnabled: boolean;
|
|
25
|
+
private _component;
|
|
26
|
+
private _previousDistance;
|
|
19
27
|
constructor(camera: OrthoPerspectiveCamera);
|
|
20
28
|
/**
|
|
21
29
|
* Sets the {@link CameraProjection} of the {@link OrthoPerspectiveCamera}.
|
|
@@ -7,8 +7,7 @@ export type CameraProjection = "Perspective" | "Orthographic";
|
|
|
7
7
|
*/
|
|
8
8
|
export type NavModeID = "Orbit" | "FirstPerson" | "Plan";
|
|
9
9
|
/**
|
|
10
|
-
* An object that determines the behavior of the camera controls
|
|
11
|
-
* and the user input (e.g. 2D floor plan mode, first person mode, etc).
|
|
10
|
+
* An object that determines the behavior of the camera controls and the user input (e.g. 2D floor plan mode, first person mode, etc).
|
|
12
11
|
*/
|
|
13
12
|
export interface NavigationMode {
|
|
14
13
|
/** The unique ID of this navigation mode. */
|
|
@@ -1,13 +1,42 @@
|
|
|
1
1
|
import { Component, Disposable, World, Event } from "../Types";
|
|
2
2
|
import { SimpleRaycaster } from "./src";
|
|
3
3
|
import { Components } from "../Components";
|
|
4
|
+
/**
|
|
5
|
+
* A component that manages raycasters for different worlds. It uses a Map to store raycasters for each world, and automatically disposes them when the world is disposed.
|
|
6
|
+
*/
|
|
4
7
|
export declare class Raycasters extends Component implements Disposable {
|
|
8
|
+
/**
|
|
9
|
+
* A unique identifier for the component.
|
|
10
|
+
* This UUID is used to register the component within the Components system.
|
|
11
|
+
*/
|
|
5
12
|
static readonly uuid: "d5d8bdf0-db25-4952-b951-b643af207ace";
|
|
13
|
+
/** {@link Component.enabled} */
|
|
6
14
|
enabled: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* A Map that stores raycasters for each world.
|
|
17
|
+
* The key is the world's UUID, and the value is the corresponding SimpleRaycaster instance.
|
|
18
|
+
*/
|
|
7
19
|
list: Map<string, SimpleRaycaster>;
|
|
20
|
+
/** {@link Disposable.onDisposed} */
|
|
8
21
|
onDisposed: Event<unknown>;
|
|
9
22
|
constructor(components: Components);
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves a SimpleRaycaster instance for the given world.
|
|
25
|
+
* If a SimpleRaycaster instance already exists for the world, it will be returned.
|
|
26
|
+
* Otherwise, a new SimpleRaycaster instance will be created and added to the list.
|
|
27
|
+
*
|
|
28
|
+
* @param world - The world for which to retrieve or create a SimpleRaycaster instance.
|
|
29
|
+
* @returns The SimpleRaycaster instance for the given world.
|
|
30
|
+
*/
|
|
10
31
|
get(world: World): SimpleRaycaster;
|
|
32
|
+
/**
|
|
33
|
+
* Deletes the SimpleRaycaster instance associated with the given world.
|
|
34
|
+
* If a SimpleRaycaster instance exists for the given world, it will be disposed and removed from the list.
|
|
35
|
+
*
|
|
36
|
+
* @param world - The world for which to delete the SimpleRaycaster instance.
|
|
37
|
+
* @returns {void}
|
|
38
|
+
*/
|
|
11
39
|
delete(world: World): void;
|
|
40
|
+
/** {@link Disposable.dispose} */
|
|
12
41
|
dispose(): void;
|
|
13
42
|
}
|
|
@@ -10,12 +10,21 @@ import { Mouse } from "./mouse";
|
|
|
10
10
|
export declare class SimpleRaycaster implements Disposable {
|
|
11
11
|
/** {@link Component.enabled} */
|
|
12
12
|
enabled: boolean;
|
|
13
|
+
/** The components instance to which this Raycaster belongs. */
|
|
13
14
|
components: Components;
|
|
14
15
|
/** {@link Disposable.onDisposed} */
|
|
15
16
|
readonly onDisposed: Event<unknown>;
|
|
16
17
|
/** The position of the mouse in the screen. */
|
|
17
18
|
readonly mouse: Mouse;
|
|
19
|
+
/**
|
|
20
|
+
* A reference to the Three.js Raycaster instance.
|
|
21
|
+
* This is used for raycasting operations.
|
|
22
|
+
*/
|
|
18
23
|
readonly three: THREE.Raycaster;
|
|
24
|
+
/**
|
|
25
|
+
* A reference to the world instance to which this Raycaster belongs.
|
|
26
|
+
* This is used to access the camera and meshes.
|
|
27
|
+
*/
|
|
19
28
|
world: World;
|
|
20
29
|
constructor(components: Components, world: World);
|
|
21
30
|
/** {@link Disposable.dispose} */
|
|
@@ -30,6 +39,15 @@ export declare class SimpleRaycaster implements Disposable {
|
|
|
30
39
|
* {@link Components.meshes}.
|
|
31
40
|
*/
|
|
32
41
|
castRay(items?: THREE.Object3D[]): THREE.Intersection | null;
|
|
42
|
+
/**
|
|
43
|
+
* Casts a ray from a given origin in a given direction and returns the first item found.
|
|
44
|
+
* This method also takes into account the clipping planes used by the renderer.
|
|
45
|
+
*
|
|
46
|
+
* @param origin - The origin of the ray.
|
|
47
|
+
* @param direction - The direction of the ray.
|
|
48
|
+
* @param items - The meshes to query. If not provided, it will query all the meshes stored in {@link World.meshes}.
|
|
49
|
+
* @returns The first intersection found or `null` if no intersection was found.
|
|
50
|
+
*/
|
|
33
51
|
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
52
|
private intersect;
|
|
35
53
|
private filterClippingPlanes;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Simple event handler by
|
|
3
|
-
* [Jason Kleban](https://gist.github.com/JasonKleban/50cee44960c225ac1993c922563aa540).
|
|
4
|
-
* Keep in mind that:
|
|
5
|
-
* - If you want to remove it later, you might want to declare the callback as
|
|
6
|
-
* an object.
|
|
7
|
-
* - If you want to maintain the reference to `this`, you will need to declare
|
|
8
|
-
* the callback as an arrow function.
|
|
2
|
+
* Simple event handler by [Jason Kleban](https://gist.github.com/JasonKleban/50cee44960c225ac1993c922563aa540). Keep in mind that if you want to remove it later, you might want to declare the callback as an object. If you want to maintain the reference to `this`, you will need to declare the callback as an arrow function.
|
|
9
3
|
*/
|
|
10
4
|
export declare class AsyncEvent<T> {
|
|
11
5
|
/**
|
|
@@ -2,10 +2,27 @@ import * as THREE from "three";
|
|
|
2
2
|
import CameraControls from "camera-controls";
|
|
3
3
|
import { BaseWorldItem } from "./base-world-item";
|
|
4
4
|
import { CameraControllable } from "./interfaces";
|
|
5
|
+
/**
|
|
6
|
+
* Abstract class representing a camera in the 3D world. All cameras should use this class as a base.
|
|
7
|
+
*/
|
|
5
8
|
export declare abstract class BaseCamera extends BaseWorldItem {
|
|
9
|
+
/**
|
|
10
|
+
* Whether the camera is enabled or not.
|
|
11
|
+
*/
|
|
6
12
|
abstract enabled: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The Three.js camera instance.
|
|
15
|
+
*/
|
|
7
16
|
abstract three: THREE.Camera;
|
|
17
|
+
/**
|
|
18
|
+
* Optional CameraControls instance for controlling the camera.
|
|
19
|
+
* This property is only available if the camera is controllable.
|
|
20
|
+
*/
|
|
8
21
|
abstract controls?: CameraControls;
|
|
9
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Checks whether the instance is {@link CameraControllable}.
|
|
24
|
+
*
|
|
25
|
+
* @returns True if the instance is controllable, false otherwise.
|
|
26
|
+
*/
|
|
10
27
|
hasCameraControls: () => this is CameraControllable;
|
|
11
28
|
}
|
|
@@ -3,7 +3,16 @@ import { Vector2 } from "three";
|
|
|
3
3
|
import { Event } from "./event";
|
|
4
4
|
import { BaseWorldItem } from "./base-world-item";
|
|
5
5
|
import { Disposable, Resizeable, Updateable } from "./interfaces";
|
|
6
|
+
/**
|
|
7
|
+
* Abstract class representing a renderer for a 3D world. All renderers should use this class as a base.
|
|
8
|
+
*/
|
|
6
9
|
export declare abstract class BaseRenderer extends BaseWorldItem implements Updateable, Disposable, Resizeable {
|
|
10
|
+
/**
|
|
11
|
+
* The three.js WebGLRenderer instance associated with this renderer.
|
|
12
|
+
*
|
|
13
|
+
* @abstract
|
|
14
|
+
* @type {THREE.WebGLRenderer}
|
|
15
|
+
*/
|
|
7
16
|
abstract three: THREE.WebGLRenderer;
|
|
8
17
|
/** {@link Updateable.onBeforeUpdate} */
|
|
9
18
|
onAfterUpdate: Event<unknown>;
|
|
@@ -11,30 +20,46 @@ export declare abstract class BaseRenderer extends BaseWorldItem implements Upda
|
|
|
11
20
|
onBeforeUpdate: Event<unknown>;
|
|
12
21
|
/** {@link Disposable.onDisposed} */
|
|
13
22
|
readonly onDisposed: Event<undefined>;
|
|
23
|
+
/** {@link Resizeable.onResize} */
|
|
14
24
|
readonly onResize: Event<THREE.Vector2>;
|
|
15
25
|
/**
|
|
16
26
|
* Event that fires when there has been a change to the list of clipping
|
|
17
27
|
* planes used by the active renderer.
|
|
18
28
|
*/
|
|
19
29
|
readonly onClippingPlanesUpdated: Event<unknown>;
|
|
30
|
+
/** {@link Updateable.update} */
|
|
20
31
|
abstract update(delta?: number): void | Promise<void>;
|
|
32
|
+
/** {@link Disposable.dispose} */
|
|
21
33
|
abstract dispose(): void;
|
|
34
|
+
/** {@link Resizeable.getSize} */
|
|
22
35
|
abstract getSize(): Vector2;
|
|
36
|
+
/** {@link Resizeable.resize} */
|
|
23
37
|
abstract resize(size: Vector2 | undefined): void;
|
|
24
38
|
/**
|
|
25
|
-
* The list of [clipping planes](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.clippingPlanes) used by this
|
|
26
|
-
* instance of the renderer.
|
|
39
|
+
* The list of [clipping planes](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.clippingPlanes) used by this instance of the renderer.
|
|
27
40
|
*/
|
|
28
41
|
clippingPlanes: THREE.Plane[];
|
|
29
42
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
* Updates the clipping planes and triggers the `onClippingPlanesUpdated` event.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* This method is typically called when there is a change to the list of clipping planes
|
|
47
|
+
* used by the active renderer.
|
|
48
|
+
*/
|
|
33
49
|
updateClippingPlanes(): void;
|
|
34
50
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
* Sets or removes a clipping plane from the renderer.
|
|
52
|
+
*
|
|
53
|
+
* @param active - A boolean indicating whether the clipping plane should be active or not.
|
|
54
|
+
* @param plane - The clipping plane to be added or removed.
|
|
55
|
+
* @param isLocal - An optional boolean indicating whether the clipping plane is local to the object. If not provided, it defaults to `false`.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* This method adds or removes a clipping plane from the `clippingPlanes` array.
|
|
59
|
+
* If `active` is `true` and the plane is not already in the array, it is added.
|
|
60
|
+
* If `active` is `false` and the plane is in the array, it is removed.
|
|
61
|
+
* The `three.clippingPlanes` property is then updated to reflect the current state of the `clippingPlanes` array,
|
|
62
|
+
* excluding any planes marked as local.
|
|
63
|
+
*/
|
|
39
64
|
setPlane(active: boolean, plane: THREE.Plane, isLocal?: boolean): void;
|
|
40
65
|
}
|
|
@@ -3,9 +3,16 @@ import { Disposable } from "./interfaces";
|
|
|
3
3
|
import { Event } from "./event";
|
|
4
4
|
import { Components } from "../../Components";
|
|
5
5
|
import { BaseWorldItem } from "./base-world-item";
|
|
6
|
+
/**
|
|
7
|
+
* Abstract class representing a base scene in the application. All scenes should use this class as a base.
|
|
8
|
+
*/
|
|
6
9
|
export declare abstract class BaseScene extends BaseWorldItem implements Disposable {
|
|
7
10
|
/** {@link Disposable.onDisposed} */
|
|
8
11
|
readonly onDisposed: Event<unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Abstract property representing the three.js object associated with this scene.
|
|
14
|
+
* It should be implemented by subclasses.
|
|
15
|
+
*/
|
|
9
16
|
abstract three: THREE.Object3D;
|
|
10
17
|
protected constructor(components: Components);
|
|
11
18
|
/** {@link Disposable.dispose} */
|
|
@@ -3,15 +3,21 @@ import { World } from "./world";
|
|
|
3
3
|
import { Event } from "./event";
|
|
4
4
|
import { Components } from "../../Components";
|
|
5
5
|
/**
|
|
6
|
-
* One of the elements that make a world. It can be either a scene, a camera
|
|
7
|
-
* or a renderer.
|
|
6
|
+
* One of the elements that make a world. It can be either a scene, a camera or a renderer.
|
|
8
7
|
*/
|
|
9
8
|
export declare abstract class BaseWorldItem extends Base {
|
|
10
9
|
readonly worlds: Map<string, World>;
|
|
10
|
+
/**
|
|
11
|
+
* Event that is triggered when a world is added or removed from the `worlds` map.
|
|
12
|
+
* The event payload contains the world instance and the action ("added" or "removed").
|
|
13
|
+
*/
|
|
11
14
|
readonly onWorldChanged: Event<{
|
|
12
15
|
world: World;
|
|
13
16
|
action: "added" | "removed";
|
|
14
17
|
}>;
|
|
18
|
+
/**
|
|
19
|
+
* The current world this item is associated with. It can be null if no world is currently active.
|
|
20
|
+
*/
|
|
15
21
|
currentWorld: World | null;
|
|
16
22
|
protected constructor(components: Components);
|
|
17
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Disposable, Hideable, Resizeable, Updateable, Configurable } from "./interfaces";
|
|
2
2
|
import { Components } from "../../Components";
|
|
3
3
|
/**
|
|
4
|
-
* Base class of the library. Useful for finding out the interfaces
|
|
4
|
+
* Base class of the library. Useful for finding out the interfaces something implements.
|
|
5
5
|
*/
|
|
6
6
|
export declare abstract class Base {
|
|
7
7
|
components: Components;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Base } from "./base";
|
|
2
2
|
/**
|
|
3
|
-
* Components are the building blocks of this library. Components are singleton
|
|
4
|
-
* elements that contain specific functionality. For instance, the SimpleClipper
|
|
5
|
-
* Component can create, delete and handle 3D clipping planes. Components must be
|
|
6
|
-
* unique (they can't be instanced more than once), and have a static UUID that
|
|
7
|
-
* identifies them uniquely. The can be accessed globally using the {@link Components}
|
|
8
|
-
* instance.
|
|
3
|
+
* Components are the building blocks of this library. Components are singleton elements that contain specific functionality. For instance, the Clipper Component can create, delete and handle 3D clipping planes. Components must be unique (they can't be instanced more than once per Components instance), and have a static UUID that identifies them uniquely. The can be accessed globally using the {@link Components} instance.
|
|
9
4
|
*/
|
|
10
5
|
export declare abstract class Component extends Base {
|
|
11
6
|
/**
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Simple event handler by
|
|
3
|
-
* [Jason Kleban](https://gist.github.com/JasonKleban/50cee44960c225ac1993c922563aa540).
|
|
4
|
-
* Keep in mind that:
|
|
5
|
-
* - If you want to remove it later, you might want to declare the callback as
|
|
6
|
-
* an object.
|
|
7
|
-
* - If you want to maintain the reference to `this`, you will need to declare
|
|
8
|
-
* the callback as an arrow function.
|
|
2
|
+
* Simple event handler by [Jason Kleban](https://gist.github.com/JasonKleban/50cee44960c225ac1993c922563aa540). Keep in mind that if you want to remove it later, you might want to declare the callback as an object. If you want to maintain the reference to `this`, you will need to declare the callback as an arrow function.
|
|
9
3
|
*/
|
|
10
4
|
export declare class Event<T> {
|
|
11
5
|
/**
|
|
@@ -2,11 +2,7 @@ import * as THREE from "three";
|
|
|
2
2
|
import CameraControls from "camera-controls";
|
|
3
3
|
import { Event } from "./event";
|
|
4
4
|
/**
|
|
5
|
-
* Whether this component has to be manually destroyed once you are done with
|
|
6
|
-
* it to prevent
|
|
7
|
-
* [memory leaks](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects).
|
|
8
|
-
* This also ensures that the DOM events created by that component will be
|
|
9
|
-
* cleaned up.
|
|
5
|
+
* Whether this component has to be manually destroyed once you are done with it to prevent [memory leaks](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects). This also ensures that the DOM events created by that component will be cleaned up.
|
|
10
6
|
*/
|
|
11
7
|
export interface Disposable {
|
|
12
8
|
/**
|
|
@@ -14,13 +10,11 @@ export interface Disposable {
|
|
|
14
10
|
* [memory leak](https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects).
|
|
15
11
|
*/
|
|
16
12
|
dispose: () => void | Promise<void>;
|
|
17
|
-
/** Fired after the tool has been
|
|
13
|
+
/** Fired after the tool has been disposed. */
|
|
18
14
|
readonly onDisposed: Event<any>;
|
|
19
15
|
}
|
|
20
16
|
/**
|
|
21
|
-
* Whether the geometric representation of this component can be
|
|
22
|
-
* hidden or shown in the
|
|
23
|
-
* [Three.js scene](https://threejs.org/docs/#api/en/scenes/Scene).
|
|
17
|
+
* Whether the geometric representation of this component can be hidden or shown in the [Three.js scene](https://threejs.org/docs/#api/en/scenes/Scene).
|
|
24
18
|
*/
|
|
25
19
|
export interface Hideable {
|
|
26
20
|
/**
|
|
@@ -31,11 +25,7 @@ export interface Hideable {
|
|
|
31
25
|
visible: boolean;
|
|
32
26
|
}
|
|
33
27
|
/**
|
|
34
|
-
* Whether this component can be resized. The meaning of this can vary depending
|
|
35
|
-
* on the component: resizing a
|
|
36
|
-
* [Renderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer)
|
|
37
|
-
* component could mean changing its resolution, whereas resizing a
|
|
38
|
-
* [Mesh](https://threejs.org/docs/#api/en/objects/Mesh) would change its scale.
|
|
28
|
+
* Whether this component can be resized. The meaning of this can vary depending on the component: resizing a [Renderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer) component could mean changing its resolution, whereas resizing a [Mesh](https://threejs.org/docs/#api/en/objects/Mesh) would change its scale.
|
|
39
29
|
*/
|
|
40
30
|
export interface Resizeable {
|
|
41
31
|
/**
|
|
@@ -73,9 +63,7 @@ export interface Progress {
|
|
|
73
63
|
total: number;
|
|
74
64
|
}
|
|
75
65
|
/**
|
|
76
|
-
* Whether this component supports create and destroy operations. This generally
|
|
77
|
-
* applies for components that work with instances, such as clipping planes or
|
|
78
|
-
* dimensions.
|
|
66
|
+
* Whether this component supports create and destroy operations. This generally applies for components that work with instances, such as clipping planes or dimensions.
|
|
79
67
|
*/
|
|
80
68
|
export interface Createable {
|
|
81
69
|
/** Creates a new instance of an element (e.g. a new Dimension). */
|
|
@@ -108,16 +96,13 @@ export interface Configurable<T extends Record<string, any>> {
|
|
|
108
96
|
*/
|
|
109
97
|
config: Required<T>;
|
|
110
98
|
}
|
|
111
|
-
/**
|
|
112
|
-
* An interface to make [three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh) compatible with typescript.
|
|
113
|
-
*/
|
|
114
|
-
export interface BVHGeometry extends THREE.BufferGeometry {
|
|
115
|
-
boundsTree: Object | undefined;
|
|
116
|
-
disposeBoundsTree: () => void;
|
|
117
|
-
}
|
|
118
99
|
/**
|
|
119
100
|
* Whether a camera uses the Camera Controls library.
|
|
120
101
|
*/
|
|
121
102
|
export interface CameraControllable {
|
|
103
|
+
/**
|
|
104
|
+
* An instance of CameraControls that provides camera control functionalities.
|
|
105
|
+
* This instance is used to manipulate the camera.
|
|
106
|
+
*/
|
|
122
107
|
controls: CameraControls;
|
|
123
108
|
}
|
|
@@ -3,11 +3,32 @@ import { BaseScene } from "./base-scene";
|
|
|
3
3
|
import { BaseCamera } from "./base-camera";
|
|
4
4
|
import { BaseRenderer } from "./base-renderer";
|
|
5
5
|
import { Updateable, Disposable } from "./interfaces";
|
|
6
|
+
/**
|
|
7
|
+
* Represents a 3D world with meshes, scene, camera, renderer, and other properties.
|
|
8
|
+
*/
|
|
6
9
|
export interface World extends Disposable, Updateable {
|
|
10
|
+
/**
|
|
11
|
+
* A set of meshes present in the world. This is taken into account for operations like raycasting.
|
|
12
|
+
*/
|
|
7
13
|
meshes: Set<THREE.Mesh>;
|
|
14
|
+
/**
|
|
15
|
+
* The base scene of the world.
|
|
16
|
+
*/
|
|
8
17
|
scene: BaseScene;
|
|
18
|
+
/**
|
|
19
|
+
* The base camera of the world.
|
|
20
|
+
*/
|
|
9
21
|
camera: BaseCamera;
|
|
22
|
+
/**
|
|
23
|
+
* The base renderer of the world. Can be null if this world doesn't use a renderer (e.g. in a backend environment).
|
|
24
|
+
*/
|
|
10
25
|
renderer: BaseRenderer | null;
|
|
26
|
+
/**
|
|
27
|
+
* A unique identifier for the world.
|
|
28
|
+
*/
|
|
11
29
|
uuid: string;
|
|
30
|
+
/**
|
|
31
|
+
* Indicates whether the world is currently disposing. This is useful for cancelling logic that access the elements of a world (which are also disposed).
|
|
32
|
+
*/
|
|
12
33
|
isDisposing: boolean;
|
|
13
34
|
}
|
|
@@ -2,38 +2,37 @@ import { Component, Disposable, Updateable, World, Event, BaseScene, BaseCamera,
|
|
|
2
2
|
import { Components } from "../Components";
|
|
3
3
|
import { SimpleWorld } from "./src";
|
|
4
4
|
export * from "./src";
|
|
5
|
+
/**
|
|
6
|
+
* A class representing a collection of worlds within a game engine. It manages the creation, deletion, and update of worlds.
|
|
7
|
+
*/
|
|
5
8
|
export declare class Worlds extends Component implements Updateable, Disposable {
|
|
6
9
|
/**
|
|
7
10
|
* A unique identifier for the component.
|
|
8
11
|
* This UUID is used to register the component within the Components system.
|
|
9
12
|
*/
|
|
10
13
|
static readonly uuid: "fdb61dc4-2ec1-4966-b83d-54ea795fad4a";
|
|
11
|
-
/**
|
|
12
|
-
* Event triggered after the update process of all worlds.
|
|
13
|
-
* Subscribers can listen to this event to perform actions post-update.
|
|
14
|
-
*/
|
|
14
|
+
/** {@link Updateable.onAfterUpdate} */
|
|
15
15
|
readonly onAfterUpdate: Event<unknown>;
|
|
16
|
-
/**
|
|
17
|
-
* Event triggered before the update process of all worlds.
|
|
18
|
-
* Subscribers can listen to this event to perform actions pre-update.
|
|
19
|
-
*/
|
|
16
|
+
/** {@link Updateable.onBeforeUpdate} */
|
|
20
17
|
readonly onBeforeUpdate: Event<unknown>;
|
|
18
|
+
/** {@link Disposable.onDisposed} */
|
|
19
|
+
readonly onDisposed: Event<unknown>;
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* An event that is triggered when a new world is created.
|
|
22
|
+
* The event passes the newly created world as a parameter.
|
|
24
23
|
*/
|
|
25
|
-
readonly onDisposed: Event<unknown>;
|
|
26
24
|
readonly onWorldCreated: Event<World>;
|
|
25
|
+
/**
|
|
26
|
+
* An event that is triggered when a world is deleted.
|
|
27
|
+
* The event passes the UUID of the deleted world as a parameter.
|
|
28
|
+
*/
|
|
27
29
|
readonly onWorldDeleted: Event<string>;
|
|
28
30
|
/**
|
|
29
31
|
* A collection of worlds managed by this component.
|
|
30
32
|
* The key is the unique identifier (UUID) of the world, and the value is the World instance.
|
|
31
33
|
*/
|
|
32
34
|
list: Map<string, World>;
|
|
33
|
-
/**
|
|
34
|
-
* A flag indicating whether the Worlds component is enabled.
|
|
35
|
-
* If false, the update process will be skipped.
|
|
36
|
-
*/
|
|
35
|
+
/** {@link Component.enabled} */
|
|
37
36
|
enabled: boolean;
|
|
38
37
|
constructor(components: Components);
|
|
39
38
|
/**
|
|
@@ -46,7 +45,24 @@ export declare class Worlds extends Component implements Updateable, Disposable
|
|
|
46
45
|
* @throws {Error} - Throws an error if a world with the same UUID already exists in the list.
|
|
47
46
|
*/
|
|
48
47
|
create<T extends BaseScene = BaseScene, U extends BaseCamera = BaseCamera, S extends BaseRenderer = BaseRenderer>(): SimpleWorld<T, U, S>;
|
|
48
|
+
/**
|
|
49
|
+
* Deletes a world from the list of worlds.
|
|
50
|
+
*
|
|
51
|
+
* @param {World} world - The world to be deleted.
|
|
52
|
+
*
|
|
53
|
+
* @throws {Error} - Throws an error if the provided world is not found in the list.
|
|
54
|
+
*
|
|
55
|
+
* @returns {void}
|
|
56
|
+
*/
|
|
49
57
|
delete(world: World): void;
|
|
58
|
+
/**
|
|
59
|
+
* Disposes of the Worlds component and all its managed worlds.
|
|
60
|
+
* This method sets the enabled flag to false, disposes of all worlds, clears the list,
|
|
61
|
+
* and triggers the onDisposed event.
|
|
62
|
+
*
|
|
63
|
+
* @returns {void}
|
|
64
|
+
*/
|
|
50
65
|
dispose(): void;
|
|
66
|
+
/** {@link Updateable.update} */
|
|
51
67
|
update(delta?: number): void | Promise<void>;
|
|
52
68
|
}
|
|
@@ -3,19 +3,24 @@ import CameraControls from "camera-controls";
|
|
|
3
3
|
import { Disposable, Updateable, Event, BaseCamera } from "../../Types";
|
|
4
4
|
import { Components } from "../../Components";
|
|
5
5
|
/**
|
|
6
|
-
* A basic camera that uses
|
|
7
|
-
* [yomotsu's cameracontrols](https://github.com/yomotsu/camera-controls) to
|
|
8
|
-
* easily control the camera in 2D and 3D. Check out it's API to find out
|
|
9
|
-
* what features it offers.
|
|
6
|
+
* A basic camera that uses [yomotsu's cameracontrols](https://github.com/yomotsu/camera-controls) to easily control the camera in 2D and 3D. Check out it's API to find out what features it offers.
|
|
10
7
|
*/
|
|
11
8
|
export declare class SimpleCamera extends BaseCamera implements Updateable, Disposable {
|
|
12
9
|
/** {@link Updateable.onBeforeUpdate} */
|
|
13
10
|
readonly onBeforeUpdate: Event<SimpleCamera>;
|
|
14
11
|
/** {@link Updateable.onAfterUpdate} */
|
|
15
12
|
readonly onAfterUpdate: Event<SimpleCamera>;
|
|
13
|
+
/**
|
|
14
|
+
* Event that is triggered when the aspect of the camera has been updated.
|
|
15
|
+
* This event is useful when you need to perform actions after the aspect of the camera has been changed.
|
|
16
|
+
*/
|
|
16
17
|
readonly onAspectUpdated: Event<unknown>;
|
|
17
18
|
/** {@link Disposable.onDisposed} */
|
|
18
19
|
readonly onDisposed: Event<string>;
|
|
20
|
+
/**
|
|
21
|
+
* A three.js PerspectiveCamera or OrthographicCamera instance.
|
|
22
|
+
* This camera is used for rendering the scene.
|
|
23
|
+
*/
|
|
19
24
|
three: THREE.PerspectiveCamera | THREE.OrthographicCamera;
|
|
20
25
|
private _allControls;
|
|
21
26
|
/**
|
|
@@ -25,9 +30,20 @@ export declare class SimpleCamera extends BaseCamera implements Updateable, Disp
|
|
|
25
30
|
* object to move, rotate, look at objects, etc.
|
|
26
31
|
*/
|
|
27
32
|
get controls(): CameraControls;
|
|
28
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Getter for the enabled state of the camera controls.
|
|
35
|
+
* If the current world is null, it returns false.
|
|
36
|
+
* Otherwise, it returns the enabled state of the camera controls.
|
|
37
|
+
*
|
|
38
|
+
* @returns {boolean} The enabled state of the camera controls.
|
|
39
|
+
*/
|
|
29
40
|
get enabled(): boolean;
|
|
30
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Setter for the enabled state of the camera controls.
|
|
43
|
+
* If the current world is not null, it sets the enabled state of the camera controls to the provided value.
|
|
44
|
+
*
|
|
45
|
+
* @param {boolean} enabled - The new enabled state of the camera controls.
|
|
46
|
+
*/
|
|
31
47
|
set enabled(enabled: boolean);
|
|
32
48
|
constructor(components: Components);
|
|
33
49
|
/** {@link Disposable.dispose} */
|