@needle-tools/engine 4.13.0 → 4.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/README.md +37 -0
- package/components.needle.json +1 -1
- package/custom-elements.json +138 -4
- package/dist/{needle-engine.bundle-CxaKFQVS.min.js → needle-engine.bundle-BNIUpreS.min.js} +107 -107
- package/dist/{needle-engine.bundle-Dl3TFYyv.js → needle-engine.bundle-DauZUYl7.js} +2347 -1845
- package/dist/{needle-engine.bundle-J4k4znv8.umd.cjs → needle-engine.bundle-tjI5Fq2c.umd.cjs} +108 -108
- package/dist/needle-engine.d.ts +4022 -419
- package/dist/needle-engine.js +2 -2
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/engine_context.d.ts +16 -0
- package/lib/engine/engine_context.js +16 -0
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +72 -0
- package/lib/engine/engine_gameobject.js +38 -0
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_input.d.ts +80 -4
- package/lib/engine/engine_input.js +78 -2
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_math.d.ts +81 -2
- package/lib/engine/engine_math.js +68 -2
- package/lib/engine/engine_math.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +181 -14
- package/lib/engine/engine_networking.js +181 -14
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking_auto.d.ts +35 -8
- package/lib/engine/engine_networking_auto.js +35 -8
- package/lib/engine/engine_networking_auto.js.map +1 -1
- package/lib/engine/engine_physics.d.ts +37 -1
- package/lib/engine/engine_physics.js +37 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +78 -0
- package/lib/engine/engine_physics_rapier.js +78 -0
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_serialization_decorator.d.ts +28 -2
- package/lib/engine/engine_serialization_decorator.js +28 -2
- package/lib/engine/engine_serialization_decorator.js.map +1 -1
- package/lib/engine/engine_time.d.ts +23 -3
- package/lib/engine/engine_time.js +23 -3
- package/lib/engine/engine_time.js.map +1 -1
- package/lib/engine/engine_util_decorator.d.ts +31 -1
- package/lib/engine/engine_util_decorator.js +31 -1
- package/lib/engine/engine_util_decorator.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +21 -5
- package/lib/engine/engine_utils.js +21 -5
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_materialx.d.ts +2 -2
- package/lib/engine/extensions/NEEDLE_materialx.js +2 -2
- package/lib/engine/extensions/NEEDLE_materialx.js.map +1 -1
- package/lib/engine/extensions/index.d.ts +1 -1
- package/lib/engine/extensions/index.js +1 -1
- package/lib/engine/extensions/index.js.map +1 -1
- package/lib/engine-components/AlignmentConstraint.d.ts +23 -3
- package/lib/engine-components/AlignmentConstraint.js +23 -3
- package/lib/engine-components/AlignmentConstraint.js.map +1 -1
- package/lib/engine-components/Animation.d.ts +42 -0
- package/lib/engine-components/Animation.js +36 -0
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/Animator.d.ts +37 -4
- package/lib/engine-components/Animator.js +37 -4
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AudioListener.d.ts +1 -1
- package/lib/engine-components/AudioListener.js +1 -1
- package/lib/engine-components/AudioSource.d.ts +32 -10
- package/lib/engine-components/AudioSource.js +32 -10
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/AxesHelper.d.ts +22 -3
- package/lib/engine-components/AxesHelper.js +22 -3
- package/lib/engine-components/AxesHelper.js.map +1 -1
- package/lib/engine-components/BasicIKConstraint.d.ts +27 -4
- package/lib/engine-components/BasicIKConstraint.js +27 -4
- package/lib/engine-components/BasicIKConstraint.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +32 -2
- package/lib/engine-components/Camera.js +32 -2
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CharacterController.d.ts +68 -4
- package/lib/engine-components/CharacterController.js +68 -4
- package/lib/engine-components/CharacterController.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +69 -12
- package/lib/engine-components/Collider.js +69 -12
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/ContactShadows.d.ts +28 -6
- package/lib/engine-components/ContactShadows.js +33 -8
- package/lib/engine-components/ContactShadows.js.map +1 -1
- package/lib/engine-components/DeleteBox.d.ts +43 -2
- package/lib/engine-components/DeleteBox.js +43 -2
- package/lib/engine-components/DeleteBox.js.map +1 -1
- package/lib/engine-components/DeviceFlag.d.ts +21 -2
- package/lib/engine-components/DeviceFlag.js +21 -2
- package/lib/engine-components/DeviceFlag.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +32 -2
- package/lib/engine-components/DragControls.js +32 -2
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/DropListener.d.ts +33 -21
- package/lib/engine-components/DropListener.js +33 -21
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/Duplicatable.d.ts +36 -5
- package/lib/engine-components/Duplicatable.js +36 -5
- package/lib/engine-components/Duplicatable.js.map +1 -1
- package/lib/engine-components/EventList.d.ts +38 -10
- package/lib/engine-components/EventList.js +40 -12
- package/lib/engine-components/EventList.js.map +1 -1
- package/lib/engine-components/EventTrigger.d.ts +1 -1
- package/lib/engine-components/EventTrigger.js +1 -1
- package/lib/engine-components/Fog.d.ts +23 -1
- package/lib/engine-components/Fog.js +23 -1
- package/lib/engine-components/Fog.js.map +1 -1
- package/lib/engine-components/GridHelper.d.ts +18 -2
- package/lib/engine-components/GridHelper.js +18 -2
- package/lib/engine-components/GridHelper.js.map +1 -1
- package/lib/engine-components/GroundProjection.d.ts +24 -2
- package/lib/engine-components/GroundProjection.js +24 -2
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/Interactable.d.ts +17 -2
- package/lib/engine-components/Interactable.js +17 -2
- package/lib/engine-components/Interactable.js.map +1 -1
- package/lib/engine-components/Joints.d.ts +50 -7
- package/lib/engine-components/Joints.js +50 -7
- package/lib/engine-components/Joints.js.map +1 -1
- package/lib/engine-components/LODGroup.d.ts +36 -14
- package/lib/engine-components/LODGroup.js +43 -11
- package/lib/engine-components/LODGroup.js.map +1 -1
- package/lib/engine-components/Light.d.ts +30 -5
- package/lib/engine-components/Light.js +30 -5
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/LookAtConstraint.d.ts +22 -7
- package/lib/engine-components/LookAtConstraint.js +22 -7
- package/lib/engine-components/LookAtConstraint.js.map +1 -1
- package/lib/engine-components/NeedleMenu.d.ts +27 -5
- package/lib/engine-components/NeedleMenu.js +27 -5
- package/lib/engine-components/NeedleMenu.js.map +1 -1
- package/lib/engine-components/NestedGltf.d.ts +39 -4
- package/lib/engine-components/NestedGltf.js +42 -4
- package/lib/engine-components/NestedGltf.js.map +1 -1
- package/lib/engine-components/OffsetConstraint.d.ts +27 -3
- package/lib/engine-components/OffsetConstraint.js +27 -3
- package/lib/engine-components/OffsetConstraint.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +41 -3
- package/lib/engine-components/OrbitControls.js +41 -3
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/PlayerColor.d.ts +1 -1
- package/lib/engine-components/PlayerColor.js +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +17 -2
- package/lib/engine-components/ReflectionProbe.js +17 -3
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +35 -0
- package/lib/engine-components/Renderer.js +36 -2
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +57 -5
- package/lib/engine-components/RigidBody.js +57 -5
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.d.ts +11 -0
- package/lib/engine-components/SceneSwitcher.js +11 -0
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/ScreenCapture.d.ts +39 -6
- package/lib/engine-components/ScreenCapture.js +39 -6
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/SeeThrough.d.ts +70 -5
- package/lib/engine-components/SeeThrough.js +70 -5
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/ShadowCatcher.d.ts +56 -4
- package/lib/engine-components/ShadowCatcher.js +56 -4
- package/lib/engine-components/ShadowCatcher.js.map +1 -1
- package/lib/engine-components/Skybox.d.ts +43 -7
- package/lib/engine-components/Skybox.js +43 -7
- package/lib/engine-components/Skybox.js.map +1 -1
- package/lib/engine-components/SmoothFollow.d.ts +66 -7
- package/lib/engine-components/SmoothFollow.js +66 -7
- package/lib/engine-components/SmoothFollow.js.map +1 -1
- package/lib/engine-components/SpatialTrigger.d.ts +48 -1
- package/lib/engine-components/SpatialTrigger.js +48 -1
- package/lib/engine-components/SpatialTrigger.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.d.ts +21 -3
- package/lib/engine-components/SpectatorCamera.js +21 -3
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedRoom.d.ts +7 -1
- package/lib/engine-components/SyncedRoom.js +7 -1
- package/lib/engine-components/SyncedRoom.js.map +1 -1
- package/lib/engine-components/SyncedTransform.d.ts +55 -6
- package/lib/engine-components/SyncedTransform.js +55 -6
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TransformGizmo.d.ts +30 -3
- package/lib/engine-components/TransformGizmo.js +30 -3
- package/lib/engine-components/TransformGizmo.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +33 -6
- package/lib/engine-components/VideoPlayer.js +45 -6
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/Voip.d.ts +33 -2
- package/lib/engine-components/Voip.js +33 -2
- package/lib/engine-components/Voip.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.d.ts +47 -13
- package/lib/engine-components/export/usdz/USDZExporter.js +47 -13
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/particlesystem/ParticleSystem.d.ts +82 -3
- package/lib/engine-components/particlesystem/ParticleSystem.js +82 -3
- package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +1 -0
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js +1 -0
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/BloomEffect.js +1 -1
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +1 -1
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +1 -1
- package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/DepthOfField.js +1 -1
- package/lib/engine-components/postprocessing/Effects/EffectWrapper.d.ts +1 -0
- package/lib/engine-components/postprocessing/Effects/EffectWrapper.js +1 -0
- package/lib/engine-components/postprocessing/Effects/EffectWrapper.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/Pixelation.js +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +1 -1
- package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/Sharpening.js +1 -1
- package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.js +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +1 -1
- package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +1 -1
- package/lib/engine-components/postprocessing/Effects/Vignette.js +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +1 -1
- package/lib/engine-components/postprocessing/Volume.d.ts +1 -1
- package/lib/engine-components/postprocessing/Volume.js +1 -1
- package/lib/engine-components/splines/Spline.d.ts +409 -12
- package/lib/engine-components/splines/Spline.js +409 -12
- package/lib/engine-components/splines/Spline.js.map +1 -1
- package/lib/engine-components/splines/SplineUtils.d.ts +1 -0
- package/lib/engine-components/splines/SplineUtils.js +1 -0
- package/lib/engine-components/splines/SplineUtils.js.map +1 -1
- package/lib/engine-components/splines/SplineWalker.d.ts +3 -1
- package/lib/engine-components/splines/SplineWalker.js +3 -1
- package/lib/engine-components/splines/SplineWalker.js.map +1 -1
- package/lib/engine-components/timeline/PlayableDirector.d.ts +103 -14
- package/lib/engine-components/timeline/PlayableDirector.js +95 -25
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/TimelineModels.d.ts +14 -0
- package/lib/engine-components/timeline/TimelineModels.js +4 -0
- package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
- package/lib/engine-components/ui/Button.d.ts +29 -3
- package/lib/engine-components/ui/Button.js +29 -3
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +29 -4
- package/lib/engine-components/ui/Canvas.js +29 -4
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/CanvasGroup.d.ts +1 -1
- package/lib/engine-components/ui/CanvasGroup.js +1 -1
- package/lib/engine-components/ui/EventSystem.d.ts +1 -1
- package/lib/engine-components/ui/EventSystem.js +1 -1
- package/lib/engine-components/ui/Graphic.d.ts +1 -0
- package/lib/engine-components/ui/Graphic.js +1 -0
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/Image.d.ts +22 -3
- package/lib/engine-components/ui/Image.js +22 -3
- package/lib/engine-components/ui/Image.js.map +1 -1
- package/lib/engine-components/ui/InputField.d.ts +1 -1
- package/lib/engine-components/ui/InputField.js +1 -1
- package/lib/engine-components/ui/Layout.d.ts +3 -0
- package/lib/engine-components/ui/Layout.js +3 -0
- package/lib/engine-components/ui/Layout.js.map +1 -1
- package/lib/engine-components/ui/Outline.d.ts +1 -1
- package/lib/engine-components/ui/Outline.js +1 -1
- package/lib/engine-components/ui/PointerEvents.d.ts +1 -1
- package/lib/engine-components/ui/PointerEvents.js +1 -1
- package/lib/engine-components/ui/Raycaster.d.ts +55 -6
- package/lib/engine-components/ui/Raycaster.js +55 -6
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/engine-components/ui/RectTransform.d.ts +1 -1
- package/lib/engine-components/ui/RectTransform.js +1 -1
- package/lib/engine-components/ui/SpatialHtml.d.ts +1 -1
- package/lib/engine-components/ui/SpatialHtml.js +1 -1
- package/lib/engine-components/ui/Text.d.ts +23 -1
- package/lib/engine-components/ui/Text.js +23 -1
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/utils/LookAt.d.ts +1 -1
- package/lib/engine-components/utils/LookAt.js +1 -1
- package/lib/engine-components/utils/OpenURL.d.ts +1 -1
- package/lib/engine-components/utils/OpenURL.js +1 -1
- package/lib/engine-components/web/Clickthrough.d.ts +116 -7
- package/lib/engine-components/web/Clickthrough.js +116 -7
- package/lib/engine-components/web/Clickthrough.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +171 -7
- package/lib/engine-components/web/CursorFollow.js +171 -7
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/web/HoverAnimation.d.ts +140 -11
- package/lib/engine-components/web/HoverAnimation.js +140 -11
- package/lib/engine-components/web/HoverAnimation.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.d.ts +4 -1
- package/lib/engine-components/web/ScrollFollow.js +4 -1
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/web/ViewBox.d.ts +116 -16
- package/lib/engine-components/web/ViewBox.js +110 -16
- package/lib/engine-components/web/ViewBox.js.map +1 -1
- package/lib/engine-components/webxr/TeleportTarget.d.ts +21 -2
- package/lib/engine-components/webxr/TeleportTarget.js +21 -2
- package/lib/engine-components/webxr/TeleportTarget.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.d.ts +10 -2
- package/lib/engine-components/webxr/WebXR.js +10 -2
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/lib/engine-components/webxr/WebXRAvatar.d.ts +39 -2
- package/lib/engine-components/webxr/WebXRAvatar.js +35 -3
- package/lib/engine-components/webxr/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/webxr/WebXRImageTracking.d.ts +266 -30
- package/lib/engine-components/webxr/WebXRImageTracking.js +266 -30
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/lib/engine-components/webxr/WebXRPlaneTracking.d.ts +1 -1
- package/lib/engine-components/webxr/WebXRPlaneTracking.js +1 -1
- package/lib/engine-components/webxr/XRFlag.d.ts +29 -2
- package/lib/engine-components/webxr/XRFlag.js +29 -2
- package/lib/engine-components/webxr/XRFlag.js.map +1 -1
- package/package.json +1 -1
- package/plugins/vite/custom-element-data.js +128 -19
- package/src/engine/engine_context.ts +16 -0
- package/src/engine/engine_gameobject.ts +73 -0
- package/src/engine/engine_input.ts +83 -7
- package/src/engine/engine_math.ts +81 -2
- package/src/engine/engine_networking.ts +186 -17
- package/src/engine/engine_networking_auto.ts +36 -9
- package/src/engine/engine_physics.ts +41 -1
- package/src/engine/engine_physics_rapier.ts +81 -0
- package/src/engine/engine_serialization_decorator.ts +28 -2
- package/src/engine/engine_time.ts +23 -3
- package/src/engine/engine_util_decorator.ts +31 -1
- package/src/engine/engine_utils.ts +21 -5
- package/src/engine/extensions/NEEDLE_materialx.ts +5 -4
- package/src/engine/extensions/index.ts +2 -2
- package/src/engine-components/AlignmentConstraint.ts +24 -4
- package/src/engine-components/Animation.ts +44 -2
- package/src/engine-components/Animator.ts +40 -7
- package/src/engine-components/AudioListener.ts +1 -1
- package/src/engine-components/AudioSource.ts +37 -15
- package/src/engine-components/AxesHelper.ts +23 -4
- package/src/engine-components/BasicIKConstraint.ts +28 -5
- package/src/engine-components/Camera.ts +33 -3
- package/src/engine-components/CharacterController.ts +74 -7
- package/src/engine-components/Collider.ts +78 -21
- package/src/engine-components/ContactShadows.ts +41 -11
- package/src/engine-components/DeleteBox.ts +43 -2
- package/src/engine-components/DeviceFlag.ts +22 -3
- package/src/engine-components/DragControls.ts +32 -2
- package/src/engine-components/DropListener.ts +41 -29
- package/src/engine-components/Duplicatable.ts +37 -6
- package/src/engine-components/EventList.ts +43 -15
- package/src/engine-components/EventTrigger.ts +1 -1
- package/src/engine-components/Fog.ts +23 -1
- package/src/engine-components/GridHelper.ts +18 -2
- package/src/engine-components/GroundProjection.ts +25 -3
- package/src/engine-components/Interactable.ts +17 -2
- package/src/engine-components/Joints.ts +51 -8
- package/src/engine-components/LODGroup.ts +45 -11
- package/src/engine-components/Light.ts +35 -13
- package/src/engine-components/LookAtConstraint.ts +26 -8
- package/src/engine-components/NeedleMenu.ts +29 -7
- package/src/engine-components/NestedGltf.ts +40 -4
- package/src/engine-components/OffsetConstraint.ts +27 -3
- package/src/engine-components/OrbitControls.ts +41 -3
- package/src/engine-components/PlayerColor.ts +1 -1
- package/src/engine-components/ReflectionProbe.ts +19 -5
- package/src/engine-components/Renderer.ts +35 -1
- package/src/engine-components/RigidBody.ts +64 -8
- package/src/engine-components/SceneSwitcher.ts +11 -0
- package/src/engine-components/ScreenCapture.ts +42 -9
- package/src/engine-components/SeeThrough.ts +76 -9
- package/src/engine-components/ShadowCatcher.ts +61 -6
- package/src/engine-components/Skybox.ts +48 -12
- package/src/engine-components/SmoothFollow.ts +68 -7
- package/src/engine-components/SpatialTrigger.ts +51 -4
- package/src/engine-components/SpectatorCamera.ts +23 -5
- package/src/engine-components/SyncedRoom.ts +8 -2
- package/src/engine-components/SyncedTransform.ts +59 -10
- package/src/engine-components/TransformGizmo.ts +31 -4
- package/src/engine-components/VideoPlayer.ts +48 -6
- package/src/engine-components/Voip.ts +33 -2
- package/src/engine-components/export/usdz/USDZExporter.ts +47 -13
- package/src/engine-components/particlesystem/ParticleSystem.ts +84 -5
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +1 -0
- package/src/engine-components/postprocessing/Effects/BloomEffect.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +1 -1
- package/src/engine-components/postprocessing/Effects/DepthOfField.ts +1 -1
- package/src/engine-components/postprocessing/Effects/EffectWrapper.ts +1 -0
- package/src/engine-components/postprocessing/Effects/Pixelation.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +1 -1
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Sharpening.ts +1 -1
- package/src/engine-components/postprocessing/Effects/TiltShiftEffect.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +1 -1
- package/src/engine-components/postprocessing/Effects/Vignette.ts +1 -1
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +1 -1
- package/src/engine-components/postprocessing/Volume.ts +1 -1
- package/src/engine-components/splines/Spline.ts +412 -14
- package/src/engine-components/splines/SplineUtils.ts +1 -0
- package/src/engine-components/splines/SplineWalker.ts +4 -2
- package/src/engine-components/timeline/PlayableDirector.ts +108 -27
- package/src/engine-components/timeline/SignalAsset.ts +1 -1
- package/src/engine-components/timeline/TimelineModels.ts +18 -2
- package/src/engine-components/ui/Button.ts +29 -3
- package/src/engine-components/ui/Canvas.ts +29 -4
- package/src/engine-components/ui/CanvasGroup.ts +2 -2
- package/src/engine-components/ui/EventSystem.ts +1 -1
- package/src/engine-components/ui/Graphic.ts +1 -0
- package/src/engine-components/ui/Image.ts +22 -3
- package/src/engine-components/ui/InputField.ts +2 -2
- package/src/engine-components/ui/Layout.ts +3 -0
- package/src/engine-components/ui/Outline.ts +1 -1
- package/src/engine-components/ui/PointerEvents.ts +1 -1
- package/src/engine-components/ui/Raycaster.ts +57 -8
- package/src/engine-components/ui/RectTransform.ts +2 -2
- package/src/engine-components/ui/SpatialHtml.ts +1 -1
- package/src/engine-components/ui/Text.ts +24 -2
- package/src/engine-components/utils/LookAt.ts +1 -1
- package/src/engine-components/utils/OpenURL.ts +1 -1
- package/src/engine-components/web/Clickthrough.ts +119 -10
- package/src/engine-components/web/CursorFollow.ts +174 -9
- package/src/engine-components/web/HoverAnimation.ts +142 -13
- package/src/engine-components/web/ScrollFollow.ts +4 -1
- package/src/engine-components/web/ViewBox.ts +118 -18
- package/src/engine-components/webxr/TeleportTarget.ts +23 -4
- package/src/engine-components/webxr/WebXR.ts +11 -3
- package/src/engine-components/webxr/WebXRAvatar.ts +41 -4
- package/src/engine-components/webxr/WebXRImageTracking.ts +282 -38
- package/src/engine-components/webxr/WebXRPlaneTracking.ts +1 -1
- package/src/engine-components/webxr/XRFlag.ts +30 -3
|
@@ -4,6 +4,8 @@ let networkingServerUrl: string | undefined = "wss://networking.needle.tools/soc
|
|
|
4
4
|
import * as flatbuffers from 'flatbuffers';
|
|
5
5
|
import { type Websocket } from 'websocket-ts';
|
|
6
6
|
|
|
7
|
+
import type { Networking } from "../engine-components/Networking.js";
|
|
8
|
+
import type { SyncedRoom } from "../engine-components/SyncedRoom.js";
|
|
7
9
|
import * as schemes from "../engine-schemes/schemes.js";
|
|
8
10
|
import { isDevEnvironment } from './debug/index.js';
|
|
9
11
|
import { Telemetry } from './engine_license.js';
|
|
@@ -116,27 +118,95 @@ declare type OwnershipResponse = {
|
|
|
116
118
|
|
|
117
119
|
declare type WebsocketSendType = IModel | object | boolean | null | string | number;
|
|
118
120
|
|
|
119
|
-
/**
|
|
120
|
-
*
|
|
121
|
+
/**
|
|
122
|
+
* Manages ownership of networked objects or components.
|
|
123
|
+
*
|
|
124
|
+
* In multiplayer scenarios, ownership determines which client has authority to modify an object.
|
|
125
|
+
* The networking server rejects changes from clients that don't own an object. This prevents conflicts
|
|
126
|
+
* when multiple users try to manipulate the same object simultaneously.
|
|
127
|
+
*
|
|
128
|
+
* **Ownership states:**
|
|
129
|
+
* - `hasOwnership`: This client owns the object and can modify it
|
|
130
|
+
* - `isOwned`: Some client (could be local or remote) owns the object
|
|
131
|
+
* - `undefined`: Ownership state is unknown (not yet queried)
|
|
132
|
+
*
|
|
133
|
+
* **Typical workflow:**
|
|
134
|
+
* 1. Request ownership before modifying an object
|
|
135
|
+
* 2. Make your changes while you have ownership
|
|
136
|
+
* 3. Free ownership when done (or keep it if still interacting)
|
|
137
|
+
*
|
|
138
|
+
* @example Basic usage
|
|
139
|
+
* ```ts
|
|
140
|
+
* export class MyComponent extends Behaviour {
|
|
141
|
+
* private ownership?: OwnershipModel;
|
|
142
|
+
*
|
|
143
|
+
* awake() {
|
|
144
|
+
* this.ownership = new OwnershipModel(this.context.connection, this.guid);
|
|
145
|
+
* }
|
|
146
|
+
*
|
|
147
|
+
* onClick() {
|
|
148
|
+
* // Request ownership before modifying the object
|
|
149
|
+
* this.ownership.requestOwnership();
|
|
150
|
+
* }
|
|
151
|
+
*
|
|
152
|
+
* update() {
|
|
153
|
+
* if (this.ownership.hasOwnership) {
|
|
154
|
+
* // Safe to modify and sync the object
|
|
155
|
+
* this.gameObject.position.y += 0.01;
|
|
156
|
+
* }
|
|
157
|
+
* }
|
|
158
|
+
*
|
|
159
|
+
* onDisable() {
|
|
160
|
+
* // Release ownership when done
|
|
161
|
+
* this.ownership.freeOwnership();
|
|
162
|
+
* this.ownership.destroy();
|
|
163
|
+
* }
|
|
164
|
+
* }
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @example Async ownership
|
|
168
|
+
* ```ts
|
|
169
|
+
* async modifyObject() {
|
|
170
|
+
* try {
|
|
171
|
+
* await this.ownership.requestOwnershipAsync();
|
|
172
|
+
* // Now guaranteed to have ownership
|
|
173
|
+
* this.transform.position.x = 5;
|
|
174
|
+
* } catch(e) {
|
|
175
|
+
* console.log("Failed to gain ownership");
|
|
176
|
+
* }
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @see {@link SyncedTransform} for a complete example of ownership in action
|
|
181
|
+
* @link https://engine.needle.tools/docs/networking.html
|
|
182
|
+
*/
|
|
121
183
|
export class OwnershipModel {
|
|
122
184
|
|
|
185
|
+
/** The unique identifier (GUID) of the object this ownership model manages */
|
|
123
186
|
public guid: string;
|
|
124
187
|
private connection: NetworkConnection;
|
|
125
188
|
|
|
189
|
+
/**
|
|
190
|
+
* Checks if the local client has ownership of this object.
|
|
191
|
+
* @returns `true` if this client owns the object and can modify it, `false` otherwise
|
|
192
|
+
*/
|
|
126
193
|
public get hasOwnership(): boolean {
|
|
127
194
|
return this._hasOwnership;
|
|
128
195
|
}
|
|
129
196
|
|
|
130
197
|
// TODO: server should just send id to everyone
|
|
131
198
|
|
|
132
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* Checks if anyone (local or remote client) has ownership of this object.
|
|
201
|
+
* @returns `true` if someone owns the object, `false` if no one owns it, `undefined` if unknown
|
|
202
|
+
*/
|
|
133
203
|
public get isOwned(): boolean | undefined {
|
|
134
204
|
return this._isOwned;
|
|
135
205
|
}
|
|
136
206
|
|
|
137
|
-
/**
|
|
207
|
+
/**
|
|
138
208
|
* Checks if Needle Engine networking is connected to a websocket. Note that this is **not equal** to being connected to a *room*. If you want to check if Needle Engine is connected to a networking room use the `isInRoom` property.
|
|
139
|
-
* @returns true if connected to the websocket.
|
|
209
|
+
* @returns true if connected to the websocket.
|
|
140
210
|
*/
|
|
141
211
|
public get isConnected(): boolean {
|
|
142
212
|
return this.connection.isConnected;
|
|
@@ -162,6 +232,10 @@ export class OwnershipModel {
|
|
|
162
232
|
|
|
163
233
|
private _isWaitingForOwnershipResponseCallback: Function | null = null;
|
|
164
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Queries the server to update the `isOwned` state.
|
|
237
|
+
* Call this to check if anyone currently has ownership.
|
|
238
|
+
*/
|
|
165
239
|
public updateIsOwned() {
|
|
166
240
|
this.connection.send(OwnershipEvent.RequestHasOwner, { guid: this.guid });
|
|
167
241
|
}
|
|
@@ -172,6 +246,11 @@ export class OwnershipModel {
|
|
|
172
246
|
}
|
|
173
247
|
}
|
|
174
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Requests ownership only if the object is not currently owned by anyone.
|
|
251
|
+
* Internally checks ownership state first, then requests ownership if free.
|
|
252
|
+
* @returns this OwnershipModel instance for method chaining
|
|
253
|
+
*/
|
|
175
254
|
public requestOwnershipIfNotOwned(): OwnershipModel {
|
|
176
255
|
if (this._isWaitingForOwnershipResponseCallback !== null) return this;
|
|
177
256
|
this._isWaitingForOwnershipResponseCallback = this.waitForHasOwnershipRequestResponse.bind(this);
|
|
@@ -197,6 +276,20 @@ export class OwnershipModel {
|
|
|
197
276
|
}
|
|
198
277
|
|
|
199
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Requests ownership and waits asynchronously until ownership is granted or timeout occurs.
|
|
281
|
+
* @returns Promise that resolves with this OwnershipModel when ownership is gained
|
|
282
|
+
* @throws Rejects with "Timeout" if ownership is not gained within ~1 second
|
|
283
|
+
* @example
|
|
284
|
+
* ```ts
|
|
285
|
+
* try {
|
|
286
|
+
* await ownership.requestOwnershipAsync();
|
|
287
|
+
* // Ownership granted, safe to modify object
|
|
288
|
+
* } catch(e) {
|
|
289
|
+
* console.warn("Could not gain ownership:", e);
|
|
290
|
+
* }
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
200
293
|
public requestOwnershipAsync(): Promise<OwnershipModel> {
|
|
201
294
|
return new Promise((resolve, reject) => {
|
|
202
295
|
this.requestOwnership();
|
|
@@ -212,12 +305,22 @@ export class OwnershipModel {
|
|
|
212
305
|
});
|
|
213
306
|
}
|
|
214
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Requests ownership of this object from the networking server.
|
|
310
|
+
* Ownership may not be granted immediately - check `hasOwnership` property or use `requestOwnershipAsync()`.
|
|
311
|
+
* @returns this OwnershipModel instance for method chaining
|
|
312
|
+
*/
|
|
215
313
|
public requestOwnership(): OwnershipModel {
|
|
216
314
|
if (debugOwner) console.log("Request ownership", this.guid);
|
|
217
315
|
this.connection.send(OwnershipEvent.RequestOwnership, { guid: this.guid });
|
|
218
316
|
return this;
|
|
219
317
|
}
|
|
220
318
|
|
|
319
|
+
/**
|
|
320
|
+
* Releases ownership of this object, allowing others to take control.
|
|
321
|
+
* Call this when you're done modifying an object to allow other users to interact with it.
|
|
322
|
+
* @returns this OwnershipModel instance for method chaining
|
|
323
|
+
*/
|
|
221
324
|
public freeOwnership(): OwnershipModel {
|
|
222
325
|
// TODO: abort "requestOwnershipIfNotOwned"
|
|
223
326
|
this.connection.send(OwnershipEvent.RemoveOwnership, { guid: this.guid });
|
|
@@ -228,6 +331,10 @@ export class OwnershipModel {
|
|
|
228
331
|
return this;
|
|
229
332
|
}
|
|
230
333
|
|
|
334
|
+
/**
|
|
335
|
+
* Cleans up event listeners and resources.
|
|
336
|
+
* Call this when the OwnershipModel is no longer needed (e.g., in `onDestroy()`).
|
|
337
|
+
*/
|
|
231
338
|
public destroy() {
|
|
232
339
|
this.connection.stopListen(OwnershipEvent.GainedOwnership, this._gainSubscription);
|
|
233
340
|
this.connection.stopListen(OwnershipEvent.LostOwnership, this._lostSubscription);
|
|
@@ -265,10 +372,46 @@ export declare type BinaryCallback = {
|
|
|
265
372
|
(data: any | flatbuffers.ByteBuffer): void;
|
|
266
373
|
}
|
|
267
374
|
|
|
268
|
-
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
|
|
375
|
+
/**
|
|
376
|
+
* Main class for multiuser networking. Access via `this.context.connection` from any component.
|
|
377
|
+
*
|
|
378
|
+
* **About GUIDs:**
|
|
379
|
+
* In Needle Engine networking, GUIDs (Globally Unique Identifiers) are used to identify objects and components across the network.
|
|
380
|
+
* Every GameObject and Component has a unique `guid` property that remains consistent across all clients.
|
|
381
|
+
* GUIDs are automatically assigned (e.g. during export from Unity/Blender) and are essential for:
|
|
382
|
+
* - Object ownership management (see {@link OwnershipModel})
|
|
383
|
+
* - State synchronization (storing and retrieving object state)
|
|
384
|
+
* - Identifying which object received a network message
|
|
385
|
+
*
|
|
386
|
+
* When working with networking, you'll typically use `this.guid` to identify your component or `this.gameObject.guid` for the GameObject.
|
|
387
|
+
*
|
|
388
|
+
* @example Joining a room
|
|
389
|
+
* ```ts
|
|
390
|
+
* this.context.connection.connect();
|
|
391
|
+
* this.context.connection.joinRoom("my-room");
|
|
392
|
+
* ```
|
|
393
|
+
* @example Listening to events
|
|
394
|
+
* ```ts
|
|
395
|
+
* this.context.connection.beginListen("my-event", (data) => {
|
|
396
|
+
* console.log("Received:", data);
|
|
397
|
+
* });
|
|
398
|
+
* ```
|
|
399
|
+
* @example Sending data
|
|
400
|
+
* ```ts
|
|
401
|
+
* this.context.connection.send("my-event", { message: "Hello" });
|
|
402
|
+
* ```
|
|
403
|
+
* @example Using GUIDs for object identification
|
|
404
|
+
* ```ts
|
|
405
|
+
* // Get state for a specific object by its GUID
|
|
406
|
+
* const state = this.context.connection.tryGetState(this.guid);
|
|
407
|
+
*
|
|
408
|
+
* // Delete remote state for an object
|
|
409
|
+
* this.context.connection.sendDeleteRemoteState(this.guid);
|
|
410
|
+
* ```
|
|
411
|
+
* @see {@link RoomEvents} for room lifecycle events
|
|
412
|
+
* @see {@link OwnershipModel} for object ownership
|
|
413
|
+
* @link https://engine.needle.tools/docs/how-to-guides/networking/
|
|
414
|
+
*/
|
|
272
415
|
export class NetworkConnection implements INetworkConnection {
|
|
273
416
|
|
|
274
417
|
private context: Context;
|
|
@@ -287,7 +430,18 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
287
430
|
}
|
|
288
431
|
|
|
289
432
|
/**
|
|
290
|
-
* Returns the state
|
|
433
|
+
* Returns the cached network state for a given GUID.
|
|
434
|
+
* The state is stored locally whenever network updates are received for that object.
|
|
435
|
+
* @param guid The unique identifier of the object whose state you want to retrieve
|
|
436
|
+
* @returns The cached state object, or `null` if no state exists for this GUID
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* // Get the last known state for this component
|
|
440
|
+
* const myState = this.context.connection.tryGetState(this.guid);
|
|
441
|
+
* if (myState) {
|
|
442
|
+
* console.log("Found cached state:", myState);
|
|
443
|
+
* }
|
|
444
|
+
* ```
|
|
291
445
|
*/
|
|
292
446
|
public tryGetState(guid: string): IModel | null {
|
|
293
447
|
if (guid === "invalid") return null;
|
|
@@ -307,7 +461,7 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
307
461
|
}
|
|
308
462
|
|
|
309
463
|
/**
|
|
310
|
-
* Checks if Needle Engine networking is connected to a websocket. Note that this is **not equal** to being connected to a *room*. If you want to check if Needle Engine is connected to a networking room use the `isInRoom` property.
|
|
464
|
+
* Checks if Needle Engine networking is connected to a websocket. Note that this is **not equal** to being connected to a *room*. If you want to check if Needle Engine is connected to a networking room use the `{@link isInRoom}` property.
|
|
311
465
|
* @returns true if connected to the websocket.
|
|
312
466
|
*/
|
|
313
467
|
public get isConnected(): boolean {
|
|
@@ -372,7 +526,7 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
372
526
|
return target;
|
|
373
527
|
}
|
|
374
528
|
|
|
375
|
-
/** Joins a networked room. If you don't want to manage a connection yourself you can use a `SyncedRoom` component as well */
|
|
529
|
+
/** Joins a networked room. If you don't want to manage a connection yourself you can use a `{@link SyncedRoom}` component as well */
|
|
376
530
|
public joinRoom(room: string, viewOnly: boolean = false): boolean {
|
|
377
531
|
if (!room) {
|
|
378
532
|
console.error("Missing room name, can not join: \"" + room + "\"");
|
|
@@ -426,7 +580,18 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
426
580
|
return this.sendWithWebsocket(key, data, queue);
|
|
427
581
|
}
|
|
428
582
|
|
|
429
|
-
/**
|
|
583
|
+
/**
|
|
584
|
+
* Deletes the network state for a specific object on the server.
|
|
585
|
+
* This removes the object's state from the room, preventing it from being sent to newly joining users.
|
|
586
|
+
* @param guid The unique identifier of the object whose state should be deleted
|
|
587
|
+
* @example
|
|
588
|
+
* ```ts
|
|
589
|
+
* // When destroying a networked object, clean up its server state
|
|
590
|
+
* onDestroy() {
|
|
591
|
+
* this.context.connection.sendDeleteRemoteState(this.guid);
|
|
592
|
+
* }
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
430
595
|
public sendDeleteRemoteState(guid: string) {
|
|
431
596
|
this.send("delete-state", { guid: guid, dontSave: true });
|
|
432
597
|
delete this._state[guid];
|
|
@@ -469,7 +634,7 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
469
634
|
}
|
|
470
635
|
|
|
471
636
|
/** Use to start listening to networking events.
|
|
472
|
-
* To unsubscribe from events use the `stopListen` method.
|
|
637
|
+
* To unsubscribe from events use the `{@link stopListen}` method.
|
|
473
638
|
* See the example below for typical usage:
|
|
474
639
|
*
|
|
475
640
|
* ### Component Example
|
|
@@ -501,7 +666,7 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
501
666
|
public stopListening(key: (string & {}) | OwnershipEvent | OwnershipEventNamesIncoming | RoomEventsIncoming | RoomEvents, callback: Function | null) { return this.stopListen(key, callback); }
|
|
502
667
|
|
|
503
668
|
/** Use to stop listening to networking events
|
|
504
|
-
* To subscribe to events use the `beginListen` method.
|
|
669
|
+
* To subscribe to events use the `{@link beginListen}` method.
|
|
505
670
|
* See the example below for typical usage:
|
|
506
671
|
*
|
|
507
672
|
* ### Component Example
|
|
@@ -548,12 +713,16 @@ export class NetworkConnection implements INetworkConnection {
|
|
|
548
713
|
|
|
549
714
|
private netWebSocketUrlProvider?: INetworkingWebsocketUrlProvider;
|
|
550
715
|
|
|
551
|
-
/** Use to override the networking server backend url.
|
|
716
|
+
/** Use to override the networking server backend url.
|
|
717
|
+
* This is what the `{@link Networking}` component uses to modify the backend url.
|
|
718
|
+
**/
|
|
552
719
|
public registerProvider(prov: INetworkingWebsocketUrlProvider) {
|
|
553
720
|
this.netWebSocketUrlProvider = prov;
|
|
554
721
|
}
|
|
555
722
|
|
|
556
|
-
/** Used to connect to the networking server
|
|
723
|
+
/** Used to connect to the networking server
|
|
724
|
+
* @param url Optional url to connect to. If not provided, it will use the url from the registered `INetworkingWebsocketUrlProvider` or the default backend networking url. If you want to change the url after connecting, you need to disconnect first and then connect again with the new url.
|
|
725
|
+
*/
|
|
557
726
|
public async connect(url?: string) {
|
|
558
727
|
if (this.connected && url && url !== networkingServerUrl) {
|
|
559
728
|
return Promise.reject("Can not connect to different server url. Please disconnect first.");
|
|
@@ -176,15 +176,42 @@ export declare type SyncFieldOptions = {
|
|
|
176
176
|
export declare type FieldChangedCallbackFn = (newValue: any, previousValue: any) => void | boolean | any;
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
179
|
+
* Marks a field for automatic network synchronization across connected clients.
|
|
180
|
+
* When a synced field changes, the new value is automatically broadcast to all users in the room.
|
|
181
|
+
*
|
|
182
|
+
* Primitives (string, number, boolean) sync automatically.
|
|
183
|
+
* For arrays/objects, reassign to trigger sync: `this.myArray = this.myArray`
|
|
184
|
+
*
|
|
185
|
+
* @param onFieldChanged Optional callback when the field changes (locally or from network).
|
|
186
|
+
* Return `false` to prevent syncing this change to others.
|
|
187
|
+
*
|
|
188
|
+
* @example Basic sync
|
|
189
|
+
* ```ts
|
|
190
|
+
* class MyComponent extends Behaviour {
|
|
191
|
+
* @syncField() playerScore: number = 0;
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
* @example With change callback
|
|
195
|
+
* ```ts
|
|
196
|
+
* class MyComponent extends Behaviour {
|
|
197
|
+
* @syncField("onHealthChanged") health: number = 100;
|
|
198
|
+
*
|
|
199
|
+
* onHealthChanged(newValue: number, oldValue: number) {
|
|
200
|
+
* console.log(`Health: ${oldValue} → ${newValue}`);
|
|
201
|
+
* }
|
|
202
|
+
* }
|
|
203
|
+
* ```
|
|
204
|
+
* @example Preventing sync (one-way)
|
|
205
|
+
* ```ts
|
|
206
|
+
* class MyComponent extends Behaviour {
|
|
207
|
+
* @syncField(function(newVal, oldVal) {
|
|
208
|
+
* // Process incoming value but don't sync our changes
|
|
209
|
+
* return false;
|
|
210
|
+
* }) serverControlled: string = "";
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
* @see {@link serializable} for editor serialization
|
|
214
|
+
* @link https://engine.needle.tools/docs/how-to-guides/networking/
|
|
188
215
|
*/
|
|
189
216
|
export const syncField = function (onFieldChanged: string | FieldChangedCallbackFn | undefined | null = null) {
|
|
190
217
|
|
|
@@ -4,14 +4,18 @@ import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
|
4
4
|
import type { ComputeBVHOptions, GeometryBVH, MeshBVH, StaticGeometryGenerator } from 'three-mesh-bvh';
|
|
5
5
|
import type { GenerateMeshBVHWorker } from 'three-mesh-bvh/src/workers/GenerateMeshBVHWorker.js';
|
|
6
6
|
|
|
7
|
+
import type { Collider } from '../engine-components/Collider.js';
|
|
8
|
+
import type { Rigidbody } from '../engine-components/RigidBody.js';
|
|
7
9
|
import { isDevEnvironment } from './debug/index.js';
|
|
8
10
|
import { Gizmos } from './engine_gizmos.js';
|
|
11
|
+
import type { RapierPhysics } from './engine_physics_rapier.js';
|
|
9
12
|
import { Context } from './engine_setup.js';
|
|
10
13
|
import { getTempVector, getWorldPosition } from "./engine_three_utils.js"
|
|
11
14
|
import type { ConstructorConcrete, Vec2, Vec3, } from './engine_types.js';
|
|
12
15
|
import type { IPhysicsEngine } from './engine_types.js';
|
|
13
16
|
import { getParam } from "./engine_utils.js"
|
|
14
17
|
|
|
18
|
+
|
|
15
19
|
const debugPhysics = getParam("debugphysics");
|
|
16
20
|
const debugWorker = getParam("debugworker");
|
|
17
21
|
const layerMaskHelper: Layers = new Layers();
|
|
@@ -133,11 +137,47 @@ export class SphereIntersection implements Intersection {
|
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Provides physics utilities including raycasting and overlap detection.
|
|
142
|
+
* Access via `this.context.physics` from any component.
|
|
143
|
+
*
|
|
144
|
+
* For physics engine features (rigidbodies, colliders, forces, etc.), use `this.context.physics.engine`.
|
|
145
|
+
* The physics engine is {@link RapierPhysics}, which uses the Rapier physics library for realistic simulation.
|
|
146
|
+
*
|
|
147
|
+
* **Performance - Automatic MeshBVH:**
|
|
148
|
+
* Needle Engine automatically uses [three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh) to accelerate raycasting.
|
|
149
|
+
* MeshBVH structures are generated automatically on web workers in the background, making raycasts significantly faster
|
|
150
|
+
* without blocking the main thread. This happens transparently - you don't need to do anything to enable it.
|
|
151
|
+
* While the BVH is being generated, raycasts fall back to standard three.js raycasting (configurable via `allowSlowRaycastFallback`).
|
|
152
|
+
*
|
|
153
|
+
* @example Raycasting from mouse position
|
|
154
|
+
* ```ts
|
|
155
|
+
* const hits = this.context.physics.raycast();
|
|
156
|
+
* if (hits.length > 0) {
|
|
157
|
+
* console.log("Hit:", hits[0].object.name);
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
* @example Raycasting with inline options
|
|
161
|
+
* ```ts
|
|
162
|
+
* const hits = this.context.physics.raycast({
|
|
163
|
+
* maxDistance: 100, // Only hit objects within 100 units
|
|
164
|
+
* layerMask: 1, // Only layer 0
|
|
165
|
+
* ignore: [this.gameObject] // Ignore self
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
* @example Physics engine raycast (against colliders only)
|
|
169
|
+
* ```ts
|
|
170
|
+
* const hit = this.context.physics.engine?.raycast(origin, direction);
|
|
171
|
+
* ```
|
|
172
|
+
* @see {@link Rigidbody} for physics simulation component
|
|
173
|
+
* @see {@link Collider} for collision detection component
|
|
174
|
+
* @see {@link RapierPhysics} for physics engine implementation details
|
|
175
|
+
*/
|
|
136
176
|
export class Physics {
|
|
137
177
|
|
|
138
178
|
private static _raycasting: number = 0;
|
|
139
179
|
/**
|
|
140
|
-
* Returns true if raycasting is currently
|
|
180
|
+
* Returns true if raycasting is currently in progress
|
|
141
181
|
*/
|
|
142
182
|
public static get raycasting() {
|
|
143
183
|
return this._raycasting > 0;
|
|
@@ -3,13 +3,16 @@ import { BufferAttribute, BufferGeometry, InterleavedBufferAttribute, LineBasicM
|
|
|
3
3
|
import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js'
|
|
4
4
|
|
|
5
5
|
import { CollisionDetectionMode, PhysicsMaterialCombine } from '../engine/engine_physics.types.js';
|
|
6
|
+
import type { Collider as NeedleCollider } from '../engine-components/Collider.js';
|
|
6
7
|
import { MeshCollider } from '../engine-components/Collider.js';
|
|
8
|
+
import type { Rigidbody as NeedleRigidbody } from '../engine-components/RigidBody.js';
|
|
7
9
|
import { isDevEnvironment } from './debug/debug.js';
|
|
8
10
|
import { ContextEvent, ContextRegistry } from './engine_context_registry.js';
|
|
9
11
|
import { foreachComponent } from './engine_gameobject.js';
|
|
10
12
|
import { Gizmos } from './engine_gizmos.js';
|
|
11
13
|
import { Mathf } from './engine_math.js';
|
|
12
14
|
import { MODULES } from './engine_modules.js';
|
|
15
|
+
import type { Physics } from './engine_physics.js';
|
|
13
16
|
import { getWorldPosition, getWorldQuaternion, getWorldScale, setWorldPositionXYZ, setWorldQuaternionXYZW } from "./engine_three_utils.js"
|
|
14
17
|
import type {
|
|
15
18
|
IBoxCollider,
|
|
@@ -61,6 +64,84 @@ declare type PhysicsBody = {
|
|
|
61
64
|
rotation(): { x: number, y: number, z: number, w: number }
|
|
62
65
|
}
|
|
63
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Rapier physics engine implementation for Needle Engine.
|
|
69
|
+
*
|
|
70
|
+
* Rapier is a fast, cross-platform physics engine that provides realistic physics simulation
|
|
71
|
+
* for rigidbodies, colliders, joints, and collision detection. It runs entirely in WebAssembly
|
|
72
|
+
* for high performance.
|
|
73
|
+
*
|
|
74
|
+
* **Features:**
|
|
75
|
+
* - Rigidbody simulation (dynamic, kinematic, static)
|
|
76
|
+
* - Multiple collider shapes (box, sphere, capsule, mesh, convex hull)
|
|
77
|
+
* - Raycasting and shape overlap queries against physics colliders
|
|
78
|
+
* - Collision and trigger events
|
|
79
|
+
* - Joints (fixed, hinge, etc.)
|
|
80
|
+
* - Continuous collision detection (CCD)
|
|
81
|
+
* - Physics materials (friction, bounciness)
|
|
82
|
+
*
|
|
83
|
+
* **Access:**
|
|
84
|
+
* The Rapier physics engine is accessible via `this.context.physics.engine` from any component.
|
|
85
|
+
* Rapier is automatically initialized when physics components are used.
|
|
86
|
+
*
|
|
87
|
+
* **Using the Rapier Module Directly:**
|
|
88
|
+
* Rapier is lazy-loaded for performance. You can access the raw Rapier module via {@link MODULES.RAPIER_PHYSICS}.
|
|
89
|
+
* Use `MODULES.RAPIER_PHYSICS.load()` to load the module, or `MODULES.RAPIER_PHYSICS.ready()` to wait for it without triggering a load.
|
|
90
|
+
* Once loaded, the module is available at `MODULES.RAPIER_PHYSICS.MODULE`.
|
|
91
|
+
*
|
|
92
|
+
* **Note:**
|
|
93
|
+
* This is the low-level physics engine implementation. For general raycasting (against all scene objects),
|
|
94
|
+
* use {@link Physics.raycast} instead. Use this class for physics-specific operations like applying forces,
|
|
95
|
+
* raycasting against colliders only, or accessing the Rapier world directly.
|
|
96
|
+
*
|
|
97
|
+
* @example Applying forces to a rigidbody
|
|
98
|
+
* ```ts
|
|
99
|
+
* const rb = this.gameObject.getComponent(Rigidbody);
|
|
100
|
+
* if (rb) {
|
|
101
|
+
* this.context.physics.engine?.addForce(rb, { x: 0, y: 10, z: 0 }, true);
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
* @example Raycasting against physics colliders only
|
|
105
|
+
* ```ts
|
|
106
|
+
* const origin = { x: 0, y: 5, z: 0 };
|
|
107
|
+
* const direction = { x: 0, y: -1, z: 0 };
|
|
108
|
+
* const hit = this.context.physics.engine?.raycast(origin, direction);
|
|
109
|
+
* if (hit) {
|
|
110
|
+
* console.log("Hit collider:", hit.collider.name);
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
* @example Accessing Rapier world directly
|
|
114
|
+
* ```ts
|
|
115
|
+
* const rapierWorld = this.context.physics.engine?.world;
|
|
116
|
+
* if (rapierWorld) {
|
|
117
|
+
* // Direct access to Rapier API
|
|
118
|
+
* console.log("Gravity:", rapierWorld.gravity);
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
* @example Using the Rapier module directly
|
|
122
|
+
* ```ts
|
|
123
|
+
* import { MODULES } from "@needle-tools/engine";
|
|
124
|
+
*
|
|
125
|
+
* // Load the Rapier module
|
|
126
|
+
* const RAPIER = await MODULES.RAPIER_PHYSICS.load();
|
|
127
|
+
*
|
|
128
|
+
* // Now you can use Rapier types and create custom physics objects
|
|
129
|
+
* const rigidBodyDesc = RAPIER.RigidBodyDesc.dynamic()
|
|
130
|
+
* .setTranslation(0, 10, 0);
|
|
131
|
+
*
|
|
132
|
+
* // Or access the already-loaded module
|
|
133
|
+
* if (MODULES.RAPIER_PHYSICS.MODULE) {
|
|
134
|
+
* const colliderDesc = MODULES.RAPIER_PHYSICS.MODULE.ColliderDesc.ball(1.0);
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
* @see {@link Rigidbody} for physics simulation component
|
|
138
|
+
* @see {@link Collider} for collision detection component
|
|
139
|
+
* @see {@link Physics} for general raycasting and physics utilities
|
|
140
|
+
* @see {@link MODULES.RAPIER_PHYSICS} for direct access to the Rapier module
|
|
141
|
+
* @link https://rapier.rs/docs/ for Rapier documentation
|
|
142
|
+
* @link https://engine.needle.tools/docs/reference/components.html#physics
|
|
143
|
+
* @link https://engine.needle.tools/docs/how-to-guides/scripting/use-physics.html
|
|
144
|
+
*/
|
|
64
145
|
export class RapierPhysics implements IPhysicsEngine {
|
|
65
146
|
|
|
66
147
|
debugRenderColliders: boolean = false;
|
|
@@ -8,8 +8,34 @@ export const serializeable = function <T>(type?: Constructor<T> | null | Array<C
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Marks a field for serialization and editor exposure. Required for fields that reference
|
|
12
|
+
* other objects, components, or assets. Primitive types (string, number, boolean) work without a type argument.
|
|
13
|
+
*
|
|
14
|
+
* @param type The constructor type for complex objects. Omit for primitives.
|
|
15
|
+
*
|
|
16
|
+
* @example Primitive types (no type needed)
|
|
17
|
+
* ```ts
|
|
18
|
+
* @serializable()
|
|
19
|
+
* speed: number = 1;
|
|
20
|
+
*
|
|
21
|
+
* @serializable()
|
|
22
|
+
* label: string = "Hello";
|
|
23
|
+
* ```
|
|
24
|
+
* @example Object references
|
|
25
|
+
* ```ts
|
|
26
|
+
* @serializable(Object3D)
|
|
27
|
+
* target: Object3D | null = null;
|
|
28
|
+
*
|
|
29
|
+
* @serializable(Renderer)
|
|
30
|
+
* myRenderer: Renderer | null = null;
|
|
31
|
+
* ```
|
|
32
|
+
* @example Arrays
|
|
33
|
+
* ```ts
|
|
34
|
+
* @serializable([Object3D])
|
|
35
|
+
* waypoints: Object3D[] = [];
|
|
36
|
+
* ```
|
|
37
|
+
* @see {@link syncField} for automatic network synchronization
|
|
38
|
+
* @link https://engine.needle.tools/docs/reference/typescript-decorators.html#serializable
|
|
13
39
|
*/
|
|
14
40
|
export const serializable = function <T>(type?: Constructor<T> | null | Array<Constructor<any> | TypeResolver<T>> | TypeResolver<T>) {
|
|
15
41
|
if (type === undefined) type = null;
|
|
@@ -8,8 +8,23 @@ let timeScale = 1;
|
|
|
8
8
|
if (typeof timescaleUrl === "number") timeScale = timescaleUrl;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Provides time-related information for frame-based game logic.
|
|
12
|
+
* Access via `this.context.time` from any component.
|
|
13
|
+
*
|
|
14
|
+
* @example Using deltaTime for frame-rate independent movement
|
|
15
|
+
* ```ts
|
|
16
|
+
* update() {
|
|
17
|
+
* // Move 1 unit per second regardless of frame rate
|
|
18
|
+
* this.gameObject.position.x += 1 * this.context.time.deltaTime;
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
* @example Checking elapsed time
|
|
22
|
+
* ```ts
|
|
23
|
+
* start() {
|
|
24
|
+
* console.log(`Time since start: ${this.context.time.time}s`);
|
|
25
|
+
* console.log(`Current frame: ${this.context.time.frameCount}`);
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
13
28
|
*/
|
|
14
29
|
export class Time implements ITime {
|
|
15
30
|
|
|
@@ -27,7 +42,12 @@ export class Time implements ITime {
|
|
|
27
42
|
get deltaTimeUnscaled() { return this._deltaTimeUnscaled; }
|
|
28
43
|
private _deltaTimeUnscaled = 0;
|
|
29
44
|
|
|
30
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* The scale at which time passes. Default is 1.
|
|
47
|
+
* - Values < 1 create slow motion (e.g. 0.5 = half speed)
|
|
48
|
+
* - Values > 1 speed up time (e.g. 2 = double speed)
|
|
49
|
+
* - Value of 0 effectively pauses time-dependent logic
|
|
50
|
+
*/
|
|
31
51
|
timeScale = 1;
|
|
32
52
|
|
|
33
53
|
/** same as frameCount */
|
|
@@ -9,7 +9,37 @@ import { watchWrite } from "./engine_utils.js";
|
|
|
9
9
|
declare type setter = (v: any) => void;
|
|
10
10
|
declare type getter = () => any;
|
|
11
11
|
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Marks a field to trigger the `onValidate` callback when its value changes.
|
|
14
|
+
* Useful for reacting to property changes from the editor or at runtime.
|
|
15
|
+
*
|
|
16
|
+
* Your component must implement `onValidate(property?: string)` to receive notifications.
|
|
17
|
+
*
|
|
18
|
+
* @param set Optional custom setter called before the value is assigned
|
|
19
|
+
* @param get Optional custom getter called when the value is read
|
|
20
|
+
*
|
|
21
|
+
* @example Basic usage
|
|
22
|
+
* ```ts
|
|
23
|
+
* export class MyComponent extends Behaviour {
|
|
24
|
+
* @serializable()
|
|
25
|
+
* @validate()
|
|
26
|
+
* color: Color = new Color(1, 0, 0);
|
|
27
|
+
*
|
|
28
|
+
* onValidate(property?: string) {
|
|
29
|
+
* if (property === "color") {
|
|
30
|
+
* console.log("Color changed to:", this.color);
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
* @example With custom setter
|
|
36
|
+
* ```ts
|
|
37
|
+
* @validate(function(value) {
|
|
38
|
+
* console.log("Setting speed to", value);
|
|
39
|
+
* })
|
|
40
|
+
* speed: number = 1;
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
13
43
|
export const validate = function (set?: setter, get?: getter) {
|
|
14
44
|
// "descriptor : undefined" prevents @validate() to be added to property getters or setters
|
|
15
45
|
return function (target: IComponent | any, propertyKey: string, descriptor?: undefined) {
|