@needle-tools/engine 4.14.0-next.52fdb13 → 4.14.0
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/components.needle.json +1 -1
- package/dist/{needle-engine.bundle-DJE-Bjpa.umd.cjs → needle-engine.bundle-COL2Bar3.umd.cjs} +120 -128
- package/dist/{needle-engine.bundle-BwfaInTa.min.js → needle-engine.bundle-NolzHLqO.min.js} +129 -137
- package/dist/{needle-engine.bundle-TmE5-_na.js → needle-engine.bundle-Z_gAD7Kg.js} +5214 -5459
- package/dist/needle-engine.d.ts +42 -299
- package/dist/needle-engine.js +569 -570
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/engine_context.d.ts +0 -2
- package/lib/engine/engine_context.js +0 -7
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_materialpropertyblock.d.ts +4 -90
- package/lib/engine/engine_materialpropertyblock.js +7 -97
- package/lib/engine/engine_materialpropertyblock.js.map +1 -1
- package/lib/engine/engine_math.d.ts +1 -34
- package/lib/engine/engine_math.js +1 -34
- 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 +0 -2
- package/lib/engine/engine_types.js +0 -2
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/webcomponents/icons.js +0 -3
- package/lib/engine/webcomponents/icons.js.map +1 -1
- package/lib/engine/webcomponents/logo-element.d.ts +0 -1
- package/lib/engine/webcomponents/logo-element.js +1 -3
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle-button.d.ts +11 -37
- package/lib/engine/webcomponents/needle-button.js +11 -42
- package/lib/engine/webcomponents/needle-button.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +2 -10
- package/lib/engine/webcomponents/needle-engine.js +3 -13
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine-components/Component.d.ts +2 -1
- package/lib/engine-components/Component.js +2 -1
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +0 -1
- package/lib/engine-components/DragControls.js +0 -21
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/NeedleMenu.d.ts +0 -2
- package/lib/engine-components/NeedleMenu.js +0 -2
- package/lib/engine-components/NeedleMenu.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +3 -28
- package/lib/engine-components/Networking.js +3 -28
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +0 -1
- package/lib/engine-components/ReflectionProbe.js +2 -20
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +0 -15
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +0 -77
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
- package/lib/engine-components/ui/Button.d.ts +0 -1
- package/lib/engine-components/ui/Button.js +0 -11
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/Text.d.ts +0 -1
- package/lib/engine-components/ui/Text.js +0 -11
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/package.json +2 -2
- package/src/engine/engine_context.ts +0 -9
- package/src/engine/engine_materialpropertyblock.ts +11 -102
- package/src/engine/engine_math.ts +1 -34
- package/src/engine/engine_networking.ts +1 -1
- package/src/engine/engine_types.ts +0 -5
- package/src/engine/webcomponents/icons.ts +0 -3
- package/src/engine/webcomponents/logo-element.ts +1 -4
- package/src/engine/webcomponents/needle-button.ts +13 -44
- package/src/engine/webcomponents/needle-engine.ts +7 -18
- package/src/engine-components/Component.ts +3 -1
- package/src/engine-components/DragControls.ts +4 -29
- package/src/engine-components/NeedleMenu.ts +3 -5
- package/src/engine-components/Networking.ts +4 -29
- package/src/engine-components/ReflectionProbe.ts +2 -21
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +32 -108
- package/src/engine-components/ui/Button.ts +0 -12
- package/src/engine-components/ui/Text.ts +0 -13
- package/lib/engine/engine_accessibility.d.ts +0 -58
- package/lib/engine/engine_accessibility.js +0 -143
- package/lib/engine/engine_accessibility.js.map +0 -1
- package/src/engine/engine_accessibility.ts +0 -178
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { Object3D } from "three";
|
|
2
|
-
import type { Context } from "./engine_setup";
|
|
3
|
-
import { IComponent, isComponent } from "./engine_types";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** Data describing the accessible semantics for a 3D object or component. */
|
|
8
|
-
type AccessibilityData = {
|
|
9
|
-
/** ARIA role (e.g. `"button"`, `"img"`, `"region"`). */
|
|
10
|
-
role: string;
|
|
11
|
-
/** Human-readable label announced by screen readers. */
|
|
12
|
-
label: string;
|
|
13
|
-
/** When `true`, the element is hidden from the accessibility tree. */
|
|
14
|
-
hidden?: boolean;
|
|
15
|
-
/** When `true`, indicates the element's content is being updated. */
|
|
16
|
-
busy?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Manages an accessible, screen-reader-friendly overlay for a Needle Engine {@link Context}.
|
|
21
|
-
*
|
|
22
|
-
* The manager maintains a visually-hidden DOM tree that mirrors relevant 3D scene objects
|
|
23
|
-
* with appropriate ARIA roles and labels. It also provides a live region so that hover
|
|
24
|
-
* events in the 3D scene can be announced to assistive technology without stealing focus.
|
|
25
|
-
*/
|
|
26
|
-
export class AccessibilityManager {
|
|
27
|
-
|
|
28
|
-
private static readonly _managers: WeakMap<object, AccessibilityManager> = new WeakMap();
|
|
29
|
-
|
|
30
|
-
/** Returns the {@link AccessibilityManager} associated with the given context or component. */
|
|
31
|
-
static get(obj: Context | IComponent) {
|
|
32
|
-
if (isComponent(obj)) {
|
|
33
|
-
return this._managers.get(obj.context);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return this._managers.get(obj);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
constructor(
|
|
41
|
-
private readonly context: Context
|
|
42
|
-
) {
|
|
43
|
-
this.root.style.cssText = `
|
|
44
|
-
position: absolute;
|
|
45
|
-
width: 1px; height: 1px;
|
|
46
|
-
padding: 0; margin: -1px;
|
|
47
|
-
overflow: hidden;
|
|
48
|
-
clip: rect(0, 0, 0, 0);
|
|
49
|
-
white-space: nowrap;
|
|
50
|
-
border: 0;
|
|
51
|
-
`
|
|
52
|
-
this.root.setAttribute("role", "region");
|
|
53
|
-
this.root.setAttribute("aria-label", "3D Needle Engine scene");
|
|
54
|
-
|
|
55
|
-
// Live region for announcing hovered 3D elements without stealing focus
|
|
56
|
-
this.liveRegion.setAttribute("aria-live", "polite");
|
|
57
|
-
this.liveRegion.setAttribute("aria-atomic", "true");
|
|
58
|
-
this.liveRegion.setAttribute("role", "status");
|
|
59
|
-
this.root.appendChild(this.liveRegion);
|
|
60
|
-
this.enabled = true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private _enabled!: boolean;
|
|
64
|
-
/** Enables or disables the accessibility overlay. When disabled, the overlay DOM is removed. */
|
|
65
|
-
set enabled(value: boolean) {
|
|
66
|
-
if (value === this._enabled) return;
|
|
67
|
-
this._enabled = value;
|
|
68
|
-
if (!value) {
|
|
69
|
-
this.root.remove();
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
AccessibilityManager._managers.set(this.context, this);
|
|
73
|
-
const target = this.context.domElement.shadowRoot || this.context.domElement;
|
|
74
|
-
target.prepend(this.root);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** Removes all tracked accessibility elements, keeping only the live region. */
|
|
79
|
-
clear() {
|
|
80
|
-
this.root.childNodes.forEach(child => child.remove());
|
|
81
|
-
this.root.appendChild(this.liveRegion);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** Removes the overlay from the DOM and unregisters this manager from the context. */
|
|
85
|
-
dispose() {
|
|
86
|
-
this.root.remove();
|
|
87
|
-
AccessibilityManager._managers.delete(this.context);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private readonly root: HTMLElement = document.createElement("div");
|
|
91
|
-
private readonly liveRegion: HTMLElement = document.createElement("div");
|
|
92
|
-
private readonly treeElements = new WeakMap<object, HTMLElement>();
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Creates or updates the accessible DOM element for a 3D object or component.
|
|
96
|
-
* @param obj - The scene object or component to represent.
|
|
97
|
-
* @param data - Partial accessibility data (role, label, hidden, busy) to apply.
|
|
98
|
-
*/
|
|
99
|
-
updateElement<T extends Object3D | IComponent>(obj: T, data: Partial<AccessibilityData>) {
|
|
100
|
-
let el = this.treeElements.get(obj);
|
|
101
|
-
if (!el) {
|
|
102
|
-
el = document.createElement("div");
|
|
103
|
-
this.treeElements.set(obj, el);
|
|
104
|
-
this.root.appendChild(el);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
let didSetRole = false;
|
|
108
|
-
|
|
109
|
-
if (typeof data === "object") {
|
|
110
|
-
if (data.role) {
|
|
111
|
-
didSetRole = true;
|
|
112
|
-
el.setAttribute("role", data.role);
|
|
113
|
-
}
|
|
114
|
-
if (data.label) {
|
|
115
|
-
el.setAttribute("aria-label", data.label);
|
|
116
|
-
}
|
|
117
|
-
if (data.hidden !== undefined) {
|
|
118
|
-
el.setAttribute("aria-hidden", String(data.hidden));
|
|
119
|
-
}
|
|
120
|
-
if (data.busy !== undefined) {
|
|
121
|
-
el.setAttribute("aria-busy", String(data.busy));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// if (didSetRole) {
|
|
127
|
-
// const role = el.getAttribute("role");
|
|
128
|
-
// if (role) {
|
|
129
|
-
// el.setAttribute("tabindex", "0");
|
|
130
|
-
// } else {
|
|
131
|
-
// el.removeAttribute("tabindex");
|
|
132
|
-
// }
|
|
133
|
-
// }
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/** Moves keyboard focus to the accessible element representing the given object. */
|
|
139
|
-
focus<T extends Object3D | IComponent>(obj: T) {
|
|
140
|
-
const el = this.treeElements.get(obj);
|
|
141
|
-
if (el) {
|
|
142
|
-
// if (!el.hasAttribute("tabindex")) {
|
|
143
|
-
// el.setAttribute("tabindex", "0");
|
|
144
|
-
// }
|
|
145
|
-
el.focus();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
/** Removes keyboard focus from the accessible element representing the given object. */
|
|
149
|
-
unfocus<T extends Object3D | IComponent>(obj: T) {
|
|
150
|
-
const el = this.treeElements.get(obj);
|
|
151
|
-
if (el) {
|
|
152
|
-
el.blur();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Announces a hover event to screen readers via the ARIA live region.
|
|
158
|
-
* @param obj - The hovered object (used to look up its label if `text` is not provided).
|
|
159
|
-
* @param text - Optional text to announce. Falls back to the element's `aria-label`.
|
|
160
|
-
*/
|
|
161
|
-
hover<T extends Object3D | IComponent>(obj: T, text?: string) {
|
|
162
|
-
const el = this.treeElements.get(obj);
|
|
163
|
-
// Update the live region text — screen reader announces this without stealing focus
|
|
164
|
-
this.liveRegion.textContent = text || el?.getAttribute("aria-label") || "";
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/** Removes the accessible DOM element for the given object and stops tracking it. */
|
|
168
|
-
removeElement(obj: Object3D | IComponent) {
|
|
169
|
-
const el = this.treeElements.get(obj);
|
|
170
|
-
el?.remove();
|
|
171
|
-
this.treeElements.delete(obj);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
private set liveRegionMode(mode: "polite" | "assertive") {
|
|
175
|
-
this.liveRegion.setAttribute("aria-live", mode);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
}
|