kitchen-simulator 3.16.6 → 3.16.7
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/es/index.js +41 -51
- package/lib/index.js +41 -51
- package/package.json +1 -1
package/es/index.js
CHANGED
|
@@ -23,11 +23,14 @@ function nextFrame() {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Track
|
|
26
|
+
* Track 3D asset network activity (gltf/glb/bin/textures/hdr/etc)
|
|
27
27
|
* Ref-counted global install so multiple instances don't clobber each other.
|
|
28
28
|
*/
|
|
29
29
|
function installGltfTracker() {
|
|
30
30
|
if (typeof window === 'undefined') {
|
|
31
|
+
var _subscribe = function _subscribe() {
|
|
32
|
+
return function () {};
|
|
33
|
+
};
|
|
31
34
|
return {
|
|
32
35
|
getInFlight: function getInFlight() {
|
|
33
36
|
return 0;
|
|
@@ -50,7 +53,7 @@ function installGltfTracker() {
|
|
|
50
53
|
return waitForIdle;
|
|
51
54
|
}(),
|
|
52
55
|
uninstall: function uninstall() {},
|
|
53
|
-
subscribe:
|
|
56
|
+
subscribe: _subscribe
|
|
54
57
|
};
|
|
55
58
|
}
|
|
56
59
|
var GLOBAL_KEY = '__kitchenSimulatorGltfTracker__';
|
|
@@ -71,7 +74,7 @@ function installGltfTracker() {
|
|
|
71
74
|
var _url$toString, _url$toString2;
|
|
72
75
|
var s = typeof url === 'string' ? url : (_url$toString = url === null || url === void 0 || (_url$toString2 = url.toString) === null || _url$toString2 === void 0 ? void 0 : _url$toString2.call(url)) !== null && _url$toString !== void 0 ? _url$toString : '';
|
|
73
76
|
var u = s.toLowerCase().split('?')[0]; // ignore cache params
|
|
74
|
-
return u.endsWith('.gltf') || u.endsWith('.glb') || u.endsWith('.bin') || u.endsWith('.
|
|
77
|
+
return u.endsWith('.gltf') || u.endsWith('.glb') || u.endsWith('.bin') || u.endsWith('.ktx2') || u.endsWith('.hdr') || u.endsWith('.exr') || u.endsWith('.png') || u.endsWith('.jpg') || u.endsWith('.jpeg') || u.endsWith('.webp');
|
|
75
78
|
} catch (_unused) {
|
|
76
79
|
return false;
|
|
77
80
|
}
|
|
@@ -92,7 +95,7 @@ function installGltfTracker() {
|
|
|
92
95
|
};
|
|
93
96
|
var subscribe = function subscribe(fn) {
|
|
94
97
|
g.listeners.add(fn);
|
|
95
|
-
fn(g.inFlight); // sync emit
|
|
98
|
+
fn(g.inFlight); // sync emit on subscribe
|
|
96
99
|
return function () {
|
|
97
100
|
return g.listeners["delete"](fn);
|
|
98
101
|
};
|
|
@@ -108,7 +111,7 @@ function installGltfTracker() {
|
|
|
108
111
|
g.originalSend = XHR.prototype.send;
|
|
109
112
|
XHR.prototype.open = function (method, url) {
|
|
110
113
|
var _g$originalOpen;
|
|
111
|
-
this.
|
|
114
|
+
this.__is3dAssetRequest = is3dAssetUrl(url);
|
|
112
115
|
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
113
116
|
rest[_key - 2] = arguments[_key];
|
|
114
117
|
}
|
|
@@ -116,7 +119,7 @@ function installGltfTracker() {
|
|
|
116
119
|
};
|
|
117
120
|
XHR.prototype.send = function () {
|
|
118
121
|
var _this = this;
|
|
119
|
-
if (this.
|
|
122
|
+
if (this.__is3dAssetRequest) {
|
|
120
123
|
g.inFlight += 1;
|
|
121
124
|
notify();
|
|
122
125
|
var _done = function done() {
|
|
@@ -151,7 +154,7 @@ function installGltfTracker() {
|
|
|
151
154
|
args[_key3] = _args2[_key3];
|
|
152
155
|
}
|
|
153
156
|
url = args === null || args === void 0 ? void 0 : args[0];
|
|
154
|
-
track =
|
|
157
|
+
track = is3dAssetUrl(url);
|
|
155
158
|
if (track) {
|
|
156
159
|
_context2.next = 1;
|
|
157
160
|
break;
|
|
@@ -181,7 +184,7 @@ function installGltfTracker() {
|
|
|
181
184
|
g.installed = true;
|
|
182
185
|
};
|
|
183
186
|
|
|
184
|
-
//
|
|
187
|
+
// “No grace” but stable: idle must remain idle for 2 RAF frames
|
|
185
188
|
function waitStableIdle2Frames() {
|
|
186
189
|
return _waitStableIdle2Frames.apply(this, arguments);
|
|
187
190
|
}
|
|
@@ -222,7 +225,7 @@ function installGltfTracker() {
|
|
|
222
225
|
while (1) switch (_context4.prev = _context4.next) {
|
|
223
226
|
case 0:
|
|
224
227
|
_ref3 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref3$timeoutMs = _ref3.timeoutMs, timeoutMs = _ref3$timeoutMs === void 0 ? 30000 : _ref3$timeoutMs;
|
|
225
|
-
start = Date.now();
|
|
228
|
+
start = Date.now();
|
|
226
229
|
_context4.next = 1;
|
|
227
230
|
return waitStableIdle2Frames();
|
|
228
231
|
case 1:
|
|
@@ -246,7 +249,7 @@ function installGltfTracker() {
|
|
|
246
249
|
}
|
|
247
250
|
if (Date.now() - start > timeoutMs) {
|
|
248
251
|
if (unsub) unsub();
|
|
249
|
-
reject(new Error('
|
|
252
|
+
reject(new Error('3D assets did not become idle within timeout'));
|
|
250
253
|
}
|
|
251
254
|
return _context3.abrupt("return");
|
|
252
255
|
case 1:
|
|
@@ -264,7 +267,7 @@ function installGltfTracker() {
|
|
|
264
267
|
case 3:
|
|
265
268
|
if (Date.now() - start > timeoutMs) {
|
|
266
269
|
if (unsub) unsub();
|
|
267
|
-
reject(new Error('
|
|
270
|
+
reject(new Error('3D assets did not become idle within timeout'));
|
|
268
271
|
}
|
|
269
272
|
case 4:
|
|
270
273
|
case "end":
|
|
@@ -310,11 +313,12 @@ function installGltfTracker() {
|
|
|
310
313
|
return g.inFlight;
|
|
311
314
|
},
|
|
312
315
|
waitForIdle: waitForIdle,
|
|
313
|
-
uninstall: uninstall
|
|
316
|
+
uninstall: uninstall,
|
|
317
|
+
subscribe: subscribe // ✅ IMPORTANT: return subscribe (this fixes your error)
|
|
314
318
|
};
|
|
315
319
|
}
|
|
316
320
|
export function renderKitchenSimulator(container) {
|
|
317
|
-
var _props$framesPerEvent, _props$waitForGltfIdl, _props$gltfTimeoutMs
|
|
321
|
+
var _props$framesPerEvent, _props$waitForGltfIdl, _props$gltfTimeoutMs;
|
|
318
322
|
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
319
323
|
if (!container) throw new Error('renderKitchenSimulator: container is required');
|
|
320
324
|
|
|
@@ -337,17 +341,14 @@ export function renderKitchenSimulator(container) {
|
|
|
337
341
|
var pendingMarkers = new Set();
|
|
338
342
|
var MARKER = Symbol('marker');
|
|
339
343
|
var gltfTracker = installGltfTracker();
|
|
340
|
-
var gltfUnsub = null;
|
|
341
|
-
function subscribeGltfInFlight(cb) {
|
|
342
|
-
if (!(gltfTracker !== null && gltfTracker !== void 0 && gltfTracker.subscribe)) return function () {};
|
|
343
|
-
return gltfTracker.subscribe(cb);
|
|
344
|
-
}
|
|
345
344
|
|
|
346
|
-
//
|
|
347
|
-
var defaultFramesPerEvent = (_props$framesPerEvent = props.framesPerEvent) !== null && _props$framesPerEvent !== void 0 ? _props$framesPerEvent : 1;
|
|
348
|
-
var
|
|
345
|
+
// FAST defaults (safe)
|
|
346
|
+
var defaultFramesPerEvent = (_props$framesPerEvent = props.framesPerEvent) !== null && _props$framesPerEvent !== void 0 ? _props$framesPerEvent : 1;
|
|
347
|
+
var waitForAssets = (_props$waitForGltfIdl = props.waitForGltfIdleAfterEachEvent) !== null && _props$waitForGltfIdl !== void 0 ? _props$waitForGltfIdl : true;
|
|
349
348
|
var defaultTimeout = (_props$gltfTimeoutMs = props.gltfTimeoutMs) !== null && _props$gltfTimeoutMs !== void 0 ? _props$gltfTimeoutMs : 30000;
|
|
350
|
-
|
|
349
|
+
|
|
350
|
+
// If you want ultra-fast UI responsiveness, you can disable waiting per-event
|
|
351
|
+
// and only wait on “important” events, see comment in settle() below.
|
|
351
352
|
|
|
352
353
|
var draining = false;
|
|
353
354
|
function isSyncScene(ev) {
|
|
@@ -359,12 +360,12 @@ export function renderKitchenSimulator(container) {
|
|
|
359
360
|
}
|
|
360
361
|
function _settle() {
|
|
361
362
|
_settle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(ev) {
|
|
362
|
-
var _ev$framesPerEvent, _ev$
|
|
363
|
-
var frames, i,
|
|
363
|
+
var _ev$framesPerEvent, _ev$waitForGltfIdleAf;
|
|
364
|
+
var frames, i, shouldWait, _ev$gltfTimeoutMs, timeoutMs;
|
|
364
365
|
return _regeneratorRuntime.wrap(function (_context7) {
|
|
365
366
|
while (1) switch (_context7.prev = _context7.next) {
|
|
366
367
|
case 0:
|
|
367
|
-
frames = (_ev$framesPerEvent = ev === null || ev === void 0 ? void 0 : ev.framesPerEvent) !== null && _ev$framesPerEvent !== void 0 ? _ev$framesPerEvent : defaultFramesPerEvent; // 1) allow reducers
|
|
368
|
+
frames = (_ev$framesPerEvent = ev === null || ev === void 0 ? void 0 : ev.framesPerEvent) !== null && _ev$framesPerEvent !== void 0 ? _ev$framesPerEvent : defaultFramesPerEvent; // (1) allow react/reducers to run (fixes “must zoom to see updates”)
|
|
368
369
|
i = 0;
|
|
369
370
|
case 1:
|
|
370
371
|
if (!(i < frames)) {
|
|
@@ -378,39 +379,30 @@ export function renderKitchenSimulator(container) {
|
|
|
378
379
|
_context7.next = 1;
|
|
379
380
|
break;
|
|
380
381
|
case 3:
|
|
381
|
-
|
|
382
|
+
// (2) optionally wait for assets
|
|
383
|
+
// fastest safe approach: keep ON for events that add/replace/load models
|
|
384
|
+
// You can override per-event via ev.waitForGltfIdleAfterEachEvent = false
|
|
385
|
+
shouldWait = (_ev$waitForGltfIdleAf = ev === null || ev === void 0 ? void 0 : ev.waitForGltfIdleAfterEachEvent) !== null && _ev$waitForGltfIdleAf !== void 0 ? _ev$waitForGltfIdleAf : waitForAssets;
|
|
386
|
+
if (!shouldWait) {
|
|
382
387
|
_context7.next = 4;
|
|
383
388
|
break;
|
|
384
389
|
}
|
|
385
|
-
return _context7.abrupt("return");
|
|
386
|
-
case 4:
|
|
387
|
-
// 2) wait for gltf idle (stable-idle 2 frames, no time grace)
|
|
388
390
|
timeoutMs = (_ev$gltfTimeoutMs = ev === null || ev === void 0 ? void 0 : ev.gltfTimeoutMs) !== null && _ev$gltfTimeoutMs !== void 0 ? _ev$gltfTimeoutMs : defaultTimeout;
|
|
389
|
-
_context7.next =
|
|
391
|
+
_context7.next = 4;
|
|
390
392
|
return gltfTracker.waitForIdle({
|
|
391
393
|
timeoutMs: timeoutMs
|
|
392
394
|
});
|
|
393
|
-
case
|
|
394
|
-
_context7.next =
|
|
395
|
+
case 4:
|
|
396
|
+
_context7.next = 5;
|
|
395
397
|
return nextFrame();
|
|
396
|
-
case
|
|
398
|
+
case 5:
|
|
397
399
|
if (!isSyncScene(ev)) {
|
|
398
|
-
_context7.next =
|
|
400
|
+
_context7.next = 6;
|
|
399
401
|
break;
|
|
400
402
|
}
|
|
401
|
-
|
|
402
|
-
case 7:
|
|
403
|
-
if (!(_i < syncExtraFrames)) {
|
|
404
|
-
_context7.next = 9;
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
_context7.next = 8;
|
|
403
|
+
_context7.next = 6;
|
|
408
404
|
return nextFrame();
|
|
409
|
-
case
|
|
410
|
-
_i += 1;
|
|
411
|
-
_context7.next = 7;
|
|
412
|
-
break;
|
|
413
|
-
case 9:
|
|
405
|
+
case 6:
|
|
414
406
|
case "end":
|
|
415
407
|
return _context7.stop();
|
|
416
408
|
}
|
|
@@ -447,10 +439,6 @@ export function renderKitchenSimulator(container) {
|
|
|
447
439
|
_context8.next = 4;
|
|
448
440
|
return nextFrame();
|
|
449
441
|
case 4:
|
|
450
|
-
if (setExternalEventFn) {
|
|
451
|
-
_context8.next = 5;
|
|
452
|
-
break;
|
|
453
|
-
}
|
|
454
442
|
return _context8.abrupt("continue", 3);
|
|
455
443
|
case 5:
|
|
456
444
|
item = queue.shift();
|
|
@@ -522,9 +510,11 @@ export function renderKitchenSimulator(container) {
|
|
|
522
510
|
__render: function __render(nextProps) {
|
|
523
511
|
root.render(/*#__PURE__*/React.createElement(Wrapper, nextProps));
|
|
524
512
|
},
|
|
513
|
+
// ✅ host can query current inFlight
|
|
525
514
|
getGltfInFlight: function getGltfInFlight() {
|
|
526
515
|
return gltfTracker.getInFlight();
|
|
527
516
|
},
|
|
517
|
+
// ✅ host can subscribe to inFlight changes (loader)
|
|
528
518
|
subscribeGltfInFlight: function subscribeGltfInFlight(cb) {
|
|
529
519
|
return gltfTracker.subscribe(cb);
|
|
530
520
|
},
|
|
@@ -550,7 +540,7 @@ export function renderKitchenSimulator(container) {
|
|
|
550
540
|
});
|
|
551
541
|
drain();
|
|
552
542
|
|
|
553
|
-
//
|
|
543
|
+
// resolve when marker cleared
|
|
554
544
|
return new Promise(function (resolve) {
|
|
555
545
|
var check = /*#__PURE__*/function () {
|
|
556
546
|
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
package/lib/index.js
CHANGED
|
@@ -31,11 +31,14 @@ function nextFrame() {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Track
|
|
34
|
+
* Track 3D asset network activity (gltf/glb/bin/textures/hdr/etc)
|
|
35
35
|
* Ref-counted global install so multiple instances don't clobber each other.
|
|
36
36
|
*/
|
|
37
37
|
function installGltfTracker() {
|
|
38
38
|
if (typeof window === 'undefined') {
|
|
39
|
+
var _subscribe = function _subscribe() {
|
|
40
|
+
return function () {};
|
|
41
|
+
};
|
|
39
42
|
return {
|
|
40
43
|
getInFlight: function getInFlight() {
|
|
41
44
|
return 0;
|
|
@@ -58,7 +61,7 @@ function installGltfTracker() {
|
|
|
58
61
|
return waitForIdle;
|
|
59
62
|
}(),
|
|
60
63
|
uninstall: function uninstall() {},
|
|
61
|
-
subscribe:
|
|
64
|
+
subscribe: _subscribe
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
var GLOBAL_KEY = '__kitchenSimulatorGltfTracker__';
|
|
@@ -79,7 +82,7 @@ function installGltfTracker() {
|
|
|
79
82
|
var _url$toString, _url$toString2;
|
|
80
83
|
var s = typeof url === 'string' ? url : (_url$toString = url === null || url === void 0 || (_url$toString2 = url.toString) === null || _url$toString2 === void 0 ? void 0 : _url$toString2.call(url)) !== null && _url$toString !== void 0 ? _url$toString : '';
|
|
81
84
|
var u = s.toLowerCase().split('?')[0]; // ignore cache params
|
|
82
|
-
return u.endsWith('.gltf') || u.endsWith('.glb') || u.endsWith('.bin') || u.endsWith('.
|
|
85
|
+
return u.endsWith('.gltf') || u.endsWith('.glb') || u.endsWith('.bin') || u.endsWith('.ktx2') || u.endsWith('.hdr') || u.endsWith('.exr') || u.endsWith('.png') || u.endsWith('.jpg') || u.endsWith('.jpeg') || u.endsWith('.webp');
|
|
83
86
|
} catch (_unused) {
|
|
84
87
|
return false;
|
|
85
88
|
}
|
|
@@ -100,7 +103,7 @@ function installGltfTracker() {
|
|
|
100
103
|
};
|
|
101
104
|
var subscribe = function subscribe(fn) {
|
|
102
105
|
g.listeners.add(fn);
|
|
103
|
-
fn(g.inFlight); // sync emit
|
|
106
|
+
fn(g.inFlight); // sync emit on subscribe
|
|
104
107
|
return function () {
|
|
105
108
|
return g.listeners["delete"](fn);
|
|
106
109
|
};
|
|
@@ -116,7 +119,7 @@ function installGltfTracker() {
|
|
|
116
119
|
g.originalSend = XHR.prototype.send;
|
|
117
120
|
XHR.prototype.open = function (method, url) {
|
|
118
121
|
var _g$originalOpen;
|
|
119
|
-
this.
|
|
122
|
+
this.__is3dAssetRequest = is3dAssetUrl(url);
|
|
120
123
|
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
121
124
|
rest[_key - 2] = arguments[_key];
|
|
122
125
|
}
|
|
@@ -124,7 +127,7 @@ function installGltfTracker() {
|
|
|
124
127
|
};
|
|
125
128
|
XHR.prototype.send = function () {
|
|
126
129
|
var _this = this;
|
|
127
|
-
if (this.
|
|
130
|
+
if (this.__is3dAssetRequest) {
|
|
128
131
|
g.inFlight += 1;
|
|
129
132
|
notify();
|
|
130
133
|
var _done = function done() {
|
|
@@ -159,7 +162,7 @@ function installGltfTracker() {
|
|
|
159
162
|
args[_key3] = _args2[_key3];
|
|
160
163
|
}
|
|
161
164
|
url = args === null || args === void 0 ? void 0 : args[0];
|
|
162
|
-
track =
|
|
165
|
+
track = is3dAssetUrl(url);
|
|
163
166
|
if (track) {
|
|
164
167
|
_context2.next = 1;
|
|
165
168
|
break;
|
|
@@ -189,7 +192,7 @@ function installGltfTracker() {
|
|
|
189
192
|
g.installed = true;
|
|
190
193
|
};
|
|
191
194
|
|
|
192
|
-
//
|
|
195
|
+
// “No grace” but stable: idle must remain idle for 2 RAF frames
|
|
193
196
|
function waitStableIdle2Frames() {
|
|
194
197
|
return _waitStableIdle2Frames.apply(this, arguments);
|
|
195
198
|
}
|
|
@@ -230,7 +233,7 @@ function installGltfTracker() {
|
|
|
230
233
|
while (1) switch (_context4.prev = _context4.next) {
|
|
231
234
|
case 0:
|
|
232
235
|
_ref3 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref3$timeoutMs = _ref3.timeoutMs, timeoutMs = _ref3$timeoutMs === void 0 ? 30000 : _ref3$timeoutMs;
|
|
233
|
-
start = Date.now();
|
|
236
|
+
start = Date.now();
|
|
234
237
|
_context4.next = 1;
|
|
235
238
|
return waitStableIdle2Frames();
|
|
236
239
|
case 1:
|
|
@@ -254,7 +257,7 @@ function installGltfTracker() {
|
|
|
254
257
|
}
|
|
255
258
|
if (Date.now() - start > timeoutMs) {
|
|
256
259
|
if (unsub) unsub();
|
|
257
|
-
reject(new Error('
|
|
260
|
+
reject(new Error('3D assets did not become idle within timeout'));
|
|
258
261
|
}
|
|
259
262
|
return _context3.abrupt("return");
|
|
260
263
|
case 1:
|
|
@@ -272,7 +275,7 @@ function installGltfTracker() {
|
|
|
272
275
|
case 3:
|
|
273
276
|
if (Date.now() - start > timeoutMs) {
|
|
274
277
|
if (unsub) unsub();
|
|
275
|
-
reject(new Error('
|
|
278
|
+
reject(new Error('3D assets did not become idle within timeout'));
|
|
276
279
|
}
|
|
277
280
|
case 4:
|
|
278
281
|
case "end":
|
|
@@ -318,11 +321,12 @@ function installGltfTracker() {
|
|
|
318
321
|
return g.inFlight;
|
|
319
322
|
},
|
|
320
323
|
waitForIdle: waitForIdle,
|
|
321
|
-
uninstall: uninstall
|
|
324
|
+
uninstall: uninstall,
|
|
325
|
+
subscribe: subscribe // ✅ IMPORTANT: return subscribe (this fixes your error)
|
|
322
326
|
};
|
|
323
327
|
}
|
|
324
328
|
function renderKitchenSimulator(container) {
|
|
325
|
-
var _props$framesPerEvent, _props$waitForGltfIdl, _props$gltfTimeoutMs
|
|
329
|
+
var _props$framesPerEvent, _props$waitForGltfIdl, _props$gltfTimeoutMs;
|
|
326
330
|
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
327
331
|
if (!container) throw new Error('renderKitchenSimulator: container is required');
|
|
328
332
|
|
|
@@ -345,17 +349,14 @@ function renderKitchenSimulator(container) {
|
|
|
345
349
|
var pendingMarkers = new Set();
|
|
346
350
|
var MARKER = Symbol('marker');
|
|
347
351
|
var gltfTracker = installGltfTracker();
|
|
348
|
-
var gltfUnsub = null;
|
|
349
|
-
function subscribeGltfInFlight(cb) {
|
|
350
|
-
if (!(gltfTracker !== null && gltfTracker !== void 0 && gltfTracker.subscribe)) return function () {};
|
|
351
|
-
return gltfTracker.subscribe(cb);
|
|
352
|
-
}
|
|
353
352
|
|
|
354
|
-
//
|
|
355
|
-
var defaultFramesPerEvent = (_props$framesPerEvent = props.framesPerEvent) !== null && _props$framesPerEvent !== void 0 ? _props$framesPerEvent : 1;
|
|
356
|
-
var
|
|
353
|
+
// FAST defaults (safe)
|
|
354
|
+
var defaultFramesPerEvent = (_props$framesPerEvent = props.framesPerEvent) !== null && _props$framesPerEvent !== void 0 ? _props$framesPerEvent : 1;
|
|
355
|
+
var waitForAssets = (_props$waitForGltfIdl = props.waitForGltfIdleAfterEachEvent) !== null && _props$waitForGltfIdl !== void 0 ? _props$waitForGltfIdl : true;
|
|
357
356
|
var defaultTimeout = (_props$gltfTimeoutMs = props.gltfTimeoutMs) !== null && _props$gltfTimeoutMs !== void 0 ? _props$gltfTimeoutMs : 30000;
|
|
358
|
-
|
|
357
|
+
|
|
358
|
+
// If you want ultra-fast UI responsiveness, you can disable waiting per-event
|
|
359
|
+
// and only wait on “important” events, see comment in settle() below.
|
|
359
360
|
|
|
360
361
|
var draining = false;
|
|
361
362
|
function isSyncScene(ev) {
|
|
@@ -367,12 +368,12 @@ function renderKitchenSimulator(container) {
|
|
|
367
368
|
}
|
|
368
369
|
function _settle() {
|
|
369
370
|
_settle = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(ev) {
|
|
370
|
-
var _ev$framesPerEvent, _ev$
|
|
371
|
-
var frames, i,
|
|
371
|
+
var _ev$framesPerEvent, _ev$waitForGltfIdleAf;
|
|
372
|
+
var frames, i, shouldWait, _ev$gltfTimeoutMs, timeoutMs;
|
|
372
373
|
return _regenerator["default"].wrap(function (_context7) {
|
|
373
374
|
while (1) switch (_context7.prev = _context7.next) {
|
|
374
375
|
case 0:
|
|
375
|
-
frames = (_ev$framesPerEvent = ev === null || ev === void 0 ? void 0 : ev.framesPerEvent) !== null && _ev$framesPerEvent !== void 0 ? _ev$framesPerEvent : defaultFramesPerEvent; // 1) allow reducers
|
|
376
|
+
frames = (_ev$framesPerEvent = ev === null || ev === void 0 ? void 0 : ev.framesPerEvent) !== null && _ev$framesPerEvent !== void 0 ? _ev$framesPerEvent : defaultFramesPerEvent; // (1) allow react/reducers to run (fixes “must zoom to see updates”)
|
|
376
377
|
i = 0;
|
|
377
378
|
case 1:
|
|
378
379
|
if (!(i < frames)) {
|
|
@@ -386,39 +387,30 @@ function renderKitchenSimulator(container) {
|
|
|
386
387
|
_context7.next = 1;
|
|
387
388
|
break;
|
|
388
389
|
case 3:
|
|
389
|
-
|
|
390
|
+
// (2) optionally wait for assets
|
|
391
|
+
// fastest safe approach: keep ON for events that add/replace/load models
|
|
392
|
+
// You can override per-event via ev.waitForGltfIdleAfterEachEvent = false
|
|
393
|
+
shouldWait = (_ev$waitForGltfIdleAf = ev === null || ev === void 0 ? void 0 : ev.waitForGltfIdleAfterEachEvent) !== null && _ev$waitForGltfIdleAf !== void 0 ? _ev$waitForGltfIdleAf : waitForAssets;
|
|
394
|
+
if (!shouldWait) {
|
|
390
395
|
_context7.next = 4;
|
|
391
396
|
break;
|
|
392
397
|
}
|
|
393
|
-
return _context7.abrupt("return");
|
|
394
|
-
case 4:
|
|
395
|
-
// 2) wait for gltf idle (stable-idle 2 frames, no time grace)
|
|
396
398
|
timeoutMs = (_ev$gltfTimeoutMs = ev === null || ev === void 0 ? void 0 : ev.gltfTimeoutMs) !== null && _ev$gltfTimeoutMs !== void 0 ? _ev$gltfTimeoutMs : defaultTimeout;
|
|
397
|
-
_context7.next =
|
|
399
|
+
_context7.next = 4;
|
|
398
400
|
return gltfTracker.waitForIdle({
|
|
399
401
|
timeoutMs: timeoutMs
|
|
400
402
|
});
|
|
401
|
-
case
|
|
402
|
-
_context7.next =
|
|
403
|
+
case 4:
|
|
404
|
+
_context7.next = 5;
|
|
403
405
|
return nextFrame();
|
|
404
|
-
case
|
|
406
|
+
case 5:
|
|
405
407
|
if (!isSyncScene(ev)) {
|
|
406
|
-
_context7.next =
|
|
408
|
+
_context7.next = 6;
|
|
407
409
|
break;
|
|
408
410
|
}
|
|
409
|
-
|
|
410
|
-
case 7:
|
|
411
|
-
if (!(_i < syncExtraFrames)) {
|
|
412
|
-
_context7.next = 9;
|
|
413
|
-
break;
|
|
414
|
-
}
|
|
415
|
-
_context7.next = 8;
|
|
411
|
+
_context7.next = 6;
|
|
416
412
|
return nextFrame();
|
|
417
|
-
case
|
|
418
|
-
_i += 1;
|
|
419
|
-
_context7.next = 7;
|
|
420
|
-
break;
|
|
421
|
-
case 9:
|
|
413
|
+
case 6:
|
|
422
414
|
case "end":
|
|
423
415
|
return _context7.stop();
|
|
424
416
|
}
|
|
@@ -455,10 +447,6 @@ function renderKitchenSimulator(container) {
|
|
|
455
447
|
_context8.next = 4;
|
|
456
448
|
return nextFrame();
|
|
457
449
|
case 4:
|
|
458
|
-
if (setExternalEventFn) {
|
|
459
|
-
_context8.next = 5;
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
450
|
return _context8.abrupt("continue", 3);
|
|
463
451
|
case 5:
|
|
464
452
|
item = queue.shift();
|
|
@@ -530,9 +518,11 @@ function renderKitchenSimulator(container) {
|
|
|
530
518
|
__render: function __render(nextProps) {
|
|
531
519
|
root.render(/*#__PURE__*/_react["default"].createElement(Wrapper, nextProps));
|
|
532
520
|
},
|
|
521
|
+
// ✅ host can query current inFlight
|
|
533
522
|
getGltfInFlight: function getGltfInFlight() {
|
|
534
523
|
return gltfTracker.getInFlight();
|
|
535
524
|
},
|
|
525
|
+
// ✅ host can subscribe to inFlight changes (loader)
|
|
536
526
|
subscribeGltfInFlight: function subscribeGltfInFlight(cb) {
|
|
537
527
|
return gltfTracker.subscribe(cb);
|
|
538
528
|
},
|
|
@@ -558,7 +548,7 @@ function renderKitchenSimulator(container) {
|
|
|
558
548
|
});
|
|
559
549
|
drain();
|
|
560
550
|
|
|
561
|
-
//
|
|
551
|
+
// resolve when marker cleared
|
|
562
552
|
return new Promise(function (resolve) {
|
|
563
553
|
var check = /*#__PURE__*/function () {
|
|
564
554
|
var _ref5 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|