@littlecarlito/blorktools 0.50.4 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/bin/cli.js +69 -0
  2. package/package.json +13 -7
  3. package/src/asset_debugger/axis-indicator/axis-indicator.css +6 -0
  4. package/src/asset_debugger/axis-indicator/axis-indicator.html +20 -0
  5. package/src/asset_debugger/axis-indicator/axis-indicator.js +822 -0
  6. package/src/asset_debugger/debugger-scene/debugger-scene.css +142 -0
  7. package/src/asset_debugger/debugger-scene/debugger-scene.html +80 -0
  8. package/src/asset_debugger/debugger-scene/debugger-scene.js +791 -0
  9. package/src/asset_debugger/header/header.css +73 -0
  10. package/src/asset_debugger/header/header.html +24 -0
  11. package/src/asset_debugger/header/header.js +224 -0
  12. package/src/asset_debugger/index.html +76 -0
  13. package/src/asset_debugger/landing-page/landing-page.css +396 -0
  14. package/src/asset_debugger/landing-page/landing-page.html +81 -0
  15. package/src/asset_debugger/landing-page/landing-page.js +611 -0
  16. package/src/asset_debugger/loading-splash/loading-splash.css +195 -0
  17. package/src/asset_debugger/loading-splash/loading-splash.html +22 -0
  18. package/src/asset_debugger/loading-splash/loading-splash.js +59 -0
  19. package/src/asset_debugger/loading-splash/preview-loading-splash.js +66 -0
  20. package/src/asset_debugger/main.css +14 -0
  21. package/src/asset_debugger/modals/examples-modal/examples-modal.css +41 -0
  22. package/src/asset_debugger/modals/examples-modal/examples-modal.html +18 -0
  23. package/src/asset_debugger/modals/examples-modal/examples-modal.js +111 -0
  24. package/src/asset_debugger/modals/examples-modal/examples.js +125 -0
  25. package/src/asset_debugger/modals/html-editor-modal/html-editor-modal.css +452 -0
  26. package/src/asset_debugger/modals/html-editor-modal/html-editor-modal.html +87 -0
  27. package/src/asset_debugger/modals/html-editor-modal/html-editor-modal.js +675 -0
  28. package/src/asset_debugger/modals/mesh-info-modal/mesh-info-modal.css +219 -0
  29. package/src/asset_debugger/modals/mesh-info-modal/mesh-info-modal.html +20 -0
  30. package/src/asset_debugger/modals/mesh-info-modal/mesh-info-modal.js +548 -0
  31. package/src/asset_debugger/modals/settings-modal/settings-modal.css +103 -0
  32. package/src/asset_debugger/modals/settings-modal/settings-modal.html +158 -0
  33. package/src/asset_debugger/modals/settings-modal/settings-modal.js +475 -0
  34. package/src/asset_debugger/panels/asset-panel/asset-panel.css +263 -0
  35. package/src/asset_debugger/panels/asset-panel/asset-panel.html +123 -0
  36. package/src/asset_debugger/panels/asset-panel/asset-panel.js +136 -0
  37. package/src/asset_debugger/panels/asset-panel/atlas-heading/atlas-heading.css +94 -0
  38. package/src/asset_debugger/panels/asset-panel/atlas-heading/atlas-heading.js +312 -0
  39. package/src/asset_debugger/panels/asset-panel/mesh-heading/mesh-heading.css +129 -0
  40. package/src/asset_debugger/panels/asset-panel/mesh-heading/mesh-heading.js +486 -0
  41. package/src/asset_debugger/panels/asset-panel/rig-heading/rig-heading.css +545 -0
  42. package/src/asset_debugger/panels/asset-panel/rig-heading/rig-heading.js +538 -0
  43. package/src/asset_debugger/panels/asset-panel/uv-heading/uv-heading.css +70 -0
  44. package/src/asset_debugger/panels/asset-panel/uv-heading/uv-heading.js +586 -0
  45. package/src/asset_debugger/panels/world-panel/world-panel.css +364 -0
  46. package/src/asset_debugger/panels/world-panel/world-panel.html +173 -0
  47. package/src/asset_debugger/panels/world-panel/world-panel.js +1891 -0
  48. package/src/asset_debugger/router.js +190 -0
  49. package/src/asset_debugger/util/animation/playback/animation-playback-controller.js +150 -0
  50. package/src/asset_debugger/util/animation/playback/animation-preview-controller.js +316 -0
  51. package/src/asset_debugger/util/animation/playback/css3d-bounce-controller.js +400 -0
  52. package/src/asset_debugger/util/animation/playback/css3d-reversal-controller.js +821 -0
  53. package/src/asset_debugger/util/animation/render/css3d-prerender-controller.js +696 -0
  54. package/src/asset_debugger/util/animation/render/debug-texture-factory.js +0 -0
  55. package/src/asset_debugger/util/animation/render/iframe2texture-render-controller.js +199 -0
  56. package/src/asset_debugger/util/animation/render/image2texture-prerender-controller.js +461 -0
  57. package/src/asset_debugger/util/animation/render/pbr-material-factory.js +82 -0
  58. package/src/asset_debugger/util/common.css +280 -0
  59. package/src/asset_debugger/util/data/animation-classifier.js +323 -0
  60. package/src/asset_debugger/util/data/duplicate-handler.js +20 -0
  61. package/src/asset_debugger/util/data/glb-buffer-manager.js +407 -0
  62. package/src/asset_debugger/util/data/glb-classifier.js +290 -0
  63. package/src/asset_debugger/util/data/html-formatter.js +76 -0
  64. package/src/asset_debugger/util/data/html-linter.js +276 -0
  65. package/src/asset_debugger/util/data/localstorage-manager.js +265 -0
  66. package/src/asset_debugger/util/data/mesh-html-manager.js +295 -0
  67. package/src/asset_debugger/util/data/string-serder.js +303 -0
  68. package/src/asset_debugger/util/data/texture-classifier.js +663 -0
  69. package/src/asset_debugger/util/data/upload/background-file-handler.js +292 -0
  70. package/src/asset_debugger/util/data/upload/dropzone-preview-controller.js +396 -0
  71. package/src/asset_debugger/util/data/upload/file-upload-manager.js +495 -0
  72. package/src/asset_debugger/util/data/upload/glb-file-handler.js +36 -0
  73. package/src/asset_debugger/util/data/upload/glb-preview-controller.js +317 -0
  74. package/src/asset_debugger/util/data/upload/lighting-file-handler.js +194 -0
  75. package/src/asset_debugger/util/data/upload/model-file-manager.js +104 -0
  76. package/src/asset_debugger/util/data/upload/texture-file-handler.js +166 -0
  77. package/src/asset_debugger/util/data/upload/zip-handler.js +686 -0
  78. package/src/asset_debugger/util/loaders/html2canvas-loader.js +107 -0
  79. package/src/asset_debugger/util/rig/bone-kinematics.js +403 -0
  80. package/src/asset_debugger/util/rig/rig-constraint-manager.js +618 -0
  81. package/src/asset_debugger/util/rig/rig-controller.js +612 -0
  82. package/src/asset_debugger/util/rig/rig-factory.js +628 -0
  83. package/src/asset_debugger/util/rig/rig-handle-factory.js +46 -0
  84. package/src/asset_debugger/util/rig/rig-label-factory.js +441 -0
  85. package/src/asset_debugger/util/rig/rig-mouse-handler.js +377 -0
  86. package/src/asset_debugger/util/rig/rig-state-manager.js +175 -0
  87. package/src/asset_debugger/util/rig/rig-tooltip-manager.js +267 -0
  88. package/src/asset_debugger/util/rig/rig-ui-factory.js +700 -0
  89. package/src/asset_debugger/util/scene/background-manager.js +284 -0
  90. package/src/asset_debugger/util/scene/camera-controller.js +243 -0
  91. package/src/asset_debugger/util/scene/css3d-debug-controller.js +406 -0
  92. package/src/asset_debugger/util/scene/css3d-frame-factory.js +113 -0
  93. package/src/asset_debugger/util/scene/css3d-scene-manager.js +529 -0
  94. package/src/asset_debugger/util/scene/glb-controller.js +208 -0
  95. package/src/asset_debugger/util/scene/lighting-manager.js +690 -0
  96. package/src/asset_debugger/util/scene/threejs-model-manager.js +437 -0
  97. package/src/asset_debugger/util/scene/threejs-preview-manager.js +207 -0
  98. package/src/asset_debugger/util/scene/threejs-preview-setup.js +478 -0
  99. package/src/asset_debugger/util/scene/threejs-scene-controller.js +286 -0
  100. package/src/asset_debugger/util/scene/ui-manager.js +107 -0
  101. package/src/asset_debugger/util/state/animation-state.js +128 -0
  102. package/src/asset_debugger/util/state/css3d-state.js +83 -0
  103. package/src/asset_debugger/util/state/glb-preview-state.js +31 -0
  104. package/src/asset_debugger/util/state/log-util.js +197 -0
  105. package/src/asset_debugger/util/state/scene-state.js +452 -0
  106. package/src/asset_debugger/util/state/threejs-state.js +54 -0
  107. package/src/asset_debugger/util/workers/lighting-worker.js +61 -0
  108. package/src/asset_debugger/util/workers/model-worker.js +109 -0
  109. package/src/asset_debugger/util/workers/texture-worker.js +54 -0
  110. package/src/asset_debugger/util/workers/worker-manager.js +212 -0
  111. package/src/asset_debugger/widgets/mesh-info-widget.js +280 -0
  112. package/src/index.html +261 -0
  113. package/src/index.js +8 -0
  114. package/vite.config.js +66 -0
@@ -0,0 +1,195 @@
1
+ .loading-splash {
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ width: 100%;
6
+ height: 100%;
7
+ background-color: #0a0a0a;
8
+ display: flex;
9
+ justify-content: center;
10
+ align-items: center;
11
+ z-index: 9999;
12
+ opacity: 1;
13
+ transition: opacity 0.5s ease-in-out;
14
+ overflow: hidden;
15
+ font-family: monospace;
16
+ }
17
+
18
+ .loading-splash.fade-out {
19
+ opacity: 0;
20
+ pointer-events: none;
21
+ }
22
+
23
+ .loading-content {
24
+ text-align: center;
25
+ color: #2ecc71;
26
+ font-family: 'Courier New', monospace;
27
+ position: relative;
28
+ width: 100%;
29
+ max-width: 600px;
30
+ padding: 2rem;
31
+ }
32
+
33
+ .loading-title {
34
+ margin-bottom: 30px;
35
+ letter-spacing: 3px;
36
+ font-size: 2.5rem;
37
+ font-weight: bold;
38
+ color: #2ecc71;
39
+ text-transform: uppercase;
40
+ text-shadow: 0 0 10px rgba(46, 204, 113, 0.7);
41
+ }
42
+
43
+ .loading-spinner-container {
44
+ position: relative;
45
+ width: 120px;
46
+ height: 120px;
47
+ margin: 30px auto;
48
+ }
49
+
50
+ /* Atomic spinner styles */
51
+ .atomic-spinner {
52
+ position: relative;
53
+ width: 100%;
54
+ height: 100%;
55
+ }
56
+
57
+ .nucleus {
58
+ position: absolute;
59
+ width: 30px;
60
+ height: 30px;
61
+ background-color: #2ecc71;
62
+ border-radius: 50%;
63
+ top: 50%;
64
+ left: 50%;
65
+ transform: translate(-50%, -50%);
66
+ box-shadow: 0 0 15px #2ecc71;
67
+ }
68
+
69
+ .electron-orbit {
70
+ position: absolute;
71
+ top: 0;
72
+ left: 0;
73
+ width: 100%;
74
+ height: 100%;
75
+ border: 1px dashed rgba(46, 204, 113, 0.3);
76
+ border-radius: 50%;
77
+ animation: rotate 4s linear infinite;
78
+ }
79
+
80
+ .electron-orbit:nth-child(2) {
81
+ width: 90%;
82
+ height: 90%;
83
+ top: 5%;
84
+ left: 5%;
85
+ animation-duration: 3s;
86
+ transform: rotate(60deg);
87
+ }
88
+
89
+ .electron-orbit:nth-child(3) {
90
+ width: 80%;
91
+ height: 80%;
92
+ top: 10%;
93
+ left: 10%;
94
+ animation-duration: 5s;
95
+ transform: rotate(120deg);
96
+ }
97
+
98
+ .electron {
99
+ position: absolute;
100
+ width: 12px;
101
+ height: 12px;
102
+ background-color: #2ecc71;
103
+ border-radius: 50%;
104
+ box-shadow: 0 0 10px #2ecc71;
105
+ }
106
+
107
+ .electron-orbit:nth-child(1) .electron {
108
+ top: 0;
109
+ left: 50%;
110
+ transform: translateX(-50%);
111
+ }
112
+
113
+ .electron-orbit:nth-child(2) .electron {
114
+ top: 50%;
115
+ left: 0;
116
+ transform: translateY(-50%);
117
+ }
118
+
119
+ .electron-orbit:nth-child(3) .electron {
120
+ bottom: 0;
121
+ left: 50%;
122
+ transform: translateX(-50%);
123
+ }
124
+
125
+ .loading-progress-text {
126
+ margin-top: 20px;
127
+ font-size: 16px;
128
+ color: #2ecc71;
129
+ letter-spacing: 1px;
130
+ font-family: 'Courier New', monospace;
131
+ position: relative;
132
+ }
133
+
134
+ .loading-progress-text::after {
135
+ content: "_";
136
+ animation: blink 1s step-end infinite;
137
+ }
138
+
139
+ /* Animations */
140
+ @keyframes rotate {
141
+ 0% { transform: rotateZ(0deg); }
142
+ 100% { transform: rotateZ(360deg); }
143
+ }
144
+
145
+ @keyframes pulse {
146
+ 0%, 100% { opacity: 1; }
147
+ 50% { opacity: 0.5; }
148
+ }
149
+
150
+ @keyframes blink {
151
+ 0%, 100% { opacity: 1; }
152
+ 50% { opacity: 0; }
153
+ }
154
+
155
+ .asset-preview-container {
156
+ position: relative;
157
+ }
158
+
159
+ /* Shared preview loading effect */
160
+ .preview-loading {
161
+ position: absolute;
162
+ top: 0;
163
+ left: 0;
164
+ width: 100%;
165
+ height: 100%;
166
+ background-color: rgba(10, 10, 10, 0.8);
167
+ display: flex;
168
+ flex-direction: column;
169
+ justify-content: center;
170
+ align-items: center;
171
+ z-index: 5;
172
+ }
173
+
174
+ .preview-loading-spinner {
175
+ width: 40px;
176
+ height: 40px;
177
+ position: relative;
178
+ }
179
+
180
+ .preview-loading-spinner .nucleus {
181
+ width: 10px;
182
+ height: 10px;
183
+ }
184
+
185
+ .preview-loading-spinner .electron {
186
+ width: 5px;
187
+ height: 5px;
188
+ }
189
+
190
+ .preview-loading-text {
191
+ margin-top: 10px;
192
+ font-size: 12px;
193
+ color: #2ecc71;
194
+ font-family: 'Courier New', monospace;
195
+ }
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <!-- Loading Splash Screen -->
3
+ <div id="loading-splash" class="loading-splash">
4
+ <div class="loading-content">
5
+ <h1 class="loading-title">ASSET DEBUGGER</h1>
6
+ <div class="loading-spinner-container">
7
+ <div class="atomic-spinner">
8
+ <div class="nucleus"></div>
9
+ <div class="electron-orbit">
10
+ <div class="electron"></div>
11
+ </div>
12
+ <div class="electron-orbit">
13
+ <div class="electron"></div>
14
+ </div>
15
+ <div class="electron-orbit">
16
+ <div class="electron"></div>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ <div id="loading-progress-text" class="loading-progress-text">Initializing</div>
21
+ </div>
22
+ </div>
@@ -0,0 +1,59 @@
1
+ // loading-splash.js - Updated for overlay integration
2
+
3
+ import { getCaller } from "../util/state/log-util";
4
+
5
+ /**
6
+ * Shows the loading splash screen overlay
7
+ */
8
+ export function showLoadingSplash(text = "") {
9
+
10
+ const loadingSplash = document.getElementById('loading-splash');
11
+ if (loadingSplash) {
12
+ loadingSplash.style.display = 'flex';
13
+ loadingSplash.classList.remove('fade-out');
14
+ const functionCaller = getCaller(1);
15
+ let logString = functionCaller + " requested to show load splash screen";
16
+ if(text) {
17
+ updateLoadingProgress(text);
18
+ logString += " with text \"" + text + "\"";
19
+ }
20
+ console.debug(logString);
21
+ } else {
22
+ console.error('Loading splash element not found in DOM');
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Updates the loading progress text on the splash screen
28
+ * @param {string} text - The progress message to display
29
+ */
30
+ export function updateLoadingProgress(text) {
31
+ const progressText = document.getElementById('loading-progress-text');
32
+ if (progressText) {
33
+ progressText.textContent = text;
34
+ } else {
35
+ console.error('Loading progress text element not found');
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Hides the loading splash screen with a fade-out animation
41
+ */
42
+ export function hideLoadingSplash() {
43
+ const loadingSplash = document.getElementById('loading-splash');
44
+ if (loadingSplash) {
45
+ loadingSplash.classList.add('fade-out');
46
+
47
+ setTimeout(() => {
48
+ loadingSplash.style.display = 'none';
49
+ loadingSplash.classList.remove('fade-out');
50
+ }, 500); // Match your CSS transition duration
51
+ } else {
52
+ console.warning('Loading splash element not found');
53
+ }
54
+ }
55
+
56
+ // Make functions globally available
57
+ window.showLoadingSplash = showLoadingSplash;
58
+ window.updateLoadingProgress = updateLoadingProgress;
59
+ window.hideLoadingSplash = hideLoadingSplash;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Shows loading state for a preview element
3
+ * @param {HTMLElement} previewElement - The preview element to show loading for
4
+ */
5
+ export function showPreviewLoading(previewElement) {
6
+ // Create loading overlay if it doesn't exist
7
+ if (!previewElement.querySelector('.preview-loading')) {
8
+ const loadingElement = document.createElement('div');
9
+ loadingElement.className = 'preview-loading';
10
+
11
+ const spinnerContainer = document.createElement('div');
12
+ spinnerContainer.className = 'preview-loading-spinner';
13
+
14
+ // Create atomic spinner structure
15
+ const atomicSpinner = document.createElement('div');
16
+ atomicSpinner.className = 'atomic-spinner';
17
+
18
+ const nucleus = document.createElement('div');
19
+ nucleus.className = 'nucleus';
20
+
21
+ const orbit1 = document.createElement('div');
22
+ orbit1.className = 'electron-orbit';
23
+ const electron1 = document.createElement('div');
24
+ electron1.className = 'electron';
25
+ orbit1.appendChild(electron1);
26
+
27
+ const orbit2 = document.createElement('div');
28
+ orbit2.className = 'electron-orbit';
29
+ const electron2 = document.createElement('div');
30
+ electron2.className = 'electron';
31
+ orbit2.appendChild(electron2);
32
+
33
+ const orbit3 = document.createElement('div');
34
+ orbit3.className = 'electron-orbit';
35
+ const electron3 = document.createElement('div');
36
+ electron3.className = 'electron';
37
+ orbit3.appendChild(electron3);
38
+
39
+ atomicSpinner.appendChild(nucleus);
40
+ atomicSpinner.appendChild(orbit1);
41
+ atomicSpinner.appendChild(orbit2);
42
+ atomicSpinner.appendChild(orbit3);
43
+
44
+ spinnerContainer.appendChild(atomicSpinner);
45
+
46
+ const loadingText = document.createElement('div');
47
+ loadingText.className = 'preview-loading-text';
48
+ loadingText.textContent = 'Loading...';
49
+
50
+ loadingElement.appendChild(spinnerContainer);
51
+ loadingElement.appendChild(loadingText);
52
+
53
+ previewElement.appendChild(loadingElement);
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Hides loading state for a preview element
59
+ * @param {HTMLElement} previewElement - The preview element to hide loading for
60
+ */
61
+ export function hidePreviewLoading(previewElement) {
62
+ const loadingElement = previewElement.querySelector('.preview-loading');
63
+ if (loadingElement) {
64
+ loadingElement.remove();
65
+ }
66
+ }
@@ -0,0 +1,14 @@
1
+ @import url('util/common.css');
2
+ @import url('loading-splash/loading-splash.css');
3
+ @import url('header/header.css');
4
+ @import url('landing-page/landing-page.css');
5
+ @import url('debugger-scene/debugger-scene.css');
6
+ @import url('axis-indicator/axis-indicator.css');
7
+ @import url('panels/world-panel/world-panel.css');
8
+ @import url('panels/asset-panel/asset-panel.css');
9
+ @import url('panels/asset-panel/atlas-heading/atlas-heading.css');
10
+ @import url('panels/asset-panel/rig-heading/rig-heading.css');
11
+ @import url('panels/asset-panel/uv-heading/uv-heading.css');
12
+ @import url('modals/settings-modal/settings-modal.css');
13
+ @import url('modals/mesh-info-modal/mesh-info-modal.css');
14
+ @import url('modals/examples-modal/examples-modal.css');
@@ -0,0 +1,41 @@
1
+ /* Example Modal Styles */
2
+ #load-example-modal .modal-container {
3
+ background-color: var(--panel-bg);
4
+ border: 1px solid var(--panel-border);
5
+ color: var(--text-color);
6
+ font-family: monospace;
7
+ }
8
+
9
+ #load-example-modal .modal-header {
10
+ border-bottom: 1px solid var(--panel-border);
11
+ }
12
+
13
+ #load-example-modal .modal-title {
14
+ color: var(--primary-color);
15
+ }
16
+
17
+ #load-example-modal .modal-close {
18
+ color: var(--text-color);
19
+ }
20
+
21
+ #rig-example-button {
22
+ background-color: var(--button-color);
23
+ color: white;
24
+ border: none;
25
+ padding: 10px 20px;
26
+ font-family: monospace;
27
+ font-size: 16px;
28
+ cursor: pointer;
29
+ transition: all 0.3s ease;
30
+ width: 80%;
31
+ margin: 0 auto;
32
+ display: block;
33
+ }
34
+
35
+ #rig-example-button:hover {
36
+ background-color: #0d74c7;
37
+ }
38
+
39
+ #rig-example-button:active {
40
+ transform: scale(0.98);
41
+ }
@@ -0,0 +1,18 @@
1
+ <!-- Load Example Modal -->
2
+ <div id="load-example-modal" class="modal-overlay">
3
+ <div class="modal-container">
4
+ <div class="modal-header">
5
+ <h3 class="modal-title">LOAD EXAMPLE</h3>
6
+ <button class="modal-close" id="close-example-modal">&times;</button>
7
+ </div>
8
+ <div class="modal-body" style="padding: 25px 20px;">
9
+ <div style="text-align: center; margin-bottom: 20px;">
10
+ <p style="margin-bottom: 20px; font-size: 16px;">SELECT AN EXAMPLE TO LOAD:</p>
11
+ <button id="rig-example-button">RIG EXAMPLE</button>
12
+ </div>
13
+ <div style="font-size: 12px; margin-top: 30px; color: #999; text-align: center;">
14
+ <p>EXAMPLES WILL LOAD WITHOUT REQUIRING ANY FILE UPLOADS</p>
15
+ </div>
16
+ </div>
17
+ </div>
18
+ </div>
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Examples Modal UI Component for Asset Debugger
3
+ *
4
+ * This component displays a modal with examples when no files are loaded.
5
+ */
6
+
7
+ export class ExamplesModal {
8
+ constructor(onExampleSelected) {
9
+ // Store the callback function to be called when an example is selected
10
+ this.onExampleSelected = onExampleSelected;
11
+
12
+ // Wait for HTML to be loaded before initializing elements
13
+ this.waitForElementsAndInitialize();
14
+ }
15
+
16
+ /**
17
+ * Wait for modal elements to be available in DOM before initializing
18
+ */
19
+ waitForElementsAndInitialize() {
20
+ // Check if modal container is loaded
21
+ if (document.getElementById('examples-modal-container')) {
22
+ // Check if modal content has been loaded into the container
23
+ if (document.getElementById('load-example-modal')) {
24
+ this.initializeElements();
25
+ this.initEventListeners();
26
+ } else {
27
+ // Wait for content to be loaded
28
+ setTimeout(() => this.waitForElementsAndInitialize(), 100);
29
+ }
30
+ } else {
31
+ // Wait for container to be available
32
+ setTimeout(() => this.waitForElementsAndInitialize(), 100);
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Initialize modal elements
38
+ */
39
+ initializeElements() {
40
+ // Modal elements
41
+ this.modal = document.getElementById('load-example-modal');
42
+ this.closeButton = document.getElementById('close-example-modal');
43
+ this.rigExampleButton = document.getElementById('rig-example-button');
44
+
45
+ console.log('Examples modal elements initialized:', !!this.modal, !!this.closeButton, !!this.rigExampleButton);
46
+ }
47
+
48
+ /**
49
+ * Initialize all event listeners for the examples modal
50
+ */
51
+ initEventListeners() {
52
+ // Close button event listener
53
+ if (this.closeButton) {
54
+ this.closeButton.addEventListener('click', () => this.closeModal());
55
+ }
56
+
57
+ // Rig example button event listener
58
+ if (this.rigExampleButton) {
59
+ this.rigExampleButton.addEventListener('click', () => {
60
+ this.closeModal();
61
+ // Call the callback with the example type
62
+ if (this.onExampleSelected) {
63
+ this.onExampleSelected('rig');
64
+ }
65
+ });
66
+ }
67
+
68
+ // Close modal when clicking outside
69
+ if (this.modal) {
70
+ this.modal.addEventListener('click', (event) => {
71
+ if (event.target === this.modal) {
72
+ this.closeModal();
73
+ }
74
+ });
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Open the examples modal
80
+ */
81
+ openModal() {
82
+ if (this.modal) {
83
+ this.modal.style.display = 'flex';
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Close the examples modal
89
+ */
90
+ closeModal() {
91
+ if (this.modal) {
92
+ this.modal.style.display = 'none';
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Show the modal if no files are loaded
98
+ * @param {boolean} hasFiles - Whether any files are loaded
99
+ * @returns {boolean} - Whether the modal was shown
100
+ */
101
+ showIfNoFiles(hasFiles) {
102
+ if (!hasFiles) {
103
+ console.log('No files loaded. Showing example modal...');
104
+ this.openModal();
105
+ return true;
106
+ }
107
+ return false;
108
+ }
109
+ }
110
+
111
+ export default ExamplesModal;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Asset Debugger - Examples Module
3
+ *
4
+ * This module provides examples that can be loaded in the asset debugger
5
+ * when no files are uploaded by the user.
6
+ */
7
+ import * as THREE from 'three';
8
+ import { getState, updateState } from '../../util/state/scene-state.js';
9
+ import { createMeshVisibilityPanel } from '../../panels/mesh-heading/mesh-heading.js';
10
+
11
+ /**
12
+ * Load a specific example by name
13
+ * @param {string} exampleName - The name of the example to load
14
+ * @returns {Promise} A promise that resolves when the example is loaded
15
+ */
16
+ export function loadExample(exampleName) {
17
+ console.log(`Loading example: ${exampleName}`);
18
+
19
+ switch(exampleName) {
20
+ case 'rig':
21
+ // For the rig example, create a wireframe cube as the base
22
+ return createWireframeCubeExample();
23
+
24
+ case 'wireframe-cube':
25
+ return createWireframeCubeExample();
26
+
27
+ default:
28
+ console.warn(`Unknown example: ${exampleName}`);
29
+ return Promise.reject(new Error(`Unknown example: ${exampleName}`));
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Create a wireframe cube example
35
+ * @returns {Promise} A promise that resolves when the example is loaded
36
+ */
37
+ export function createWireframeCubeExample() {
38
+ return new Promise((resolve, reject) => {
39
+ const state = getState();
40
+
41
+ // Check if scene is initialized
42
+ if (!state.scene) {
43
+ console.warn("Scene not initialized yet. Cannot create wireframe cube example.");
44
+ reject(new Error("Scene not initialized. Try again after scene is ready."));
45
+ return;
46
+ }
47
+
48
+ try {
49
+ console.log('[EXAMPLE] Creating wireframe cube example');
50
+
51
+ // Create a default dark gray background color
52
+ state.scene.background = new THREE.Color(0x222222);
53
+ console.log('[EXAMPLE] Background color set to #222222');
54
+
55
+ // Import lighting utilities to use their default lighting
56
+ import('../../util/scene/lighting-manager.js').then(lightingUtil => {
57
+ // Add standard lighting from lighting-util.js
58
+ lightingUtil.addLighting(state.scene);
59
+ console.log('[EXAMPLE] Added standard lighting using lighting-util.js');
60
+
61
+ // Create cube geometry (make it larger for visibility)
62
+ const geometry = new THREE.BoxGeometry(3, 3, 3);
63
+
64
+ // Create wireframe material with a bright color
65
+ const material = new THREE.MeshBasicMaterial({
66
+ color: 0x00ff00, // Bright green
67
+ wireframe: true,
68
+ wireframeLinewidth: 3
69
+ });
70
+
71
+ // Create mesh and add to scene
72
+ const cube = new THREE.Mesh(geometry, material);
73
+ cube.name = "WireframeCube";
74
+ state.scene.add(cube);
75
+ console.log('[EXAMPLE] Added wireframe cube to scene');
76
+
77
+ // Position the cube at the center
78
+ cube.position.set(0, 0, 0);
79
+
80
+ // Explicitly position the camera to view the cube
81
+ if (state.camera) {
82
+ // Position camera far enough to see the cube
83
+ state.camera.position.set(0, 0, 10);
84
+ state.camera.lookAt(0, 0, 0);
85
+ console.log('[EXAMPLE] Positioned camera at (0,0,10) looking at cube');
86
+
87
+ // If we have camera controls, reset them
88
+ if (state.controls) {
89
+ state.controls.target.set(0, 0, 0);
90
+ state.controls.update();
91
+ console.log('[EXAMPLE] Updated camera controls to target cube');
92
+ }
93
+ } else {
94
+ console.warn('[EXAMPLE] Camera not found in state, may not be able to see cube');
95
+ }
96
+
97
+ // Store in state
98
+ updateState('cube', cube);
99
+ updateState('meshes', [cube]);
100
+ console.log('[EXAMPLE] Updated state with cube reference');
101
+
102
+ // Set up mesh visibility panel
103
+ createMeshVisibilityPanel();
104
+
105
+ // Log scene contents for debugging
106
+ console.log('[EXAMPLE] Scene children:', state.scene.children);
107
+ console.log('[EXAMPLE] Camera position:', state.camera ? state.camera.position : 'Camera not found');
108
+
109
+ console.log('[EXAMPLE] Created wireframe cube example with standard lighting');
110
+ resolve(cube);
111
+ }).catch(error => {
112
+ console.error('[EXAMPLE] Error importing lighting-util.js:', error);
113
+ reject(error);
114
+ });
115
+ } catch (error) {
116
+ console.error('[EXAMPLE] Error creating wireframe cube example:', error);
117
+ reject(error);
118
+ }
119
+ });
120
+ }
121
+
122
+ export default {
123
+ loadExample,
124
+ createWireframeCubeExample
125
+ };