@relu-interactives/spatial-ecs 0.5.3 → 0.8.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/dist/{System-V_mv07le.d.cts → System-8D-XBDKZ.d.cts} +734 -8
- package/dist/{System-V_mv07le.d.ts → System-DPMAW30g.d.ts} +734 -8
- package/dist/{XRHandPose-CU3vNFuS.d.ts → XRHandPose-G0Dl-F0w.d.ts} +93 -3
- package/dist/{XRHandPose-CQTLGxFC.d.cts → XRHandPose-VQMT1WXj.d.cts} +93 -3
- package/dist/animation/index.cjs +252 -0
- package/dist/animation/index.cjs.map +1 -0
- package/dist/animation/index.d.cts +100 -0
- package/dist/animation/index.d.ts +100 -0
- package/dist/animation/index.js +4 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/chunk-CKTHDXPS.js +11 -0
- package/dist/chunk-CKTHDXPS.js.map +1 -0
- package/dist/chunk-G4XJ53LS.js +1237 -0
- package/dist/chunk-G4XJ53LS.js.map +1 -0
- package/dist/chunk-GSWC6LLD.js +241 -0
- package/dist/chunk-GSWC6LLD.js.map +1 -0
- package/dist/{chunk-DF5SSRN6.js → chunk-JIJQFW6P.js} +1216 -2920
- package/dist/chunk-JIJQFW6P.js.map +1 -0
- package/dist/{chunk-BUEKOSR5.js → chunk-NNDUOQ7O.js} +188 -14
- package/dist/chunk-NNDUOQ7O.js.map +1 -0
- package/dist/chunk-OHCNPPMX.js +334 -0
- package/dist/chunk-OHCNPPMX.js.map +1 -0
- package/dist/{chunk-RXBLOO5B.js → chunk-SGF73YTF.js} +105 -715
- package/dist/chunk-SGF73YTF.js.map +1 -0
- package/dist/chunk-U727NTWQ.js +2856 -0
- package/dist/chunk-U727NTWQ.js.map +1 -0
- package/dist/{chunk-OY7ZODZP.js → chunk-XE4OXN2W.js} +3 -9
- package/dist/chunk-XE4OXN2W.js.map +1 -0
- package/dist/{chunk-OWQSESTO.js → chunk-XU2DVWCP.js} +4 -3
- package/dist/chunk-XU2DVWCP.js.map +1 -0
- package/dist/components/index.cjs +183 -10
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +5 -3
- package/dist/components/index.d.ts +5 -3
- package/dist/components/index.js +3 -2
- package/dist/docs/api/Behaviour/classes/Behaviour.md +366 -79
- package/dist/docs/api/Behaviour/index.md +7 -3
- package/dist/docs/api/Behaviour/type-aliases/UiInteractionEvent.md +35 -0
- package/dist/docs/api/Component/classes/Component.md +14 -1
- package/dist/docs/api/components/classes/AnimationComponent.md +26 -26
- package/dist/docs/api/components/classes/AudioComponent.md +19 -19
- package/dist/docs/api/components/classes/CameraComponent.md +14 -14
- package/dist/docs/api/components/classes/EntityType.md +4 -4
- package/dist/docs/api/components/classes/Environment.md +5 -4
- package/dist/docs/api/components/classes/ImageComponent.md +7 -7
- package/dist/docs/api/components/classes/ImageTarget.md +8 -8
- package/dist/docs/api/components/classes/ImageTargetAnchor.md +4 -4
- package/dist/docs/api/components/classes/InstanceSlotComponent.md +4 -4
- package/dist/docs/api/components/classes/InstancedMeshComponent.md +10 -10
- package/dist/docs/api/components/classes/LightComponent.md +6 -6
- package/dist/docs/api/components/classes/MaterialComponent.md +16 -16
- package/dist/docs/api/components/classes/MeshComponent.md +3 -3
- package/dist/docs/api/components/classes/MeshGeometryComponent.md +9 -9
- package/dist/docs/api/components/classes/ModelComponent.md +8 -5
- package/dist/docs/api/components/classes/Name.md +3 -3
- package/dist/docs/api/components/classes/Object3DRef.md +4 -4
- package/dist/docs/api/components/classes/ParentId.md +3 -3
- package/dist/docs/api/components/classes/PhysicsComponent.md +7 -6
- package/dist/docs/api/components/classes/Postprocessing.md +3 -3
- package/dist/docs/api/components/classes/PrefabInstance.md +5 -5
- package/dist/docs/api/components/classes/PrefabNode.md +3 -3
- package/dist/docs/api/components/classes/ScriptComponent.md +5 -5
- package/dist/docs/api/components/classes/ScriptObjectComponent.md +9 -9
- package/dist/docs/api/components/classes/Selectable.md +3 -3
- package/dist/docs/api/components/classes/SelectionTransformState.md +5 -5
- package/dist/docs/api/components/classes/SpriteComponent.md +7 -7
- package/dist/docs/api/components/classes/TransformComponent.md +12 -12
- package/dist/docs/api/components/classes/UIButtonComponent.md +63 -0
- package/dist/docs/api/components/classes/UIPanelComponent.md +62 -0
- package/dist/docs/api/components/classes/UISliderComponent.md +59 -0
- package/dist/docs/api/components/classes/UITextComponent.md +59 -0
- package/dist/docs/api/components/classes/UIToggleComponent.md +56 -0
- package/dist/docs/api/components/classes/VRTeleportAreaComponent.md +53 -0
- package/dist/docs/api/components/classes/VideoComponent.md +28 -28
- package/dist/docs/api/components/classes/XRAnchorComponent.md +64 -0
- package/dist/docs/api/components/classes/XREnvironmentComponent.md +64 -0
- package/dist/docs/api/components/classes/XRHandPoseComponent.md +50 -0
- package/dist/docs/api/components/classes/XRInteractableComponent.md +74 -0
- package/dist/docs/api/components/classes/XRInteractorComponent.md +57 -0
- package/dist/docs/api/components/classes/XRInteractorSideComponent.md +50 -0
- package/dist/docs/api/components/classes/XRRigComponent.md +68 -0
- package/dist/docs/api/components/functions/createAttachPoint.md +25 -0
- package/dist/docs/api/components/functions/createHandPoseEntry.md +25 -0
- package/dist/docs/api/components/functions/defaultMaterialValue.md +1 -1
- package/dist/docs/api/components/functions/handPoseDefinitionFor.md +33 -0
- package/dist/docs/api/components/functions/normalizeEnvironmentLighting.md +30 -0
- package/dist/docs/api/components/functions/normalizePhysicsState.md +1 -1
- package/dist/docs/api/components/functions/setModelLoadState.md +33 -0
- package/dist/docs/api/components/functions/setPhysicsLiveRef.md +3 -9
- package/dist/docs/api/components/index.md +61 -4
- package/dist/docs/api/components/type-aliases/AnimationComponentOptions.md +9 -9
- package/dist/docs/api/components/type-aliases/CameraComponentOptions.md +13 -13
- package/dist/docs/api/components/type-aliases/CameraProjection.md +1 -1
- package/dist/docs/api/components/type-aliases/CameraRuntimeType.md +5 -3
- package/dist/docs/api/components/type-aliases/ColliderShape.md +1 -1
- package/dist/docs/api/components/type-aliases/ColliderState.md +20 -20
- package/dist/docs/api/components/type-aliases/CubeMeshParameters.md +4 -4
- package/dist/docs/api/components/type-aliases/EditableMeshObjectKind.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentFogState.md +8 -8
- package/dist/docs/api/components/type-aliases/EnvironmentFogType.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentGradientEffect.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentLightingState.md +40 -0
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxImageProjection.md +22 -0
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxState.md +9 -7
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxType.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentState.md +7 -5
- package/dist/docs/api/components/type-aliases/EnvironmentToneMapping.md +16 -0
- package/dist/docs/api/components/type-aliases/ImageTargetAnchorOptions.md +3 -3
- package/dist/docs/api/components/type-aliases/ImageTargetReference.md +7 -7
- package/dist/docs/api/components/type-aliases/InstanceTransform.md +13 -13
- package/dist/docs/api/components/type-aliases/InstancedMeshKind.md +1 -1
- package/dist/docs/api/components/type-aliases/LightShadowState.md +37 -0
- package/dist/docs/api/components/type-aliases/LightValueState.md +13 -11
- package/dist/docs/api/components/type-aliases/MaterialTypeValue.md +1 -1
- package/dist/docs/api/components/type-aliases/MaterialValueState.md +28 -28
- package/dist/docs/api/components/type-aliases/MeshGeometryParameters.md +1 -1
- package/dist/docs/api/components/type-aliases/MeshGeometryParametersByKind.md +7 -7
- package/dist/docs/api/components/type-aliases/ModelLoadState.md +15 -0
- package/dist/docs/api/components/type-aliases/PhysicsState.md +3 -3
- package/dist/docs/api/components/type-aliases/PlaneMeshParameters.md +3 -3
- package/dist/docs/api/components/type-aliases/PostprocessingState.md +62 -62
- package/dist/docs/api/components/type-aliases/RadiusHeightMeshParameters.md +3 -3
- package/dist/docs/api/components/type-aliases/RadiusMeshParameters.md +2 -2
- package/dist/docs/api/components/type-aliases/RigidbodyState.md +17 -17
- package/dist/docs/api/components/type-aliases/RigidbodyType.md +1 -1
- package/dist/docs/api/components/type-aliases/ScriptEntry.md +8 -8
- package/dist/docs/api/components/type-aliases/ScriptObjectComponentInput.md +1 -1
- package/dist/docs/api/components/type-aliases/ScriptObjectRuntimeState.md +1 -1
- package/dist/docs/api/components/type-aliases/TextureFilteringValue.md +1 -1
- package/dist/docs/api/components/type-aliases/TransformData.md +4 -4
- package/dist/docs/api/components/type-aliases/TransformModeValue.md +1 -1
- package/dist/docs/api/components/type-aliases/TransformSpaceValue.md +1 -1
- package/dist/docs/api/components/type-aliases/UIButtonOptions.md +45 -0
- package/dist/docs/api/components/type-aliases/UIPanelOptions.md +39 -0
- package/dist/docs/api/components/type-aliases/UISliderOptions.md +39 -0
- package/dist/docs/api/components/type-aliases/UITextOptions.md +41 -0
- package/dist/docs/api/components/type-aliases/UIToggleOptions.md +35 -0
- package/dist/docs/api/components/type-aliases/UiFollowMode.md +15 -0
- package/dist/docs/api/components/type-aliases/UiTextAlign.md +13 -0
- package/dist/docs/api/components/type-aliases/UiTextVAlign.md +13 -0
- package/dist/docs/api/components/type-aliases/VRTeleportAreaOptions.md +29 -0
- package/dist/docs/api/components/type-aliases/Vec3.md +4 -4
- package/dist/docs/api/components/type-aliases/VrTeleportShape.md +15 -0
- package/dist/docs/api/components/type-aliases/XRAnchorOptions.md +23 -0
- package/dist/docs/api/components/type-aliases/XRHandPoseOptions.md +23 -0
- package/dist/docs/api/components/type-aliases/XRInteractableOptions.md +75 -0
- package/dist/docs/api/components/type-aliases/XRInteractorOptions.md +37 -0
- package/dist/docs/api/components/type-aliases/XRRigOptions.md +51 -0
- package/dist/docs/api/components/type-aliases/XrAttachPoint.md +53 -0
- package/dist/docs/api/components/type-aliases/XrDistanceGrabBehavior.md +19 -0
- package/dist/docs/api/components/type-aliases/XrEnvironmentKind.md +15 -0
- package/dist/docs/api/components/type-aliases/XrEnvironmentOrientation.md +15 -0
- package/dist/docs/api/components/type-aliases/XrEnvironmentPhysics.md +25 -0
- package/dist/docs/api/components/type-aliases/XrGrabGesture.md +19 -0
- package/dist/docs/api/components/type-aliases/XrGrabHands.md +20 -0
- package/dist/docs/api/components/type-aliases/XrGrabReach.md +20 -0
- package/dist/docs/api/components/type-aliases/XrHandPoseEntry.md +49 -0
- package/dist/docs/api/components/type-aliases/XrHandPreset.md +19 -0
- package/dist/docs/api/components/type-aliases/XrInteractorSide.md +15 -0
- package/dist/docs/api/components/type-aliases/XrInteractorType.md +13 -0
- package/dist/docs/api/components/type-aliases/XrLocomotionMode.md +15 -0
- package/dist/docs/api/components/type-aliases/XrTrackingOrigin.md +24 -0
- package/dist/docs/api/components/type-aliases/XrTwoHandRotation.md +15 -0
- package/dist/docs/api/components/variables/DEFAULT_COLLIDER_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_LIGHTING.md +15 -0
- package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_INSTANCED_MESH_PARAMETERS.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_INSTANCE_TRANSFORM.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_MESH_GEOMETRY_PARAMETERS.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_PHYSICS_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_POSE_CURLS.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_POSE_DIRECTIONS.md +13 -0
- package/dist/docs/api/components/variables/DEFAULT_POSTPROCESSING_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_RIGIDBODY_STATE.md +1 -1
- package/dist/docs/api/components/variables/MODEL_NO_PATH_MESSAGE.md +15 -0
- package/dist/docs/api/index/classes/AnimationStateMachine.md +16 -16
- package/dist/docs/api/index/classes/AnimationStateManager.md +13 -13
- package/dist/docs/api/index/classes/AnimationSystem.md +3 -3
- package/dist/docs/api/index/classes/AudioSystem.md +4 -4
- package/dist/docs/api/index/classes/CameraSyncSystem.md +2 -2
- package/dist/docs/api/index/classes/EnvironmentSyncSystem.md +19 -4
- package/dist/docs/api/index/classes/HandPoseTracker.md +114 -0
- package/dist/docs/api/index/classes/InputSystem.md +33 -33
- package/dist/docs/api/index/classes/InstancedMeshSystem.md +2 -2
- package/dist/docs/api/index/classes/LightSyncSystem.md +2 -2
- package/dist/docs/api/index/classes/MaterialSyncSystem.md +3 -3
- package/dist/docs/api/index/classes/MeshGeometrySystem.md +2 -2
- package/dist/docs/api/index/classes/ObjectManagementSystem.md +14 -14
- package/dist/docs/api/index/classes/ObjectVisibilitySystem.md +2 -2
- package/dist/docs/api/index/classes/PhysicsSyncSystem.md +4 -4
- package/dist/docs/api/index/classes/PostprocessingSyncSystem.md +34 -10
- package/dist/docs/api/index/classes/RenderSystem.md +13 -4
- package/dist/docs/api/index/classes/ScriptBehaviourSystem.md +9 -5
- package/dist/docs/api/index/classes/ScriptObject.md +10 -10
- package/dist/docs/api/index/classes/ScriptObjectSystem.md +6 -6
- package/dist/docs/api/index/classes/TeleportAimGate.md +114 -0
- package/dist/docs/api/index/classes/ThrowVelocityTracker.md +89 -0
- package/dist/docs/api/index/classes/TransformSyncSystem.md +2 -2
- package/dist/docs/api/index/classes/UIInteractionSystem.md +60 -0
- package/dist/docs/api/index/classes/UIPanelSystem.md +79 -0
- package/dist/docs/api/index/classes/VRTeleportAreaSystem.md +49 -0
- package/dist/docs/api/index/classes/VideoSystem.md +8 -6
- package/dist/docs/api/index/classes/World.md +282 -100
- package/dist/docs/api/index/classes/XRAnchorSystem.md +90 -0
- package/dist/docs/api/index/classes/XRControllerVisualSystem.md +77 -0
- package/dist/docs/api/index/classes/XREnvironmentSystem.md +137 -0
- package/dist/docs/api/index/classes/XRHandPoseSystem.md +107 -0
- package/dist/docs/api/index/classes/XRHitTestSystem.md +93 -0
- package/dist/docs/api/index/classes/XRHoverVisualSystem.md +76 -0
- package/dist/docs/api/index/classes/XRInputSystem.md +189 -0
- package/dist/docs/api/index/classes/XRInteractionSystem.md +323 -0
- package/dist/docs/api/index/classes/XRLocomotionSystem.md +128 -0
- package/dist/docs/api/index/classes/XRSessionSystem.md +116 -0
- package/dist/docs/api/index/classes/XRTeleportVisualSystem.md +75 -0
- package/dist/docs/api/index/functions/angularVelocityFrom.md +33 -0
- package/dist/docs/api/index/functions/applyHandMaterial.md +26 -0
- package/dist/docs/api/index/functions/applyPrefabToSnapshotInstances.md +1 -1
- package/dist/docs/api/index/functions/arcGroundCrossing.md +30 -0
- package/dist/docs/api/index/functions/buildComponentValueMaps.md +1 -1
- package/dist/docs/api/index/functions/buildNodeKeyMapsFromSnapshot.md +1 -1
- package/dist/docs/api/index/functions/buildNodeMapsFromSnapshot.md +1 -1
- package/dist/docs/api/index/functions/canonicalizeComponentValue.md +1 -1
- package/dist/docs/api/index/functions/clearModelCache.md +1 -1
- package/dist/docs/api/index/functions/clearPrefabCache.md +1 -1
- package/dist/docs/api/index/functions/cloneHandPose.md +23 -0
- package/dist/docs/api/index/functions/collectDiffPaths.md +1 -1
- package/dist/docs/api/index/functions/collectDirectPrefabDependencies.md +1 -1
- package/dist/docs/api/index/functions/collectEntitySubtree.md +1 -1
- package/dist/docs/api/index/functions/collectSnapshotSubtreeIds.md +1 -1
- package/dist/docs/api/index/functions/computeFingerCurl.md +29 -0
- package/dist/docs/api/index/functions/computeHandShape.md +29 -0
- package/dist/docs/api/index/functions/computeInstanceOverrides.md +1 -1
- package/dist/docs/api/index/functions/computePalmPose.md +30 -0
- package/dist/docs/api/index/functions/computePalmWidth.md +25 -0
- package/dist/docs/api/index/functions/computePinch.md +29 -0
- package/dist/docs/api/index/functions/computeSpread.md +33 -0
- package/dist/docs/api/index/functions/createAnimationComponent.md +1 -1
- package/dist/docs/api/index/functions/createAudioComponent.md +1 -1
- package/dist/docs/api/index/functions/createCameraComponent.md +1 -1
- package/dist/docs/api/index/functions/createEntityTypeComponent.md +2 -2
- package/dist/docs/api/index/functions/createEnvironmentComponent.md +1 -1
- package/dist/docs/api/index/functions/createHandMaterial.md +30 -0
- package/dist/docs/api/index/functions/createImageComponent.md +1 -1
- package/dist/docs/api/index/functions/createImageTargetAnchorComponent.md +1 -1
- package/dist/docs/api/index/functions/createImageTargetComponent.md +2 -2
- package/dist/docs/api/index/functions/createInstanceSlotComponent.md +1 -1
- package/dist/docs/api/index/functions/createInstancedMeshComponent.md +1 -1
- package/dist/docs/api/index/functions/createLightComponent.md +2 -2
- package/dist/docs/api/index/functions/createMaterialComponent.md +2 -2
- package/dist/docs/api/index/functions/createMeshComponent.md +1 -1
- package/dist/docs/api/index/functions/createMeshGeometryComponent.md +1 -1
- package/dist/docs/api/index/functions/createModelComponent.md +1 -1
- package/dist/docs/api/index/functions/createNameComponent.md +1 -1
- package/dist/docs/api/index/functions/createObject3DRefComponent.md +1 -1
- package/dist/docs/api/index/functions/createParentIdComponent.md +1 -1
- package/dist/docs/api/index/functions/createPhysicsComponent.md +1 -1
- package/dist/docs/api/index/functions/createPostprocessingComponent.md +1 -1
- package/dist/docs/api/index/functions/createScriptComponent.md +1 -1
- package/dist/docs/api/index/functions/createScriptObjectComponent.md +1 -1
- package/dist/docs/api/index/functions/createSelectableComponent.md +1 -1
- package/dist/docs/api/index/functions/createSelectionTransformStateComponent.md +1 -1
- package/dist/docs/api/index/functions/createSpriteComponent.md +1 -1
- package/dist/docs/api/index/functions/createTransformComponent.md +1 -1
- package/dist/docs/api/index/functions/createUIButtonComponent.md +28 -0
- package/dist/docs/api/index/functions/createUIPanelComponent.md +28 -0
- package/dist/docs/api/index/functions/createUISliderComponent.md +28 -0
- package/dist/docs/api/index/functions/createUITextComponent.md +28 -0
- package/dist/docs/api/index/functions/createUIToggleComponent.md +28 -0
- package/dist/docs/api/index/functions/createVRTeleportAreaComponent.md +28 -0
- package/dist/docs/api/index/functions/createVideoComponent.md +1 -1
- package/dist/docs/api/index/functions/createXRAnchorComponent.md +28 -0
- package/dist/docs/api/index/functions/createXRHandPoseComponent.md +28 -0
- package/dist/docs/api/index/functions/createXRInteractableComponent.md +28 -0
- package/dist/docs/api/index/functions/createXRInteractorComponent.md +28 -0
- package/dist/docs/api/index/functions/createXRInteractorSideComponent.md +28 -0
- package/dist/docs/api/index/functions/createXRRigComponent.md +28 -0
- package/dist/docs/api/index/functions/decanonicalizeComponentValue.md +1 -1
- package/dist/docs/api/index/functions/despawnPrefab.md +1 -1
- package/dist/docs/api/index/functions/encodeOverride.md +1 -1
- package/dist/docs/api/index/functions/estimateHandScale.md +28 -0
- package/dist/docs/api/index/functions/findSnapshotRootEntityIds.md +1 -1
- package/dist/docs/api/index/functions/findTopLevelNestedRegions.md +1 -1
- package/dist/docs/api/index/functions/getHandPosePreset.md +31 -0
- package/dist/docs/api/index/functions/groupOverridePaths.md +1 -1
- package/dist/docs/api/index/functions/handPoseFromCurls.md +42 -0
- package/dist/docs/api/index/functions/hydrateWorldFromSnapshot.md +1 -1
- package/dist/docs/api/index/functions/hydrateWorldFromSnapshotDetailed.md +1 -1
- package/dist/docs/api/index/functions/indexSnapshotByEntity.md +1 -1
- package/dist/docs/api/index/functions/instantiateSubtree.md +1 -1
- package/dist/docs/api/index/functions/loadPrefab.md +1 -1
- package/dist/docs/api/index/functions/loadSharedGltf.md +1 -1
- package/dist/docs/api/index/functions/matchHandPose.md +34 -0
- package/dist/docs/api/index/functions/mergeComponentValue.md +1 -1
- package/dist/docs/api/index/functions/parseOverride.md +1 -1
- package/dist/docs/api/index/functions/parsePrefabAsset.md +1 -1
- package/dist/docs/api/index/functions/prefabFileVersionFor.md +1 -1
- package/dist/docs/api/index/functions/readXrCapabilities.md +30 -0
- package/dist/docs/api/index/functions/registerDefaultComponentFactories.md +1 -1
- package/dist/docs/api/index/functions/registerDefaultFactories.md +1 -1
- package/dist/docs/api/index/functions/remapSnapshotEntityIds.md +3 -3
- package/dist/docs/api/index/functions/resolveDracoDecoderPath.md +1 -1
- package/dist/docs/api/index/functions/restoreComponentState.md +1 -1
- package/dist/docs/api/index/functions/restorePostCreateComponents.md +1 -1
- package/dist/docs/api/index/functions/sampleTeleportArc.md +40 -0
- package/dist/docs/api/index/functions/serializeEntitySubtree.md +1 -1
- package/dist/docs/api/index/functions/setDracoDecoderPath.md +1 -1
- package/dist/docs/api/index/functions/setPrefabAssetUrlResolver.md +1 -1
- package/dist/docs/api/index/functions/spawnPrefab.md +1 -1
- package/dist/docs/api/index/index.md +116 -4
- package/dist/docs/api/index/interfaces/ChromaKeyOptions.md +20 -0
- package/dist/docs/api/index/interfaces/EcsSystem.md +3 -3
- package/dist/docs/api/index/interfaces/PostprocessingBuildContext.md +21 -0
- package/dist/docs/api/index/interfaces/PostprocessingPipeline.md +84 -0
- package/dist/docs/api/index/interfaces/RenderBackend.md +168 -0
- package/dist/docs/api/index/interfaces/StateMachine.md +13 -13
- package/dist/docs/api/index/type-aliases/AnimationStateCallbacks.md +4 -4
- package/dist/docs/api/index/type-aliases/ApplyPrefabToSnapshotResult.md +3 -3
- package/dist/docs/api/index/type-aliases/ComponentFactory.md +1 -1
- package/dist/docs/api/index/type-aliases/ComponentValueMaps.md +50 -26
- package/dist/docs/api/index/type-aliases/EcsComponentFactoryKind.md +14 -2
- package/dist/docs/api/index/type-aliases/EcsRenderer.md +17 -0
- package/dist/docs/api/index/type-aliases/EcsWorldComponentSnapshot.md +3 -3
- package/dist/docs/api/index/type-aliases/EcsWorldStateSnapshotLike.md +4 -4
- package/dist/docs/api/index/type-aliases/ExternalRefWarning.md +5 -5
- package/dist/docs/api/index/type-aliases/HandMaterialOptions.md +32 -0
- package/dist/docs/api/index/type-aliases/HandPoseTrackerOptions.md +27 -0
- package/dist/docs/api/index/type-aliases/HydrateOptions.md +3 -3
- package/dist/docs/api/index/type-aliases/HydrateWorldFromSnapshotResult.md +4 -4
- package/dist/docs/api/index/type-aliases/InstantiateSubtreeResult.md +3 -3
- package/dist/docs/api/index/type-aliases/KeyboardKey.md +1 -1
- package/dist/docs/api/index/type-aliases/ModuleLoader.md +1 -1
- package/dist/docs/api/index/type-aliases/MouseButton.md +1 -1
- package/dist/docs/api/index/type-aliases/NestedRegion.md +5 -5
- package/dist/docs/api/index/type-aliases/NodeKeyMaps.md +5 -5
- package/dist/docs/api/index/type-aliases/NodeMaps.md +4 -4
- package/dist/docs/api/index/type-aliases/PrefabAsset.md +5 -5
- package/dist/docs/api/index/type-aliases/RemapSnapshotOptions.md +2 -2
- package/dist/docs/api/index/type-aliases/RendererKind.md +15 -0
- package/dist/docs/api/index/type-aliases/ScriptBehaviourSystemOptions.md +23 -0
- package/dist/docs/api/index/type-aliases/ScriptErrorEvent.md +39 -0
- package/dist/docs/api/index/type-aliases/ScriptErrorListener.md +25 -0
- package/dist/docs/api/index/type-aliases/ScriptErrorPhase.md +28 -0
- package/dist/docs/api/index/type-aliases/ScriptErrorReport.md +31 -0
- package/dist/docs/api/index/type-aliases/ScriptErrorSource.md +15 -0
- package/dist/docs/api/index/type-aliases/SelectionContext.md +4 -4
- package/dist/docs/api/index/type-aliases/SerializeEntitySubtreeResult.md +4 -4
- package/dist/docs/api/index/type-aliases/SpawnPrefabOptions.md +5 -5
- package/dist/docs/api/index/type-aliases/SpawnPrefabSource.md +1 -1
- package/dist/docs/api/index/type-aliases/SubtreeSnapshot.md +3 -3
- package/dist/docs/api/index/type-aliases/UiCanvasLike.md +46 -0
- package/dist/docs/api/index/type-aliases/VelocitySample.md +23 -0
- package/dist/docs/api/index/type-aliases/XrCapabilities.md +41 -0
- package/dist/docs/api/index/type-aliases/XrFinger.md +13 -0
- package/dist/docs/api/index/type-aliases/XrFingerCurl.md +27 -0
- package/dist/docs/api/index/type-aliases/XrFingerTarget.md +31 -0
- package/dist/docs/api/index/type-aliases/XrHandJointName.md +40 -0
- package/dist/docs/api/index/type-aliases/XrHandJoints.md +18 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseAxis.md +15 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseContext.md +23 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseDefinition.md +47 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseDirection.md +21 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseEvent.md +13 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseEventDetail.md +27 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseMatch.md +25 -0
- package/dist/docs/api/index/type-aliases/XrHandPoseOrientation.md +25 -0
- package/dist/docs/api/index/type-aliases/XrHandShape.md +46 -0
- package/dist/docs/api/index/type-aliases/XrHandedness.md +15 -0
- package/dist/docs/api/index/type-aliases/XrHitResult.md +25 -0
- package/dist/docs/api/index/type-aliases/XrInputKind.md +19 -0
- package/dist/docs/api/index/type-aliases/XrInputState.md +60 -0
- package/dist/docs/api/index/type-aliases/XrPalmPose.md +31 -0
- package/dist/docs/api/index/variables/ADDED_NODE_MARKER_COMPONENT.md +2 -2
- package/dist/docs/api/index/variables/ARC_GRAVITY.md +15 -0
- package/dist/docs/api/index/variables/ARC_MAX_TIME.md +15 -0
- package/dist/docs/api/index/variables/ARC_SPEED.md +15 -0
- package/dist/docs/api/index/variables/ARC_STEPS.md +15 -0
- package/dist/docs/api/index/variables/CURLED_COS.md +13 -0
- package/dist/docs/api/index/variables/DEFAULT_DIRECTION_TOLERANCE.md +15 -0
- package/dist/docs/api/index/variables/DEFAULT_ENTER_CONFIDENCE.md +13 -0
- package/dist/docs/api/index/variables/DEFAULT_EXIT_CONFIDENCE.md +13 -0
- package/dist/docs/api/index/variables/DEFAULT_LOST_GRACE_SECONDS.md +13 -0
- package/dist/docs/api/index/variables/DEFAULT_MIN_HOLD_SECONDS.md +13 -0
- package/dist/docs/api/index/variables/DEFAULT_SCRIPT_ERROR_RETRY_DELAY.md +17 -0
- package/dist/docs/api/index/variables/FALLBACK_HAND_SCALE.md +15 -0
- package/dist/docs/api/index/variables/HAND_POSE_PRESETS.md +19 -0
- package/dist/docs/api/index/variables/HAND_POSE_PRESET_IDS.md +15 -0
- package/dist/docs/api/index/variables/HYDRATABLE_ENTITY_KINDS.md +1 -1
- package/dist/docs/api/index/variables/KeyboardKeys.md +89 -89
- package/dist/docs/api/index/variables/MATCH_FALLOFF.md +15 -0
- package/dist/docs/api/index/variables/MAX_PLAUSIBLE_SPEED.md +25 -0
- package/dist/docs/api/index/variables/MAX_SAMPLE_AGE_SECONDS.md +18 -0
- package/dist/docs/api/index/variables/NODE_KEY_SEPARATOR.md +1 -1
- package/dist/docs/api/index/variables/NO_XR_CAPABILITIES.md +15 -0
- package/dist/docs/api/index/variables/OVERRIDE_DIFF_EXCLUDED_COMPONENTS.md +1 -1
- package/dist/docs/api/index/variables/OVERRIDE_ROOT_EXCLUDED_COMPONENTS.md +1 -1
- package/dist/docs/api/index/variables/PINCH_FINGERS.md +15 -0
- package/dist/docs/api/index/variables/PREFAB_FILE_VERSION.md +1 -1
- package/dist/docs/api/index/variables/PREFAB_FILE_VERSION_NESTED.md +1 -1
- package/dist/docs/api/index/variables/SCRIPT_OBJECT_ROOT_FLAG.md +1 -1
- package/dist/docs/api/index/variables/SHARED_MODEL_RESOURCE_FLAG.md +1 -1
- package/dist/docs/api/index/variables/STRAIGHT_COS.md +19 -0
- package/dist/docs/api/index/variables/VELOCITY_SAMPLES.md +15 -0
- package/dist/docs/api/index/variables/XR_FINGERS.md +13 -0
- package/dist/docs/api/index/variables/XR_HOVER_SHELL_FLAG.md +15 -0
- package/dist/docs/api/index/variables/webglBackend.md +16 -0
- package/dist/docs/api/typedoc-sidebar.json +1 -1
- package/dist/docs/api/types/type-aliases/AssetInput.md +3 -3
- package/dist/docs/api/types/type-aliases/CheckboxInput.md +3 -3
- package/dist/docs/api/types/type-aliases/ColorInput.md +1 -1
- package/dist/docs/api/types/type-aliases/ComponentInput.md +4 -4
- package/dist/docs/api/types/type-aliases/ComponentKind.md +1 -1
- package/dist/docs/api/types/type-aliases/DropdownInput.md +3 -3
- package/dist/docs/api/types/type-aliases/DropdownOption.md +3 -3
- package/dist/docs/api/types/type-aliases/EcsEntityEditorKind.md +1 -1
- package/dist/docs/api/types/type-aliases/EcsEntityKind.md +10 -2
- package/dist/docs/api/types/type-aliases/EntityId.md +1 -1
- package/dist/docs/api/types/type-aliases/EntityInput.md +3 -3
- package/dist/docs/api/types/type-aliases/FloatInput.md +1 -1
- package/dist/docs/api/types/type-aliases/IntersectionResult.md +3 -3
- package/dist/docs/api/types/type-aliases/ParentLookup.md +3 -3
- package/dist/docs/api/types/type-aliases/SelectionListener.md +1 -1
- package/dist/docs/api/types/type-aliases/SliderInput.md +5 -5
- package/dist/docs/api/types/type-aliases/TextInput.md +1 -1
- package/dist/docs/api/types/type-aliases/ToggleInput.md +1 -1
- package/dist/docs/api/types/type-aliases/Vec3.md +1 -1
- package/dist/docs/api/types/type-aliases/Vector2Input.md +3 -3
- package/dist/docs/api/types/type-aliases/Vector3Input.md +4 -4
- package/dist/docs/api/types/type-aliases/WorldEntityView.md +1 -1
- package/dist/docs/guide/audio-mixing-and-sound-banks.md +71 -0
- package/dist/docs/guide/authoring-a-behaviour.md +3 -3
- package/dist/docs/guide/authoring-a-script-object.md +12 -9
- package/dist/docs/guide/behaviour-data-binding/index.md +11 -11
- package/dist/docs/guide/behaviour-lifecycle.md +9 -0
- package/dist/docs/guide/bone-attachments-and-ik.md +128 -0
- package/dist/docs/guide/component-catalog.md +10 -2
- package/dist/docs/guide/components/light.md +42 -0
- package/dist/docs/guide/components/model.md +32 -3
- package/dist/docs/guide/concepts.md +2 -2
- package/dist/docs/guide/getting-started/creating-objects.md +2 -2
- package/dist/docs/guide/getting-started/editing-objects.md +2 -2
- package/dist/docs/guide/getting-started/editor/ai-agent.md +227 -0
- package/dist/docs/guide/getting-started/editor/hierarchy.md +2 -2
- package/dist/docs/guide/getting-started/editor/index.md +3 -2
- package/dist/docs/guide/getting-started/editor/inspector.md +2 -2
- package/dist/docs/guide/getting-started/editor/scene-inspector.md +3 -3
- package/dist/docs/guide/getting-started/editor/toolbar.md +11 -11
- package/dist/docs/guide/getting-started/editor/viewport.md +17 -9
- package/dist/docs/guide/getting-started/index.md +1 -1
- package/dist/docs/guide/getting-started/installation.md +1 -1
- package/dist/docs/guide/getting-started/preview-and-test.md +7 -7
- package/dist/docs/guide/getting-started/project-types/image-tracking.md +23 -11
- package/dist/docs/guide/getting-started/project-types/index.md +4 -4
- package/dist/docs/guide/getting-started/project-types/vr.md +270 -2
- package/dist/docs/guide/getting-started/projects.md +4 -5
- package/dist/docs/guide/getting-started/shortcuts.md +5 -4
- package/dist/docs/guide/multiplayer.md +92 -0
- package/dist/docs/guide/scene/environment.md +101 -4
- package/dist/docs/guide/scene/index.md +4 -4
- package/dist/docs/guide/scene/postprocessing.md +67 -5
- package/dist/docs/guide/spawning/area-light.md +2 -0
- package/dist/docs/guide/systems/environment-sync-system.md +11 -6
- package/dist/docs/guide/systems/light-sync-system.md +5 -3
- package/dist/docs/guide/systems/postprocessing-sync-system.md +16 -6
- package/dist/docs/guide/systems/render-system.md +7 -6
- package/dist/docs/guide/systems/script-behaviour-system.md +7 -5
- package/dist/docs/guide/systems/script-object-system.md +3 -1
- package/dist/docs/guide/systems/video-system.md +1 -1
- package/dist/docs/guide/webgpu-and-tsl.md +415 -0
- package/dist/docs/guide/world-api.md +52 -2
- package/dist/factories/index.cjs +770 -283
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +14 -3
- package/dist/factories/index.d.ts +14 -3
- package/dist/factories/index.js +7 -4
- package/dist/{index-D2Jt_JzH.d.ts → index-C61n65PE.d.ts} +135 -42
- package/dist/{index-DaG03vyN.d.cts → index-C70N4BYG.d.cts} +135 -42
- package/dist/{index-C3ik3sA1.d.ts → index-D9DjrUn3.d.cts} +25 -3
- package/dist/{index-Dlr-7-4m.d.cts → index-DppafVu4.d.ts} +25 -3
- package/dist/index.cjs +3642 -1263
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -11
- package/dist/index.d.ts +113 -11
- package/dist/index.js +187 -12
- package/dist/index.js.map +1 -1
- package/dist/network/index.cjs +4896 -0
- package/dist/network/index.cjs.map +1 -0
- package/dist/network/index.d.cts +98 -0
- package/dist/network/index.d.ts +98 -0
- package/dist/network/index.js +493 -0
- package/dist/network/index.js.map +1 -0
- package/dist/systems/index.cjs +3958 -1762
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +4 -2
- package/dist/systems/index.d.ts +4 -2
- package/dist/systems/index.js +8 -4
- package/dist/types.d.cts +3 -1
- package/dist/types.d.ts +3 -1
- package/dist/webgpu/index.d.ts +113 -0
- package/dist/webgpu/index.js +302 -0
- package/dist/webgpu/index.js.map +1 -0
- package/dist/worldSnapshotUtils.d.cts +3 -1
- package/dist/worldSnapshotUtils.d.ts +3 -1
- package/dist/worldSnapshotUtils.js +3 -2
- package/package.json +19 -3
- package/dist/chunk-BUEKOSR5.js.map +0 -1
- package/dist/chunk-DF5SSRN6.js.map +0 -1
- package/dist/chunk-OWQSESTO.js.map +0 -1
- package/dist/chunk-OY7ZODZP.js.map +0 -1
- package/dist/chunk-RXBLOO5B.js.map +0 -1
- package/dist/chunk-WJD2VKEH.js +0 -315
- package/dist/chunk-WJD2VKEH.js.map +0 -1
|
@@ -0,0 +1,1237 @@
|
|
|
1
|
+
import { AnimationComponent, AudioComponent, Object3DRef, CameraComponent, MeshGeometryComponent, PhysicsComponent, Environment, EntityType, ImageComponent, ImageTargetAnchor, ImageTarget, LightComponent, MaterialComponent, MeshComponent, ModelComponent, Name, ParentId, Postprocessing, ScriptComponent, ScriptObjectComponent, Selectable, SelectionTransformState, SpriteComponent, TransformComponent, InstancedMeshComponent, InstanceSlotComponent, VideoComponent, XRRigComponent, VRTeleportAreaComponent, XRHandPoseComponent, XRAnchorComponent, BoneAttachmentComponent, IKComponent, NetworkIdentityComponent, NetworkTransformComponent, NetworkedPropsComponent, NetworkSpawnerComponent, XRInteractableComponent, XRInteractorComponent, XRInteractorSideComponent, UIButtonComponent, UIPanelComponent, UISliderComponent, UITextComponent, UIToggleComponent, setModelLoadState } from './chunk-NNDUOQ7O.js';
|
|
2
|
+
import { detectRig, skeletonFromObject3D } from './chunk-GSWC6LLD.js';
|
|
3
|
+
import { __name } from './chunk-XE4OXN2W.js';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
|
6
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
7
|
+
import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js';
|
|
8
|
+
import { clone } from 'three/examples/jsm/utils/SkeletonUtils.js';
|
|
9
|
+
|
|
10
|
+
// core/factories/components/AnimationFactory.ts
|
|
11
|
+
function createAnimationComponent(world, entityId, ...args) {
|
|
12
|
+
const component = new AnimationComponent(...args);
|
|
13
|
+
world.addComponent(entityId, component);
|
|
14
|
+
return component;
|
|
15
|
+
}
|
|
16
|
+
__name(createAnimationComponent, "createAnimationComponent");
|
|
17
|
+
function normalizeDistanceModel(distanceModel) {
|
|
18
|
+
const normalized = distanceModel.trim().toLowerCase();
|
|
19
|
+
if (normalized === "linear" || normalized === "exponential") {
|
|
20
|
+
return normalized;
|
|
21
|
+
}
|
|
22
|
+
return "inverse";
|
|
23
|
+
}
|
|
24
|
+
__name(normalizeDistanceModel, "normalizeDistanceModel");
|
|
25
|
+
function createConfiguredAudio(listener, options) {
|
|
26
|
+
const sound = options.positional ? new THREE.PositionalAudio(listener) : new THREE.Audio(listener);
|
|
27
|
+
sound.setLoop(options.loop);
|
|
28
|
+
sound.setVolume(options.volume);
|
|
29
|
+
sound.setPlaybackRate(options.pitch);
|
|
30
|
+
if (sound instanceof THREE.PositionalAudio) {
|
|
31
|
+
sound.setRefDistance(options.refDistance);
|
|
32
|
+
sound.setDistanceModel(normalizeDistanceModel(options.distanceModel));
|
|
33
|
+
sound.setRolloffFactor(options.rolloffFactor);
|
|
34
|
+
}
|
|
35
|
+
return sound;
|
|
36
|
+
}
|
|
37
|
+
__name(createConfiguredAudio, "createConfiguredAudio");
|
|
38
|
+
function createAudioEditorHelper() {
|
|
39
|
+
if (typeof document === "undefined") {
|
|
40
|
+
const geometry = new THREE.EdgesGeometry(
|
|
41
|
+
new THREE.OctahedronGeometry(0.22, 0)
|
|
42
|
+
);
|
|
43
|
+
const material2 = new THREE.LineBasicMaterial({
|
|
44
|
+
color: "#8bc8ff",
|
|
45
|
+
transparent: true,
|
|
46
|
+
opacity: 0.95,
|
|
47
|
+
depthTest: false
|
|
48
|
+
});
|
|
49
|
+
const fallback = new THREE.LineSegments(geometry, material2);
|
|
50
|
+
fallback.renderOrder = 10;
|
|
51
|
+
fallback.userData.ecsHelper = true;
|
|
52
|
+
fallback.visible = false;
|
|
53
|
+
return fallback;
|
|
54
|
+
}
|
|
55
|
+
const size = 96;
|
|
56
|
+
const canvas = document.createElement("canvas");
|
|
57
|
+
canvas.width = size;
|
|
58
|
+
canvas.height = size;
|
|
59
|
+
const ctx = canvas.getContext("2d");
|
|
60
|
+
if (!ctx) {
|
|
61
|
+
return new THREE.Object3D();
|
|
62
|
+
}
|
|
63
|
+
ctx.clearRect(0, 0, size, size);
|
|
64
|
+
ctx.fillStyle = "rgba(27, 35, 52, 0.9)";
|
|
65
|
+
ctx.beginPath();
|
|
66
|
+
ctx.arc(size / 2, size / 2, 36, 0, Math.PI * 2);
|
|
67
|
+
ctx.fill();
|
|
68
|
+
ctx.strokeStyle = "rgba(137, 202, 255, 0.9)";
|
|
69
|
+
ctx.lineWidth = 4;
|
|
70
|
+
ctx.beginPath();
|
|
71
|
+
ctx.arc(size / 2, size / 2, 36, 0, Math.PI * 2);
|
|
72
|
+
ctx.stroke();
|
|
73
|
+
ctx.fillStyle = "#d9ecff";
|
|
74
|
+
ctx.beginPath();
|
|
75
|
+
ctx.moveTo(33, 56);
|
|
76
|
+
ctx.lineTo(43, 56);
|
|
77
|
+
ctx.lineTo(54, 66);
|
|
78
|
+
ctx.lineTo(54, 30);
|
|
79
|
+
ctx.lineTo(43, 40);
|
|
80
|
+
ctx.lineTo(33, 40);
|
|
81
|
+
ctx.closePath();
|
|
82
|
+
ctx.fill();
|
|
83
|
+
ctx.strokeStyle = "#7fd2ff";
|
|
84
|
+
ctx.lineWidth = 4;
|
|
85
|
+
ctx.lineCap = "round";
|
|
86
|
+
ctx.beginPath();
|
|
87
|
+
ctx.arc(56, 48, 10, -0.8, 0.8);
|
|
88
|
+
ctx.stroke();
|
|
89
|
+
ctx.beginPath();
|
|
90
|
+
ctx.arc(56, 48, 16, -0.8, 0.8);
|
|
91
|
+
ctx.stroke();
|
|
92
|
+
const texture = new THREE.CanvasTexture(canvas);
|
|
93
|
+
texture.needsUpdate = true;
|
|
94
|
+
const material = new THREE.SpriteMaterial({
|
|
95
|
+
map: texture,
|
|
96
|
+
transparent: true,
|
|
97
|
+
depthTest: false
|
|
98
|
+
});
|
|
99
|
+
const helper = new THREE.Sprite(material);
|
|
100
|
+
helper.scale.set(0.68, 0.68, 0.68);
|
|
101
|
+
helper.renderOrder = 10;
|
|
102
|
+
helper.userData.ecsHelper = true;
|
|
103
|
+
helper.visible = false;
|
|
104
|
+
return helper;
|
|
105
|
+
}
|
|
106
|
+
__name(createAudioEditorHelper, "createAudioEditorHelper");
|
|
107
|
+
function createAudioComponent(world, entityId, path = "", options = {}, context) {
|
|
108
|
+
const component = new AudioComponent(path, options);
|
|
109
|
+
const anchor = context?.object ?? null;
|
|
110
|
+
const listener = context?.listener ?? null;
|
|
111
|
+
if (anchor && listener) {
|
|
112
|
+
component.object = anchor;
|
|
113
|
+
const sound = createConfiguredAudio(listener, component.options);
|
|
114
|
+
if (context?.isEditor) {
|
|
115
|
+
anchor.add(createAudioEditorHelper());
|
|
116
|
+
}
|
|
117
|
+
anchor.add(sound);
|
|
118
|
+
component.audio = sound;
|
|
119
|
+
}
|
|
120
|
+
world.addComponent(entityId, component);
|
|
121
|
+
return component;
|
|
122
|
+
}
|
|
123
|
+
__name(createAudioComponent, "createAudioComponent");
|
|
124
|
+
function createCameraComponent(world, entityId, payload = {}) {
|
|
125
|
+
const object = world.getComponent(entityId, Object3DRef)?.object;
|
|
126
|
+
const objectCamera = object instanceof THREE.Camera ? object : void 0;
|
|
127
|
+
const component = new CameraComponent({
|
|
128
|
+
...payload,
|
|
129
|
+
camera: payload.camera ?? objectCamera
|
|
130
|
+
});
|
|
131
|
+
world.addComponent(entityId, component);
|
|
132
|
+
return component;
|
|
133
|
+
}
|
|
134
|
+
__name(createCameraComponent, "createCameraComponent");
|
|
135
|
+
|
|
136
|
+
// core/factories/components/PhysicsFactory.ts
|
|
137
|
+
function deriveColliderFromGeometry(world, entityId) {
|
|
138
|
+
const meshGeometry = world.getComponent(entityId, MeshGeometryComponent);
|
|
139
|
+
if (!meshGeometry) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
switch (meshGeometry.kind) {
|
|
143
|
+
case "plane": {
|
|
144
|
+
const params = meshGeometry.parameters;
|
|
145
|
+
return {
|
|
146
|
+
collider: {
|
|
147
|
+
shape: "cuboid",
|
|
148
|
+
size: { x: params.width, y: params.height, z: 0.05 }
|
|
149
|
+
},
|
|
150
|
+
// An (effectively) zero-thickness sheet is only physically meaningful
|
|
151
|
+
// as static geometry — planes are floors/walls, not dynamic bodies.
|
|
152
|
+
rigidbody: { type: "fixed" }
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
case "cube": {
|
|
156
|
+
const params = meshGeometry.parameters;
|
|
157
|
+
return {
|
|
158
|
+
collider: {
|
|
159
|
+
shape: "cuboid",
|
|
160
|
+
size: { x: params.width, y: params.height, z: params.depth }
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
case "sphere": {
|
|
165
|
+
const params = meshGeometry.parameters;
|
|
166
|
+
return { collider: { shape: "ball", radius: params.radius } };
|
|
167
|
+
}
|
|
168
|
+
case "capsule": {
|
|
169
|
+
const params = meshGeometry.parameters;
|
|
170
|
+
return {
|
|
171
|
+
collider: {
|
|
172
|
+
shape: "capsule",
|
|
173
|
+
radius: params.radius,
|
|
174
|
+
height: params.height
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
case "cylinder": {
|
|
179
|
+
const params = meshGeometry.parameters;
|
|
180
|
+
return {
|
|
181
|
+
collider: {
|
|
182
|
+
shape: "cylinder",
|
|
183
|
+
radius: params.radius,
|
|
184
|
+
height: params.height
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
default:
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
__name(deriveColliderFromGeometry, "deriveColliderFromGeometry");
|
|
193
|
+
function createPhysicsComponent(world, entityId, values) {
|
|
194
|
+
const initial = values ?? deriveColliderFromGeometry(world, entityId) ?? void 0;
|
|
195
|
+
const component = new PhysicsComponent(initial);
|
|
196
|
+
world.addComponent(entityId, component);
|
|
197
|
+
return component;
|
|
198
|
+
}
|
|
199
|
+
__name(createPhysicsComponent, "createPhysicsComponent");
|
|
200
|
+
|
|
201
|
+
// core/factories/components/EnvironmentFactory.ts
|
|
202
|
+
function createEnvironmentComponent(world, entityId, values) {
|
|
203
|
+
const component = new Environment(values);
|
|
204
|
+
world.addComponent(entityId, component);
|
|
205
|
+
return component;
|
|
206
|
+
}
|
|
207
|
+
__name(createEnvironmentComponent, "createEnvironmentComponent");
|
|
208
|
+
|
|
209
|
+
// core/factories/components/EntityTypeFactory.ts
|
|
210
|
+
function createEntityTypeComponent(world, entityId, ...args) {
|
|
211
|
+
const component = new EntityType(...args);
|
|
212
|
+
world.addComponent(entityId, component);
|
|
213
|
+
return component;
|
|
214
|
+
}
|
|
215
|
+
__name(createEntityTypeComponent, "createEntityTypeComponent");
|
|
216
|
+
|
|
217
|
+
// core/factories/components/ImageComponentFactory.ts
|
|
218
|
+
function createImageComponent(world, entityId, ...args) {
|
|
219
|
+
const component = new ImageComponent(...args);
|
|
220
|
+
world.addComponent(entityId, component);
|
|
221
|
+
return component;
|
|
222
|
+
}
|
|
223
|
+
__name(createImageComponent, "createImageComponent");
|
|
224
|
+
|
|
225
|
+
// core/factories/components/ImageTargetAnchorFactory.ts
|
|
226
|
+
function createImageTargetAnchorComponent(world, entityId, ...args) {
|
|
227
|
+
const component = new ImageTargetAnchor(...args);
|
|
228
|
+
world.addComponent(entityId, component);
|
|
229
|
+
return component;
|
|
230
|
+
}
|
|
231
|
+
__name(createImageTargetAnchorComponent, "createImageTargetAnchorComponent");
|
|
232
|
+
|
|
233
|
+
// core/factories/components/ImageTargetFactory.ts
|
|
234
|
+
function createImageTargetComponent(world, entityId, ...args) {
|
|
235
|
+
const component = new ImageTarget(...args);
|
|
236
|
+
world.addComponent(entityId, component);
|
|
237
|
+
return component;
|
|
238
|
+
}
|
|
239
|
+
__name(createImageTargetComponent, "createImageTargetComponent");
|
|
240
|
+
|
|
241
|
+
// core/factories/components/LightFactory.ts
|
|
242
|
+
function createLightComponent(world, entityId, ...args) {
|
|
243
|
+
const component = new LightComponent(...args);
|
|
244
|
+
world.addComponent(entityId, component);
|
|
245
|
+
return component;
|
|
246
|
+
}
|
|
247
|
+
__name(createLightComponent, "createLightComponent");
|
|
248
|
+
|
|
249
|
+
// core/factories/components/MaterialFactory.ts
|
|
250
|
+
function createMaterialComponent(world, entityId, ...args) {
|
|
251
|
+
const component = new MaterialComponent(...args);
|
|
252
|
+
world.addComponent(entityId, component);
|
|
253
|
+
return component;
|
|
254
|
+
}
|
|
255
|
+
__name(createMaterialComponent, "createMaterialComponent");
|
|
256
|
+
|
|
257
|
+
// core/factories/components/MeshFactory.ts
|
|
258
|
+
function createMeshComponent(world, entityId, ...args) {
|
|
259
|
+
const component = new MeshComponent(...args);
|
|
260
|
+
world.addComponent(entityId, component);
|
|
261
|
+
return component;
|
|
262
|
+
}
|
|
263
|
+
__name(createMeshComponent, "createMeshComponent");
|
|
264
|
+
|
|
265
|
+
// core/factories/components/MeshGeometryFactory.ts
|
|
266
|
+
function createMeshGeometryComponent(world, entityId, ...args) {
|
|
267
|
+
const component = new MeshGeometryComponent(...args);
|
|
268
|
+
world.addComponent(entityId, component);
|
|
269
|
+
return component;
|
|
270
|
+
}
|
|
271
|
+
__name(createMeshGeometryComponent, "createMeshGeometryComponent");
|
|
272
|
+
|
|
273
|
+
// core/factories/components/ModelFactory.ts
|
|
274
|
+
function createModelComponent(world, entityId, ...args) {
|
|
275
|
+
const component = new ModelComponent(...args);
|
|
276
|
+
world.addComponent(entityId, component);
|
|
277
|
+
return component;
|
|
278
|
+
}
|
|
279
|
+
__name(createModelComponent, "createModelComponent");
|
|
280
|
+
|
|
281
|
+
// core/factories/components/NameFactory.ts
|
|
282
|
+
function createNameComponent(world, entityId, ...args) {
|
|
283
|
+
const component = new Name(...args);
|
|
284
|
+
world.addComponent(entityId, component);
|
|
285
|
+
return component;
|
|
286
|
+
}
|
|
287
|
+
__name(createNameComponent, "createNameComponent");
|
|
288
|
+
|
|
289
|
+
// core/factories/components/Object3DRefFactory.ts
|
|
290
|
+
function createObject3DRefComponent(world, entityId, ...args) {
|
|
291
|
+
const component = new Object3DRef(...args);
|
|
292
|
+
world.addComponent(entityId, component);
|
|
293
|
+
return component;
|
|
294
|
+
}
|
|
295
|
+
__name(createObject3DRefComponent, "createObject3DRefComponent");
|
|
296
|
+
|
|
297
|
+
// core/factories/components/ParentIdFactory.ts
|
|
298
|
+
function createParentIdComponent(world, entityId, ...args) {
|
|
299
|
+
const component = new ParentId(...args);
|
|
300
|
+
world.addComponent(entityId, component);
|
|
301
|
+
return component;
|
|
302
|
+
}
|
|
303
|
+
__name(createParentIdComponent, "createParentIdComponent");
|
|
304
|
+
|
|
305
|
+
// core/factories/components/PostprocessingFactory.ts
|
|
306
|
+
function createPostprocessingComponent(world, entityId, values) {
|
|
307
|
+
const component = new Postprocessing(values);
|
|
308
|
+
world.addComponent(entityId, component);
|
|
309
|
+
return component;
|
|
310
|
+
}
|
|
311
|
+
__name(createPostprocessingComponent, "createPostprocessingComponent");
|
|
312
|
+
|
|
313
|
+
// core/factories/components/ScriptComponentFactory.ts
|
|
314
|
+
function createScriptComponent(world, entityId, payload = {}) {
|
|
315
|
+
const entries = Array.isArray(payload.entries) ? payload.entries.map((entry) => ({
|
|
316
|
+
entityId,
|
|
317
|
+
className: typeof entry.className === "string" ? entry.className : "",
|
|
318
|
+
scriptUrl: typeof entry.scriptUrl === "string" ? entry.scriptUrl : "",
|
|
319
|
+
enabled: typeof entry.enabled === "boolean" ? entry.enabled : true,
|
|
320
|
+
data: entry.data && typeof entry.data === "object" && !Array.isArray(entry.data) ? entry.data : {},
|
|
321
|
+
runtimeState: entry.runtimeState,
|
|
322
|
+
runtimeMessage: typeof entry.runtimeMessage === "string" ? entry.runtimeMessage : void 0
|
|
323
|
+
})) : [];
|
|
324
|
+
const component = new ScriptComponent(entries);
|
|
325
|
+
world.addComponent(entityId, component);
|
|
326
|
+
return component;
|
|
327
|
+
}
|
|
328
|
+
__name(createScriptComponent, "createScriptComponent");
|
|
329
|
+
|
|
330
|
+
// core/factories/components/ScriptObjectComponentFactory.ts
|
|
331
|
+
function createScriptObjectComponent(world, entityId, payload = {}) {
|
|
332
|
+
const component = new ScriptObjectComponent(payload);
|
|
333
|
+
world.addComponent(entityId, component);
|
|
334
|
+
return component;
|
|
335
|
+
}
|
|
336
|
+
__name(createScriptObjectComponent, "createScriptObjectComponent");
|
|
337
|
+
|
|
338
|
+
// core/factories/components/SelectableFactory.ts
|
|
339
|
+
function createSelectableComponent(world, entityId, ...args) {
|
|
340
|
+
const component = new Selectable(...args);
|
|
341
|
+
world.addComponent(entityId, component);
|
|
342
|
+
return component;
|
|
343
|
+
}
|
|
344
|
+
__name(createSelectableComponent, "createSelectableComponent");
|
|
345
|
+
|
|
346
|
+
// core/factories/components/SelectionTransformStateFactory.ts
|
|
347
|
+
function createSelectionTransformStateComponent(world, entityId, ...args) {
|
|
348
|
+
const component = new SelectionTransformState(...args);
|
|
349
|
+
world.addComponent(entityId, component);
|
|
350
|
+
return component;
|
|
351
|
+
}
|
|
352
|
+
__name(createSelectionTransformStateComponent, "createSelectionTransformStateComponent");
|
|
353
|
+
|
|
354
|
+
// core/factories/components/SpriteFactory.ts
|
|
355
|
+
function createSpriteComponent(world, entityId, ...args) {
|
|
356
|
+
const component = new SpriteComponent(...args);
|
|
357
|
+
world.addComponent(entityId, component);
|
|
358
|
+
return component;
|
|
359
|
+
}
|
|
360
|
+
__name(createSpriteComponent, "createSpriteComponent");
|
|
361
|
+
|
|
362
|
+
// core/factories/components/TransformFactory.ts
|
|
363
|
+
function createTransformComponent(world, entityId, ...args) {
|
|
364
|
+
const component = new TransformComponent(...args);
|
|
365
|
+
world.addComponent(entityId, component);
|
|
366
|
+
return component;
|
|
367
|
+
}
|
|
368
|
+
__name(createTransformComponent, "createTransformComponent");
|
|
369
|
+
|
|
370
|
+
// core/factories/components/InstancedMeshComponentFactory.ts
|
|
371
|
+
function createInstancedMeshComponent(world, entityId, meshKind, meshParameters, options) {
|
|
372
|
+
const component = new InstancedMeshComponent(meshKind, meshParameters, options);
|
|
373
|
+
world.addComponent(entityId, component);
|
|
374
|
+
return component;
|
|
375
|
+
}
|
|
376
|
+
__name(createInstancedMeshComponent, "createInstancedMeshComponent");
|
|
377
|
+
|
|
378
|
+
// core/factories/components/InstanceSlotComponentFactory.ts
|
|
379
|
+
function createInstanceSlotComponent(world, entityId, groupEntityId, slotIndex) {
|
|
380
|
+
const component = new InstanceSlotComponent(groupEntityId, slotIndex);
|
|
381
|
+
world.addComponent(entityId, component);
|
|
382
|
+
return component;
|
|
383
|
+
}
|
|
384
|
+
__name(createInstanceSlotComponent, "createInstanceSlotComponent");
|
|
385
|
+
|
|
386
|
+
// core/factories/components/VideoFactory.ts
|
|
387
|
+
function createVideoComponent(world, entityId, ...args) {
|
|
388
|
+
const component = new VideoComponent(...args);
|
|
389
|
+
world.addComponent(entityId, component);
|
|
390
|
+
return component;
|
|
391
|
+
}
|
|
392
|
+
__name(createVideoComponent, "createVideoComponent");
|
|
393
|
+
|
|
394
|
+
// core/factories/components/XRRigFactory.ts
|
|
395
|
+
function createXRRigComponent(world, entityId, ...args) {
|
|
396
|
+
const component = new XRRigComponent(...args);
|
|
397
|
+
world.addComponent(entityId, component);
|
|
398
|
+
return component;
|
|
399
|
+
}
|
|
400
|
+
__name(createXRRigComponent, "createXRRigComponent");
|
|
401
|
+
|
|
402
|
+
// core/factories/components/VRTeleportAreaFactory.ts
|
|
403
|
+
function createVRTeleportAreaComponent(world, entityId, ...args) {
|
|
404
|
+
const component = new VRTeleportAreaComponent(...args);
|
|
405
|
+
world.addComponent(entityId, component);
|
|
406
|
+
return component;
|
|
407
|
+
}
|
|
408
|
+
__name(createVRTeleportAreaComponent, "createVRTeleportAreaComponent");
|
|
409
|
+
|
|
410
|
+
// core/factories/components/XRHandPoseFactory.ts
|
|
411
|
+
function createXRHandPoseComponent(world, entityId, ...args) {
|
|
412
|
+
const component = new XRHandPoseComponent(...args);
|
|
413
|
+
world.addComponent(entityId, component);
|
|
414
|
+
return component;
|
|
415
|
+
}
|
|
416
|
+
__name(createXRHandPoseComponent, "createXRHandPoseComponent");
|
|
417
|
+
|
|
418
|
+
// core/factories/components/XRAnchorFactory.ts
|
|
419
|
+
function createXRAnchorComponent(world, entityId, ...args) {
|
|
420
|
+
const component = new XRAnchorComponent(...args);
|
|
421
|
+
world.addComponent(entityId, component);
|
|
422
|
+
return component;
|
|
423
|
+
}
|
|
424
|
+
__name(createXRAnchorComponent, "createXRAnchorComponent");
|
|
425
|
+
|
|
426
|
+
// core/factories/components/BoneAttachmentFactory.ts
|
|
427
|
+
function createBoneAttachmentComponent(world, entityId, ...args) {
|
|
428
|
+
const component = new BoneAttachmentComponent(...args);
|
|
429
|
+
world.addComponent(entityId, component);
|
|
430
|
+
return component;
|
|
431
|
+
}
|
|
432
|
+
__name(createBoneAttachmentComponent, "createBoneAttachmentComponent");
|
|
433
|
+
|
|
434
|
+
// core/factories/components/IKFactory.ts
|
|
435
|
+
function createIKComponent(world, entityId, ...args) {
|
|
436
|
+
const component = new IKComponent(...args);
|
|
437
|
+
world.addComponent(entityId, component);
|
|
438
|
+
return component;
|
|
439
|
+
}
|
|
440
|
+
__name(createIKComponent, "createIKComponent");
|
|
441
|
+
|
|
442
|
+
// core/factories/components/NetworkFactory.ts
|
|
443
|
+
function createNetworkIdentityComponent(world, entityId) {
|
|
444
|
+
const component = new NetworkIdentityComponent();
|
|
445
|
+
world.addComponent(entityId, component);
|
|
446
|
+
return component;
|
|
447
|
+
}
|
|
448
|
+
__name(createNetworkIdentityComponent, "createNetworkIdentityComponent");
|
|
449
|
+
function createNetworkTransformComponent(world, entityId, ...args) {
|
|
450
|
+
const component = new NetworkTransformComponent(...args);
|
|
451
|
+
world.addComponent(entityId, component);
|
|
452
|
+
return component;
|
|
453
|
+
}
|
|
454
|
+
__name(createNetworkTransformComponent, "createNetworkTransformComponent");
|
|
455
|
+
function createNetworkedPropsComponent(world, entityId, ...args) {
|
|
456
|
+
const component = new NetworkedPropsComponent(...args);
|
|
457
|
+
world.addComponent(entityId, component);
|
|
458
|
+
return component;
|
|
459
|
+
}
|
|
460
|
+
__name(createNetworkedPropsComponent, "createNetworkedPropsComponent");
|
|
461
|
+
function createNetworkSpawnerComponent(world, entityId, ...args) {
|
|
462
|
+
const component = new NetworkSpawnerComponent(...args);
|
|
463
|
+
world.addComponent(entityId, component);
|
|
464
|
+
return component;
|
|
465
|
+
}
|
|
466
|
+
__name(createNetworkSpawnerComponent, "createNetworkSpawnerComponent");
|
|
467
|
+
|
|
468
|
+
// core/factories/components/XRInteractableFactory.ts
|
|
469
|
+
function createXRInteractableComponent(world, entityId, ...args) {
|
|
470
|
+
const component = new XRInteractableComponent(...args);
|
|
471
|
+
world.addComponent(entityId, component);
|
|
472
|
+
return component;
|
|
473
|
+
}
|
|
474
|
+
__name(createXRInteractableComponent, "createXRInteractableComponent");
|
|
475
|
+
|
|
476
|
+
// core/factories/components/XRInteractorFactory.ts
|
|
477
|
+
function createXRInteractorComponent(world, entityId, ...args) {
|
|
478
|
+
const component = new XRInteractorComponent(...args);
|
|
479
|
+
world.addComponent(entityId, component);
|
|
480
|
+
return component;
|
|
481
|
+
}
|
|
482
|
+
__name(createXRInteractorComponent, "createXRInteractorComponent");
|
|
483
|
+
|
|
484
|
+
// core/factories/components/XRInteractorSideFactory.ts
|
|
485
|
+
function createXRInteractorSideComponent(world, entityId, ...args) {
|
|
486
|
+
const component = new XRInteractorSideComponent(...args);
|
|
487
|
+
world.addComponent(entityId, component);
|
|
488
|
+
return component;
|
|
489
|
+
}
|
|
490
|
+
__name(createXRInteractorSideComponent, "createXRInteractorSideComponent");
|
|
491
|
+
|
|
492
|
+
// core/factories/components/UIButtonComponentFactory.ts
|
|
493
|
+
function createUIButtonComponent(world, entityId, ...args) {
|
|
494
|
+
const component = new UIButtonComponent(...args);
|
|
495
|
+
world.addComponent(entityId, component);
|
|
496
|
+
return component;
|
|
497
|
+
}
|
|
498
|
+
__name(createUIButtonComponent, "createUIButtonComponent");
|
|
499
|
+
|
|
500
|
+
// core/factories/components/UIPanelComponentFactory.ts
|
|
501
|
+
function createUIPanelComponent(world, entityId, ...args) {
|
|
502
|
+
const component = new UIPanelComponent(...args);
|
|
503
|
+
world.addComponent(entityId, component);
|
|
504
|
+
return component;
|
|
505
|
+
}
|
|
506
|
+
__name(createUIPanelComponent, "createUIPanelComponent");
|
|
507
|
+
|
|
508
|
+
// core/factories/components/UISliderComponentFactory.ts
|
|
509
|
+
function createUISliderComponent(world, entityId, ...args) {
|
|
510
|
+
const component = new UISliderComponent(...args);
|
|
511
|
+
world.addComponent(entityId, component);
|
|
512
|
+
return component;
|
|
513
|
+
}
|
|
514
|
+
__name(createUISliderComponent, "createUISliderComponent");
|
|
515
|
+
|
|
516
|
+
// core/factories/components/UITextComponentFactory.ts
|
|
517
|
+
function createUITextComponent(world, entityId, ...args) {
|
|
518
|
+
const component = new UITextComponent(...args);
|
|
519
|
+
world.addComponent(entityId, component);
|
|
520
|
+
return component;
|
|
521
|
+
}
|
|
522
|
+
__name(createUITextComponent, "createUITextComponent");
|
|
523
|
+
|
|
524
|
+
// core/factories/components/UIToggleComponentFactory.ts
|
|
525
|
+
function createUIToggleComponent(world, entityId, ...args) {
|
|
526
|
+
const component = new UIToggleComponent(...args);
|
|
527
|
+
world.addComponent(entityId, component);
|
|
528
|
+
return component;
|
|
529
|
+
}
|
|
530
|
+
__name(createUIToggleComponent, "createUIToggleComponent");
|
|
531
|
+
function collectBones(root) {
|
|
532
|
+
const bones = /* @__PURE__ */ new Set();
|
|
533
|
+
root.traverse((o) => {
|
|
534
|
+
if (o.isBone) bones.add(o);
|
|
535
|
+
const skinned = o;
|
|
536
|
+
if (skinned.isSkinnedMesh && skinned.skeleton) {
|
|
537
|
+
for (const b of skinned.skeleton.bones) bones.add(b);
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
return bones;
|
|
541
|
+
}
|
|
542
|
+
__name(collectBones, "collectBones");
|
|
543
|
+
function humanoidNames(root) {
|
|
544
|
+
try {
|
|
545
|
+
return detectRig(skeletonFromObject3D(root)).byName;
|
|
546
|
+
} catch {
|
|
547
|
+
return /* @__PURE__ */ new Map();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
__name(humanoidNames, "humanoidNames");
|
|
551
|
+
function listModelBones(root) {
|
|
552
|
+
const bones = collectBones(root);
|
|
553
|
+
const humanoid = humanoidNames(root);
|
|
554
|
+
const out = [];
|
|
555
|
+
const visit = /* @__PURE__ */ __name((o, parent, depth) => {
|
|
556
|
+
const isBone = bones.has(o);
|
|
557
|
+
if (isBone) {
|
|
558
|
+
out.push({ name: o.name, humanoid: humanoid.get(o.name) ?? null, parent: parent?.name ?? null, depth });
|
|
559
|
+
}
|
|
560
|
+
for (const c of o.children) visit(c, isBone ? o : parent, isBone ? depth + 1 : depth);
|
|
561
|
+
}, "visit");
|
|
562
|
+
visit(root, null, 0);
|
|
563
|
+
return out;
|
|
564
|
+
}
|
|
565
|
+
__name(listModelBones, "listModelBones");
|
|
566
|
+
function findModelBone(root, ref) {
|
|
567
|
+
const bones = collectBones(root);
|
|
568
|
+
const byName = /* @__PURE__ */ new Map();
|
|
569
|
+
for (const b of bones) if (!byName.has(b.name)) byName.set(b.name, b);
|
|
570
|
+
const name = ref.bone ?? "";
|
|
571
|
+
if (name) {
|
|
572
|
+
const hit = byName.get(name) ?? byName.get(THREE.PropertyBinding.sanitizeNodeName(name));
|
|
573
|
+
if (hit) return hit;
|
|
574
|
+
}
|
|
575
|
+
if (ref.humanoid) {
|
|
576
|
+
for (const [node, human] of humanoidNames(root)) {
|
|
577
|
+
if (human === ref.humanoid) return byName.get(node) ?? root.getObjectByName(node) ?? null;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
__name(findModelBone, "findModelBone");
|
|
583
|
+
|
|
584
|
+
// core/utils/dracoDecoderPath.ts
|
|
585
|
+
var LOCAL_DRACO_DECODER_RELATIVE_PATH = "./assets/draco/";
|
|
586
|
+
var DRACO_DECODER_CDN_PATH = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/";
|
|
587
|
+
var dracoDecoderPathOverride = null;
|
|
588
|
+
function setDracoDecoderPath(path) {
|
|
589
|
+
dracoDecoderPathOverride = path;
|
|
590
|
+
}
|
|
591
|
+
__name(setDracoDecoderPath, "setDracoDecoderPath");
|
|
592
|
+
function isBlockedBrowserFileUrl(url) {
|
|
593
|
+
return url.startsWith("file://");
|
|
594
|
+
}
|
|
595
|
+
__name(isBlockedBrowserFileUrl, "isBlockedBrowserFileUrl");
|
|
596
|
+
function resolveDracoDecoderPath() {
|
|
597
|
+
if (dracoDecoderPathOverride) {
|
|
598
|
+
return dracoDecoderPathOverride;
|
|
599
|
+
}
|
|
600
|
+
try {
|
|
601
|
+
const resolvedPath = new URL(
|
|
602
|
+
LOCAL_DRACO_DECODER_RELATIVE_PATH,
|
|
603
|
+
import.meta.url
|
|
604
|
+
).toString();
|
|
605
|
+
if (isBlockedBrowserFileUrl(resolvedPath)) {
|
|
606
|
+
return DRACO_DECODER_CDN_PATH;
|
|
607
|
+
}
|
|
608
|
+
return resolvedPath;
|
|
609
|
+
} catch {
|
|
610
|
+
return DRACO_DECODER_CDN_PATH;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
__name(resolveDracoDecoderPath, "resolveDracoDecoderPath");
|
|
614
|
+
function createGLTFLoader() {
|
|
615
|
+
const loader = new GLTFLoader();
|
|
616
|
+
try {
|
|
617
|
+
const dracoLoader = new DRACOLoader();
|
|
618
|
+
dracoLoader.setDecoderPath(resolveDracoDecoderPath());
|
|
619
|
+
loader.setDRACOLoader(dracoLoader);
|
|
620
|
+
} catch (error) {
|
|
621
|
+
console.warn("DRACOLoader could not be configured. Loading non-Draco models only.", error);
|
|
622
|
+
}
|
|
623
|
+
loader.setMeshoptDecoder(MeshoptDecoder);
|
|
624
|
+
return loader;
|
|
625
|
+
}
|
|
626
|
+
__name(createGLTFLoader, "createGLTFLoader");
|
|
627
|
+
var SHARED_MODEL_RESOURCE_FLAG = "spatialEcsSharedModelResource";
|
|
628
|
+
var modelCache = /* @__PURE__ */ new Map();
|
|
629
|
+
function markSharedResources(root) {
|
|
630
|
+
root.traverse((child) => {
|
|
631
|
+
if (!(child instanceof THREE.Mesh)) {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
if (child.geometry) {
|
|
635
|
+
child.geometry.userData[SHARED_MODEL_RESOURCE_FLAG] = true;
|
|
636
|
+
}
|
|
637
|
+
const materials = Array.isArray(child.material) ? child.material : [child.material];
|
|
638
|
+
for (const material of materials) {
|
|
639
|
+
if (material) {
|
|
640
|
+
material.userData[SHARED_MODEL_RESOURCE_FLAG] = true;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
__name(markSharedResources, "markSharedResources");
|
|
646
|
+
function loadSharedGltf(url, load) {
|
|
647
|
+
let pending = modelCache.get(url);
|
|
648
|
+
if (!pending) {
|
|
649
|
+
pending = load().then((gltf) => {
|
|
650
|
+
markSharedResources(gltf.scene);
|
|
651
|
+
return gltf;
|
|
652
|
+
});
|
|
653
|
+
pending.catch(() => {
|
|
654
|
+
modelCache.delete(url);
|
|
655
|
+
});
|
|
656
|
+
modelCache.set(url, pending);
|
|
657
|
+
}
|
|
658
|
+
return pending;
|
|
659
|
+
}
|
|
660
|
+
__name(loadSharedGltf, "loadSharedGltf");
|
|
661
|
+
function cloneModelScene(scene) {
|
|
662
|
+
return clone(scene);
|
|
663
|
+
}
|
|
664
|
+
__name(cloneModelScene, "cloneModelScene");
|
|
665
|
+
function clearModelCache(url) {
|
|
666
|
+
if (typeof url === "string") {
|
|
667
|
+
modelCache.delete(url);
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
modelCache.clear();
|
|
671
|
+
}
|
|
672
|
+
__name(clearModelCache, "clearModelCache");
|
|
673
|
+
|
|
674
|
+
// core/factories/objects/shared.ts
|
|
675
|
+
function createBaseEntity(world, object, options) {
|
|
676
|
+
const entityId = world.createEntity();
|
|
677
|
+
object.userData.entityId = entityId;
|
|
678
|
+
const transform = createTransform(options.transformInput);
|
|
679
|
+
applyTransform(object, transform);
|
|
680
|
+
world.addComponent(entityId, transform);
|
|
681
|
+
createObject3DRefComponent(world, entityId, object);
|
|
682
|
+
createNameComponent(world, entityId, options.label);
|
|
683
|
+
createEntityTypeComponent(world, entityId, options.entityType);
|
|
684
|
+
createParentIdComponent(world, entityId, options.parentId ?? null);
|
|
685
|
+
createSelectableComponent(world, entityId, true);
|
|
686
|
+
return entityId;
|
|
687
|
+
}
|
|
688
|
+
__name(createBaseEntity, "createBaseEntity");
|
|
689
|
+
|
|
690
|
+
// core/factories/objects/ModelFactory.ts
|
|
691
|
+
function getModelFileName(path) {
|
|
692
|
+
const segments = path.split(/[\\/]/).filter(Boolean);
|
|
693
|
+
return segments[segments.length - 1] ?? "";
|
|
694
|
+
}
|
|
695
|
+
__name(getModelFileName, "getModelFileName");
|
|
696
|
+
function createModelLoader() {
|
|
697
|
+
return createGLTFLoader();
|
|
698
|
+
}
|
|
699
|
+
__name(createModelLoader, "createModelLoader");
|
|
700
|
+
function createModel({
|
|
701
|
+
world,
|
|
702
|
+
scene,
|
|
703
|
+
payload,
|
|
704
|
+
isEditor
|
|
705
|
+
}) {
|
|
706
|
+
const anchor = new THREE.Object3D();
|
|
707
|
+
const modelPath = payload.path ?? "";
|
|
708
|
+
const entityId = createBaseEntity(world, anchor, {
|
|
709
|
+
label: payload.name ?? "Model",
|
|
710
|
+
entityType: "model",
|
|
711
|
+
transformInput: payload.transform
|
|
712
|
+
});
|
|
713
|
+
const model = createModelComponent(world, entityId, modelPath);
|
|
714
|
+
createMeshGeometryComponent(world, entityId, "model", anchor, {}, {
|
|
715
|
+
modelName: getModelFileName(modelPath),
|
|
716
|
+
castShadow: false,
|
|
717
|
+
receiveShadow: false
|
|
718
|
+
});
|
|
719
|
+
model.object = anchor;
|
|
720
|
+
scene.add(anchor);
|
|
721
|
+
if (!modelPath) {
|
|
722
|
+
return entityId;
|
|
723
|
+
}
|
|
724
|
+
setModelLoadState(model, "loading");
|
|
725
|
+
loadModelInto({ world, entityId, anchor, modelPath, isEditor: Boolean(isEditor) });
|
|
726
|
+
return entityId;
|
|
727
|
+
}
|
|
728
|
+
__name(createModel, "createModel");
|
|
729
|
+
function loadModelInto({
|
|
730
|
+
world,
|
|
731
|
+
entityId,
|
|
732
|
+
anchor,
|
|
733
|
+
modelPath,
|
|
734
|
+
isEditor
|
|
735
|
+
}) {
|
|
736
|
+
const model = world.getComponent(entityId, ModelComponent);
|
|
737
|
+
const meshGeometry = world.getComponent(entityId, MeshGeometryComponent);
|
|
738
|
+
if (!model) return;
|
|
739
|
+
const attachLoadedModel = /* @__PURE__ */ __name((gltf, object) => {
|
|
740
|
+
if (!world.hasEntity(entityId) || world.getComponent(entityId, ModelComponent) !== model) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
object.userData.entityId = entityId;
|
|
744
|
+
object.traverse((child) => {
|
|
745
|
+
child.userData.entityId = entityId;
|
|
746
|
+
});
|
|
747
|
+
anchor.add(object);
|
|
748
|
+
model.object = object;
|
|
749
|
+
if (meshGeometry) meshGeometry.object = object;
|
|
750
|
+
if (gltf.animations.length > 0) {
|
|
751
|
+
let animation = world.getComponent(entityId, AnimationComponent);
|
|
752
|
+
if (!animation) {
|
|
753
|
+
animation = createAnimationComponent(world, entityId, {
|
|
754
|
+
clips: gltf.animations,
|
|
755
|
+
externalClipSources: [],
|
|
756
|
+
paused: false,
|
|
757
|
+
reverse: false,
|
|
758
|
+
timeScale: 1,
|
|
759
|
+
crossFadeDuration: 0
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
animation.setModelClips(gltf.animations);
|
|
763
|
+
}
|
|
764
|
+
setModelLoadState(model, "loaded");
|
|
765
|
+
}, "attachLoadedModel");
|
|
766
|
+
const onLoadError = /* @__PURE__ */ __name((error) => {
|
|
767
|
+
const message = error instanceof Error && error.message ? error.message : typeof error === "string" && error ? error : `Failed to load model: ${modelPath}`;
|
|
768
|
+
setModelLoadState(model, "error", message);
|
|
769
|
+
console.error(`Failed to load model: ${modelPath}`, error);
|
|
770
|
+
}, "onLoadError");
|
|
771
|
+
if (isEditor) {
|
|
772
|
+
createModelLoader().load(
|
|
773
|
+
modelPath,
|
|
774
|
+
(gltf) => attachLoadedModel(gltf, gltf.scene),
|
|
775
|
+
void 0,
|
|
776
|
+
onLoadError
|
|
777
|
+
);
|
|
778
|
+
} else {
|
|
779
|
+
loadSharedGltf(
|
|
780
|
+
modelPath,
|
|
781
|
+
() => new Promise((resolve, reject) => {
|
|
782
|
+
createModelLoader().load(modelPath, resolve, void 0, reject);
|
|
783
|
+
})
|
|
784
|
+
).then((gltf) => attachLoadedModel(gltf, cloneModelScene(gltf.scene))).catch(onLoadError);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
__name(loadModelInto, "loadModelInto");
|
|
788
|
+
function reloadModelEntity(world, entityId, isEditor) {
|
|
789
|
+
const model = world.getComponent(entityId, ModelComponent);
|
|
790
|
+
const anchor = world.getComponent(entityId, Object3DRef)?.object;
|
|
791
|
+
if (!model || !anchor || !model.path) return false;
|
|
792
|
+
const old = model.object;
|
|
793
|
+
if (old && old !== anchor) {
|
|
794
|
+
old.removeFromParent();
|
|
795
|
+
old.traverse((child) => {
|
|
796
|
+
const mesh = child;
|
|
797
|
+
if (mesh.geometry && !mesh.geometry.userData?.[SHARED_MODEL_RESOURCE_FLAG]) mesh.geometry.dispose();
|
|
798
|
+
const mats = Array.isArray(mesh.material) ? mesh.material : mesh.material ? [mesh.material] : [];
|
|
799
|
+
for (const m of mats) if (!m.userData?.[SHARED_MODEL_RESOURCE_FLAG]) m.dispose();
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
model.object = anchor;
|
|
803
|
+
setModelLoadState(model, "loading");
|
|
804
|
+
loadModelInto({ world, entityId, anchor, modelPath: model.path, isEditor });
|
|
805
|
+
return true;
|
|
806
|
+
}
|
|
807
|
+
__name(reloadModelEntity, "reloadModelEntity");
|
|
808
|
+
|
|
809
|
+
// core/systems/ObjectManagementSystem.ts
|
|
810
|
+
var BONE_SOCKET_FLAG = "__reluBoneSocket";
|
|
811
|
+
var _boneScale = new THREE.Vector3();
|
|
812
|
+
var _anchorScale = new THREE.Vector3();
|
|
813
|
+
function createTransform(input) {
|
|
814
|
+
return new TransformComponent(input);
|
|
815
|
+
}
|
|
816
|
+
__name(createTransform, "createTransform");
|
|
817
|
+
function applyTransform(object, transform) {
|
|
818
|
+
object.position.set(
|
|
819
|
+
transform.position.x,
|
|
820
|
+
transform.position.y,
|
|
821
|
+
transform.position.z
|
|
822
|
+
);
|
|
823
|
+
object.rotation.set(
|
|
824
|
+
transform.rotation.x,
|
|
825
|
+
transform.rotation.y,
|
|
826
|
+
transform.rotation.z
|
|
827
|
+
);
|
|
828
|
+
object.scale.set(transform.scale.x, transform.scale.y, transform.scale.z);
|
|
829
|
+
}
|
|
830
|
+
__name(applyTransform, "applyTransform");
|
|
831
|
+
var _ObjectManagementSystem = class _ObjectManagementSystem {
|
|
832
|
+
constructor(scene, camera, isEditor = false) {
|
|
833
|
+
this.registry = /* @__PURE__ */ new Map();
|
|
834
|
+
this.componentRegistry = /* @__PURE__ */ new Map();
|
|
835
|
+
this.createQueue = [];
|
|
836
|
+
this.boneSockets = /* @__PURE__ */ new Map();
|
|
837
|
+
/** Attachments whose bone wasn't found in a given model (skip re-searching every frame). */
|
|
838
|
+
this.boneMisses = /* @__PURE__ */ new Map();
|
|
839
|
+
this.scene = scene;
|
|
840
|
+
this.camera = camera;
|
|
841
|
+
this.isEditor = isEditor;
|
|
842
|
+
}
|
|
843
|
+
register(kind, factory) {
|
|
844
|
+
this.registry.set(kind, factory);
|
|
845
|
+
}
|
|
846
|
+
registerComponentFactory(kind, factory) {
|
|
847
|
+
this.componentRegistry.set(kind, factory);
|
|
848
|
+
}
|
|
849
|
+
getOrCreateAudioListener() {
|
|
850
|
+
const existing = this.camera.userData.ecsAudioListener;
|
|
851
|
+
if (existing instanceof THREE.AudioListener) {
|
|
852
|
+
return existing;
|
|
853
|
+
}
|
|
854
|
+
const listener = new THREE.AudioListener();
|
|
855
|
+
this.camera.add(listener);
|
|
856
|
+
this.camera.userData.ecsAudioListener = listener;
|
|
857
|
+
return listener;
|
|
858
|
+
}
|
|
859
|
+
isEditorMode() {
|
|
860
|
+
return this.isEditor;
|
|
861
|
+
}
|
|
862
|
+
getComponentFactory(kind) {
|
|
863
|
+
return this.componentRegistry.get(kind) ?? null;
|
|
864
|
+
}
|
|
865
|
+
createComponentNow(kind, world, entityId, ...args) {
|
|
866
|
+
const factory = this.componentRegistry.get(kind);
|
|
867
|
+
if (!factory) {
|
|
868
|
+
throw new Error(`Unknown component kind: ${kind}`);
|
|
869
|
+
}
|
|
870
|
+
return factory(world, entityId, ...args);
|
|
871
|
+
}
|
|
872
|
+
requestCreate(kind, payload = {}, onCreated) {
|
|
873
|
+
this.createQueue.push({ kind, payload, onCreated });
|
|
874
|
+
}
|
|
875
|
+
createNow(kind, world, payload = {}) {
|
|
876
|
+
const factory = this.registry.get(kind);
|
|
877
|
+
if (!factory) {
|
|
878
|
+
throw new Error(`Unknown object kind: ${kind}`);
|
|
879
|
+
}
|
|
880
|
+
const entityId = factory({
|
|
881
|
+
world,
|
|
882
|
+
scene: this.scene,
|
|
883
|
+
camera: this.camera,
|
|
884
|
+
payload,
|
|
885
|
+
isEditor: this.isEditor
|
|
886
|
+
});
|
|
887
|
+
const object = world.getComponent(entityId, Object3DRef)?.object;
|
|
888
|
+
if (object) {
|
|
889
|
+
object.userData.ecsKind = kind;
|
|
890
|
+
}
|
|
891
|
+
if (payload.parentId !== void 0) {
|
|
892
|
+
world.addComponent(entityId, new ParentId(payload.parentId));
|
|
893
|
+
}
|
|
894
|
+
return entityId;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Removes an entity from the ECS world and its associated `Object3D` from the
|
|
898
|
+
* THREE.js scene graph.
|
|
899
|
+
*
|
|
900
|
+
* @param world - The world the entity belongs to.
|
|
901
|
+
* @param entityId - The entity to remove.
|
|
902
|
+
* @param dispose - When `true`, traverses the entity's `Object3D` subtree and
|
|
903
|
+
* calls `.dispose()` on every `BufferGeometry` and `Material` found. Pass
|
|
904
|
+
* `true` when the entity will not be reused and you want to free GPU memory
|
|
905
|
+
* immediately (e.g. dynamically spawned objects). Defaults to `false`.
|
|
906
|
+
* @returns `true` if the entity existed and was removed; `false` if the entity
|
|
907
|
+
* was not found.
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* ```ts
|
|
911
|
+
* // Remove from scene, keep GPU resources (safe if geometry is shared)
|
|
912
|
+
* objects.deleteEntity(world, entityId);
|
|
913
|
+
*
|
|
914
|
+
* // Remove from scene and free GPU memory (use for one-off spawned objects)
|
|
915
|
+
* objects.deleteEntity(world, entityId, true);
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
918
|
+
deleteEntity(world, entityId, dispose = false) {
|
|
919
|
+
if (!world.hasEntity(entityId)) {
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
const object3d = world.getComponent(entityId, Object3DRef)?.object;
|
|
923
|
+
if (object3d?.parent) {
|
|
924
|
+
object3d.parent.remove(object3d);
|
|
925
|
+
}
|
|
926
|
+
if (dispose && object3d) {
|
|
927
|
+
object3d.traverse((child) => {
|
|
928
|
+
if (child instanceof THREE.Mesh) {
|
|
929
|
+
if (!child.geometry?.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {
|
|
930
|
+
child.geometry?.dispose();
|
|
931
|
+
}
|
|
932
|
+
const materials = Array.isArray(child.material) ? child.material : [child.material];
|
|
933
|
+
for (const mat of materials) {
|
|
934
|
+
if (mat && !mat.userData?.[SHARED_MODEL_RESOURCE_FLAG]) {
|
|
935
|
+
mat.dispose();
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
world.destroyEntity(entityId);
|
|
942
|
+
return true;
|
|
943
|
+
}
|
|
944
|
+
setParent(world, entityId, parentId, options) {
|
|
945
|
+
if (!world.hasEntity(entityId)) {
|
|
946
|
+
return false;
|
|
947
|
+
}
|
|
948
|
+
if (parentId !== null && !world.hasEntity(parentId)) {
|
|
949
|
+
return false;
|
|
950
|
+
}
|
|
951
|
+
if (parentId === entityId) {
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
let ancestor = parentId;
|
|
955
|
+
while (ancestor !== null) {
|
|
956
|
+
if (ancestor === entityId) {
|
|
957
|
+
return false;
|
|
958
|
+
}
|
|
959
|
+
ancestor = world.getComponent(ancestor, ParentId)?.value ?? null;
|
|
960
|
+
}
|
|
961
|
+
const parentComponent = world.getComponent(entityId, ParentId);
|
|
962
|
+
if (parentComponent) {
|
|
963
|
+
if (parentComponent.value === parentId) {
|
|
964
|
+
return false;
|
|
965
|
+
}
|
|
966
|
+
parentComponent.value = parentId;
|
|
967
|
+
} else {
|
|
968
|
+
world.addComponent(entityId, new ParentId(parentId));
|
|
969
|
+
}
|
|
970
|
+
if (world.getComponent(entityId, BoneAttachmentComponent)) {
|
|
971
|
+
world.removeComponent(entityId, BoneAttachmentComponent);
|
|
972
|
+
}
|
|
973
|
+
const preserveWorldTransform = options?.preserveWorldTransform ?? true;
|
|
974
|
+
if (preserveWorldTransform) {
|
|
975
|
+
const object = world.getComponent(entityId, Object3DRef)?.object;
|
|
976
|
+
const parentObject = parentId !== null ? world.getComponent(parentId, Object3DRef)?.object ?? null : null;
|
|
977
|
+
if (object) {
|
|
978
|
+
this.scene.updateMatrixWorld(true);
|
|
979
|
+
if (parentObject && parentObject !== object) {
|
|
980
|
+
parentObject.attach(object);
|
|
981
|
+
} else {
|
|
982
|
+
this.scene.attach(object);
|
|
983
|
+
}
|
|
984
|
+
object.updateMatrixWorld(true);
|
|
985
|
+
this.syncTransformComponentFromObject(world, entityId, object);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
this.reconcileSceneFromWorld(world);
|
|
989
|
+
return true;
|
|
990
|
+
}
|
|
991
|
+
syncTransformComponentFromObject(world, entityId, object) {
|
|
992
|
+
const transform = world.getComponent(entityId, TransformComponent);
|
|
993
|
+
if (!transform) {
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
transform.position.x = object.position.x;
|
|
997
|
+
transform.position.y = object.position.y;
|
|
998
|
+
transform.position.z = object.position.z;
|
|
999
|
+
transform.rotation.x = object.rotation.x;
|
|
1000
|
+
transform.rotation.y = object.rotation.y;
|
|
1001
|
+
transform.rotation.z = object.rotation.z;
|
|
1002
|
+
transform.scale.x = object.scale.x;
|
|
1003
|
+
transform.scale.y = object.scale.y;
|
|
1004
|
+
transform.scale.z = object.scale.z;
|
|
1005
|
+
}
|
|
1006
|
+
reconcileSceneFromWorld(world) {
|
|
1007
|
+
const worldObjects = /* @__PURE__ */ new Map();
|
|
1008
|
+
const entityIds = world.query(Object3DRef);
|
|
1009
|
+
for (const entityId of entityIds) {
|
|
1010
|
+
const object = world.getComponent(entityId, Object3DRef)?.object;
|
|
1011
|
+
if (!object) {
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
worldObjects.set(entityId, object);
|
|
1015
|
+
}
|
|
1016
|
+
for (const child of [...this.scene.children]) {
|
|
1017
|
+
const entityId = child.userData?.entityId;
|
|
1018
|
+
if (typeof entityId === "number" && !world.hasEntity(entityId)) {
|
|
1019
|
+
this.scene.remove(child);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
for (const entityId of [...this.boneSockets.keys()]) {
|
|
1023
|
+
if (!world.hasEntity(entityId)) this.dropBoneSocket(entityId);
|
|
1024
|
+
}
|
|
1025
|
+
for (const [entityId, object] of worldObjects.entries()) {
|
|
1026
|
+
const parentEntityId = world.getComponent(entityId, ParentId)?.value;
|
|
1027
|
+
const parentObject = typeof parentEntityId === "number" ? worldObjects.get(parentEntityId) : void 0;
|
|
1028
|
+
const expectedParent = this.resolveBoneSocket(world, entityId, typeof parentEntityId === "number" ? parentEntityId : null) ?? parentObject;
|
|
1029
|
+
if (expectedParent && expectedParent !== object) {
|
|
1030
|
+
if (object.parent !== expectedParent) {
|
|
1031
|
+
expectedParent.add(object);
|
|
1032
|
+
object.updateMatrixWorld(true);
|
|
1033
|
+
}
|
|
1034
|
+
continue;
|
|
1035
|
+
}
|
|
1036
|
+
if (object.parent !== this.scene) {
|
|
1037
|
+
this.scene.add(object);
|
|
1038
|
+
object.updateMatrixWorld(true);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
dropBoneSocket(entityId) {
|
|
1043
|
+
const s = this.boneSockets.get(entityId);
|
|
1044
|
+
if (!s) return;
|
|
1045
|
+
s.socket.removeFromParent();
|
|
1046
|
+
this.boneSockets.delete(entityId);
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* The socket an attached entity hangs under, or `null` (not attached, the
|
|
1050
|
+
* parent's model not loaded yet, or no such bone — the entity then sits
|
|
1051
|
+
* under its parent as an ordinary child).
|
|
1052
|
+
*/
|
|
1053
|
+
resolveBoneSocket(world, entityId, parentEntityId) {
|
|
1054
|
+
const attachment = world.getComponent(entityId, BoneAttachmentComponent);
|
|
1055
|
+
if (!attachment) {
|
|
1056
|
+
if (this.boneSockets.has(entityId)) this.dropBoneSocket(entityId);
|
|
1057
|
+
this.boneMisses.delete(entityId);
|
|
1058
|
+
return null;
|
|
1059
|
+
}
|
|
1060
|
+
const root = attachment.enabled && parentEntityId !== null ? world.getComponent(parentEntityId, ModelComponent)?.object ?? null : null;
|
|
1061
|
+
if (!root) {
|
|
1062
|
+
this.dropBoneSocket(entityId);
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
const key = `${attachment.bone}|${attachment.humanoid ?? ""}|${attachment.compensateScale}`;
|
|
1066
|
+
const current = this.boneSockets.get(entityId);
|
|
1067
|
+
if (current && current.modelUuid === root.uuid && current.key === key && current.socket.parent === current.bone) {
|
|
1068
|
+
this.fitSocketScale(world, current, parentEntityId, attachment.compensateScale);
|
|
1069
|
+
return current.socket;
|
|
1070
|
+
}
|
|
1071
|
+
this.dropBoneSocket(entityId);
|
|
1072
|
+
const missKey = `${root.uuid}|${key}`;
|
|
1073
|
+
if (this.boneMisses.get(entityId) === missKey) return null;
|
|
1074
|
+
const bone = findModelBone(root, attachment);
|
|
1075
|
+
if (!bone) {
|
|
1076
|
+
this.boneMisses.set(entityId, missKey);
|
|
1077
|
+
return null;
|
|
1078
|
+
}
|
|
1079
|
+
this.boneMisses.delete(entityId);
|
|
1080
|
+
const socket = new THREE.Object3D();
|
|
1081
|
+
socket.name = `socket:${bone.name}`;
|
|
1082
|
+
socket.userData[BONE_SOCKET_FLAG] = entityId;
|
|
1083
|
+
bone.add(socket);
|
|
1084
|
+
const s = { bone, socket, modelUuid: root.uuid, key };
|
|
1085
|
+
this.boneSockets.set(entityId, s);
|
|
1086
|
+
this.fitSocketScale(world, s, parentEntityId, attachment.compensateScale);
|
|
1087
|
+
return socket;
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Cancel the rig's own scale between the character and the bone (a
|
|
1091
|
+
* centimetre armature under a 0.01 node), so offsets are in the character's
|
|
1092
|
+
* units and the object keeps its size; the character entity's own scale
|
|
1093
|
+
* still applies, as it does to any child.
|
|
1094
|
+
*/
|
|
1095
|
+
fitSocketScale(world, s, parentEntityId, compensate) {
|
|
1096
|
+
if (!compensate) {
|
|
1097
|
+
s.socket.scale.set(1, 1, 1);
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
const anchor = parentEntityId !== null ? world.getComponent(parentEntityId, Object3DRef)?.object : null;
|
|
1101
|
+
s.bone.updateWorldMatrix(true, false);
|
|
1102
|
+
_boneScale.setFromMatrixScale(s.bone.matrixWorld);
|
|
1103
|
+
if (anchor) _anchorScale.setFromMatrixScale(anchor.matrixWorld);
|
|
1104
|
+
else _anchorScale.set(1, 1, 1);
|
|
1105
|
+
const safe = /* @__PURE__ */ __name((v) => Math.abs(v) < 1e-9 ? 1 : v, "safe");
|
|
1106
|
+
s.socket.scale.set(
|
|
1107
|
+
_anchorScale.x / safe(_boneScale.x),
|
|
1108
|
+
_anchorScale.y / safe(_boneScale.y),
|
|
1109
|
+
_anchorScale.z / safe(_boneScale.z)
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Load a model entity's file again and swap it in (the file was rewritten);
|
|
1114
|
+
* the entity, its components and children stay, attachments re-home.
|
|
1115
|
+
*/
|
|
1116
|
+
reloadModel(world, entityId) {
|
|
1117
|
+
return reloadModelEntity(world, entityId, this.isEditor);
|
|
1118
|
+
}
|
|
1119
|
+
/** Reload every model entity whose path `matches` (returns how many). */
|
|
1120
|
+
reloadModelsAt(world, matches) {
|
|
1121
|
+
let n = 0;
|
|
1122
|
+
for (const id of world.query(ModelComponent)) {
|
|
1123
|
+
const path = world.getComponent(id, ModelComponent)?.path ?? "";
|
|
1124
|
+
if (path && matches(path) && this.reloadModel(world, id)) n++;
|
|
1125
|
+
}
|
|
1126
|
+
return n;
|
|
1127
|
+
}
|
|
1128
|
+
/** The bones of an entity's loaded model (empty until it loads, or for a model without a skeleton). */
|
|
1129
|
+
listModelBones(world, entityId) {
|
|
1130
|
+
const root = world.getComponent(entityId, ModelComponent)?.object;
|
|
1131
|
+
return root ? listModelBones(root) : [];
|
|
1132
|
+
}
|
|
1133
|
+
/** The socket object an attached entity currently hangs under, if resolved. */
|
|
1134
|
+
getBoneSocket(entityId) {
|
|
1135
|
+
return this.boneSockets.get(entityId)?.socket ?? null;
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Fix `entityId` to a bone of `parentEntityId`'s model (making it the
|
|
1139
|
+
* parent if it isn't). With `preserveWorldTransform` (default) it stays
|
|
1140
|
+
* where it is and its Transform becomes the offset from the bone; without,
|
|
1141
|
+
* it snaps onto the bone (zero offset). Returns whether the bone was found
|
|
1142
|
+
* (when the model is still loading, the attachment is stored and resolves
|
|
1143
|
+
* once it loads, without preserving the pose).
|
|
1144
|
+
*/
|
|
1145
|
+
attachToBone(world, entityId, parentEntityId, ref, options) {
|
|
1146
|
+
if (!world.hasEntity(entityId) || !world.hasEntity(parentEntityId) || entityId === parentEntityId) {
|
|
1147
|
+
return { ok: false, resolved: false, bone: null };
|
|
1148
|
+
}
|
|
1149
|
+
for (let a = parentEntityId; a !== null; a = world.getComponent(a, ParentId)?.value ?? null) {
|
|
1150
|
+
if (a === entityId) return { ok: false, resolved: false, bone: null };
|
|
1151
|
+
}
|
|
1152
|
+
const object = world.getComponent(entityId, Object3DRef)?.object ?? null;
|
|
1153
|
+
this.scene.updateMatrixWorld(true);
|
|
1154
|
+
const worldMatrix = object ? object.matrixWorld.clone() : null;
|
|
1155
|
+
const bones = this.listModelBones(world, parentEntityId);
|
|
1156
|
+
let bone = ref.bone ?? "";
|
|
1157
|
+
let humanoid = ref.humanoid ?? null;
|
|
1158
|
+
const info = bones.find((b) => bone ? b.name === bone : b.humanoid === humanoid);
|
|
1159
|
+
if (info) {
|
|
1160
|
+
bone = info.name;
|
|
1161
|
+
humanoid = info.humanoid ?? humanoid;
|
|
1162
|
+
}
|
|
1163
|
+
const parent = world.getComponent(entityId, ParentId);
|
|
1164
|
+
if (parent) parent.value = parentEntityId;
|
|
1165
|
+
else world.addComponent(entityId, new ParentId(parentEntityId));
|
|
1166
|
+
let attachment = world.getComponent(entityId, BoneAttachmentComponent);
|
|
1167
|
+
if (!attachment) {
|
|
1168
|
+
attachment = new BoneAttachmentComponent();
|
|
1169
|
+
world.addComponent(entityId, attachment);
|
|
1170
|
+
}
|
|
1171
|
+
attachment.bone = bone;
|
|
1172
|
+
attachment.humanoid = humanoid;
|
|
1173
|
+
attachment.compensateScale = options?.compensateScale ?? true;
|
|
1174
|
+
attachment.enabled = true;
|
|
1175
|
+
this.boneMisses.delete(entityId);
|
|
1176
|
+
this.reconcileSceneFromWorld(world);
|
|
1177
|
+
const socket = this.getBoneSocket(entityId);
|
|
1178
|
+
if (object && socket) {
|
|
1179
|
+
if (options?.preserveWorldTransform ?? true) {
|
|
1180
|
+
socket.updateWorldMatrix(true, false);
|
|
1181
|
+
const local = socket.matrixWorld.clone().invert().multiply(worldMatrix);
|
|
1182
|
+
local.decompose(object.position, object.quaternion, object.scale);
|
|
1183
|
+
} else {
|
|
1184
|
+
object.position.set(0, 0, 0);
|
|
1185
|
+
object.quaternion.identity();
|
|
1186
|
+
object.scale.set(1, 1, 1);
|
|
1187
|
+
}
|
|
1188
|
+
object.updateMatrixWorld(true);
|
|
1189
|
+
this.syncTransformComponentFromObject(world, entityId, object);
|
|
1190
|
+
}
|
|
1191
|
+
return { ok: true, resolved: Boolean(socket), bone: bone || humanoid };
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Release a bone attachment. The entity stays a child of the character
|
|
1195
|
+
* (or moves to the root with `toRoot`), and by default keeps its place in
|
|
1196
|
+
* the world.
|
|
1197
|
+
*/
|
|
1198
|
+
detachFromBone(world, entityId, options) {
|
|
1199
|
+
if (!world.getComponent(entityId, BoneAttachmentComponent)) return false;
|
|
1200
|
+
const object = world.getComponent(entityId, Object3DRef)?.object ?? null;
|
|
1201
|
+
this.scene.updateMatrixWorld(true);
|
|
1202
|
+
const worldMatrix = object ? object.matrixWorld.clone() : null;
|
|
1203
|
+
world.removeComponent(entityId, BoneAttachmentComponent);
|
|
1204
|
+
this.boneMisses.delete(entityId);
|
|
1205
|
+
if (options?.toRoot) {
|
|
1206
|
+
const parent = world.getComponent(entityId, ParentId);
|
|
1207
|
+
if (parent) parent.value = null;
|
|
1208
|
+
}
|
|
1209
|
+
const parentId = world.getComponent(entityId, ParentId)?.value ?? null;
|
|
1210
|
+
const home = (parentId !== null ? world.getComponent(parentId, Object3DRef)?.object : null) ?? this.scene;
|
|
1211
|
+
this.dropBoneSocket(entityId);
|
|
1212
|
+
if (object) {
|
|
1213
|
+
home.add(object);
|
|
1214
|
+
if (worldMatrix && (options?.preserveWorldTransform ?? true)) {
|
|
1215
|
+
home.updateWorldMatrix(true, false);
|
|
1216
|
+
home.matrixWorld.clone().invert().multiply(worldMatrix).decompose(object.position, object.quaternion, object.scale);
|
|
1217
|
+
}
|
|
1218
|
+
object.updateMatrixWorld(true);
|
|
1219
|
+
this.syncTransformComponentFromObject(world, entityId, object);
|
|
1220
|
+
}
|
|
1221
|
+
this.reconcileSceneFromWorld(world);
|
|
1222
|
+
return true;
|
|
1223
|
+
}
|
|
1224
|
+
update(world) {
|
|
1225
|
+
for (const request of this.createQueue.splice(0)) {
|
|
1226
|
+
const entityId = this.createNow(request.kind, world, request.payload);
|
|
1227
|
+
request.onCreated?.(entityId);
|
|
1228
|
+
}
|
|
1229
|
+
this.reconcileSceneFromWorld(world);
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
__name(_ObjectManagementSystem, "ObjectManagementSystem");
|
|
1233
|
+
var ObjectManagementSystem = _ObjectManagementSystem;
|
|
1234
|
+
|
|
1235
|
+
export { ObjectManagementSystem, SHARED_MODEL_RESOURCE_FLAG, applyTransform, clearModelCache, createAnimationComponent, createAudioComponent, createBaseEntity, createBoneAttachmentComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createGLTFLoader, createIKComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModel, createModelComponent, createNameComponent, createNetworkIdentityComponent, createNetworkSpawnerComponent, createNetworkTransformComponent, createNetworkedPropsComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransform, createTransformComponent, createUIButtonComponent, createUIPanelComponent, createUISliderComponent, createUITextComponent, createUIToggleComponent, createVRTeleportAreaComponent, createVideoComponent, createXRAnchorComponent, createXRHandPoseComponent, createXRInteractableComponent, createXRInteractorComponent, createXRInteractorSideComponent, createXRRigComponent, findModelBone, listModelBones, loadSharedGltf, resolveDracoDecoderPath, setDracoDecoderPath };
|
|
1236
|
+
//# sourceMappingURL=chunk-G4XJ53LS.js.map
|
|
1237
|
+
//# sourceMappingURL=chunk-G4XJ53LS.js.map
|