@gnsx/three 0.186.0 → 0.186.1
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/build/three.core.js +79 -6
- package/package.json +1 -1
- package/src/utils.js +79 -6
package/build/three.core.js
CHANGED
|
@@ -2087,9 +2087,79 @@ function warnOnce( ...params ) {
|
|
|
2087
2087
|
|
|
2088
2088
|
}
|
|
2089
2089
|
|
|
2090
|
+
// WITH_GENESYS
|
|
2091
|
+
/**
|
|
2092
|
+
* Shared MessageChannel used by {@link yieldToTask}. One pair of ports is
|
|
2093
|
+
* owned for the lifetime of this module so compileAsync does not allocate a
|
|
2094
|
+
* channel per yield.
|
|
2095
|
+
*
|
|
2096
|
+
* @private
|
|
2097
|
+
* @type {MessageChannel|null}
|
|
2098
|
+
*/
|
|
2099
|
+
let _taskYieldChannel = null;
|
|
2100
|
+
|
|
2101
|
+
/**
|
|
2102
|
+
* Resolvers waiting for the next MessageChannel task. Sequential
|
|
2103
|
+
* `await yieldToMain()` callers queue at most one entry; the array still
|
|
2104
|
+
* preserves ordering if several yields overlap.
|
|
2105
|
+
*
|
|
2106
|
+
* @private
|
|
2107
|
+
* @type {Array<Function>}
|
|
2108
|
+
*/
|
|
2109
|
+
const _taskYieldResolvers = [];
|
|
2110
|
+
|
|
2111
|
+
/**
|
|
2112
|
+
* Yields to a new event-loop task without waiting for a display frame.
|
|
2113
|
+
*
|
|
2114
|
+
* @private
|
|
2115
|
+
* @return {Promise<void>}
|
|
2116
|
+
*/
|
|
2117
|
+
function yieldToTask() {
|
|
2118
|
+
|
|
2119
|
+
return new Promise( resolve => {
|
|
2120
|
+
|
|
2121
|
+
if ( typeof MessageChannel === 'function' ) {
|
|
2122
|
+
|
|
2123
|
+
if ( _taskYieldChannel === null ) {
|
|
2124
|
+
|
|
2125
|
+
_taskYieldChannel = new MessageChannel();
|
|
2126
|
+
_taskYieldChannel.port1.onmessage = function () {
|
|
2127
|
+
|
|
2128
|
+
const next = _taskYieldResolvers.shift();
|
|
2129
|
+
if ( next !== undefined ) next();
|
|
2130
|
+
|
|
2131
|
+
};
|
|
2132
|
+
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
_taskYieldResolvers.push( resolve );
|
|
2136
|
+
_taskYieldChannel.port2.postMessage( null );
|
|
2137
|
+
return;
|
|
2138
|
+
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
if ( typeof setTimeout === 'function' ) {
|
|
2142
|
+
|
|
2143
|
+
setTimeout( resolve, 0 );
|
|
2144
|
+
return;
|
|
2145
|
+
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
resolve();
|
|
2149
|
+
|
|
2150
|
+
} );
|
|
2151
|
+
|
|
2152
|
+
}
|
|
2153
|
+
// !WITH_GENESYS
|
|
2154
|
+
|
|
2090
2155
|
/**
|
|
2091
2156
|
* Yields execution to the main thread to allow rendering and other tasks.
|
|
2092
|
-
* Uses scheduler.yield() when available (Chrome 115+)
|
|
2157
|
+
* Uses scheduler.yield() when available (Chrome 115+).
|
|
2158
|
+
* WITH_GENESYS
|
|
2159
|
+
* Falls back to a MessageChannel (or setTimeout) task continuation so browsers
|
|
2160
|
+
* without the Scheduler API do not wait one animation frame per yield.
|
|
2161
|
+
* !WITH_GENESYS
|
|
2162
|
+
* Falls back to requestAnimationFrame.
|
|
2093
2163
|
*
|
|
2094
2164
|
* @return {Promise<void>}
|
|
2095
2165
|
*/
|
|
@@ -2101,11 +2171,14 @@ function yieldToMain() {
|
|
|
2101
2171
|
|
|
2102
2172
|
}
|
|
2103
2173
|
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2174
|
+
// WITH_GENESYS
|
|
2175
|
+
return yieldToTask();
|
|
2176
|
+
// !WITH_GENESYS
|
|
2177
|
+
// return new Promise( resolve => {
|
|
2178
|
+
//
|
|
2179
|
+
// requestAnimationFrame( resolve );
|
|
2180
|
+
//
|
|
2181
|
+
// } );
|
|
2109
2182
|
|
|
2110
2183
|
}
|
|
2111
2184
|
|
package/package.json
CHANGED
package/src/utils.js
CHANGED
|
@@ -347,9 +347,79 @@ function warnOnce( ...params ) {
|
|
|
347
347
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
// WITH_GENESYS
|
|
351
|
+
/**
|
|
352
|
+
* Shared MessageChannel used by {@link yieldToTask}. One pair of ports is
|
|
353
|
+
* owned for the lifetime of this module so compileAsync does not allocate a
|
|
354
|
+
* channel per yield.
|
|
355
|
+
*
|
|
356
|
+
* @private
|
|
357
|
+
* @type {MessageChannel|null}
|
|
358
|
+
*/
|
|
359
|
+
let _taskYieldChannel = null;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Resolvers waiting for the next MessageChannel task. Sequential
|
|
363
|
+
* `await yieldToMain()` callers queue at most one entry; the array still
|
|
364
|
+
* preserves ordering if several yields overlap.
|
|
365
|
+
*
|
|
366
|
+
* @private
|
|
367
|
+
* @type {Array<Function>}
|
|
368
|
+
*/
|
|
369
|
+
const _taskYieldResolvers = [];
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Yields to a new event-loop task without waiting for a display frame.
|
|
373
|
+
*
|
|
374
|
+
* @private
|
|
375
|
+
* @return {Promise<void>}
|
|
376
|
+
*/
|
|
377
|
+
function yieldToTask() {
|
|
378
|
+
|
|
379
|
+
return new Promise( resolve => {
|
|
380
|
+
|
|
381
|
+
if ( typeof MessageChannel === 'function' ) {
|
|
382
|
+
|
|
383
|
+
if ( _taskYieldChannel === null ) {
|
|
384
|
+
|
|
385
|
+
_taskYieldChannel = new MessageChannel();
|
|
386
|
+
_taskYieldChannel.port1.onmessage = function () {
|
|
387
|
+
|
|
388
|
+
const next = _taskYieldResolvers.shift();
|
|
389
|
+
if ( next !== undefined ) next();
|
|
390
|
+
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
_taskYieldResolvers.push( resolve );
|
|
396
|
+
_taskYieldChannel.port2.postMessage( null );
|
|
397
|
+
return;
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if ( typeof setTimeout === 'function' ) {
|
|
402
|
+
|
|
403
|
+
setTimeout( resolve, 0 );
|
|
404
|
+
return;
|
|
405
|
+
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
resolve();
|
|
409
|
+
|
|
410
|
+
} );
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
// !WITH_GENESYS
|
|
414
|
+
|
|
350
415
|
/**
|
|
351
416
|
* Yields execution to the main thread to allow rendering and other tasks.
|
|
352
|
-
* Uses scheduler.yield() when available (Chrome 115+)
|
|
417
|
+
* Uses scheduler.yield() when available (Chrome 115+).
|
|
418
|
+
* WITH_GENESYS
|
|
419
|
+
* Falls back to a MessageChannel (or setTimeout) task continuation so browsers
|
|
420
|
+
* without the Scheduler API do not wait one animation frame per yield.
|
|
421
|
+
* !WITH_GENESYS
|
|
422
|
+
* Falls back to requestAnimationFrame.
|
|
353
423
|
*
|
|
354
424
|
* @return {Promise<void>}
|
|
355
425
|
*/
|
|
@@ -361,11 +431,14 @@ function yieldToMain() {
|
|
|
361
431
|
|
|
362
432
|
}
|
|
363
433
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
434
|
+
// WITH_GENESYS
|
|
435
|
+
return yieldToTask();
|
|
436
|
+
// !WITH_GENESYS
|
|
437
|
+
// return new Promise( resolve => {
|
|
438
|
+
//
|
|
439
|
+
// requestAnimationFrame( resolve );
|
|
440
|
+
//
|
|
441
|
+
// } );
|
|
369
442
|
|
|
370
443
|
}
|
|
371
444
|
|