@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
|
@@ -1,12 +1,63 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
|
+
/** Known needle-engine tag names that should be updated from the source */
|
|
5
|
+
const NEEDLE_TAG_NAMES = ['needle-engine', 'needle-menu', 'needle-button'];
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
8
|
+
* Merges needle-engine custom element data into an existing custom-elements.json file.
|
|
9
|
+
* Preserves user-defined tags while updating needle-engine specific tags.
|
|
10
|
+
* @param {object} sourceData - The needle-engine custom-elements.json data
|
|
11
|
+
* @param {object} targetData - The existing project custom-elements.json data
|
|
12
|
+
* @returns {object} Merged data
|
|
13
|
+
*/
|
|
14
|
+
function mergeCustomElementData(sourceData, targetData) {
|
|
15
|
+
const merged = { ...targetData };
|
|
16
|
+
|
|
17
|
+
// Ensure basic structure
|
|
18
|
+
merged.version = sourceData.version || targetData.version || 1.1;
|
|
19
|
+
merged.tags = merged.tags || [];
|
|
20
|
+
merged.globalAttributes = merged.globalAttributes || targetData.globalAttributes || [];
|
|
21
|
+
merged.valueSets = merged.valueSets || targetData.valueSets || [];
|
|
22
|
+
|
|
23
|
+
// Get source tags (needle-engine tags)
|
|
24
|
+
const sourceTags = sourceData.tags || [];
|
|
25
|
+
|
|
26
|
+
// Update or add needle-engine tags
|
|
27
|
+
for (const sourceTag of sourceTags) {
|
|
28
|
+
const existingIndex = merged.tags.findIndex(t => t.name === sourceTag.name);
|
|
29
|
+
if (existingIndex >= 0) {
|
|
30
|
+
// Replace existing needle-engine tag with updated version
|
|
31
|
+
if (NEEDLE_TAG_NAMES.includes(sourceTag.name)) {
|
|
32
|
+
merged.tags[existingIndex] = sourceTag;
|
|
33
|
+
}
|
|
34
|
+
// Otherwise keep existing (user-defined) tag
|
|
35
|
+
} else {
|
|
36
|
+
// Add new tag
|
|
37
|
+
merged.tags.push(sourceTag);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Merge valueSets (avoid duplicates by name)
|
|
42
|
+
const sourceValueSets = sourceData.valueSets || [];
|
|
43
|
+
for (const sourceSet of sourceValueSets) {
|
|
44
|
+
const existingIndex = merged.valueSets.findIndex(s => s.name === sourceSet.name);
|
|
45
|
+
if (existingIndex >= 0) {
|
|
46
|
+
merged.valueSets[existingIndex] = sourceSet;
|
|
47
|
+
} else {
|
|
48
|
+
merged.valueSets.push(sourceSet);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return merged;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Ensure the repo workspace or .vscode settings include Needle Engine custom HTML data if they exist.
|
|
57
|
+
* Copies custom-elements.json to the project and merges with existing user content.
|
|
58
|
+
* - Copies/merges `custom-elements.json` to project root
|
|
59
|
+
* - Adds `./custom-elements.json` to `.code-workspace settings.html.customData`
|
|
60
|
+
* - Adds `./custom-elements.json` to `.vscode/settings.json html.customData`
|
|
10
61
|
* @param {string} command
|
|
11
62
|
* @param {import('../types').needleMeta | null} config
|
|
12
63
|
* @param {import('../types').userSettings} userSettings
|
|
@@ -21,6 +72,52 @@ export const needleCustomElementData = (command, config, userSettings = {}) => {
|
|
|
21
72
|
try {
|
|
22
73
|
const cwd = process.cwd();
|
|
23
74
|
|
|
75
|
+
// Path to source custom-elements.json in node_modules
|
|
76
|
+
const sourceFile = path.join(cwd, 'node_modules', '@needle-tools', 'engine', 'custom-elements.json');
|
|
77
|
+
// Path to target custom-elements.json in project root
|
|
78
|
+
const targetFile = path.join(cwd, 'custom-elements.json');
|
|
79
|
+
|
|
80
|
+
// Copy/merge custom-elements.json to project
|
|
81
|
+
if (fs.existsSync(sourceFile)) {
|
|
82
|
+
try {
|
|
83
|
+
const sourceData = JSON.parse(fs.readFileSync(sourceFile, 'utf8'));
|
|
84
|
+
|
|
85
|
+
let targetData = {};
|
|
86
|
+
if (fs.existsSync(targetFile)) {
|
|
87
|
+
// Merge with existing file to preserve user content
|
|
88
|
+
try {
|
|
89
|
+
targetData = JSON.parse(fs.readFileSync(targetFile, 'utf8'));
|
|
90
|
+
} catch {
|
|
91
|
+
targetData = {};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const mergedData = mergeCustomElementData(sourceData, targetData);
|
|
96
|
+
const newContent = JSON.stringify(mergedData, null, 2);
|
|
97
|
+
|
|
98
|
+
// Only write if content changed
|
|
99
|
+
const existingContent = fs.existsSync(targetFile)
|
|
100
|
+
? fs.readFileSync(targetFile, 'utf8')
|
|
101
|
+
: '';
|
|
102
|
+
if (newContent !== existingContent) {
|
|
103
|
+
fs.writeFileSync(targetFile, newContent, 'utf8');
|
|
104
|
+
}
|
|
105
|
+
} catch (err) {
|
|
106
|
+
// Fallback: just copy the file if merge fails
|
|
107
|
+
try {
|
|
108
|
+
fs.copyFileSync(sourceFile, targetFile);
|
|
109
|
+
} catch {
|
|
110
|
+
// ignore
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Local path for VSCode settings (now points to project root)
|
|
116
|
+
const localCustomDataPath = './custom-elements.json';
|
|
117
|
+
// Old path in node_modules (to remove/replace)
|
|
118
|
+
const oldNodeModulesPath = './node_modules/@needle-tools/engine/custom-elements.json';
|
|
119
|
+
const oldWorkspaceNodeModulesPath = './../node_modules/@needle-tools/engine/custom-elements.json';
|
|
120
|
+
|
|
24
121
|
// 1) workspace file(s)
|
|
25
122
|
const files = fs.readdirSync(cwd);
|
|
26
123
|
const workspaceFiles = files.filter(f => f.endsWith('.code-workspace'));
|
|
@@ -30,12 +127,19 @@ export const needleCustomElementData = (command, config, userSettings = {}) => {
|
|
|
30
127
|
const raw = fs.readFileSync(full, 'utf8');
|
|
31
128
|
const data = JSON.parse(raw);
|
|
32
129
|
|
|
33
|
-
// Ensure settings.html.customData contains the
|
|
130
|
+
// Ensure settings.html.customData contains the local path
|
|
34
131
|
data.settings = data.settings || {};
|
|
35
132
|
data.settings['html.customData'] = data.settings['html.customData'] || [];
|
|
36
|
-
|
|
37
|
-
if
|
|
38
|
-
|
|
133
|
+
|
|
134
|
+
// Remove old node_modules path if present
|
|
135
|
+
const oldIndex = data.settings['html.customData'].indexOf(oldWorkspaceNodeModulesPath);
|
|
136
|
+
if (oldIndex >= 0) {
|
|
137
|
+
data.settings['html.customData'].splice(oldIndex, 1);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Add local path if not present
|
|
141
|
+
if (!data.settings['html.customData'].includes(localCustomDataPath)) {
|
|
142
|
+
data.settings['html.customData'].push(localCustomDataPath);
|
|
39
143
|
|
|
40
144
|
const newRaw = JSON.stringify(data, null, 2);
|
|
41
145
|
fs.writeFileSync(full, newRaw, 'utf8');
|
|
@@ -47,21 +151,26 @@ export const needleCustomElementData = (command, config, userSettings = {}) => {
|
|
|
47
151
|
|
|
48
152
|
// 2) .vscode/settings.json
|
|
49
153
|
const vscodeDir = path.join(cwd, '.vscode');
|
|
50
|
-
|
|
51
154
|
const settingsFile = path.join(vscodeDir, 'settings.json');
|
|
52
|
-
|
|
53
|
-
let settings = {};
|
|
54
|
-
let rawSettings = "";
|
|
155
|
+
|
|
55
156
|
if (fs.existsSync(settingsFile)) {
|
|
56
157
|
try {
|
|
57
|
-
rawSettings = fs.readFileSync(settingsFile, 'utf8');
|
|
58
|
-
|
|
158
|
+
const rawSettings = fs.readFileSync(settingsFile, 'utf8');
|
|
159
|
+
/** @type {Record<string, any>} */
|
|
160
|
+
const settings = JSON.parse(rawSettings) || {};
|
|
59
161
|
|
|
60
162
|
settings['html.customData'] = settings['html.customData'] || [];
|
|
61
|
-
|
|
62
|
-
if
|
|
63
|
-
|
|
64
|
-
|
|
163
|
+
|
|
164
|
+
// Remove old node_modules path if present
|
|
165
|
+
const oldIndex = settings['html.customData'].indexOf(oldNodeModulesPath);
|
|
166
|
+
if (oldIndex >= 0) {
|
|
167
|
+
settings['html.customData'].splice(oldIndex, 1);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Add local path if not present
|
|
171
|
+
if (!settings['html.customData'].includes(localCustomDataPath)) {
|
|
172
|
+
settings['html.customData'].push(localCustomDataPath);
|
|
173
|
+
|
|
65
174
|
// Write back settings.json if changed
|
|
66
175
|
const newRawSettings = JSON.stringify(settings, null, 2);
|
|
67
176
|
fs.writeFileSync(settingsFile, newRawSettings, 'utf8');
|
|
@@ -97,15 +97,31 @@ export class ContextArgs {
|
|
|
97
97
|
scene?: Scene;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Represents the different phases of the update cycle in Needle Engine.
|
|
102
|
+
* Components can register for specific frame events to perform actions at precise moments.
|
|
103
|
+
* The order of execution is: Start → EarlyUpdate → Update → LateUpdate → OnBeforeRender → OnAfterRender
|
|
104
|
+
*
|
|
105
|
+
* @see {@link Component.startCoroutine} for using FrameEvent with coroutines
|
|
106
|
+
*/
|
|
100
107
|
export enum FrameEvent {
|
|
108
|
+
/** Called once when a component starts for the first time */
|
|
101
109
|
Start = -1,
|
|
110
|
+
/** Called at the beginning of each frame, before the main update */
|
|
102
111
|
EarlyUpdate = 0,
|
|
112
|
+
/** The main update phase, called once per frame */
|
|
103
113
|
Update = 1,
|
|
114
|
+
/** Called after all Update callbacks have finished */
|
|
104
115
|
LateUpdate = 2,
|
|
116
|
+
/** Called immediately before the scene is rendered */
|
|
105
117
|
OnBeforeRender = 3,
|
|
118
|
+
/** Called after the scene has been rendered */
|
|
106
119
|
OnAfterRender = 4,
|
|
120
|
+
/** Called before each physics simulation step */
|
|
107
121
|
PrePhysicsStep = 9,
|
|
122
|
+
/** Called after each physics simulation step */
|
|
108
123
|
PostPhysicsStep = 10,
|
|
124
|
+
/** Default value when no specific frame event is set */
|
|
109
125
|
Undefined = -1,
|
|
110
126
|
}
|
|
111
127
|
|
|
@@ -152,6 +152,29 @@ export function setDontDestroy(instance: Object3D | Component, value: boolean =
|
|
|
152
152
|
|
|
153
153
|
const destroyed_components: Array<IComponent> = [];
|
|
154
154
|
const destroyed_objects: Array<Object3D> = [];
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Destroys a GameObject or Component, removing it from the scene and cleaning up resources.
|
|
158
|
+
* Calls `onDisable()` and `onDestroy()` lifecycle methods on all affected components.
|
|
159
|
+
*
|
|
160
|
+
* @param instance The Object3D or Component to destroy
|
|
161
|
+
* @param recursive If true (default), also destroys all children recursively
|
|
162
|
+
* @param dispose If true, also disposes GPU resources (geometries, materials, textures)
|
|
163
|
+
*
|
|
164
|
+
* @example Destroy an object
|
|
165
|
+
* ```ts
|
|
166
|
+
* import { destroy } from "@needle-tools/engine";
|
|
167
|
+
* destroy(this.gameObject);
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @example Destroy with resource disposal
|
|
171
|
+
* ```ts
|
|
172
|
+
* destroy(myObject, true, true); // recursive + dispose GPU resources
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @see {@link GameObject.destroy} for the static method equivalent
|
|
176
|
+
* @see {@link setDontDestroy} to mark objects as non-destroyable
|
|
177
|
+
*/
|
|
155
178
|
export function destroy(instance: Object3D | Component, recursive: boolean = true, dispose: boolean = false) {
|
|
156
179
|
destroyed_components.length = 0;
|
|
157
180
|
destroyed_objects.length = 0;
|
|
@@ -224,6 +247,22 @@ function internalDestroy(instance: Object3D | Component, recursive: boolean = tr
|
|
|
224
247
|
|
|
225
248
|
declare type ForEachComponentCallback = (comp: Component) => any;
|
|
226
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Iterates over all components on an Object3D and optionally its children.
|
|
252
|
+
* The callback can return a value to stop iteration early.
|
|
253
|
+
*
|
|
254
|
+
* @param instance The Object3D to iterate components on
|
|
255
|
+
* @param cb Callback function called for each component. Return a value to stop iteration.
|
|
256
|
+
* @param recursive If true (default), also iterates components on all children
|
|
257
|
+
* @returns The first non-undefined value returned by the callback, or undefined
|
|
258
|
+
*
|
|
259
|
+
* @example Find first Rigidbody in hierarchy
|
|
260
|
+
* ```ts
|
|
261
|
+
* const rb = foreachComponent(myObject, comp => {
|
|
262
|
+
* if (comp instanceof Rigidbody) return comp;
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
227
266
|
export function foreachComponent(instance: Object3D, cb: ForEachComponentCallback, recursive: boolean = true): any {
|
|
228
267
|
return internalForEachComponent(instance, cb, recursive);
|
|
229
268
|
}
|
|
@@ -294,6 +333,40 @@ declare type NewObjectReferenceMap = Record<string, { target: object, key: strin
|
|
|
294
333
|
*/
|
|
295
334
|
export declare type InstantiateContext = Readonly<InstantiateReferenceMap>;
|
|
296
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Creates a copy (clone) of a GameObject or loads and instantiates an AssetReference.
|
|
338
|
+
* All components on the original object are cloned and `awake()` is called on them.
|
|
339
|
+
*
|
|
340
|
+
* @param instance The Object3D to clone, or an AssetReference to load and instantiate
|
|
341
|
+
* @param opts Optional instantiation settings (position, rotation, scale, parent)
|
|
342
|
+
* @returns The cloned GameObject, or a Promise<Object3D> if instantiating from AssetReference
|
|
343
|
+
*
|
|
344
|
+
* @example Clone an object
|
|
345
|
+
* ```ts
|
|
346
|
+
* import { instantiate } from "@needle-tools/engine";
|
|
347
|
+
* const clone = instantiate(original);
|
|
348
|
+
* clone.position.set(1, 0, 0);
|
|
349
|
+
* this.context.scene.add(clone);
|
|
350
|
+
* ```
|
|
351
|
+
*
|
|
352
|
+
* @example Instantiate with options
|
|
353
|
+
* ```ts
|
|
354
|
+
* const clone = instantiate(original, {
|
|
355
|
+
* parent: parentObject,
|
|
356
|
+
* position: new Vector3(0, 1, 0),
|
|
357
|
+
* rotation: new Quaternion()
|
|
358
|
+
* });
|
|
359
|
+
* ```
|
|
360
|
+
*
|
|
361
|
+
* @example Instantiate from AssetReference
|
|
362
|
+
* ```ts
|
|
363
|
+
* const instance = await instantiate(myAssetRef);
|
|
364
|
+
* if (instance) this.context.scene.add(instance);
|
|
365
|
+
* ```
|
|
366
|
+
*
|
|
367
|
+
* @see {@link GameObject.instantiate} for the static method equivalent
|
|
368
|
+
* @see {@link destroy} to remove instantiated objects
|
|
369
|
+
*/
|
|
297
370
|
export function instantiate(instance: AssetReference, opts?: IInstantiateOptions | null): Promise<Object3D | null>
|
|
298
371
|
export function instantiate(instance: GameObject | Object3D, opts?: IInstantiateOptions | null): GameObject
|
|
299
372
|
export function instantiate(instance: AssetReference | GameObject | Object3D, opts?: IInstantiateOptions | null | undefined): GameObject | Promise<Object3D | null> {
|
|
@@ -9,10 +9,17 @@ import { DeviceUtilities, type EnumToPrimitiveUnion, getParam } from './engine_u
|
|
|
9
9
|
const debug = getParam("debuginput");
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Types of pointer input devices supported by Needle Engine.
|
|
14
|
+
*/
|
|
12
15
|
export const enum PointerType {
|
|
16
|
+
/** Mouse or trackpad input */
|
|
13
17
|
Mouse = "mouse",
|
|
18
|
+
/** Touch screen input */
|
|
14
19
|
Touch = "touch",
|
|
20
|
+
/** XR controller input (e.g., VR controllers) */
|
|
15
21
|
Controller = "controller",
|
|
22
|
+
/** XR hand tracking input */
|
|
16
23
|
Hand = "hand"
|
|
17
24
|
}
|
|
18
25
|
export type PointerTypeNames = EnumToPrimitiveUnion<PointerType>;
|
|
@@ -28,12 +35,23 @@ const enum KeyboardEnumType {
|
|
|
28
35
|
KeyPressed = "keypress"
|
|
29
36
|
}
|
|
30
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Event types that can be listened to via {@link Input.addEventListener}.
|
|
40
|
+
* @see {@link NEPointerEvent} for pointer event data
|
|
41
|
+
* @see {@link NEKeyboardEvent} for keyboard event data
|
|
42
|
+
*/
|
|
31
43
|
export const enum InputEvents {
|
|
44
|
+
/** Fired when a pointer button is pressed */
|
|
32
45
|
PointerDown = "pointerdown",
|
|
46
|
+
/** Fired when a pointer button is released */
|
|
33
47
|
PointerUp = "pointerup",
|
|
48
|
+
/** Fired when a pointer moves */
|
|
34
49
|
PointerMove = "pointermove",
|
|
50
|
+
/** Fired when a key is pressed down */
|
|
35
51
|
KeyDown = "keydown",
|
|
52
|
+
/** Fired when a key is released */
|
|
36
53
|
KeyUp = "keyup",
|
|
54
|
+
/** Fired when a key produces a character value */
|
|
37
55
|
KeyPressed = "keypress"
|
|
38
56
|
}
|
|
39
57
|
|
|
@@ -81,7 +99,22 @@ export interface IPointerHitEventReceiver {
|
|
|
81
99
|
export declare type NEPointerEventIntersection = Intersection & { event?: NEPointerEvent };
|
|
82
100
|
|
|
83
101
|
/**
|
|
84
|
-
*
|
|
102
|
+
* Extended PointerEvent with Needle Engine-specific data.
|
|
103
|
+
* Contains information about the input device, spatial data for XR, and world-space ray.
|
|
104
|
+
*
|
|
105
|
+
* @example Accessing event data in a component
|
|
106
|
+
* ```ts
|
|
107
|
+
* onPointerDown(args: PointerEventData) {
|
|
108
|
+
* const evt = args.event;
|
|
109
|
+
* console.log(`Pointer ${evt.pointerId} (${evt.pointerType})`);
|
|
110
|
+
* if (evt.isSpatial) {
|
|
111
|
+
* console.log("XR input, ray:", evt.ray);
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @see {@link Input} for the input management system
|
|
117
|
+
* @see {@link PointerType} for available pointer types
|
|
85
118
|
*/
|
|
86
119
|
export class NEPointerEvent extends PointerEvent {
|
|
87
120
|
|
|
@@ -255,7 +288,50 @@ declare type EventListenerOptions = {
|
|
|
255
288
|
type RegisteredEventListenerValue = Array<{ priority: number, listeners: Array<{ callback: InputEventListener, options: EventListenerOptions }> }>;
|
|
256
289
|
|
|
257
290
|
/**
|
|
258
|
-
*
|
|
291
|
+
* Handles all input events including mouse, touch, keyboard, and XR controllers.
|
|
292
|
+
* Access via `this.context.input` from any component.
|
|
293
|
+
*
|
|
294
|
+
* @example Checking mouse/pointer state
|
|
295
|
+
* ```ts
|
|
296
|
+
* update() {
|
|
297
|
+
* if (this.context.input.mouseDown) {
|
|
298
|
+
* console.log("Mouse button pressed");
|
|
299
|
+
* }
|
|
300
|
+
* if (this.context.input.mouseClick) {
|
|
301
|
+
* console.log("Click detected");
|
|
302
|
+
* }
|
|
303
|
+
* const pos = this.context.input.mousePosition;
|
|
304
|
+
* console.log(`Mouse at: ${pos.x}, ${pos.y}`);
|
|
305
|
+
* }
|
|
306
|
+
* ```
|
|
307
|
+
* @example Keyboard input
|
|
308
|
+
* ```ts
|
|
309
|
+
* update() {
|
|
310
|
+
* if (this.context.input.isKeyDown("Space")) {
|
|
311
|
+
* console.log("Space pressed this frame");
|
|
312
|
+
* }
|
|
313
|
+
* if (this.context.input.isKeyPressed("w")) {
|
|
314
|
+
* console.log("W key is held down");
|
|
315
|
+
* }
|
|
316
|
+
* }
|
|
317
|
+
* ```
|
|
318
|
+
* @example Event-based input
|
|
319
|
+
* ```ts
|
|
320
|
+
* onEnable() {
|
|
321
|
+
* this.context.input.addEventListener("pointerdown", this.onPointerDown);
|
|
322
|
+
* }
|
|
323
|
+
* onDisable() {
|
|
324
|
+
* this.context.input.removeEventListener("pointerdown", this.onPointerDown);
|
|
325
|
+
* }
|
|
326
|
+
* onPointerDown = (evt: NEPointerEvent) => {
|
|
327
|
+
* console.log("Pointer down:", evt.pointerId);
|
|
328
|
+
* }
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* @see {@link NEPointerEvent} for pointer event data
|
|
332
|
+
* @see {@link InputEvents} for available event types
|
|
333
|
+
* @see {@link PointerType} for pointer device types
|
|
334
|
+
* @link https://engine.needle.tools/docs/scripting.html
|
|
259
335
|
*/
|
|
260
336
|
export class Input implements IInput {
|
|
261
337
|
|
|
@@ -269,14 +345,14 @@ export class Input implements IInput {
|
|
|
269
345
|
* @param type The event type to listen for
|
|
270
346
|
* @param callback The callback to call when the event is triggered
|
|
271
347
|
* @param options The options for adding the event listener.
|
|
272
|
-
* @example Basic usage
|
|
348
|
+
* @example Basic usage
|
|
273
349
|
* ```ts
|
|
274
|
-
* input.addEventListener("pointerdown", (evt) => {
|
|
350
|
+
* input.addEventListener("pointerdown", (evt) => {
|
|
275
351
|
* console.log("Pointer down", evt.pointerId, evt.pointerType);
|
|
276
352
|
* });
|
|
277
353
|
* ```
|
|
278
|
-
* @example Adding a listener that is called after all other listeners
|
|
279
|
-
* By using a higher value for the queue the listener will be called after other listeners (default queue is 0).
|
|
354
|
+
* @example Adding a listener that is called after all other listeners
|
|
355
|
+
* By using a higher value for the queue the listener will be called after other listeners (default queue is 0).
|
|
280
356
|
* ```ts
|
|
281
357
|
* input.addEventListener("pointerdown", (evt) => {
|
|
282
358
|
* console.log("Pointer down", evt.pointerId, evt.pointerType);
|
|
@@ -285,7 +361,7 @@ export class Input implements IInput {
|
|
|
285
361
|
* @example Adding a listener that is only called once
|
|
286
362
|
* ```ts
|
|
287
363
|
* input.addEventListener("pointerdown", (evt) => {
|
|
288
|
-
*
|
|
364
|
+
* console.log("Pointer down", evt.pointerId, evt.pointerType);
|
|
289
365
|
* }, { once: true });
|
|
290
366
|
* ```
|
|
291
367
|
*/
|
|
@@ -4,9 +4,40 @@ import type { Vec3 } from "./engine_types.js";
|
|
|
4
4
|
|
|
5
5
|
declare type Vector = Vector3 | Vector4 | Vector2 | Quaternion;
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Math utility class providing common mathematical operations.
|
|
9
|
+
* Access via the exported `Mathf` constant.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { Mathf } from "@needle-tools/engine";
|
|
14
|
+
*
|
|
15
|
+
* // Random number between 0 and 10
|
|
16
|
+
* const rand = Mathf.random(0, 10);
|
|
17
|
+
*
|
|
18
|
+
* // Clamp a value
|
|
19
|
+
* const clamped = Mathf.clamp(value, 0, 100);
|
|
20
|
+
*
|
|
21
|
+
* // Smooth interpolation
|
|
22
|
+
* const smoothed = Mathf.lerp(start, end, t);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
7
25
|
class MathHelper {
|
|
8
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Returns a random number or element.
|
|
29
|
+
* @param arr Array to pick a random element from
|
|
30
|
+
* @returns Random element from array, or null if array is empty
|
|
31
|
+
* @example `Mathf.random([1, 2, 3])` - returns random element
|
|
32
|
+
*/
|
|
9
33
|
random<T>(arr: Array<T>): T | null;
|
|
34
|
+
/**
|
|
35
|
+
* Returns a random number between min and max (inclusive).
|
|
36
|
+
* @param min Minimum value (inclusive)
|
|
37
|
+
* @param max Maximum value (inclusive)
|
|
38
|
+
* @returns Random number in range, or 0-1 if no args provided
|
|
39
|
+
* @example `Mathf.random(0, 10)` - returns 0 to 10
|
|
40
|
+
*/
|
|
10
41
|
random(min?: number, max?: number): number;
|
|
11
42
|
random<T>(arrayOrMin?: number | Array<T>, max?: number): number | T | null {
|
|
12
43
|
if (Array.isArray(arrayOrMin)) {
|
|
@@ -21,12 +52,25 @@ class MathHelper {
|
|
|
21
52
|
return Math.random();
|
|
22
53
|
}
|
|
23
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Fills a Vector3 with random values.
|
|
57
|
+
* @param target Vector3 to fill with random values
|
|
58
|
+
* @param min Minimum value for each component
|
|
59
|
+
* @param max Maximum value for each component
|
|
60
|
+
*/
|
|
24
61
|
randomVector3(target: Vector3, min: number = 0, max: number = 1) {
|
|
25
62
|
target.x = this.random(min, max);
|
|
26
63
|
target.y = this.random(min, max);
|
|
27
64
|
target.z = this.random(min, max);
|
|
28
65
|
}
|
|
29
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Clamps a value between min and max.
|
|
69
|
+
* @param value Value to clamp
|
|
70
|
+
* @param min Minimum bound
|
|
71
|
+
* @param max Maximum bound
|
|
72
|
+
* @returns Clamped value
|
|
73
|
+
*/
|
|
30
74
|
clamp(value: number, min: number, max: number) {
|
|
31
75
|
|
|
32
76
|
if (value < min) {
|
|
@@ -39,12 +83,21 @@ class MathHelper {
|
|
|
39
83
|
return value;
|
|
40
84
|
}
|
|
41
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Clamps a value between 0 and 1.
|
|
88
|
+
* @param value Value to clamp
|
|
89
|
+
* @returns Value clamped to [0, 1]
|
|
90
|
+
*/
|
|
42
91
|
clamp01(value: number) {
|
|
43
92
|
return this.clamp(value, 0, 1);
|
|
44
93
|
}
|
|
45
94
|
|
|
46
95
|
/**
|
|
47
|
-
*
|
|
96
|
+
* Linearly interpolates between two values.
|
|
97
|
+
* @param value1 Start value (returned when t=0)
|
|
98
|
+
* @param value2 End value (returned when t=1)
|
|
99
|
+
* @param t Interpolation factor, clamped to [0, 1]
|
|
100
|
+
* @returns Interpolated value
|
|
48
101
|
*/
|
|
49
102
|
lerp(value1: number, value2: number, t: number) {
|
|
50
103
|
t = t < 0 ? 0 : t;
|
|
@@ -53,7 +106,12 @@ class MathHelper {
|
|
|
53
106
|
}
|
|
54
107
|
|
|
55
108
|
/**
|
|
56
|
-
*
|
|
109
|
+
* Calculates the linear interpolation parameter that produces the given value.
|
|
110
|
+
* Inverse of lerp: if `lerp(a, b, t) = v`, then `inverseLerp(a, b, v) = t`
|
|
111
|
+
* @param value1 Start value
|
|
112
|
+
* @param value2 End value
|
|
113
|
+
* @param t The value to find the parameter for
|
|
114
|
+
* @returns The interpolation parameter (may be outside [0,1] if t is outside [value1, value2])
|
|
57
115
|
*/
|
|
58
116
|
inverseLerp(value1: number, value2: number, t: number) {
|
|
59
117
|
return (t - value1) / (value2 - value1);
|
|
@@ -71,6 +129,14 @@ class MathHelper {
|
|
|
71
129
|
return min2 + (max2 - min2) * (value - min1) / (max1 - min1);
|
|
72
130
|
}
|
|
73
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Moves a value towards a target by a maximum step amount.
|
|
134
|
+
* Useful for smooth following or gradual value changes.
|
|
135
|
+
* @param value1 Current value
|
|
136
|
+
* @param value2 Target value
|
|
137
|
+
* @param amount Maximum step to move (positive moves toward target)
|
|
138
|
+
* @returns New value moved toward target, never overshooting
|
|
139
|
+
*/
|
|
74
140
|
moveTowards(value1: number, value2: number, amount: number) {
|
|
75
141
|
value1 += amount;
|
|
76
142
|
if (amount < 0 && value1 < value2) value1 = value2;
|
|
@@ -108,6 +174,14 @@ class MathHelper {
|
|
|
108
174
|
return Math.pow(linear, 1 / 2.2);
|
|
109
175
|
}
|
|
110
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Checks if two vectors are approximately equal within epsilon tolerance.
|
|
179
|
+
* Works with Vector2, Vector3, Vector4, and Quaternion.
|
|
180
|
+
* @param v1 First vector
|
|
181
|
+
* @param v2 Second vector
|
|
182
|
+
* @param epsilon Tolerance for comparison (default: Number.EPSILON)
|
|
183
|
+
* @returns True if all components are within epsilon of each other
|
|
184
|
+
*/
|
|
111
185
|
approximately(v1: Vector, v2: Vector, epsilon = Number.EPSILON) {
|
|
112
186
|
for (const key of vectorKeys) {
|
|
113
187
|
const a = v1[key];
|
|
@@ -121,6 +195,11 @@ class MathHelper {
|
|
|
121
195
|
return true;
|
|
122
196
|
}
|
|
123
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Easing function: slow start, fast middle, slow end (cubic).
|
|
200
|
+
* @param x Input value from 0 to 1
|
|
201
|
+
* @returns Eased value from 0 to 1
|
|
202
|
+
*/
|
|
124
203
|
easeInOutCubic(x: number) {
|
|
125
204
|
return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
|
|
126
205
|
}
|