@relu-interactives/spatial-ecs 0.2.2
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 +125 -0
- package/dist/System-rXAmagXA.d.cts +659 -0
- package/dist/System-rXAmagXA.d.ts +659 -0
- package/dist/Video-CDemv74U.d.cts +1261 -0
- package/dist/Video-ChKV1UI7.d.ts +1261 -0
- package/dist/assets/draco/draco_decoder.js +34 -0
- package/dist/assets/draco/draco_decoder.wasm +0 -0
- package/dist/assets/draco/draco_wasm_wrapper.js +117 -0
- package/dist/chunk-AYEF3X2P.js +223 -0
- package/dist/chunk-AYEF3X2P.js.map +1 -0
- package/dist/chunk-MAWBTMCG.js +1722 -0
- package/dist/chunk-MAWBTMCG.js.map +1 -0
- package/dist/chunk-NFDTIYR4.js +248 -0
- package/dist/chunk-NFDTIYR4.js.map +1 -0
- package/dist/chunk-OY7ZODZP.js +16 -0
- package/dist/chunk-OY7ZODZP.js.map +1 -0
- package/dist/chunk-P2YDX5DB.js +3304 -0
- package/dist/chunk-P2YDX5DB.js.map +1 -0
- package/dist/chunk-QHILSPT4.js +3 -0
- package/dist/chunk-QHILSPT4.js.map +1 -0
- package/dist/chunk-XWIEEJ7Z.js +1315 -0
- package/dist/chunk-XWIEEJ7Z.js.map +1 -0
- package/dist/components/index.cjs +1745 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +4 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -0
- package/dist/docs/api/Behaviour/classes/Behaviour.md +554 -0
- package/dist/docs/api/Behaviour/index.md +15 -0
- package/dist/docs/api/Component/classes/Component.md +57 -0
- package/dist/docs/api/Component/index.md +15 -0
- package/dist/docs/api/components/classes/AnimationComponent.md +318 -0
- package/dist/docs/api/components/classes/AudioComponent.md +114 -0
- package/dist/docs/api/components/classes/CameraComponent.md +59 -0
- package/dist/docs/api/components/classes/EntityType.md +48 -0
- package/dist/docs/api/components/classes/Environment.md +47 -0
- package/dist/docs/api/components/classes/ImageComponent.md +57 -0
- package/dist/docs/api/components/classes/ImageTarget.md +60 -0
- package/dist/docs/api/components/classes/ImageTargetAnchor.md +48 -0
- package/dist/docs/api/components/classes/LightComponent.md +70 -0
- package/dist/docs/api/components/classes/MaterialComponent.md +181 -0
- package/dist/docs/api/components/classes/MeshComponent.md +48 -0
- package/dist/docs/api/components/classes/MeshGeometryComponent.md +64 -0
- package/dist/docs/api/components/classes/ModelComponent.md +49 -0
- package/dist/docs/api/components/classes/Name.md +46 -0
- package/dist/docs/api/components/classes/Object3DRef.md +54 -0
- package/dist/docs/api/components/classes/ParentId.md +47 -0
- package/dist/docs/api/components/classes/PhysicsComponent.md +82 -0
- package/dist/docs/api/components/classes/Postprocessing.md +49 -0
- package/dist/docs/api/components/classes/ScriptComponent.md +54 -0
- package/dist/docs/api/components/classes/Selectable.md +46 -0
- package/dist/docs/api/components/classes/SelectionTransformState.md +54 -0
- package/dist/docs/api/components/classes/SpriteComponent.md +55 -0
- package/dist/docs/api/components/classes/TransformComponent.md +197 -0
- package/dist/docs/api/components/classes/VideoComponent.md +123 -0
- package/dist/docs/api/components/functions/normalizePhysicsState.md +23 -0
- package/dist/docs/api/components/index.md +94 -0
- package/dist/docs/api/components/type-aliases/AnimationComponentOptions.md +42 -0
- package/dist/docs/api/components/type-aliases/CameraComponentOptions.md +45 -0
- package/dist/docs/api/components/type-aliases/CameraProjection.md +15 -0
- package/dist/docs/api/components/type-aliases/CameraRuntimeType.md +15 -0
- package/dist/docs/api/components/type-aliases/ColliderShape.md +15 -0
- package/dist/docs/api/components/type-aliases/ColliderState.md +62 -0
- package/dist/docs/api/components/type-aliases/CubeMeshParameters.md +27 -0
- package/dist/docs/api/components/type-aliases/EditableMeshObjectKind.md +15 -0
- package/dist/docs/api/components/type-aliases/EnvironmentFogState.md +37 -0
- package/dist/docs/api/components/type-aliases/EnvironmentFogType.md +15 -0
- package/dist/docs/api/components/type-aliases/EnvironmentGradientEffect.md +15 -0
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxState.md +34 -0
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxType.md +15 -0
- package/dist/docs/api/components/type-aliases/EnvironmentState.md +29 -0
- package/dist/docs/api/components/type-aliases/ImageTargetAnchorOptions.md +25 -0
- package/dist/docs/api/components/type-aliases/ImageTargetReference.md +33 -0
- package/dist/docs/api/components/type-aliases/LightValueState.md +41 -0
- package/dist/docs/api/components/type-aliases/MaterialTypeValue.md +15 -0
- package/dist/docs/api/components/type-aliases/MaterialValueState.md +75 -0
- package/dist/docs/api/components/type-aliases/MeshGeometryParameters.md +13 -0
- package/dist/docs/api/components/type-aliases/MeshGeometryParametersByKind.md +33 -0
- package/dist/docs/api/components/type-aliases/PhysicsState.md +25 -0
- package/dist/docs/api/components/type-aliases/PlaneMeshParameters.md +25 -0
- package/dist/docs/api/components/type-aliases/PostprocessingState.md +164 -0
- package/dist/docs/api/components/type-aliases/RadiusHeightMeshParameters.md +25 -0
- package/dist/docs/api/components/type-aliases/RadiusMeshParameters.md +23 -0
- package/dist/docs/api/components/type-aliases/RigidbodyState.md +53 -0
- package/dist/docs/api/components/type-aliases/RigidbodyType.md +19 -0
- package/dist/docs/api/components/type-aliases/ScriptEntry.md +38 -0
- package/dist/docs/api/components/type-aliases/TextureFilteringValue.md +15 -0
- package/dist/docs/api/components/type-aliases/TransformData.md +27 -0
- package/dist/docs/api/components/type-aliases/TransformModeValue.md +15 -0
- package/dist/docs/api/components/type-aliases/TransformSpaceValue.md +15 -0
- package/dist/docs/api/components/type-aliases/Vec3.md +27 -0
- package/dist/docs/api/components/variables/DEFAULT_COLLIDER_STATE.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_STATE.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_MESH_GEOMETRY_PARAMETERS.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_PHYSICS_STATE.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_POSTPROCESSING_STATE.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_RIGIDBODY_STATE.md +13 -0
- package/dist/docs/api/index/classes/AnimationStateMachine.md +201 -0
- package/dist/docs/api/index/classes/AnimationStateManager.md +253 -0
- package/dist/docs/api/index/classes/AnimationSystem.md +68 -0
- package/dist/docs/api/index/classes/AudioSystem.md +98 -0
- package/dist/docs/api/index/classes/CameraSyncSystem.md +49 -0
- package/dist/docs/api/index/classes/EnvironmentSyncSystem.md +75 -0
- package/dist/docs/api/index/classes/InputSystem.md +449 -0
- package/dist/docs/api/index/classes/LightSyncSystem.md +49 -0
- package/dist/docs/api/index/classes/MaterialSyncSystem.md +67 -0
- package/dist/docs/api/index/classes/MeshGeometrySystem.md +49 -0
- package/dist/docs/api/index/classes/ObjectManagementSystem.md +298 -0
- package/dist/docs/api/index/classes/ObjectVisibilitySystem.md +49 -0
- package/dist/docs/api/index/classes/PhysicsSyncSystem.md +83 -0
- package/dist/docs/api/index/classes/PostprocessingSyncSystem.md +80 -0
- package/dist/docs/api/index/classes/RenderSystem.md +64 -0
- package/dist/docs/api/index/classes/ScriptBehaviourSystem.md +83 -0
- package/dist/docs/api/index/classes/TransformSyncSystem.md +49 -0
- package/dist/docs/api/index/classes/VideoSystem.md +97 -0
- package/dist/docs/api/index/classes/World.md +1405 -0
- package/dist/docs/api/index/functions/createAnimationComponent.md +28 -0
- package/dist/docs/api/index/functions/createAudioComponent.md +32 -0
- package/dist/docs/api/index/functions/createCameraComponent.md +28 -0
- package/dist/docs/api/index/functions/createEntityTypeComponent.md +28 -0
- package/dist/docs/api/index/functions/createEnvironmentComponent.md +28 -0
- package/dist/docs/api/index/functions/createImageComponent.md +28 -0
- package/dist/docs/api/index/functions/createImageTargetAnchorComponent.md +28 -0
- package/dist/docs/api/index/functions/createImageTargetComponent.md +28 -0
- package/dist/docs/api/index/functions/createLightComponent.md +28 -0
- package/dist/docs/api/index/functions/createMaterialComponent.md +28 -0
- package/dist/docs/api/index/functions/createMeshComponent.md +28 -0
- package/dist/docs/api/index/functions/createMeshGeometryComponent.md +28 -0
- package/dist/docs/api/index/functions/createModelComponent.md +28 -0
- package/dist/docs/api/index/functions/createNameComponent.md +28 -0
- package/dist/docs/api/index/functions/createObject3DRefComponent.md +28 -0
- package/dist/docs/api/index/functions/createParentIdComponent.md +28 -0
- package/dist/docs/api/index/functions/createPhysicsComponent.md +30 -0
- package/dist/docs/api/index/functions/createPostprocessingComponent.md +28 -0
- package/dist/docs/api/index/functions/createScriptComponent.md +28 -0
- package/dist/docs/api/index/functions/createSelectableComponent.md +28 -0
- package/dist/docs/api/index/functions/createSelectionTransformStateComponent.md +28 -0
- package/dist/docs/api/index/functions/createSpriteComponent.md +28 -0
- package/dist/docs/api/index/functions/createTransformComponent.md +28 -0
- package/dist/docs/api/index/functions/createVideoComponent.md +28 -0
- package/dist/docs/api/index/functions/hydrateWorldFromSnapshot.md +28 -0
- package/dist/docs/api/index/functions/hydrateWorldFromSnapshotDetailed.md +28 -0
- package/dist/docs/api/index/functions/registerDefaultComponentFactories.md +23 -0
- package/dist/docs/api/index/functions/registerDefaultFactories.md +23 -0
- package/dist/docs/api/index/index.md +249 -0
- package/dist/docs/api/index/interfaces/EcsSystem.md +50 -0
- package/dist/docs/api/index/interfaces/StateMachine.md +26 -0
- package/dist/docs/api/index/type-aliases/AnimationStateCallbacks.md +25 -0
- package/dist/docs/api/index/type-aliases/ComponentFactory.md +25 -0
- package/dist/docs/api/index/type-aliases/EcsComponentFactoryKind.md +37 -0
- package/dist/docs/api/index/type-aliases/EcsWorldComponentSnapshot.md +26 -0
- package/dist/docs/api/index/type-aliases/EcsWorldStateSnapshotLike.md +25 -0
- package/dist/docs/api/index/type-aliases/HydrateWorldFromSnapshotResult.md +23 -0
- package/dist/docs/api/index/type-aliases/KeyboardKey.md +13 -0
- package/dist/docs/api/index/type-aliases/MouseButton.md +13 -0
- package/dist/docs/api/index/type-aliases/SelectionContext.md +31 -0
- package/dist/docs/api/index/variables/HYDRATABLE_ENTITY_KINDS.md +13 -0
- package/dist/docs/api/index/variables/KeyboardKeys.md +195 -0
- package/dist/docs/api/index.md +15 -0
- package/dist/docs/api/typedoc-sidebar.json +1 -0
- package/dist/docs/api/types/index.md +34 -0
- package/dist/docs/api/types/type-aliases/AssetInput.md +23 -0
- package/dist/docs/api/types/type-aliases/CheckboxInput.md +13 -0
- package/dist/docs/api/types/type-aliases/ColorInput.md +13 -0
- package/dist/docs/api/types/type-aliases/ComponentInput.md +52 -0
- package/dist/docs/api/types/type-aliases/ComponentKind.md +37 -0
- package/dist/docs/api/types/type-aliases/DropdownInput.md +23 -0
- package/dist/docs/api/types/type-aliases/DropdownOption.md +23 -0
- package/dist/docs/api/types/type-aliases/EcsEntityEditorKind.md +15 -0
- package/dist/docs/api/types/type-aliases/EcsEntityKind.md +35 -0
- package/dist/docs/api/types/type-aliases/EntityId.md +16 -0
- package/dist/docs/api/types/type-aliases/EntityInput.md +23 -0
- package/dist/docs/api/types/type-aliases/FloatInput.md +13 -0
- package/dist/docs/api/types/type-aliases/IntersectionResult.md +29 -0
- package/dist/docs/api/types/type-aliases/ParentLookup.md +26 -0
- package/dist/docs/api/types/type-aliases/SelectionListener.md +25 -0
- package/dist/docs/api/types/type-aliases/SliderInput.md +27 -0
- package/dist/docs/api/types/type-aliases/TextInput.md +13 -0
- package/dist/docs/api/types/type-aliases/ToggleInput.md +13 -0
- package/dist/docs/api/types/type-aliases/Vec3.md +23 -0
- package/dist/docs/api/types/type-aliases/Vector2Input.md +23 -0
- package/dist/docs/api/types/type-aliases/Vector3Input.md +25 -0
- package/dist/docs/api/types/type-aliases/WorldEntityView.md +17 -0
- package/dist/docs/guide/accessing-components.md +399 -0
- package/dist/docs/guide/authoring-a-behaviour.md +166 -0
- package/dist/docs/guide/behaviour-lifecycle.md +43 -0
- package/dist/docs/guide/component-catalog.md +59 -0
- package/dist/docs/guide/components/_sidebar.json +78 -0
- package/dist/docs/guide/components/animation.md +171 -0
- package/dist/docs/guide/components/audio.md +181 -0
- package/dist/docs/guide/components/camera.md +179 -0
- package/dist/docs/guide/components/entity-type.md +141 -0
- package/dist/docs/guide/components/image-target-anchor.md +103 -0
- package/dist/docs/guide/components/image-target.md +122 -0
- package/dist/docs/guide/components/image.md +146 -0
- package/dist/docs/guide/components/light.md +157 -0
- package/dist/docs/guide/components/material.md +161 -0
- package/dist/docs/guide/components/mesh-geometry.md +153 -0
- package/dist/docs/guide/components/mesh.md +151 -0
- package/dist/docs/guide/components/model.md +96 -0
- package/dist/docs/guide/components/name.md +121 -0
- package/dist/docs/guide/components/object3d-ref.md +115 -0
- package/dist/docs/guide/components/parent-id.md +108 -0
- package/dist/docs/guide/components/physics.md +163 -0
- package/dist/docs/guide/components/script.md +142 -0
- package/dist/docs/guide/components/sprite.md +155 -0
- package/dist/docs/guide/components/transform.md +155 -0
- package/dist/docs/guide/components/video.md +153 -0
- package/dist/docs/guide/concepts.md +34 -0
- package/dist/docs/guide/getting-started/creating-objects.md +50 -0
- package/dist/docs/guide/getting-started/editing-objects.md +62 -0
- package/dist/docs/guide/getting-started/editor/assets-browser.md +55 -0
- package/dist/docs/guide/getting-started/editor/hierarchy.md +47 -0
- package/dist/docs/guide/getting-started/editor/index.md +16 -0
- package/dist/docs/guide/getting-started/editor/inspector.md +36 -0
- package/dist/docs/guide/getting-started/editor/modules.md +35 -0
- package/dist/docs/guide/getting-started/editor/scene-inspector.md +64 -0
- package/dist/docs/guide/getting-started/editor/toolbar.md +39 -0
- package/dist/docs/guide/getting-started/editor/viewport.md +43 -0
- package/dist/docs/guide/getting-started/first-launch.md +17 -0
- package/dist/docs/guide/getting-started/index.md +37 -0
- package/dist/docs/guide/getting-started/installation.md +59 -0
- package/dist/docs/guide/getting-started/preview-and-test.md +55 -0
- package/dist/docs/guide/getting-started/project-types/3d.md +30 -0
- package/dist/docs/guide/getting-started/project-types/ar.md +6 -0
- package/dist/docs/guide/getting-started/project-types/face-tracking.md +6 -0
- package/dist/docs/guide/getting-started/project-types/image-tracking.md +42 -0
- package/dist/docs/guide/getting-started/project-types/index.md +25 -0
- package/dist/docs/guide/getting-started/project-types/vr.md +6 -0
- package/dist/docs/guide/getting-started/projects.md +53 -0
- package/dist/docs/guide/getting-started/shortcuts.md +43 -0
- package/dist/docs/guide/inspector-data-binding.md +367 -0
- package/dist/docs/guide/reading-input.md +202 -0
- package/dist/docs/guide/scene/environment.md +101 -0
- package/dist/docs/guide/scene/index.md +36 -0
- package/dist/docs/guide/scene/postprocessing.md +108 -0
- package/dist/docs/guide/spawning/ambient-light.md +28 -0
- package/dist/docs/guide/spawning/area-light.md +32 -0
- package/dist/docs/guide/spawning/audio.md +42 -0
- package/dist/docs/guide/spawning/camera.md +50 -0
- package/dist/docs/guide/spawning/capsule.md +29 -0
- package/dist/docs/guide/spawning/cube.md +31 -0
- package/dist/docs/guide/spawning/cylinder.md +29 -0
- package/dist/docs/guide/spawning/directional-light.md +32 -0
- package/dist/docs/guide/spawning/empty.md +31 -0
- package/dist/docs/guide/spawning/image-target.md +48 -0
- package/dist/docs/guide/spawning/image.md +33 -0
- package/dist/docs/guide/spawning/index.md +79 -0
- package/dist/docs/guide/spawning/model.md +31 -0
- package/dist/docs/guide/spawning/plane.md +31 -0
- package/dist/docs/guide/spawning/point-light.md +32 -0
- package/dist/docs/guide/spawning/sphere.md +29 -0
- package/dist/docs/guide/spawning/spot-light.md +32 -0
- package/dist/docs/guide/spawning/sprite.md +31 -0
- package/dist/docs/guide/spawning/video.md +53 -0
- package/dist/docs/guide/system-overview.md +73 -0
- package/dist/docs/guide/systems/_sidebar.json +66 -0
- package/dist/docs/guide/systems/animation-system.md +32 -0
- package/dist/docs/guide/systems/audio-system.md +28 -0
- package/dist/docs/guide/systems/camera-sync-system.md +31 -0
- package/dist/docs/guide/systems/environment-sync-system.md +31 -0
- package/dist/docs/guide/systems/input-system.md +217 -0
- package/dist/docs/guide/systems/light-sync-system.md +29 -0
- package/dist/docs/guide/systems/material-sync-system.md +32 -0
- package/dist/docs/guide/systems/mesh-geometry-system.md +40 -0
- package/dist/docs/guide/systems/object-management-system.md +38 -0
- package/dist/docs/guide/systems/object-visibility-system.md +26 -0
- package/dist/docs/guide/systems/physics-sync-system.md +56 -0
- package/dist/docs/guide/systems/postprocessing-sync-system.md +43 -0
- package/dist/docs/guide/systems/render-system.md +22 -0
- package/dist/docs/guide/systems/script-behaviour-system.md +59 -0
- package/dist/docs/guide/systems/transform-sync-system.md +29 -0
- package/dist/docs/guide/systems/video-system.md +30 -0
- package/dist/docs/guide/world-api.md +405 -0
- package/dist/factories/index.cjs +3077 -0
- package/dist/factories/index.cjs.map +1 -0
- package/dist/factories/index.d.cts +69 -0
- package/dist/factories/index.d.ts +69 -0
- package/dist/factories/index.js +6 -0
- package/dist/factories/index.js.map +1 -0
- package/dist/index-B4-YyUNR.d.cts +73 -0
- package/dist/index-BZUOKeTO.d.ts +73 -0
- package/dist/index.cjs +8584 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +283 -0
- package/dist/index.d.ts +283 -0
- package/dist/index.js +1729 -0
- package/dist/index.js.map +1 -0
- package/dist/systems/index.cjs +5119 -0
- package/dist/systems/index.cjs.map +1 -0
- package/dist/systems/index.d.cts +200 -0
- package/dist/systems/index.d.ts +200 -0
- package/dist/systems/index.js +6 -0
- package/dist/systems/index.js.map +1 -0
- package/dist/types.cjs +4 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +3 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/worldSnapshotUtils.cjs +259 -0
- package/dist/worldSnapshotUtils.cjs.map +1 -0
- package/dist/worldSnapshotUtils.d.cts +3 -0
- package/dist/worldSnapshotUtils.d.ts +3 -0
- package/dist/worldSnapshotUtils.js +4 -0
- package/dist/worldSnapshotUtils.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,1745 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var THREE4 = require('three');
|
|
4
|
+
|
|
5
|
+
function _interopNamespace(e) {
|
|
6
|
+
if (e && e.__esModule) return e;
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var THREE4__namespace = /*#__PURE__*/_interopNamespace(THREE4);
|
|
24
|
+
|
|
25
|
+
var __defProp = Object.defineProperty;
|
|
26
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
27
|
+
|
|
28
|
+
// core/Component.ts
|
|
29
|
+
var _Component = class _Component {
|
|
30
|
+
};
|
|
31
|
+
__name(_Component, "Component");
|
|
32
|
+
var Component = _Component;
|
|
33
|
+
|
|
34
|
+
// core/AnimationStateMachine.ts
|
|
35
|
+
var _AnimationStateMachine = class _AnimationStateMachine {
|
|
36
|
+
constructor(name, clip, callbacks = {}, loop = false, clipId = null) {
|
|
37
|
+
this.isPlaying = false;
|
|
38
|
+
this.isPaused = false;
|
|
39
|
+
this.name = name;
|
|
40
|
+
this.clip = clip;
|
|
41
|
+
this.clipId = clipId;
|
|
42
|
+
this.loop = loop;
|
|
43
|
+
this.callbacks = {
|
|
44
|
+
onStart: callbacks.onStart ?? (() => {
|
|
45
|
+
}),
|
|
46
|
+
onPlaying: callbacks.onPlaying ?? (() => {
|
|
47
|
+
}),
|
|
48
|
+
onEnd: callbacks.onEnd ?? (() => {
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
setCallbacks(callbacks) {
|
|
53
|
+
this.callbacks = {
|
|
54
|
+
onStart: callbacks.onStart ?? this.callbacks.onStart,
|
|
55
|
+
onPlaying: callbacks.onPlaying ?? this.callbacks.onPlaying,
|
|
56
|
+
onEnd: callbacks.onEnd ?? this.callbacks.onEnd
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
setLoop(loop) {
|
|
60
|
+
this.loop = loop;
|
|
61
|
+
}
|
|
62
|
+
onStart() {
|
|
63
|
+
this.callbacks.onStart();
|
|
64
|
+
}
|
|
65
|
+
onPlaying() {
|
|
66
|
+
this.callbacks.onPlaying();
|
|
67
|
+
}
|
|
68
|
+
onEnd() {
|
|
69
|
+
this.callbacks.onEnd();
|
|
70
|
+
}
|
|
71
|
+
play() {
|
|
72
|
+
const wasPlaying = this.isPlaying;
|
|
73
|
+
this.isPlaying = true;
|
|
74
|
+
this.isPaused = false;
|
|
75
|
+
if (!wasPlaying) {
|
|
76
|
+
this.onStart();
|
|
77
|
+
}
|
|
78
|
+
this.onPlaying();
|
|
79
|
+
}
|
|
80
|
+
pause() {
|
|
81
|
+
if (!this.isPlaying) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.isPlaying = false;
|
|
85
|
+
this.isPaused = true;
|
|
86
|
+
}
|
|
87
|
+
stop() {
|
|
88
|
+
const shouldNotifyEnd = this.isPlaying || this.isPaused;
|
|
89
|
+
this.isPlaying = false;
|
|
90
|
+
this.isPaused = false;
|
|
91
|
+
if (shouldNotifyEnd) {
|
|
92
|
+
this.onEnd();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
__name(_AnimationStateMachine, "AnimationStateMachine");
|
|
97
|
+
var AnimationStateMachine = _AnimationStateMachine;
|
|
98
|
+
var _AnimationStateManager = class _AnimationStateManager {
|
|
99
|
+
constructor() {
|
|
100
|
+
this.states = /* @__PURE__ */ new Map();
|
|
101
|
+
this.activeState = null;
|
|
102
|
+
}
|
|
103
|
+
addState(state) {
|
|
104
|
+
this.states.set(state.name, state);
|
|
105
|
+
return state;
|
|
106
|
+
}
|
|
107
|
+
createState(name, clip, callbacks = {}, loop = false, clipId = null) {
|
|
108
|
+
const state = new AnimationStateMachine(name, clip, callbacks, loop, clipId);
|
|
109
|
+
this.states.set(name, state);
|
|
110
|
+
return state;
|
|
111
|
+
}
|
|
112
|
+
removeState(name) {
|
|
113
|
+
const state = this.states.get(name);
|
|
114
|
+
if (!state) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (this.activeState?.name === name) {
|
|
118
|
+
this.activeState.stop();
|
|
119
|
+
this.activeState = null;
|
|
120
|
+
}
|
|
121
|
+
return this.states.delete(name);
|
|
122
|
+
}
|
|
123
|
+
getState(name) {
|
|
124
|
+
return this.states.get(name) ?? null;
|
|
125
|
+
}
|
|
126
|
+
hasState(name) {
|
|
127
|
+
return this.states.has(name);
|
|
128
|
+
}
|
|
129
|
+
listStates() {
|
|
130
|
+
return [...this.states.values()];
|
|
131
|
+
}
|
|
132
|
+
getActiveState() {
|
|
133
|
+
return this.activeState;
|
|
134
|
+
}
|
|
135
|
+
switchState(name, autoPlay = true) {
|
|
136
|
+
const next = this.states.get(name) ?? null;
|
|
137
|
+
if (!next) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
if (this.activeState && this.activeState !== next) {
|
|
141
|
+
this.activeState.stop();
|
|
142
|
+
}
|
|
143
|
+
this.activeState = next;
|
|
144
|
+
if (autoPlay) {
|
|
145
|
+
next.play();
|
|
146
|
+
}
|
|
147
|
+
return next;
|
|
148
|
+
}
|
|
149
|
+
playState(name) {
|
|
150
|
+
const state = name ? this.switchState(name, false) : this.activeState;
|
|
151
|
+
if (!state) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
this.activeState = state;
|
|
155
|
+
state.play();
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
pauseState(name) {
|
|
159
|
+
const state = name ? this.states.get(name) : this.activeState;
|
|
160
|
+
if (!state) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
state.pause();
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
stopState(name) {
|
|
167
|
+
const state = name ? this.states.get(name) : this.activeState;
|
|
168
|
+
if (!state) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
state.stop();
|
|
172
|
+
if (!name || this.activeState?.name === name) {
|
|
173
|
+
this.activeState = null;
|
|
174
|
+
}
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
clear() {
|
|
178
|
+
this.stopState();
|
|
179
|
+
this.states.clear();
|
|
180
|
+
this.activeState = null;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
__name(_AnimationStateManager, "AnimationStateManager");
|
|
184
|
+
var AnimationStateManager = _AnimationStateManager;
|
|
185
|
+
|
|
186
|
+
// core/components/Animation.ts
|
|
187
|
+
var _AnimationComponent = class _AnimationComponent extends Component {
|
|
188
|
+
constructor(options = {}) {
|
|
189
|
+
super();
|
|
190
|
+
this.modelClips = Array.isArray(options.clips) ? [...options.clips] : [];
|
|
191
|
+
this.importedClips = [];
|
|
192
|
+
this.clipById = /* @__PURE__ */ new Map();
|
|
193
|
+
this.clipEntriesById = /* @__PURE__ */ new Map();
|
|
194
|
+
this.clips = [];
|
|
195
|
+
this.clipCatalog = [];
|
|
196
|
+
this.availableClips = [];
|
|
197
|
+
this.externalClipSources = [];
|
|
198
|
+
this.setExternalClipSources(options.externalClipSources ?? []);
|
|
199
|
+
this.refreshClipCatalog();
|
|
200
|
+
this.paused = options.paused ?? false;
|
|
201
|
+
this.reverse = options.reverse ?? false;
|
|
202
|
+
this.timeScale = options.timeScale ?? 1;
|
|
203
|
+
this.crossFadeDuration = options.crossFadeDuration ?? 0;
|
|
204
|
+
this.stateManager = new AnimationStateManager();
|
|
205
|
+
this.states = this.stateManager.listStates();
|
|
206
|
+
this.active = this.stateManager.getActiveState();
|
|
207
|
+
this.activeStateName = this.active?.name ?? null;
|
|
208
|
+
if (Array.isArray(options.states) && options.states.length > 0) {
|
|
209
|
+
for (const entry of options.states) {
|
|
210
|
+
this.addState(entry.name, entry.clip, entry.loop ?? false);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (typeof options.activeState === "string" && options.activeState.length > 0) {
|
|
214
|
+
this.switchState(options.activeState, !this.paused);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
refreshClipCatalog() {
|
|
218
|
+
const catalog = [];
|
|
219
|
+
const nameCounts = /* @__PURE__ */ new Map();
|
|
220
|
+
const nextById = /* @__PURE__ */ new Map();
|
|
221
|
+
const nextEntriesById = /* @__PURE__ */ new Map();
|
|
222
|
+
for (const [index, clip] of this.modelClips.entries()) {
|
|
223
|
+
const name = typeof clip?.name === "string" && clip.name.length > 0 ? clip.name : `Clip ${index + 1}`;
|
|
224
|
+
const id = `model:${index}:${name}`;
|
|
225
|
+
const count = (nameCounts.get(name) ?? 0) + 1;
|
|
226
|
+
nameCounts.set(name, count);
|
|
227
|
+
const entry = {
|
|
228
|
+
id,
|
|
229
|
+
name,
|
|
230
|
+
label: count > 1 ? `${name} (${count})` : name,
|
|
231
|
+
clip,
|
|
232
|
+
source: "model",
|
|
233
|
+
sourceUrl: null
|
|
234
|
+
};
|
|
235
|
+
catalog.push(entry);
|
|
236
|
+
nextById.set(id, clip);
|
|
237
|
+
nextEntriesById.set(id, entry);
|
|
238
|
+
}
|
|
239
|
+
for (const [index, imported] of this.importedClips.entries()) {
|
|
240
|
+
const clip = imported.clip;
|
|
241
|
+
const name = typeof clip?.name === "string" && clip.name.length > 0 ? clip.name : `Clip ${index + 1}`;
|
|
242
|
+
const sourceUrl = imported.sourceUrl;
|
|
243
|
+
const id = `external:${index}:${name}`;
|
|
244
|
+
const count = (nameCounts.get(name) ?? 0) + 1;
|
|
245
|
+
nameCounts.set(name, count);
|
|
246
|
+
const sourceSuffix = sourceUrl ? sourceUrl.split("/").pop() ?? sourceUrl : "external";
|
|
247
|
+
const entry = {
|
|
248
|
+
id,
|
|
249
|
+
name,
|
|
250
|
+
label: count > 1 ? `${name} (${count}) \u2022 ${sourceSuffix}` : `${name} \u2022 ${sourceSuffix}`,
|
|
251
|
+
clip,
|
|
252
|
+
source: "external",
|
|
253
|
+
sourceUrl
|
|
254
|
+
};
|
|
255
|
+
catalog.push(entry);
|
|
256
|
+
nextById.set(id, clip);
|
|
257
|
+
nextEntriesById.set(id, entry);
|
|
258
|
+
}
|
|
259
|
+
this.clipById = nextById;
|
|
260
|
+
this.clipEntriesById = nextEntriesById;
|
|
261
|
+
this.clipCatalog = catalog;
|
|
262
|
+
this.clips = catalog.map((entry) => entry.clip);
|
|
263
|
+
this.availableClips = catalog.map((entry) => entry.name);
|
|
264
|
+
}
|
|
265
|
+
refreshStateRefs() {
|
|
266
|
+
this.states = this.stateManager.listStates();
|
|
267
|
+
this.active = this.stateManager.getActiveState();
|
|
268
|
+
this.activeStateName = this.active?.name ?? null;
|
|
269
|
+
}
|
|
270
|
+
resolveClipRef(clipRef) {
|
|
271
|
+
const trimmed = clipRef.trim();
|
|
272
|
+
if (!trimmed) {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
const byId = this.clipById.get(trimmed);
|
|
276
|
+
if (byId) {
|
|
277
|
+
return { id: trimmed, clip: byId };
|
|
278
|
+
}
|
|
279
|
+
const byName = this.clipCatalog.find((entry) => entry.name === trimmed);
|
|
280
|
+
if (!byName) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
return { id: byName.id, clip: byName.clip };
|
|
284
|
+
}
|
|
285
|
+
setModelClips(clips) {
|
|
286
|
+
this.modelClips = Array.isArray(clips) ? [...clips] : [];
|
|
287
|
+
this.refreshClipCatalog();
|
|
288
|
+
}
|
|
289
|
+
setImportedClips(clips) {
|
|
290
|
+
if (!Array.isArray(clips)) {
|
|
291
|
+
this.importedClips = [];
|
|
292
|
+
this.refreshClipCatalog();
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
this.importedClips = clips.map((entry) => {
|
|
296
|
+
if (entry instanceof THREE4__namespace.AnimationClip) {
|
|
297
|
+
return { clip: entry, sourceUrl: null };
|
|
298
|
+
}
|
|
299
|
+
if (!entry || typeof entry !== "object") {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
const candidate = entry;
|
|
303
|
+
if (!(candidate.clip instanceof THREE4__namespace.AnimationClip)) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
clip: candidate.clip,
|
|
308
|
+
sourceUrl: typeof candidate.sourceUrl === "string" && candidate.sourceUrl.length > 0 ? candidate.sourceUrl : null
|
|
309
|
+
};
|
|
310
|
+
}).filter((entry) => entry !== null);
|
|
311
|
+
this.refreshClipCatalog();
|
|
312
|
+
}
|
|
313
|
+
setExternalClipSources(sources) {
|
|
314
|
+
if (!Array.isArray(sources)) {
|
|
315
|
+
this.externalClipSources = [];
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const seen = /* @__PURE__ */ new Set();
|
|
319
|
+
const normalized = [];
|
|
320
|
+
for (const source of sources) {
|
|
321
|
+
if (typeof source !== "string") {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
const trimmed = source.trim();
|
|
325
|
+
if (!trimmed || seen.has(trimmed)) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
seen.add(trimmed);
|
|
329
|
+
normalized.push(trimmed);
|
|
330
|
+
}
|
|
331
|
+
this.externalClipSources = normalized;
|
|
332
|
+
}
|
|
333
|
+
addState(name, clipRef, loop = false) {
|
|
334
|
+
if (!name.trim()) {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
const resolved = this.resolveClipRef(clipRef);
|
|
338
|
+
if (!resolved) {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
const state = this.stateManager.createState(name, resolved.clip, {}, loop, resolved.id);
|
|
342
|
+
this.refreshStateRefs();
|
|
343
|
+
return state;
|
|
344
|
+
}
|
|
345
|
+
setStates(states) {
|
|
346
|
+
const previousActive = this.activeStateName;
|
|
347
|
+
this.stateManager.clear();
|
|
348
|
+
for (const state of states) {
|
|
349
|
+
if (!state.name.trim()) {
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
let createdState = null;
|
|
353
|
+
if (typeof state.clipId === "string" && state.clipId.trim().length > 0) {
|
|
354
|
+
createdState = this.addState(state.name, state.clipId, Boolean(state.loop));
|
|
355
|
+
}
|
|
356
|
+
if (!createdState) {
|
|
357
|
+
this.addState(state.name, state.clip, Boolean(state.loop));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (previousActive) {
|
|
361
|
+
this.stateManager.switchState(previousActive, !this.paused);
|
|
362
|
+
}
|
|
363
|
+
this.refreshStateRefs();
|
|
364
|
+
}
|
|
365
|
+
getStateConfigs() {
|
|
366
|
+
return this.states.map((state) => ({
|
|
367
|
+
name: state.name,
|
|
368
|
+
clip: state.clip.name,
|
|
369
|
+
clipId: state.clipId,
|
|
370
|
+
loop: state.loop
|
|
371
|
+
}));
|
|
372
|
+
}
|
|
373
|
+
setActiveState(name, autoPlay = true) {
|
|
374
|
+
if (!name) {
|
|
375
|
+
const stopped = this.stateManager.stopState();
|
|
376
|
+
this.paused = true;
|
|
377
|
+
this.refreshStateRefs();
|
|
378
|
+
return stopped;
|
|
379
|
+
}
|
|
380
|
+
return this.switchState(name, autoPlay);
|
|
381
|
+
}
|
|
382
|
+
removeState(name) {
|
|
383
|
+
const removed = this.stateManager.removeState(name);
|
|
384
|
+
if (removed) {
|
|
385
|
+
this.refreshStateRefs();
|
|
386
|
+
}
|
|
387
|
+
return removed;
|
|
388
|
+
}
|
|
389
|
+
switchState(name, autoPlay = true) {
|
|
390
|
+
const state = this.stateManager.switchState(name, autoPlay);
|
|
391
|
+
if (!state) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
this.paused = !state.isPlaying;
|
|
395
|
+
this.refreshStateRefs();
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
playState(name) {
|
|
399
|
+
const played = this.stateManager.playState(name);
|
|
400
|
+
if (!played) {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
this.paused = false;
|
|
404
|
+
this.refreshStateRefs();
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
pauseState(name) {
|
|
408
|
+
const paused = this.stateManager.pauseState(name);
|
|
409
|
+
if (!paused) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
this.paused = true;
|
|
413
|
+
this.refreshStateRefs();
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
stopState(name) {
|
|
417
|
+
const stopped = this.stateManager.stopState(name);
|
|
418
|
+
if (!stopped) {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
this.paused = true;
|
|
422
|
+
this.refreshStateRefs();
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
__name(_AnimationComponent, "AnimationComponent");
|
|
427
|
+
var AnimationComponent = _AnimationComponent;
|
|
428
|
+
var DEFAULT_FOV = 50;
|
|
429
|
+
var DEFAULT_NEAR = 0.1;
|
|
430
|
+
var DEFAULT_FAR = 2e3;
|
|
431
|
+
var DEFAULT_ORTHO_LEFT = -5;
|
|
432
|
+
var DEFAULT_ORTHO_RIGHT = 5;
|
|
433
|
+
var DEFAULT_ORTHO_TOP = 5;
|
|
434
|
+
var DEFAULT_ORTHO_BOTTOM = -5;
|
|
435
|
+
var DEFAULT_ZOOM = 1;
|
|
436
|
+
function inferProjection(camera) {
|
|
437
|
+
if (camera instanceof THREE4__namespace.OrthographicCamera) {
|
|
438
|
+
return "orthographic";
|
|
439
|
+
}
|
|
440
|
+
return "perspective";
|
|
441
|
+
}
|
|
442
|
+
__name(inferProjection, "inferProjection");
|
|
443
|
+
function readCameraNear(camera) {
|
|
444
|
+
if (camera && "near" in camera && typeof camera.near === "number" && Number.isFinite(camera.near)) {
|
|
445
|
+
return camera.near;
|
|
446
|
+
}
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
__name(readCameraNear, "readCameraNear");
|
|
450
|
+
function readCameraFar(camera) {
|
|
451
|
+
if (camera && "far" in camera && typeof camera.far === "number" && Number.isFinite(camera.far)) {
|
|
452
|
+
return camera.far;
|
|
453
|
+
}
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
__name(readCameraFar, "readCameraFar");
|
|
457
|
+
function inferFov(camera) {
|
|
458
|
+
if (camera instanceof THREE4__namespace.PerspectiveCamera && Number.isFinite(camera.fov)) {
|
|
459
|
+
return camera.fov;
|
|
460
|
+
}
|
|
461
|
+
return DEFAULT_FOV;
|
|
462
|
+
}
|
|
463
|
+
__name(inferFov, "inferFov");
|
|
464
|
+
function inferNear(camera) {
|
|
465
|
+
const near = readCameraNear(camera);
|
|
466
|
+
if (near !== null) {
|
|
467
|
+
return near;
|
|
468
|
+
}
|
|
469
|
+
return DEFAULT_NEAR;
|
|
470
|
+
}
|
|
471
|
+
__name(inferNear, "inferNear");
|
|
472
|
+
function inferFar(camera) {
|
|
473
|
+
const far = readCameraFar(camera);
|
|
474
|
+
if (far !== null) {
|
|
475
|
+
return far;
|
|
476
|
+
}
|
|
477
|
+
return DEFAULT_FAR;
|
|
478
|
+
}
|
|
479
|
+
__name(inferFar, "inferFar");
|
|
480
|
+
function inferOrthoLeft(camera) {
|
|
481
|
+
if (camera instanceof THREE4__namespace.OrthographicCamera && Number.isFinite(camera.left)) {
|
|
482
|
+
return camera.left;
|
|
483
|
+
}
|
|
484
|
+
return DEFAULT_ORTHO_LEFT;
|
|
485
|
+
}
|
|
486
|
+
__name(inferOrthoLeft, "inferOrthoLeft");
|
|
487
|
+
function inferOrthoRight(camera) {
|
|
488
|
+
if (camera instanceof THREE4__namespace.OrthographicCamera && Number.isFinite(camera.right)) {
|
|
489
|
+
return camera.right;
|
|
490
|
+
}
|
|
491
|
+
return DEFAULT_ORTHO_RIGHT;
|
|
492
|
+
}
|
|
493
|
+
__name(inferOrthoRight, "inferOrthoRight");
|
|
494
|
+
function inferOrthoTop(camera) {
|
|
495
|
+
if (camera instanceof THREE4__namespace.OrthographicCamera && Number.isFinite(camera.top)) {
|
|
496
|
+
return camera.top;
|
|
497
|
+
}
|
|
498
|
+
return DEFAULT_ORTHO_TOP;
|
|
499
|
+
}
|
|
500
|
+
__name(inferOrthoTop, "inferOrthoTop");
|
|
501
|
+
function inferOrthoBottom(camera) {
|
|
502
|
+
if (camera instanceof THREE4__namespace.OrthographicCamera && Number.isFinite(camera.bottom)) {
|
|
503
|
+
return camera.bottom;
|
|
504
|
+
}
|
|
505
|
+
return DEFAULT_ORTHO_BOTTOM;
|
|
506
|
+
}
|
|
507
|
+
__name(inferOrthoBottom, "inferOrthoBottom");
|
|
508
|
+
function inferZoom(camera) {
|
|
509
|
+
if (camera && "zoom" in camera && typeof camera.zoom === "number" && Number.isFinite(camera.zoom)) {
|
|
510
|
+
return camera.zoom;
|
|
511
|
+
}
|
|
512
|
+
return DEFAULT_ZOOM;
|
|
513
|
+
}
|
|
514
|
+
__name(inferZoom, "inferZoom");
|
|
515
|
+
var _CameraComponent = class _CameraComponent extends Component {
|
|
516
|
+
constructor(payload = {}) {
|
|
517
|
+
super();
|
|
518
|
+
this.camera = payload.camera ?? new THREE4__namespace.PerspectiveCamera();
|
|
519
|
+
this.type = payload.type ?? "3d";
|
|
520
|
+
this.isDefault = typeof payload.isDefault === "boolean" ? payload.isDefault : false;
|
|
521
|
+
this.projection = payload.projection ?? inferProjection(payload.camera);
|
|
522
|
+
this.fov = typeof payload.fov === "number" && Number.isFinite(payload.fov) ? payload.fov : inferFov(payload.camera);
|
|
523
|
+
this.near = typeof payload.near === "number" && Number.isFinite(payload.near) ? payload.near : inferNear(payload.camera);
|
|
524
|
+
this.far = typeof payload.far === "number" && Number.isFinite(payload.far) ? payload.far : inferFar(payload.camera);
|
|
525
|
+
this.left = typeof payload.left === "number" && Number.isFinite(payload.left) ? payload.left : inferOrthoLeft(payload.camera);
|
|
526
|
+
this.right = typeof payload.right === "number" && Number.isFinite(payload.right) ? payload.right : inferOrthoRight(payload.camera);
|
|
527
|
+
this.top = typeof payload.top === "number" && Number.isFinite(payload.top) ? payload.top : inferOrthoTop(payload.camera);
|
|
528
|
+
this.bottom = typeof payload.bottom === "number" && Number.isFinite(payload.bottom) ? payload.bottom : inferOrthoBottom(payload.camera);
|
|
529
|
+
this.zoom = typeof payload.zoom === "number" && Number.isFinite(payload.zoom) ? payload.zoom : inferZoom(payload.camera);
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
__name(_CameraComponent, "CameraComponent");
|
|
533
|
+
var CameraComponent = _CameraComponent;
|
|
534
|
+
|
|
535
|
+
// core/components/Audio.ts
|
|
536
|
+
var DEFAULT_AUDIO_OPTIONS = {
|
|
537
|
+
autoplay: false,
|
|
538
|
+
loop: false,
|
|
539
|
+
pitch: 1,
|
|
540
|
+
volume: 1,
|
|
541
|
+
positional: false,
|
|
542
|
+
refDistance: 1,
|
|
543
|
+
distanceModel: "inverse",
|
|
544
|
+
rolloffFactor: 1
|
|
545
|
+
};
|
|
546
|
+
var _AudioComponent = class _AudioComponent extends Component {
|
|
547
|
+
constructor(path, options = {}) {
|
|
548
|
+
super();
|
|
549
|
+
this.path = path;
|
|
550
|
+
this.options = {
|
|
551
|
+
...DEFAULT_AUDIO_OPTIONS,
|
|
552
|
+
...options
|
|
553
|
+
};
|
|
554
|
+
this.object = null;
|
|
555
|
+
this.audio = null;
|
|
556
|
+
Object.defineProperty(this, "isPlaying", {
|
|
557
|
+
value: false,
|
|
558
|
+
writable: true,
|
|
559
|
+
configurable: true,
|
|
560
|
+
enumerable: false
|
|
561
|
+
});
|
|
562
|
+
Object.defineProperty(this, "isPaused", {
|
|
563
|
+
value: false,
|
|
564
|
+
writable: true,
|
|
565
|
+
configurable: true,
|
|
566
|
+
enumerable: false
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Signals `AudioSystem` to start (or resume) playback.
|
|
571
|
+
* Has no direct effect in the editor — `AudioSystem` drives the actual
|
|
572
|
+
* THREE.js call in preview.
|
|
573
|
+
*/
|
|
574
|
+
play() {
|
|
575
|
+
this.isPlaying = true;
|
|
576
|
+
this.isPaused = false;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Signals `AudioSystem` to pause playback, preserving the current position.
|
|
580
|
+
* Calling {@link play} afterwards resumes from where it paused.
|
|
581
|
+
* No-op if not currently playing.
|
|
582
|
+
*/
|
|
583
|
+
pause() {
|
|
584
|
+
if (!this.isPlaying) return;
|
|
585
|
+
this.isPlaying = false;
|
|
586
|
+
this.isPaused = true;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Signals `AudioSystem` to stop playback and reset the playback position.
|
|
590
|
+
*/
|
|
591
|
+
stop() {
|
|
592
|
+
this.isPlaying = false;
|
|
593
|
+
this.isPaused = false;
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
__name(_AudioComponent, "AudioComponent");
|
|
597
|
+
var AudioComponent = _AudioComponent;
|
|
598
|
+
|
|
599
|
+
// core/components/Environment.ts
|
|
600
|
+
var DEFAULT_ENVIRONMENT_STATE = {
|
|
601
|
+
skybox: {
|
|
602
|
+
type: "none",
|
|
603
|
+
color: "#1e1e1e",
|
|
604
|
+
imageUrl: "",
|
|
605
|
+
gradient: {
|
|
606
|
+
colors: ["#464766", "#657ea6", "#0f0e1a"],
|
|
607
|
+
effect: "linear"
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
fog: {
|
|
611
|
+
type: "none",
|
|
612
|
+
color: "#1e1e1e",
|
|
613
|
+
linear: {
|
|
614
|
+
near: 1,
|
|
615
|
+
far: 100
|
|
616
|
+
},
|
|
617
|
+
exponential: {
|
|
618
|
+
density: 2e-3
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
gravity: {
|
|
622
|
+
x: 0,
|
|
623
|
+
y: -9.81,
|
|
624
|
+
z: 0
|
|
625
|
+
},
|
|
626
|
+
fixedTimeStep: 0.02
|
|
627
|
+
};
|
|
628
|
+
function normalizeColors(colors) {
|
|
629
|
+
if (!Array.isArray(colors)) {
|
|
630
|
+
return [...DEFAULT_ENVIRONMENT_STATE.skybox.gradient.colors];
|
|
631
|
+
}
|
|
632
|
+
const normalized = colors.filter(
|
|
633
|
+
(entry) => typeof entry === "string" && entry.length > 0
|
|
634
|
+
);
|
|
635
|
+
if (normalized.length === 0) {
|
|
636
|
+
return [...DEFAULT_ENVIRONMENT_STATE.skybox.gradient.colors];
|
|
637
|
+
}
|
|
638
|
+
return normalized;
|
|
639
|
+
}
|
|
640
|
+
__name(normalizeColors, "normalizeColors");
|
|
641
|
+
function normalizeGradientEffect(value) {
|
|
642
|
+
if (value === "radial" || value === "linear" || value === "angular") {
|
|
643
|
+
return value;
|
|
644
|
+
}
|
|
645
|
+
return DEFAULT_ENVIRONMENT_STATE.skybox.gradient.effect;
|
|
646
|
+
}
|
|
647
|
+
__name(normalizeGradientEffect, "normalizeGradientEffect");
|
|
648
|
+
function normalizeSkyboxType(value) {
|
|
649
|
+
if (value === "gradient" || value === "color" || value === "none") {
|
|
650
|
+
return value;
|
|
651
|
+
}
|
|
652
|
+
if (value === "image" || value === "Image") {
|
|
653
|
+
return "image";
|
|
654
|
+
}
|
|
655
|
+
return DEFAULT_ENVIRONMENT_STATE.skybox.type;
|
|
656
|
+
}
|
|
657
|
+
__name(normalizeSkyboxType, "normalizeSkyboxType");
|
|
658
|
+
function normalizeFogType(value) {
|
|
659
|
+
if (value === "linear" || value === "exponential" || value === "none") {
|
|
660
|
+
return value;
|
|
661
|
+
}
|
|
662
|
+
return DEFAULT_ENVIRONMENT_STATE.fog.type;
|
|
663
|
+
}
|
|
664
|
+
__name(normalizeFogType, "normalizeFogType");
|
|
665
|
+
function toFiniteNumber(value, fallback) {
|
|
666
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
667
|
+
return fallback;
|
|
668
|
+
}
|
|
669
|
+
return value;
|
|
670
|
+
}
|
|
671
|
+
__name(toFiniteNumber, "toFiniteNumber");
|
|
672
|
+
var _Environment = class _Environment extends Component {
|
|
673
|
+
constructor(values) {
|
|
674
|
+
super();
|
|
675
|
+
const skybox = values?.skybox;
|
|
676
|
+
const fog = values?.fog;
|
|
677
|
+
const gravity = values?.gravity;
|
|
678
|
+
this.values = {
|
|
679
|
+
skybox: {
|
|
680
|
+
type: normalizeSkyboxType(skybox?.type),
|
|
681
|
+
color: typeof skybox?.color === "string" ? skybox.color : DEFAULT_ENVIRONMENT_STATE.skybox.color,
|
|
682
|
+
imageUrl: typeof skybox?.imageUrl === "string" ? skybox.imageUrl : DEFAULT_ENVIRONMENT_STATE.skybox.imageUrl,
|
|
683
|
+
gradient: {
|
|
684
|
+
colors: normalizeColors(skybox?.gradient?.colors),
|
|
685
|
+
effect: normalizeGradientEffect(skybox?.gradient?.effect)
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
fog: {
|
|
689
|
+
type: normalizeFogType(fog?.type),
|
|
690
|
+
color: typeof fog?.color === "string" ? fog.color : DEFAULT_ENVIRONMENT_STATE.fog.color,
|
|
691
|
+
linear: {
|
|
692
|
+
near: toFiniteNumber(
|
|
693
|
+
fog?.linear?.near,
|
|
694
|
+
DEFAULT_ENVIRONMENT_STATE.fog.linear.near
|
|
695
|
+
),
|
|
696
|
+
far: toFiniteNumber(
|
|
697
|
+
fog?.linear?.far,
|
|
698
|
+
DEFAULT_ENVIRONMENT_STATE.fog.linear.far
|
|
699
|
+
)
|
|
700
|
+
},
|
|
701
|
+
exponential: {
|
|
702
|
+
density: toFiniteNumber(
|
|
703
|
+
fog?.exponential?.density,
|
|
704
|
+
DEFAULT_ENVIRONMENT_STATE.fog.exponential.density
|
|
705
|
+
)
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
gravity: {
|
|
709
|
+
x: toFiniteNumber(gravity?.x, DEFAULT_ENVIRONMENT_STATE.gravity.x),
|
|
710
|
+
y: toFiniteNumber(gravity?.y, DEFAULT_ENVIRONMENT_STATE.gravity.y),
|
|
711
|
+
z: toFiniteNumber(gravity?.z, DEFAULT_ENVIRONMENT_STATE.gravity.z)
|
|
712
|
+
},
|
|
713
|
+
fixedTimeStep: toFiniteNumber(
|
|
714
|
+
values?.fixedTimeStep,
|
|
715
|
+
DEFAULT_ENVIRONMENT_STATE.fixedTimeStep
|
|
716
|
+
)
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
__name(_Environment, "Environment");
|
|
721
|
+
var Environment = _Environment;
|
|
722
|
+
|
|
723
|
+
// core/components/Postprocessing.ts
|
|
724
|
+
var DEFAULT_POSTPROCESSING_STATE = {
|
|
725
|
+
postEnabled: false,
|
|
726
|
+
dof: {
|
|
727
|
+
enabled: false,
|
|
728
|
+
focusDistance: 0.015,
|
|
729
|
+
focalLength: 0.018,
|
|
730
|
+
bokehScale: 3
|
|
731
|
+
},
|
|
732
|
+
bloom: {
|
|
733
|
+
enabled: false,
|
|
734
|
+
intensity: 1.2,
|
|
735
|
+
threshold: 0.2,
|
|
736
|
+
radius: 0.7
|
|
737
|
+
},
|
|
738
|
+
vignette: {
|
|
739
|
+
enabled: false,
|
|
740
|
+
offset: 0.05,
|
|
741
|
+
darkness: 1.2
|
|
742
|
+
},
|
|
743
|
+
chromAberration: {
|
|
744
|
+
enabled: false,
|
|
745
|
+
offsetX: 3e-3,
|
|
746
|
+
offsetY: 3e-3
|
|
747
|
+
},
|
|
748
|
+
noise: {
|
|
749
|
+
enabled: false,
|
|
750
|
+
opacity: 0.12
|
|
751
|
+
},
|
|
752
|
+
pixelation: {
|
|
753
|
+
enabled: false,
|
|
754
|
+
granularity: 6
|
|
755
|
+
},
|
|
756
|
+
toneMapping: {
|
|
757
|
+
enabled: false,
|
|
758
|
+
exposure: 1.3
|
|
759
|
+
},
|
|
760
|
+
hueSaturation: {
|
|
761
|
+
enabled: false,
|
|
762
|
+
hue: 0.05,
|
|
763
|
+
saturation: 0.2
|
|
764
|
+
},
|
|
765
|
+
sepia: {
|
|
766
|
+
enabled: false,
|
|
767
|
+
intensity: 0.5
|
|
768
|
+
},
|
|
769
|
+
smaa: {
|
|
770
|
+
enabled: false
|
|
771
|
+
},
|
|
772
|
+
ssao: {
|
|
773
|
+
enabled: false,
|
|
774
|
+
intensity: 1.5,
|
|
775
|
+
radius: 0.25
|
|
776
|
+
},
|
|
777
|
+
dotScreen: {
|
|
778
|
+
enabled: false,
|
|
779
|
+
dotScreenScale: 1.2,
|
|
780
|
+
dotScreenAngle: 1.57,
|
|
781
|
+
scale: 1.2,
|
|
782
|
+
angle: 1.57,
|
|
783
|
+
blendFunction: void 0,
|
|
784
|
+
opacity: void 0
|
|
785
|
+
},
|
|
786
|
+
glitch: {
|
|
787
|
+
enabled: false,
|
|
788
|
+
blendFunction: void 0,
|
|
789
|
+
chromaticAberrationOffset: void 0,
|
|
790
|
+
delay: void 0,
|
|
791
|
+
duration: void 0,
|
|
792
|
+
strength: void 0,
|
|
793
|
+
dtSize: void 0,
|
|
794
|
+
columns: void 0,
|
|
795
|
+
ratio: void 0,
|
|
796
|
+
mode: void 0,
|
|
797
|
+
active: void 0
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
function asRecord(value) {
|
|
801
|
+
if (!value || typeof value !== "object") {
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
804
|
+
return value;
|
|
805
|
+
}
|
|
806
|
+
__name(asRecord, "asRecord");
|
|
807
|
+
function toFiniteNumber2(value, fallback) {
|
|
808
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
809
|
+
return fallback;
|
|
810
|
+
}
|
|
811
|
+
return value;
|
|
812
|
+
}
|
|
813
|
+
__name(toFiniteNumber2, "toFiniteNumber");
|
|
814
|
+
function toBoolean(value, fallback) {
|
|
815
|
+
if (typeof value !== "boolean") {
|
|
816
|
+
return fallback;
|
|
817
|
+
}
|
|
818
|
+
return value;
|
|
819
|
+
}
|
|
820
|
+
__name(toBoolean, "toBoolean");
|
|
821
|
+
function normalizeNumberTuple(value) {
|
|
822
|
+
if (!Array.isArray(value) || value.length !== 2) {
|
|
823
|
+
return void 0;
|
|
824
|
+
}
|
|
825
|
+
if (typeof value[0] !== "number" || !Number.isFinite(value[0]) || typeof value[1] !== "number" || !Number.isFinite(value[1])) {
|
|
826
|
+
return void 0;
|
|
827
|
+
}
|
|
828
|
+
return [value[0], value[1]];
|
|
829
|
+
}
|
|
830
|
+
__name(normalizeNumberTuple, "normalizeNumberTuple");
|
|
831
|
+
function normalizePostprocessing(value) {
|
|
832
|
+
const postprocessing = asRecord(value);
|
|
833
|
+
const defaults = DEFAULT_POSTPROCESSING_STATE;
|
|
834
|
+
const dof = asRecord(postprocessing?.dof);
|
|
835
|
+
const bloom = asRecord(postprocessing?.bloom);
|
|
836
|
+
const vignette = asRecord(postprocessing?.vignette);
|
|
837
|
+
const chromAberration = asRecord(postprocessing?.chromAberration);
|
|
838
|
+
const noise = asRecord(postprocessing?.noise);
|
|
839
|
+
const pixelation = asRecord(postprocessing?.pixelation);
|
|
840
|
+
const toneMapping = asRecord(postprocessing?.toneMapping);
|
|
841
|
+
const hueSaturation = asRecord(postprocessing?.hueSaturation);
|
|
842
|
+
const sepia = asRecord(postprocessing?.sepia);
|
|
843
|
+
const smaa = asRecord(postprocessing?.smaa);
|
|
844
|
+
const ssao = asRecord(postprocessing?.ssao);
|
|
845
|
+
const dotScreen = asRecord(postprocessing?.dotScreen);
|
|
846
|
+
const glitch = asRecord(postprocessing?.glitch);
|
|
847
|
+
const glitchChromaticAberrationOffset = asRecord(
|
|
848
|
+
glitch?.chromaticAberrationOffset
|
|
849
|
+
);
|
|
850
|
+
const glitchStrength = asRecord(glitch?.strength);
|
|
851
|
+
const dotScreenScale = toFiniteNumber2(
|
|
852
|
+
dotScreen?.dotScreenScale,
|
|
853
|
+
defaults.dotScreen.dotScreenScale
|
|
854
|
+
);
|
|
855
|
+
const dotScreenAngle = toFiniteNumber2(
|
|
856
|
+
dotScreen?.dotScreenAngle,
|
|
857
|
+
defaults.dotScreen.dotScreenAngle
|
|
858
|
+
);
|
|
859
|
+
const normalizedGlitchStrength = typeof glitch?.strength === "number" && Number.isFinite(glitch.strength) ? glitch.strength : glitchStrength && typeof glitchStrength.x === "number" && Number.isFinite(glitchStrength.x) && typeof glitchStrength.y === "number" && Number.isFinite(glitchStrength.y) ? { x: glitchStrength.x, y: glitchStrength.y } : void 0;
|
|
860
|
+
const normalizedGlitchChromaticAberrationOffset = normalizeNumberTuple(glitch?.chromaticAberrationOffset) ?? (glitchChromaticAberrationOffset && typeof glitchChromaticAberrationOffset.x === "number" && Number.isFinite(glitchChromaticAberrationOffset.x) && typeof glitchChromaticAberrationOffset.y === "number" && Number.isFinite(glitchChromaticAberrationOffset.y) ? {
|
|
861
|
+
x: glitchChromaticAberrationOffset.x,
|
|
862
|
+
y: glitchChromaticAberrationOffset.y
|
|
863
|
+
} : void 0);
|
|
864
|
+
return {
|
|
865
|
+
postEnabled: toBoolean(postprocessing?.postEnabled, defaults.postEnabled),
|
|
866
|
+
dof: {
|
|
867
|
+
enabled: toBoolean(dof?.enabled, defaults.dof.enabled),
|
|
868
|
+
focusDistance: toFiniteNumber2(dof?.focusDistance, defaults.dof.focusDistance),
|
|
869
|
+
focalLength: toFiniteNumber2(dof?.focalLength, defaults.dof.focalLength),
|
|
870
|
+
bokehScale: toFiniteNumber2(dof?.bokehScale, defaults.dof.bokehScale)
|
|
871
|
+
},
|
|
872
|
+
bloom: {
|
|
873
|
+
enabled: toBoolean(bloom?.enabled, defaults.bloom.enabled),
|
|
874
|
+
intensity: toFiniteNumber2(bloom?.intensity, defaults.bloom.intensity),
|
|
875
|
+
threshold: toFiniteNumber2(bloom?.threshold, defaults.bloom.threshold),
|
|
876
|
+
radius: toFiniteNumber2(bloom?.radius, defaults.bloom.radius)
|
|
877
|
+
},
|
|
878
|
+
vignette: {
|
|
879
|
+
enabled: toBoolean(vignette?.enabled, defaults.vignette.enabled),
|
|
880
|
+
offset: toFiniteNumber2(vignette?.offset, defaults.vignette.offset),
|
|
881
|
+
darkness: toFiniteNumber2(vignette?.darkness, defaults.vignette.darkness)
|
|
882
|
+
},
|
|
883
|
+
chromAberration: {
|
|
884
|
+
enabled: toBoolean(chromAberration?.enabled, defaults.chromAberration.enabled),
|
|
885
|
+
offsetX: toFiniteNumber2(chromAberration?.offsetX, defaults.chromAberration.offsetX),
|
|
886
|
+
offsetY: toFiniteNumber2(chromAberration?.offsetY, defaults.chromAberration.offsetY)
|
|
887
|
+
},
|
|
888
|
+
noise: {
|
|
889
|
+
enabled: toBoolean(noise?.enabled, defaults.noise.enabled),
|
|
890
|
+
opacity: toFiniteNumber2(noise?.opacity, defaults.noise.opacity)
|
|
891
|
+
},
|
|
892
|
+
pixelation: {
|
|
893
|
+
enabled: toBoolean(pixelation?.enabled, defaults.pixelation.enabled),
|
|
894
|
+
granularity: toFiniteNumber2(pixelation?.granularity, defaults.pixelation.granularity)
|
|
895
|
+
},
|
|
896
|
+
toneMapping: {
|
|
897
|
+
enabled: toBoolean(toneMapping?.enabled, defaults.toneMapping.enabled),
|
|
898
|
+
exposure: toFiniteNumber2(toneMapping?.exposure, defaults.toneMapping.exposure)
|
|
899
|
+
},
|
|
900
|
+
hueSaturation: {
|
|
901
|
+
enabled: toBoolean(hueSaturation?.enabled, defaults.hueSaturation.enabled),
|
|
902
|
+
hue: toFiniteNumber2(hueSaturation?.hue, defaults.hueSaturation.hue),
|
|
903
|
+
saturation: toFiniteNumber2(
|
|
904
|
+
hueSaturation?.saturation,
|
|
905
|
+
defaults.hueSaturation.saturation
|
|
906
|
+
)
|
|
907
|
+
},
|
|
908
|
+
sepia: {
|
|
909
|
+
enabled: toBoolean(sepia?.enabled, defaults.sepia.enabled),
|
|
910
|
+
intensity: toFiniteNumber2(sepia?.intensity, defaults.sepia.intensity)
|
|
911
|
+
},
|
|
912
|
+
smaa: {
|
|
913
|
+
enabled: toBoolean(smaa?.enabled, defaults.smaa.enabled)
|
|
914
|
+
},
|
|
915
|
+
ssao: {
|
|
916
|
+
enabled: toBoolean(ssao?.enabled, defaults.ssao.enabled),
|
|
917
|
+
intensity: toFiniteNumber2(ssao?.intensity, defaults.ssao.intensity),
|
|
918
|
+
radius: toFiniteNumber2(ssao?.radius, defaults.ssao.radius)
|
|
919
|
+
},
|
|
920
|
+
dotScreen: {
|
|
921
|
+
enabled: toBoolean(dotScreen?.enabled, defaults.dotScreen.enabled),
|
|
922
|
+
dotScreenScale,
|
|
923
|
+
dotScreenAngle,
|
|
924
|
+
scale: toFiniteNumber2(dotScreen?.scale, dotScreenScale),
|
|
925
|
+
angle: toFiniteNumber2(dotScreen?.angle, dotScreenAngle),
|
|
926
|
+
blendFunction: typeof dotScreen?.blendFunction === "number" && Number.isFinite(dotScreen.blendFunction) ? dotScreen.blendFunction : defaults.dotScreen.blendFunction,
|
|
927
|
+
opacity: typeof dotScreen?.opacity === "number" && Number.isFinite(dotScreen.opacity) ? dotScreen.opacity : defaults.dotScreen.opacity
|
|
928
|
+
},
|
|
929
|
+
glitch: {
|
|
930
|
+
enabled: toBoolean(glitch?.enabled, defaults.glitch.enabled),
|
|
931
|
+
blendFunction: typeof glitch?.blendFunction === "number" && Number.isFinite(glitch.blendFunction) ? glitch.blendFunction : defaults.glitch.blendFunction,
|
|
932
|
+
chromaticAberrationOffset: normalizedGlitchChromaticAberrationOffset,
|
|
933
|
+
delay: normalizeNumberTuple(glitch?.delay) ?? defaults.glitch.delay,
|
|
934
|
+
duration: normalizeNumberTuple(glitch?.duration) ?? defaults.glitch.duration,
|
|
935
|
+
strength: normalizedGlitchStrength,
|
|
936
|
+
dtSize: typeof glitch?.dtSize === "number" && Number.isFinite(glitch.dtSize) ? glitch.dtSize : defaults.glitch.dtSize,
|
|
937
|
+
columns: typeof glitch?.columns === "number" && Number.isFinite(glitch.columns) ? glitch.columns : defaults.glitch.columns,
|
|
938
|
+
ratio: typeof glitch?.ratio === "number" && Number.isFinite(glitch.ratio) ? glitch.ratio : defaults.glitch.ratio,
|
|
939
|
+
mode: typeof glitch?.mode === "string" ? glitch.mode : defaults.glitch.mode,
|
|
940
|
+
active: toBoolean(glitch?.active, defaults.glitch.active ?? false)
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
__name(normalizePostprocessing, "normalizePostprocessing");
|
|
945
|
+
var _Postprocessing = class _Postprocessing extends Component {
|
|
946
|
+
constructor(values) {
|
|
947
|
+
super();
|
|
948
|
+
this.values = normalizePostprocessing(values);
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
__name(_Postprocessing, "Postprocessing");
|
|
952
|
+
var Postprocessing = _Postprocessing;
|
|
953
|
+
|
|
954
|
+
// core/components/Physics.ts
|
|
955
|
+
var DEFAULT_RIGIDBODY_STATE = {
|
|
956
|
+
enabled: true,
|
|
957
|
+
type: "dynamic",
|
|
958
|
+
mass: 1,
|
|
959
|
+
linearDamping: 0,
|
|
960
|
+
angularDamping: 0,
|
|
961
|
+
gravityScale: 1,
|
|
962
|
+
canSleep: true,
|
|
963
|
+
ccdEnabled: false,
|
|
964
|
+
lockTranslations: false,
|
|
965
|
+
lockTranslationX: false,
|
|
966
|
+
lockTranslationY: false,
|
|
967
|
+
lockTranslationZ: false,
|
|
968
|
+
lockRotations: false,
|
|
969
|
+
lockRotationX: false,
|
|
970
|
+
lockRotationY: false,
|
|
971
|
+
lockRotationZ: false
|
|
972
|
+
};
|
|
973
|
+
var DEFAULT_COLLIDER_STATE = {
|
|
974
|
+
enabled: true,
|
|
975
|
+
shape: "cuboid",
|
|
976
|
+
offsetPosition: {
|
|
977
|
+
x: 0,
|
|
978
|
+
y: 0,
|
|
979
|
+
z: 0
|
|
980
|
+
},
|
|
981
|
+
offsetRotation: {
|
|
982
|
+
x: 0,
|
|
983
|
+
y: 0,
|
|
984
|
+
z: 0
|
|
985
|
+
},
|
|
986
|
+
size: {
|
|
987
|
+
x: 1,
|
|
988
|
+
y: 1,
|
|
989
|
+
z: 1
|
|
990
|
+
},
|
|
991
|
+
radius: 0.5,
|
|
992
|
+
height: 1,
|
|
993
|
+
restitution: 0,
|
|
994
|
+
friction: 0.5,
|
|
995
|
+
isSensor: false
|
|
996
|
+
};
|
|
997
|
+
var DEFAULT_PHYSICS_STATE = {
|
|
998
|
+
rigidbody: DEFAULT_RIGIDBODY_STATE,
|
|
999
|
+
collider: DEFAULT_COLLIDER_STATE
|
|
1000
|
+
};
|
|
1001
|
+
function asRecord2(value) {
|
|
1002
|
+
if (!value || typeof value !== "object") {
|
|
1003
|
+
return null;
|
|
1004
|
+
}
|
|
1005
|
+
return value;
|
|
1006
|
+
}
|
|
1007
|
+
__name(asRecord2, "asRecord");
|
|
1008
|
+
function toFiniteNumber3(value, fallback) {
|
|
1009
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1010
|
+
return fallback;
|
|
1011
|
+
}
|
|
1012
|
+
return value;
|
|
1013
|
+
}
|
|
1014
|
+
__name(toFiniteNumber3, "toFiniteNumber");
|
|
1015
|
+
function toBoolean2(value, fallback) {
|
|
1016
|
+
if (typeof value !== "boolean") {
|
|
1017
|
+
return fallback;
|
|
1018
|
+
}
|
|
1019
|
+
return value;
|
|
1020
|
+
}
|
|
1021
|
+
__name(toBoolean2, "toBoolean");
|
|
1022
|
+
function toRigidbodyType(value, fallback) {
|
|
1023
|
+
if (value === "dynamic" || value === "fixed" || value === "kinematicPosition" || value === "kinematicVelocity") {
|
|
1024
|
+
return value;
|
|
1025
|
+
}
|
|
1026
|
+
return fallback;
|
|
1027
|
+
}
|
|
1028
|
+
__name(toRigidbodyType, "toRigidbodyType");
|
|
1029
|
+
function toColliderShape(value, fallback) {
|
|
1030
|
+
if (value === "cuboid" || value === "ball" || value === "capsule" || value === "cylinder" || value === "trimesh") {
|
|
1031
|
+
return value;
|
|
1032
|
+
}
|
|
1033
|
+
return fallback;
|
|
1034
|
+
}
|
|
1035
|
+
__name(toColliderShape, "toColliderShape");
|
|
1036
|
+
function normalizeRigidbodyState(value) {
|
|
1037
|
+
const source = asRecord2(value);
|
|
1038
|
+
const defaults = DEFAULT_RIGIDBODY_STATE;
|
|
1039
|
+
const legacyLockTranslations = toBoolean2(
|
|
1040
|
+
source?.lockTranslations,
|
|
1041
|
+
defaults.lockTranslations
|
|
1042
|
+
);
|
|
1043
|
+
const legacyLockRotations = toBoolean2(
|
|
1044
|
+
source?.lockRotations,
|
|
1045
|
+
defaults.lockRotations
|
|
1046
|
+
);
|
|
1047
|
+
const lockTranslationX = toBoolean2(
|
|
1048
|
+
source?.lockTranslationX,
|
|
1049
|
+
legacyLockTranslations
|
|
1050
|
+
);
|
|
1051
|
+
const lockTranslationY = toBoolean2(
|
|
1052
|
+
source?.lockTranslationY,
|
|
1053
|
+
legacyLockTranslations
|
|
1054
|
+
);
|
|
1055
|
+
const lockTranslationZ = toBoolean2(
|
|
1056
|
+
source?.lockTranslationZ,
|
|
1057
|
+
legacyLockTranslations
|
|
1058
|
+
);
|
|
1059
|
+
const lockRotationX = toBoolean2(source?.lockRotationX, legacyLockRotations);
|
|
1060
|
+
const lockRotationY = toBoolean2(source?.lockRotationY, legacyLockRotations);
|
|
1061
|
+
const lockRotationZ = toBoolean2(source?.lockRotationZ, legacyLockRotations);
|
|
1062
|
+
return {
|
|
1063
|
+
enabled: toBoolean2(source?.enabled, defaults.enabled),
|
|
1064
|
+
type: toRigidbodyType(source?.type, defaults.type),
|
|
1065
|
+
mass: Math.max(1e-4, toFiniteNumber3(source?.mass, defaults.mass)),
|
|
1066
|
+
linearDamping: Math.max(
|
|
1067
|
+
0,
|
|
1068
|
+
toFiniteNumber3(source?.linearDamping, defaults.linearDamping)
|
|
1069
|
+
),
|
|
1070
|
+
angularDamping: Math.max(
|
|
1071
|
+
0,
|
|
1072
|
+
toFiniteNumber3(source?.angularDamping, defaults.angularDamping)
|
|
1073
|
+
),
|
|
1074
|
+
gravityScale: toFiniteNumber3(source?.gravityScale, defaults.gravityScale),
|
|
1075
|
+
canSleep: toBoolean2(source?.canSleep, defaults.canSleep),
|
|
1076
|
+
ccdEnabled: toBoolean2(source?.ccdEnabled, defaults.ccdEnabled),
|
|
1077
|
+
lockTranslations: legacyLockTranslations,
|
|
1078
|
+
lockTranslationX,
|
|
1079
|
+
lockTranslationY,
|
|
1080
|
+
lockTranslationZ,
|
|
1081
|
+
lockRotations: legacyLockRotations,
|
|
1082
|
+
lockRotationX,
|
|
1083
|
+
lockRotationY,
|
|
1084
|
+
lockRotationZ
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
__name(normalizeRigidbodyState, "normalizeRigidbodyState");
|
|
1088
|
+
function normalizeColliderState(value) {
|
|
1089
|
+
const source = asRecord2(value);
|
|
1090
|
+
const defaults = DEFAULT_COLLIDER_STATE;
|
|
1091
|
+
const offsetPosition = asRecord2(source?.offsetPosition);
|
|
1092
|
+
const offsetRotation = asRecord2(source?.offsetRotation);
|
|
1093
|
+
const size = asRecord2(source?.size);
|
|
1094
|
+
return {
|
|
1095
|
+
enabled: toBoolean2(source?.enabled, defaults.enabled),
|
|
1096
|
+
shape: toColliderShape(source?.shape, defaults.shape),
|
|
1097
|
+
offsetPosition: {
|
|
1098
|
+
x: toFiniteNumber3(offsetPosition?.x, defaults.offsetPosition.x),
|
|
1099
|
+
y: toFiniteNumber3(offsetPosition?.y, defaults.offsetPosition.y),
|
|
1100
|
+
z: toFiniteNumber3(offsetPosition?.z, defaults.offsetPosition.z)
|
|
1101
|
+
},
|
|
1102
|
+
offsetRotation: {
|
|
1103
|
+
x: toFiniteNumber3(offsetRotation?.x, defaults.offsetRotation.x),
|
|
1104
|
+
y: toFiniteNumber3(offsetRotation?.y, defaults.offsetRotation.y),
|
|
1105
|
+
z: toFiniteNumber3(offsetRotation?.z, defaults.offsetRotation.z)
|
|
1106
|
+
},
|
|
1107
|
+
size: {
|
|
1108
|
+
x: Math.max(1e-4, toFiniteNumber3(size?.x, defaults.size.x)),
|
|
1109
|
+
y: Math.max(1e-4, toFiniteNumber3(size?.y, defaults.size.y)),
|
|
1110
|
+
z: Math.max(1e-4, toFiniteNumber3(size?.z, defaults.size.z))
|
|
1111
|
+
},
|
|
1112
|
+
radius: Math.max(1e-4, toFiniteNumber3(source?.radius, defaults.radius)),
|
|
1113
|
+
height: Math.max(1e-4, toFiniteNumber3(source?.height, defaults.height)),
|
|
1114
|
+
restitution: Math.max(0, toFiniteNumber3(source?.restitution, defaults.restitution)),
|
|
1115
|
+
friction: Math.max(0, toFiniteNumber3(source?.friction, defaults.friction)),
|
|
1116
|
+
isSensor: toBoolean2(source?.isSensor, defaults.isSensor)
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
__name(normalizeColliderState, "normalizeColliderState");
|
|
1120
|
+
function normalizePhysicsState(value) {
|
|
1121
|
+
const source = asRecord2(value);
|
|
1122
|
+
return {
|
|
1123
|
+
rigidbody: normalizeRigidbodyState(
|
|
1124
|
+
source?.rigidbody ?? void 0
|
|
1125
|
+
),
|
|
1126
|
+
collider: normalizeColliderState(
|
|
1127
|
+
source?.collider ?? void 0
|
|
1128
|
+
)
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
__name(normalizePhysicsState, "normalizePhysicsState");
|
|
1132
|
+
var _PhysicsComponent = class _PhysicsComponent extends Component {
|
|
1133
|
+
constructor(values) {
|
|
1134
|
+
super();
|
|
1135
|
+
this.values = normalizePhysicsState(values);
|
|
1136
|
+
this.rigidBody = null;
|
|
1137
|
+
this.collider = null;
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Patch rigidbody and/or collider state. Each sub-object is deep-merged
|
|
1141
|
+
* with the current values via the respective normalizer.
|
|
1142
|
+
*/
|
|
1143
|
+
setValues(patch) {
|
|
1144
|
+
this.values = normalizePhysicsState({
|
|
1145
|
+
rigidbody: { ...this.values.rigidbody, ...patch.rigidbody ?? {} },
|
|
1146
|
+
collider: { ...this.values.collider, ...patch.collider ?? {} }
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
__name(_PhysicsComponent, "PhysicsComponent");
|
|
1151
|
+
var PhysicsComponent = _PhysicsComponent;
|
|
1152
|
+
|
|
1153
|
+
// core/components/EntityType.ts
|
|
1154
|
+
var _EntityType = class _EntityType extends Component {
|
|
1155
|
+
constructor(value) {
|
|
1156
|
+
super();
|
|
1157
|
+
this.value = value;
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
1160
|
+
__name(_EntityType, "EntityType");
|
|
1161
|
+
var EntityType = _EntityType;
|
|
1162
|
+
|
|
1163
|
+
// core/components/Image.ts
|
|
1164
|
+
var _ImageComponent = class _ImageComponent extends Component {
|
|
1165
|
+
constructor(path, width = 1, height = 1) {
|
|
1166
|
+
super();
|
|
1167
|
+
this.path = path;
|
|
1168
|
+
this.width = width;
|
|
1169
|
+
this.height = height;
|
|
1170
|
+
this.texture = null;
|
|
1171
|
+
this.object = null;
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
__name(_ImageComponent, "ImageComponent");
|
|
1175
|
+
var ImageComponent = _ImageComponent;
|
|
1176
|
+
|
|
1177
|
+
// core/components/ImageTarget.ts
|
|
1178
|
+
var _ImageTarget = class _ImageTarget extends Component {
|
|
1179
|
+
constructor(options, texture, object) {
|
|
1180
|
+
super();
|
|
1181
|
+
this.targets = options?.targets ?? [];
|
|
1182
|
+
this.compiledTargetUrl = options?.compiledTargetUrl;
|
|
1183
|
+
this.compiledTargetDir = options?.compiledTargetDir;
|
|
1184
|
+
this.texture = texture ?? null;
|
|
1185
|
+
this.object = object ?? null;
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
__name(_ImageTarget, "ImageTarget");
|
|
1189
|
+
var ImageTarget = _ImageTarget;
|
|
1190
|
+
|
|
1191
|
+
// core/components/ImageTargetAnchor.ts
|
|
1192
|
+
var _ImageTargetAnchor = class _ImageTargetAnchor extends Component {
|
|
1193
|
+
constructor(options) {
|
|
1194
|
+
super();
|
|
1195
|
+
this.targetId = options?.targetId ?? null;
|
|
1196
|
+
this.targetUrl = options?.targetUrl;
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
__name(_ImageTargetAnchor, "ImageTargetAnchor");
|
|
1200
|
+
var ImageTargetAnchor = _ImageTargetAnchor;
|
|
1201
|
+
function toHexColor(value) {
|
|
1202
|
+
return `#${value.getHexString()}`;
|
|
1203
|
+
}
|
|
1204
|
+
__name(toHexColor, "toHexColor");
|
|
1205
|
+
function createValueState(light) {
|
|
1206
|
+
const base = {
|
|
1207
|
+
color: toHexColor(light.color),
|
|
1208
|
+
intensity: light.intensity,
|
|
1209
|
+
castShadow: light.castShadow ?? false,
|
|
1210
|
+
frustumCulling: light.frustumCulled
|
|
1211
|
+
};
|
|
1212
|
+
if (light instanceof THREE4__namespace.PointLight) {
|
|
1213
|
+
base.distance = light.distance;
|
|
1214
|
+
base.decay = light.decay;
|
|
1215
|
+
} else if (light instanceof THREE4__namespace.SpotLight) {
|
|
1216
|
+
base.distance = light.distance;
|
|
1217
|
+
base.decay = light.decay;
|
|
1218
|
+
base.angle = light.angle;
|
|
1219
|
+
base.penumbra = light.penumbra;
|
|
1220
|
+
} else if (light instanceof THREE4__namespace.RectAreaLight) {
|
|
1221
|
+
base.width = light.width;
|
|
1222
|
+
base.height = light.height;
|
|
1223
|
+
}
|
|
1224
|
+
return base;
|
|
1225
|
+
}
|
|
1226
|
+
__name(createValueState, "createValueState");
|
|
1227
|
+
var _LightComponent = class _LightComponent extends Component {
|
|
1228
|
+
constructor(light) {
|
|
1229
|
+
super();
|
|
1230
|
+
this.light = light;
|
|
1231
|
+
this.type = light.type;
|
|
1232
|
+
this.values = createValueState(light);
|
|
1233
|
+
}
|
|
1234
|
+
setValues(patch) {
|
|
1235
|
+
this.values = {
|
|
1236
|
+
...this.values,
|
|
1237
|
+
...patch
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
__name(_LightComponent, "LightComponent");
|
|
1242
|
+
var LightComponent = _LightComponent;
|
|
1243
|
+
function toHexColor2(value, fallback) {
|
|
1244
|
+
if (value && typeof value === "object" && typeof value.getHexString === "function") {
|
|
1245
|
+
try {
|
|
1246
|
+
return `#${value.getHexString()}`;
|
|
1247
|
+
} catch {
|
|
1248
|
+
return fallback;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
return fallback;
|
|
1252
|
+
}
|
|
1253
|
+
__name(toHexColor2, "toHexColor");
|
|
1254
|
+
function getMaterialType(material) {
|
|
1255
|
+
if (material instanceof THREE4__namespace.MeshPhysicalMaterial) {
|
|
1256
|
+
return "physical";
|
|
1257
|
+
}
|
|
1258
|
+
if (material instanceof THREE4__namespace.MeshPhongMaterial) {
|
|
1259
|
+
return "phong";
|
|
1260
|
+
}
|
|
1261
|
+
if (material instanceof THREE4__namespace.MeshBasicMaterial) {
|
|
1262
|
+
return "basic";
|
|
1263
|
+
}
|
|
1264
|
+
return "standard";
|
|
1265
|
+
}
|
|
1266
|
+
__name(getMaterialType, "getMaterialType");
|
|
1267
|
+
function createMaterialValue(material) {
|
|
1268
|
+
const materialRecord = material;
|
|
1269
|
+
const normalScale = materialRecord.normalScale;
|
|
1270
|
+
const map = materialRecord.map;
|
|
1271
|
+
return {
|
|
1272
|
+
type: getMaterialType(material),
|
|
1273
|
+
color: toHexColor2(materialRecord.color, "#ffffff"),
|
|
1274
|
+
roughness: typeof materialRecord.roughness === "number" ? materialRecord.roughness : 0.5,
|
|
1275
|
+
metalness: typeof materialRecord.metalness === "number" ? materialRecord.metalness : 0.5,
|
|
1276
|
+
normalScale: typeof normalScale?.x === "number" ? normalScale.x : 1,
|
|
1277
|
+
opacity: typeof materialRecord.opacity === "number" ? materialRecord.opacity : 1,
|
|
1278
|
+
emissive: toHexColor2(materialRecord.emissive, "#000000"),
|
|
1279
|
+
emissiveIntensity: typeof materialRecord.emissiveIntensity === "number" ? materialRecord.emissiveIntensity : 0,
|
|
1280
|
+
side: typeof materialRecord.side === "number" ? materialRecord.side : THREE4__namespace.FrontSide,
|
|
1281
|
+
blending: typeof materialRecord.blending === "number" ? materialRecord.blending : THREE4__namespace.NormalBlending,
|
|
1282
|
+
depthTest: materialRecord.depthTest !== false,
|
|
1283
|
+
depthWrite: materialRecord.depthWrite !== false,
|
|
1284
|
+
wireframe: Boolean(materialRecord.wireframe),
|
|
1285
|
+
transparent: Boolean(materialRecord.transparent),
|
|
1286
|
+
textureMap: map?.image ? map.source?.data?.currentSrc || map.image?.src : void 0,
|
|
1287
|
+
alphaTextureMap: materialRecord.alphaMap?.image?.src,
|
|
1288
|
+
normalMap: materialRecord.normalMap?.image?.src,
|
|
1289
|
+
roughnessMap: materialRecord.roughnessMap?.image?.src,
|
|
1290
|
+
metalnessMap: materialRecord.metalnessMap?.image?.src,
|
|
1291
|
+
aoMap: materialRecord.aoMap?.image?.src,
|
|
1292
|
+
emissiveMap: materialRecord.emissiveMap?.image?.src,
|
|
1293
|
+
bumpMap: materialRecord.bumpMap?.image?.src,
|
|
1294
|
+
displacementMap: materialRecord.displacementMap?.image?.src,
|
|
1295
|
+
lightMap: materialRecord.lightMap?.image?.src,
|
|
1296
|
+
envMap: materialRecord.envMap?.image?.src,
|
|
1297
|
+
textureFiltering: map?.magFilter === THREE4__namespace.NearestFilter ? "sharp" : "smooth",
|
|
1298
|
+
useMipmaps: map?.generateMipmaps !== false
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
__name(createMaterialValue, "createMaterialValue");
|
|
1302
|
+
function defaultMaterialValue() {
|
|
1303
|
+
return {
|
|
1304
|
+
type: "standard",
|
|
1305
|
+
color: "#ffffff",
|
|
1306
|
+
roughness: 0.5,
|
|
1307
|
+
metalness: 0.5,
|
|
1308
|
+
normalScale: 1,
|
|
1309
|
+
opacity: 1,
|
|
1310
|
+
emissive: "#000000",
|
|
1311
|
+
emissiveIntensity: 0,
|
|
1312
|
+
side: THREE4__namespace.FrontSide,
|
|
1313
|
+
blending: THREE4__namespace.NormalBlending,
|
|
1314
|
+
depthTest: true,
|
|
1315
|
+
depthWrite: true,
|
|
1316
|
+
wireframe: false,
|
|
1317
|
+
transparent: false,
|
|
1318
|
+
textureFiltering: "smooth",
|
|
1319
|
+
useMipmaps: true
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
__name(defaultMaterialValue, "defaultMaterialValue");
|
|
1323
|
+
var _MaterialComponent = class _MaterialComponent extends Component {
|
|
1324
|
+
constructor(materialOrMaterials = []) {
|
|
1325
|
+
super();
|
|
1326
|
+
this.materials = [];
|
|
1327
|
+
this.material = null;
|
|
1328
|
+
this.values = [];
|
|
1329
|
+
this.setMaterials(materialOrMaterials);
|
|
1330
|
+
}
|
|
1331
|
+
setMaterials(materialOrMaterials = []) {
|
|
1332
|
+
this.materials = Array.isArray(materialOrMaterials) ? materialOrMaterials.filter(Boolean) : materialOrMaterials ? [materialOrMaterials] : [];
|
|
1333
|
+
this.material = this.materials[0] ?? null;
|
|
1334
|
+
this.values = this.materials.length > 0 ? this.materials.map((material) => createMaterialValue(material)) : [defaultMaterialValue()];
|
|
1335
|
+
}
|
|
1336
|
+
updateValue(index, patch) {
|
|
1337
|
+
if (index < 0) {
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
while (this.values.length <= index) {
|
|
1341
|
+
this.values.push(defaultMaterialValue());
|
|
1342
|
+
}
|
|
1343
|
+
this.values[index] = {
|
|
1344
|
+
...this.values[index],
|
|
1345
|
+
...patch
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
resetValue(index) {
|
|
1349
|
+
if (index < 0) {
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
while (this.values.length <= index) {
|
|
1353
|
+
this.values.push(defaultMaterialValue());
|
|
1354
|
+
}
|
|
1355
|
+
const type = this.values[index]?.type ?? "standard";
|
|
1356
|
+
this.values[index] = {
|
|
1357
|
+
...defaultMaterialValue(),
|
|
1358
|
+
type
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
setMaterialType(index, type) {
|
|
1362
|
+
this.updateValue(index, { type });
|
|
1363
|
+
}
|
|
1364
|
+
setTextureFiltering(index, filtering) {
|
|
1365
|
+
this.updateValue(index, { textureFiltering: filtering });
|
|
1366
|
+
}
|
|
1367
|
+
setUseMipmaps(index, enabled) {
|
|
1368
|
+
this.updateValue(index, { useMipmaps: enabled });
|
|
1369
|
+
}
|
|
1370
|
+
};
|
|
1371
|
+
__name(_MaterialComponent, "MaterialComponent");
|
|
1372
|
+
var MaterialComponent = _MaterialComponent;
|
|
1373
|
+
|
|
1374
|
+
// core/components/Mesh.ts
|
|
1375
|
+
var _MeshComponent = class _MeshComponent extends Component {
|
|
1376
|
+
constructor(mesh) {
|
|
1377
|
+
super();
|
|
1378
|
+
this.mesh = mesh;
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
__name(_MeshComponent, "MeshComponent");
|
|
1382
|
+
var MeshComponent = _MeshComponent;
|
|
1383
|
+
var DEFAULT_MESH_GEOMETRY_PARAMETERS = {
|
|
1384
|
+
capsule: { radius: 0.5, height: 1 },
|
|
1385
|
+
cube: { width: 1, height: 1, depth: 1 },
|
|
1386
|
+
cylinder: { radius: 0.5, height: 1 },
|
|
1387
|
+
model: {},
|
|
1388
|
+
plane: { width: 100, height: 100 },
|
|
1389
|
+
sphere: { radius: 0.5 }
|
|
1390
|
+
};
|
|
1391
|
+
var GEOMETRY_TYPE_BY_KIND = {
|
|
1392
|
+
capsule: "CapsuleGeometry",
|
|
1393
|
+
cube: "BoxGeometry",
|
|
1394
|
+
cylinder: "CylinderGeometry",
|
|
1395
|
+
model: "Model",
|
|
1396
|
+
plane: "PlaneGeometry",
|
|
1397
|
+
sphere: "SphereGeometry"
|
|
1398
|
+
};
|
|
1399
|
+
var _MeshGeometryComponent = class _MeshGeometryComponent extends Component {
|
|
1400
|
+
constructor(kind, object, parameters, options) {
|
|
1401
|
+
super();
|
|
1402
|
+
this.kind = kind;
|
|
1403
|
+
this.geometryType = GEOMETRY_TYPE_BY_KIND[kind];
|
|
1404
|
+
this.object = object;
|
|
1405
|
+
this.modelName = options?.modelName ?? "";
|
|
1406
|
+
this.castShadow = options?.castShadow ?? false;
|
|
1407
|
+
this.receiveShadow = options?.receiveShadow ?? false;
|
|
1408
|
+
switch (kind) {
|
|
1409
|
+
case "cube":
|
|
1410
|
+
this.parameters = {
|
|
1411
|
+
...DEFAULT_MESH_GEOMETRY_PARAMETERS.cube,
|
|
1412
|
+
...parameters
|
|
1413
|
+
};
|
|
1414
|
+
break;
|
|
1415
|
+
case "plane":
|
|
1416
|
+
this.parameters = {
|
|
1417
|
+
...DEFAULT_MESH_GEOMETRY_PARAMETERS.plane,
|
|
1418
|
+
...parameters
|
|
1419
|
+
};
|
|
1420
|
+
break;
|
|
1421
|
+
case "sphere":
|
|
1422
|
+
this.parameters = {
|
|
1423
|
+
...DEFAULT_MESH_GEOMETRY_PARAMETERS.sphere,
|
|
1424
|
+
...parameters
|
|
1425
|
+
};
|
|
1426
|
+
break;
|
|
1427
|
+
case "cylinder":
|
|
1428
|
+
this.parameters = {
|
|
1429
|
+
...DEFAULT_MESH_GEOMETRY_PARAMETERS.cylinder,
|
|
1430
|
+
...parameters
|
|
1431
|
+
};
|
|
1432
|
+
break;
|
|
1433
|
+
case "capsule":
|
|
1434
|
+
this.parameters = {
|
|
1435
|
+
...DEFAULT_MESH_GEOMETRY_PARAMETERS.capsule,
|
|
1436
|
+
...parameters
|
|
1437
|
+
};
|
|
1438
|
+
break;
|
|
1439
|
+
case "model":
|
|
1440
|
+
this.parameters = {};
|
|
1441
|
+
break;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
__name(_MeshGeometryComponent, "MeshGeometryComponent");
|
|
1446
|
+
var MeshGeometryComponent = _MeshGeometryComponent;
|
|
1447
|
+
|
|
1448
|
+
// core/components/Model.ts
|
|
1449
|
+
var _ModelComponent = class _ModelComponent extends Component {
|
|
1450
|
+
constructor(path) {
|
|
1451
|
+
super();
|
|
1452
|
+
this.path = path;
|
|
1453
|
+
this.object = null;
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
__name(_ModelComponent, "ModelComponent");
|
|
1457
|
+
var ModelComponent = _ModelComponent;
|
|
1458
|
+
|
|
1459
|
+
// core/components/Name.ts
|
|
1460
|
+
var _Name = class _Name extends Component {
|
|
1461
|
+
constructor(value) {
|
|
1462
|
+
super();
|
|
1463
|
+
this.value = value;
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
__name(_Name, "Name");
|
|
1467
|
+
var Name = _Name;
|
|
1468
|
+
|
|
1469
|
+
// core/components/Object3DRef.ts
|
|
1470
|
+
var _Object3DRef = class _Object3DRef extends Component {
|
|
1471
|
+
constructor(object, visibility) {
|
|
1472
|
+
super();
|
|
1473
|
+
this.object = object;
|
|
1474
|
+
this.visibility = typeof visibility === "boolean" ? visibility : Boolean(object.visible);
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
__name(_Object3DRef, "Object3DRef");
|
|
1478
|
+
var Object3DRef = _Object3DRef;
|
|
1479
|
+
|
|
1480
|
+
// core/components/ParentId.ts
|
|
1481
|
+
var _ParentId = class _ParentId extends Component {
|
|
1482
|
+
constructor(value = null) {
|
|
1483
|
+
super();
|
|
1484
|
+
this.value = value;
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
__name(_ParentId, "ParentId");
|
|
1488
|
+
var ParentId = _ParentId;
|
|
1489
|
+
|
|
1490
|
+
// core/components/ScriptComponent.ts
|
|
1491
|
+
var _ScriptComponent = class _ScriptComponent extends Component {
|
|
1492
|
+
constructor(entries = []) {
|
|
1493
|
+
super();
|
|
1494
|
+
this.entries = entries.map((entry) => ({
|
|
1495
|
+
entityId: typeof entry.entityId === "number" ? entry.entityId : 0,
|
|
1496
|
+
className: typeof entry.className === "string" ? entry.className : "",
|
|
1497
|
+
scriptUrl: typeof entry.scriptUrl === "string" ? entry.scriptUrl : "",
|
|
1498
|
+
enabled: typeof entry.enabled === "boolean" ? entry.enabled : true,
|
|
1499
|
+
executeInEditor: typeof entry.executeInEditor === "boolean" ? entry.executeInEditor : false,
|
|
1500
|
+
data: entry.data && typeof entry.data === "object" && !Array.isArray(entry.data) ? entry.data : {},
|
|
1501
|
+
runtimeState: entry.runtimeState,
|
|
1502
|
+
runtimeMessage: typeof entry.runtimeMessage === "string" ? entry.runtimeMessage : void 0
|
|
1503
|
+
}));
|
|
1504
|
+
Object.defineProperty(this, "scriptInstance", {
|
|
1505
|
+
value: null,
|
|
1506
|
+
writable: true,
|
|
1507
|
+
configurable: true,
|
|
1508
|
+
enumerable: false
|
|
1509
|
+
});
|
|
1510
|
+
Object.defineProperty(this, "scriptInstances", {
|
|
1511
|
+
value: /* @__PURE__ */ new Map(),
|
|
1512
|
+
writable: true,
|
|
1513
|
+
configurable: true,
|
|
1514
|
+
enumerable: false
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
__name(_ScriptComponent, "ScriptComponent");
|
|
1519
|
+
var ScriptComponent = _ScriptComponent;
|
|
1520
|
+
|
|
1521
|
+
// core/components/Selectable.ts
|
|
1522
|
+
var _Selectable = class _Selectable extends Component {
|
|
1523
|
+
constructor(enabled = true) {
|
|
1524
|
+
super();
|
|
1525
|
+
this.enabled = enabled;
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
__name(_Selectable, "Selectable");
|
|
1529
|
+
var Selectable = _Selectable;
|
|
1530
|
+
|
|
1531
|
+
// core/components/Sprite.ts
|
|
1532
|
+
var _SpriteComponent = class _SpriteComponent extends Component {
|
|
1533
|
+
constructor(path, width = 1, height = 1) {
|
|
1534
|
+
super();
|
|
1535
|
+
this.path = path;
|
|
1536
|
+
this.width = width;
|
|
1537
|
+
this.height = height;
|
|
1538
|
+
this.texture = null;
|
|
1539
|
+
this.object = null;
|
|
1540
|
+
}
|
|
1541
|
+
};
|
|
1542
|
+
__name(_SpriteComponent, "SpriteComponent");
|
|
1543
|
+
var SpriteComponent = _SpriteComponent;
|
|
1544
|
+
|
|
1545
|
+
// core/components/SelectionTransformState.ts
|
|
1546
|
+
var _SelectionTransformState = class _SelectionTransformState extends Component {
|
|
1547
|
+
constructor(transform = "translate", space = "world", selectedEntityId = null) {
|
|
1548
|
+
super();
|
|
1549
|
+
this.transform = transform;
|
|
1550
|
+
this.space = space;
|
|
1551
|
+
this.selectedEntityId = selectedEntityId;
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
1554
|
+
__name(_SelectionTransformState, "SelectionTransformState");
|
|
1555
|
+
var SelectionTransformState = _SelectionTransformState;
|
|
1556
|
+
function readXYZ(input) {
|
|
1557
|
+
return {
|
|
1558
|
+
x: input.x,
|
|
1559
|
+
y: input.y,
|
|
1560
|
+
z: input.z
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
__name(readXYZ, "readXYZ");
|
|
1564
|
+
var _TransformComponent = class _TransformComponent extends Component {
|
|
1565
|
+
constructor(data = {}) {
|
|
1566
|
+
super();
|
|
1567
|
+
const position = data.position ?? {};
|
|
1568
|
+
const rotation = data.rotation ?? {};
|
|
1569
|
+
const scale = data.scale ?? {};
|
|
1570
|
+
this.position = {
|
|
1571
|
+
x: position.x ?? 0,
|
|
1572
|
+
y: position.y ?? 0,
|
|
1573
|
+
z: position.z ?? 0
|
|
1574
|
+
};
|
|
1575
|
+
this.rotation = {
|
|
1576
|
+
x: rotation.x ?? 0,
|
|
1577
|
+
y: rotation.y ?? 0,
|
|
1578
|
+
z: rotation.z ?? 0
|
|
1579
|
+
};
|
|
1580
|
+
this.scale = {
|
|
1581
|
+
x: scale.x ?? 1,
|
|
1582
|
+
y: scale.y ?? 1,
|
|
1583
|
+
z: scale.z ?? 1
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
toPositionVector3(target = new THREE4.Vector3()) {
|
|
1587
|
+
return target.set(this.position.x, this.position.y, this.position.z);
|
|
1588
|
+
}
|
|
1589
|
+
toRotationEuler(target = new THREE4.Euler(), order = "XYZ") {
|
|
1590
|
+
return target.set(this.rotation.x, this.rotation.y, this.rotation.z, order);
|
|
1591
|
+
}
|
|
1592
|
+
toRotationQuaternion(target = new THREE4.Quaternion(), order = "XYZ") {
|
|
1593
|
+
const euler = new THREE4.Euler(
|
|
1594
|
+
this.rotation.x,
|
|
1595
|
+
this.rotation.y,
|
|
1596
|
+
this.rotation.z,
|
|
1597
|
+
order
|
|
1598
|
+
);
|
|
1599
|
+
return target.setFromEuler(euler);
|
|
1600
|
+
}
|
|
1601
|
+
toScaleVector3(target = new THREE4.Vector3()) {
|
|
1602
|
+
return target.set(this.scale.x, this.scale.y, this.scale.z);
|
|
1603
|
+
}
|
|
1604
|
+
setPosition(input) {
|
|
1605
|
+
const next = readXYZ(input);
|
|
1606
|
+
this.position.x = next.x;
|
|
1607
|
+
this.position.y = next.y;
|
|
1608
|
+
this.position.z = next.z;
|
|
1609
|
+
return this;
|
|
1610
|
+
}
|
|
1611
|
+
setScale(input) {
|
|
1612
|
+
const next = readXYZ(input);
|
|
1613
|
+
this.scale.x = next.x;
|
|
1614
|
+
this.scale.y = next.y;
|
|
1615
|
+
this.scale.z = next.z;
|
|
1616
|
+
return this;
|
|
1617
|
+
}
|
|
1618
|
+
setRotation(input, order = "XYZ") {
|
|
1619
|
+
if (input instanceof THREE4.Quaternion) {
|
|
1620
|
+
const euler = new THREE4.Euler().setFromQuaternion(input, order);
|
|
1621
|
+
this.rotation.x = euler.x;
|
|
1622
|
+
this.rotation.y = euler.y;
|
|
1623
|
+
this.rotation.z = euler.z;
|
|
1624
|
+
return this;
|
|
1625
|
+
}
|
|
1626
|
+
const next = readXYZ(input);
|
|
1627
|
+
this.rotation.x = next.x;
|
|
1628
|
+
this.rotation.y = next.y;
|
|
1629
|
+
this.rotation.z = next.z;
|
|
1630
|
+
return this;
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
__name(_TransformComponent, "TransformComponent");
|
|
1634
|
+
var TransformComponent = _TransformComponent;
|
|
1635
|
+
|
|
1636
|
+
// core/components/Video.ts
|
|
1637
|
+
var DEFAULT_VIDEO_OPTIONS = {
|
|
1638
|
+
autoplay: false,
|
|
1639
|
+
loop: true,
|
|
1640
|
+
volume: 1,
|
|
1641
|
+
width: 1,
|
|
1642
|
+
height: 1,
|
|
1643
|
+
isGreenScreen: false,
|
|
1644
|
+
backgroundColor: "#00ff00",
|
|
1645
|
+
similarity: 0.4,
|
|
1646
|
+
smoothness: 0.08,
|
|
1647
|
+
spill: 0.12,
|
|
1648
|
+
/** When `true`, the video's audio stream is spatialized using the entity's transform. */
|
|
1649
|
+
positional: false,
|
|
1650
|
+
/** Distance at which volume is unattenuated (positional only). */
|
|
1651
|
+
refDistance: 1,
|
|
1652
|
+
/** WebAudio distance model (`linear`, `inverse`, `exponential`). Positional only. */
|
|
1653
|
+
distanceModel: "inverse",
|
|
1654
|
+
/** How quickly volume falls off past `refDistance`. Positional only. */
|
|
1655
|
+
rolloffFactor: 1
|
|
1656
|
+
};
|
|
1657
|
+
var _VideoComponent = class _VideoComponent extends Component {
|
|
1658
|
+
constructor(path, options = {}) {
|
|
1659
|
+
super();
|
|
1660
|
+
this.path = path;
|
|
1661
|
+
this.options = {
|
|
1662
|
+
...DEFAULT_VIDEO_OPTIONS,
|
|
1663
|
+
...options
|
|
1664
|
+
};
|
|
1665
|
+
this.object = null;
|
|
1666
|
+
this.videoElement = null;
|
|
1667
|
+
this.texture = null;
|
|
1668
|
+
this.material = null;
|
|
1669
|
+
this.audioNode = null;
|
|
1670
|
+
Object.defineProperty(this, "isPlaying", {
|
|
1671
|
+
value: false,
|
|
1672
|
+
writable: true,
|
|
1673
|
+
configurable: true,
|
|
1674
|
+
enumerable: false
|
|
1675
|
+
});
|
|
1676
|
+
Object.defineProperty(this, "isPaused", {
|
|
1677
|
+
value: false,
|
|
1678
|
+
writable: true,
|
|
1679
|
+
configurable: true,
|
|
1680
|
+
enumerable: false
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Signals `VideoSystem` to start (or resume) playback.
|
|
1685
|
+
* Has no direct effect in the editor — `VideoSystem` drives the actual
|
|
1686
|
+
* HTML video element call in preview.
|
|
1687
|
+
*/
|
|
1688
|
+
play() {
|
|
1689
|
+
this.isPlaying = true;
|
|
1690
|
+
this.isPaused = false;
|
|
1691
|
+
}
|
|
1692
|
+
/**
|
|
1693
|
+
* Signals `VideoSystem` to pause playback, preserving the current position.
|
|
1694
|
+
* Calling {@link play} afterwards resumes from where it paused.
|
|
1695
|
+
* No-op if not currently playing.
|
|
1696
|
+
*/
|
|
1697
|
+
pause() {
|
|
1698
|
+
if (!this.isPlaying) return;
|
|
1699
|
+
this.isPlaying = false;
|
|
1700
|
+
this.isPaused = true;
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Signals `VideoSystem` to stop playback and reset the playback position.
|
|
1704
|
+
*/
|
|
1705
|
+
stop() {
|
|
1706
|
+
this.isPlaying = false;
|
|
1707
|
+
this.isPaused = false;
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
__name(_VideoComponent, "VideoComponent");
|
|
1711
|
+
var VideoComponent = _VideoComponent;
|
|
1712
|
+
|
|
1713
|
+
exports.AnimationComponent = AnimationComponent;
|
|
1714
|
+
exports.AudioComponent = AudioComponent;
|
|
1715
|
+
exports.CameraComponent = CameraComponent;
|
|
1716
|
+
exports.DEFAULT_COLLIDER_STATE = DEFAULT_COLLIDER_STATE;
|
|
1717
|
+
exports.DEFAULT_ENVIRONMENT_STATE = DEFAULT_ENVIRONMENT_STATE;
|
|
1718
|
+
exports.DEFAULT_MESH_GEOMETRY_PARAMETERS = DEFAULT_MESH_GEOMETRY_PARAMETERS;
|
|
1719
|
+
exports.DEFAULT_PHYSICS_STATE = DEFAULT_PHYSICS_STATE;
|
|
1720
|
+
exports.DEFAULT_POSTPROCESSING_STATE = DEFAULT_POSTPROCESSING_STATE;
|
|
1721
|
+
exports.DEFAULT_RIGIDBODY_STATE = DEFAULT_RIGIDBODY_STATE;
|
|
1722
|
+
exports.EntityType = EntityType;
|
|
1723
|
+
exports.Environment = Environment;
|
|
1724
|
+
exports.ImageComponent = ImageComponent;
|
|
1725
|
+
exports.ImageTarget = ImageTarget;
|
|
1726
|
+
exports.ImageTargetAnchor = ImageTargetAnchor;
|
|
1727
|
+
exports.LightComponent = LightComponent;
|
|
1728
|
+
exports.MaterialComponent = MaterialComponent;
|
|
1729
|
+
exports.MeshComponent = MeshComponent;
|
|
1730
|
+
exports.MeshGeometryComponent = MeshGeometryComponent;
|
|
1731
|
+
exports.ModelComponent = ModelComponent;
|
|
1732
|
+
exports.Name = Name;
|
|
1733
|
+
exports.Object3DRef = Object3DRef;
|
|
1734
|
+
exports.ParentId = ParentId;
|
|
1735
|
+
exports.PhysicsComponent = PhysicsComponent;
|
|
1736
|
+
exports.Postprocessing = Postprocessing;
|
|
1737
|
+
exports.ScriptComponent = ScriptComponent;
|
|
1738
|
+
exports.Selectable = Selectable;
|
|
1739
|
+
exports.SelectionTransformState = SelectionTransformState;
|
|
1740
|
+
exports.SpriteComponent = SpriteComponent;
|
|
1741
|
+
exports.TransformComponent = TransformComponent;
|
|
1742
|
+
exports.VideoComponent = VideoComponent;
|
|
1743
|
+
exports.normalizePhysicsState = normalizePhysicsState;
|
|
1744
|
+
//# sourceMappingURL=index.cjs.map
|
|
1745
|
+
//# sourceMappingURL=index.cjs.map
|