@needle-tools/engine 4.12.5 → 4.13.0-next.1eca7a7
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 +5 -0
- package/README.md +38 -1
- package/components.needle.json +1 -1
- package/custom-elements.json +156 -5
- package/dist/{gltf-progressive-BqUnxvCx.umd.cjs → gltf-progressive-BURrJW0U.umd.cjs} +1 -1
- package/dist/{gltf-progressive-CSaX5HQb.min.js → gltf-progressive-DHLDFNvQ.min.js} +1 -1
- package/dist/{gltf-progressive-ChnIhDXx.js → gltf-progressive-eiJCrjLb.js} +3 -3
- package/dist/materialx-B9ddsHcF.min.js +90 -0
- package/dist/materialx-BF23AVE8.umd.cjs +90 -0
- package/dist/materialx-fkoFuRh3.js +4636 -0
- package/dist/{needle-engine.bundle-Cnemui9H.umd.cjs → needle-engine.bundle-BfrDWglE.umd.cjs} +124 -124
- package/dist/{needle-engine.bundle-B_IGIr6Z.min.js → needle-engine.bundle-Bx_Lq_3v.min.js} +131 -131
- package/dist/{needle-engine.bundle-Cj66livk.js → needle-engine.bundle-MQyZGnMF.js} +3754 -3374
- package/dist/needle-engine.d.ts +2791 -309
- package/dist/needle-engine.js +415 -414
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-12-UW7je.min.js → postprocessing-BVNrgYZK.min.js} +1 -1
- package/dist/{postprocessing-B3Hu0Ryi.umd.cjs → postprocessing-CI2TjWpu.umd.cjs} +1 -1
- package/dist/{postprocessing-R535krvT.js → postprocessing-DdM-tz1j.js} +2 -2
- package/dist/{three-BzxwLtUE.umd.cjs → three-BW2s1Yl-.umd.cjs} +25 -25
- package/dist/{three-DMvLgxja.min.js → three-I__hSXzr.min.js} +26 -26
- package/dist/{three-D9pcFbxc.js → three-VvRoMeIN.js} +22 -0
- package/dist/{three-examples-F0MJj0vr.js → three-examples-BhfOE7NG.js} +1 -1
- package/dist/{three-examples-CjSwCv_b.umd.cjs → three-examples-Bpfu6ke_.umd.cjs} +1 -1
- package/dist/{three-examples-CIv2roOA.min.js → three-examples-D8zAE_7t.min.js} +1 -1
- package/dist/{three-mesh-ui-BLnJQzMl.umd.cjs → three-mesh-ui-BU55xDxJ.umd.cjs} +1 -1
- package/dist/{three-mesh-ui-BllgajJz.min.js → three-mesh-ui-C3QbemOV.min.js} +1 -1
- package/dist/{three-mesh-ui-DYyiRn5Y.js → three-mesh-ui-CcMp-FQm.js} +1 -1
- package/dist/{vendor-BIFy-gRe.js → vendor-BiyIZ61v.js} +1 -1
- package/dist/{vendor-BFgQSG2m.umd.cjs → vendor-COVQl0b8.umd.cjs} +1 -1
- package/dist/{vendor-ChgmXMYr.min.js → vendor-DW7zqjuT.min.js} +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_loaders.js +7 -1
- package/lib/engine/engine_loaders.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_modules.d.ts +9 -0
- package/lib/engine/engine_modules.js +25 -0
- package/lib/engine/engine_modules.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 +35 -1
- package/lib/engine/engine_physics.js +35 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +76 -0
- package/lib/engine/engine_physics_rapier.js +76 -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/engine_utils_format.d.ts +1 -1
- package/lib/engine/engine_utils_format.js +4 -1
- package/lib/engine/engine_utils_format.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_materialx.d.ts +29 -0
- package/lib/engine/extensions/NEEDLE_materialx.js +115 -0
- package/lib/engine/extensions/NEEDLE_materialx.js.map +1 -0
- package/lib/engine/extensions/extensions.js +2 -0
- package/lib/engine/extensions/extensions.js.map +1 -1
- package/lib/engine/extensions/index.d.ts +1 -0
- package/lib/engine/extensions/index.js +1 -0
- 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/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 +31 -1
- package/lib/engine-components/Camera.js +31 -1
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CharacterController.d.ts +67 -3
- package/lib/engine-components/CharacterController.js +67 -3
- 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 +26 -6
- package/lib/engine-components/ContactShadows.js +46 -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 +38 -10
- package/lib/engine-components/EventList.js.map +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 +27 -5
- package/lib/engine-components/Light.js +27 -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/ReflectionProbe.d.ts +17 -2
- package/lib/engine-components/ReflectionProbe.js +28 -10
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +34 -0
- package/lib/engine-components/Renderer.js +35 -2
- package/lib/engine-components/Renderer.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 +38 -6
- package/lib/engine-components/ScreenCapture.js +38 -6
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/Skybox.js +1 -1
- 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 +6 -0
- package/lib/engine-components/SyncedRoom.js +6 -0
- 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/timeline/PlayableDirector.d.ts +99 -14
- package/lib/engine-components/timeline/PlayableDirector.js +91 -25
- package/lib/engine-components/timeline/PlayableDirector.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 +28 -3
- package/lib/engine-components/ui/Canvas.js +28 -3
- package/lib/engine-components/ui/Canvas.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/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/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/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/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 +3 -2
- package/plugins/vite/custom-element-data.js +128 -19
- package/plugins/vite/dependencies.js +9 -4
- package/plugins/vite/index.js +0 -2
- 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_loaders.ts +9 -2
- package/src/engine/engine_math.ts +81 -2
- package/src/engine/engine_modules.ts +24 -0
- package/src/engine/engine_networking.ts +187 -17
- package/src/engine/engine_networking_auto.ts +36 -9
- package/src/engine/engine_physics.ts +37 -1
- package/src/engine/engine_physics_rapier.ts +77 -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/engine_utils_format.ts +6 -2
- package/src/engine/extensions/NEEDLE_materialx.ts +143 -0
- package/src/engine/extensions/extensions.ts +2 -0
- package/src/engine/extensions/index.ts +1 -0
- 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/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 +73 -6
- package/src/engine-components/Collider.ts +78 -21
- package/src/engine-components/ContactShadows.ts +51 -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 +42 -29
- package/src/engine-components/Duplicatable.ts +37 -6
- package/src/engine-components/EventList.ts +41 -13
- 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 +30 -8
- 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/ReflectionProbe.ts +31 -13
- package/src/engine-components/Renderer.ts +34 -1
- package/src/engine-components/SceneSwitcher.ts +11 -0
- package/src/engine-components/ScreenCapture.ts +41 -9
- package/src/engine-components/Skybox.ts +1 -1
- package/src/engine-components/SmoothFollow.ts +69 -7
- package/src/engine-components/SpatialTrigger.ts +51 -4
- package/src/engine-components/SpectatorCamera.ts +23 -5
- package/src/engine-components/SyncedRoom.ts +6 -0
- 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/timeline/PlayableDirector.ts +104 -27
- package/src/engine-components/ui/Button.ts +29 -3
- package/src/engine-components/ui/Canvas.ts +28 -3
- package/src/engine-components/ui/Image.ts +22 -3
- package/src/engine-components/ui/Raycaster.ts +57 -8
- package/src/engine-components/ui/Text.ts +24 -2
- 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/XRFlag.ts +30 -3
- package/plugins/vite/materialx.js +0 -32
|
@@ -8,26 +8,62 @@ import { EventList } from "./EventList.js";
|
|
|
8
8
|
|
|
9
9
|
const debug = getParam("debugnestedgltf");
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
11
|
+
/**
|
|
12
|
+
* NestedGltf loads and instantiates a glTF file when the component starts.
|
|
13
|
+
* NestedGltf components are created by the Unity exporter when nesting Objects with the GltfObject component (in Unity).
|
|
14
|
+
* Use this for lazy-loading content, modular scene composition, or dynamic asset loading.
|
|
13
15
|
*
|
|
16
|
+
* 
|
|
17
|
+
*
|
|
18
|
+
* The loaded glTF is instantiated as a sibling (child of parent) by default,
|
|
19
|
+
* inheriting the transform of the GameObject with this component.
|
|
20
|
+
*
|
|
21
|
+
* **Features:**
|
|
22
|
+
* - Automatic loading on start
|
|
23
|
+
* - Progress callbacks for loading UI
|
|
24
|
+
* - Preloading support for faster display
|
|
25
|
+
* - Event callback when loading completes
|
|
26
|
+
*
|
|
27
|
+
* @example Load a glTF when object becomes active
|
|
28
|
+
* ```ts
|
|
29
|
+
* const nested = myPlaceholder.addComponent(NestedGltf);
|
|
30
|
+
* nested.filePath = new AssetReference("models/furniture.glb");
|
|
31
|
+
* nested.loaded.addEventListener(({ instance }) => {
|
|
32
|
+
* console.log("Loaded:", instance.name);
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Preload for instant display
|
|
37
|
+
* ```ts
|
|
38
|
+
* // Preload during loading screen
|
|
39
|
+
* await nested.preload();
|
|
40
|
+
* // Later, when object becomes active, it displays instantly
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
14
43
|
* @summary Loads and instantiates a nested glTF file
|
|
15
44
|
* @category Asset Management
|
|
16
45
|
* @group Components
|
|
46
|
+
* @see {@link AssetReference} for asset loading utilities
|
|
47
|
+
* @see {@link SceneSwitcher} for scene-level loading
|
|
48
|
+
* @link https://engine.needle.tools/samples/hotspots
|
|
17
49
|
*/
|
|
18
50
|
export class NestedGltf extends Behaviour {
|
|
19
51
|
|
|
20
|
-
/**
|
|
52
|
+
/** Reference to the glTF file to load. Can be a URL or asset path. */
|
|
21
53
|
@serializable(AssetReference)
|
|
22
54
|
filePath?: AssetReference;
|
|
23
55
|
|
|
24
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Event fired when the glTF has been loaded and instantiated.
|
|
58
|
+
* Provides the component, loaded instance, and asset reference.
|
|
59
|
+
*/
|
|
25
60
|
@serializable(EventList)
|
|
26
61
|
loaded: EventList<{ component: NestedGltf, instance: any, asset: AssetReference }> = new EventList();
|
|
27
62
|
|
|
28
63
|
/**
|
|
29
64
|
* EXPERIMENTAL for cloud asset loading
|
|
30
65
|
*/
|
|
66
|
+
@serializable()
|
|
31
67
|
loadAssetInParent = true;
|
|
32
68
|
|
|
33
69
|
|
|
@@ -5,11 +5,35 @@ import * as utils from "./../engine/engine_three_utils.js";
|
|
|
5
5
|
import { Behaviour, GameObject } from "./Component.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* OffsetConstraint
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* OffsetConstraint maintains a fixed positional and rotational offset relative to a target object.
|
|
9
|
+
* Useful for attaching objects to moving targets while preserving a specific spatial relationship.
|
|
10
|
+
*
|
|
11
|
+
* **Use cases:**
|
|
12
|
+
* - Camera following a player with offset
|
|
13
|
+
* - UI elements attached to characters
|
|
14
|
+
* - Weapons attached to hands
|
|
15
|
+
* - Objects orbiting around a target
|
|
16
|
+
*
|
|
17
|
+
* **Options:**
|
|
18
|
+
* - `affectPosition` - Apply position offset
|
|
19
|
+
* - `affectRotation` - Apply rotation offset
|
|
20
|
+
* - `alignLookDirection` - Make object face same direction as target
|
|
21
|
+
* - `levelLookDirection` - Keep look direction horizontal (ignore pitch)
|
|
22
|
+
* - `levelPosition` - Project position onto horizontal plane
|
|
23
|
+
* - `referenceSpace` - Transform offset in this object's coordinate space
|
|
24
|
+
*
|
|
25
|
+
* @example Attach camera offset to player
|
|
26
|
+
* ```ts
|
|
27
|
+
* const constraint = camera.addComponent(OffsetConstraint);
|
|
28
|
+
* // Configure via serialized properties in editor
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @summary Maintains positional/rotational offset relative to target
|
|
11
32
|
* @category Constraints
|
|
12
33
|
* @group Components
|
|
34
|
+
* @see {@link SmoothFollow} for smoothed following
|
|
35
|
+
* @see {@link LookAtConstraint} for aim constraints
|
|
36
|
+
* @see {@link AlignmentConstraint} for alignment between two objects
|
|
13
37
|
*/
|
|
14
38
|
export class OffsetConstraint extends Behaviour {
|
|
15
39
|
|
|
@@ -60,12 +60,50 @@ declare module 'three/examples/jsm/controls/OrbitControls.js' {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
/**
|
|
64
|
+
* OrbitControls provides interactive camera control using three.js OrbitControls.
|
|
65
|
+
* Users can rotate, pan, and zoom the camera to explore 3D scenes.
|
|
66
|
+
*
|
|
67
|
+
* **Features:**
|
|
68
|
+
* - Rotation around a target point (orbit)
|
|
69
|
+
* - Panning to move the view
|
|
70
|
+
* - Zooming via scroll or pinch
|
|
71
|
+
* - Auto-rotation for showcases
|
|
72
|
+
* - Configurable angle and distance limits
|
|
73
|
+
* - Smooth damping for natural feel
|
|
74
|
+
*
|
|
75
|
+
* 
|
|
76
|
+
*
|
|
77
|
+
* **Access underlying controls:**
|
|
78
|
+
* - `controls` - The three.js OrbitControls instance
|
|
79
|
+
* - `controllerObject` - The object being controlled (usually the camera)
|
|
80
|
+
*
|
|
81
|
+
* **Debug options:**
|
|
82
|
+
* - `?debugorbit` - Log orbit control events
|
|
83
|
+
* - `?freecam` - Enable unrestricted camera movement
|
|
84
|
+
*
|
|
85
|
+
* @example Basic setup
|
|
86
|
+
* ```ts
|
|
87
|
+
* const orbitControls = camera.getComponent(OrbitControls);
|
|
88
|
+
* orbitControls.autoRotate = true;
|
|
89
|
+
* orbitControls.autoRotateSpeed = 2;
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @example Set look-at target
|
|
93
|
+
* ```ts
|
|
94
|
+
* orbitControls.setLookTargetPosition(new Vector3(0, 1, 0), true);
|
|
95
|
+
* // Or move both camera and target
|
|
96
|
+
* orbitControls.setCameraTargetPosition(new Vector3(5, 2, 5), new Vector3(0, 0, 0));
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
66
99
|
* @summary Camera controller using three.js OrbitControls
|
|
67
100
|
* @category Camera and Controls
|
|
68
101
|
* @group Components
|
|
102
|
+
* @see {@link LookAtConstraint} for setting the look-at target
|
|
103
|
+
* @see {@link SmoothFollow} for smooth camera following
|
|
104
|
+
* @see {@link Camera} for camera configuration
|
|
105
|
+
* @link https://threejs.org/docs/#examples/en/controls/OrbitControls
|
|
106
|
+
* @link https://engine.needle.tools/samples/panorama-controls alternative controls in samples
|
|
69
107
|
*/
|
|
70
108
|
export class OrbitControls extends Behaviour implements ICameraController {
|
|
71
109
|
|
|
@@ -15,13 +15,28 @@ const $reflectionProbeKey = Symbol("reflectionProbeKey");
|
|
|
15
15
|
const $originalMaterial = Symbol("original material");
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* ReflectionProbe provides environment reflection data to materials within its defined area.
|
|
19
|
+
* Use for chrome-like materials that need accurate environment reflections.
|
|
20
|
+
*
|
|
21
|
+
* **Setup:**
|
|
22
|
+
* 1. Add ReflectionProbe component to an object
|
|
23
|
+
* 2. Assign a cubemap or HDR texture
|
|
24
|
+
* 3. In Renderer components, assign the probe as anchor override
|
|
25
|
+
*
|
|
26
|
+
* **Note:** Volume-based automatic assignment is not fully supported yet.
|
|
27
|
+
* Objects (Renderer components) can explicitly reference their reflection probe.
|
|
28
|
+
*
|
|
29
|
+
* **Debug options:**
|
|
30
|
+
* - `?debugreflectionprobe` - Log probe info
|
|
31
|
+
* - `?noreflectionprobe` - Disable all reflection probes
|
|
32
|
+
*
|
|
33
|
+
* - Example: https://engine.needle.tools/samples/reflection-probes
|
|
34
|
+
*
|
|
22
35
|
* @summary Provides reflection data to materials
|
|
23
36
|
* @category Rendering
|
|
24
37
|
* @group Components
|
|
38
|
+
* @see {@link Renderer} for material and rendering control
|
|
39
|
+
* @see {@link Light} for scene lighting
|
|
25
40
|
*/
|
|
26
41
|
export class ReflectionProbe extends Behaviour {
|
|
27
42
|
|
|
@@ -45,7 +60,6 @@ export class ReflectionProbe extends Behaviour {
|
|
|
45
60
|
return probe;
|
|
46
61
|
}
|
|
47
62
|
}
|
|
48
|
-
// TODO not supported right now, as we'd have to pass the ReflectionProbe scale through as well.
|
|
49
63
|
else if (probe.isInBox(object)) {
|
|
50
64
|
if (debug) console.log("Found reflection probe", object.name, probe.name);
|
|
51
65
|
return probe;
|
|
@@ -137,7 +151,7 @@ export class ReflectionProbe extends Behaviour {
|
|
|
137
151
|
// and some need reflection probe and some don't
|
|
138
152
|
// we need to make sure we don't override the material but use a copy
|
|
139
153
|
|
|
140
|
-
private static _rendererMaterialsCache: Map<IRenderer, Array<{ material: Material, copy: Material }>> = new Map();
|
|
154
|
+
private static _rendererMaterialsCache: Map<IRenderer, Array<{ material: Material, copy: Material, originalVersion: number }>> = new Map();
|
|
141
155
|
|
|
142
156
|
onSet(_rend: IRenderer) {
|
|
143
157
|
if (disable) return;
|
|
@@ -171,15 +185,16 @@ export class ReflectionProbe extends Behaviour {
|
|
|
171
185
|
let cached = rendererCache[i];
|
|
172
186
|
|
|
173
187
|
// make sure we have the currently assigned material cached (and an up to date clone of that)
|
|
174
|
-
//
|
|
188
|
+
// Compare against the stored original version, not the clone's version (which gets modified by needsUpdate)
|
|
189
|
+
// This prevents cloning materials every frame when onUnset restores the original material
|
|
175
190
|
const isCachedInstance = material === cached?.copy;
|
|
176
|
-
const hasChanged = !cached || cached.material.uuid !== material.uuid || cached.
|
|
191
|
+
const hasChanged = !cached || cached.material.uuid !== material.uuid || cached.originalVersion !== material.version;
|
|
177
192
|
if (!isCachedInstance && hasChanged) {
|
|
178
193
|
if (debug) {
|
|
179
194
|
let reason = "";
|
|
180
195
|
if (!cached) reason = "not cached";
|
|
181
196
|
else if (cached.material !== material) reason = "reference changed; cached instance?: " + isCachedInstance;
|
|
182
|
-
else if (cached.
|
|
197
|
+
else if (cached.originalVersion !== material.version) reason = "version changed";
|
|
183
198
|
console.warn("Cloning material", material.name, material.version, "Reason:", reason, "\n", material.uuid, "\n", cached?.copy.uuid, "\n", _rend.name);
|
|
184
199
|
}
|
|
185
200
|
|
|
@@ -189,11 +204,13 @@ export class ReflectionProbe extends Behaviour {
|
|
|
189
204
|
if (cached) {
|
|
190
205
|
cached.copy = clone;
|
|
191
206
|
cached.material = material;
|
|
207
|
+
cached.originalVersion = material.version;
|
|
192
208
|
}
|
|
193
209
|
else {
|
|
194
210
|
cached = {
|
|
195
211
|
material: material,
|
|
196
|
-
copy: clone
|
|
212
|
+
copy: clone,
|
|
213
|
+
originalVersion: material.version
|
|
197
214
|
};
|
|
198
215
|
rendererCache.push(cached);
|
|
199
216
|
}
|
|
@@ -213,9 +230,10 @@ export class ReflectionProbe extends Behaviour {
|
|
|
213
230
|
const copy = cached?.copy;
|
|
214
231
|
|
|
215
232
|
if ("envMap" in copy) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
233
|
+
if (copy.envMap !== this.texture) { // Only update if changed
|
|
234
|
+
copy.envMap = this.texture;
|
|
235
|
+
copy.needsUpdate = true;
|
|
236
|
+
}
|
|
219
237
|
}
|
|
220
238
|
|
|
221
239
|
_rend.sharedMaterials[i] = copy;
|
|
@@ -200,8 +200,42 @@ class SharedMaterialArray implements ISharedMaterials {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
|
+
* Renderer controls rendering properties of meshes including materials,
|
|
204
|
+
* lightmaps, reflection probes, and GPU instancing.
|
|
205
|
+
*
|
|
206
|
+
* **Materials:**
|
|
207
|
+
* Access materials via `sharedMaterials` array. Changes affect all instances.
|
|
208
|
+
* Use material cloning for per-instance variations.
|
|
209
|
+
*
|
|
210
|
+
* **Instancing:**
|
|
211
|
+
* Enable GPU instancing for improved performance with many identical objects.
|
|
212
|
+
* Use `Renderer.setInstanced(obj, true)` or `enableInstancing` property.
|
|
213
|
+
*
|
|
214
|
+
* **Lightmaps:**
|
|
215
|
+
* Baked lighting is automatically applied when exported from Unity.
|
|
216
|
+
* Access via the associated {@link RendererLightmap} component.
|
|
217
|
+
*
|
|
218
|
+
* **Debug options:**
|
|
219
|
+
* - `?debugrenderer` - Log renderer info
|
|
220
|
+
* - `?wireframe` - Show wireframe rendering
|
|
221
|
+
* - `?noinstancing` - Disable GPU instancing
|
|
222
|
+
*
|
|
223
|
+
* @example Change material at runtime
|
|
224
|
+
* ```ts
|
|
225
|
+
* const renderer = myObject.getComponent(Renderer);
|
|
226
|
+
* renderer.sharedMaterials[0] = newMaterial;
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* @example Enable instancing
|
|
230
|
+
* ```ts
|
|
231
|
+
* Renderer.setInstanced(myObject, true);
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
203
234
|
* @category Rendering
|
|
204
235
|
* @group Components
|
|
236
|
+
* @see {@link ReflectionProbe} for environment reflections
|
|
237
|
+
* @see {@link Light} for scene lighting
|
|
238
|
+
* @see {@link LODGroup} for level of detail
|
|
205
239
|
*/
|
|
206
240
|
export class Renderer extends Behaviour implements IRenderer {
|
|
207
241
|
|
|
@@ -691,7 +725,6 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
691
725
|
}
|
|
692
726
|
|
|
693
727
|
if (this.reflectionProbeUsage !== ReflectionProbeUsage.Off && this._reflectionProbe) {
|
|
694
|
-
if (!this._lightmaps?.length) // Currently reflectionprobes cant be used with lightmaps
|
|
695
728
|
this._reflectionProbe.onSet(this);
|
|
696
729
|
}
|
|
697
730
|
// since three 163 we need to set the envMap to the scene envMap if it is not set
|
|
@@ -84,6 +84,13 @@ export interface ISceneEventListener {
|
|
|
84
84
|
* - [Needle Website](https://needle.tools)
|
|
85
85
|
* - [Songs Of Cultures](https://app.songsofcultures.com)
|
|
86
86
|
*
|
|
87
|
+
* 
|
|
88
|
+
* *Replace entire scenes with the SceneSwitcher.*
|
|
89
|
+
*
|
|
90
|
+
* 
|
|
91
|
+
* *Multiple SceneSwitcher components can be used at the same time and they can also be nested
|
|
92
|
+
* (a scene loaded by a SceneSwitcher can also have a SceneSwitcher to load sub-scenes).*
|
|
93
|
+
*
|
|
87
94
|
* ### Interfaces
|
|
88
95
|
* Use the {@link ISceneEventListener} interface to listen to scene open and closing events with the ability to modify transitions and stall the scene loading process.
|
|
89
96
|
*
|
|
@@ -111,6 +118,10 @@ export interface ISceneEventListener {
|
|
|
111
118
|
* @summary Dynamically loads and switches between multiple scenes
|
|
112
119
|
* @category Asset Management
|
|
113
120
|
* @group Components
|
|
121
|
+
* @see {@link ISceneEventListener} for scene transition callbacks
|
|
122
|
+
* @see {@link AssetReference} for loading individual assets
|
|
123
|
+
* @see {@link NestedGltf} for embedding static glTF content
|
|
124
|
+
* @link https://engine.needle.tools/docs/how-to-guides/components/scene-switcher.html
|
|
114
125
|
*/
|
|
115
126
|
export class SceneSwitcher extends Behaviour {
|
|
116
127
|
|
|
@@ -61,19 +61,51 @@ export declare type ScreenCaptureOptions = {
|
|
|
61
61
|
deviceFilter?: (device: MediaDeviceInfo) => boolean,
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
64
|
+
/**
|
|
65
|
+
* ScreenCapture enables sharing screen, camera, or microphone with users in a networked room.
|
|
66
|
+
* The stream is displayed via a {@link VideoPlayer} component on the same GameObject.
|
|
67
|
+
*
|
|
68
|
+
* **Supported capture devices:**
|
|
69
|
+
* - `Screen` - Share desktop/window/tab
|
|
70
|
+
* - `Camera` - Share webcam feed
|
|
71
|
+
* - `Microphone` - Audio only
|
|
72
|
+
* - `Canvas` - Share the 3D canvas (experimental)
|
|
72
73
|
*
|
|
74
|
+
* 
|
|
75
|
+
*
|
|
76
|
+
* **How it works:**
|
|
77
|
+
* - Click the object to start/stop sharing (if `allowStartOnClick` is true)
|
|
78
|
+
* - Or call `share()` / `close()` programmatically
|
|
79
|
+
* - Stream is sent to all users in the same room via WebRTC
|
|
80
|
+
* - Receiving clients see the video on their VideoPlayer
|
|
81
|
+
*
|
|
82
|
+
* **Debug:** Append `?debugscreensharing` to the URL for console logging.
|
|
83
|
+
*
|
|
84
|
+
* @example Start screen sharing programmatically
|
|
85
|
+
* ```ts
|
|
86
|
+
* const capture = myScreen.getComponent(ScreenCapture);
|
|
87
|
+
* await capture?.share({ device: "Screen" });
|
|
88
|
+
*
|
|
89
|
+
* // Later, stop sharing
|
|
90
|
+
* capture?.close();
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example Share webcam with constraints
|
|
94
|
+
* ```ts
|
|
95
|
+
* await capture?.share({
|
|
96
|
+
* device: "Camera",
|
|
97
|
+
* constraints: { width: 1280, height: 720 }
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
73
101
|
* @summary Share screen, camera or microphone in a networked room
|
|
74
102
|
* @category Networking
|
|
75
103
|
* @group Components
|
|
76
|
-
|
|
104
|
+
* @see {@link VideoPlayer} for displaying the received stream
|
|
105
|
+
* @see {@link Voip} for voice-only communication
|
|
106
|
+
* @see {@link SyncedRoom} for room management
|
|
107
|
+
* @link https://engine.needle.tools/docs/networking.html
|
|
108
|
+
*/
|
|
77
109
|
export class ScreenCapture extends Behaviour implements IPointerClickHandler {
|
|
78
110
|
|
|
79
111
|
/**
|
|
@@ -443,7 +443,7 @@ function tryParseMagicSkyboxName(str: string | null | undefined, environment: bo
|
|
|
443
443
|
return useLowRes ? value.url_low : value.url;
|
|
444
444
|
}
|
|
445
445
|
else if (typeof str === "string" && str?.length && (isDevEnvironment() || debug)) {
|
|
446
|
-
const noUrlOrFile = !str.startsWith("http") && !str.startsWith("file:") && !str.startsWith("blob:") && !str.startsWith("data:")
|
|
446
|
+
const noUrlOrFile = !str.startsWith("http") && !str.startsWith("file:") && !str.startsWith("blob:") && !str.startsWith("data:") && !str.startsWith("/")
|
|
447
447
|
if(noUrlOrFile) {
|
|
448
448
|
console.warn(`RemoteSkybox: Unknown magic skybox name "${str}". Valid names are: ${Object.keys(MagicSkyboxNames).map(n => `"${n}"`).join(", ")}`);
|
|
449
449
|
}
|
|
@@ -6,12 +6,57 @@ import { serializable } from "../engine/engine_serialization_decorator.js";
|
|
|
6
6
|
import { getWorldPosition, getWorldQuaternion } from "../engine/engine_three_utils.js";
|
|
7
7
|
import { Behaviour } from "./Component.js";
|
|
8
8
|
|
|
9
|
+
import type { LookAt } from "./api.js";
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
|
-
* SmoothFollow makes
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* SmoothFollow makes this GameObject smoothly follow another target object's position and/or rotation.
|
|
13
|
+
*
|
|
14
|
+
* **Position Following:**
|
|
15
|
+
* When enabled (`followFactor > 0`), this object will move towards the target's world position.
|
|
16
|
+
* The object interpolates from its current position to the target's position each frame.
|
|
17
|
+
* Use `positionAxes` to restrict following to specific axes (e.g., only horizontal movement).
|
|
18
|
+
*
|
|
19
|
+
* **Rotation Following:**
|
|
20
|
+
* When enabled (`rotateFactor > 0`), this object will rotate to match the target's world rotation.
|
|
21
|
+
* The object smoothly interpolates from its current rotation to the target's rotation each frame.
|
|
22
|
+
* This makes the object face the same direction as the target, not look at it (use {@link LookAt} for that).
|
|
23
|
+
*
|
|
24
|
+
* **Smoothing:**
|
|
25
|
+
* Both position and rotation use time-based interpolation (lerp/slerp).
|
|
26
|
+
* Higher factor values = faster following (less lag), lower values = slower following (more lag).
|
|
27
|
+
* Set a factor to 0 to disable that type of following entirely.
|
|
28
|
+
*
|
|
29
|
+
* **Common Use Cases:**
|
|
30
|
+
* - Camera following a player character
|
|
31
|
+
* - UI elements tracking world objects
|
|
32
|
+
* - Delayed motion effects (ghost trails, spring arms)
|
|
33
|
+
* - Smoothed object attachment
|
|
34
|
+
*
|
|
35
|
+
* @example Follow a target with smooth position
|
|
36
|
+
* ```ts
|
|
37
|
+
* const follower = myObject.addComponent(SmoothFollow);
|
|
38
|
+
* follower.target = playerObject;
|
|
39
|
+
* follower.followFactor = 5; // Higher = faster following
|
|
40
|
+
* follower.rotateFactor = 0; // Don't follow rotation
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example Follow only on horizontal plane
|
|
44
|
+
* ```ts
|
|
45
|
+
* follower.positionAxes = Axes.X | Axes.Z; // Follow X and Z only (no vertical)
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example Follow both position and rotation
|
|
49
|
+
* ```ts
|
|
50
|
+
* follower.target = targetObject;
|
|
51
|
+
* follower.followFactor = 3; // Smooth position following
|
|
52
|
+
* follower.rotateFactor = 2; // Smooth rotation following
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @summary Smoothly follows a target object's position and/or rotation
|
|
13
56
|
* @category Interactivity
|
|
14
57
|
* @group Components
|
|
58
|
+
* @see {@link LookAtConstraint} for making an object look at a target (different from rotation following)
|
|
59
|
+
* @see {@link Mathf} for the interpolation used
|
|
15
60
|
*/
|
|
16
61
|
export class SmoothFollow extends Behaviour {
|
|
17
62
|
|
|
@@ -22,21 +67,34 @@ export class SmoothFollow extends Behaviour {
|
|
|
22
67
|
target: Object3D | null = null;
|
|
23
68
|
|
|
24
69
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
70
|
+
* Speed factor for position following.
|
|
71
|
+
* Controls how quickly this object moves to match the target's position.
|
|
72
|
+
* Higher values = faster/tighter following (less lag), lower = slower/looser (more lag).
|
|
73
|
+
* Set to 0 to disable position following entirely.
|
|
74
|
+
* @default 0.1
|
|
27
75
|
*/
|
|
28
76
|
@serializable()
|
|
29
77
|
followFactor = .1;
|
|
78
|
+
|
|
30
79
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
80
|
+
* Speed factor for rotation following.
|
|
81
|
+
* Controls how quickly this object rotates to match the target's rotation.
|
|
82
|
+
* Higher values = faster/tighter following (less lag), lower = slower/looser (more lag).
|
|
83
|
+
* Set to 0 to disable rotation following entirely.
|
|
84
|
+
* @default 0.1
|
|
33
85
|
*/
|
|
34
86
|
@serializable()
|
|
35
87
|
rotateFactor = .1;
|
|
36
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Which position axes to follow. Use bitwise OR to combine:
|
|
91
|
+
* `Axes.X | Axes.Y` follows only X and Y axes.
|
|
92
|
+
* @default Axes.All
|
|
93
|
+
*/
|
|
37
94
|
@serializable()
|
|
38
95
|
positionAxes: Axes = Axes.All;
|
|
39
96
|
|
|
97
|
+
/** When true, rotates 180° around Y axis (useful for mirrored setups) */
|
|
40
98
|
flipForward: boolean = false;
|
|
41
99
|
|
|
42
100
|
private static _invertForward: Quaternion = new Quaternion().setFromAxisAngle(new Vector3(0, 1, 0), Math.PI);
|
|
@@ -49,6 +107,10 @@ export class SmoothFollow extends Behaviour {
|
|
|
49
107
|
this.updateNow(false);
|
|
50
108
|
}
|
|
51
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Manually update the position/rotation to follow the target.
|
|
112
|
+
* @param hard If true, snaps instantly to target without smoothing
|
|
113
|
+
*/
|
|
52
114
|
updateNow(hard: boolean) {
|
|
53
115
|
if (!this.target || this.target === this.gameObject) return;
|
|
54
116
|
if (this.followFactor > 0) {
|
|
@@ -24,11 +24,34 @@ function testMask(mask1, mask2) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Component that receives and responds to spatial events, like entering or exiting a trigger zone.
|
|
28
|
-
* Used in conjunction with {@link SpatialTrigger} to create interactive spatial events.
|
|
27
|
+
* Component that receives and responds to spatial events, like entering or exiting a trigger zone.
|
|
28
|
+
* Used in conjunction with {@link SpatialTrigger} to create interactive spatial events.
|
|
29
|
+
*
|
|
30
|
+
* Place this on objects that should react when entering trigger zones. The receiver checks
|
|
31
|
+
* against all active SpatialTriggers each frame and fires events when intersections change.
|
|
32
|
+
*
|
|
33
|
+
* Events can be connected via {@link EventList} in the editor or listened to in code.
|
|
34
|
+
*
|
|
35
|
+
* @example Listen to trigger events
|
|
36
|
+
* ```ts
|
|
37
|
+
* export class DoorTrigger extends Behaviour {
|
|
38
|
+
* @serializable(SpatialTriggerReceiver)
|
|
39
|
+
* receiver?: SpatialTriggerReceiver;
|
|
40
|
+
*
|
|
41
|
+
* start() {
|
|
42
|
+
* this.receiver?.onEnter?.addEventListener(() => {
|
|
43
|
+
* console.log("Player entered door zone");
|
|
44
|
+
* });
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
29
49
|
* @summary Receives spatial trigger events
|
|
30
50
|
* @category Interactivity
|
|
31
51
|
* @group Components
|
|
52
|
+
* @see {@link SpatialTrigger} for defining trigger zones
|
|
53
|
+
* @see {@link EventList} for event handling
|
|
54
|
+
* @link https://engine.needle.tools/samples/spatial-triggers/
|
|
32
55
|
*/
|
|
33
56
|
export class SpatialTriggerReceiver extends Behaviour {
|
|
34
57
|
|
|
@@ -126,10 +149,34 @@ export class SpatialTriggerReceiver extends Behaviour {
|
|
|
126
149
|
}
|
|
127
150
|
|
|
128
151
|
/**
|
|
129
|
-
* A spatial trigger component that detects objects within a box-shaped area.
|
|
130
|
-
* Used to trigger events when objects enter, stay in, or exit the defined area
|
|
152
|
+
* A spatial trigger component that detects objects within a box-shaped area.
|
|
153
|
+
* Used to trigger events when objects enter, stay in, or exit the defined area.
|
|
154
|
+
*
|
|
155
|
+
* The trigger area is defined by the GameObject's bounding box (uses {@link BoxHelperComponent}).
|
|
156
|
+
* Objects with {@link SpatialTriggerReceiver} components are tested against this area.
|
|
157
|
+
*
|
|
158
|
+
* **Mask system:** Both trigger and receiver have a `triggerMask` - they only interact
|
|
159
|
+
* when their masks have overlapping bits set. This allows selective triggering.
|
|
160
|
+
*
|
|
161
|
+
* **Debug:** Use `?debugspatialtrigger` URL parameter to visualize trigger zones.
|
|
162
|
+
*
|
|
163
|
+
* @example Create a pickup zone
|
|
164
|
+
* ```ts
|
|
165
|
+
* // On the pickup zone object
|
|
166
|
+
* const trigger = pickupZone.addComponent(SpatialTrigger);
|
|
167
|
+
* trigger.triggerMask = 1; // Layer 1 for pickups
|
|
168
|
+
*
|
|
169
|
+
* // On the player
|
|
170
|
+
* const receiver = player.addComponent(SpatialTriggerReceiver);
|
|
171
|
+
* receiver.triggerMask = 1; // Match the pickup layer
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @summary Define a trigger zone that detects entering objects
|
|
131
175
|
* @category Interactivity
|
|
132
176
|
* @group Components
|
|
177
|
+
* @see {@link SpatialTriggerReceiver} for objects that respond to triggers
|
|
178
|
+
* @see {@link BoxHelperComponent} for the underlying box used to define the trigger area
|
|
179
|
+
* @link https://engine.needle.tools/samples/spatial-triggers/
|
|
133
180
|
*/
|
|
134
181
|
export class SpatialTrigger extends Behaviour {
|
|
135
182
|
|
|
@@ -31,14 +31,32 @@ export enum SpectatorMode {
|
|
|
31
31
|
const debug = getParam("debugspectator");
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
34
|
+
* SpectatorCamera enables following and spectating other users in networked sessions.
|
|
35
|
+
* Switch between first-person (see what they see) and third-person (orbit around them) views.
|
|
36
|
+
*
|
|
37
|
+
* **Keyboard controls** (when `useKeys = true`):
|
|
38
|
+
* - `F` - Request all users to follow the local player
|
|
39
|
+
* - `ESC` - Stop spectating
|
|
40
|
+
*
|
|
41
|
+
* **Spectator modes:**
|
|
42
|
+
* - `FirstPerson` - View from the followed player's perspective
|
|
43
|
+
* - `ThirdPerson` - Freely orbit around the followed player
|
|
44
|
+
*
|
|
45
|
+
* **Debug:** Use `?debugspectator` URL parameter for logging.
|
|
46
|
+
*
|
|
47
|
+
* @example Start spectating a user
|
|
48
|
+
* ```ts
|
|
49
|
+
* const spectator = camera.getComponent(SpectatorCamera);
|
|
50
|
+
* spectator.follow(targetUserId);
|
|
51
|
+
* spectator.mode = SpectatorMode.ThirdPerson;
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
39
54
|
* @summary Spectator camera for following other users
|
|
40
55
|
* @category Networking
|
|
41
56
|
* @group Components
|
|
57
|
+
* @see {@link SpectatorMode} for view options
|
|
58
|
+
* @see {@link SyncedRoom} for networked sessions
|
|
59
|
+
* @see {@link OrbitControls} for third-person orbit
|
|
42
60
|
*/
|
|
43
61
|
export class SpectatorCamera extends Behaviour {
|
|
44
62
|
|
|
@@ -33,9 +33,15 @@ const debug = utils.getParam("debugsyncedroom");
|
|
|
33
33
|
* myObject.addComponent(SyncedRoom, { joinRandomRoom: true, roomPrefix: "myApp_" });
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
|
+
* **Debug:** Use `?debugsyncedroom` URL parameter for logging.
|
|
37
|
+
*
|
|
36
38
|
* @summary Joins a networked room based on URL parameters or a random room
|
|
37
39
|
* @category Networking
|
|
38
40
|
* @group Components
|
|
41
|
+
* @see {@link SyncedTransform} for synchronizing object transforms
|
|
42
|
+
* @see {@link Voip} for voice communication in rooms
|
|
43
|
+
* @see {@link ScreenCapture} for screen/video sharing
|
|
44
|
+
* @link https://engine.needle.tools/docs/networking.html
|
|
39
45
|
*/
|
|
40
46
|
export class SyncedRoom extends Behaviour {
|
|
41
47
|
|