@needle-tools/engine 4.14.0-next.31f837e → 4.14.0-next.52fdb13
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 +9 -0
- package/components.needle.json +1 -1
- package/dist/{generateMeshBVH.worker-DFcS3P04.js → generateMeshBVH.worker-DiCnZlf3.js} +1 -1
- package/dist/{gltf-progressive-8voIgNp_.js → gltf-progressive-Bm_6aEi4.js} +4 -4
- package/dist/{gltf-progressive-BRRBj-nY.umd.cjs → gltf-progressive-BttGBXw6.umd.cjs} +3 -3
- package/dist/{gltf-progressive-Dkh3tG4-.min.js → gltf-progressive-T5WKTux5.min.js} +1 -1
- package/dist/{loader.worker-C6cXDgR1.js → loader.worker-BqODMeeW.js} +1 -1
- package/dist/{materialx-Dx8st96L.min.js → materialx-CJyQZtjt.min.js} +1 -1
- package/dist/{materialx-D66rYPqe.js → materialx-DMs1E08Z.js} +2 -2
- package/dist/{materialx-CxlgposR.umd.cjs → materialx-DaKKOoVk.umd.cjs} +1 -1
- package/dist/{needle-engine.bundle-D7w0XD7M.min.js → needle-engine.bundle-BwfaInTa.min.js} +156 -148
- package/dist/{needle-engine.bundle-BQXG5qbQ.umd.cjs → needle-engine.bundle-DJE-Bjpa.umd.cjs} +141 -133
- package/dist/{needle-engine.bundle-Byl5i6zJ.js → needle-engine.bundle-TmE5-_na.js} +6741 -6449
- package/dist/needle-engine.d.ts +896 -51
- package/dist/needle-engine.js +571 -570
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-Ce5-UWiA.min.js → postprocessing-06AXuvdv.min.js} +2 -2
- package/dist/{postprocessing-BkSpxpYB.js → postprocessing-CI2x8Cln.js} +4 -4
- package/dist/{postprocessing-DFVElmAh.umd.cjs → postprocessing-CPDcA21P.umd.cjs} +2 -2
- package/dist/{three-Bad8p1pf.umd.cjs → three-BjYim-vL.umd.cjs} +47 -47
- package/dist/{three-DFV1-P9z.js → three-Bvk2VKbF.js} +2 -2
- package/dist/{three-CWn13_u1.min.js → three-IG2qPafA.min.js} +2 -2
- package/dist/{three-examples-CO-tx3Sp.umd.cjs → three-examples-BMmNgNCN.umd.cjs} +1 -1
- package/dist/{three-examples-43yqn3mL.js → three-examples-CMYCd5nH.js} +1 -1
- package/dist/{three-examples-DKuJVGT4.min.js → three-examples-CQl1fFZp.min.js} +1 -1
- package/dist/{three-mesh-ui-DyEA5HQF.min.js → three-mesh-ui-5HVE2RV-.min.js} +1 -1
- package/dist/{three-mesh-ui-fSAQJxdI.js → three-mesh-ui-BlakAItG.js} +1 -1
- package/dist/{three-mesh-ui-ChzVOraf.umd.cjs → three-mesh-ui-D828VbQp.umd.cjs} +1 -1
- package/dist/{vendor-pe19S9r5.min.js → vendor-BxK0WKmT.min.js} +1 -1
- package/dist/{vendor-B51YffMU.umd.cjs → vendor-CIDkyBaO.umd.cjs} +1 -1
- package/dist/{vendor-CgpZ5ivC.js → vendor-ixwD-vv2.js} +1 -1
- package/lib/engine/api.d.ts +203 -18
- package/lib/engine/api.js +271 -18
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_accessibility.d.ts +58 -0
- package/lib/engine/engine_accessibility.js +143 -0
- package/lib/engine/engine_accessibility.js.map +1 -0
- package/lib/engine/engine_context.d.ts +2 -0
- package/lib/engine/engine_context.js +7 -0
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_materialpropertyblock.d.ts +309 -11
- package/lib/engine/engine_materialpropertyblock.js +396 -36
- package/lib/engine/engine_materialpropertyblock.js.map +1 -1
- package/lib/engine/engine_math.d.ts +34 -1
- package/lib/engine/engine_math.js +34 -1
- package/lib/engine/engine_math.js.map +1 -1
- package/lib/engine/engine_networking.js +1 -1
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_types.d.ts +2 -0
- package/lib/engine/engine_types.js +2 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/webcomponents/icons.js +3 -0
- package/lib/engine/webcomponents/icons.js.map +1 -1
- package/lib/engine/webcomponents/logo-element.d.ts +1 -0
- package/lib/engine/webcomponents/logo-element.js +3 -1
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle-button.d.ts +37 -11
- package/lib/engine/webcomponents/needle-button.js +42 -11
- package/lib/engine/webcomponents/needle-button.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +10 -2
- package/lib/engine/webcomponents/needle-engine.js +13 -3
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/Component.d.ts +1 -2
- package/lib/engine-components/Component.js +1 -2
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +1 -0
- package/lib/engine-components/DragControls.js +21 -0
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/Duplicatable.js.map +1 -1
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/NeedleMenu.d.ts +2 -0
- package/lib/engine-components/NeedleMenu.js +2 -0
- package/lib/engine-components/NeedleMenu.js.map +1 -1
- package/lib/engine-components/NestedGltf.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +28 -3
- package/lib/engine-components/Networking.js +28 -3
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +33 -3
- package/lib/engine-components/ReflectionProbe.js +76 -27
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +2 -0
- package/lib/engine-components/Renderer.js +30 -6
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RendererLightmap.js +2 -3
- package/lib/engine-components/RendererLightmap.js.map +1 -1
- package/lib/engine-components/SeeThrough.d.ts +0 -2
- package/lib/engine-components/SeeThrough.js +114 -88
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/SmoothFollow.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +107 -13
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +167 -30
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
- package/lib/engine-components/ui/Button.d.ts +1 -0
- package/lib/engine-components/ui/Button.js +11 -0
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/engine-components/ui/Text.d.ts +1 -0
- package/lib/engine-components/ui/Text.js +11 -0
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/web/ViewBox.d.ts +2 -2
- package/lib/engine-components/web/ViewBox.js +2 -2
- package/lib/engine-components/web/ViewBox.js.map +1 -1
- package/lib/engine-components/webxr/WebXRPlaneTracking.js.map +1 -1
- package/lib/engine-components/webxr/controllers/XRControllerFollow.js.map +1 -1
- package/lib/engine-components/webxr/controllers/XRControllerMovement.js.map +1 -1
- package/package.json +4 -4
- package/src/engine/api.ts +371 -19
- package/src/engine/engine_accessibility.ts +178 -0
- package/src/engine/engine_context.ts +9 -0
- package/src/engine/engine_materialpropertyblock.ts +499 -42
- package/src/engine/engine_math.ts +34 -1
- package/src/engine/engine_networking.ts +1 -1
- package/src/engine/engine_types.ts +5 -0
- package/src/engine/webcomponents/icons.ts +3 -0
- package/src/engine/webcomponents/logo-element.ts +4 -1
- package/src/engine/webcomponents/needle-button.ts +44 -13
- package/src/engine/webcomponents/needle-engine.ts +18 -7
- package/src/engine-components/Camera.ts +2 -2
- package/src/engine-components/Component.ts +1 -3
- package/src/engine-components/DragControls.ts +29 -4
- package/src/engine-components/DropListener.ts +1 -1
- package/src/engine-components/Duplicatable.ts +1 -1
- package/src/engine-components/GroundProjection.ts +3 -0
- package/src/engine-components/NeedleMenu.ts +8 -3
- package/src/engine-components/NestedGltf.ts +1 -1
- package/src/engine-components/Networking.ts +29 -4
- package/src/engine-components/ReflectionProbe.ts +81 -31
- package/src/engine-components/Renderer.ts +34 -6
- package/src/engine-components/RendererLightmap.ts +2 -3
- package/src/engine-components/SeeThrough.ts +122 -107
- package/src/engine-components/SmoothFollow.ts +2 -2
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +198 -65
- package/src/engine-components/ui/Button.ts +13 -1
- package/src/engine-components/ui/Raycaster.ts +1 -1
- package/src/engine-components/ui/Text.ts +13 -0
- package/src/engine-components/web/ViewBox.ts +9 -2
- package/src/engine-components/webxr/WebXRPlaneTracking.ts +3 -3
- package/src/engine-components/webxr/controllers/XRControllerFollow.ts +1 -1
- package/src/engine-components/webxr/controllers/XRControllerMovement.ts +4 -4
|
@@ -254,7 +254,40 @@ class LowPassFilter {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
/**
|
|
257
|
-
* OneEuroFilter is a
|
|
257
|
+
* [OneEuroFilter](https://engine.needle.tools/docs/api/OneEuroFilter) is a low-pass filter designed to reduce jitter in noisy signals while maintaining low latency.
|
|
258
|
+
* It's particularly useful for smoothing tracking data from XR controllers, hand tracking, or other input devices where the signal contains noise but responsiveness is important.
|
|
259
|
+
*
|
|
260
|
+
* The filter automatically adapts its smoothing strength based on the signal's velocity:
|
|
261
|
+
* - When the signal moves slowly, it applies strong smoothing to reduce jitter
|
|
262
|
+
* - When the signal moves quickly, it reduces smoothing to maintain responsiveness
|
|
263
|
+
*
|
|
264
|
+
* Based on the research paper: [1€ Filter: A Simple Speed-based Low-pass Filter for Noisy Input](http://cristal.univ-lille.fr/~casiez/1euro/)
|
|
265
|
+
*
|
|
266
|
+
* @example Basic usage with timestamp
|
|
267
|
+
* ```ts
|
|
268
|
+
* const filter = new OneEuroFilter(120, 1.0, 0.0);
|
|
269
|
+
*
|
|
270
|
+
* // In your update loop:
|
|
271
|
+
* const smoothedValue = filter.filter(noisyValue, this.context.time.time);
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @example Without timestamps (using frequency estimate)
|
|
275
|
+
* ```ts
|
|
276
|
+
* // Assuming 60 FPS update rate
|
|
277
|
+
* const filter = new OneEuroFilter(60, 1.0, 0.5);
|
|
278
|
+
*
|
|
279
|
+
* // Call without timestamp - uses the frequency estimate
|
|
280
|
+
* const smoothedValue = filter.filter(noisyValue);
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* @example Smoothing 3D positions
|
|
284
|
+
* ```ts
|
|
285
|
+
* const posFilter = new OneEuroFilterXYZ(90, 0.5, 0.0);
|
|
286
|
+
*
|
|
287
|
+
* posFilter.filter(trackedPosition, smoothedPosition, this.context.time.time);
|
|
288
|
+
* ```
|
|
289
|
+
*
|
|
290
|
+
* @see {@link OneEuroFilterXYZ} for filtering 3D vectors
|
|
258
291
|
*/
|
|
259
292
|
export class OneEuroFilter {
|
|
260
293
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const defaultNetworkingBackendUrlProvider = "https://urls.needle.tools/default-networking-backend/index";
|
|
2
|
-
let networkingServerUrl: string | undefined = "wss://networking.needle.tools/socket";
|
|
2
|
+
let networkingServerUrl: string | undefined = "wss://networking-2.needle.tools/socket";
|
|
3
3
|
|
|
4
4
|
import * as flatbuffers from 'flatbuffers';
|
|
5
5
|
import { type Websocket } from 'websocket-ts';
|
|
@@ -164,10 +164,15 @@ export interface IHasGuid {
|
|
|
164
164
|
guid: string;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
// DO NOT CHANGE THE SYMBOL NAME
|
|
168
|
+
export const $componentName = Symbol("component-name");
|
|
169
|
+
|
|
167
170
|
// TODO: we might want to separate the IComponent and IBehaviour where the Behaviour is the one with custom methods and the component only has e.g. the gameobject reference
|
|
168
171
|
export interface IComponent extends IHasGuid {
|
|
169
172
|
get isComponent(): boolean;
|
|
170
173
|
|
|
174
|
+
get [$componentName](): string | undefined;
|
|
175
|
+
|
|
171
176
|
/** the object this component is attached to */
|
|
172
177
|
gameObject: IGameObject;
|
|
173
178
|
// guid: string;
|
|
@@ -17,6 +17,9 @@ export function getIconElement(str: string): HTMLElement {
|
|
|
17
17
|
span.innerText = str;
|
|
18
18
|
span.style.visibility = "hidden";
|
|
19
19
|
span.style.userSelect = "none";
|
|
20
|
+
span.setAttribute("role", "img");
|
|
21
|
+
span.setAttribute("aria-label", str + " icon");
|
|
22
|
+
span.setAttribute("aria-hidden", "true");
|
|
20
23
|
fontReady(fontname).then(res => {
|
|
21
24
|
if (res) span.style.visibility = "";
|
|
22
25
|
else {
|
|
@@ -84,8 +84,11 @@ export class NeedleLogoElement extends HTMLElement {
|
|
|
84
84
|
globalThis.open("https://needle.tools", "_blank");
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
connectedCallback() {
|
|
88
90
|
this.wrapper.setAttribute("title", "Made with Needle Engine");
|
|
91
|
+
this.setAttribute("aria-label", "Needle Engine logo. Click to open the Needle Engine website.");
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
private readonly _root: ShadowRoot;
|
|
@@ -13,32 +13,58 @@ const htmlTagName = "needle-button";
|
|
|
13
13
|
const isDev = isDevEnvironment();
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* [<needle-button>](https://engine.needle.tools/docs/api/NeedleButtonElement) is a web component for easily adding AR, VR, Quicklook, or QR code buttons to your website without writing JavaScript code.
|
|
17
|
+
*
|
|
18
|
+
* The button automatically handles session management and displays appropriate UI based on device capabilities.
|
|
19
|
+
* It comes with default styling (glassmorphism design) but can be fully customized with CSS.
|
|
20
|
+
*
|
|
21
|
+
* **Supported button types:**
|
|
22
|
+
* - `ar` - WebXR AR session button
|
|
23
|
+
* - `vr` - WebXR VR session button
|
|
24
|
+
* - `quicklook` - Apple AR Quick Look button (iOS only)
|
|
25
|
+
* - `qrcode` - QR code sharing button
|
|
26
|
+
*
|
|
27
|
+
* @example Basic AR/VR buttons
|
|
18
28
|
* ```html
|
|
29
|
+
* <needle-engine src="scene.glb"></needle-engine>
|
|
19
30
|
* <needle-button ar></needle-button>
|
|
20
31
|
* <needle-button vr></needle-button>
|
|
21
32
|
* <needle-button quicklook></needle-button>
|
|
22
33
|
* ```
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
34
|
+
*
|
|
35
|
+
* @example Custom button labels
|
|
25
36
|
* ```html
|
|
26
|
-
* <needle-button ar>Start AR</needle-button>
|
|
27
|
-
* <needle-button vr>
|
|
37
|
+
* <needle-button ar>Start AR Experience</needle-button>
|
|
38
|
+
* <needle-button vr>Enter VR Mode</needle-button>
|
|
28
39
|
* <needle-button quicklook>View in AR</needle-button>
|
|
29
40
|
* ```
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
41
|
+
*
|
|
42
|
+
* @example Custom styling
|
|
32
43
|
* ```html
|
|
33
|
-
* <!-- You can either style the element directly or use a CSS stylesheet -->
|
|
34
44
|
* <style>
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
45
|
+
* needle-button {
|
|
46
|
+
* background-color: #ff6b6b;
|
|
47
|
+
* color: white;
|
|
48
|
+
* border-radius: 8px;
|
|
49
|
+
* padding: 1rem 2rem;
|
|
50
|
+
* }
|
|
51
|
+
* needle-button:hover {
|
|
52
|
+
* background-color: #ff5252;
|
|
53
|
+
* }
|
|
39
54
|
* </style>
|
|
40
55
|
* <needle-button ar>Start AR</needle-button>
|
|
41
56
|
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example Unstyled button (for complete custom styling)
|
|
59
|
+
* ```html
|
|
60
|
+
* <needle-button ar unstyled>
|
|
61
|
+
* <span class="my-icon">🥽</span>
|
|
62
|
+
* Launch AR
|
|
63
|
+
* </needle-button>
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @see {@link NeedleEngineWebComponent} for the main <needle-engine> element
|
|
67
|
+
* @see {@link NeedleMenu} for the built-in menu component that can display similar buttons
|
|
42
68
|
*/
|
|
43
69
|
export class NeedleButtonElement extends HTMLElement {
|
|
44
70
|
|
|
@@ -73,18 +99,22 @@ export class NeedleButtonElement extends HTMLElement {
|
|
|
73
99
|
if (this.getAttribute("ar") != null) {
|
|
74
100
|
this.#webxrfactory ??= new WebXRButtonFactory()
|
|
75
101
|
this.#button = this.#webxrfactory.createARButton();
|
|
102
|
+
this.setAttribute("aria-label", "Enter augmented reality mode");
|
|
76
103
|
}
|
|
77
104
|
else if (this.getAttribute("vr") != null) {
|
|
78
105
|
this.#webxrfactory ??= new WebXRButtonFactory()
|
|
79
106
|
this.#button = this.#webxrfactory.createVRButton();
|
|
107
|
+
this.setAttribute("aria-label", "Enter virtual reality mode");
|
|
80
108
|
}
|
|
81
109
|
else if (this.getAttribute("quicklook") != null) {
|
|
82
110
|
this.#webxrfactory ??= new WebXRButtonFactory()
|
|
83
111
|
this.#button = this.#webxrfactory.createQuicklookButton();
|
|
112
|
+
this.setAttribute("aria-label", "View in AR with Apple Quick Look");
|
|
84
113
|
}
|
|
85
114
|
else if (this.getAttribute("qrcode") != null) {
|
|
86
115
|
this.#buttonfactory ??= new ButtonsFactory();
|
|
87
116
|
this.#button = this.#buttonfactory.createQRCode({ anchorElement: this });
|
|
117
|
+
this.setAttribute("aria-label", "Share application with QR code");
|
|
88
118
|
}
|
|
89
119
|
else {
|
|
90
120
|
if (isDev) {
|
|
@@ -93,6 +123,7 @@ export class NeedleButtonElement extends HTMLElement {
|
|
|
93
123
|
else {
|
|
94
124
|
console.debug("No button type specified for <needle-button>. Use either ar, vr or quicklook attribute.")
|
|
95
125
|
}
|
|
126
|
+
this.setAttribute("aria-label", "Needle Button with no specified type");
|
|
96
127
|
return;
|
|
97
128
|
}
|
|
98
129
|
|
|
@@ -87,17 +87,25 @@ const observedAttributes = [
|
|
|
87
87
|
|
|
88
88
|
// https://developers.google.com/web/fundamentals/web-components/customelements
|
|
89
89
|
|
|
90
|
-
/**
|
|
91
|
-
* The `<needle-engine>` web component. See {@link NeedleEngineAttributes} attributes for supported attributes
|
|
92
|
-
* The web component creates and manages a Needle Engine context, which is responsible for rendering a 3D scene using threejs.
|
|
93
|
-
* The context is created when the `src` attribute is set, and disposed when the element is removed from the DOM. You can prevent cleanup by setting the `keep-alive` attribute to `true`.
|
|
90
|
+
/**
|
|
91
|
+
* The `<needle-engine>` web component. See {@link NeedleEngineAttributes} attributes for supported attributes
|
|
92
|
+
* The web component creates and manages a Needle Engine context, which is responsible for rendering a 3D scene using threejs.
|
|
93
|
+
* The context is created when the `src` attribute is set, and disposed when the element is removed from the DOM. You can prevent cleanup by setting the `keep-alive` attribute to `true`.
|
|
94
94
|
* The context is accessible from the `<needle-engine>` element: `document.querySelector("needle-engine").context`.
|
|
95
95
|
* See {@link https://engine.needle.tools/docs/reference/needle-engine-attributes}
|
|
96
96
|
*
|
|
97
|
-
* @example
|
|
97
|
+
* @example Basic usage
|
|
98
|
+
* ```html
|
|
98
99
|
* <needle-engine src="https://example.com/scene.glb"></needle-engine>
|
|
99
|
-
*
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example With camera controls disabled
|
|
103
|
+
* ```html
|
|
100
104
|
* <needle-engine src="https://example.com/scene.glb" camera-controls="false"></needle-engine>
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @see {@link NeedleButtonElement} for adding AR/VR/Quicklook buttons via <needle-button>
|
|
108
|
+
* @see {@link NeedleMenu} for the built-in menu configuration component
|
|
101
109
|
*/
|
|
102
110
|
export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngineComponent {
|
|
103
111
|
|
|
@@ -176,7 +184,9 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
176
184
|
|
|
177
185
|
ensureFonts();
|
|
178
186
|
|
|
179
|
-
this.attachShadow({ mode: 'open' });
|
|
187
|
+
this.attachShadow({ mode: 'open', delegatesFocus: true });
|
|
188
|
+
this.setAttribute("role", "application");
|
|
189
|
+
this.setAttribute("aria-label", "Needle Engine 3D scene");
|
|
180
190
|
const template = document.createElement('template');
|
|
181
191
|
// #region CSS
|
|
182
192
|
template.innerHTML = `<style>
|
|
@@ -282,6 +292,7 @@ export class NeedleEngineWebComponent extends HTMLElement implements INeedleEngi
|
|
|
282
292
|
if (this.getAttribute("tabindex") === null || this.getAttribute("tabindex") === undefined)
|
|
283
293
|
this.setAttribute("tabindex", "0");
|
|
284
294
|
|
|
295
|
+
|
|
285
296
|
this.addEventListener("xr-session-started", this.onXRSessionStarted);
|
|
286
297
|
this.onSetupDesktop();
|
|
287
298
|
|
|
@@ -132,7 +132,7 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
132
132
|
*/
|
|
133
133
|
get nearClipPlane(): number { return this._nearClipPlane; }
|
|
134
134
|
@serializable()
|
|
135
|
-
set nearClipPlane(val) {
|
|
135
|
+
set nearClipPlane(val: number) {
|
|
136
136
|
const changed = this._nearClipPlane != val;
|
|
137
137
|
this._nearClipPlane = val;
|
|
138
138
|
if (this._cam && (changed || this._cam.near != val)) {
|
|
@@ -149,7 +149,7 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
149
149
|
*/
|
|
150
150
|
get farClipPlane(): number { return this._farClipPlane; }
|
|
151
151
|
@serializable()
|
|
152
|
-
set farClipPlane(val) {
|
|
152
|
+
set farClipPlane(val: number) {
|
|
153
153
|
const changed = this._farClipPlane != val;
|
|
154
154
|
this._farClipPlane = val;
|
|
155
155
|
if (this._cam && (changed || this._cam.far != val)) {
|
|
@@ -10,7 +10,7 @@ import * as main from "../engine/engine_mainloop_utils.js";
|
|
|
10
10
|
import { syncDestroy, syncInstantiate, SyncInstantiateOptions } from "../engine/engine_networking_instantiate.js";
|
|
11
11
|
import { Context, FrameEvent } from "../engine/engine_setup.js";
|
|
12
12
|
import * as threeutils from "../engine/engine_three_utils.js";
|
|
13
|
-
import type
|
|
13
|
+
import { $componentName, type Collision, type ComponentInit, type Constructor, type ConstructorConcrete, type GuidsMap, type ICollider, type IComponent, type IGameObject, type SourceIdentifier } from "../engine/engine_types.js";
|
|
14
14
|
import { TypeStore } from "../engine/engine_typestore.js";
|
|
15
15
|
import type { INeedleXRSessionEventReceiver, NeedleXRControllerEventArgs, NeedleXREventArgs } from "../engine/engine_xr.js";
|
|
16
16
|
import { type IPointerEventHandler, PointerEventData } from "./ui/PointerEvents.js";
|
|
@@ -542,8 +542,6 @@ export abstract class GameObject extends Object3D implements Object3D, IGameObje
|
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
-
// DO NOT CHANGE THE SYMBOL NAME
|
|
546
|
-
const $componentName = Symbol("component-name");
|
|
547
545
|
|
|
548
546
|
/**
|
|
549
547
|
* Needle Engine component's are the main building blocks of the Needle Engine.
|
|
@@ -193,7 +193,7 @@ export class DragControls extends Behaviour implements IPointerEventHandler {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
|
|
197
197
|
private _rigidbody: Rigidbody | null = null;
|
|
198
198
|
|
|
199
199
|
// future:
|
|
@@ -235,12 +235,22 @@ export class DragControls extends Behaviour implements IPointerEventHandler {
|
|
|
235
235
|
/** @internal */
|
|
236
236
|
onEnable(): void {
|
|
237
237
|
DragControls._instances.push(this);
|
|
238
|
+
this.context.accessibility.updateElement(this, {
|
|
239
|
+
role: "button",
|
|
240
|
+
label: "Drag " + (this.gameObject.name || "object"),
|
|
241
|
+
hidden: false,
|
|
242
|
+
});
|
|
238
243
|
}
|
|
239
244
|
/** @internal */
|
|
240
245
|
onDisable(): void {
|
|
246
|
+
this.context.accessibility.updateElement(this, { hidden: true });
|
|
241
247
|
DragControls._instances = DragControls._instances.filter(i => i !== this);
|
|
242
248
|
}
|
|
243
249
|
|
|
250
|
+
onDestroy(): void {
|
|
251
|
+
this.context.accessibility.removeElement(this);
|
|
252
|
+
}
|
|
253
|
+
|
|
244
254
|
/**
|
|
245
255
|
* Checks if editing is allowed for the current networking connection.
|
|
246
256
|
* @param _obj Optional object to check edit permissions for
|
|
@@ -268,6 +278,8 @@ export class DragControls extends Behaviour implements IPointerEventHandler {
|
|
|
268
278
|
if (!dc || dc !== this) return;
|
|
269
279
|
DragControls.lastHovered = evt.object;
|
|
270
280
|
this.context.domElement.style.cursor = 'pointer';
|
|
281
|
+
|
|
282
|
+
this.context.accessibility.hover(this, `Draggable ${evt.object?.name}`);
|
|
271
283
|
}
|
|
272
284
|
|
|
273
285
|
/**
|
|
@@ -339,6 +351,14 @@ export class DragControls extends Behaviour implements IPointerEventHandler {
|
|
|
339
351
|
}
|
|
340
352
|
|
|
341
353
|
args.use();
|
|
354
|
+
|
|
355
|
+
this.context.accessibility.updateElement(this, {
|
|
356
|
+
role: "button",
|
|
357
|
+
label: "Dragging " + (this.gameObject.name || "object"),
|
|
358
|
+
hidden: false,
|
|
359
|
+
busy: true,
|
|
360
|
+
});
|
|
361
|
+
this.context.accessibility.focus(this);
|
|
342
362
|
}
|
|
343
363
|
}
|
|
344
364
|
|
|
@@ -375,6 +395,11 @@ export class DragControls extends Behaviour implements IPointerEventHandler {
|
|
|
375
395
|
}
|
|
376
396
|
args.use();
|
|
377
397
|
}
|
|
398
|
+
|
|
399
|
+
this.context.accessibility.unfocus(this);
|
|
400
|
+
this.context.accessibility.updateElement(this, {
|
|
401
|
+
busy: false,
|
|
402
|
+
});
|
|
378
403
|
}
|
|
379
404
|
|
|
380
405
|
/**
|
|
@@ -779,12 +804,12 @@ class DragPointerHandler implements IDragHandler {
|
|
|
779
804
|
* Used for determining if enough motion has occurred to start a drag.
|
|
780
805
|
*/
|
|
781
806
|
getTotalMovement(): Vector3 { return this._totalMovement; }
|
|
782
|
-
|
|
807
|
+
|
|
783
808
|
/**
|
|
784
809
|
* Returns the object that follows the pointer during dragging operations.
|
|
785
810
|
*/
|
|
786
811
|
get followObject(): GameObject { return this._followObject; }
|
|
787
|
-
|
|
812
|
+
|
|
788
813
|
/**
|
|
789
814
|
* Returns the point where the pointer initially hit the object in local space.
|
|
790
815
|
*/
|
|
@@ -1377,7 +1402,7 @@ class LegacyDragVisualsHelper {
|
|
|
1377
1402
|
|
|
1378
1403
|
/** Controls whether visual helpers like lines and markers are displayed */
|
|
1379
1404
|
showGizmo: boolean = true;
|
|
1380
|
-
|
|
1405
|
+
|
|
1381
1406
|
/** When true, drag plane alignment changes based on view angle */
|
|
1382
1407
|
useViewAngle: boolean = true;
|
|
1383
1408
|
|
|
@@ -181,7 +181,7 @@ export class DropListener extends Behaviour {
|
|
|
181
181
|
* Only used when fitIntoVolume is enabled.
|
|
182
182
|
*/
|
|
183
183
|
@serializable(Vector3)
|
|
184
|
-
fitVolumeSize = new Vector3(1, 1, 1);
|
|
184
|
+
fitVolumeSize: Vector3 = new Vector3(1, 1, 1);
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
187
|
* When enabled, dropped objects will be positioned at the point where the cursor hit the scene.
|
|
@@ -5,7 +5,10 @@ import { Gizmos } from "../engine/engine_gizmos.js";
|
|
|
5
5
|
import { serializable } from "../engine/engine_serialization_decorator.js";
|
|
6
6
|
import { getBoundingBox, getTempVector, getWorldScale, Graphics, setVisibleInCustomShadowRendering, setWorldPosition } from "../engine/engine_three_utils.js";
|
|
7
7
|
import { delayForFrames, getParam, Watch as Watch } from "../engine/engine_utils.js";
|
|
8
|
+
// Type-only imports for TSDoc @see links
|
|
9
|
+
import type { Camera } from "./Camera.js";
|
|
8
10
|
import { Behaviour } from "./Component.js";
|
|
11
|
+
import type { ContactShadows } from "./ContactShadows.js";
|
|
9
12
|
|
|
10
13
|
const debug = getParam("debuggroundprojection");
|
|
11
14
|
|
|
@@ -2,12 +2,15 @@ import type { Context } from '../engine/engine_context.js';
|
|
|
2
2
|
import { serializable } from '../engine/engine_serialization.js';
|
|
3
3
|
import { DeviceUtilities } from '../engine/engine_utils.js';
|
|
4
4
|
import { Behaviour } from './Component.js';
|
|
5
|
+
// Type-only imports for TSDoc @see links
|
|
6
|
+
import type { ScreenCapture } from './ScreenCapture.js';
|
|
7
|
+
import type { Voip } from './Voip.js';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* [NeedleMenu](https://engine.needle.tools/docs/api/NeedleMenu) provides configuration for the built-in UI menu.
|
|
8
11
|
* The menu renders as HTML overlay in browser mode and automatically
|
|
9
|
-
* switches to a 3D spatial menu in VR/AR.
|
|
10
|
-
*
|
|
12
|
+
* switches to a 3D spatial menu in VR/AR.
|
|
13
|
+
*
|
|
11
14
|
* 
|
|
12
15
|
*
|
|
13
16
|
* **Features:**
|
|
@@ -15,7 +18,7 @@ import { Behaviour } from './Component.js';
|
|
|
15
18
|
* - Audio mute/unmute button
|
|
16
19
|
* - QR code sharing (desktop only)
|
|
17
20
|
* - Spatial menu in XR (appears when looking up)
|
|
18
|
-
* - Custom positioning (top/bottom)
|
|
21
|
+
* - Custom positioning (top/bottom)
|
|
19
22
|
*
|
|
20
23
|
* **Programmatic access:**
|
|
21
24
|
* Access the menu API via `this.context.menu` to add custom buttons,
|
|
@@ -33,6 +36,8 @@ import { Behaviour } from './Component.js';
|
|
|
33
36
|
* @category User Interface
|
|
34
37
|
* @group Components
|
|
35
38
|
* @see {@link Context.menu} for programmatic menu control
|
|
39
|
+
* @see {@link NeedleButtonElement} for standalone <needle-button> web component
|
|
40
|
+
* @see {@link NeedleEngineWebComponent} for the main <needle-engine> element
|
|
36
41
|
* @see {@link Voip} adds a microphone button to the menu
|
|
37
42
|
* @see {@link ScreenCapture} adds a screen sharing button
|
|
38
43
|
**/
|
|
@@ -7,10 +7,34 @@ import { Behaviour } from "./Component.js";
|
|
|
7
7
|
const debug = getParam("debugnet");
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Provides configuration
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Provides websocket URL configuration for the built-in networking system.
|
|
11
|
+
* Add this component to override the default networking backend URL used by {@link NetworkConnection} (`this.context.connection`).
|
|
12
|
+
*
|
|
13
|
+
* The component registers itself as a URL provider on `awake()`. When the networking system connects,
|
|
14
|
+
* it queries this provider for the websocket URL to use instead of the default Needle networking backend.
|
|
15
|
+
*
|
|
16
|
+
* **URL resolution order:**
|
|
17
|
+
* 1. If `urlParameterName` is set and the corresponding URL parameter exists in the browser URL, that value is used
|
|
18
|
+
* 2. If running on a local network and `localhost` is set, the `localhost` URL is used
|
|
19
|
+
* 3. Otherwise, the `url` field is used
|
|
20
|
+
*
|
|
21
|
+
* Without this component, the default backend URL `wss://networking-2.needle.tools/socket` is used.
|
|
22
|
+
*
|
|
23
|
+
* **Note:** This component only configures the websocket URL. To actually join a networked room,
|
|
24
|
+
* use a `SyncedRoom` component or call `this.context.connection.joinRoom("room-name")` directly.
|
|
25
|
+
*
|
|
26
|
+
* @example Overriding the URL via browser parameter
|
|
27
|
+
* ```ts
|
|
28
|
+
* // With urlParameterName="server", visiting:
|
|
29
|
+
* // https://myapp.com/?server=wss://my-server.com/socket
|
|
30
|
+
* // will connect to that server instead
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @see {@link NetworkConnection} for the main networking API (`this.context.connection`)
|
|
34
|
+
* @see {@link SyncedRoom} for automatic room joining
|
|
35
|
+
* @see {@link OwnershipModel} for networked object ownership
|
|
36
|
+
* @see {@link RoomEvents} for room lifecycle events
|
|
37
|
+
* @link https://engine.needle.tools/docs/how-to-guides/networking/
|
|
14
38
|
* @summary Networking configuration
|
|
15
39
|
* @category Networking
|
|
16
40
|
* @group Components
|
|
@@ -20,6 +44,7 @@ export class Networking extends Behaviour implements INetworkingWebsocketUrlProv
|
|
|
20
44
|
/**
|
|
21
45
|
* The websocket URL to connect to for networking functionality.
|
|
22
46
|
* Can be a complete URL or a relative path that will be resolved against the current origin.
|
|
47
|
+
* @default null
|
|
23
48
|
*/
|
|
24
49
|
@serializable()
|
|
25
50
|
url: string | null = null;
|