@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.
Files changed (142) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/components.needle.json +1 -1
  3. package/dist/{generateMeshBVH.worker-DFcS3P04.js → generateMeshBVH.worker-DiCnZlf3.js} +1 -1
  4. package/dist/{gltf-progressive-8voIgNp_.js → gltf-progressive-Bm_6aEi4.js} +4 -4
  5. package/dist/{gltf-progressive-BRRBj-nY.umd.cjs → gltf-progressive-BttGBXw6.umd.cjs} +3 -3
  6. package/dist/{gltf-progressive-Dkh3tG4-.min.js → gltf-progressive-T5WKTux5.min.js} +1 -1
  7. package/dist/{loader.worker-C6cXDgR1.js → loader.worker-BqODMeeW.js} +1 -1
  8. package/dist/{materialx-Dx8st96L.min.js → materialx-CJyQZtjt.min.js} +1 -1
  9. package/dist/{materialx-D66rYPqe.js → materialx-DMs1E08Z.js} +2 -2
  10. package/dist/{materialx-CxlgposR.umd.cjs → materialx-DaKKOoVk.umd.cjs} +1 -1
  11. package/dist/{needle-engine.bundle-D7w0XD7M.min.js → needle-engine.bundle-BwfaInTa.min.js} +156 -148
  12. package/dist/{needle-engine.bundle-BQXG5qbQ.umd.cjs → needle-engine.bundle-DJE-Bjpa.umd.cjs} +141 -133
  13. package/dist/{needle-engine.bundle-Byl5i6zJ.js → needle-engine.bundle-TmE5-_na.js} +6741 -6449
  14. package/dist/needle-engine.d.ts +896 -51
  15. package/dist/needle-engine.js +571 -570
  16. package/dist/needle-engine.min.js +1 -1
  17. package/dist/needle-engine.umd.cjs +1 -1
  18. package/dist/{postprocessing-Ce5-UWiA.min.js → postprocessing-06AXuvdv.min.js} +2 -2
  19. package/dist/{postprocessing-BkSpxpYB.js → postprocessing-CI2x8Cln.js} +4 -4
  20. package/dist/{postprocessing-DFVElmAh.umd.cjs → postprocessing-CPDcA21P.umd.cjs} +2 -2
  21. package/dist/{three-Bad8p1pf.umd.cjs → three-BjYim-vL.umd.cjs} +47 -47
  22. package/dist/{three-DFV1-P9z.js → three-Bvk2VKbF.js} +2 -2
  23. package/dist/{three-CWn13_u1.min.js → three-IG2qPafA.min.js} +2 -2
  24. package/dist/{three-examples-CO-tx3Sp.umd.cjs → three-examples-BMmNgNCN.umd.cjs} +1 -1
  25. package/dist/{three-examples-43yqn3mL.js → three-examples-CMYCd5nH.js} +1 -1
  26. package/dist/{three-examples-DKuJVGT4.min.js → three-examples-CQl1fFZp.min.js} +1 -1
  27. package/dist/{three-mesh-ui-DyEA5HQF.min.js → three-mesh-ui-5HVE2RV-.min.js} +1 -1
  28. package/dist/{three-mesh-ui-fSAQJxdI.js → three-mesh-ui-BlakAItG.js} +1 -1
  29. package/dist/{three-mesh-ui-ChzVOraf.umd.cjs → three-mesh-ui-D828VbQp.umd.cjs} +1 -1
  30. package/dist/{vendor-pe19S9r5.min.js → vendor-BxK0WKmT.min.js} +1 -1
  31. package/dist/{vendor-B51YffMU.umd.cjs → vendor-CIDkyBaO.umd.cjs} +1 -1
  32. package/dist/{vendor-CgpZ5ivC.js → vendor-ixwD-vv2.js} +1 -1
  33. package/lib/engine/api.d.ts +203 -18
  34. package/lib/engine/api.js +271 -18
  35. package/lib/engine/api.js.map +1 -1
  36. package/lib/engine/engine_accessibility.d.ts +58 -0
  37. package/lib/engine/engine_accessibility.js +143 -0
  38. package/lib/engine/engine_accessibility.js.map +1 -0
  39. package/lib/engine/engine_context.d.ts +2 -0
  40. package/lib/engine/engine_context.js +7 -0
  41. package/lib/engine/engine_context.js.map +1 -1
  42. package/lib/engine/engine_materialpropertyblock.d.ts +309 -11
  43. package/lib/engine/engine_materialpropertyblock.js +396 -36
  44. package/lib/engine/engine_materialpropertyblock.js.map +1 -1
  45. package/lib/engine/engine_math.d.ts +34 -1
  46. package/lib/engine/engine_math.js +34 -1
  47. package/lib/engine/engine_math.js.map +1 -1
  48. package/lib/engine/engine_networking.js +1 -1
  49. package/lib/engine/engine_networking.js.map +1 -1
  50. package/lib/engine/engine_types.d.ts +2 -0
  51. package/lib/engine/engine_types.js +2 -0
  52. package/lib/engine/engine_types.js.map +1 -1
  53. package/lib/engine/webcomponents/icons.js +3 -0
  54. package/lib/engine/webcomponents/icons.js.map +1 -1
  55. package/lib/engine/webcomponents/logo-element.d.ts +1 -0
  56. package/lib/engine/webcomponents/logo-element.js +3 -1
  57. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  58. package/lib/engine/webcomponents/needle-button.d.ts +37 -11
  59. package/lib/engine/webcomponents/needle-button.js +42 -11
  60. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  61. package/lib/engine/webcomponents/needle-engine.d.ts +10 -2
  62. package/lib/engine/webcomponents/needle-engine.js +13 -3
  63. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  64. package/lib/engine-components/Camera.js.map +1 -1
  65. package/lib/engine-components/Component.d.ts +1 -2
  66. package/lib/engine-components/Component.js +1 -2
  67. package/lib/engine-components/Component.js.map +1 -1
  68. package/lib/engine-components/DragControls.d.ts +1 -0
  69. package/lib/engine-components/DragControls.js +21 -0
  70. package/lib/engine-components/DragControls.js.map +1 -1
  71. package/lib/engine-components/DropListener.js.map +1 -1
  72. package/lib/engine-components/Duplicatable.js.map +1 -1
  73. package/lib/engine-components/GroundProjection.js.map +1 -1
  74. package/lib/engine-components/NeedleMenu.d.ts +2 -0
  75. package/lib/engine-components/NeedleMenu.js +2 -0
  76. package/lib/engine-components/NeedleMenu.js.map +1 -1
  77. package/lib/engine-components/NestedGltf.js.map +1 -1
  78. package/lib/engine-components/Networking.d.ts +28 -3
  79. package/lib/engine-components/Networking.js +28 -3
  80. package/lib/engine-components/Networking.js.map +1 -1
  81. package/lib/engine-components/ReflectionProbe.d.ts +33 -3
  82. package/lib/engine-components/ReflectionProbe.js +76 -27
  83. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  84. package/lib/engine-components/Renderer.d.ts +2 -0
  85. package/lib/engine-components/Renderer.js +30 -6
  86. package/lib/engine-components/Renderer.js.map +1 -1
  87. package/lib/engine-components/RendererLightmap.js +2 -3
  88. package/lib/engine-components/RendererLightmap.js.map +1 -1
  89. package/lib/engine-components/SeeThrough.d.ts +0 -2
  90. package/lib/engine-components/SeeThrough.js +114 -88
  91. package/lib/engine-components/SeeThrough.js.map +1 -1
  92. package/lib/engine-components/SmoothFollow.js.map +1 -1
  93. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +107 -13
  94. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +167 -30
  95. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
  96. package/lib/engine-components/ui/Button.d.ts +1 -0
  97. package/lib/engine-components/ui/Button.js +11 -0
  98. package/lib/engine-components/ui/Button.js.map +1 -1
  99. package/lib/engine-components/ui/Raycaster.js.map +1 -1
  100. package/lib/engine-components/ui/Text.d.ts +1 -0
  101. package/lib/engine-components/ui/Text.js +11 -0
  102. package/lib/engine-components/ui/Text.js.map +1 -1
  103. package/lib/engine-components/web/ViewBox.d.ts +2 -2
  104. package/lib/engine-components/web/ViewBox.js +2 -2
  105. package/lib/engine-components/web/ViewBox.js.map +1 -1
  106. package/lib/engine-components/webxr/WebXRPlaneTracking.js.map +1 -1
  107. package/lib/engine-components/webxr/controllers/XRControllerFollow.js.map +1 -1
  108. package/lib/engine-components/webxr/controllers/XRControllerMovement.js.map +1 -1
  109. package/package.json +4 -4
  110. package/src/engine/api.ts +371 -19
  111. package/src/engine/engine_accessibility.ts +178 -0
  112. package/src/engine/engine_context.ts +9 -0
  113. package/src/engine/engine_materialpropertyblock.ts +499 -42
  114. package/src/engine/engine_math.ts +34 -1
  115. package/src/engine/engine_networking.ts +1 -1
  116. package/src/engine/engine_types.ts +5 -0
  117. package/src/engine/webcomponents/icons.ts +3 -0
  118. package/src/engine/webcomponents/logo-element.ts +4 -1
  119. package/src/engine/webcomponents/needle-button.ts +44 -13
  120. package/src/engine/webcomponents/needle-engine.ts +18 -7
  121. package/src/engine-components/Camera.ts +2 -2
  122. package/src/engine-components/Component.ts +1 -3
  123. package/src/engine-components/DragControls.ts +29 -4
  124. package/src/engine-components/DropListener.ts +1 -1
  125. package/src/engine-components/Duplicatable.ts +1 -1
  126. package/src/engine-components/GroundProjection.ts +3 -0
  127. package/src/engine-components/NeedleMenu.ts +8 -3
  128. package/src/engine-components/NestedGltf.ts +1 -1
  129. package/src/engine-components/Networking.ts +29 -4
  130. package/src/engine-components/ReflectionProbe.ts +81 -31
  131. package/src/engine-components/Renderer.ts +34 -6
  132. package/src/engine-components/RendererLightmap.ts +2 -3
  133. package/src/engine-components/SeeThrough.ts +122 -107
  134. package/src/engine-components/SmoothFollow.ts +2 -2
  135. package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +198 -65
  136. package/src/engine-components/ui/Button.ts +13 -1
  137. package/src/engine-components/ui/Raycaster.ts +1 -1
  138. package/src/engine-components/ui/Text.ts +13 -0
  139. package/src/engine-components/web/ViewBox.ts +9 -2
  140. package/src/engine-components/webxr/WebXRPlaneTracking.ts +3 -3
  141. package/src/engine-components/webxr/controllers/XRControllerFollow.ts +1 -1
  142. package/src/engine-components/webxr/controllers/XRControllerMovement.ts +4 -4
package/lib/engine/api.js CHANGED
@@ -1,86 +1,339 @@
1
1
  /**
2
- * Contains core functionality for Needle Engine.
3
- * This includes
4
- * - Context Management
5
- * - Asset Loading
6
- * - Component Lifecycle
7
- * - Time Handling
8
- * - XR support
9
- * - Unified Input Handling
10
- * - Needle Menu
11
- * - Networking
12
- * - Physics, Collisions, Raycasting
13
- * - Math and Filtering Helpers
14
- * - Rendering Utilities
15
- * - Debugging Utilities, Gizmos
16
- * - User agent detection
17
- * - and more.
2
+ * The Engine Core API is the main entry point for Needle Engine functionality.
3
+ * It provides a unified interface for building interactive 3D web experiences
4
+ * with features spanning rendering, physics, networking, XR, and more.
5
+ *
6
+ * ## Quick Start
7
+ * ```typescript
8
+ * import { Context, Behaviour, serializable } from "@needle-tools/engine";
9
+ *
10
+ * class MyComponent extends Behaviour {
11
+ * @serializable()
12
+ * speed: number = 1;
13
+ *
14
+ * update() {
15
+ * this.gameObject.rotateY(this.context.time.deltaTime * this.speed);
16
+ * }
17
+ * }
18
+ * ```
19
+ *
20
+ * ## Module Categories
21
+ *
22
+ * ### Context & Application
23
+ * The {@link Context} class is the central hub that manages the scene, renderer, camera,
24
+ * and all engine systems. Access it via `this.context` in any component.
25
+ * - {@link Context} - Main engine context managing scene, renderer, and systems
26
+ * - {@link ContextRegistry} - Registry for multiple engine contexts
27
+ * - {@link Application} - Application-level utilities and state
28
+ *
29
+ * ### Components & GameObjects
30
+ * Needle Engine uses a component-based architecture similar to Unity.
31
+ * Components are attached to three.js Object3D instances (GameObjects).
32
+ * - {@link addComponent}, {@link getComponent}, {@link removeComponent} - Component management
33
+ * - {@link findObjectOfType}, {@link findObjectsOfType} - Scene queries
34
+ * - {@link instantiate}, {@link destroy} - Object lifecycle
35
+ * @see {@link https://engine.needle.tools/docs/scripting.html | Scripting Documentation}
36
+ *
37
+ * ### Asset Loading
38
+ * Load glTF/GLB files, textures, and other assets at runtime.
39
+ * - {@link loadSync}, {@link parseSync} - Load glTF/GLB assets
40
+ * - {@link AssetDatabase} - Asset reference management
41
+ * - {@link Addressables} - Addressable asset system
42
+ * @see {@link https://engine.needle.tools/docs/addressables.html | Addressables Documentation}
43
+ *
44
+ * ### Input System
45
+ * Unified input handling for mouse, touch, keyboard, and XR controllers.
46
+ * Access via `this.context.input` in components.
47
+ * - {@link Input} - Unified input manager
48
+ * - {@link NEPointerEvent} - Cross-platform pointer events
49
+ * - {@link InputEvents} - Event types for input listeners
50
+ * @see {@link https://engine.needle.tools/docs/input.html | Input Documentation}
51
+ *
52
+ * ### Physics & Raycasting
53
+ * Rapier-based physics engine with collision detection and raycasting.
54
+ * - {@link Physics} - Physics world access and raycasting
55
+ * - {@link RaycastOptions} - Configure raycast behavior
56
+ * - {@link Collision}, {@link ContactPoint} - Collision data types
57
+ * @see {@link https://engine.needle.tools/docs/physics.html | Physics Documentation}
58
+ *
59
+ * ### Networking
60
+ * Real-time multiplayer networking with automatic state synchronization.
61
+ * - {@link NetworkConnection} - WebSocket connection management
62
+ * - {@link RoomEvents} - Room join/leave events
63
+ * - {@link syncField} - Decorator for automatic field synchronization
64
+ * - {@link PeerNetworking} - WebRTC peer-to-peer connections
65
+ * @see {@link https://engine.needle.tools/docs/networking.html | Networking Documentation}
66
+ *
67
+ * ### XR (AR/VR)
68
+ * WebXR support for augmented and virtual reality experiences.
69
+ * - {@link NeedleXRSession} - XR session management
70
+ * - {@link NeedleXRController} - XR controller input and tracking
71
+ * - {@link XRRig} - XR camera rig configuration
72
+ * @see {@link https://engine.needle.tools/docs/xr.html | XR Documentation}
73
+ *
74
+ * ### Time & Animation
75
+ * Frame timing and animation utilities.
76
+ * - {@link Time} - Delta time, frame count, time scale
77
+ * - {@link AnimationUtils} - Animation playback helpers
78
+ * - Coroutines via {@link startCoroutine} for async sequences
79
+ *
80
+ * ### Debugging & Gizmos
81
+ * Visual debugging tools for development.
82
+ * - {@link Gizmos} - Draw debug shapes (lines, spheres, boxes)
83
+ * - {@link showBalloonMessage}, {@link showBalloonWarning} - On-screen messages
84
+ * - {@link isDevEnvironment} - Check if running in development mode
85
+ *
86
+ * ### Utilities
87
+ * Helper functions for common operations.
88
+ * - {@link getParam} - URL parameter parsing
89
+ * - {@link delay} - Promise-based delay
90
+ * - {@link generateQRCode} - QR code generation
91
+ * - Math utilities: {@link Mathf}, vector operations
18
92
  *
19
93
  * @module Engine Core
94
+ * @see {@link https://engine.needle.tools/docs/ | Needle Engine Documentation}
20
95
  */
96
+ // ============================================================================
97
+ // DEBUGGING & DEVELOPMENT
98
+ // Debugging utilities, gizmos, and development tools.
99
+ // ============================================================================
21
100
  export * from "./debug/index.js";
101
+ // ============================================================================
102
+ // ASSET LOADING & MANAGEMENT
103
+ // Systems for loading, managing, and referencing assets at runtime.
104
+ // ============================================================================
105
+ /** Addressable asset system for loading assets by address/label */
22
106
  export * from "./engine_addressables.js";
107
+ /** Animation playback and control utilities */
23
108
  export { AnimationUtils } from "./engine_animation.js";
109
+ /** Application-level state and utilities */
24
110
  export { Application } from "./engine_application.js";
111
+ /** Asset database for managing asset references */
25
112
  export * from "./engine_assetdatabase.js";
113
+ // ============================================================================
114
+ // CAMERA & RENDERING
115
+ // Camera control, rendering utilities, and visual effects.
116
+ // ============================================================================
117
+ /** Camera fitting utilities for framing objects */
26
118
  export * from "./engine_camera.fit.js";
119
+ /** Camera controller management and auto-fit configuration */
27
120
  export { getCameraController, setAutoFitEnabled, setCameraController, useForAutoFit } from "./engine_camera.js";
121
+ // ============================================================================
122
+ // COMPONENTS & GAMEOBJECTS
123
+ // Component-based architecture for building interactive 3D content.
124
+ // Functions for adding, removing, and querying components on objects.
125
+ // ============================================================================
126
+ /**
127
+ * Component management functions: addComponent, getComponent, removeComponent, etc.
128
+ * @see {@link https://engine.needle.tools/docs/scripting.html | Scripting Documentation}
129
+ */
28
130
  export * from "./engine_components.js";
131
+ /** Internal component lifecycle events and management */
29
132
  export * from "./engine_components_internal.js";
30
- export * from "./engine_components_internal.js";
133
+ /** Engine constants and configuration values */
31
134
  export * from "./engine_constants.js";
135
+ // ============================================================================
136
+ // CONTEXT & LIFECYCLE
137
+ // Core engine context and application lifecycle management.
138
+ // ============================================================================
139
+ /**
140
+ * Main engine context class - the central hub for all engine systems.
141
+ * Provides access to scene, renderer, camera, input, physics, networking, and more.
142
+ * @see {@link https://engine.needle.tools/docs/scripting.html#context | Context Documentation}
143
+ */
32
144
  export * from "./engine_context.js";
145
+ /** Registry for managing multiple engine contexts */
33
146
  export * from "./engine_context_registry.js";
147
+ /**
148
+ * Coroutine system for async sequences in components.
149
+ * Use startCoroutine() for frame-based async operations.
150
+ */
34
151
  export * from "./engine_coroutine.js";
152
+ /** Factory functions for creating primitives and objects */
35
153
  export * from "./engine_create_objects.js";
154
+ /** Feature flags for enabling/disabling engine features */
36
155
  export * from "./engine_feature_flags.js";
156
+ /**
157
+ * GameObject utilities: instantiate, destroy, find, traverse.
158
+ * @see {@link https://engine.needle.tools/docs/scripting.html#finding-objects | Finding Objects}
159
+ */
37
160
  export * from "./engine_gameobject.js";
161
+ /**
162
+ * Visual debugging with Gizmos - draw lines, spheres, boxes for debugging.
163
+ * @see {@link https://engine.needle.tools/docs/debugging.html | Debugging Documentation}
164
+ */
38
165
  export { Gizmos } from "./engine_gizmos.js";
166
+ /** glTF/GLB loader registration and management */
39
167
  export * from "./engine_gltf.js";
168
+ /** Hot reload support for development */
40
169
  export * from "./engine_hot_reload.js";
170
+ // ============================================================================
171
+ // INPUT SYSTEM
172
+ // Unified input handling for mouse, touch, keyboard, and XR controllers.
173
+ // ============================================================================
174
+ /**
175
+ * Unified input system supporting mouse, touch, keyboard, and XR controllers.
176
+ * Access via this.context.input in components.
177
+ * @see {@link https://engine.needle.tools/docs/input.html | Input Documentation}
178
+ */
41
179
  export * from "./engine_input.js";
180
+ // ============================================================================
181
+ // INSTANCING & PERFORMANCE
182
+ // GPU instancing and performance optimization utilities.
183
+ // ============================================================================
184
+ /** GPU instancing utilities for rendering many similar objects efficiently */
42
185
  export { InstancingUtil } from "./engine_instancing.js";
186
+ /** License checking utilities */
43
187
  export { hasCommercialLicense, hasIndieLicense, hasProLicense } from "./engine_license.js";
188
+ // ============================================================================
189
+ // LIFECYCLE & LOADING
190
+ // Component lifecycle hooks and asset loading systems.
191
+ // ============================================================================
192
+ /** Lifecycle API for registering global callbacks */
44
193
  export * from "./engine_lifecycle_api.js";
194
+ /** Model loader callbacks for customizing load behavior */
45
195
  export { NeedleEngineModelLoader } from "./engine_loaders.callbacks.js";
196
+ /**
197
+ * Asset loading functions: loadSync, parseSync for glTF/GLB files.
198
+ * @see {@link https://engine.needle.tools/docs/addressables.html | Loading Assets}
199
+ */
46
200
  export { loadAsset, loadSync, parseSync } from "./engine_loaders.js";
201
+ // ============================================================================
202
+ // MATERIALS & RENDERING
203
+ // Material utilities and rendering helpers.
204
+ // ============================================================================
205
+ /** MaterialPropertyBlock for efficient material property overrides per-instance */
206
+ export { MaterialPropertyBlock } from "./engine_materialpropertyblock.js";
207
+ /** Math utilities: Mathf, interpolation, easing functions */
47
208
  export * from "./engine_math.js";
209
+ /** Engine modules registry */
48
210
  export { MODULES as NEEDLE_ENGINE_MODULES } from "./engine_modules.js";
211
+ // ============================================================================
212
+ // NETWORKING
213
+ // Real-time multiplayer networking with WebSocket and WebRTC support.
214
+ // ============================================================================
215
+ /**
216
+ * Core networking: NetworkConnection, RoomEvents, OwnershipEvent.
217
+ * @see {@link https://engine.needle.tools/docs/networking.html | Networking Documentation}
218
+ */
49
219
  export * from "./engine_networking.js";
220
+ /**
221
+ * @syncField decorator for automatic field synchronization across clients.
222
+ * @see {@link https://engine.needle.tools/docs/networking.html#synced-variables | Synced Variables}
223
+ */
50
224
  export { syncField } from "./engine_networking_auto.js";
225
+ /** Blob/binary data transfer over network */
51
226
  export * from "./engine_networking_blob.js";
227
+ /** File transfer utilities for networking */
52
228
  export * from "./engine_networking_files.js";
229
+ /**
230
+ * Network instantiation for spawning synced objects.
231
+ * @see {@link https://engine.needle.tools/docs/networking.html#spawning-objects | Spawning Objects}
232
+ */
53
233
  export * from "./engine_networking_instantiate.js";
234
+ /** WebRTC peer-to-peer networking for direct client connections */
54
235
  export * from "./engine_networking_peer.js";
236
+ /** Media streaming utilities (audio/video) */
55
237
  export * from "./engine_networking_streams.js";
238
+ /** Networking type definitions and interfaces */
56
239
  export * from "./engine_networking_types.js";
240
+ /** Networking utility functions */
57
241
  export * from "./engine_networking_utils.js";
58
- export { MaterialPropertyBlock } from "./engine_materialpropertyblock.js";
242
+ // ============================================================================
243
+ // PHYSICS & RAYCASTING
244
+ // Rapier-based physics simulation and raycasting.
245
+ // ============================================================================
246
+ /** Object patching utilities */
59
247
  export * from "./engine_patcher.js";
248
+ /**
249
+ * Physics system: raycasting, collision queries, physics world access.
250
+ * @see {@link https://engine.needle.tools/docs/physics.html | Physics Documentation}
251
+ */
60
252
  export * from "./engine_physics.js";
253
+ /** Physics type definitions: RaycastOptions, Collision, ContactPoint */
61
254
  export * from "./engine_physics.types.js";
255
+ /** Rapier physics engine integration */
62
256
  export * from "./engine_physics_rapier.js";
257
+ // ============================================================================
258
+ // PLAYER & VIEW MANAGEMENT
259
+ // Multi-player view management and scene lighting.
260
+ // ============================================================================
261
+ /** Player view management for multi-user scenarios */
63
262
  export * from "./engine_playerview.js";
263
+ /** PMREM (Prefiltered Mipmapped Radiance Environment Map) loading */
64
264
  export { loadPMREM } from "./engine_pmrem.js";
265
+ /** Scene lighting data and environment configuration */
65
266
  export * from "./engine_scenelighting.js";
267
+ // ============================================================================
268
+ // SERIALIZATION
269
+ // Component serialization for saving/loading and networking.
270
+ // ============================================================================
271
+ /**
272
+ * Serialization utilities for components and objects.
273
+ * @see {@link https://engine.needle.tools/docs/scripting.html#serialization | Serialization Documentation}
274
+ */
66
275
  export * from "./engine_serialization.js";
276
+ // ============================================================================
277
+ // UTILITIES & HELPERS
278
+ // General-purpose utility functions and helpers.
279
+ // ============================================================================
280
+ /** Testing utilities for automated tests */
67
281
  export * from "./engine_test_utils.js";
282
+ /** Texture utilities and processing */
68
283
  export * from "./engine_texture.js";
284
+ /** Three.js helper utilities: getWorldPosition, getTempVector, etc. */
69
285
  export * from "./engine_three_utils.js";
286
+ /**
287
+ * Time class: deltaTime, time, frameCount, timeScale.
288
+ * Access via this.context.time in components.
289
+ */
70
290
  export * from "./engine_time.js";
291
+ /** Time-related utility functions */
71
292
  export * from "./engine_time_utils.js";
293
+ /** Core type definitions and interfaces */
72
294
  export * from "./engine_types.js";
295
+ /** Type registration for component discovery */
73
296
  export { registerType, TypeStore } from "./engine_typestore.js";
297
+ /** Decorator utilities: @prefix, @validate */
74
298
  export { prefix, validate } from "./engine_util_decorator.js";
299
+ /** General utilities: getParam, delay, DeviceUtilities, etc. */
75
300
  export * from "./engine_utils.js";
301
+ /** Formatting utilities for strings and numbers */
76
302
  export * from "./engine_utils_format.js";
303
+ /** QR code generation utility */
77
304
  export { generateQRCode } from "./engine_utils_qrcode.js";
305
+ /** Screenshot capture utilities */
78
306
  export * from "./engine_utils_screenshot.js";
307
+ // ============================================================================
308
+ // EXTENSIONS & INTEGRATIONS
309
+ // glTF extensions and JavaScript object extensions.
310
+ // ============================================================================
311
+ /** Export utilities and formats */
79
312
  export * from "./export/index.js";
313
+ /** glTF extension implementations (NEEDLE_components, etc.) */
80
314
  export * from "./extensions/index.js";
315
+ /** JavaScript object extensions for three.js objects */
81
316
  export * from "./js-extensions/index.js";
317
+ // ============================================================================
318
+ // WEB COMPONENTS
319
+ // Custom HTML elements for embedding Needle Engine.
320
+ // ============================================================================
321
+ /** Web component API utilities */
82
322
  export * from "./webcomponents/api.js";
323
+ /**
324
+ * <needle-engine> web component for embedding 3D scenes.
325
+ * @see {@link https://engine.needle.tools/docs/html.html | HTML Integration}
326
+ */
83
327
  export * from "./webcomponents/needle-engine.js";
328
+ /** Loading screen and progress indicators */
84
329
  export * from "./webcomponents/needle-engine.loading.js";
330
+ // ============================================================================
331
+ // XR (AR/VR)
332
+ // WebXR support for augmented and virtual reality experiences.
333
+ // ============================================================================
334
+ /**
335
+ * XR API: NeedleXRSession, NeedleXRController, XRRig.
336
+ * @see {@link https://engine.needle.tools/docs/xr.html | XR Documentation}
337
+ */
85
338
  export * from "./xr/api.js";
86
339
  //# sourceMappingURL=api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/engine/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;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GzC,+EAA+E;AAC/E,iBAAiB;AACjB,oDAAoD;AACpD,+EAA+E;AAE/E,kCAAkC;AAClC,cAAc,wBAAwB,CAAA;AAEtC;;;GAGG;AACH,cAAc,kCAAkC,CAAC;AAEjD,6CAA6C;AAC7C,cAAc,0CAA0C,CAAC;AAGzD,+EAA+E;AAC/E,aAAa;AACb,+DAA+D;AAC/D,+EAA+E;AAE/E;;;GAGG;AACH,cAAc,aAAa,CAAA"}
@@ -0,0 +1,58 @@
1
+ import { Object3D } from "three";
2
+ import type { Context } from "./engine_setup";
3
+ import { IComponent } from "./engine_types";
4
+ /** Data describing the accessible semantics for a 3D object or component. */
5
+ type AccessibilityData = {
6
+ /** ARIA role (e.g. `"button"`, `"img"`, `"region"`). */
7
+ role: string;
8
+ /** Human-readable label announced by screen readers. */
9
+ label: string;
10
+ /** When `true`, the element is hidden from the accessibility tree. */
11
+ hidden?: boolean;
12
+ /** When `true`, indicates the element's content is being updated. */
13
+ busy?: boolean;
14
+ };
15
+ /**
16
+ * Manages an accessible, screen-reader-friendly overlay for a Needle Engine {@link Context}.
17
+ *
18
+ * The manager maintains a visually-hidden DOM tree that mirrors relevant 3D scene objects
19
+ * with appropriate ARIA roles and labels. It also provides a live region so that hover
20
+ * events in the 3D scene can be announced to assistive technology without stealing focus.
21
+ */
22
+ export declare class AccessibilityManager {
23
+ private readonly context;
24
+ private static readonly _managers;
25
+ /** Returns the {@link AccessibilityManager} associated with the given context or component. */
26
+ static get(obj: Context | IComponent): AccessibilityManager | undefined;
27
+ constructor(context: Context);
28
+ private _enabled;
29
+ /** Enables or disables the accessibility overlay. When disabled, the overlay DOM is removed. */
30
+ set enabled(value: boolean);
31
+ /** Removes all tracked accessibility elements, keeping only the live region. */
32
+ clear(): void;
33
+ /** Removes the overlay from the DOM and unregisters this manager from the context. */
34
+ dispose(): void;
35
+ private readonly root;
36
+ private readonly liveRegion;
37
+ private readonly treeElements;
38
+ /**
39
+ * Creates or updates the accessible DOM element for a 3D object or component.
40
+ * @param obj - The scene object or component to represent.
41
+ * @param data - Partial accessibility data (role, label, hidden, busy) to apply.
42
+ */
43
+ updateElement<T extends Object3D | IComponent>(obj: T, data: Partial<AccessibilityData>): void;
44
+ /** Moves keyboard focus to the accessible element representing the given object. */
45
+ focus<T extends Object3D | IComponent>(obj: T): void;
46
+ /** Removes keyboard focus from the accessible element representing the given object. */
47
+ unfocus<T extends Object3D | IComponent>(obj: T): void;
48
+ /**
49
+ * Announces a hover event to screen readers via the ARIA live region.
50
+ * @param obj - The hovered object (used to look up its label if `text` is not provided).
51
+ * @param text - Optional text to announce. Falls back to the element's `aria-label`.
52
+ */
53
+ hover<T extends Object3D | IComponent>(obj: T, text?: string): void;
54
+ /** Removes the accessible DOM element for the given object and stops tracking it. */
55
+ removeElement(obj: Object3D | IComponent): void;
56
+ private set liveRegionMode(value);
57
+ }
58
+ export {};
@@ -0,0 +1,143 @@
1
+ import { isComponent } from "./engine_types";
2
+ /**
3
+ * Manages an accessible, screen-reader-friendly overlay for a Needle Engine {@link Context}.
4
+ *
5
+ * The manager maintains a visually-hidden DOM tree that mirrors relevant 3D scene objects
6
+ * with appropriate ARIA roles and labels. It also provides a live region so that hover
7
+ * events in the 3D scene can be announced to assistive technology without stealing focus.
8
+ */
9
+ export class AccessibilityManager {
10
+ context;
11
+ static _managers = new WeakMap();
12
+ /** Returns the {@link AccessibilityManager} associated with the given context or component. */
13
+ static get(obj) {
14
+ if (isComponent(obj)) {
15
+ return this._managers.get(obj.context);
16
+ }
17
+ else {
18
+ return this._managers.get(obj);
19
+ }
20
+ }
21
+ constructor(context) {
22
+ this.context = context;
23
+ this.root.style.cssText = `
24
+ position: absolute;
25
+ width: 1px; height: 1px;
26
+ padding: 0; margin: -1px;
27
+ overflow: hidden;
28
+ clip: rect(0, 0, 0, 0);
29
+ white-space: nowrap;
30
+ border: 0;
31
+ `;
32
+ this.root.setAttribute("role", "region");
33
+ this.root.setAttribute("aria-label", "3D Needle Engine scene");
34
+ // Live region for announcing hovered 3D elements without stealing focus
35
+ this.liveRegion.setAttribute("aria-live", "polite");
36
+ this.liveRegion.setAttribute("aria-atomic", "true");
37
+ this.liveRegion.setAttribute("role", "status");
38
+ this.root.appendChild(this.liveRegion);
39
+ this.enabled = true;
40
+ }
41
+ _enabled;
42
+ /** Enables or disables the accessibility overlay. When disabled, the overlay DOM is removed. */
43
+ set enabled(value) {
44
+ if (value === this._enabled)
45
+ return;
46
+ this._enabled = value;
47
+ if (!value) {
48
+ this.root.remove();
49
+ }
50
+ else {
51
+ AccessibilityManager._managers.set(this.context, this);
52
+ const target = this.context.domElement.shadowRoot || this.context.domElement;
53
+ target.prepend(this.root);
54
+ }
55
+ }
56
+ /** Removes all tracked accessibility elements, keeping only the live region. */
57
+ clear() {
58
+ this.root.childNodes.forEach(child => child.remove());
59
+ this.root.appendChild(this.liveRegion);
60
+ }
61
+ /** Removes the overlay from the DOM and unregisters this manager from the context. */
62
+ dispose() {
63
+ this.root.remove();
64
+ AccessibilityManager._managers.delete(this.context);
65
+ }
66
+ root = document.createElement("div");
67
+ liveRegion = document.createElement("div");
68
+ treeElements = new WeakMap();
69
+ /**
70
+ * Creates or updates the accessible DOM element for a 3D object or component.
71
+ * @param obj - The scene object or component to represent.
72
+ * @param data - Partial accessibility data (role, label, hidden, busy) to apply.
73
+ */
74
+ updateElement(obj, data) {
75
+ let el = this.treeElements.get(obj);
76
+ if (!el) {
77
+ el = document.createElement("div");
78
+ this.treeElements.set(obj, el);
79
+ this.root.appendChild(el);
80
+ let didSetRole = false;
81
+ if (typeof data === "object") {
82
+ if (data.role) {
83
+ didSetRole = true;
84
+ el.setAttribute("role", data.role);
85
+ }
86
+ if (data.label) {
87
+ el.setAttribute("aria-label", data.label);
88
+ }
89
+ if (data.hidden !== undefined) {
90
+ el.setAttribute("aria-hidden", String(data.hidden));
91
+ }
92
+ if (data.busy !== undefined) {
93
+ el.setAttribute("aria-busy", String(data.busy));
94
+ }
95
+ }
96
+ // if (didSetRole) {
97
+ // const role = el.getAttribute("role");
98
+ // if (role) {
99
+ // el.setAttribute("tabindex", "0");
100
+ // } else {
101
+ // el.removeAttribute("tabindex");
102
+ // }
103
+ // }
104
+ }
105
+ }
106
+ /** Moves keyboard focus to the accessible element representing the given object. */
107
+ focus(obj) {
108
+ const el = this.treeElements.get(obj);
109
+ if (el) {
110
+ // if (!el.hasAttribute("tabindex")) {
111
+ // el.setAttribute("tabindex", "0");
112
+ // }
113
+ el.focus();
114
+ }
115
+ }
116
+ /** Removes keyboard focus from the accessible element representing the given object. */
117
+ unfocus(obj) {
118
+ const el = this.treeElements.get(obj);
119
+ if (el) {
120
+ el.blur();
121
+ }
122
+ }
123
+ /**
124
+ * Announces a hover event to screen readers via the ARIA live region.
125
+ * @param obj - The hovered object (used to look up its label if `text` is not provided).
126
+ * @param text - Optional text to announce. Falls back to the element's `aria-label`.
127
+ */
128
+ hover(obj, text) {
129
+ const el = this.treeElements.get(obj);
130
+ // Update the live region text — screen reader announces this without stealing focus
131
+ this.liveRegion.textContent = text || el?.getAttribute("aria-label") || "";
132
+ }
133
+ /** Removes the accessible DOM element for the given object and stops tracking it. */
134
+ removeElement(obj) {
135
+ const el = this.treeElements.get(obj);
136
+ el?.remove();
137
+ this.treeElements.delete(obj);
138
+ }
139
+ set liveRegionMode(mode) {
140
+ this.liveRegion.setAttribute("aria-live", mode);
141
+ }
142
+ }
143
+ //# sourceMappingURL=engine_accessibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine_accessibility.js","sourceRoot":"","sources":["../../src/engine/engine_accessibility.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAgBzD;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IAeR;IAbb,MAAM,CAAU,SAAS,GAA0C,IAAI,OAAO,EAAE,CAAC;IAEzF,+FAA+F;IAC/F,MAAM,CAAC,GAAG,CAAC,GAAyB;QAChC,IAAI,WAAW,CAAC,GAAG,CAAC,EAA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C;IAC/E,CAAC;IAED,qFAAqF;IACrF,aAAa,CAAC,GAA0B;QACpC,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,EAAE,EAAE,MAAM,EAAE,CAAC;QACb,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,IAAY,cAAc,CAAC,IAA4B;QACnD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC"}
@@ -20,6 +20,7 @@ import type { CoroutineData, ICamera, IComponent, IContext, ILight, Model, Sourc
20
20
  import type { INeedleXRSessionEventReceiver, NeedleXRSession } from './engine_xr.js';
21
21
  import { NeedleMenu } from './webcomponents/needle menu/needle-menu.js';
22
22
  import type { NeedleEngineWebComponent } from './webcomponents/needle-engine.js';
23
+ import { AccessibilityManager } from './engine_accessibility.js';
23
24
  export declare const build_scene_functions: {
24
25
  [name: string]: (context: Context) => Promise<void>;
25
26
  };
@@ -359,6 +360,7 @@ export declare class Context implements IContext {
359
360
  readonly lodsManager: LODsManager;
360
361
  /** Access the needle menu to add or remove buttons to the menu element */
361
362
  readonly menu: NeedleMenu;
363
+ readonly accessibility: AccessibilityManager;
362
364
  /**
363
365
  * Checks if the context is fully created and ready
364
366
  * @returns true if the context is fully created and ready
@@ -32,6 +32,7 @@ import { Time } from './engine_time.js';
32
32
  import { patchTonemapping } from './engine_tonemapping.js';
33
33
  import { deepClone, DeviceUtilities, getParam } from './engine_utils.js';
34
34
  import { NeedleMenu } from './webcomponents/needle menu/needle-menu.js';
35
+ import { AccessibilityManager } from './engine_accessibility.js';
35
36
  const debug = getParam("debugcontext");
36
37
  const stats = getParam("stats");
37
38
  const debugActive = getParam("debugactive");
@@ -462,6 +463,7 @@ export class Context {
462
463
  lodsManager;
463
464
  /** Access the needle menu to add or remove buttons to the menu element */
464
465
  menu;
466
+ accessibility;
465
467
  /**
466
468
  * Checks if the context is fully created and ready
467
469
  * @returns true if the context is fully created and ready
@@ -509,6 +511,7 @@ export class Context {
509
511
  this.menu = new NeedleMenu(this);
510
512
  this.lodsManager = new LODsManager(this);
511
513
  this.animations = new AnimationsRegistry(this);
514
+ this.accessibility = new AccessibilityManager(this);
512
515
  const resizeCallback = () => this._needsUpdateSize = true;
513
516
  window.addEventListener('resize', resizeCallback);
514
517
  this._disposeCallbacks.push(() => window.removeEventListener('resize', resizeCallback));
@@ -544,6 +547,8 @@ export class Context {
544
547
  if (debug)
545
548
  console.log("Using Renderer Parameters:", params, this.domElement);
546
549
  this.renderer = new WebGLRenderer(params);
550
+ this.renderer.domElement.setAttribute("aria-label", "3D rendering");
551
+ this.renderer.domElement.setAttribute("role", "img");
547
552
  this.renderer.debug.checkShaderErrors = isDevEnvironment() || getParam("checkshadererrors") === true;
548
553
  // some tonemapping other than "NONE" is required for adjusting exposure with EXR environments
549
554
  this.renderer.toneMappingExposure = 1; // range [0...inf] instead of the usual -15..15
@@ -718,6 +723,7 @@ export class Context {
718
723
  this.lightmaps?.clear();
719
724
  this.physics?.engine?.clearCaches();
720
725
  this.lodsManager.disable();
726
+ this.accessibility?.clear();
721
727
  this._onBeforeRenderListeners.clear();
722
728
  this._onAfterRenderListeners.clear();
723
729
  if (!this.isManagedExternally) {
@@ -736,6 +742,7 @@ export class Context {
736
742
  */
737
743
  dispose() {
738
744
  this.internalOnDestroy();
745
+ this.accessibility.dispose();
739
746
  }
740
747
  /**@deprecated use dispose() */
741
748
  onDestroy() { this.internalOnDestroy(); }