@needle-tools/engine 4.17.0-next.36dcae2 → 4.17.0-next.4989636

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 (238) hide show
  1. package/components.needle.json +1 -1
  2. package/dist/gltf-progressive-BryRjllq.min.js +10 -0
  3. package/dist/gltf-progressive-Cl167Vjx.js +1537 -0
  4. package/dist/gltf-progressive-DJBMx-zB.umd.cjs +10 -0
  5. package/dist/gltf-progressive.worker-BqODMeeW.js +23 -0
  6. package/dist/needle-engine.bundle-BTIpdDE9.umd.cjs +1654 -0
  7. package/dist/{needle-engine.bundle-CQFEuAQB.js → needle-engine.bundle-CH2ZOagS.js} +35829 -35882
  8. package/dist/needle-engine.bundle-D5h7xxUH.min.js +1654 -0
  9. package/dist/needle-engine.d.ts +105 -39
  10. package/dist/needle-engine.js +608 -607
  11. package/dist/needle-engine.min.js +1 -1
  12. package/dist/needle-engine.umd.cjs +1 -1
  13. package/dist/three-examples.js +7815 -6828
  14. package/dist/three-examples.min.js +17 -15
  15. package/dist/three-examples.umd.cjs +17 -15
  16. package/dist/three.js +15994 -24892
  17. package/dist/three.min.js +214 -214
  18. package/dist/three.umd.cjs +208 -208
  19. package/dist/vendor-CntUvmJu.umd.cjs +1116 -0
  20. package/dist/{vendor-BPp9F5vR.min.js → vendor-DPbfJJ4d.min.js} +94 -94
  21. package/dist/{vendor-CQMI3jTS.js → vendor-vHLk8sXu.js} +8558 -8516
  22. package/lib/engine/analytics/index.js.map +1 -1
  23. package/lib/engine/codegen/register_types.d.ts +1 -1
  24. package/lib/engine/codegen/register_types.js +159 -157
  25. package/lib/engine/codegen/register_types.js.map +1 -1
  26. package/lib/engine/debug/debug.d.ts +1 -4
  27. package/lib/engine/debug/debug.js +1 -25
  28. package/lib/engine/debug/debug.js.map +1 -1
  29. package/lib/engine/debug/debug_environment.d.ts +4 -0
  30. package/lib/engine/debug/debug_environment.js +26 -0
  31. package/lib/engine/debug/debug_environment.js.map +1 -0
  32. package/lib/engine/debug/debug_overlay.js +2 -1
  33. package/lib/engine/debug/debug_overlay.js.map +1 -1
  34. package/lib/engine/debug/debug_spatial_console.js +1 -1
  35. package/lib/engine/debug/debug_spatial_console.js.map +1 -1
  36. package/lib/engine/engine_audio.js +0 -1
  37. package/lib/engine/engine_audio.js.map +1 -1
  38. package/lib/engine/engine_components.js +6 -3
  39. package/lib/engine/engine_components.js.map +1 -1
  40. package/lib/engine/engine_gltf_builtin_components.d.ts +0 -1
  41. package/lib/engine/engine_gltf_builtin_components.js +5 -4
  42. package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
  43. package/lib/engine/engine_init.d.ts +10 -0
  44. package/lib/engine/engine_init.js +44 -0
  45. package/lib/engine/engine_init.js.map +1 -0
  46. package/lib/engine/engine_loaders.d.ts +2 -0
  47. package/lib/engine/engine_loaders.js +2 -1
  48. package/lib/engine/engine_loaders.js.map +1 -1
  49. package/lib/engine/engine_modules.d.ts +8 -0
  50. package/lib/engine/engine_modules.js +1 -0
  51. package/lib/engine/engine_modules.js.map +1 -1
  52. package/lib/engine/engine_networking.d.ts +2 -1
  53. package/lib/engine/engine_networking.js +3 -1
  54. package/lib/engine/engine_networking.js.map +1 -1
  55. package/lib/engine/engine_networking_blob.js +3 -3
  56. package/lib/engine/engine_networking_blob.js.map +1 -1
  57. package/lib/engine/engine_networking_peer.d.ts +2 -2
  58. package/lib/engine/engine_networking_peer.js +7 -6
  59. package/lib/engine/engine_networking_peer.js.map +1 -1
  60. package/lib/engine/engine_networking_streams.d.ts +2 -1
  61. package/lib/engine/engine_networking_streams.js +2 -2
  62. package/lib/engine/engine_networking_streams.js.map +1 -1
  63. package/lib/engine/engine_physics_rapier.d.ts +2 -0
  64. package/lib/engine/engine_physics_rapier.js +35 -4
  65. package/lib/engine/engine_physics_rapier.js.map +1 -1
  66. package/lib/engine/engine_shims.d.ts +1 -0
  67. package/lib/engine/engine_shims.js +20 -19
  68. package/lib/engine/engine_shims.js.map +1 -1
  69. package/lib/engine/engine_tonemapping.js +0 -1
  70. package/lib/engine/engine_tonemapping.js.map +1 -1
  71. package/lib/engine/engine_types.d.ts +8 -0
  72. package/lib/engine/engine_typestore.d.ts +11 -0
  73. package/lib/engine/engine_typestore.js +29 -0
  74. package/lib/engine/engine_typestore.js.map +1 -1
  75. package/lib/engine/extensions/NEEDLE_animator_controller_model.d.ts +1 -1
  76. package/lib/engine/js-extensions/Camera.d.ts +1 -1
  77. package/lib/engine/js-extensions/Camera.js +43 -37
  78. package/lib/engine/js-extensions/Camera.js.map +1 -1
  79. package/lib/engine/js-extensions/Layers.js +0 -1
  80. package/lib/engine/js-extensions/Layers.js.map +1 -1
  81. package/lib/engine/js-extensions/Object3D.d.ts +1 -0
  82. package/lib/engine/js-extensions/Object3D.js +173 -167
  83. package/lib/engine/js-extensions/Object3D.js.map +1 -1
  84. package/lib/engine/js-extensions/Vector.d.ts +1 -0
  85. package/lib/engine/js-extensions/Vector.js +10 -4
  86. package/lib/engine/js-extensions/Vector.js.map +1 -1
  87. package/lib/engine/js-extensions/index.d.ts +0 -3
  88. package/lib/engine/js-extensions/index.js +0 -2
  89. package/lib/engine/js-extensions/index.js.map +1 -1
  90. package/lib/engine/webcomponents/WebXRButtons.js +11 -13
  91. package/lib/engine/webcomponents/WebXRButtons.js.map +1 -1
  92. package/lib/engine/webcomponents/buttons.js +4 -4
  93. package/lib/engine/webcomponents/buttons.js.map +1 -1
  94. package/lib/engine/webcomponents/font-urls.d.ts +2 -0
  95. package/lib/engine/webcomponents/font-urls.js +8 -0
  96. package/lib/engine/webcomponents/font-urls.js.map +1 -0
  97. package/lib/engine/webcomponents/fonts.d.ts +2 -2
  98. package/lib/engine/webcomponents/fonts.js +12 -7
  99. package/lib/engine/webcomponents/fonts.js.map +1 -1
  100. package/lib/engine/webcomponents/init.d.ts +4 -0
  101. package/lib/engine/webcomponents/init.js +20 -0
  102. package/lib/engine/webcomponents/init.js.map +1 -0
  103. package/lib/engine/webcomponents/logo-element.js +2 -2
  104. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  105. package/lib/engine/webcomponents/needle menu/menu-priority.d.ts +10 -0
  106. package/lib/engine/webcomponents/needle menu/menu-priority.js +21 -0
  107. package/lib/engine/webcomponents/needle menu/menu-priority.js.map +1 -0
  108. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.d.ts +1 -1
  109. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +1 -1
  110. package/lib/engine/webcomponents/needle menu/needle-menu.js +7 -11
  111. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  112. package/lib/engine/webcomponents/needle-button.js +0 -3
  113. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  114. package/lib/engine/webcomponents/needle-engine.js +4 -10
  115. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  116. package/lib/engine/webcomponents/quicklook-handler.d.ts +29 -0
  117. package/lib/engine/webcomponents/quicklook-handler.js +21 -0
  118. package/lib/engine/webcomponents/quicklook-handler.js.map +1 -0
  119. package/lib/engine/xr/NeedleXRSession.d.ts +1 -0
  120. package/lib/engine/xr/NeedleXRSession.js +1 -0
  121. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  122. package/lib/engine-components/AnimationUtilsAutoplay.d.ts +1 -1
  123. package/lib/engine-components/AnimationUtilsAutoplay.js +29 -23
  124. package/lib/engine-components/AnimationUtilsAutoplay.js.map +1 -1
  125. package/lib/engine-components/Animator.d.ts +1 -1
  126. package/lib/engine-components/AnimatorController.d.ts +1 -1
  127. package/lib/engine-components/CameraUtils.d.ts +1 -1
  128. package/lib/engine-components/CameraUtils.js +79 -73
  129. package/lib/engine-components/CameraUtils.js.map +1 -1
  130. package/lib/engine-components/Collider.d.ts +2 -0
  131. package/lib/engine-components/Collider.js +25 -3
  132. package/lib/engine-components/Collider.js.map +1 -1
  133. package/lib/engine-components/LookAtConstraint.d.ts +34 -1
  134. package/lib/engine-components/LookAtConstraint.js +54 -1
  135. package/lib/engine-components/LookAtConstraint.js.map +1 -1
  136. package/lib/engine-components/Networking.d.ts +2 -1
  137. package/lib/engine-components/Networking.js +2 -1
  138. package/lib/engine-components/Networking.js.map +1 -1
  139. package/lib/engine-components/SceneSwitcher.d.ts +1 -0
  140. package/lib/engine-components/SceneSwitcher.js +3 -1
  141. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  142. package/lib/engine-components/Skybox.d.ts +1 -0
  143. package/lib/engine-components/Skybox.js +4 -2
  144. package/lib/engine-components/Skybox.js.map +1 -1
  145. package/lib/engine-components/SyncedRoom.d.ts +1 -0
  146. package/lib/engine-components/SyncedRoom.js +1 -0
  147. package/lib/engine-components/SyncedRoom.js.map +1 -1
  148. package/lib/engine-components/api.d.ts +5 -8
  149. package/lib/engine-components/api.js +4 -7
  150. package/lib/engine-components/api.js.map +1 -1
  151. package/lib/engine-components/export/usdz/USDZExporter.js +8 -0
  152. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  153. package/lib/engine-components/postprocessing/PostProcessingHandler.js +18 -5
  154. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  155. package/lib/engine-components/postprocessing/utils.js +7 -2
  156. package/lib/engine-components/postprocessing/utils.js.map +1 -1
  157. package/lib/engine-components/timeline/TimelineTracks.d.ts +1 -1
  158. package/lib/engine-components/timeline/TimelineTracks.js +4 -2
  159. package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
  160. package/lib/engine-components/web/ScrollFollow.d.ts +0 -8
  161. package/lib/engine-components/webxr/WebXR.d.ts +15 -2
  162. package/lib/engine-components/webxr/WebXR.js +15 -2
  163. package/lib/engine-components/webxr/WebXR.js.map +1 -1
  164. package/lib/needle-engine.d.ts +0 -1
  165. package/lib/needle-engine.js +2 -1
  166. package/lib/needle-engine.js.map +1 -1
  167. package/package.json +11 -3
  168. package/plugins/vite/ai.d.ts +11 -7
  169. package/plugins/vite/ai.js +21 -16
  170. package/plugins/vite/asap.js +42 -2
  171. package/plugins/vite/dependencies.js +110 -16
  172. package/plugins/vite/index.d.ts +1 -0
  173. package/plugins/vite/index.js +4 -0
  174. package/plugins/vite/treeshake.d.ts +11 -0
  175. package/plugins/vite/treeshake.js +216 -0
  176. package/src/engine/analytics/index.ts +1 -1
  177. package/src/engine/codegen/register_types.ts +159 -157
  178. package/src/engine/debug/debug.ts +1 -26
  179. package/src/engine/debug/debug_environment.ts +26 -0
  180. package/src/engine/debug/debug_overlay.ts +2 -1
  181. package/src/engine/debug/debug_spatial_console.ts +1 -1
  182. package/src/engine/engine_audio.ts +1 -2
  183. package/src/engine/engine_components.ts +6 -3
  184. package/src/engine/engine_gltf_builtin_components.ts +4 -5
  185. package/src/engine/engine_init.ts +45 -0
  186. package/src/engine/engine_loaders.ts +2 -1
  187. package/src/engine/engine_modules.ts +3 -0
  188. package/src/engine/engine_networking.ts +5 -1
  189. package/src/engine/engine_networking_blob.ts +3 -3
  190. package/src/engine/engine_networking_peer.ts +8 -6
  191. package/src/engine/engine_networking_streams.ts +4 -3
  192. package/src/engine/engine_physics_rapier.ts +37 -4
  193. package/src/engine/engine_shims.ts +22 -20
  194. package/src/engine/engine_tonemapping.ts +0 -1
  195. package/src/engine/engine_types.ts +9 -0
  196. package/src/engine/engine_typestore.ts +29 -0
  197. package/src/engine/extensions/NEEDLE_animator_controller_model.ts +1 -1
  198. package/src/engine/js-extensions/Camera.ts +40 -33
  199. package/src/engine/js-extensions/Layers.ts +1 -2
  200. package/src/engine/js-extensions/Object3D.ts +174 -170
  201. package/src/engine/js-extensions/Vector.ts +11 -4
  202. package/src/engine/js-extensions/index.ts +0 -3
  203. package/src/engine/webcomponents/WebXRButtons.ts +12 -13
  204. package/src/engine/webcomponents/buttons.ts +4 -4
  205. package/src/engine/webcomponents/font-urls.js +9 -0
  206. package/src/engine/webcomponents/fonts.ts +12 -7
  207. package/src/engine/webcomponents/init.ts +23 -0
  208. package/src/engine/webcomponents/logo-element.ts +2 -2
  209. package/src/engine/webcomponents/needle menu/menu-priority.ts +20 -0
  210. package/src/engine/webcomponents/needle menu/needle-menu.ts +8 -13
  211. package/src/engine/webcomponents/needle-button.ts +0 -3
  212. package/src/engine/webcomponents/needle-engine.ts +4 -13
  213. package/src/engine/webcomponents/quicklook-handler.ts +37 -0
  214. package/src/engine/xr/NeedleXRSession.ts +2 -1
  215. package/src/engine-components/AnimationUtilsAutoplay.ts +8 -3
  216. package/src/engine-components/AnimatorController.ts +1 -1
  217. package/src/engine-components/CameraUtils.ts +15 -8
  218. package/src/engine-components/Collider.ts +24 -3
  219. package/src/engine-components/LookAtConstraint.ts +46 -1
  220. package/src/engine-components/Networking.ts +3 -1
  221. package/src/engine-components/SceneSwitcher.ts +3 -1
  222. package/src/engine-components/Skybox.ts +4 -2
  223. package/src/engine-components/SyncedRoom.ts +2 -0
  224. package/src/engine-components/api.ts +5 -10
  225. package/src/engine-components/export/usdz/USDZExporter.ts +9 -0
  226. package/src/engine-components/postprocessing/PostProcessingHandler.ts +19 -7
  227. package/src/engine-components/postprocessing/utils.ts +7 -2
  228. package/src/engine-components/timeline/TimelineTracks.ts +6 -2
  229. package/src/engine-components/web/ScrollFollow.ts +0 -2
  230. package/src/engine-components/webxr/WebXR.ts +15 -2
  231. package/src/needle-engine.ts +2 -1
  232. package/dist/gltf-progressive-BBIL1q1j.umd.cjs +0 -4022
  233. package/dist/gltf-progressive-BbHl9z0v.js +0 -28272
  234. package/dist/gltf-progressive-Clq_N7Zx.min.js +0 -4022
  235. package/dist/gltf-progressive.worker-CCrD-Ycm.js +0 -3
  236. package/dist/needle-engine.bundle-CrqNZdEN.umd.cjs +0 -1657
  237. package/dist/needle-engine.bundle-DyVf6QdN.min.js +0 -1657
  238. package/dist/vendor-CipoooTV.umd.cjs +0 -1116
@@ -0,0 +1,216 @@
1
+ import { existsSync, readFileSync, readdirSync, statSync } from 'fs';
2
+ import path from 'path';
3
+ import { tryLoadProjectConfig } from './config.js';
4
+ import { needleLog } from './logging.js';
5
+
6
+ /**
7
+ * Scans local GLB/glTF files to determine which engine components are actually used,
8
+ * then rewrites the engine's `codegen/register_types.ts` so that unused components
9
+ * are registered lazily via `TypeStore.addLazy()` instead of eagerly imported.
10
+ *
11
+ * @param {"build" | "serve"} command
12
+ * @param {import('../types/needleConfig').needleMeta | null | undefined} config
13
+ * @param {import('../types').userSettings} userSettings
14
+ * @returns {import('vite').Plugin | undefined}
15
+ */
16
+ export function needleTreeshake(command, config, userSettings) {
17
+
18
+ if (command !== 'build') return;
19
+
20
+ // Temporarily disabled: the treeshake plugin's dynamic imports are ineffective
21
+ // because codegen/components.ts statically re-exports all components via the
22
+ // `export *` chain from needle-engine.ts. The dynamic import() calls in
23
+ // register_types cannot create split points for already-statically-imported modules.
24
+ // TODO: Find a way to also transform components.ts without breaking the public API.
25
+ return;
26
+
27
+ /** @type {Set<string>} component names found in local GLB/glTF files */
28
+ const usedComponents = new Set();
29
+
30
+ return {
31
+ name: 'needle:treeshake',
32
+ apply: 'build',
33
+
34
+ buildStart() {
35
+ const projectConfig = tryLoadProjectConfig();
36
+ const assetsDir = projectConfig?.assetsDirectory || 'assets';
37
+ const assetsPath = path.resolve(process.cwd(), assetsDir);
38
+
39
+ if (!existsSync(assetsPath)) {
40
+ needleLog('needle-treeshake', `Assets directory "${assetsPath}" not found — skipping component scanning`);
41
+ return;
42
+ }
43
+
44
+ const files = findGltfFiles(assetsPath);
45
+ needleLog('needle-treeshake', `Found ${files.length} GLB/glTF file(s) in "${assetsDir}"`);
46
+
47
+ for (const file of files) {
48
+ try {
49
+ const names = extractComponentNames(file);
50
+ for (const name of names) usedComponents.add(name);
51
+ }
52
+ catch (err) {
53
+ needleLog('needle-treeshake', `Failed to parse "${file}": ${err.message}`, 'warn');
54
+ }
55
+ }
56
+
57
+ if (usedComponents.size > 0) {
58
+ needleLog('needle-treeshake', `Components used in local scenes: ${[...usedComponents].sort().join(', ')}`);
59
+ }
60
+ else {
61
+ needleLog('needle-treeshake', 'No components found in local scenes — all components will be loaded eagerly');
62
+ }
63
+ },
64
+
65
+ /**
66
+ * @param {string} src
67
+ * @param {string} id
68
+ */
69
+ transform(src, id) {
70
+ if (usedComponents.size === 0) return;
71
+
72
+ if (id.includes('engine/codegen/register_types')) {
73
+ return { code: rewriteRegisterTypes(src, usedComponents), map: null };
74
+ }
75
+ }
76
+ };
77
+ }
78
+
79
+
80
+ /**
81
+ * Recursively find all .glb and .gltf files in a directory
82
+ * @param {string} dir
83
+ * @returns {string[]}
84
+ */
85
+ function findGltfFiles(dir) {
86
+ /** @type {string[]} */
87
+ const results = [];
88
+ try {
89
+ for (const entry of readdirSync(dir)) {
90
+ const full = path.join(dir, entry);
91
+ try {
92
+ const stat = statSync(full);
93
+ if (stat.isDirectory()) {
94
+ results.push(...findGltfFiles(full));
95
+ }
96
+ else if (entry.endsWith('.glb') || entry.endsWith('.gltf')) {
97
+ results.push(full);
98
+ }
99
+ }
100
+ catch { /* skip inaccessible entries */ }
101
+ }
102
+ }
103
+ catch { /* skip inaccessible directories */ }
104
+ return results;
105
+ }
106
+
107
+
108
+ /**
109
+ * Extract all NEEDLE_components names from a GLB or glTF file
110
+ * @param {string} filePath
111
+ * @returns {Set<string>}
112
+ */
113
+ function extractComponentNames(filePath) {
114
+ /** @type {Set<string>} */
115
+ const names = new Set();
116
+
117
+ let json;
118
+ if (filePath.endsWith('.glb')) {
119
+ const buf = readFileSync(filePath);
120
+ if (buf.length < 20) return names;
121
+ const jsonLen = buf.readUInt32LE(12);
122
+ json = JSON.parse(buf.slice(20, 20 + jsonLen).toString('utf8'));
123
+ }
124
+ else {
125
+ json = JSON.parse(readFileSync(filePath, 'utf8'));
126
+ }
127
+
128
+ if (json.nodes) {
129
+ for (const node of json.nodes) {
130
+ const comps = node?.extensions?.NEEDLE_components?.builtin_components;
131
+ if (comps) {
132
+ for (const comp of comps) {
133
+ if (comp?.name) names.add(comp.name);
134
+ }
135
+ }
136
+ }
137
+ }
138
+
139
+ return names;
140
+ }
141
+
142
+
143
+ /**
144
+ * Rewrite the engine's register_types.ts source:
145
+ * - Eager components: keep static imports + TypeStore.add()
146
+ * - Lazy components: per-file dynamic import() + TypeStore.addLazy()
147
+ *
148
+ * @param {string} src
149
+ * @param {Set<string>} usedComponents
150
+ * @returns {string}
151
+ */
152
+ function rewriteRegisterTypes(src, usedComponents) {
153
+ /** @type {Map<string, { importPath: string, importLine: string }>} */
154
+ const importMap = new Map();
155
+ const importRegex = /^import\s*\{\s*(\w+)\s*\}\s*from\s*"([^"]+)"\s*;?\s*$/gm;
156
+ let match;
157
+ while ((match = importRegex.exec(src)) !== null) {
158
+ importMap.set(match[1], { importPath: match[2], importLine: match[0] });
159
+ }
160
+
161
+ /** @type {Map<string, string>} */
162
+ const addMap = new Map();
163
+ const addRegex = /TypeStore\.add\("(\w+)",\s*(\w+)\)/g;
164
+ while ((match = addRegex.exec(src)) !== null) {
165
+ addMap.set(match[1], match[2]);
166
+ }
167
+
168
+ /** @type {{ name: string, varName: string, importPath: string, importLine: string }[]} */
169
+ const eager = [];
170
+ /** @type {{ name: string, varName: string, importPath: string, importLine: string }[]} */
171
+ const lazy = [];
172
+
173
+ for (const [compName, varName] of addMap) {
174
+ const imp = importMap.get(varName);
175
+ if (!imp) continue;
176
+ if (usedComponents.has(compName)) {
177
+ eager.push({ name: compName, varName, ...imp });
178
+ }
179
+ else {
180
+ lazy.push({ name: compName, varName, ...imp });
181
+ }
182
+ }
183
+
184
+ needleLog('needle-treeshake', `Eager: ${eager.length} components, Lazy: ${lazy.length} components`);
185
+
186
+ const lines = [];
187
+ lines.push('/* eslint-disable */');
188
+ lines.push('import { TypeStore } from "./../engine_typestore.js"');
189
+ lines.push('');
190
+
191
+ const eagerPaths = new Set(eager.map(e => e.importLine));
192
+ lines.push('// Eagerly loaded components (used in local scenes)');
193
+ for (const importLine of eagerPaths) {
194
+ lines.push(importLine);
195
+ }
196
+
197
+ lines.push('');
198
+ lines.push('// Register types');
199
+ lines.push('export function initBuiltinTypes() {');
200
+
201
+ for (const e of eager) {
202
+ lines.push(`\tTypeStore.add("${e.name}", ${e.varName});`);
203
+ }
204
+
205
+ if (lazy.length > 0) {
206
+ lines.push('');
207
+ lines.push(`\t// Lazy-loaded components (${lazy.length} components, loaded on demand)`);
208
+ for (const comp of lazy) {
209
+ lines.push(`\tTypeStore.addLazy("${comp.name}", () => import("${comp.importPath}").then(m => m.${comp.varName}));`);
210
+ }
211
+ }
212
+
213
+ lines.push('}');
214
+
215
+ return lines.join('\n');
216
+ }
@@ -3,7 +3,7 @@ import { LCP } from "./lcp.js";
3
3
  /**
4
4
  * @param args - The arguments to initialize the performance analytics with.
5
5
  */
6
- export module NeedleEnginePerformanceAnalytics {
6
+ export namespace NeedleEnginePerformanceAnalytics {
7
7
  export function init(...args: Array<"lcp">) {
8
8
  if (args.includes("lcp"))
9
9
  LCP.observe();
@@ -161,160 +161,162 @@ import { PlayerState } from "../../engine-components-experimental/networking/Pla
161
161
  import { PresentationMode } from "../../engine-components-experimental/Presentation.js";
162
162
 
163
163
  // Register types
164
- TypeStore.add("AlignmentConstraint", AlignmentConstraint);
165
- TypeStore.add("Animation", Animation);
166
- TypeStore.add("Animator", Animator);
167
- TypeStore.add("AudioListener", AudioListener);
168
- TypeStore.add("AudioSource", AudioSource);
169
- TypeStore.add("Avatar_Brain_LookAt", Avatar_Brain_LookAt);
170
- TypeStore.add("Avatar_MouthShapes", Avatar_MouthShapes);
171
- TypeStore.add("Avatar_MustacheShake", Avatar_MustacheShake);
172
- TypeStore.add("AvatarBlink_Simple", AvatarBlink_Simple);
173
- TypeStore.add("AvatarEyeLook_Rotation", AvatarEyeLook_Rotation);
174
- TypeStore.add("AxesHelper", AxesHelper);
175
- TypeStore.add("BasicIKConstraint", BasicIKConstraint);
176
- TypeStore.add("BoxHelperComponent", BoxHelperComponent);
177
- TypeStore.add("Camera", Camera);
178
- TypeStore.add("CharacterController", CharacterController);
179
- TypeStore.add("CharacterControllerInput", CharacterControllerInput);
180
- TypeStore.add("SphereCollider", SphereCollider);
181
- TypeStore.add("BoxCollider", BoxCollider);
182
- TypeStore.add("MeshCollider", MeshCollider);
183
- TypeStore.add("CapsuleCollider", CapsuleCollider);
184
- TypeStore.add("ContactShadows", ContactShadows);
185
- TypeStore.add("LogStats", LogStats);
186
- TypeStore.add("DeleteBox", DeleteBox);
187
- TypeStore.add("Deletable", Deletable);
188
- TypeStore.add("DeviceFlag", DeviceFlag);
189
- TypeStore.add("DragControls", DragControls);
190
- TypeStore.add("DropListener", DropListener);
191
- TypeStore.add("Duplicatable", Duplicatable);
192
- TypeStore.add("EventListEvent", EventListEvent);
193
- TypeStore.add("EventTrigger", EventTrigger);
194
- TypeStore.add("GltfExportBox", GltfExportBox);
195
- TypeStore.add("GltfExport", GltfExport);
196
- TypeStore.add("VariantAction", VariantAction);
197
- TypeStore.add("ChangeTransformOnClick", ChangeTransformOnClick);
198
- TypeStore.add("ChangeMaterialOnClick", ChangeMaterialOnClick);
199
- TypeStore.add("SetActiveOnClick", SetActiveOnClick);
200
- TypeStore.add("HideOnStart", HideOnStart);
201
- TypeStore.add("EmphasizeOnClick", EmphasizeOnClick);
202
- TypeStore.add("PlayAudioOnClick", PlayAudioOnClick);
203
- TypeStore.add("PlayAnimationOnClick", PlayAnimationOnClick);
204
- TypeStore.add("PreliminaryAction", PreliminaryAction);
205
- TypeStore.add("PreliminaryTrigger", PreliminaryTrigger);
206
- TypeStore.add("VisibilityAction", VisibilityAction);
207
- TypeStore.add("TapGestureTrigger", TapGestureTrigger);
208
- TypeStore.add("USDZExporter", USDZExporter);
209
- TypeStore.add("Fog", Fog);
210
- TypeStore.add("BoxGizmo", BoxGizmo);
211
- TypeStore.add("GridHelper", GridHelper);
212
- TypeStore.add("GroundProjectedEnv", GroundProjectedEnv);
213
- TypeStore.add("UsageMarker", UsageMarker);
214
- TypeStore.add("Interactable", Interactable);
215
- TypeStore.add("FixedJoint", FixedJoint);
216
- TypeStore.add("HingeJoint", HingeJoint);
217
- TypeStore.add("Light", Light);
218
- TypeStore.add("LODGroup", LODGroup);
219
- TypeStore.add("LookAtConstraint", LookAtConstraint);
220
- TypeStore.add("NeedleMenu", NeedleMenu);
221
- TypeStore.add("NestedGltf", NestedGltf);
222
- TypeStore.add("Networking", Networking);
223
- TypeStore.add("OffsetConstraint", OffsetConstraint);
224
- TypeStore.add("CameraTargetReachedEvent", CameraTargetReachedEvent);
225
- TypeStore.add("OrbitControls", OrbitControls);
226
- TypeStore.add("ParticleSystemRenderer", ParticleSystemRenderer);
227
- TypeStore.add("ParticleSystem", ParticleSystem);
228
- TypeStore.add("Attractor", Attractor);
229
- TypeStore.add("PlayerColor", PlayerColor);
230
- TypeStore.add("Antialiasing", Antialiasing);
231
- TypeStore.add("BloomEffect", BloomEffect);
232
- TypeStore.add("ChromaticAberration", ChromaticAberration);
233
- TypeStore.add("ColorAdjustments", ColorAdjustments);
234
- TypeStore.add("DepthOfField", DepthOfField);
235
- TypeStore.add("EffectWrapper", EffectWrapper);
236
- TypeStore.add("PixelationEffect", PixelationEffect);
237
- TypeStore.add("ScreenSpaceAmbientOcclusion", ScreenSpaceAmbientOcclusion);
238
- TypeStore.add("ScreenSpaceAmbientOcclusionN8", ScreenSpaceAmbientOcclusionN8);
239
- TypeStore.add("SharpeningEffect", SharpeningEffect);
240
- TypeStore.add("TiltShiftEffect", TiltShiftEffect);
241
- TypeStore.add("ToneMappingEffect", ToneMappingEffect);
242
- TypeStore.add("Vignette", Vignette);
243
- TypeStore.add("Volume", Volume);
244
- TypeStore.add("ReflectionProbe", ReflectionProbe);
245
- TypeStore.add("Renderer", Renderer);
246
- TypeStore.add("MeshRenderer", MeshRenderer);
247
- TypeStore.add("SkinnedMeshRenderer", SkinnedMeshRenderer);
248
- TypeStore.add("Rigidbody", Rigidbody);
249
- TypeStore.add("SceneSwitcher", SceneSwitcher);
250
- TypeStore.add("ScreenCapture", ScreenCapture);
251
- TypeStore.add("SeeThrough", SeeThrough);
252
- TypeStore.add("ShadowCatcher", ShadowCatcher);
253
- TypeStore.add("RemoteSkybox", RemoteSkybox);
254
- TypeStore.add("SmoothFollow", SmoothFollow);
255
- TypeStore.add("SpatialTriggerReceiver", SpatialTriggerReceiver);
256
- TypeStore.add("SpatialTrigger", SpatialTrigger);
257
- TypeStore.add("SpectatorCamera", SpectatorCamera);
258
- TypeStore.add("SplineContainer", SplineContainer);
259
- TypeStore.add("SplineWalker", SplineWalker);
260
- TypeStore.add("SpriteRenderer", SpriteRenderer);
261
- TypeStore.add("SyncedCamera", SyncedCamera);
262
- TypeStore.add("SyncedRoom", SyncedRoom);
263
- TypeStore.add("SyncedTransform", SyncedTransform);
264
- TypeStore.add("TestRunner", TestRunner);
265
- TypeStore.add("TestSimulateUserData", TestSimulateUserData);
266
- TypeStore.add("PlayableDirector", PlayableDirector);
267
- TypeStore.add("SignalReceiver", SignalReceiver);
268
- TypeStore.add("AnimationTrackHandler", AnimationTrackHandler);
269
- TypeStore.add("AudioTrackHandler", AudioTrackHandler);
270
- TypeStore.add("MarkerTrackHandler", MarkerTrackHandler);
271
- TypeStore.add("SignalTrackHandler", SignalTrackHandler);
272
- TypeStore.add("ControlTrackHandler", ControlTrackHandler);
273
- TypeStore.add("TransformGizmo", TransformGizmo);
274
- TypeStore.add("BaseUIComponent", BaseUIComponent);
275
- TypeStore.add("UIRootComponent", UIRootComponent);
276
- TypeStore.add("Button", Button);
277
- TypeStore.add("Canvas", Canvas);
278
- TypeStore.add("CanvasGroup", CanvasGroup);
279
- TypeStore.add("EventSystem", EventSystem);
280
- TypeStore.add("Graphic", Graphic);
281
- TypeStore.add("MaskableGraphic", MaskableGraphic);
282
- TypeStore.add("Image", Image);
283
- TypeStore.add("RawImage", RawImage);
284
- TypeStore.add("InputField", InputField);
285
- TypeStore.add("VerticalLayoutGroup", VerticalLayoutGroup);
286
- TypeStore.add("HorizontalLayoutGroup", HorizontalLayoutGroup);
287
- TypeStore.add("GridLayoutGroup", GridLayoutGroup);
288
- TypeStore.add("Outline", Outline);
289
- TypeStore.add("ObjectRaycaster", ObjectRaycaster);
290
- TypeStore.add("GraphicRaycaster", GraphicRaycaster);
291
- TypeStore.add("SpatialGrabRaycaster", SpatialGrabRaycaster);
292
- TypeStore.add("RectTransform", RectTransform);
293
- TypeStore.add("SpatialHtml", SpatialHtml);
294
- TypeStore.add("Text", Text);
295
- TypeStore.add("EnvironmentScene", EnvironmentScene);
296
- TypeStore.add("LookAt", LookAt);
297
- TypeStore.add("OpenURL", OpenURL);
298
- TypeStore.add("VideoPlayer", VideoPlayer);
299
- TypeStore.add("Voip", Voip);
300
- TypeStore.add("ClickThrough", ClickThrough);
301
- TypeStore.add("CursorFollow", CursorFollow);
302
- TypeStore.add("HoverAnimation", HoverAnimation);
303
- TypeStore.add("ScrollFollow", ScrollFollow);
304
- TypeStore.add("ViewBox", ViewBox);
305
- TypeStore.add("Avatar", Avatar);
306
- TypeStore.add("XRControllerFollow", XRControllerFollow);
307
- TypeStore.add("XRControllerModel", XRControllerModel);
308
- TypeStore.add("XRControllerMovement", XRControllerMovement);
309
- TypeStore.add("TeleportTarget", TeleportTarget);
310
- TypeStore.add("WebARCameraBackground", WebARCameraBackground);
311
- TypeStore.add("WebARSessionRoot", WebARSessionRoot);
312
- TypeStore.add("WebXR", WebXR);
313
- TypeStore.add("AvatarMarker", AvatarMarker);
314
- TypeStore.add("WebXRImageTracking", WebXRImageTracking);
315
- TypeStore.add("WebXRPlaneTracking", WebXRPlaneTracking);
316
- TypeStore.add("XRRig", XRRig);
317
- TypeStore.add("XRFlag", XRFlag);
318
- TypeStore.add("PlayerSync", PlayerSync);
319
- TypeStore.add("PlayerState", PlayerState);
320
- TypeStore.add("PresentationMode", PresentationMode);
164
+ export function initBuiltinTypes() {
165
+ TypeStore.add("AlignmentConstraint", AlignmentConstraint);
166
+ TypeStore.add("Animation", Animation);
167
+ TypeStore.add("Animator", Animator);
168
+ TypeStore.add("AudioListener", AudioListener);
169
+ TypeStore.add("AudioSource", AudioSource);
170
+ TypeStore.add("Avatar_Brain_LookAt", Avatar_Brain_LookAt);
171
+ TypeStore.add("Avatar_MouthShapes", Avatar_MouthShapes);
172
+ TypeStore.add("Avatar_MustacheShake", Avatar_MustacheShake);
173
+ TypeStore.add("AvatarBlink_Simple", AvatarBlink_Simple);
174
+ TypeStore.add("AvatarEyeLook_Rotation", AvatarEyeLook_Rotation);
175
+ TypeStore.add("AxesHelper", AxesHelper);
176
+ TypeStore.add("BasicIKConstraint", BasicIKConstraint);
177
+ TypeStore.add("BoxHelperComponent", BoxHelperComponent);
178
+ TypeStore.add("Camera", Camera);
179
+ TypeStore.add("CharacterController", CharacterController);
180
+ TypeStore.add("CharacterControllerInput", CharacterControllerInput);
181
+ TypeStore.add("SphereCollider", SphereCollider);
182
+ TypeStore.add("BoxCollider", BoxCollider);
183
+ TypeStore.add("MeshCollider", MeshCollider);
184
+ TypeStore.add("CapsuleCollider", CapsuleCollider);
185
+ TypeStore.add("ContactShadows", ContactShadows);
186
+ TypeStore.add("LogStats", LogStats);
187
+ TypeStore.add("DeleteBox", DeleteBox);
188
+ TypeStore.add("Deletable", Deletable);
189
+ TypeStore.add("DeviceFlag", DeviceFlag);
190
+ TypeStore.add("DragControls", DragControls);
191
+ TypeStore.add("DropListener", DropListener);
192
+ TypeStore.add("Duplicatable", Duplicatable);
193
+ TypeStore.add("EventListEvent", EventListEvent);
194
+ TypeStore.add("EventTrigger", EventTrigger);
195
+ TypeStore.add("GltfExportBox", GltfExportBox);
196
+ TypeStore.add("GltfExport", GltfExport);
197
+ TypeStore.add("VariantAction", VariantAction);
198
+ TypeStore.add("ChangeTransformOnClick", ChangeTransformOnClick);
199
+ TypeStore.add("ChangeMaterialOnClick", ChangeMaterialOnClick);
200
+ TypeStore.add("SetActiveOnClick", SetActiveOnClick);
201
+ TypeStore.add("HideOnStart", HideOnStart);
202
+ TypeStore.add("EmphasizeOnClick", EmphasizeOnClick);
203
+ TypeStore.add("PlayAudioOnClick", PlayAudioOnClick);
204
+ TypeStore.add("PlayAnimationOnClick", PlayAnimationOnClick);
205
+ TypeStore.add("PreliminaryAction", PreliminaryAction);
206
+ TypeStore.add("PreliminaryTrigger", PreliminaryTrigger);
207
+ TypeStore.add("VisibilityAction", VisibilityAction);
208
+ TypeStore.add("TapGestureTrigger", TapGestureTrigger);
209
+ TypeStore.add("USDZExporter", USDZExporter);
210
+ TypeStore.add("Fog", Fog);
211
+ TypeStore.add("BoxGizmo", BoxGizmo);
212
+ TypeStore.add("GridHelper", GridHelper);
213
+ TypeStore.add("GroundProjectedEnv", GroundProjectedEnv);
214
+ TypeStore.add("UsageMarker", UsageMarker);
215
+ TypeStore.add("Interactable", Interactable);
216
+ TypeStore.add("FixedJoint", FixedJoint);
217
+ TypeStore.add("HingeJoint", HingeJoint);
218
+ TypeStore.add("Light", Light);
219
+ TypeStore.add("LODGroup", LODGroup);
220
+ TypeStore.add("LookAtConstraint", LookAtConstraint);
221
+ TypeStore.add("NeedleMenu", NeedleMenu);
222
+ TypeStore.add("NestedGltf", NestedGltf);
223
+ TypeStore.add("Networking", Networking);
224
+ TypeStore.add("OffsetConstraint", OffsetConstraint);
225
+ TypeStore.add("CameraTargetReachedEvent", CameraTargetReachedEvent);
226
+ TypeStore.add("OrbitControls", OrbitControls);
227
+ TypeStore.add("ParticleSystemRenderer", ParticleSystemRenderer);
228
+ TypeStore.add("ParticleSystem", ParticleSystem);
229
+ TypeStore.add("Attractor", Attractor);
230
+ TypeStore.add("PlayerColor", PlayerColor);
231
+ TypeStore.add("Antialiasing", Antialiasing);
232
+ TypeStore.add("BloomEffect", BloomEffect);
233
+ TypeStore.add("ChromaticAberration", ChromaticAberration);
234
+ TypeStore.add("ColorAdjustments", ColorAdjustments);
235
+ TypeStore.add("DepthOfField", DepthOfField);
236
+ TypeStore.add("EffectWrapper", EffectWrapper);
237
+ TypeStore.add("PixelationEffect", PixelationEffect);
238
+ TypeStore.add("ScreenSpaceAmbientOcclusion", ScreenSpaceAmbientOcclusion);
239
+ TypeStore.add("ScreenSpaceAmbientOcclusionN8", ScreenSpaceAmbientOcclusionN8);
240
+ TypeStore.add("SharpeningEffect", SharpeningEffect);
241
+ TypeStore.add("TiltShiftEffect", TiltShiftEffect);
242
+ TypeStore.add("ToneMappingEffect", ToneMappingEffect);
243
+ TypeStore.add("Vignette", Vignette);
244
+ TypeStore.add("Volume", Volume);
245
+ TypeStore.add("ReflectionProbe", ReflectionProbe);
246
+ TypeStore.add("Renderer", Renderer);
247
+ TypeStore.add("MeshRenderer", MeshRenderer);
248
+ TypeStore.add("SkinnedMeshRenderer", SkinnedMeshRenderer);
249
+ TypeStore.add("Rigidbody", Rigidbody);
250
+ TypeStore.add("SceneSwitcher", SceneSwitcher);
251
+ TypeStore.add("ScreenCapture", ScreenCapture);
252
+ TypeStore.add("SeeThrough", SeeThrough);
253
+ TypeStore.add("ShadowCatcher", ShadowCatcher);
254
+ TypeStore.add("RemoteSkybox", RemoteSkybox);
255
+ TypeStore.add("SmoothFollow", SmoothFollow);
256
+ TypeStore.add("SpatialTriggerReceiver", SpatialTriggerReceiver);
257
+ TypeStore.add("SpatialTrigger", SpatialTrigger);
258
+ TypeStore.add("SpectatorCamera", SpectatorCamera);
259
+ TypeStore.add("SplineContainer", SplineContainer);
260
+ TypeStore.add("SplineWalker", SplineWalker);
261
+ TypeStore.add("SpriteRenderer", SpriteRenderer);
262
+ TypeStore.add("SyncedCamera", SyncedCamera);
263
+ TypeStore.add("SyncedRoom", SyncedRoom);
264
+ TypeStore.add("SyncedTransform", SyncedTransform);
265
+ TypeStore.add("TestRunner", TestRunner);
266
+ TypeStore.add("TestSimulateUserData", TestSimulateUserData);
267
+ TypeStore.add("PlayableDirector", PlayableDirector);
268
+ TypeStore.add("SignalReceiver", SignalReceiver);
269
+ TypeStore.add("AnimationTrackHandler", AnimationTrackHandler);
270
+ TypeStore.add("AudioTrackHandler", AudioTrackHandler);
271
+ TypeStore.add("MarkerTrackHandler", MarkerTrackHandler);
272
+ TypeStore.add("SignalTrackHandler", SignalTrackHandler);
273
+ TypeStore.add("ControlTrackHandler", ControlTrackHandler);
274
+ TypeStore.add("TransformGizmo", TransformGizmo);
275
+ TypeStore.add("BaseUIComponent", BaseUIComponent);
276
+ TypeStore.add("UIRootComponent", UIRootComponent);
277
+ TypeStore.add("Button", Button);
278
+ TypeStore.add("Canvas", Canvas);
279
+ TypeStore.add("CanvasGroup", CanvasGroup);
280
+ TypeStore.add("EventSystem", EventSystem);
281
+ TypeStore.add("Graphic", Graphic);
282
+ TypeStore.add("MaskableGraphic", MaskableGraphic);
283
+ TypeStore.add("Image", Image);
284
+ TypeStore.add("RawImage", RawImage);
285
+ TypeStore.add("InputField", InputField);
286
+ TypeStore.add("VerticalLayoutGroup", VerticalLayoutGroup);
287
+ TypeStore.add("HorizontalLayoutGroup", HorizontalLayoutGroup);
288
+ TypeStore.add("GridLayoutGroup", GridLayoutGroup);
289
+ TypeStore.add("Outline", Outline);
290
+ TypeStore.add("ObjectRaycaster", ObjectRaycaster);
291
+ TypeStore.add("GraphicRaycaster", GraphicRaycaster);
292
+ TypeStore.add("SpatialGrabRaycaster", SpatialGrabRaycaster);
293
+ TypeStore.add("RectTransform", RectTransform);
294
+ TypeStore.add("SpatialHtml", SpatialHtml);
295
+ TypeStore.add("Text", Text);
296
+ TypeStore.add("EnvironmentScene", EnvironmentScene);
297
+ TypeStore.add("LookAt", LookAt);
298
+ TypeStore.add("OpenURL", OpenURL);
299
+ TypeStore.add("VideoPlayer", VideoPlayer);
300
+ TypeStore.add("Voip", Voip);
301
+ TypeStore.add("ClickThrough", ClickThrough);
302
+ TypeStore.add("CursorFollow", CursorFollow);
303
+ TypeStore.add("HoverAnimation", HoverAnimation);
304
+ TypeStore.add("ScrollFollow", ScrollFollow);
305
+ TypeStore.add("ViewBox", ViewBox);
306
+ TypeStore.add("Avatar", Avatar);
307
+ TypeStore.add("XRControllerFollow", XRControllerFollow);
308
+ TypeStore.add("XRControllerModel", XRControllerModel);
309
+ TypeStore.add("XRControllerMovement", XRControllerMovement);
310
+ TypeStore.add("TeleportTarget", TeleportTarget);
311
+ TypeStore.add("WebARCameraBackground", WebARCameraBackground);
312
+ TypeStore.add("WebARSessionRoot", WebARSessionRoot);
313
+ TypeStore.add("WebXR", WebXR);
314
+ TypeStore.add("AvatarMarker", AvatarMarker);
315
+ TypeStore.add("WebXRImageTracking", WebXRImageTracking);
316
+ TypeStore.add("WebXRPlaneTracking", WebXRPlaneTracking);
317
+ TypeStore.add("XRRig", XRRig);
318
+ TypeStore.add("XRFlag", XRFlag);
319
+ TypeStore.add("PlayerSync", PlayerSync);
320
+ TypeStore.add("PlayerState", PlayerState);
321
+ TypeStore.add("PresentationMode", PresentationMode);
322
+ }
@@ -1,5 +1,3 @@
1
- import { isLocalNetwork } from "../engine_networking_utils.js";
2
- import { getParam } from "../engine_utils.js";
3
1
  import { addLog, BalloonOptions, clearMessages, LogType, setAllowBalloonMessages, setAllowOverlayMessages } from "./debug_overlay.js";
4
2
 
5
3
  export {
@@ -11,10 +9,9 @@ export {
11
9
  // eslint-disable-next-line @typescript-eslint/no-deprecated
12
10
  setAllowOverlayMessages,
13
11
  };
12
+ export { isDevEnvironment, setDevEnvironment } from "./debug_environment.js";
14
13
  export { enableSpatialConsole } from "./debug_spatial_console.js";
15
14
 
16
- const noDevLogs = getParam("nodevlogs");
17
-
18
15
 
19
16
  /** Displays a debug message on screen for a certain amount of time */
20
17
  export function showBalloonMessage(text: string, options?: Partial<BalloonOptions>): void {
@@ -28,26 +25,4 @@ export function showBalloonWarning(text: string, options?: Partial<BalloonOption
28
25
  /** Displays an error message on screen for a certain amount of time */
29
26
  export function showBalloonError(text: string, options?: Partial<BalloonOptions>): void {
30
27
  showBalloonMessage(text, { ...options, type: LogType.Error });
31
- }
32
-
33
- let _manuallySetDevEnvironment: boolean | undefined;
34
- let _cachedDevEnvironment: boolean | undefined;
35
-
36
- /** True when the application runs on a local url */
37
- export function isDevEnvironment(): boolean {
38
- if (noDevLogs) return false;
39
- if (_manuallySetDevEnvironment !== undefined) return _manuallySetDevEnvironment;
40
- if (_cachedDevEnvironment !== undefined) return _cachedDevEnvironment;
41
-
42
- let res = isLocalNetwork();
43
- if (!res) {
44
- // is stackblitz?
45
- res = window.location.hostname.endsWith(".local-credentialless.webcontainer.io");
46
- }
47
- _cachedDevEnvironment = res;
48
- return res;
49
- }
50
- /** Enforce the dev environment flag to be true or false */
51
- export function setDevEnvironment(val: boolean): void {
52
- _manuallySetDevEnvironment = val;
53
28
  }
@@ -0,0 +1,26 @@
1
+ import { isLocalNetwork } from "../engine_networking_utils.js";
2
+ import { getParam } from "../engine_utils.js";
3
+
4
+ const noDevLogs = getParam("nodevlogs");
5
+
6
+ let _manuallySetDevEnvironment: boolean | undefined;
7
+ let _cachedDevEnvironment: boolean | undefined;
8
+
9
+ /** True when the application runs on a local url */
10
+ export function isDevEnvironment(): boolean {
11
+ if (noDevLogs) return false;
12
+ if (_manuallySetDevEnvironment !== undefined) return _manuallySetDevEnvironment;
13
+ if (_cachedDevEnvironment !== undefined) return _cachedDevEnvironment;
14
+
15
+ let res = isLocalNetwork();
16
+ if (!res) {
17
+ // is stackblitz?
18
+ res = window.location.hostname.endsWith(".local-credentialless.webcontainer.io");
19
+ }
20
+ _cachedDevEnvironment = res;
21
+ return res;
22
+ }
23
+ /** Enforce the dev environment flag to be true or false */
24
+ export function setDevEnvironment(val: boolean): void {
25
+ _manuallySetDevEnvironment = val;
26
+ }
@@ -245,8 +245,9 @@ export function clearMessages() {
245
245
  }
246
246
 
247
247
 
248
+ // @import is OK here — the debug overlay is only created on errors, so this doesn't
249
+ // add to normal page load. Keep in sync with font-urls.js if the URL changes.
248
250
  const logsContainerStyles = `
249
-
250
251
  @import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');
251
252
 
252
253
  div[data-needle_engine_debug_overlay] {
@@ -6,7 +6,7 @@ import { ContextRegistry } from "../engine_context_registry.js";
6
6
  import { OneEuroFilterXYZ } from "../engine_math.js";
7
7
  import { lookAtObject } from "../engine_three_utils.js";
8
8
  import type { IContext, IGameObject } from "../engine_types.js";
9
- import { isDevEnvironment } from "./debug.js";
9
+ import { isDevEnvironment } from "./debug_environment.js";
10
10
  import { onError } from "./debug_overlay.js";
11
11
 
12
12