@gnsx/three 0.185.12 → 0.185.14
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.cjs +18 -5
- package/build/three.core.js +18 -5
- package/build/three.core.min.js +1 -1
- package/build/three.webgpu.js +28 -13
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +28 -13
- package/build/three.webgpu.nodes.min.js +1 -1
- package/package.json +1 -1
- package/src/profiler/ProfilerService.js +18 -5
- package/src/renderers/common/Renderer.js +28 -13
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import { warnOnce } from '../utils.js';
|
|
|
10
10
|
* // play for a few seconds
|
|
11
11
|
* __gnsx_profiler.report() // sorted console.table (aggregated stats)
|
|
12
12
|
* __gnsx_profiler.downloadTrace() // download gnsx-trace.json for Speedscope / Perfetto
|
|
13
|
+
* __gnsx_profiler.downloadTrace('gnsx-trace.json', 0.05) // omit spans < 0.05 ms
|
|
13
14
|
* __gnsx_profiler.reset() // clear samples and trace
|
|
14
15
|
* __gnsx_profiler.disable()
|
|
15
16
|
*
|
|
@@ -1216,11 +1217,16 @@ class ProfilerServiceClass {
|
|
|
1216
1217
|
}
|
|
1217
1218
|
|
|
1218
1219
|
/**
|
|
1220
|
+
* @param {number} [minDurationMs=0] Omit complete spans shorter than this duration (ms). Capture is unaffected.
|
|
1219
1221
|
* @return {import('./ProfilerService.js').ChromeTrace}
|
|
1220
1222
|
*/
|
|
1221
|
-
exportChromeTrace() {
|
|
1223
|
+
exportChromeTrace( minDurationMs = 0 ) {
|
|
1222
1224
|
|
|
1223
|
-
const
|
|
1225
|
+
const thresholdMs = Number.isFinite( minDurationMs ) && minDurationMs > 0 ? minDurationMs : 0;
|
|
1226
|
+
const minDurUs = thresholdMs * 1000;
|
|
1227
|
+
const slices = minDurUs > 0
|
|
1228
|
+
? this.traceEvents.filter( e => ( e.dur ?? 0 ) >= minDurUs )
|
|
1229
|
+
: [ ...this.traceEvents ];
|
|
1224
1230
|
slices.sort( ( a, b ) => {
|
|
1225
1231
|
|
|
1226
1232
|
if ( a.ts !== b.ts ) return a.ts - b.ts;
|
|
@@ -1298,8 +1304,9 @@ class ProfilerServiceClass {
|
|
|
1298
1304
|
|
|
1299
1305
|
/**
|
|
1300
1306
|
* @param {string} [filename='gnsx-trace.json']
|
|
1307
|
+
* @param {number} [minDurationMs=0] Omit complete spans shorter than this duration (ms).
|
|
1301
1308
|
*/
|
|
1302
|
-
downloadTrace( filename = 'gnsx-trace.json' ) {
|
|
1309
|
+
downloadTrace( filename = 'gnsx-trace.json', minDurationMs = 0 ) {
|
|
1303
1310
|
|
|
1304
1311
|
if ( typeof document === 'undefined' ) {
|
|
1305
1312
|
|
|
@@ -1322,7 +1329,10 @@ class ProfilerServiceClass {
|
|
|
1322
1329
|
|
|
1323
1330
|
}
|
|
1324
1331
|
|
|
1325
|
-
const
|
|
1332
|
+
const thresholdMs = Number.isFinite( minDurationMs ) && minDurationMs > 0 ? minDurationMs : 0;
|
|
1333
|
+
const trace = this.exportChromeTrace( thresholdMs );
|
|
1334
|
+
const eventCount = trace.traceEvents.filter( e => e.ph === 'X' ).length;
|
|
1335
|
+
const json = JSON.stringify( trace );
|
|
1326
1336
|
const blob = new Blob( [ json ], { type: 'application/json' } );
|
|
1327
1337
|
const url = URL.createObjectURL( blob );
|
|
1328
1338
|
const a = document.createElement( 'a' );
|
|
@@ -1330,7 +1340,10 @@ class ProfilerServiceClass {
|
|
|
1330
1340
|
a.download = filename;
|
|
1331
1341
|
a.click();
|
|
1332
1342
|
URL.revokeObjectURL( url );
|
|
1333
|
-
|
|
1343
|
+
const thresholdNote = thresholdMs > 0
|
|
1344
|
+
? ` (filtered ${this.traceEvents.length - eventCount} spans < ${thresholdMs} ms)`
|
|
1345
|
+
: '';
|
|
1346
|
+
console.log( `[ProfilerService] Trace downloaded: ${filename} (${eventCount} events${thresholdNote})` );
|
|
1334
1347
|
|
|
1335
1348
|
}
|
|
1336
1349
|
|
|
@@ -1378,20 +1378,24 @@ class Renderer {
|
|
|
1378
1378
|
*/
|
|
1379
1379
|
render( scene, camera ) {
|
|
1380
1380
|
|
|
1381
|
-
// WITH_GENESYS
|
|
1382
|
-
ProfilerService.begin( 'Renderer.render' );
|
|
1383
|
-
// !WITH_GENESYS
|
|
1384
|
-
|
|
1385
1381
|
if ( this._initialized === false ) {
|
|
1386
1382
|
|
|
1387
1383
|
throw new Error( 'THREE.Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.' );
|
|
1388
1384
|
|
|
1389
1385
|
}
|
|
1390
1386
|
|
|
1391
|
-
this._renderScene( scene, camera );
|
|
1392
|
-
|
|
1393
1387
|
// WITH_GENESYS
|
|
1394
|
-
|
|
1388
|
+
const label = `Renderer.render (${scene.name || scene.type})`;
|
|
1389
|
+
const handle = ProfilerService.beginGpu( label, this );
|
|
1390
|
+
try {
|
|
1391
|
+
|
|
1392
|
+
this._renderScene( scene, camera );
|
|
1393
|
+
|
|
1394
|
+
} finally {
|
|
1395
|
+
|
|
1396
|
+
ProfilerService.endGpu( handle );
|
|
1397
|
+
|
|
1398
|
+
}
|
|
1395
1399
|
// !WITH_GENESYS
|
|
1396
1400
|
|
|
1397
1401
|
}
|
|
@@ -1545,10 +1549,6 @@ class Renderer {
|
|
|
1545
1549
|
|
|
1546
1550
|
if ( this._isDeviceLost === true ) return;
|
|
1547
1551
|
|
|
1548
|
-
// WITH_GENESYS
|
|
1549
|
-
ProfilerService.begin( 'Renderer._renderScene' );
|
|
1550
|
-
// !WITH_GENESYS
|
|
1551
|
-
|
|
1552
1552
|
//
|
|
1553
1553
|
|
|
1554
1554
|
const frameBufferTarget = useFrameBufferTarget ? this._getFrameBufferTarget() : null;
|
|
@@ -1785,6 +1785,12 @@ class Renderer {
|
|
|
1785
1785
|
renderContext.activeMipmapLevel = activeMipmapLevel;
|
|
1786
1786
|
renderContext.occlusionQueryCount = renderList.occlusionQueryCount;
|
|
1787
1787
|
|
|
1788
|
+
// WITH_GENESYS
|
|
1789
|
+
// Size is finalized above from the active RT or drawing buffer.
|
|
1790
|
+
const profilerLabel = `Renderer._renderScene (${renderContext.width}x${renderContext.height})`;
|
|
1791
|
+
ProfilerService.begin( profilerLabel );
|
|
1792
|
+
// !WITH_GENESYS
|
|
1793
|
+
|
|
1788
1794
|
//
|
|
1789
1795
|
|
|
1790
1796
|
renderContext.scissorValue.max( _vector4.set( 0, 0, 0, 0 ) );
|
|
@@ -1860,7 +1866,7 @@ class Renderer {
|
|
|
1860
1866
|
//
|
|
1861
1867
|
|
|
1862
1868
|
// WITH_GENESYS
|
|
1863
|
-
ProfilerService.end(
|
|
1869
|
+
ProfilerService.end( profilerLabel );
|
|
1864
1870
|
// !WITH_GENESYS
|
|
1865
1871
|
|
|
1866
1872
|
return renderContext;
|
|
@@ -3436,7 +3442,7 @@ class Renderer {
|
|
|
3436
3442
|
_renderObjects( renderList, camera, scene, lightsNode, passId = null ) {
|
|
3437
3443
|
|
|
3438
3444
|
// WITH_GENESYS
|
|
3439
|
-
const label =
|
|
3445
|
+
const label = `_renderObjects (${renderList.length})`;
|
|
3440
3446
|
ProfilerService.begin( label );
|
|
3441
3447
|
// !WITH_GENESYS
|
|
3442
3448
|
|
|
@@ -3671,6 +3677,11 @@ class Renderer {
|
|
|
3671
3677
|
*/
|
|
3672
3678
|
renderObject( object, scene, camera, geometry, material, group, lightsNode, clippingContext = null, passId = null ) {
|
|
3673
3679
|
|
|
3680
|
+
// WITH_GENESYS
|
|
3681
|
+
const label = `renderObject (${object.name || object.type} - ${material.name || material.type})`;
|
|
3682
|
+
ProfilerService.begin( label );
|
|
3683
|
+
// !WITH_GENESYS
|
|
3684
|
+
|
|
3674
3685
|
let materialOverride = false;
|
|
3675
3686
|
let materialColorNode;
|
|
3676
3687
|
let materialDepthNode;
|
|
@@ -3782,6 +3793,10 @@ class Renderer {
|
|
|
3782
3793
|
|
|
3783
3794
|
object.onAfterRender( this, scene, camera, geometry, material, group );
|
|
3784
3795
|
|
|
3796
|
+
// WITH_GENESYS
|
|
3797
|
+
ProfilerService.end( label );
|
|
3798
|
+
// !WITH_GENESYS
|
|
3799
|
+
|
|
3785
3800
|
}
|
|
3786
3801
|
|
|
3787
3802
|
/**
|