@needle-tools/engine 5.1.0-canary.e9062c0 → 5.1.0-canary.f57972c
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 +120 -0
- package/SKILL.md +4 -1
- package/components.needle.json +1 -1
- package/dist/{needle-engine.bundle-CDKcuALa.js → needle-engine.bundle-CAIG39cL.js} +13605 -12680
- package/dist/needle-engine.bundle-CFh_isu6.umd.cjs +1734 -0
- package/dist/needle-engine.bundle-CtadUKoi.min.js +1734 -0
- package/dist/needle-engine.d.ts +1579 -394
- package/dist/needle-engine.js +542 -538
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/three.js +1 -0
- package/dist/three.min.js +21 -21
- package/dist/three.umd.cjs +16 -16
- package/lib/engine/api.d.ts +8 -1
- package/lib/engine/api.js +7 -1
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/codegen/register_types.js +10 -18
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/debug/debug_spatial_console.d.ts +2 -0
- package/lib/engine/debug/debug_spatial_console.js +10 -7
- package/lib/engine/debug/debug_spatial_console.js.map +1 -1
- package/lib/engine/engine_addressables.d.ts +2 -0
- package/lib/engine/engine_addressables.js +6 -3
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_audio.d.ts +68 -0
- package/lib/engine/engine_audio.js +172 -0
- package/lib/engine/engine_audio.js.map +1 -1
- package/lib/engine/engine_camera.fit.js +16 -4
- package/lib/engine/engine_camera.fit.js.map +1 -1
- package/lib/engine/engine_components.js +1 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_context.d.ts +37 -27
- package/lib/engine/engine_context.js +51 -31
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_context_eventbus.d.ts +47 -0
- package/lib/engine/engine_context_eventbus.js +47 -0
- package/lib/engine/engine_context_eventbus.js.map +1 -0
- package/lib/engine/engine_disposable.d.ts +172 -0
- package/lib/engine/engine_disposable.js +136 -0
- package/lib/engine/engine_disposable.js.map +1 -0
- package/lib/engine/engine_gameobject.d.ts +1 -10
- package/lib/engine/engine_gameobject.js +22 -120
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.js +7 -69
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_init.js +14 -4
- package/lib/engine/engine_init.js.map +1 -1
- package/lib/engine/engine_input.d.ts +24 -5
- package/lib/engine/engine_input.js +3 -2
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_instantiate_resolve.d.ts +42 -0
- package/lib/engine/engine_instantiate_resolve.js +372 -0
- package/lib/engine/engine_instantiate_resolve.js.map +1 -0
- package/lib/engine/engine_license.d.ts +7 -7
- package/lib/engine/engine_license.js +186 -58
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.js +7 -4
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +51 -37
- package/lib/engine/engine_networking.js +132 -82
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking.transport.websocket.d.ts +15 -0
- package/lib/engine/engine_networking.transport.websocket.js +38 -0
- package/lib/engine/engine_networking.transport.websocket.js.map +1 -0
- package/lib/engine/engine_networking_blob.js +4 -4
- package/lib/engine/engine_networking_blob.js.map +1 -1
- package/lib/engine/engine_networking_instantiate.js +2 -2
- package/lib/engine/engine_networking_instantiate.js.map +1 -1
- package/lib/engine/engine_networking_types.d.ts +39 -1
- package/lib/engine/engine_networking_types.js +7 -0
- package/lib/engine/engine_networking_types.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +21 -3
- package/lib/engine/engine_physics_rapier.js +94 -25
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_scenedata.d.ts +5 -7
- package/lib/engine/engine_scenedata.js +16 -13
- package/lib/engine/engine_scenedata.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.d.ts +10 -16
- package/lib/engine/engine_serialization_builtin_serializer.js +56 -46
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
- package/lib/engine/engine_serialization_core.d.ts +1 -0
- package/lib/engine/engine_serialization_core.js +7 -0
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_types.d.ts +29 -11
- package/lib/engine/engine_types.js +1 -1
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_util_decorator.js +7 -2
- package/lib/engine/engine_util_decorator.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +1 -1
- package/lib/engine/engine_utils.js +19 -5
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/engine_utils_qrcode.js +2 -2
- package/lib/engine/engine_utils_qrcode.js.map +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
- package/lib/engine/webcomponents/jsx.d.ts +9 -2
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +6 -6
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +10 -4
- package/lib/engine/webcomponents/needle-engine.js +3 -3
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
- package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +3 -2
- package/lib/engine/xr/NeedleXRSession.js +50 -14
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine/xr/TempXRContext.js +2 -2
- package/lib/engine/xr/TempXRContext.js.map +1 -1
- package/lib/engine/xr/events.d.ts +1 -1
- package/lib/engine/xr/events.js.map +1 -1
- package/lib/engine-components/Animation.js +17 -16
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/AnimationBuilder.d.ts +158 -0
- package/lib/engine-components/AnimationBuilder.js +305 -0
- package/lib/engine-components/AnimationBuilder.js.map +1 -0
- package/lib/engine-components/Animator.d.ts +6 -0
- package/lib/engine-components/Animator.js +23 -13
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.builder.d.ts +191 -0
- package/lib/engine-components/AnimatorController.builder.js +263 -0
- package/lib/engine-components/AnimatorController.builder.js.map +1 -0
- package/lib/engine-components/AnimatorController.d.ts +4 -119
- package/lib/engine-components/AnimatorController.js +37 -233
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioSource.d.ts +19 -3
- package/lib/engine-components/AudioSource.js +121 -68
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +18 -9
- package/lib/engine-components/Collider.js +61 -14
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +72 -9
- package/lib/engine-components/Component.js +114 -10
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/ContactShadows.d.ts +1 -0
- package/lib/engine-components/ContactShadows.js +14 -1
- package/lib/engine-components/ContactShadows.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +7 -0
- package/lib/engine-components/DragControls.js +19 -7
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/DropListener.js +3 -0
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/EventList.d.ts +31 -9
- package/lib/engine-components/EventList.js +37 -76
- package/lib/engine-components/EventList.js.map +1 -1
- package/lib/engine-components/Joints.d.ts +4 -2
- package/lib/engine-components/Joints.js +19 -3
- package/lib/engine-components/Joints.js.map +1 -1
- package/lib/engine-components/Light.js +13 -3
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +1 -1
- package/lib/engine-components/Networking.js +1 -1
- package/lib/engine-components/OrbitControls.d.ts +0 -2
- package/lib/engine-components/OrbitControls.js +30 -12
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.js +2 -0
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +12 -4
- package/lib/engine-components/RigidBody.js +18 -4
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.js +3 -0
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/SeeThrough.js +2 -2
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/api.d.ts +2 -1
- package/lib/engine-components/api.js +2 -1
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +7 -13
- package/lib/engine-components/codegen/components.js +7 -13
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
- package/lib/engine-components/postprocessing/VolumeParameter.d.ts +2 -0
- package/lib/engine-components/postprocessing/VolumeParameter.js +4 -1
- package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -1
- package/lib/engine-components/timeline/PlayableDirector.d.ts +21 -11
- package/lib/engine-components/timeline/PlayableDirector.js +75 -67
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/SignalAsset.d.ts +3 -1
- package/lib/engine-components/timeline/SignalAsset.js +1 -0
- package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
- package/lib/engine-components/timeline/TimelineBuilder.d.ts +413 -0
- package/lib/engine-components/timeline/TimelineBuilder.js +506 -0
- package/lib/engine-components/timeline/TimelineBuilder.js.map +1 -0
- package/lib/engine-components/timeline/TimelineModels.d.ts +2 -1
- package/lib/engine-components/timeline/TimelineModels.js +3 -0
- package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.d.ts +37 -6
- package/lib/engine-components/timeline/TimelineTracks.js +92 -26
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/timeline/index.d.ts +2 -1
- package/lib/engine-components/timeline/index.js +2 -0
- package/lib/engine-components/timeline/index.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +1 -1
- package/lib/engine-components/ui/Canvas.js +2 -8
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/Text.d.ts +1 -0
- package/lib/engine-components/ui/Text.js +10 -7
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +0 -1
- package/lib/engine-components/web/CursorFollow.js +21 -13
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/webxr/WebXRImageTracking.d.ts +62 -1
- package/lib/engine-components/webxr/WebXRImageTracking.js +59 -2
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/package.json +2 -83
- package/plugins/common/cloud.js +6 -1
- package/plugins/common/license.js +31 -10
- package/plugins/common/worker.js +9 -4
- package/plugins/vite/asap.js +17 -8
- package/plugins/vite/dependencies.js +29 -10
- package/plugins/vite/dependency-watcher.js +2 -2
- package/plugins/vite/editor-connection.js +3 -3
- package/plugins/vite/license.js +42 -7
- package/plugins/vite/local-files-core.js +3 -3
- package/plugins/vite/local-files-utils.d.ts +3 -1
- package/plugins/vite/local-files-utils.js +29 -5
- package/plugins/vite/reload.js +19 -18
- package/plugins/vite/server.js +2 -1
- package/src/engine/api.ts +11 -1
- package/src/engine/codegen/register_types.ts +10 -18
- package/src/engine/debug/debug_spatial_console.ts +10 -7
- package/src/engine/engine_addressables.ts +6 -3
- package/src/engine/engine_audio.ts +184 -0
- package/src/engine/engine_camera.fit.ts +15 -4
- package/src/engine/engine_components.ts +1 -1
- package/src/engine/engine_context.ts +63 -39
- package/src/engine/engine_context_eventbus.ts +73 -0
- package/src/engine/engine_disposable.ts +214 -0
- package/src/engine/engine_gameobject.ts +54 -159
- package/src/engine/engine_gltf_builtin_components.ts +7 -76
- package/src/engine/engine_init.ts +14 -4
- package/src/engine/engine_input.ts +28 -7
- package/src/engine/engine_instantiate_resolve.ts +407 -0
- package/src/engine/engine_license.ts +202 -56
- package/src/engine/engine_mainloop_utils.ts +7 -4
- package/src/engine/engine_networking.transport.websocket.ts +45 -0
- package/src/engine/engine_networking.ts +161 -137
- package/src/engine/engine_networking_blob.ts +4 -4
- package/src/engine/engine_networking_instantiate.ts +2 -2
- package/src/engine/engine_networking_types.ts +41 -1
- package/src/engine/engine_physics_rapier.ts +102 -33
- package/src/engine/engine_scenedata.ts +16 -13
- package/src/engine/engine_serialization_builtin_serializer.ts +64 -52
- package/src/engine/engine_serialization_core.ts +9 -0
- package/src/engine/engine_types.ts +46 -27
- package/src/engine/engine_util_decorator.ts +7 -2
- package/src/engine/engine_utils.ts +16 -5
- package/src/engine/engine_utils_qrcode.ts +2 -2
- package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
- package/src/engine/webcomponents/jsx.d.ts +9 -2
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
- package/src/engine/webcomponents/needle menu/needle-menu.ts +6 -6
- package/src/engine/webcomponents/needle-engine.loading.ts +6 -6
- package/src/engine/webcomponents/needle-engine.ts +12 -6
- package/src/engine/xr/NeedleXRSession.ts +48 -13
- package/src/engine/xr/TempXRContext.ts +2 -2
- package/src/engine/xr/events.ts +1 -1
- package/src/engine-components/Animation.ts +19 -16
- package/src/engine-components/AnimationBuilder.ts +472 -0
- package/src/engine-components/Animator.ts +24 -12
- package/src/engine-components/AnimatorController.builder.ts +387 -0
- package/src/engine-components/AnimatorController.ts +24 -292
- package/src/engine-components/AudioSource.ts +130 -79
- package/src/engine-components/Collider.ts +66 -18
- package/src/engine-components/Component.ts +118 -20
- package/src/engine-components/ContactShadows.ts +15 -1
- package/src/engine-components/DragControls.ts +18 -11
- package/src/engine-components/DropListener.ts +3 -0
- package/src/engine-components/EventList.ts +45 -83
- package/src/engine-components/Joints.ts +20 -4
- package/src/engine-components/Light.ts +13 -4
- package/src/engine-components/Networking.ts +1 -1
- package/src/engine-components/OrbitControls.ts +34 -14
- package/src/engine-components/ReflectionProbe.ts +2 -0
- package/src/engine-components/RigidBody.ts +18 -4
- package/src/engine-components/SceneSwitcher.ts +3 -0
- package/src/engine-components/SeeThrough.ts +2 -2
- package/src/engine-components/api.ts +2 -1
- package/src/engine-components/codegen/components.ts +7 -13
- package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
- package/src/engine-components/postprocessing/VolumeParameter.ts +4 -1
- package/src/engine-components/timeline/PlayableDirector.ts +83 -81
- package/src/engine-components/timeline/SignalAsset.ts +4 -1
- package/src/engine-components/timeline/TimelineBuilder.ts +824 -0
- package/src/engine-components/timeline/TimelineModels.ts +5 -1
- package/src/engine-components/timeline/TimelineTracks.ts +96 -27
- package/src/engine-components/timeline/index.ts +2 -1
- package/src/engine-components/ui/Canvas.ts +2 -8
- package/src/engine-components/ui/Text.ts +12 -8
- package/src/engine-components/web/CursorFollow.ts +21 -14
- package/src/engine-components/webxr/WebXRImageTracking.ts +79 -7
- package/dist/needle-engine.bundle--q_w7iXI.umd.cjs +0 -1732
- package/dist/needle-engine.bundle-w22UkaT_.min.js +0 -1732
- package/lib/engine-components/AvatarLoader.d.ts +0 -80
- package/lib/engine-components/AvatarLoader.js +0 -232
- package/lib/engine-components/AvatarLoader.js.map +0 -1
- package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +0 -11
- package/lib/engine-components/avatar/AvatarBlink_Simple.js +0 -77
- package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +0 -1
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +0 -14
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +0 -69
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +0 -29
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +0 -122
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +0 -15
- package/lib/engine-components/avatar/Avatar_MouthShapes.js +0 -80
- package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +0 -9
- package/lib/engine-components/avatar/Avatar_MustacheShake.js +0 -30
- package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +0 -1
- package/src/engine-components/AvatarLoader.ts +0 -264
- package/src/engine-components/avatar/AvatarBlink_Simple.ts +0 -70
- package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +0 -64
- package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +0 -140
- package/src/engine-components/avatar/Avatar_MouthShapes.ts +0 -84
- package/src/engine-components/avatar/Avatar_MustacheShake.ts +0 -32
- package/src/vite-env.d.ts +0 -16
|
@@ -5,7 +5,6 @@ import { type GLTF as THREE_GLTF } from "three/examples/jsm/loaders/GLTFLoader.j
|
|
|
5
5
|
|
|
6
6
|
import type { Camera as CameraComponent } from "../engine-components/api.js";
|
|
7
7
|
import type { Context } from "./engine_context.js";
|
|
8
|
-
import { InstantiateContext } from "./engine_gameobject.js";
|
|
9
8
|
import { CollisionDetectionMode, type PhysicsMaterial, RigidbodyConstraints } from "./engine_physics.types.js";
|
|
10
9
|
import { CircularBuffer } from "./engine_utils.js";
|
|
11
10
|
import type { NeedleXRSession } from "./engine_xr.js";
|
|
@@ -196,13 +195,11 @@ export interface IComponent extends IHasGuid {
|
|
|
196
195
|
/** @internal */
|
|
197
196
|
__internalStart();
|
|
198
197
|
/** @internal */
|
|
199
|
-
__internalEnable(
|
|
198
|
+
__internalEnable(isHierarchyChange?: boolean);
|
|
200
199
|
/** @internal */
|
|
201
|
-
__internalDisable(
|
|
200
|
+
__internalDisable(isHierarchyChange?: boolean);
|
|
202
201
|
/** @internal */
|
|
203
202
|
__internalDestroy();
|
|
204
|
-
/** @internal */
|
|
205
|
-
resolveGuids?(guidsMap: GuidsMap): void;
|
|
206
203
|
|
|
207
204
|
/** experimental, called when the script is registered for the first time, this is called even if the component is not enabled. */
|
|
208
205
|
registering?();
|
|
@@ -240,14 +237,14 @@ export interface IComponent extends IHasGuid {
|
|
|
240
237
|
}
|
|
241
238
|
|
|
242
239
|
export function isComponent(obj: any): obj is IComponent {
|
|
243
|
-
return obj && obj.isComponent;
|
|
240
|
+
return obj && typeof obj === "object" && obj.isComponent;
|
|
244
241
|
}
|
|
245
242
|
|
|
246
243
|
export type ICamera = CameraComponent;
|
|
247
244
|
|
|
248
245
|
export type IAnimationComponent = Pick<IComponent, "gameObject"> & {
|
|
249
246
|
isAnimationComponent: boolean;
|
|
250
|
-
addClip?(clip: AnimationClip);
|
|
247
|
+
addClip?(clip: AnimationClip): void;
|
|
251
248
|
}
|
|
252
249
|
|
|
253
250
|
/** Interface for a camera controller component that can be attached to a camera to control it */
|
|
@@ -274,7 +271,10 @@ export declare interface IRenderer extends IComponent {
|
|
|
274
271
|
|
|
275
272
|
export declare interface IEventList {
|
|
276
273
|
readonly isEventList: true;
|
|
277
|
-
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export declare interface ISignalReceiver {
|
|
277
|
+
readonly isSignalReceiver: true;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
// export declare interface IPhysicsComponent extends IComponent {
|
|
@@ -302,12 +302,18 @@ export declare interface ICollider extends IComponent {
|
|
|
302
302
|
* Default: [0]
|
|
303
303
|
*/
|
|
304
304
|
membership?: number[];
|
|
305
|
-
/** The collider filter indicates what groups the collider can interact with (e.g. group 3 and 4)
|
|
306
|
-
* An `undefined` array indicates that the collider can interact with all groups
|
|
307
|
-
* Note: Make sure to call updateProperties after having changed this property
|
|
305
|
+
/** The collider filter indicates what groups the collider can interact with (e.g. group 3 and 4)
|
|
306
|
+
* An `undefined` array indicates that the collider can interact with all groups
|
|
307
|
+
* Note: Make sure to call updateProperties after having changed this property
|
|
308
308
|
* Default: undefined
|
|
309
309
|
*/
|
|
310
310
|
filter?: number[];
|
|
311
|
+
/** The density of the collider used for automatic mass calculation.
|
|
312
|
+
* When the attached Rigidbody has `autoMass` enabled, the mass is computed as `density × volume`.
|
|
313
|
+
* Note: Make sure to call updateProperties after having changed this property
|
|
314
|
+
* Default: undefined (uses physics engine default of 1.0)
|
|
315
|
+
*/
|
|
316
|
+
density?: number;
|
|
311
317
|
}
|
|
312
318
|
|
|
313
319
|
export declare interface ISphereCollider extends ICollider {
|
|
@@ -475,8 +481,10 @@ export interface IPhysicsEngine {
|
|
|
475
481
|
postStep();
|
|
476
482
|
/** Indicates whether the physics engine is currently updating */
|
|
477
483
|
get isUpdating(): boolean;
|
|
478
|
-
/**
|
|
479
|
-
|
|
484
|
+
/** Tears down the physics world and frees all resources. The world will be re-created on next use. */
|
|
485
|
+
dispose(): void;
|
|
486
|
+
/** @deprecated Use {@link dispose} instead. */
|
|
487
|
+
clearCaches(): void;
|
|
480
488
|
|
|
481
489
|
/** Enables or disables the physics engine */
|
|
482
490
|
enabled: boolean;
|
|
@@ -513,20 +521,25 @@ export interface IPhysicsEngine {
|
|
|
513
521
|
/** True if you want to also hit objects when the raycast starts from inside a collider */
|
|
514
522
|
solid?: boolean,
|
|
515
523
|
queryFilterFlags?: QueryFilterFlags,
|
|
516
|
-
/**
|
|
517
|
-
* Raycast filter groups. Groups are used to apply the collision group rules for the scene query.
|
|
518
|
-
* The scene query will only consider hits with colliders with collision groups compatible with
|
|
524
|
+
/**
|
|
525
|
+
* Raycast filter groups. Groups are used to apply the collision group rules for the scene query.
|
|
526
|
+
* The scene query will only consider hits with colliders with collision groups compatible with
|
|
519
527
|
* this collision group (using the bitwise test described in the collision groups section).
|
|
520
|
-
* For example membership 0x0001 and filter 0x0002 should be 0x00010002
|
|
528
|
+
* For example membership 0x0001 and filter 0x0002 should be 0x00010002
|
|
521
529
|
* @see https://rapier.rs/docs/user_guides/javascript/colliders#collision-groups-and-solver-groups
|
|
522
530
|
*/
|
|
523
531
|
filterGroups?: number,
|
|
524
|
-
/**
|
|
532
|
+
/**
|
|
525
533
|
* Predicate to filter colliders in raycast results
|
|
526
534
|
* @param collider The collider being tested
|
|
527
535
|
* @returns False to ignore this collider, true to include it
|
|
528
536
|
*/
|
|
529
|
-
filterPredicate?: (collider: ICollider) => boolean
|
|
537
|
+
filterPredicate?: (collider: ICollider) => boolean,
|
|
538
|
+
/** When true, trigger/sensor colliders will be included in the raycast results.
|
|
539
|
+
* By default trigger colliders are skipped.
|
|
540
|
+
* @default false
|
|
541
|
+
*/
|
|
542
|
+
includeTriggers?: boolean,
|
|
530
543
|
}): RaycastResult;
|
|
531
544
|
|
|
532
545
|
/**
|
|
@@ -541,20 +554,25 @@ export interface IPhysicsEngine {
|
|
|
541
554
|
/** True if you want to also hit objects when the raycast starts from inside a collider */
|
|
542
555
|
solid?: boolean,
|
|
543
556
|
queryFilterFlags?: QueryFilterFlags,
|
|
544
|
-
/**
|
|
545
|
-
* Raycast filter groups. Groups are used to apply the collision group rules for the scene query.
|
|
546
|
-
* The scene query will only consider hits with colliders with collision groups compatible with
|
|
557
|
+
/**
|
|
558
|
+
* Raycast filter groups. Groups are used to apply the collision group rules for the scene query.
|
|
559
|
+
* The scene query will only consider hits with colliders with collision groups compatible with
|
|
547
560
|
* this collision group (using the bitwise test described in the collision groups section).
|
|
548
|
-
* For example membership 0x0001 and filter 0x0002 should be 0x00010002
|
|
561
|
+
* For example membership 0x0001 and filter 0x0002 should be 0x00010002
|
|
549
562
|
* @see https://rapier.rs/docs/user_guides/javascript/colliders#collision-groups-and-solver-groups
|
|
550
563
|
*/
|
|
551
564
|
filterGroups?: number,
|
|
552
|
-
/**
|
|
565
|
+
/**
|
|
553
566
|
* Predicate to filter colliders in raycast results
|
|
554
567
|
* @param collider The collider being tested
|
|
555
568
|
* @returns False to ignore this collider, true to include it
|
|
556
569
|
*/
|
|
557
|
-
filterPredicate?: (collider: ICollider) => boolean
|
|
570
|
+
filterPredicate?: (collider: ICollider) => boolean,
|
|
571
|
+
/** When true, trigger/sensor colliders will be included in the raycast results.
|
|
572
|
+
* By default trigger colliders are skipped.
|
|
573
|
+
* @default false
|
|
574
|
+
*/
|
|
575
|
+
includeTriggers?: boolean,
|
|
558
576
|
}): RaycastResult;
|
|
559
577
|
|
|
560
578
|
/**
|
|
@@ -738,8 +756,9 @@ export interface IPhysicsEngine {
|
|
|
738
756
|
getBody(obj: ICollider | IRigidbody): null | any;
|
|
739
757
|
|
|
740
758
|
// Joints
|
|
741
|
-
addFixedJoint(body1: IRigidbody, body2: IRigidbody);
|
|
742
|
-
addHingeJoint(body1: IRigidbody, body2: IRigidbody, anchor: Vec3, axis: Vec3);
|
|
759
|
+
addFixedJoint(body1: IRigidbody, body2: IRigidbody): Promise<any> | any;
|
|
760
|
+
addHingeJoint(body1: IRigidbody, body2: IRigidbody, anchor: Vec3, axis: Vec3): Promise<any> | any;
|
|
761
|
+
removeJoint(joint: any): void;
|
|
743
762
|
|
|
744
763
|
/** Enable to render collider shapes */
|
|
745
764
|
debugRenderColliders: boolean;
|
|
@@ -79,8 +79,12 @@ function createPropertyWrapper(target: IComponent | any, _propertyKey: string |
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
//
|
|
83
|
-
|
|
82
|
+
// Only install the getter/setter once per instance.
|
|
83
|
+
// processStart may call __internalAwake again for components that were inactive
|
|
84
|
+
// during processNewScripts — the base Component.__internalAwake has a __didAwake guard
|
|
85
|
+
// but this decorator wrapper runs before reaching it, so we need our own idempotency check.
|
|
86
|
+
const desc = Object.getOwnPropertyDescriptor(this, propertyKey);
|
|
87
|
+
if (!desc || !desc.get) {
|
|
84
88
|
|
|
85
89
|
// make sure the field is initialized in a hidden property
|
|
86
90
|
this[$prop] = this[propertyKey];
|
|
@@ -99,6 +103,7 @@ function createPropertyWrapper(target: IComponent | any, _propertyKey: string |
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
Object.defineProperty(this, propertyKey, {
|
|
106
|
+
configurable: true,
|
|
102
107
|
set: function (v) {
|
|
103
108
|
if (this[$isAssigningProperties] === true) {
|
|
104
109
|
this[$prop] = v;
|
|
@@ -279,24 +279,35 @@ declare type deepClonePredicate = (owner: any, propertyName: string, current: an
|
|
|
279
279
|
* return true;
|
|
280
280
|
* });
|
|
281
281
|
* */
|
|
282
|
-
export function deepClone(obj: any, predicate?: deepClonePredicate): any {
|
|
282
|
+
export function deepClone(obj: any, predicate?: deepClonePredicate, _visited?: WeakSet<object>): any {
|
|
283
283
|
if (obj !== null && obj !== undefined && typeof obj === "object") {
|
|
284
|
+
if (!_visited) _visited = new WeakSet();
|
|
285
|
+
if (_visited.has(obj)) return obj;
|
|
286
|
+
_visited.add(obj);
|
|
287
|
+
|
|
284
288
|
let clone;
|
|
285
289
|
if (Array.isArray(obj)) clone = [];
|
|
286
290
|
else {
|
|
287
|
-
clone = Object.create(obj);
|
|
288
|
-
|
|
291
|
+
clone = Object.create(Object.getPrototypeOf(obj));
|
|
292
|
+
// Copy own properties, skipping getter-only properties that can't be set
|
|
293
|
+
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
294
|
+
for (const key in descriptors) {
|
|
295
|
+
const desc = descriptors[key];
|
|
296
|
+
if (desc.set || desc.writable !== false) {
|
|
297
|
+
try { clone[key] = obj[key]; }
|
|
298
|
+
catch { /* skip read-only properties */ }
|
|
299
|
+
}
|
|
300
|
+
}
|
|
289
301
|
}
|
|
290
302
|
for (const key of Object.keys(obj)) {
|
|
291
303
|
const val = obj[key];
|
|
292
304
|
if (predicate && !predicate(obj, key, val)) {
|
|
293
|
-
// console.log("SKIP", val);
|
|
294
305
|
clone[key] = val;
|
|
295
306
|
}
|
|
296
307
|
else if (val?.clone !== undefined && typeof val.clone === "function")
|
|
297
308
|
clone[key] = val.clone();
|
|
298
309
|
else
|
|
299
|
-
clone[key] = deepClone(val, predicate);
|
|
310
|
+
clone[key] = deepClone(val, predicate, _visited);
|
|
300
311
|
}
|
|
301
312
|
return clone;
|
|
302
313
|
}
|
|
@@ -4,7 +4,7 @@ import { Quaternion, Vector2, Vector3, Vector4 } from "three";
|
|
|
4
4
|
|
|
5
5
|
import { needleLogoOnlySVG } from "./assets/index.js";
|
|
6
6
|
import { isDevEnvironment } from "./debug/debug.js";
|
|
7
|
-
import {
|
|
7
|
+
import { _$LVgA } from "./engine_license.js";
|
|
8
8
|
import { InternalAttributeUtils } from "./engine_utils_attributes.js";
|
|
9
9
|
import type { NeedleEngineWebComponent } from "./webcomponents/needle-engine.js";
|
|
10
10
|
|
|
@@ -135,7 +135,7 @@ async function internalRenderQRCodeOverlays(canvas: HTMLCanvasElement, args: { s
|
|
|
135
135
|
console.debug("[QR Code] No web component found")
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
const canUseCustomLogo =
|
|
138
|
+
const canUseCustomLogo = _$LVgA();
|
|
139
139
|
|
|
140
140
|
// Query logo src from needle-engine attribute.
|
|
141
141
|
// For any supported attribute it's possible to use "falsey" values (e.g. "0" or "false" to disable the logo in the QR code)
|
|
@@ -35,7 +35,7 @@ export class GenerateMeshBVHWorker extends WorkerBase {
|
|
|
35
35
|
|
|
36
36
|
worker.onerror = e => {
|
|
37
37
|
|
|
38
|
-
reject(new Error(`[GenerateMeshBVHWorker] ${e.message || "
|
|
38
|
+
reject(new Error(`[GenerateMeshBVHWorker] ${e.message || "Could not load worker."}`));
|
|
39
39
|
|
|
40
40
|
};
|
|
41
41
|
|
|
@@ -3,8 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Covers both the global JSX namespace (Preact, SolidJS, Svelte, vanilla TS)
|
|
5
5
|
* and React's module-scoped JSX namespace (react-jsx / react-jsxdev transform).
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANT: This file must be a module (has a top-level import/export) so that
|
|
8
|
+
* `declare module "react"` is treated as a *module augmentation* (merging into
|
|
9
|
+
* the existing React types) rather than an *ambient module declaration* (which
|
|
10
|
+
* would shadow/replace @types/react).
|
|
6
11
|
*/
|
|
7
12
|
|
|
13
|
+
import type { NeedleEngineAttributes } from "./needle-engine.js";
|
|
14
|
+
|
|
8
15
|
interface NeedleButtonJSXAttributes extends Partial<Omit<HTMLElement, "style" | "children">> {
|
|
9
16
|
style?: Partial<CSSStyleDeclaration>;
|
|
10
17
|
ar?: boolean | string;
|
|
@@ -23,7 +30,7 @@ interface NeedleLogoElementJSXAttributes extends Partial<Omit<HTMLElement, "styl
|
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
interface NeedleElements {
|
|
26
|
-
"needle-engine":
|
|
33
|
+
"needle-engine": Partial<NeedleEngineAttributes>;
|
|
27
34
|
"needle-button": NeedleButtonJSXAttributes;
|
|
28
35
|
"needle-menu": NeedleMenuJSXAttributes;
|
|
29
36
|
"needle-logo-element": NeedleLogoElementJSXAttributes;
|
|
@@ -36,7 +43,7 @@ declare global {
|
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
45
|
|
|
39
|
-
// React module-scoped JSX namespace
|
|
46
|
+
// React module-scoped JSX namespace (module augmentation, not ambient declaration)
|
|
40
47
|
declare module "react" {
|
|
41
48
|
namespace JSX {
|
|
42
49
|
interface IntrinsicElements extends NeedleElements {}
|
|
@@ -2,7 +2,7 @@ import { Mesh, Object3D, TextureLoader, Vector4 } from "three";
|
|
|
2
2
|
import ThreeMeshUI from "three-mesh-ui";
|
|
3
3
|
|
|
4
4
|
import { addNewComponent } from "../../engine_components.js";
|
|
5
|
-
import {
|
|
5
|
+
import { _kRatU } from "../../engine_license.js";
|
|
6
6
|
import { OneEuroFilterXYZ } from "../../engine_math.js";
|
|
7
7
|
import type { Context } from "../../engine_setup.js";
|
|
8
8
|
import { lookAtObject } from "../../engine_three_utils.js";
|
|
@@ -321,7 +321,7 @@ export class NeedleSpatialMenu {
|
|
|
321
321
|
}
|
|
322
322
|
if (this.menu) {
|
|
323
323
|
const index = this.menu.children.indexOf(this._poweredByNeedleElement as any);
|
|
324
|
-
if (!this._showNeedleLogo &&
|
|
324
|
+
if (!this._showNeedleLogo && _kRatU()) {
|
|
325
325
|
if (index >= 0) {
|
|
326
326
|
this._poweredByNeedleElement.removeFromParent();
|
|
327
327
|
this.markDirty();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { showBalloonMessage } from "../../debug/debug.js";
|
|
2
|
-
import { HTMLElementBase } from "../../engine_ssr.js";
|
|
3
2
|
import type { Context } from "../../engine_context.js";
|
|
4
|
-
import {
|
|
3
|
+
import { _$LVgA, __BJrSMke, Telemetry } from "../../engine_license.js";
|
|
5
4
|
import { isLocalNetwork } from "../../engine_networking_utils.js";
|
|
5
|
+
import { HTMLElementBase } from "../../engine_ssr.js";
|
|
6
6
|
import { DeviceUtilities, getParam } from "../../engine_utils.js";
|
|
7
7
|
import { onXRSessionStart, XRSessionEventArgs } from "../../xr/events.js";
|
|
8
8
|
import { ButtonsFactory } from "../buttons.js";
|
|
@@ -778,8 +778,8 @@ export class NeedleMenuElement extends HTMLElementBase {
|
|
|
778
778
|
try {
|
|
779
779
|
// if the user has a license then we CAN hide the needle logo
|
|
780
780
|
// calling this method immediately will cause an issue with vite bundling tho
|
|
781
|
-
window.requestAnimationFrame(() =>
|
|
782
|
-
if (res == true &&
|
|
781
|
+
window.requestAnimationFrame(() => __BJrSMke(res => {
|
|
782
|
+
if (res == true && _$LVgA() && !debugNonCommercial) {
|
|
783
783
|
let visible = this._userRequestedLogoVisible;
|
|
784
784
|
if (visible === undefined) visible = false;
|
|
785
785
|
this.___onSetLogoVisible(visible);
|
|
@@ -830,7 +830,7 @@ export class NeedleMenuElement extends HTMLElementBase {
|
|
|
830
830
|
// ensure the menu is not hidden or removed
|
|
831
831
|
const requiredParent = this?.parentNode;
|
|
832
832
|
if (this.style.display != "flex" || this.style.visibility != "visible" || this.style.opacity != "1" || requiredParent != this._domElement?.shadowRoot) {
|
|
833
|
-
if (!
|
|
833
|
+
if (!_$LVgA()) {
|
|
834
834
|
const change = changeEventCounter++;
|
|
835
835
|
// if a user doesn't have a local pro license *but* for development the menu is hidden then we show a warning
|
|
836
836
|
if (isLocalNetwork() && this._userRequestedMenuVisible === false) {
|
|
@@ -918,7 +918,7 @@ export class NeedleMenuElement extends HTMLElementBase {
|
|
|
918
918
|
showNeedleLogo(visible: boolean) {
|
|
919
919
|
this._userRequestedLogoVisible = visible;
|
|
920
920
|
if (!visible) {
|
|
921
|
-
if (!
|
|
921
|
+
if (!_$LVgA() || debugNonCommercial) {
|
|
922
922
|
console.warn("[Needle Engine] You need a PRO license to hide the Needle Engine logo in production.");
|
|
923
923
|
const localNetwork = isLocalNetwork()
|
|
924
924
|
if (!localNetwork) return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { needleLogoOnlySVG } from "../assets/index.js"
|
|
2
2
|
import { isDevEnvironment, showBalloonWarning } from "../debug/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { _$LVgA, _kRatU, __VbRTQ } from "../engine_license.js";
|
|
4
4
|
import { Mathf } from "../engine_math.js";
|
|
5
5
|
import { LoadingProgressArgs } from "../engine_setup.js";
|
|
6
6
|
import { getParam } from "../engine_utils.js";
|
|
@@ -205,7 +205,7 @@ export class EngineLoadingView implements ILoadingViewHandler {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
|
|
208
|
-
const hasLicense =
|
|
208
|
+
const hasLicense = _kRatU();
|
|
209
209
|
if (!existing) {
|
|
210
210
|
this._loadingElement.style.position = "absolute";
|
|
211
211
|
this._loadingElement.style.width = "100%";
|
|
@@ -373,7 +373,7 @@ export class EngineLoadingView implements ILoadingViewHandler {
|
|
|
373
373
|
|
|
374
374
|
// private async handleRuntimeLicense(loadingElement: HTMLElement) {
|
|
375
375
|
// // First check if we have a commercial license
|
|
376
|
-
// let commercialLicense =
|
|
376
|
+
// let commercialLicense = _$LVgA();
|
|
377
377
|
// // if it's the case then we don't need to perform a runtime check
|
|
378
378
|
// if (commercialLicense) return;
|
|
379
379
|
|
|
@@ -393,10 +393,10 @@ export class EngineLoadingView implements ILoadingViewHandler {
|
|
|
393
393
|
// loadingElement.appendChild(nonCommercialContainer);
|
|
394
394
|
|
|
395
395
|
// // Use the runtime license check
|
|
396
|
-
// if (!isDevEnvironment() &&
|
|
396
|
+
// if (!isDevEnvironment() && __VbRTQ) {
|
|
397
397
|
// if (debugLicense) console.log("Waiting for runtime license check");
|
|
398
|
-
// await
|
|
399
|
-
// commercialLicense =
|
|
398
|
+
// await __VbRTQ;
|
|
399
|
+
// commercialLicense = _$LVgA();
|
|
400
400
|
// }
|
|
401
401
|
// if (commercialLicense) return;
|
|
402
402
|
// nonCommercialContainer.style.transition = "opacity .5s ease-in-out";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isDevEnvironment, showBalloonWarning } from "../debug/index.js";
|
|
2
|
-
import { HTMLElementBase } from "../engine_ssr.js";
|
|
3
2
|
import { PUBLIC_KEY, VERSION } from "../engine_constants.js";
|
|
4
3
|
import { ContextEvent, ContextRegistry } from "../engine_context_registry.js";
|
|
5
|
-
import {
|
|
4
|
+
import { _$LVgA } from "../engine_license.js";
|
|
6
5
|
import { onStart } from "../engine_lifecycle_api.js";
|
|
7
6
|
import { setDracoDecoderPath, setDracoDecoderType, setKtx2TranscoderPath } from "../engine_loaders.gltf.js";
|
|
8
7
|
import { Context, ContextCreateArgs } from "../engine_setup.js";
|
|
8
|
+
import { HTMLElementBase } from "../engine_ssr.js";
|
|
9
9
|
import { nameToThreeTonemapping } from "../engine_tonemapping.js";
|
|
10
10
|
import { type INeedleEngineComponent, type LoadedModel } from "../engine_types.js";
|
|
11
11
|
import type { addAttributeChangeCallback } from "../engine_utils.js";
|
|
@@ -42,11 +42,17 @@ export interface NeedleEngineAttributes {
|
|
|
42
42
|
'hash': string;
|
|
43
43
|
/** Set to automatically add OrbitControls to the loaded scene. */
|
|
44
44
|
'camera-controls': string;
|
|
45
|
-
/** Override the default
|
|
45
|
+
/** Override the default Draco decoder/decompressor path. Can be a URL or a local path to a directory containing the Draco decoder files.
|
|
46
|
+
* @default "https://www.gstatic.com/draco/versioned/decoders/1.5.7/"
|
|
47
|
+
* @example <needle-engine dracoDecoderPath="./decoders/draco/"></needle-engine>
|
|
48
|
+
*/
|
|
46
49
|
'dracoDecoderPath': string;
|
|
47
|
-
/** Override the default
|
|
50
|
+
/** Override the default Draco decoder type. */
|
|
48
51
|
'dracoDecoderType': 'wasm' | 'js';
|
|
49
|
-
/** Override the default KTX2 transcoder/decoder path.
|
|
52
|
+
/** Override the default KTX2 transcoder/decoder path. Can be a URL or a local path to a directory containing the KTX2 transcoder files.
|
|
53
|
+
* @default "https://cdn.needle.tools/static/three/0.179.1/basis2/"
|
|
54
|
+
* @example <needle-engine ktx2DecoderPath="./decoders/ktx2/"></needle-engine>
|
|
55
|
+
*/
|
|
50
56
|
'ktx2DecoderPath': string;
|
|
51
57
|
/** Prevent context from being disposed when element is removed from DOM. */
|
|
52
58
|
'keep-alive': 'true' | 'false';
|
|
@@ -540,7 +546,7 @@ export class NeedleEngineWebComponent extends HTMLElementBase implements INeedle
|
|
|
540
546
|
|
|
541
547
|
|
|
542
548
|
// Loading start events
|
|
543
|
-
const allowOverridingDefaultLoading =
|
|
549
|
+
const allowOverridingDefaultLoading = _$LVgA();
|
|
544
550
|
// default loading can be overriden by calling preventDefault in the onload start event
|
|
545
551
|
this.ensureLoadStartIsRegistered();
|
|
546
552
|
let useDefaultLoading = this.dispatchEvent(new CustomEvent("loadstart", {
|
|
@@ -840,15 +840,16 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
840
840
|
get viewerPose(): XRViewerPose | undefined { return this._viewerPose; }
|
|
841
841
|
|
|
842
842
|
|
|
843
|
-
/** @returns `true` if any image is currently being tracked */
|
|
844
|
-
/** returns true if images are currently being tracked */
|
|
843
|
+
/** @returns `true` if any image is currently being tracked or emulated */
|
|
845
844
|
get isTrackingImages() {
|
|
846
845
|
if (this.frame && "getImageTrackingResults" in this.frame && typeof this.frame.getImageTrackingResults === "function") {
|
|
847
846
|
try {
|
|
848
847
|
const trackingResult = this.frame.getImageTrackingResults();
|
|
849
848
|
for (const result of trackingResult) {
|
|
850
849
|
const state = result.trackingState;
|
|
851
|
-
if (state === "tracked")
|
|
850
|
+
if (state === "tracked" || state === "emulated") {
|
|
851
|
+
return true;
|
|
852
|
+
}
|
|
852
853
|
}
|
|
853
854
|
}
|
|
854
855
|
catch {
|
|
@@ -1053,6 +1054,8 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1053
1054
|
private readonly _xr_update_scripts: INeedleXRSessionEventReceiver[] = [];
|
|
1054
1055
|
/** scripts that are in the scene but inactive (e.g. disabled parent gameObject) */
|
|
1055
1056
|
private readonly _inactive_scripts: INeedleXRSessionEventReceiver[] = [];
|
|
1057
|
+
/** tracks scripts that have received onEnterXR — prevents spurious onLeaveXR calls */
|
|
1058
|
+
private readonly _scripts_in_xr = new Set<INeedleXRSessionEventReceiver>();
|
|
1056
1059
|
private readonly _controllerAdded: ControllerChangedEvt[];
|
|
1057
1060
|
private readonly _controllerRemoved: ControllerChangedEvt[];
|
|
1058
1061
|
private readonly _originalCameraWorldPosition?: Vector3 | null;
|
|
@@ -1163,7 +1166,18 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1163
1166
|
// we set the session on the webxr manager at the end because we want to receive inputsource events first
|
|
1164
1167
|
// e.g. in case there's a bug in the threejs codebase
|
|
1165
1168
|
this.context.xr = this;
|
|
1166
|
-
this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet)
|
|
1169
|
+
this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet)
|
|
1170
|
+
.catch(err => {
|
|
1171
|
+
// Workaround for WebXR emulators on localhost: the polyfilled XRSession fails the
|
|
1172
|
+
// native XRWebGLBinding constructor's instanceof check. Retry with layers disabled.
|
|
1173
|
+
// See https://github.com/meta-quest/immersive-web-emulator/issues/80
|
|
1174
|
+
if (isDevEnvironment() && err instanceof TypeError && typeof XRWebGLBinding !== "undefined") {
|
|
1175
|
+
console.error(`XRWebGLBinding failed (${err.message}).\nSee https://github.com/meta-quest/immersive-web-emulator/issues/80`);
|
|
1176
|
+
}
|
|
1177
|
+
else {
|
|
1178
|
+
console.error("renderer.xr.setSession failed:", err);
|
|
1179
|
+
}
|
|
1180
|
+
});
|
|
1167
1181
|
// disable three.js renderer controller autoUpdate (added in ac67b31e3548386f8a93e23a4176554c92bbd0d9)
|
|
1168
1182
|
if ("controllerAutoUpdate" in this.context.renderer.xr) {
|
|
1169
1183
|
console.debug("Disabling three.js controllerAutoUpdate");
|
|
@@ -1331,8 +1345,10 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1331
1345
|
// even if they might already be destroyed e.g. by the WebXR component (it destroys the default controller scripts)
|
|
1332
1346
|
// they should still receive this callback to be properly cleaned up
|
|
1333
1347
|
for (const listener of this._xr_scripts) {
|
|
1348
|
+
this._scripts_in_xr.delete(listener);
|
|
1334
1349
|
listener?.onLeaveXR?.({ xr: this });
|
|
1335
1350
|
}
|
|
1351
|
+
this._scripts_in_xr.clear();
|
|
1336
1352
|
|
|
1337
1353
|
this.sync?.onExitXR(this);
|
|
1338
1354
|
|
|
@@ -1399,10 +1415,17 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1399
1415
|
}
|
|
1400
1416
|
|
|
1401
1417
|
// make sure the camera is parented to the active rig
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1418
|
+
// Note: applyCustomForward() inserts _cameraRenderParent between rig and camera,
|
|
1419
|
+
// so the hierarchy is: rig → _cameraRenderParent → camera. We check the effective parent.
|
|
1420
|
+
if (this.rig) {
|
|
1421
|
+
const cameraObject = this._mainCamera?.gameObject ?? this.context.mainCamera;
|
|
1422
|
+
if (cameraObject) {
|
|
1423
|
+
const effectiveParent = cameraObject.parent === this._cameraRenderParent
|
|
1424
|
+
? this._cameraRenderParent.parent
|
|
1425
|
+
: cameraObject.parent;
|
|
1426
|
+
if (effectiveParent !== this.rig.gameObject) {
|
|
1427
|
+
this.rig.gameObject.add(cameraObject);
|
|
1428
|
+
}
|
|
1406
1429
|
}
|
|
1407
1430
|
}
|
|
1408
1431
|
|
|
@@ -1534,8 +1557,12 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1534
1557
|
}
|
|
1535
1558
|
|
|
1536
1559
|
//performance.mark('NeedleXRSession update scripts start');
|
|
1537
|
-
//
|
|
1538
|
-
|
|
1560
|
+
// check all XR scripts for destroyed or inactive state
|
|
1561
|
+
// this must cover _xr_scripts (not just _xr_update_scripts) so that scripts
|
|
1562
|
+
// without onUpdateXR are also detected as inactive when removed from the scene
|
|
1563
|
+
// iterate backwards since markInactive/removeScript modifies the array
|
|
1564
|
+
for (let i = this._xr_scripts.length - 1; i >= 0; i--) {
|
|
1565
|
+
const script = this._xr_scripts[i];
|
|
1539
1566
|
if (script.destroyed === true) {
|
|
1540
1567
|
this._script_to_remove.push(script);
|
|
1541
1568
|
continue;
|
|
@@ -1544,6 +1571,10 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1544
1571
|
this.markInactive(script);
|
|
1545
1572
|
continue;
|
|
1546
1573
|
}
|
|
1574
|
+
}
|
|
1575
|
+
// invoke update on scripts that have onUpdateXR
|
|
1576
|
+
for (const script of this._xr_update_scripts) {
|
|
1577
|
+
if (script.destroyed || script.activeAndEnabled === false) continue;
|
|
1547
1578
|
if (script.onUpdateXR) script.onUpdateXR(args);
|
|
1548
1579
|
}
|
|
1549
1580
|
//performance.mark('NeedleXRSession update scripts end');
|
|
@@ -1666,9 +1697,11 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1666
1697
|
const script = this._inactive_scripts[i];
|
|
1667
1698
|
if (script.activeAndEnabled) {
|
|
1668
1699
|
this._inactive_scripts.splice(i, 1);
|
|
1669
|
-
|
|
1670
|
-
this.
|
|
1671
|
-
|
|
1700
|
+
// addScript returns false if already re-added (e.g. via new_scripts_xr processing)
|
|
1701
|
+
if (this.addScript(script)) {
|
|
1702
|
+
this.invokeCallback_EnterXR(script);
|
|
1703
|
+
for (const ctrl of this.controllers) this.invokeCallback_ControllerAdded(script, ctrl);
|
|
1704
|
+
}
|
|
1672
1705
|
}
|
|
1673
1706
|
}
|
|
1674
1707
|
}
|
|
@@ -1689,6 +1722,7 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1689
1722
|
}
|
|
1690
1723
|
|
|
1691
1724
|
private invokeCallback_EnterXR(script: INeedleXRSessionEventReceiver) {
|
|
1725
|
+
this._scripts_in_xr.add(script);
|
|
1692
1726
|
if (script.onEnterXR) {
|
|
1693
1727
|
script.onEnterXR({ xr: this });
|
|
1694
1728
|
}
|
|
@@ -1704,6 +1738,7 @@ export class NeedleXRSession implements INeedleXRSession {
|
|
|
1704
1738
|
}
|
|
1705
1739
|
}
|
|
1706
1740
|
private invokeCallback_LeaveXR(script: INeedleXRSessionEventReceiver) {
|
|
1741
|
+
if (!this._scripts_in_xr.delete(script)) return;
|
|
1707
1742
|
if (script.onLeaveXR && !script.destroyed) {
|
|
1708
1743
|
script.onLeaveXR({ xr: this });
|
|
1709
1744
|
}
|
|
@@ -3,7 +3,7 @@ import { ArrayCamera, AxesHelper, Camera, Color, DirectionalLight, Fog, GridHelp
|
|
|
3
3
|
import { needleLogoOnlySVG } from "../assets/index.js";
|
|
4
4
|
import { isDevEnvironment } from "../debug/index.js";
|
|
5
5
|
import { ObjectUtils, PrimitiveType } from "../engine_create_objects.js";
|
|
6
|
-
import {
|
|
6
|
+
import { _$LVgA } from "../engine_license.js";
|
|
7
7
|
import { Mathf } from "../engine_math.js";
|
|
8
8
|
import { delay, DeviceUtilities } from "../engine_utils.js";
|
|
9
9
|
|
|
@@ -215,7 +215,7 @@ export class TemporaryXRContext {
|
|
|
215
215
|
this._scene.background = new Color(0x000000);
|
|
216
216
|
|
|
217
217
|
let logoSrc = needleLogoOnlySVG;
|
|
218
|
-
if (
|
|
218
|
+
if (_$LVgA()) {
|
|
219
219
|
const htmlComponent = document.querySelector("needle-engine");
|
|
220
220
|
if (htmlComponent) {
|
|
221
221
|
const licenseLogo = htmlComponent.getAttribute("logo-src");
|
package/src/engine/xr/events.ts
CHANGED