@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.
- package/components.needle.json +1 -1
- package/dist/gltf-progressive-BryRjllq.min.js +10 -0
- package/dist/gltf-progressive-Cl167Vjx.js +1537 -0
- package/dist/gltf-progressive-DJBMx-zB.umd.cjs +10 -0
- package/dist/gltf-progressive.worker-BqODMeeW.js +23 -0
- package/dist/needle-engine.bundle-BTIpdDE9.umd.cjs +1654 -0
- package/dist/{needle-engine.bundle-CQFEuAQB.js → needle-engine.bundle-CH2ZOagS.js} +35829 -35882
- package/dist/needle-engine.bundle-D5h7xxUH.min.js +1654 -0
- package/dist/needle-engine.d.ts +105 -39
- package/dist/needle-engine.js +608 -607
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/three-examples.js +7815 -6828
- package/dist/three-examples.min.js +17 -15
- package/dist/three-examples.umd.cjs +17 -15
- package/dist/three.js +15994 -24892
- package/dist/three.min.js +214 -214
- package/dist/three.umd.cjs +208 -208
- package/dist/vendor-CntUvmJu.umd.cjs +1116 -0
- package/dist/{vendor-BPp9F5vR.min.js → vendor-DPbfJJ4d.min.js} +94 -94
- package/dist/{vendor-CQMI3jTS.js → vendor-vHLk8sXu.js} +8558 -8516
- package/lib/engine/analytics/index.js.map +1 -1
- package/lib/engine/codegen/register_types.d.ts +1 -1
- package/lib/engine/codegen/register_types.js +159 -157
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/debug/debug.d.ts +1 -4
- package/lib/engine/debug/debug.js +1 -25
- package/lib/engine/debug/debug.js.map +1 -1
- package/lib/engine/debug/debug_environment.d.ts +4 -0
- package/lib/engine/debug/debug_environment.js +26 -0
- package/lib/engine/debug/debug_environment.js.map +1 -0
- package/lib/engine/debug/debug_overlay.js +2 -1
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/debug/debug_spatial_console.js +1 -1
- package/lib/engine/debug/debug_spatial_console.js.map +1 -1
- package/lib/engine/engine_audio.js +0 -1
- package/lib/engine/engine_audio.js.map +1 -1
- package/lib/engine/engine_components.js +6 -3
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.d.ts +0 -1
- package/lib/engine/engine_gltf_builtin_components.js +5 -4
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_init.d.ts +10 -0
- package/lib/engine/engine_init.js +44 -0
- package/lib/engine/engine_init.js.map +1 -0
- package/lib/engine/engine_loaders.d.ts +2 -0
- package/lib/engine/engine_loaders.js +2 -1
- package/lib/engine/engine_loaders.js.map +1 -1
- package/lib/engine/engine_modules.d.ts +8 -0
- package/lib/engine/engine_modules.js +1 -0
- package/lib/engine/engine_modules.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +2 -1
- package/lib/engine/engine_networking.js +3 -1
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking_blob.js +3 -3
- package/lib/engine/engine_networking_blob.js.map +1 -1
- package/lib/engine/engine_networking_peer.d.ts +2 -2
- package/lib/engine/engine_networking_peer.js +7 -6
- package/lib/engine/engine_networking_peer.js.map +1 -1
- package/lib/engine/engine_networking_streams.d.ts +2 -1
- package/lib/engine/engine_networking_streams.js +2 -2
- package/lib/engine/engine_networking_streams.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +2 -0
- package/lib/engine/engine_physics_rapier.js +35 -4
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_shims.d.ts +1 -0
- package/lib/engine/engine_shims.js +20 -19
- package/lib/engine/engine_shims.js.map +1 -1
- package/lib/engine/engine_tonemapping.js +0 -1
- package/lib/engine/engine_tonemapping.js.map +1 -1
- package/lib/engine/engine_types.d.ts +8 -0
- package/lib/engine/engine_typestore.d.ts +11 -0
- package/lib/engine/engine_typestore.js +29 -0
- package/lib/engine/engine_typestore.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_animator_controller_model.d.ts +1 -1
- package/lib/engine/js-extensions/Camera.d.ts +1 -1
- package/lib/engine/js-extensions/Camera.js +43 -37
- package/lib/engine/js-extensions/Camera.js.map +1 -1
- package/lib/engine/js-extensions/Layers.js +0 -1
- package/lib/engine/js-extensions/Layers.js.map +1 -1
- package/lib/engine/js-extensions/Object3D.d.ts +1 -0
- package/lib/engine/js-extensions/Object3D.js +173 -167
- package/lib/engine/js-extensions/Object3D.js.map +1 -1
- package/lib/engine/js-extensions/Vector.d.ts +1 -0
- package/lib/engine/js-extensions/Vector.js +10 -4
- package/lib/engine/js-extensions/Vector.js.map +1 -1
- package/lib/engine/js-extensions/index.d.ts +0 -3
- package/lib/engine/js-extensions/index.js +0 -2
- package/lib/engine/js-extensions/index.js.map +1 -1
- package/lib/engine/webcomponents/WebXRButtons.js +11 -13
- package/lib/engine/webcomponents/WebXRButtons.js.map +1 -1
- package/lib/engine/webcomponents/buttons.js +4 -4
- package/lib/engine/webcomponents/buttons.js.map +1 -1
- package/lib/engine/webcomponents/font-urls.d.ts +2 -0
- package/lib/engine/webcomponents/font-urls.js +8 -0
- package/lib/engine/webcomponents/font-urls.js.map +1 -0
- package/lib/engine/webcomponents/fonts.d.ts +2 -2
- package/lib/engine/webcomponents/fonts.js +12 -7
- package/lib/engine/webcomponents/fonts.js.map +1 -1
- package/lib/engine/webcomponents/init.d.ts +4 -0
- package/lib/engine/webcomponents/init.js +20 -0
- package/lib/engine/webcomponents/init.js.map +1 -0
- package/lib/engine/webcomponents/logo-element.js +2 -2
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/menu-priority.d.ts +10 -0
- package/lib/engine/webcomponents/needle menu/menu-priority.js +21 -0
- package/lib/engine/webcomponents/needle menu/menu-priority.js.map +1 -0
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.d.ts +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +7 -11
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-button.js +0 -3
- package/lib/engine/webcomponents/needle-button.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.js +4 -10
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/webcomponents/quicklook-handler.d.ts +29 -0
- package/lib/engine/webcomponents/quicklook-handler.js +21 -0
- package/lib/engine/webcomponents/quicklook-handler.js.map +1 -0
- package/lib/engine/xr/NeedleXRSession.d.ts +1 -0
- package/lib/engine/xr/NeedleXRSession.js +1 -0
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/AnimationUtilsAutoplay.d.ts +1 -1
- package/lib/engine-components/AnimationUtilsAutoplay.js +29 -23
- package/lib/engine-components/AnimationUtilsAutoplay.js.map +1 -1
- package/lib/engine-components/Animator.d.ts +1 -1
- package/lib/engine-components/AnimatorController.d.ts +1 -1
- package/lib/engine-components/CameraUtils.d.ts +1 -1
- package/lib/engine-components/CameraUtils.js +79 -73
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +2 -0
- package/lib/engine-components/Collider.js +25 -3
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/LookAtConstraint.d.ts +34 -1
- package/lib/engine-components/LookAtConstraint.js +54 -1
- package/lib/engine-components/LookAtConstraint.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +2 -1
- package/lib/engine-components/Networking.js +2 -1
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.d.ts +1 -0
- package/lib/engine-components/SceneSwitcher.js +3 -1
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/Skybox.d.ts +1 -0
- package/lib/engine-components/Skybox.js +4 -2
- package/lib/engine-components/Skybox.js.map +1 -1
- package/lib/engine-components/SyncedRoom.d.ts +1 -0
- package/lib/engine-components/SyncedRoom.js +1 -0
- package/lib/engine-components/SyncedRoom.js.map +1 -1
- package/lib/engine-components/api.d.ts +5 -8
- package/lib/engine-components/api.js +4 -7
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +8 -0
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +18 -5
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/lib/engine-components/postprocessing/utils.js +7 -2
- package/lib/engine-components/postprocessing/utils.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.d.ts +1 -1
- package/lib/engine-components/timeline/TimelineTracks.js +4 -2
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.d.ts +0 -8
- package/lib/engine-components/webxr/WebXR.d.ts +15 -2
- package/lib/engine-components/webxr/WebXR.js +15 -2
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/lib/needle-engine.d.ts +0 -1
- package/lib/needle-engine.js +2 -1
- package/lib/needle-engine.js.map +1 -1
- package/package.json +11 -3
- package/plugins/vite/ai.d.ts +11 -7
- package/plugins/vite/ai.js +21 -16
- package/plugins/vite/asap.js +42 -2
- package/plugins/vite/dependencies.js +110 -16
- package/plugins/vite/index.d.ts +1 -0
- package/plugins/vite/index.js +4 -0
- package/plugins/vite/treeshake.d.ts +11 -0
- package/plugins/vite/treeshake.js +216 -0
- package/src/engine/analytics/index.ts +1 -1
- package/src/engine/codegen/register_types.ts +159 -157
- package/src/engine/debug/debug.ts +1 -26
- package/src/engine/debug/debug_environment.ts +26 -0
- package/src/engine/debug/debug_overlay.ts +2 -1
- package/src/engine/debug/debug_spatial_console.ts +1 -1
- package/src/engine/engine_audio.ts +1 -2
- package/src/engine/engine_components.ts +6 -3
- package/src/engine/engine_gltf_builtin_components.ts +4 -5
- package/src/engine/engine_init.ts +45 -0
- package/src/engine/engine_loaders.ts +2 -1
- package/src/engine/engine_modules.ts +3 -0
- package/src/engine/engine_networking.ts +5 -1
- package/src/engine/engine_networking_blob.ts +3 -3
- package/src/engine/engine_networking_peer.ts +8 -6
- package/src/engine/engine_networking_streams.ts +4 -3
- package/src/engine/engine_physics_rapier.ts +37 -4
- package/src/engine/engine_shims.ts +22 -20
- package/src/engine/engine_tonemapping.ts +0 -1
- package/src/engine/engine_types.ts +9 -0
- package/src/engine/engine_typestore.ts +29 -0
- package/src/engine/extensions/NEEDLE_animator_controller_model.ts +1 -1
- package/src/engine/js-extensions/Camera.ts +40 -33
- package/src/engine/js-extensions/Layers.ts +1 -2
- package/src/engine/js-extensions/Object3D.ts +174 -170
- package/src/engine/js-extensions/Vector.ts +11 -4
- package/src/engine/js-extensions/index.ts +0 -3
- package/src/engine/webcomponents/WebXRButtons.ts +12 -13
- package/src/engine/webcomponents/buttons.ts +4 -4
- package/src/engine/webcomponents/font-urls.js +9 -0
- package/src/engine/webcomponents/fonts.ts +12 -7
- package/src/engine/webcomponents/init.ts +23 -0
- package/src/engine/webcomponents/logo-element.ts +2 -2
- package/src/engine/webcomponents/needle menu/menu-priority.ts +20 -0
- package/src/engine/webcomponents/needle menu/needle-menu.ts +8 -13
- package/src/engine/webcomponents/needle-button.ts +0 -3
- package/src/engine/webcomponents/needle-engine.ts +4 -13
- package/src/engine/webcomponents/quicklook-handler.ts +37 -0
- package/src/engine/xr/NeedleXRSession.ts +2 -1
- package/src/engine-components/AnimationUtilsAutoplay.ts +8 -3
- package/src/engine-components/AnimatorController.ts +1 -1
- package/src/engine-components/CameraUtils.ts +15 -8
- package/src/engine-components/Collider.ts +24 -3
- package/src/engine-components/LookAtConstraint.ts +46 -1
- package/src/engine-components/Networking.ts +3 -1
- package/src/engine-components/SceneSwitcher.ts +3 -1
- package/src/engine-components/Skybox.ts +4 -2
- package/src/engine-components/SyncedRoom.ts +2 -0
- package/src/engine-components/api.ts +5 -10
- package/src/engine-components/export/usdz/USDZExporter.ts +9 -0
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +19 -7
- package/src/engine-components/postprocessing/utils.ts +7 -2
- package/src/engine-components/timeline/TimelineTracks.ts +6 -2
- package/src/engine-components/web/ScrollFollow.ts +0 -2
- package/src/engine-components/webxr/WebXR.ts +15 -2
- package/src/needle-engine.ts +2 -1
- package/dist/gltf-progressive-BBIL1q1j.umd.cjs +0 -4022
- package/dist/gltf-progressive-BbHl9z0v.js +0 -28272
- package/dist/gltf-progressive-Clq_N7Zx.min.js +0 -4022
- package/dist/gltf-progressive.worker-CCrD-Ycm.js +0 -3
- package/dist/needle-engine.bundle-CrqNZdEN.umd.cjs +0 -1657
- package/dist/needle-engine.bundle-DyVf6QdN.min.js +0 -1657
- 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
|
|
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
|
-
|
|
165
|
-
TypeStore.add("
|
|
166
|
-
TypeStore.add("
|
|
167
|
-
TypeStore.add("
|
|
168
|
-
TypeStore.add("
|
|
169
|
-
TypeStore.add("
|
|
170
|
-
TypeStore.add("
|
|
171
|
-
TypeStore.add("
|
|
172
|
-
TypeStore.add("
|
|
173
|
-
TypeStore.add("
|
|
174
|
-
TypeStore.add("
|
|
175
|
-
TypeStore.add("
|
|
176
|
-
TypeStore.add("
|
|
177
|
-
TypeStore.add("
|
|
178
|
-
TypeStore.add("
|
|
179
|
-
TypeStore.add("
|
|
180
|
-
TypeStore.add("
|
|
181
|
-
TypeStore.add("
|
|
182
|
-
TypeStore.add("
|
|
183
|
-
TypeStore.add("
|
|
184
|
-
TypeStore.add("
|
|
185
|
-
TypeStore.add("
|
|
186
|
-
TypeStore.add("
|
|
187
|
-
TypeStore.add("
|
|
188
|
-
TypeStore.add("
|
|
189
|
-
TypeStore.add("
|
|
190
|
-
TypeStore.add("
|
|
191
|
-
TypeStore.add("
|
|
192
|
-
TypeStore.add("
|
|
193
|
-
TypeStore.add("
|
|
194
|
-
TypeStore.add("
|
|
195
|
-
TypeStore.add("
|
|
196
|
-
TypeStore.add("
|
|
197
|
-
TypeStore.add("
|
|
198
|
-
TypeStore.add("
|
|
199
|
-
TypeStore.add("
|
|
200
|
-
TypeStore.add("
|
|
201
|
-
TypeStore.add("
|
|
202
|
-
TypeStore.add("
|
|
203
|
-
TypeStore.add("
|
|
204
|
-
TypeStore.add("
|
|
205
|
-
TypeStore.add("
|
|
206
|
-
TypeStore.add("
|
|
207
|
-
TypeStore.add("
|
|
208
|
-
TypeStore.add("
|
|
209
|
-
TypeStore.add("
|
|
210
|
-
TypeStore.add("
|
|
211
|
-
TypeStore.add("
|
|
212
|
-
TypeStore.add("
|
|
213
|
-
TypeStore.add("
|
|
214
|
-
TypeStore.add("
|
|
215
|
-
TypeStore.add("
|
|
216
|
-
TypeStore.add("
|
|
217
|
-
TypeStore.add("
|
|
218
|
-
TypeStore.add("
|
|
219
|
-
TypeStore.add("
|
|
220
|
-
TypeStore.add("
|
|
221
|
-
TypeStore.add("
|
|
222
|
-
TypeStore.add("
|
|
223
|
-
TypeStore.add("
|
|
224
|
-
TypeStore.add("
|
|
225
|
-
TypeStore.add("
|
|
226
|
-
TypeStore.add("
|
|
227
|
-
TypeStore.add("
|
|
228
|
-
TypeStore.add("
|
|
229
|
-
TypeStore.add("
|
|
230
|
-
TypeStore.add("
|
|
231
|
-
TypeStore.add("
|
|
232
|
-
TypeStore.add("
|
|
233
|
-
TypeStore.add("
|
|
234
|
-
TypeStore.add("
|
|
235
|
-
TypeStore.add("
|
|
236
|
-
TypeStore.add("
|
|
237
|
-
TypeStore.add("
|
|
238
|
-
TypeStore.add("
|
|
239
|
-
TypeStore.add("
|
|
240
|
-
TypeStore.add("
|
|
241
|
-
TypeStore.add("
|
|
242
|
-
TypeStore.add("
|
|
243
|
-
TypeStore.add("
|
|
244
|
-
TypeStore.add("
|
|
245
|
-
TypeStore.add("
|
|
246
|
-
TypeStore.add("
|
|
247
|
-
TypeStore.add("
|
|
248
|
-
TypeStore.add("
|
|
249
|
-
TypeStore.add("
|
|
250
|
-
TypeStore.add("
|
|
251
|
-
TypeStore.add("
|
|
252
|
-
TypeStore.add("
|
|
253
|
-
TypeStore.add("
|
|
254
|
-
TypeStore.add("
|
|
255
|
-
TypeStore.add("
|
|
256
|
-
TypeStore.add("
|
|
257
|
-
TypeStore.add("
|
|
258
|
-
TypeStore.add("
|
|
259
|
-
TypeStore.add("
|
|
260
|
-
TypeStore.add("
|
|
261
|
-
TypeStore.add("
|
|
262
|
-
TypeStore.add("
|
|
263
|
-
TypeStore.add("
|
|
264
|
-
TypeStore.add("
|
|
265
|
-
TypeStore.add("
|
|
266
|
-
TypeStore.add("
|
|
267
|
-
TypeStore.add("
|
|
268
|
-
TypeStore.add("
|
|
269
|
-
TypeStore.add("
|
|
270
|
-
TypeStore.add("
|
|
271
|
-
TypeStore.add("
|
|
272
|
-
TypeStore.add("
|
|
273
|
-
TypeStore.add("
|
|
274
|
-
TypeStore.add("
|
|
275
|
-
TypeStore.add("
|
|
276
|
-
TypeStore.add("
|
|
277
|
-
TypeStore.add("
|
|
278
|
-
TypeStore.add("
|
|
279
|
-
TypeStore.add("
|
|
280
|
-
TypeStore.add("
|
|
281
|
-
TypeStore.add("
|
|
282
|
-
TypeStore.add("
|
|
283
|
-
TypeStore.add("
|
|
284
|
-
TypeStore.add("
|
|
285
|
-
TypeStore.add("
|
|
286
|
-
TypeStore.add("
|
|
287
|
-
TypeStore.add("
|
|
288
|
-
TypeStore.add("
|
|
289
|
-
TypeStore.add("
|
|
290
|
-
TypeStore.add("
|
|
291
|
-
TypeStore.add("
|
|
292
|
-
TypeStore.add("
|
|
293
|
-
TypeStore.add("
|
|
294
|
-
TypeStore.add("
|
|
295
|
-
TypeStore.add("
|
|
296
|
-
TypeStore.add("
|
|
297
|
-
TypeStore.add("
|
|
298
|
-
TypeStore.add("
|
|
299
|
-
TypeStore.add("
|
|
300
|
-
TypeStore.add("
|
|
301
|
-
TypeStore.add("
|
|
302
|
-
TypeStore.add("
|
|
303
|
-
TypeStore.add("
|
|
304
|
-
TypeStore.add("
|
|
305
|
-
TypeStore.add("
|
|
306
|
-
TypeStore.add("
|
|
307
|
-
TypeStore.add("
|
|
308
|
-
TypeStore.add("
|
|
309
|
-
TypeStore.add("
|
|
310
|
-
TypeStore.add("
|
|
311
|
-
TypeStore.add("
|
|
312
|
-
TypeStore.add("
|
|
313
|
-
TypeStore.add("
|
|
314
|
-
TypeStore.add("
|
|
315
|
-
TypeStore.add("
|
|
316
|
-
TypeStore.add("
|
|
317
|
-
TypeStore.add("
|
|
318
|
-
TypeStore.add("
|
|
319
|
-
TypeStore.add("
|
|
320
|
-
TypeStore.add("
|
|
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 "./
|
|
9
|
+
import { isDevEnvironment } from "./debug_environment.js";
|
|
10
10
|
import { onError } from "./debug_overlay.js";
|
|
11
11
|
|
|
12
12
|
|