@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
|
@@ -111,11 +111,27 @@ export function getUrlParams() {
|
|
|
111
111
|
// bit strange that we have to pass T in here as well but otherwise the type parameter is stripped it seems
|
|
112
112
|
type Param<T extends string> = string | boolean | number | T;
|
|
113
113
|
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
114
|
+
/**
|
|
115
|
+
* Checks if a URL parameter exists and returns its value.
|
|
116
|
+
* Useful for debugging, feature flags, and configuration.
|
|
117
|
+
*
|
|
118
|
+
* @param paramName The URL parameter name to check
|
|
119
|
+
* @returns
|
|
120
|
+
* - `true` if the parameter exists without a value (e.g. `?debug`)
|
|
121
|
+
* - `false` if the parameter doesn't exist or is set to `0`
|
|
122
|
+
* - The numeric value if it's a number (e.g. `?level=5` returns `5`)
|
|
123
|
+
* - The string value otherwise (e.g. `?name=test` returns `"test"`)
|
|
124
|
+
*
|
|
125
|
+
* @example Check debug mode
|
|
126
|
+
* ```ts
|
|
127
|
+
* if (getParam("debug")) {
|
|
128
|
+
* console.log("Debug mode enabled");
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
* @example Get a numeric value
|
|
132
|
+
* ```ts
|
|
133
|
+
* const level = getParam("level"); // Returns number if ?level=5
|
|
134
|
+
* ```
|
|
119
135
|
*/
|
|
120
136
|
export function getParam<T extends string>(paramName: T): Param<T> {
|
|
121
137
|
if (showHelp && !requestedParams.includes(paramName))
|
|
@@ -16,7 +16,8 @@ export type NeedleMimetype = "unknown" | "unsupported" |
|
|
|
16
16
|
"model/vnd.usdc" |
|
|
17
17
|
"model/fbx" |
|
|
18
18
|
"model/vnd.autodesk.fbx" |
|
|
19
|
-
"model/obj"
|
|
19
|
+
"model/obj" |
|
|
20
|
+
"application/materialx+xml"
|
|
20
21
|
| (string & {})
|
|
21
22
|
|
|
22
23
|
|
|
@@ -95,6 +96,8 @@ export async function tryDetermineMimetypeFromURL(url: string, opts: { useExtens
|
|
|
95
96
|
return "model/vnd.usdz+zip";
|
|
96
97
|
case "OBJ":
|
|
97
98
|
return "model/obj";
|
|
99
|
+
case "MTLX":
|
|
100
|
+
return "application/materialx+xml";
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
|
|
@@ -222,6 +225,7 @@ export function tryDetermineMimetypeFromBinary(url: string, data: ArrayBuffer, r
|
|
|
222
225
|
case "model/fbx":
|
|
223
226
|
case "model/vnd.autodesk.fbx":
|
|
224
227
|
case "model/obj":
|
|
228
|
+
case "application/materialx+xml":
|
|
225
229
|
return content_type;
|
|
226
230
|
// case "model/stl":
|
|
227
231
|
// return "stl";
|
|
@@ -271,7 +275,7 @@ export function tryDetermineMimetypeFromBinary(url: string, data: ArrayBuffer, r
|
|
|
271
275
|
|
|
272
276
|
if (isDevEnvironment() || debug) {
|
|
273
277
|
const text = new TextDecoder().decode(data.slice(0, Math.min(data.byteLength, 32)));
|
|
274
|
-
console.warn(`Could not determine file type.\n\nConsider registering a custom loader via the 'onCreateCustomModelLoader' callback: 'NeedleEngineModelLoader.onCreateCustomModelLoader(args => { })'\n\nContent-Type: \"${response.headers.get("content-type")}\n\"Text: \"${text}\"\nBinary:`, bytes);
|
|
278
|
+
console.warn(`Could not determine file type.\n\nConsider registering a custom loader via the 'onCreateCustomModelLoader' callback: 'NeedleEngineModelLoader.onCreateCustomModelLoader(args => { })'\n\nContent-Type: \"${response.headers.get("content-type")}\"\n\"Text: \"${text}\"\nBinary:`, bytes);
|
|
275
279
|
}
|
|
276
280
|
else {
|
|
277
281
|
console.debug(`Could not determine file type from binary data`);
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Loader, LoadingManager, Material, Object3D, TextureLoader } from "three";
|
|
2
|
+
import { GLTFLoader, GLTFLoaderPlugin, GLTFParser } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
3
|
+
|
|
4
|
+
import { ObjectUtils } from "../engine_create_objects.js";
|
|
5
|
+
import { MODULES } from "../engine_modules.js";
|
|
6
|
+
import { IContext } from "../engine_types.js";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// #region Utils
|
|
10
|
+
|
|
11
|
+
export namespace MaterialX {
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Utility function to load a MaterialX material from a URL. This can be used in your own code to load MaterialX materials outside of the glTF loading process. The URL should point to a MaterialX XML file.
|
|
16
|
+
*/
|
|
17
|
+
export async function loadFromUrl(urlOrXML: string,
|
|
18
|
+
opts?: {
|
|
19
|
+
url?: string,
|
|
20
|
+
loadingManager?: LoadingManager,
|
|
21
|
+
materialNameOrIndex?: number | string
|
|
22
|
+
}
|
|
23
|
+
): Promise<import("three").Material | null> {
|
|
24
|
+
|
|
25
|
+
if (!urlOrXML) throw new Error("URL or XML string is required to load a MaterialX material");
|
|
26
|
+
|
|
27
|
+
// Ensure the MaterialX module is loaded
|
|
28
|
+
const module = await MODULES.MaterialX.load();
|
|
29
|
+
|
|
30
|
+
// Check if the input is an XML string or a URL
|
|
31
|
+
// And fetch the XML content if it's a URL
|
|
32
|
+
const isXmlString = urlOrXML.trimStart().startsWith("<");
|
|
33
|
+
const xml = isXmlString ? urlOrXML : await fetch(urlOrXML).then(r => r.text()).catch(console.error);
|
|
34
|
+
if (!xml) {
|
|
35
|
+
console.warn("Failed to load MaterialX file from url", urlOrXML);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// For relative texture paths we might need to detect the base directory of the material file.
|
|
40
|
+
// We can only do this if we have a URL (not an XML string) and if the URL is not a data URL. In that case we can use the URL to determine the base path for textures.
|
|
41
|
+
// This can be used by the loader callback to resolve texture paths relative to the material file.
|
|
42
|
+
let dir: string | undefined = undefined;
|
|
43
|
+
if (opts?.url || !isXmlString) {
|
|
44
|
+
const parts = (opts?.url || urlOrXML).split('/');
|
|
45
|
+
parts.pop();
|
|
46
|
+
dir = parts.join('/');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const textureLoader = new TextureLoader();
|
|
50
|
+
return module.Experimental_API.createMaterialXMaterial(xml, opts?.materialNameOrIndex ?? 0, {
|
|
51
|
+
getTexture: async url => {
|
|
52
|
+
if (!url.startsWith("http") && !url.startsWith("data:") && !url.startsWith("blob:") && !url.startsWith("file:")) {
|
|
53
|
+
if (dir) {
|
|
54
|
+
url = dir + "/" + url;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return textureLoader.loadAsync(url).catch(e => {
|
|
58
|
+
console.warn(`Failed to load texture for MaterialX material ${url}`, e);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
cacheKey: urlOrXML,
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// #region Loader
|
|
69
|
+
|
|
70
|
+
export class MaterialXLoader extends Loader<Object3D | null> {
|
|
71
|
+
|
|
72
|
+
loadAsync(url: string, onProgress?: ((event: ProgressEvent<EventTarget>) => void) | undefined): Promise<Object3D> {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
this.load(url, resolve, onProgress, reject);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
load(url: string, onLoad: (data: Object3D) => void, onProgress?: ((event: ProgressEvent<EventTarget>) => void) | undefined, onError?: ((err: unknown) => void) | undefined): void {
|
|
79
|
+
onProgress?.({ type: "progress", loaded: 0, total: 0 } as ProgressEvent);
|
|
80
|
+
|
|
81
|
+
MaterialX.loadFromUrl(url, {
|
|
82
|
+
}).then(mat => {
|
|
83
|
+
if (mat) {
|
|
84
|
+
onLoad(this.onLoaded(mat));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
onError?.(new Error("Failed to load MaterialX material from url: " + url));
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private onLoaded(mat: Material): Object3D {
|
|
93
|
+
const shaderball = ObjectUtils.createPrimitive("ShaderBall", { material: mat });
|
|
94
|
+
return shaderball;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
// #region GLTF Extension
|
|
101
|
+
|
|
102
|
+
export class NEEDLE_materialx implements GLTFLoaderPlugin {
|
|
103
|
+
|
|
104
|
+
get name(): string {
|
|
105
|
+
return "materialx-loading-helper";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
constructor(
|
|
109
|
+
private readonly context: IContext,
|
|
110
|
+
private readonly loader: GLTFLoader,
|
|
111
|
+
private readonly url: string,
|
|
112
|
+
private readonly parser: GLTFParser,
|
|
113
|
+
) {
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private mtlxLoader?: import("@needle-tools/materialx").MaterialXLoader;
|
|
117
|
+
|
|
118
|
+
async beforeRoot() {
|
|
119
|
+
const mtlxExtension = this.parser.json.extensions?.["NEEDLE_materials_mtlx"];
|
|
120
|
+
if (mtlxExtension) {
|
|
121
|
+
const module = await MODULES.MaterialX.load();
|
|
122
|
+
try {
|
|
123
|
+
this.mtlxLoader = new module.MaterialXLoader(this.parser, {
|
|
124
|
+
cacheKey: `${this.url}:materialx`,
|
|
125
|
+
parameters: {
|
|
126
|
+
precision: this.context.renderer?.capabilities.precision as any,
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
getFrame: () => this.context.time.frame,
|
|
130
|
+
getTime: () => this.context.time.time,
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
console.error(error);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
loadMaterial(index) {
|
|
140
|
+
if (this.mtlxLoader) return this.mtlxLoader.loadMaterial(index);
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -12,6 +12,7 @@ import { EXT_texture_exr } from "./EXT_texture_exr.js";
|
|
|
12
12
|
import { NEEDLE_components } from "./NEEDLE_components.js";
|
|
13
13
|
import { NEEDLE_gameobject_data } from "./NEEDLE_gameobject_data.js";
|
|
14
14
|
import { NEEDLE_lighting_settings } from "./NEEDLE_lighting_settings.js";
|
|
15
|
+
import { NEEDLE_materialx } from "./NEEDLE_materialx.js";
|
|
15
16
|
import { NEEDLE_persistent_assets } from "./NEEDLE_persistent_assets.js";
|
|
16
17
|
import { NEEDLE_progressive } from "./NEEDLE_progressive.js";
|
|
17
18
|
import { NEEDLE_render_objects } from "./NEEDLE_render_objects.js";
|
|
@@ -136,6 +137,7 @@ export async function registerExtensions(loader: GLTFLoader, context: Context, u
|
|
|
136
137
|
loader.register(p => new NEEDLE_render_objects(p, sourceId));
|
|
137
138
|
loader.register(p => new NEEDLE_progressive(p));
|
|
138
139
|
loader.register(p => new EXT_texture_exr(p));
|
|
140
|
+
loader.register(p => new NEEDLE_materialx(context, loader, url, p));
|
|
139
141
|
if (isResourceTrackingEnabled()) loader.register(p => new InternalUsageTrackerPlugin(p))
|
|
140
142
|
|
|
141
143
|
await KHR_ANIMATIONPOINTER_IMPORT.catch(_ => { })
|
|
@@ -2,5 +2,6 @@ export { compareAssociation } from "./extension_utils.js"
|
|
|
2
2
|
export * from "./extensions.js"
|
|
3
3
|
export * from "./NEEDLE_animator_controller_model.js"
|
|
4
4
|
export { SceneLightSettings } from "./NEEDLE_lighting_settings.js"
|
|
5
|
+
export { MaterialX } from "./NEEDLE_materialx.js"
|
|
5
6
|
export * from "./NEEDLE_progressive.js"
|
|
6
7
|
export { CustomShader } from "./NEEDLE_techniques_webgl.js"
|
|
@@ -5,12 +5,32 @@ import * as utils from "./../engine/engine_three_utils.js";
|
|
|
5
5
|
import { Behaviour, GameObject } from "./Component.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* AlignmentConstraint positions and scales this GameObject to span between two target objects.
|
|
9
|
+
* The object is rotated to face `to` and scaled along Z to match the distance.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* **Use cases:**
|
|
12
|
+
* - Dynamic beams or laser effects between objects
|
|
13
|
+
* - Stretchy connectors or ropes
|
|
14
|
+
* - Visual links between UI elements
|
|
15
|
+
* - Debug lines between transforms
|
|
16
|
+
*
|
|
17
|
+
* **How it works:**
|
|
18
|
+
* - Position: Centered between `from` and `to` (or at `from` if not centered)
|
|
19
|
+
* - Rotation: Looks at `to` from `from`
|
|
20
|
+
* - Scale: Z-axis scales to match distance, X/Y use `width`
|
|
21
|
+
*
|
|
22
|
+
* @example Create a beam between two objects
|
|
23
|
+
* ```ts
|
|
24
|
+
* const beam = beamMesh.addComponent(AlignmentConstraint);
|
|
25
|
+
* // Set targets via serialized properties in editor
|
|
26
|
+
* // or via code if properties are exposed
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @summary Aligns and scales object between two targets
|
|
12
30
|
* @category Constraints
|
|
13
|
-
* @group Components
|
|
31
|
+
* @group Components
|
|
32
|
+
* @see {@link LookAtConstraint} for rotation-only constraints
|
|
33
|
+
* @see {@link SmoothFollow} for following with smoothing
|
|
14
34
|
**/
|
|
15
35
|
export class AlignmentConstraint extends Behaviour {
|
|
16
36
|
|
|
@@ -10,6 +10,12 @@ import { Behaviour } from "./Component.js";
|
|
|
10
10
|
|
|
11
11
|
const debug = getParam("debuganimation");
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Options for controlling animation playback via {@link Animation.play}.
|
|
15
|
+
* All options are optional - defaults are sensible for most use cases.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link Animation} for the component that uses these options
|
|
18
|
+
*/
|
|
13
19
|
export declare type PlayOptions = {
|
|
14
20
|
/**
|
|
15
21
|
* The fade duration in seconds for the action to fade in and other actions to fade out (if exclusive is enabled)
|
|
@@ -59,11 +65,47 @@ declare type AnimationIdentifier = AnimationClip | number | string | undefined;
|
|
|
59
65
|
class Vec2 { x!: number; y!: number }
|
|
60
66
|
|
|
61
67
|
/**
|
|
62
|
-
* Animation component to play animations on a GameObject.
|
|
68
|
+
* Animation component to play animations on a GameObject.
|
|
69
|
+
* For simpler animation needs compared to {@link Animator}, this component directly
|
|
70
|
+
* plays AnimationClips without state machine logic.
|
|
71
|
+
*
|
|
72
|
+
* **Key features:**
|
|
73
|
+
* - Play animations by index, name, or clip reference
|
|
74
|
+
* - Cross-fade between animations with `fadeDuration`
|
|
75
|
+
* - Loop or play once with optional clamping
|
|
76
|
+
* - Random start time and speed variation
|
|
77
|
+
* - Promise-based completion handling
|
|
78
|
+
*
|
|
63
79
|
*
|
|
64
|
-
*
|
|
80
|
+
* 
|
|
81
|
+
*
|
|
82
|
+
* @example Play animation by name
|
|
83
|
+
* ```ts
|
|
84
|
+
* const anim = this.gameObject.getComponent(Animation);
|
|
85
|
+
* await anim?.play("Walk", { loop: true, fadeDuration: 0.3 });
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example Play with options
|
|
89
|
+
* ```ts
|
|
90
|
+
* anim?.play(0, {
|
|
91
|
+
* loop: false,
|
|
92
|
+
* clampWhenFinished: true,
|
|
93
|
+
* speed: 2
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @summary Plays animations from AnimationClips
|
|
65
98
|
* @category Animation and Sequencing
|
|
66
99
|
* @group Components
|
|
100
|
+
* @see {@link Animator} for state machine-based animation
|
|
101
|
+
* @see {@link PlayOptions} for all playback options
|
|
102
|
+
* @link https://engine.needle.tools/samples/?overlay=samples&tag=animation
|
|
103
|
+
* @link https://engine.needle.tools/samples/imunogard/
|
|
104
|
+
*
|
|
105
|
+
* @link https://engine.needle.tools/docs/blender/animation.html
|
|
106
|
+
*
|
|
107
|
+
* 
|
|
108
|
+
*
|
|
67
109
|
*/
|
|
68
110
|
export class Animation extends Behaviour implements IAnimationComponent {
|
|
69
111
|
|
|
@@ -12,7 +12,7 @@ import { Behaviour } from "./Component.js";
|
|
|
12
12
|
const debug = getParam("debuganimator");
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Represents an event emitted by an animation mixer
|
|
15
|
+
* Represents an event emitted by an animation mixer
|
|
16
16
|
* @category Animation and Sequencing
|
|
17
17
|
* @group Components
|
|
18
18
|
*/
|
|
@@ -28,7 +28,7 @@ export declare class MixerEvent {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Configuration options for playing animations
|
|
31
|
+
* Configuration options for playing animations
|
|
32
32
|
* @category Animation and Sequencing
|
|
33
33
|
*/
|
|
34
34
|
export declare class PlayOptions {
|
|
@@ -38,15 +38,48 @@ export declare class PlayOptions {
|
|
|
38
38
|
clampWhenFinished?: boolean;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
41
|
+
/**
|
|
42
|
+
* Animator plays and manages state-machine based animations on a GameObject.
|
|
43
|
+
* Uses an {@link AnimatorController} for state transitions, blending, and parameters.
|
|
44
|
+
*
|
|
45
|
+
* **State machine animations:**
|
|
46
|
+
* Define animation states and transitions in Unity's Animator window or in [Blender's Animator Controller editor](https://engine.needle.tools/docs/blender/animation.html)
|
|
47
|
+
* Control transitions via parameters (bool, int, float, trigger).
|
|
45
48
|
*
|
|
49
|
+
* 
|
|
50
|
+
*
|
|
51
|
+
* **Creating at runtime:**
|
|
52
|
+
* Use `AnimatorController.createFromClips()` to create controllers from code.
|
|
53
|
+
*
|
|
54
|
+
* **Parameters:**
|
|
55
|
+
* - `setTrigger(name)` - Trigger a one-shot transition
|
|
56
|
+
* - `setBool(name, value)` - Set boolean parameter
|
|
57
|
+
* - `setFloat(name, value)` - Set float parameter
|
|
58
|
+
* - `setInteger(name, value)` - Set integer parameter
|
|
59
|
+
*
|
|
60
|
+
* @example Trigger animation state
|
|
61
|
+
* ```ts
|
|
62
|
+
* const animator = myCharacter.getComponent(Animator);
|
|
63
|
+
* animator.setTrigger("Jump");
|
|
64
|
+
* animator.setFloat("Speed", 5);
|
|
65
|
+
* animator.setBool("IsRunning", true);
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example Listen to animation events
|
|
69
|
+
* ```ts
|
|
70
|
+
* animator.onLoop(evt => console.log("Animation looped"));
|
|
71
|
+
* animator.onFinished(evt => console.log("Animation finished"));
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
46
74
|
* @summary Plays and manages animations on a GameObject based on an AnimatorController
|
|
47
75
|
* @category Animation and Sequencing
|
|
48
76
|
* @group Components
|
|
49
|
-
|
|
77
|
+
* @see {@link AnimatorController} for state machine configuration
|
|
78
|
+
* @see {@link Animation} for simple clip playback
|
|
79
|
+
* @see {@link PlayableDirector} for timeline-based animation
|
|
80
|
+
*
|
|
81
|
+
* @link https://engine.needle.tools/docs/blender/animation.html
|
|
82
|
+
*/
|
|
50
83
|
export class Animator extends Behaviour implements IAnimationComponent {
|
|
51
84
|
|
|
52
85
|
/**
|
|
@@ -37,24 +37,46 @@ export enum AudioRolloffMode {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* Plays audio clips in the scene
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
40
|
+
/**
|
|
41
|
+
* Plays audio clips in the scene with support for spatial (3D) positioning.
|
|
42
|
+
*
|
|
43
|
+
* **Browser autoplay policies:**
|
|
44
|
+
* Web browsers require user interaction before playing audio. Use
|
|
45
|
+
* `AudioSource.userInteractionRegistered` to check if playback is allowed,
|
|
46
|
+
* or `registerWaitForAllowAudio()` to queue playback until interaction occurs.
|
|
47
|
+
*
|
|
48
|
+
* **Spatial audio:**
|
|
49
|
+
* Set `spatialBlend` to 1 for full 3D positioning, or 0 for 2D (non-spatial).
|
|
50
|
+
* Requires an {@link AudioListener} in the scene (typically on the camera).
|
|
51
|
+
*
|
|
52
|
+
* **Visibility handling:**
|
|
53
|
+
* Audio automatically pauses when the tab is hidden unless `playInBackground = true`.
|
|
54
|
+
* On mobile, audio always pauses in background regardless of this setting.
|
|
55
|
+
*
|
|
56
|
+
* @example Play audio on button click
|
|
57
|
+
* ```ts
|
|
58
|
+
* onClick() {
|
|
59
|
+
* const audio = this.getComponent(AudioSource);
|
|
60
|
+
* audio.play();
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example Wait for user interaction
|
|
65
|
+
* ```ts
|
|
66
|
+
* AudioSource.registerWaitForAllowAudio(() => {
|
|
67
|
+
* this.getComponent(AudioSource)?.play();
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
55
71
|
* @summary Plays audio clips from files or media streams
|
|
56
72
|
* @category Multimedia
|
|
57
73
|
* @group Components
|
|
74
|
+
* @see {@link AudioListener} for the audio receiver component
|
|
75
|
+
* @see {@link AudioRolloffMode} for distance attenuation options
|
|
76
|
+
* @see {@link Voip} for voice communication
|
|
77
|
+
* @see {@link PlayableDirector} for timeline-based audio
|
|
78
|
+
* @link https://engine.needle.tools/samples/?overlay=samples&tag=audio
|
|
79
|
+
* @link https://spatial-audio-zubckswmztj.needle.run/
|
|
58
80
|
*/
|
|
59
81
|
export class AudioSource extends Behaviour {
|
|
60
82
|
|
|
@@ -5,12 +5,31 @@ import { serializable } from "../engine/engine_serialization_decorator.js";
|
|
|
5
5
|
import { Behaviour } from "./Component.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* AxesHelper visualizes the local coordinate axes of an object.
|
|
9
|
+
* Displays colored lines for X (red), Y (green), and Z (blue) axes.
|
|
10
|
+
*
|
|
11
|
+
* **Use cases:**
|
|
12
|
+
* - Debugging object orientation and rotation
|
|
13
|
+
* - Visualizing pivot points
|
|
14
|
+
* - Understanding coordinate systems
|
|
15
|
+
*
|
|
16
|
+
* **Properties:**
|
|
17
|
+
* - `length` - Length of axis lines in world units
|
|
18
|
+
* - `depthTest` - Whether axes are occluded by scene objects
|
|
19
|
+
* - `isGizmo` - Only show when `?gizmos` URL parameter is set
|
|
20
|
+
*
|
|
21
|
+
* @example Add axes visualization
|
|
22
|
+
* ```ts
|
|
23
|
+
* const axes = myObject.addComponent(AxesHelper);
|
|
24
|
+
* axes.length = 2;
|
|
25
|
+
* axes.depthTest = false; // Always visible on top
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @summary Visualizes object axes (X=red, Y=green, Z=blue)
|
|
12
29
|
* @category Helpers
|
|
13
30
|
* @group Components
|
|
31
|
+
* @see {@link GridHelper} for grid visualization
|
|
32
|
+
* @see {@link Gizmos} for debug drawing utilities
|
|
14
33
|
*/
|
|
15
34
|
export class AxesHelper extends Behaviour {
|
|
16
35
|
/**
|
|
@@ -4,12 +4,35 @@ import * as utils from "./../engine/engine_three_utils.js";
|
|
|
4
4
|
import { Behaviour, GameObject } from "./Component.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* BasicIKConstraint
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* BasicIKConstraint provides simple two-bone inverse kinematics.
|
|
8
|
+
* Positions this GameObject as a "joint" between `from` and `to` targets,
|
|
9
|
+
* using a `hint` object to determine the bend direction.
|
|
10
|
+
*
|
|
11
|
+
* **Use cases:**
|
|
12
|
+
* - Simple arm/leg IK (elbow/knee positioning)
|
|
13
|
+
* - Mechanical linkages
|
|
14
|
+
* - Procedural animation joints
|
|
15
|
+
*
|
|
16
|
+
* **How it works:**
|
|
17
|
+
* - Calculates joint position based on `desiredDistance` (bone length)
|
|
18
|
+
* - Uses `hint` to determine which way the joint bends
|
|
19
|
+
* - Automatically handles stretching when targets are too far apart
|
|
20
|
+
*
|
|
21
|
+
* @example Setup basic limb IK
|
|
22
|
+
* ```ts
|
|
23
|
+
* // Attach to the elbow/knee joint object
|
|
24
|
+
* const ik = elbowJoint.addComponent(BasicIKConstraint);
|
|
25
|
+
* // Configure via serialized properties in editor:
|
|
26
|
+
* // - from: shoulder/hip
|
|
27
|
+
* // - to: wrist/ankle
|
|
28
|
+
* // - hint: control point for bend direction
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @summary Two-bone inverse kinematics constraint
|
|
32
|
+
* @category Animation and Sequencing
|
|
12
33
|
* @group Components
|
|
34
|
+
* @see {@link LookAtConstraint} for aim constraints
|
|
35
|
+
* @see {@link AlignmentConstraint} for simpler alignment
|
|
13
36
|
*/
|
|
14
37
|
export class BasicIKConstraint extends Behaviour {
|
|
15
38
|
|
|
@@ -32,13 +32,43 @@ const debug = getParam("debugcam");
|
|
|
32
32
|
const debugscreenpointtoray = getParam("debugscreenpointtoray");
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* Camera component that handles rendering from a specific viewpoint in the scene.
|
|
36
|
-
* Supports both perspective and orthographic cameras with various rendering options.
|
|
37
|
-
* Internally
|
|
35
|
+
* Camera component that handles rendering from a specific viewpoint in the scene.
|
|
36
|
+
* Supports both perspective and orthographic cameras with various rendering options.
|
|
37
|
+
* Internally uses three.js {@link PerspectiveCamera} or {@link OrthographicCamera}.
|
|
38
38
|
*
|
|
39
|
+
* 
|
|
40
|
+
*
|
|
41
|
+
* **Background clearing:**
|
|
42
|
+
* Control how the camera clears the background using `clearFlags`:
|
|
43
|
+
* - `Skybox` - Use scene skybox/environment
|
|
44
|
+
* - `SolidColor` - Clear with `backgroundColor`
|
|
45
|
+
* - `None` - Don't clear (for layered rendering)
|
|
46
|
+
*
|
|
47
|
+
* **Render targets:**
|
|
48
|
+
* Set `targetTexture` to a {@link RenderTexture} to render to a texture
|
|
49
|
+
* instead of the screen (useful for mirrors, portals, minimaps).
|
|
50
|
+
*
|
|
51
|
+
* [](https://engine.needle.tools/samples/movie-set)
|
|
52
|
+
*
|
|
53
|
+
* @example Configure camera settings
|
|
54
|
+
* ```ts
|
|
55
|
+
* const cam = this.context.mainCameraComponent;
|
|
56
|
+
* cam.fieldOfView = 60;
|
|
57
|
+
* cam.nearClipPlane = 0.1;
|
|
58
|
+
* cam.farClipPlane = 1000;
|
|
59
|
+
* cam.clearFlags = ClearFlags.SolidColor;
|
|
60
|
+
* cam.backgroundColor = new RGBAColor(0.1, 0.1, 0.2, 1);
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* - Example: https://engine.needle.tools/samples/multiple-cameras
|
|
64
|
+
*
|
|
39
65
|
* @summary Rendering scenes from a specific viewpoint
|
|
40
66
|
* @category Camera and Controls
|
|
41
67
|
* @group Components
|
|
68
|
+
* @see {@link OrbitControls} for camera interaction
|
|
69
|
+
* @see {@link RenderTexture} for off-screen rendering
|
|
70
|
+
* @see {@link ClearFlags} for background clearing options
|
|
71
|
+
* @link https://engine.needle.tools/samples/movie-set/
|
|
42
72
|
*/
|
|
43
73
|
export class Camera extends Behaviour implements ICamera {
|
|
44
74
|
|