@shopware-ag/dive 3.0.11 → 4.0.0
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/README.md +31 -5
- package/build/chunks/{AssetCache-MtISiPD2.cjs → AssetCache-DdxevusY.cjs} +1 -1
- package/build/chunks/{AssetCache-DOB996Vk.mjs → AssetCache-MXFCGzZU.mjs} +1 -1
- package/build/chunks/AssetExporter-CD2iuQce.mjs +108 -0
- package/build/chunks/AssetExporter-CoL-QXkB.cjs +1 -0
- package/build/chunks/{AssetLoader-B1n3KGOu.cjs → AssetLoader-BDDJG9JL.cjs} +2 -2
- package/build/chunks/{AssetLoader-BY5D3Cvc.mjs → AssetLoader-kRhuVN4p.mjs} +12 -21
- package/build/chunks/FileTypes-DGSsi-AX.mjs +2294 -0
- package/build/chunks/FileTypes-gD_1MonW.cjs +29 -0
- package/build/chunks/ModelComponent-Cj3ff6nL.cjs +1 -0
- package/build/chunks/ModelComponent-DkfAgTL0.mjs +87 -0
- package/build/chunks/OrbitController-DFPcXvlO.cjs +1 -0
- package/build/chunks/OrbitController-DLEyTvUt.mjs +612 -0
- package/build/chunks/SpriteTextComponent-ByefJLeU.cjs +1 -0
- package/build/chunks/SpriteTextComponent-CG5vfiFy.mjs +83 -0
- package/build/chunks/collectAnimations-BgYCN1le.mjs +35 -0
- package/build/chunks/collectAnimations-C3HfZHte.cjs +1 -0
- package/build/chunks/contributesToBounds-C1mva__U.cjs +1 -0
- package/build/chunks/contributesToBounds-DYmHYES4.mjs +14 -0
- package/build/chunks/detachTransformControls-2XQrpLN-.cjs +1 -0
- package/build/chunks/detachTransformControls-Dr3TIdVy.mjs +209 -0
- package/build/chunks/{isFileTypeSupported-C-hfGk-7.mjs → isFileExtensionSupported-CgcqpgqN.mjs} +1 -1
- package/build/chunks/{isFileTypeSupported-xoGjHFuz.cjs → isFileExtensionSupported-RvlnH2dr.cjs} +1 -1
- package/build/chunks/isVisibleInHierarchy-D9JcLqR5.cjs +1 -0
- package/build/chunks/isVisibleInHierarchy-KzVGvDEw.mjs +21 -0
- package/build/components/boundingbox/BoundingBoxComponent.d.ts +100 -0
- package/build/components/boundingbox/index.d.ts +1 -0
- package/build/components/camera/CameraComponent.d.ts +75 -0
- package/build/components/camera/index.d.ts +2 -0
- package/build/components/camera/perspective/PerspectiveCameraComponent.d.ts +39 -0
- package/build/components/grid/GridComponent.d.ts +50 -0
- package/build/components/index.d.ts +6 -9
- package/build/components/light/LightComponent.d.ts +65 -0
- package/build/components/light/ambient/AmbientLightComponent.d.ts +10 -0
- package/build/components/light/directional/DirectionalLightComponent.d.ts +23 -0
- package/build/components/light/hemi/HemisphereLightComponent.d.ts +21 -0
- package/build/components/light/index.d.ts +5 -3
- package/build/components/light/point/PointLightComponent.d.ts +26 -0
- package/build/components/line/MultiLineComponent.d.ts +133 -0
- package/build/components/line/index.d.ts +1 -0
- package/build/components/mesh/MeshComponent.d.ts +74 -0
- package/build/components/mesh/floor/FloorComponent.d.ts +36 -0
- package/build/components/mesh/index.d.ts +4 -0
- package/build/components/mesh/model/ModelComponent.d.ts +67 -0
- package/build/components/mesh/primitive/PrimitiveComponent.d.ts +43 -0
- package/build/components/spritetext/SpriteTextComponent.d.ts +58 -0
- package/build/constants/VisibilityLayerMask.d.ts +23 -0
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +252 -774
- package/build/engine/Dive.d.ts +17 -13
- package/build/engine/boundingbox/BoundingBox.d.ts +76 -0
- package/build/engine/component/Component.d.ts +236 -0
- package/build/engine/environment/Environment.d.ts +8 -18
- package/build/engine/index.d.ts +4 -1
- package/build/engine/node/Node.d.ts +189 -0
- package/build/engine/promise/abortable/AbortablePromise.d.ts +8 -0
- package/build/engine/renderer/Renderer.d.ts +43 -7
- package/build/engine/scene/Scene.d.ts +88 -4
- package/build/engine/scene/root/Root.d.ts +29 -0
- package/build/engine/scene/xrroot/XRRoot.d.ts +1 -1
- package/build/engine/view/View.d.ts +15 -4
- package/build/helpers/collectAnimations/collectAnimations.d.ts +23 -0
- package/build/helpers/computeProductBounds/computeProductBounds.d.ts +18 -0
- package/build/helpers/contributesToBounds/contributesToBounds.d.ts +17 -0
- package/build/helpers/detachTransformControls/detachTransformControls.d.ts +15 -0
- package/build/helpers/disposeComponents/disposeComponents.d.ts +20 -0
- package/build/helpers/findSceneRecursive/findSceneRecursive.d.ts +7 -3
- package/build/helpers/implementsInterface/implementsInterface.d.ts +11 -0
- package/build/helpers/index.d.ts +6 -1
- package/build/helpers/isVisibleInHierarchy/isVisibleInHierarchy.d.ts +12 -0
- package/build/index.d.ts +0 -1
- package/build/plugins/animation/index.mjs +3 -2
- package/build/plugins/animation/src/system/AnimationSystem.d.ts +3 -2
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +2 -2
- package/build/plugins/ar/src/webxr/WebXR.d.ts +7 -0
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetexporter/index.cjs +1 -1
- package/build/plugins/assetexporter/index.mjs +1 -1
- package/build/plugins/assetexporter/src/AssetExporter.d.ts +12 -0
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +2 -2
- package/build/plugins/mediacreator/index.cjs +1 -1
- package/build/plugins/mediacreator/index.mjs +32 -30
- package/build/plugins/mediacreator/src/MediaCreator.d.ts +1 -2
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.d.ts +1 -0
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orbitcontroller/src/OrbitController.d.ts +39 -6
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +41 -33
- package/build/plugins/orientationdisplay/src/OrientationDisplay.d.ts +3 -3
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +71 -19
- package/build/plugins/quickview/src/QuickView.d.ts +40 -8
- package/build/plugins/quickview/types/QuickViewSettings.d.ts +14 -0
- package/build/plugins/state/index.cjs +1 -27
- package/build/plugins/state/index.mjs +2031 -4135
- package/build/plugins/state/src/EngineGateway.d.ts +98 -0
- package/build/plugins/state/src/EntityRegistry.d.ts +51 -0
- package/build/plugins/state/src/State.d.ts +20 -9
- package/build/plugins/state/src/actions/camera/computeencompassingview.d.ts +1 -1
- package/build/plugins/state/src/actions/camera/movecamera.d.ts +2 -2
- package/build/plugins/state/src/actions/index.d.ts +1 -0
- package/build/plugins/state/src/actions/media/generatemedia.d.ts +1 -1
- package/build/plugins/state/src/actions/object/addobject.d.ts +2 -3
- package/build/plugins/state/src/actions/object/deleteobject.d.ts +3 -4
- package/build/plugins/state/src/actions/object/deselectobject.d.ts +3 -4
- package/build/plugins/state/src/actions/object/dropit.d.ts +2 -2
- package/build/plugins/state/src/actions/object/getallobjects.d.ts +2 -3
- package/build/plugins/state/src/actions/object/getobjects.d.ts +3 -4
- package/build/plugins/state/src/actions/object/index.d.ts +0 -1
- package/build/plugins/state/src/actions/object/modelloaded.d.ts +2 -2
- package/build/plugins/state/src/actions/object/selectobject.d.ts +3 -4
- package/build/plugins/state/src/actions/object/setparent.d.ts +3 -4
- package/build/plugins/state/src/actions/object/updateobject.d.ts +3 -4
- package/build/plugins/state/src/actions/renderer/startrender.d.ts +1 -1
- package/build/plugins/state/src/actions/scene/exportscene.d.ts +2 -2
- package/build/plugins/state/src/actions/scene/index.d.ts +0 -1
- package/build/plugins/state/src/actions/scene/setbackground.d.ts +2 -2
- package/build/plugins/state/src/actions/scene/updatescene.d.ts +2 -2
- package/build/plugins/state/src/actions/state/getstate.d.ts +8 -0
- package/build/plugins/state/src/actions/state/index.d.ts +2 -0
- package/build/plugins/state/src/actions/state/setstate.d.ts +8 -0
- package/build/plugins/state/src/helpers/copyVectors/copyVectors.d.ts +17 -0
- package/build/plugins/state/src/helpers/updateParentLink/updateParentLink.d.ts +29 -0
- package/build/plugins/state/src/helpers/watchEntity/watchEntity.d.ts +30 -0
- package/build/plugins/state/types/ActionTypes.d.ts +18 -3
- package/build/plugins/state/types/RegisteredEntity.d.ts +27 -0
- package/build/plugins/state/types/{StateSceneData.d.ts → StateData.d.ts} +7 -8
- package/build/plugins/state/types/index.d.ts +3 -1
- package/build/plugins/state/types/schema/BaseEntitySchema.d.ts +25 -0
- package/build/plugins/state/types/schema/CameraSchema.d.ts +18 -0
- package/build/plugins/state/types/schema/EntitySchema.d.ts +21 -0
- package/build/plugins/state/types/schema/EntityTypeSchema.d.ts +9 -0
- package/build/{types → plugins/state/types}/schema/GroupSchema.d.ts +8 -1
- package/build/{types → plugins/state/types}/schema/LightSchema.d.ts +16 -0
- package/build/plugins/state/types/schema/ModelSchema.d.ts +33 -0
- package/build/{types → plugins/state/types}/schema/PrimitiveSchema.d.ts +8 -4
- package/build/{types → plugins/state/types}/schema/index.d.ts +1 -4
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +194 -150
- package/build/plugins/toolbox/src/PointerContext.d.ts +7 -0
- package/build/plugins/toolbox/src/SelectionState.d.ts +21 -0
- package/build/plugins/toolbox/src/Toolbox.d.ts +9 -2
- package/build/{components → plugins/toolbox/src}/gizmo/Gizmo.d.ts +16 -2
- package/build/{components → plugins/toolbox/src}/gizmo/handles/AxisHandle.d.ts +2 -3
- package/build/{components → plugins/toolbox/src}/gizmo/handles/RadialHandle.d.ts +2 -3
- package/build/{components → plugins/toolbox/src}/gizmo/handles/ScaleHandle.d.ts +2 -3
- package/build/{components → plugins/toolbox/src}/gizmo/rotate/RotateGizmo.d.ts +2 -2
- package/build/{components → plugins/toolbox/src}/gizmo/scale/ScaleGizmo.d.ts +3 -3
- package/build/{components → plugins/toolbox/src}/gizmo/translate/TranslateGizmo.d.ts +2 -2
- package/build/types/components/DIVESceneObject.d.ts +13 -6
- package/build/types/components/index.d.ts +0 -1
- package/build/types/events/DIVEComponentEventMap.d.ts +14 -0
- package/build/types/events/DIVEEntityEventMap.d.ts +47 -0
- package/build/types/events/index.d.ts +2 -0
- package/build/types/geometry/DIVEGeometry.d.ts +16 -0
- package/build/types/geometry/DIVEGeometryType.d.ts +7 -0
- package/build/types/geometry/index.d.ts +2 -0
- package/build/types/index.d.ts +3 -1
- package/build/types/material/DIVEMaterial.d.ts +21 -0
- package/build/types/material/index.d.ts +1 -0
- package/package.json +8 -9
- package/build/chunks/AssetExporter-Cdxb04b3.cjs +0 -1
- package/build/chunks/AssetExporter-DLL_vJae.mjs +0 -67
- package/build/chunks/FileTypes-DMTSUCcK.cjs +0 -29
- package/build/chunks/FileTypes-DYtXCJQV.mjs +0 -2141
- package/build/chunks/PerspectiveCamera-B5TvUzTa.mjs +0 -39
- package/build/chunks/PerspectiveCamera-DwQUmkDv.cjs +0 -1
- package/build/chunks/PovSchema-Co9FznEz.cjs +0 -1
- package/build/chunks/PovSchema-DWWvr_ED.mjs +0 -10
- package/build/chunks/findInterface-C6mrvf_t.cjs +0 -1
- package/build/chunks/findInterface-DbJ5qzbc.mjs +0 -11
- package/build/components/boundingbox/BoundingBox.d.ts +0 -136
- package/build/components/floor/Floor.d.ts +0 -14
- package/build/components/grid/Grid.d.ts +0 -23
- package/build/components/group/Group.d.ts +0 -28
- package/build/components/light/AmbientLight.d.ts +0 -19
- package/build/components/light/PointLight.d.ts +0 -29
- package/build/components/light/SceneLight.d.ts +0 -20
- package/build/components/model/Model.d.ts +0 -26
- package/build/components/node/Node.d.ts +0 -24
- package/build/components/primitive/Primitive.d.ts +0 -27
- package/build/components/root/Root.d.ts +0 -34
- package/build/engine/camera/PerspectiveCamera.d.ts +0 -24
- package/build/helpers/isFileTypeSupported/isFileTypeSupported.d.ts +0 -9
- package/build/plugins/state/src/actions/object/placeonfloor.d.ts +0 -12
- package/build/plugins/state/src/actions/scene/getallscenedata.d.ts +0 -9
- package/build/types/components/DIVELight.d.ts +0 -4
- package/build/types/schema/BaseEntitySchema.d.ts +0 -8
- package/build/types/schema/EntitySchema.d.ts +0 -11
- package/build/types/schema/EntityTypeSchema.d.ts +0 -1
- package/build/types/schema/GeometrySchema.d.ts +0 -7
- package/build/types/schema/GeometryTypeSchema.d.ts +0 -1
- package/build/types/schema/MaterialSchema.d.ts +0 -11
- package/build/types/schema/ModelSchema.d.ts +0 -14
- package/build/types/schema/PovSchema.d.ts +0 -10
- /package/build/{components → plugins/toolbox/src}/gizmo/plane/GizmoPlane.d.ts +0 -0
package/build/engine/Dive.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { DIVEClock } from './clock/Clock.ts';
|
|
2
2
|
import { DIVEView } from './view/View.ts';
|
|
3
3
|
import { DIVEScene, DIVESceneSettings } from './scene/Scene.ts';
|
|
4
|
-
import { DIVEPerspectiveCameraSettings } from '
|
|
4
|
+
import { DIVEPerspectiveCameraSettings } from '../components/camera/perspective/PerspectiveCameraComponent.ts';
|
|
5
5
|
import { DIVERendererSettings } from './renderer/Renderer.ts';
|
|
6
|
-
import { OrbitControllerSettings } from '../plugins/orbitcontroller/index.ts';
|
|
7
6
|
declare global {
|
|
8
7
|
interface Window {
|
|
9
8
|
DIVE: {
|
|
@@ -15,6 +14,12 @@ declare global {
|
|
|
15
14
|
* Get the first instance of DIVE
|
|
16
15
|
*/
|
|
17
16
|
get instance(): DIVE | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Maximum amount of DIVE instances that can be created. This is checked on initialization of a new instance.
|
|
19
|
+
*
|
|
20
|
+
* You can change this value to allow more instances, but be aware that this can lead to performance issues and crashes.
|
|
21
|
+
*/
|
|
22
|
+
instanceLimit: number;
|
|
18
23
|
};
|
|
19
24
|
}
|
|
20
25
|
}
|
|
@@ -31,13 +36,13 @@ export type DIVESettings = {
|
|
|
31
36
|
* @default false
|
|
32
37
|
*/
|
|
33
38
|
displayAxes: boolean;
|
|
34
|
-
} & DIVESceneSettings & DIVEPerspectiveCameraSettings & DIVERendererSettings
|
|
39
|
+
} & DIVESceneSettings & DIVEPerspectiveCameraSettings & DIVERendererSettings;
|
|
35
40
|
export declare const DIVEDefaultSettings: Required<DIVESettings>;
|
|
36
41
|
/**
|
|
37
42
|
* #### DIVE
|
|
38
43
|
* is the main class of the DIVE framework.
|
|
39
44
|
*
|
|
40
|
-
* An instance of this class delivers a complete 3D environment with a perspective camera
|
|
45
|
+
* An instance of this class delivers a complete 3D environment with a perspective camera and orbit controls.
|
|
41
46
|
* ```ts
|
|
42
47
|
* import { DIVE } from "@shopware-ag/dive";
|
|
43
48
|
*
|
|
@@ -45,13 +50,16 @@ export declare const DIVEDefaultSettings: Required<DIVESettings>;
|
|
|
45
50
|
*
|
|
46
51
|
* const dive = new DIVE();
|
|
47
52
|
*
|
|
48
|
-
* myWrapper.appendChild(dive.
|
|
53
|
+
* myWrapper.appendChild(dive.canvas);
|
|
54
|
+
* ```
|
|
49
55
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
56
|
+
* Driving a scene from data is the job of the state plugin, which wraps a
|
|
57
|
+
* DIVE instance rather than being part of it:
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { State } from "@shopware-ag/dive/state";
|
|
53
60
|
*
|
|
54
|
-
* dive
|
|
61
|
+
* const state = new State(dive, orbitController);
|
|
62
|
+
* await state.performAction('SET_STATE', sceneData);
|
|
55
63
|
* ```
|
|
56
64
|
* @module
|
|
57
65
|
*/
|
|
@@ -70,10 +78,6 @@ export declare class DIVE {
|
|
|
70
78
|
get canvas(): HTMLCanvasElement;
|
|
71
79
|
get scene(): DIVEScene;
|
|
72
80
|
get clock(): DIVEClock;
|
|
73
|
-
/**
|
|
74
|
-
* @deprecated Use startAsync() instead, which returns a promise that resolves when the engine is fully initialized.
|
|
75
|
-
*/
|
|
76
|
-
start(): void;
|
|
77
81
|
startAsync(): Promise<void>;
|
|
78
82
|
stop(): void;
|
|
79
83
|
disposeAsync(): Promise<void>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Box3, Matrix4, Sphere, Vector3, Object3D } from 'three/webgpu';
|
|
2
|
+
/**
|
|
3
|
+
* The box that encloses a set of objects.
|
|
4
|
+
*
|
|
5
|
+
* A measurement and nothing else: no place in the scene graph, no owner, no
|
|
6
|
+
* visualisation. {@link BoundingBoxComponent} is what gives a node one of these
|
|
7
|
+
* and keeps it current; anything that just needs the numbers builds one here.
|
|
8
|
+
*
|
|
9
|
+
* Two shapes:
|
|
10
|
+
*
|
|
11
|
+
* - {@link enclose} is axis-aligned in world space. What camera framing wants,
|
|
12
|
+
* and what `size` means for a whole scene.
|
|
13
|
+
* - {@link encloseOriented} is axis-aligned in a frame that carries another
|
|
14
|
+
* object's position and rotation but not its scale. The box hugs a turned
|
|
15
|
+
* object instead of enclosing its world projection, and `size` becomes the
|
|
16
|
+
* object's own width, height and depth in world units. A 2 x 1 x 1 object
|
|
17
|
+
* turned 45 degrees measures 2 x 1 x 1 oriented and 2.121 x 1 x 2.121
|
|
18
|
+
* world-aligned.
|
|
19
|
+
*
|
|
20
|
+
* `center` and `sphere` are in world space either way, so code that frames a
|
|
21
|
+
* camera never has to ask which shape it was handed. Only `box` and `size` live
|
|
22
|
+
* in the measured frame, and {@link frame} is how they get to the world.
|
|
23
|
+
*
|
|
24
|
+
* Reused rather than rebuilt: enclosing again overwrites what is there, so a
|
|
25
|
+
* caller that measures repeatedly allocates once.
|
|
26
|
+
*
|
|
27
|
+
* Only geometry that {@link computeProductBounds} counts as real is measured, so
|
|
28
|
+
* helpers, the ground plane and gizmo handles never widen a box.
|
|
29
|
+
*
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
export declare class BoundingBox {
|
|
33
|
+
readonly isBoundingBox: true;
|
|
34
|
+
private _box;
|
|
35
|
+
private _sphere;
|
|
36
|
+
private _center;
|
|
37
|
+
private _size;
|
|
38
|
+
private _frame;
|
|
39
|
+
private _oriented;
|
|
40
|
+
/** The box itself, in the frame it was measured in. */
|
|
41
|
+
get box(): Box3;
|
|
42
|
+
/** Width, height and depth, in the frame the box was measured in. */
|
|
43
|
+
get size(): Vector3;
|
|
44
|
+
/** The centre of the box, in world space. */
|
|
45
|
+
get center(): Vector3;
|
|
46
|
+
/** The sphere around the box, in world space. */
|
|
47
|
+
get sphere(): Sphere;
|
|
48
|
+
/** The radius of that sphere. */
|
|
49
|
+
get radius(): number;
|
|
50
|
+
/** How the measured frame relates to the world. Identity when world-aligned. */
|
|
51
|
+
get frame(): Matrix4;
|
|
52
|
+
/** Whether anything was found to measure. */
|
|
53
|
+
get isEmpty(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Measures a world-aligned box around everything given.
|
|
56
|
+
*
|
|
57
|
+
* @param objects - What to enclose, with everything below it.
|
|
58
|
+
*/
|
|
59
|
+
enclose(objects: Object3D | readonly Object3D[]): this;
|
|
60
|
+
/**
|
|
61
|
+
* Measures a box aligned to another object's axes.
|
|
62
|
+
*
|
|
63
|
+
* @param objects - What to enclose, with everything below it.
|
|
64
|
+
* @param frame - Whose axes to align to. Its position and rotation are taken,
|
|
65
|
+
* its scale is not: the scale belongs in the extents, or `size` would report
|
|
66
|
+
* the geometry's own numbers rather than the size in the scene.
|
|
67
|
+
*/
|
|
68
|
+
encloseOriented(objects: Object3D | readonly Object3D[], frame: Object3D): this;
|
|
69
|
+
/** Empties the box, for when there is nothing to measure. */
|
|
70
|
+
clear(): this;
|
|
71
|
+
private _measure;
|
|
72
|
+
/** Turns the measured box into the world-space figures. */
|
|
73
|
+
private _derive;
|
|
74
|
+
/** The distance from the world centre to the furthest corner. */
|
|
75
|
+
private _worldRadius;
|
|
76
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { EventDispatcher, Object3D } from 'three/webgpu';
|
|
2
|
+
import { DIVENode } from '../node/Node.ts';
|
|
3
|
+
import { DIVEComponentEventMap } from '../../types/events/DIVEComponentEventMap.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Base class for everything that gives a node a capability: geometry, a light,
|
|
6
|
+
* a label, a helper visualisation, per-frame behaviour.
|
|
7
|
+
*
|
|
8
|
+
* A component is **not** part of the scene graph. What it owns is: three rebuilds
|
|
9
|
+
* its render list by walking the graph every single frame, so a mesh or a light
|
|
10
|
+
* has to be in `children` to be drawn -- but it goes into the *node's* children,
|
|
11
|
+
* through {@link contribute}. The component itself stays out, because an exporter
|
|
12
|
+
* writes a node for everything it walks, so a component in the graph would cost
|
|
13
|
+
* one level per component per save.
|
|
14
|
+
*
|
|
15
|
+
* The two rules worth knowing before writing one:
|
|
16
|
+
*
|
|
17
|
+
* 1. **Contribute your content, do not parent it.** `contribute` puts objects
|
|
18
|
+
* into the owner's children and takes them along when the component moves;
|
|
19
|
+
* `withdraw` takes them back. Anything that needs an internal offset carries
|
|
20
|
+
* it on the object contributed -- a directional light's direction lives on the
|
|
21
|
+
* light. A component has no transform of its own to offer.
|
|
22
|
+
* 2. **Never attach another component.** Contribute all the objects you like --
|
|
23
|
+
* `PointLightComponent` contributes a light and a clickable proxy sphere --
|
|
24
|
+
* but never call `owner.addComponent`. A component describes one capability
|
|
25
|
+
* and does not decide what else its owner is made of; composing a node is the
|
|
26
|
+
* caller's job. A component that needs a sibling should be handed it, or the
|
|
27
|
+
* caller should attach both.
|
|
28
|
+
*
|
|
29
|
+
* Constructors take no arguments: {@link clone} calls `new this.constructor()`.
|
|
30
|
+
* Configure through setters instead.
|
|
31
|
+
*
|
|
32
|
+
* An `EventDispatcher`, so a component reports what happens to it on itself. A
|
|
33
|
+
* detached one can speak too, which is why nothing here guards a report with
|
|
34
|
+
* {@link isAttached}: whether an event fires says something about the event, never
|
|
35
|
+
* about the delivery route.
|
|
36
|
+
*
|
|
37
|
+
* A component is not in the `.parent` chain, but what it contributes is, and
|
|
38
|
+
* `findInterface` walks that chain up from a raycast hit looking for
|
|
39
|
+
* `isSelectable` and friends. A capability brand on a contributed mesh therefore
|
|
40
|
+
* gets the mesh handed back instead of the node behind it. Contribute plain
|
|
41
|
+
* objects and let the node carry the brands.
|
|
42
|
+
*
|
|
43
|
+
* @module
|
|
44
|
+
*/
|
|
45
|
+
export declare abstract class DIVEComponent extends EventDispatcher<DIVEComponentEventMap> {
|
|
46
|
+
readonly isDIVEComponent: true;
|
|
47
|
+
/** For debugging: nothing reads it, since components are not in the graph. */
|
|
48
|
+
name: string;
|
|
49
|
+
/**
|
|
50
|
+
* The node this component is attached to.
|
|
51
|
+
*
|
|
52
|
+
* Throws while the component is detached, rather than handing out a `null`
|
|
53
|
+
* that every consumer has to rule out. A non-nullable owner is not available
|
|
54
|
+
* to us: {@link clone} builds a component before there is any node to put it
|
|
55
|
+
* on, so a detached one has to be constructible, and detached is therefore a
|
|
56
|
+
* real state rather than an impossible one.
|
|
57
|
+
*
|
|
58
|
+
* Ask {@link isAttached} when a detached component is a case to handle rather
|
|
59
|
+
* than a mistake.
|
|
60
|
+
*/
|
|
61
|
+
get owner(): DIVENode;
|
|
62
|
+
/**
|
|
63
|
+
* What this component put into its owner's children.
|
|
64
|
+
*
|
|
65
|
+
* A component owns renderables -- a mesh, a light, a camera, a helper -- but
|
|
66
|
+
* they belong in the *node's* children, not in its own. `children` is three's
|
|
67
|
+
* render queue, so the content has to be in the graph; the component holding
|
|
68
|
+
* it does not, and an exporter writes every graph node it walks. One level
|
|
69
|
+
* per component per save is what that costs.
|
|
70
|
+
*
|
|
71
|
+
* Contribute through {@link contribute}, take back through {@link withdraw}.
|
|
72
|
+
* Both work whether or not the component is attached: while it has no owner
|
|
73
|
+
* this is a list and nothing more, and everything on it is added the moment
|
|
74
|
+
* one arrives.
|
|
75
|
+
*/
|
|
76
|
+
get contributions(): readonly Object3D[];
|
|
77
|
+
private _contributed;
|
|
78
|
+
/**
|
|
79
|
+
* Whether this component is attached to a node.
|
|
80
|
+
*/
|
|
81
|
+
get isAttached(): boolean;
|
|
82
|
+
private _owner;
|
|
83
|
+
/**
|
|
84
|
+
* Whether this component currently participates in the per-frame tick.
|
|
85
|
+
*
|
|
86
|
+
* Only meaningful for components that implement {@link tick}. Enrolment and
|
|
87
|
+
* participation are separate questions: whether a component can ever tick is
|
|
88
|
+
* decided by the method existing, while this decides whether it does right
|
|
89
|
+
* now, so one that only works some of the time can withdraw entirely instead
|
|
90
|
+
* of being called every frame to return immediately.
|
|
91
|
+
*/
|
|
92
|
+
get tickEnabled(): boolean;
|
|
93
|
+
private _tickEnabled;
|
|
94
|
+
/**
|
|
95
|
+
* Implement to receive a per-frame callback.
|
|
96
|
+
*
|
|
97
|
+
* The mere presence of this method enrols the component; components without
|
|
98
|
+
* it are never visited. Needs the camera? Put an `onBeforeRender` on the
|
|
99
|
+
* meshes the component owns instead -- `tick` has no view context.
|
|
100
|
+
*
|
|
101
|
+
* @param deltaTime - Seconds since the previous frame.
|
|
102
|
+
*/
|
|
103
|
+
tick?(deltaTime: number): void;
|
|
104
|
+
/**
|
|
105
|
+
* Enables or disables this component's per-frame tick.
|
|
106
|
+
*
|
|
107
|
+
* @param enabled - Whether the component should tick.
|
|
108
|
+
*/
|
|
109
|
+
setTickEnabled(enabled: boolean): void;
|
|
110
|
+
/**
|
|
111
|
+
* Called once the component has been attached to a node.
|
|
112
|
+
*
|
|
113
|
+
* @param owner - The node it is now attached to.
|
|
114
|
+
*/
|
|
115
|
+
protected onAttach(owner: DIVENode): void;
|
|
116
|
+
/**
|
|
117
|
+
* Called after the component has been detached from a node.
|
|
118
|
+
*
|
|
119
|
+
* Takes the previous owner explicitly because three clears `parent` before
|
|
120
|
+
* dispatching `removed`, so `this.owner` is already `null` by this point.
|
|
121
|
+
*
|
|
122
|
+
* @param previousOwner - The node it was attached to.
|
|
123
|
+
*/
|
|
124
|
+
protected onDetach(previousOwner: DIVENode): void;
|
|
125
|
+
/**
|
|
126
|
+
* Puts objects into the owner's children, and remembers them.
|
|
127
|
+
*
|
|
128
|
+
* Safe to call from a constructor: with no owner yet this only records them,
|
|
129
|
+
* and {@link contributions} is applied as soon as one arrives. Safe to call
|
|
130
|
+
* twice with the same object -- the second time is ignored rather than
|
|
131
|
+
* producing a duplicate, which would send a spurious `childremoved` /
|
|
132
|
+
* `childadded` pair through the owner.
|
|
133
|
+
*
|
|
134
|
+
* @param objects - What this component contributes to its owner.
|
|
135
|
+
*/
|
|
136
|
+
protected contribute(...objects: Object3D[]): void;
|
|
137
|
+
/**
|
|
138
|
+
* Takes objects back out of the owner's children.
|
|
139
|
+
*
|
|
140
|
+
* Only unparents them. Disposing is a separate concern: a component that is
|
|
141
|
+
* merely moving to another node must not destroy what it carries.
|
|
142
|
+
*
|
|
143
|
+
* @param objects - What to take back. Anything not contributed is ignored.
|
|
144
|
+
*/
|
|
145
|
+
protected withdraw(...objects: Object3D[]): void;
|
|
146
|
+
/**
|
|
147
|
+
* Releases GPU resources held by this component.
|
|
148
|
+
*
|
|
149
|
+
* Subclasses owning geometries, materials or textures must override this.
|
|
150
|
+
*/
|
|
151
|
+
dispose(): void;
|
|
152
|
+
/**
|
|
153
|
+
* Hands the contributions to a new owner.
|
|
154
|
+
*
|
|
155
|
+
* Adds only what is not already there, so a stray direct assignment to
|
|
156
|
+
* `node.children` cannot leave this out of step -- and so re-attaching a
|
|
157
|
+
* component that never left is a no-op.
|
|
158
|
+
*/
|
|
159
|
+
private _adopt;
|
|
160
|
+
/**
|
|
161
|
+
* Called by {@link DIVENode.addComponent}. Not for anyone else.
|
|
162
|
+
*
|
|
163
|
+
* three's `added`/`removed` events used to drive this, which caught every way
|
|
164
|
+
* into the graph -- `add`, `attach`, `clear`, re-parenting. A component is no
|
|
165
|
+
* longer in the graph, so the node is now the only way in, and that is what
|
|
166
|
+
* makes this reliable rather than what makes it fragile.
|
|
167
|
+
*
|
|
168
|
+
* @internal
|
|
169
|
+
*/
|
|
170
|
+
_attach(owner: DIVENode): void;
|
|
171
|
+
/**
|
|
172
|
+
* Called by {@link DIVENode.removeComponent}. Not for anyone else.
|
|
173
|
+
*
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
_detach(): void;
|
|
177
|
+
/**
|
|
178
|
+
* A component of the same kind, configured the same way.
|
|
179
|
+
*
|
|
180
|
+
* Calls `new this.constructor()`, which is why constructors take no
|
|
181
|
+
* arguments, and hands over to {@link copy}.
|
|
182
|
+
*/
|
|
183
|
+
clone(): this;
|
|
184
|
+
/**
|
|
185
|
+
* Takes on another component's configuration.
|
|
186
|
+
*
|
|
187
|
+
* The base copies the name and nothing else. A component holding state --
|
|
188
|
+
* a geometry descriptor, a material, an intensity factor -- overrides this
|
|
189
|
+
* and copies it, because a clone that silently drops it looks like it worked.
|
|
190
|
+
*
|
|
191
|
+
* Never copies contributions: the clone builds or loads its own.
|
|
192
|
+
*
|
|
193
|
+
* @param source - The component to copy from.
|
|
194
|
+
*/
|
|
195
|
+
copy(source: this): this;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The component that contributed `object`, if any.
|
|
199
|
+
*
|
|
200
|
+
* @param object - Something found in a node's children.
|
|
201
|
+
*/
|
|
202
|
+
export declare function contributedBy(object: Object3D): DIVEComponent | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* Any component class, for `instanceof` lookups.
|
|
205
|
+
*
|
|
206
|
+
* Uses `never[]` parameters so abstract bases that take constructor arguments
|
|
207
|
+
* still match -- only the class identity matters here, never its signature.
|
|
208
|
+
* Concrete components must still be zero-argument so `clone()` works.
|
|
209
|
+
*/
|
|
210
|
+
export type DIVEComponentClass<T extends DIVEComponent = DIVEComponent> = abstract new (...args: never[]) => T;
|
|
211
|
+
/**
|
|
212
|
+
* Type guard for components, without importing the class.
|
|
213
|
+
*
|
|
214
|
+
* @param object - The object to test.
|
|
215
|
+
*/
|
|
216
|
+
export declare function isDIVEComponent(object: unknown): object is DIVEComponent;
|
|
217
|
+
/**
|
|
218
|
+
* Walks **up** from an object to the component that contains it.
|
|
219
|
+
*
|
|
220
|
+
* The counterpart to `DIVENode.getComponent`, which looks at a node's own
|
|
221
|
+
* components: this starts anywhere inside one and finds the component itself.
|
|
222
|
+
* That is how a caller holding only what a component owns gets back to it -- an
|
|
223
|
+
* `OrbitController` hands out its camera, and `setCameraLayer` lives on the
|
|
224
|
+
* camera's component.
|
|
225
|
+
*
|
|
226
|
+
* Walks up from `object`, asking at each step which component contributed it --
|
|
227
|
+
* a component owns its content but does not parent it, so it is not an ancestor.
|
|
228
|
+
* Going up as well as asking means this still finds a component from something
|
|
229
|
+
* nested deep inside what it contributed.
|
|
230
|
+
*
|
|
231
|
+
* Matches with `instanceof`, so an abstract base finds its subclasses.
|
|
232
|
+
*
|
|
233
|
+
* @param object - Where to start, typically something a component owns.
|
|
234
|
+
* @param Ctor - The component class to look for.
|
|
235
|
+
*/
|
|
236
|
+
export declare function findComponent<T extends DIVEComponent>(object: Object3D, Ctor: DIVEComponentClass<T>): T | undefined;
|
|
@@ -18,30 +18,12 @@ export type DIVEEnvironmentSettings = {
|
|
|
18
18
|
* @default false
|
|
19
19
|
*/
|
|
20
20
|
useAsBackground: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* The intensity of the environment lighting.
|
|
23
|
-
*
|
|
24
|
-
* @default 1
|
|
25
|
-
*/
|
|
26
|
-
globalEnvIntensity: number;
|
|
27
|
-
/**
|
|
28
|
-
* The exposure of the HDR image.
|
|
29
|
-
*
|
|
30
|
-
* @default 1
|
|
31
|
-
*/
|
|
32
|
-
exposure: number;
|
|
33
21
|
/**
|
|
34
22
|
* The rotation of the HDR image in radians.
|
|
35
23
|
*
|
|
36
24
|
* @default 0
|
|
37
25
|
*/
|
|
38
26
|
rotateY: number;
|
|
39
|
-
/**
|
|
40
|
-
* Whether to replace the existing lights (can be restored via `restoreLights`).
|
|
41
|
-
*
|
|
42
|
-
* @default false
|
|
43
|
-
*/
|
|
44
|
-
replaceLights?: boolean;
|
|
45
27
|
};
|
|
46
28
|
export declare const DIVEEnvironmentDefaultSettings: DIVEEnvironmentSettings;
|
|
47
29
|
/**
|
|
@@ -53,6 +35,7 @@ export declare const DIVEEnvironmentDefaultSettings: DIVEEnvironmentSettings;
|
|
|
53
35
|
*/
|
|
54
36
|
export declare class DIVEEnvironment {
|
|
55
37
|
private originalBackground;
|
|
38
|
+
private installedBackground;
|
|
56
39
|
private _webgpurenderer;
|
|
57
40
|
private scene;
|
|
58
41
|
private pmrem;
|
|
@@ -71,6 +54,13 @@ export declare class DIVEEnvironment {
|
|
|
71
54
|
* Disposes the environment.
|
|
72
55
|
*/
|
|
73
56
|
dispose(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Whether `scene.background` is still the one this environment installed.
|
|
59
|
+
*
|
|
60
|
+
* A foreign value means something else has changed the background in the
|
|
61
|
+
* meantime, which makes it the value to restore instead.
|
|
62
|
+
*/
|
|
63
|
+
private ownsSceneBackground;
|
|
74
64
|
private clearEnvironment;
|
|
75
65
|
/**
|
|
76
66
|
* Updates the environment.
|
package/build/engine/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './Dive.ts';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './component/Component.ts';
|
|
3
|
+
export * from './node/Node.ts';
|
|
4
|
+
export * from './boundingbox/BoundingBox.ts';
|
|
3
5
|
export * from './clock/Clock.ts';
|
|
4
6
|
export * from './renderer/Renderer.ts';
|
|
5
7
|
export * from './environment/Environment.ts';
|
|
@@ -7,4 +9,5 @@ export * from './canvas/CanvasLifecycleManager.ts';
|
|
|
7
9
|
export * from './promise/deferred/DeferredPromise.ts';
|
|
8
10
|
export * from './promise/abortable/AbortablePromise.ts';
|
|
9
11
|
export * from './scene/Scene.ts';
|
|
12
|
+
export * from './scene/root/Root.ts';
|
|
10
13
|
export * from './view/View.ts';
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { Box3, Object3D, Vector3, Vector3Like } from 'three/webgpu';
|
|
2
|
+
import { DIVEMovable } from '../../interfaces/Movable.ts';
|
|
3
|
+
import { DIVESelectable } from '../../interfaces/Selectable.ts';
|
|
4
|
+
import { TransformControls } from 'three/examples/jsm/controls/TransformControls.ts';
|
|
5
|
+
import { DIVEEntityEventMap } from '../../types/events/index.ts';
|
|
6
|
+
import { DIVEComponent, DIVEComponentClass } from '../component/Component.ts';
|
|
7
|
+
/**
|
|
8
|
+
* A node in the scene tree.
|
|
9
|
+
*
|
|
10
|
+
* Nodes carry the transform and the identity; everything they *do* comes from
|
|
11
|
+
* the components attached to them. `children` holds both -- it has to, because
|
|
12
|
+
* three builds its render list from the scene graph -- so use `nodes` for the
|
|
13
|
+
* logical child tree and `components` for the attached capabilities.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
export declare class DIVENode extends Object3D<DIVEEntityEventMap> implements DIVESelectable, DIVEMovable {
|
|
18
|
+
readonly isSelectable: true;
|
|
19
|
+
readonly isMovable: true;
|
|
20
|
+
readonly isDIVENode: true;
|
|
21
|
+
gizmo: TransformControls | null;
|
|
22
|
+
protected _positionWorldBuffer: Vector3;
|
|
23
|
+
protected _boundingBox: Box3;
|
|
24
|
+
private _components;
|
|
25
|
+
/** The scene this node belongs to, cached so it survives detachment. */
|
|
26
|
+
private _scene;
|
|
27
|
+
/**
|
|
28
|
+
* The components attached to this node.
|
|
29
|
+
*/
|
|
30
|
+
get components(): readonly DIVEComponent[];
|
|
31
|
+
/**
|
|
32
|
+
* The child nodes of this node -- the logical scene tree.
|
|
33
|
+
*
|
|
34
|
+
* Filters `children` by `isDIVENode`, which excludes components as well as
|
|
35
|
+
* raw geometry a component happens to own. Uncached on purpose: direct
|
|
36
|
+
* `children` assignment bypasses three's events, so a cache would be able
|
|
37
|
+
* to go stale, and the list is short enough that filtering costs nothing.
|
|
38
|
+
*/
|
|
39
|
+
get nodes(): DIVENode[];
|
|
40
|
+
constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Attaches a component to this node.
|
|
43
|
+
*
|
|
44
|
+
* Uses `add`, never `attach`: a component has no meaningful transform of its
|
|
45
|
+
* own, and `attach` would apply an inverse world matrix to it.
|
|
46
|
+
*
|
|
47
|
+
* Announces itself with `componentadded`, named after three's `childadded`
|
|
48
|
+
* because it is the same kind of fact about the same node. A component is not
|
|
49
|
+
* a child, so three's own events say nothing about one, and without this
|
|
50
|
+
* nothing could observe what a node is made of.
|
|
51
|
+
*
|
|
52
|
+
* @param component - The component to attach.
|
|
53
|
+
* @returns The component, for chaining.
|
|
54
|
+
*/
|
|
55
|
+
addComponent<T extends DIVEComponent>(component: T): T;
|
|
56
|
+
/**
|
|
57
|
+
* Detaches a component from this node.
|
|
58
|
+
*
|
|
59
|
+
* Announces itself with `componentremoved`, after the component is gone, so a
|
|
60
|
+
* listener that re-reads the node sees what is left rather than what was.
|
|
61
|
+
*
|
|
62
|
+
* @param component - The component to detach.
|
|
63
|
+
*/
|
|
64
|
+
removeComponent(component: DIVEComponent): this;
|
|
65
|
+
/**
|
|
66
|
+
* Finds the first attached component of the given type.
|
|
67
|
+
*
|
|
68
|
+
* Matches with `instanceof`, so a base class finds its subclasses -- asking
|
|
69
|
+
* for `MeshComponent` also returns a `PrimitiveComponent`, and asking
|
|
70
|
+
* for an abstract base such as `DIVELightComponent` works too.
|
|
71
|
+
*
|
|
72
|
+
* @param Ctor - The component class to look for.
|
|
73
|
+
*/
|
|
74
|
+
getComponent<T extends DIVEComponent>(Ctor: DIVEComponentClass<T>): T | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Finds every attached component of the given type.
|
|
77
|
+
*
|
|
78
|
+
* @param Ctor - The component class to look for.
|
|
79
|
+
*/
|
|
80
|
+
getComponents<T extends DIVEComponent>(Ctor: DIVEComponentClass<T>): T[];
|
|
81
|
+
/**
|
|
82
|
+
* Like {@link getComponent}, but throws when the component is missing.
|
|
83
|
+
*
|
|
84
|
+
* Use this wherever a component is part of the node's contract -- a model
|
|
85
|
+
* node always has mesh geometry, a light node always has a light. Throwing
|
|
86
|
+
* once beats threading an `undefined` through every caller.
|
|
87
|
+
*
|
|
88
|
+
* @param Ctor - The component class to look for.
|
|
89
|
+
*/
|
|
90
|
+
requireComponent<T extends DIVEComponent>(Ctor: DIVEComponentClass<T>): T;
|
|
91
|
+
/**
|
|
92
|
+
* Removes all child nodes and raw children, keeping what components own.
|
|
93
|
+
*
|
|
94
|
+
* `Object3D.clear()` would take the contributions with it, which would
|
|
95
|
+
* silently strip a node of its geometry or its light. A component gives up
|
|
96
|
+
* its own content through `withdraw`, never through the node.
|
|
97
|
+
*/
|
|
98
|
+
clear(): this;
|
|
99
|
+
/**
|
|
100
|
+
* Copies another node, its components included.
|
|
101
|
+
*
|
|
102
|
+
* Child nodes are cloned, contributed content is not: a component brings its
|
|
103
|
+
* own along, and cloning it here as well would leave the copy with ownerless
|
|
104
|
+
* geometry beside a component that knows nothing about it.
|
|
105
|
+
*
|
|
106
|
+
* **Replaces the components this node already has, disposing them.** A node
|
|
107
|
+
* that attaches components in its constructor -- `DIVERoot` and its floor --
|
|
108
|
+
* would otherwise end up with two of each, and the ones being replaced hold
|
|
109
|
+
* GPU resources that nobody else will ever release. Unexpected for a copy
|
|
110
|
+
* operation, hence spelled out here.
|
|
111
|
+
*
|
|
112
|
+
* @param source - The node to copy from.
|
|
113
|
+
* @param recursive - Whether to copy children.
|
|
114
|
+
*/
|
|
115
|
+
copy(source: this, recursive?: boolean): this;
|
|
116
|
+
/**
|
|
117
|
+
* Re-evaluates whether a component should be ticking.
|
|
118
|
+
*
|
|
119
|
+
* @param component - The component whose tick state changed.
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
refreshComponentTick(component: DIVEComponent): void;
|
|
123
|
+
setPosition(position: Vector3Like): void;
|
|
124
|
+
setRotation(rotation: Vector3Like): void;
|
|
125
|
+
setScale(scale: Vector3Like): void;
|
|
126
|
+
/**
|
|
127
|
+
* Writes a transform **without reporting it for this node**.
|
|
128
|
+
*
|
|
129
|
+
* For a caller that announces the change itself: the state's apply path
|
|
130
|
+
* writes a whole patch and its action announces it once. Going through
|
|
131
|
+
* `setPosition`, `setRotation` and `setScale` there meant three reports for
|
|
132
|
+
* one patch, on top of the action's own — which is what this exists to avoid.
|
|
133
|
+
*
|
|
134
|
+
* Members are still woken, because nothing else tells them: their own
|
|
135
|
+
* transform did not change, but their world transform did, and no caller
|
|
136
|
+
* knows about them.
|
|
137
|
+
*
|
|
138
|
+
* @param patch - The parts of the transform to write. Anything absent is left
|
|
139
|
+
* alone.
|
|
140
|
+
*/
|
|
141
|
+
applyTransform(patch: {
|
|
142
|
+
position?: Vector3Like | null;
|
|
143
|
+
rotation?: Vector3Like | null;
|
|
144
|
+
scale?: Vector3Like | null;
|
|
145
|
+
}): void;
|
|
146
|
+
/**
|
|
147
|
+
* Reports this node's transform, and its members' new world transforms.
|
|
148
|
+
*
|
|
149
|
+
* One event for every kind of move, so a listener never has to ask what
|
|
150
|
+
* caused it: a gizmo drag and a `setPosition` both arrive as
|
|
151
|
+
* `object-transform`.
|
|
152
|
+
*
|
|
153
|
+
* Can be called when the object is moved from a foreign object (gizmo,
|
|
154
|
+
* parent, etc.) to update the object's position.
|
|
155
|
+
*/
|
|
156
|
+
onMove(): void;
|
|
157
|
+
/**
|
|
158
|
+
* Writes whatever the patch carries, guarded field by field.
|
|
159
|
+
*
|
|
160
|
+
* @returns Whether anything actually changed. Nothing reports otherwise, so
|
|
161
|
+
* a patch that repeats the current transform stays silent.
|
|
162
|
+
*/
|
|
163
|
+
private _writeTransform;
|
|
164
|
+
/**
|
|
165
|
+
* Has every member report its new world transform, recursively.
|
|
166
|
+
*
|
|
167
|
+
* Members are reached through their own `onMove`, so a nested group carries
|
|
168
|
+
* on down its own members.
|
|
169
|
+
*/
|
|
170
|
+
private _reportMembers;
|
|
171
|
+
/**
|
|
172
|
+
* Rests this node on the highest surface below it, and never below the
|
|
173
|
+
* ground plane.
|
|
174
|
+
*
|
|
175
|
+
* The floor is deliberately not a raycast target: it is a flat plane at
|
|
176
|
+
* y = 0, so "hit the floor" and "hit nothing" produce the same answer. The
|
|
177
|
+
* clamp to y = 0 covers the remaining case, geometry parked below the floor,
|
|
178
|
+
* which must not drag this node underground.
|
|
179
|
+
*/
|
|
180
|
+
dropIt(): void;
|
|
181
|
+
setVisibility(visible: boolean): void;
|
|
182
|
+
setToWorldOrigin(): void;
|
|
183
|
+
onSelect(): void;
|
|
184
|
+
onDeselect(): void;
|
|
185
|
+
private _handleAddedToTree;
|
|
186
|
+
private _handleRemovedFromTree;
|
|
187
|
+
private _attachToScene;
|
|
188
|
+
private _detachFromScene;
|
|
189
|
+
}
|
|
@@ -13,5 +13,13 @@ export declare class DIVEAbortablePromise<T> implements Promise<T> {
|
|
|
13
13
|
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
14
14
|
finally(onfinally?: (() => void) | null): Promise<T>;
|
|
15
15
|
abort(reason?: unknown): void;
|
|
16
|
+
/**
|
|
17
|
+
* Runs the executor and hands back its promise.
|
|
18
|
+
*
|
|
19
|
+
* The `catch` is not redundant, unlike one inside an `async` function: this
|
|
20
|
+
* method is synchronous, so an executor that throws before its first `await`
|
|
21
|
+
* would throw at whoever called this rather than reject the promise they
|
|
22
|
+
* were handed.
|
|
23
|
+
*/
|
|
16
24
|
private _execute;
|
|
17
25
|
}
|