@rings-webgpu/core 1.0.47 → 1.0.48
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/dist/rings.es.js +24 -24
- package/dist/rings.es.js.map +3 -3
- package/dist/rings.es.max.js +71 -8
- package/dist/rings.umd.js +40 -40
- package/dist/rings.umd.js.map +3 -3
- package/dist/rings.umd.max.js +71 -8
- package/dist/types/loader/parser/ply/PlyStreamParser.d.ts +12 -0
- package/package.json +1 -1
package/dist/rings.es.max.js
CHANGED
|
@@ -42326,7 +42326,7 @@ class PostProcessingComponent extends ComponentBase {
|
|
|
42326
42326
|
}
|
|
42327
42327
|
}
|
|
42328
42328
|
|
|
42329
|
-
const version = "1.0.
|
|
42329
|
+
const version = "1.0.48";
|
|
42330
42330
|
|
|
42331
42331
|
class Engine3D {
|
|
42332
42332
|
/**
|
|
@@ -62160,6 +62160,11 @@ class PlyStreamParser {
|
|
|
62160
62160
|
_onSplatParsed = null;
|
|
62161
62161
|
_batchSize = 1e3;
|
|
62162
62162
|
_cancelled = false;
|
|
62163
|
+
// Async processing state
|
|
62164
|
+
_parseTimeoutId = null;
|
|
62165
|
+
_verticesPerChunk = 1e7;
|
|
62166
|
+
// Number of vertices to process per chunk
|
|
62167
|
+
_useIdleCallback = typeof requestIdleCallback !== "undefined";
|
|
62163
62168
|
constructor(onHeaderParsed, onSplatParsed, batchSize = 1e3) {
|
|
62164
62169
|
this._onHeaderParsed = onHeaderParsed;
|
|
62165
62170
|
this._onSplatParsed = onSplatParsed;
|
|
@@ -62182,6 +62187,14 @@ class PlyStreamParser {
|
|
|
62182
62187
|
*/
|
|
62183
62188
|
cancel() {
|
|
62184
62189
|
this._cancelled = true;
|
|
62190
|
+
if (this._parseTimeoutId !== null) {
|
|
62191
|
+
if (this._useIdleCallback) {
|
|
62192
|
+
cancelIdleCallback(this._parseTimeoutId);
|
|
62193
|
+
} else {
|
|
62194
|
+
clearTimeout(this._parseTimeoutId);
|
|
62195
|
+
}
|
|
62196
|
+
this._parseTimeoutId = null;
|
|
62197
|
+
}
|
|
62185
62198
|
}
|
|
62186
62199
|
/**
|
|
62187
62200
|
* Check if parsing is cancelled
|
|
@@ -62350,21 +62363,36 @@ class PlyStreamParser {
|
|
|
62350
62363
|
}
|
|
62351
62364
|
/**
|
|
62352
62365
|
* Parse vertices from current data buffer
|
|
62366
|
+
* Entry point - checks if async processing is already scheduled
|
|
62353
62367
|
*/
|
|
62354
62368
|
_parseVertices() {
|
|
62355
62369
|
if (!this._header || !this._dataBuffer) return;
|
|
62370
|
+
if (this._parseTimeoutId !== null) {
|
|
62371
|
+
return;
|
|
62372
|
+
}
|
|
62373
|
+
this._parseVerticesChunk();
|
|
62374
|
+
}
|
|
62375
|
+
/**
|
|
62376
|
+
* Parse a chunk of vertices with time and count limits
|
|
62377
|
+
*/
|
|
62378
|
+
_parseVerticesChunk() {
|
|
62379
|
+
if (!this._header || !this._dataBuffer || this._cancelled) {
|
|
62380
|
+
this._parseTimeoutId = null;
|
|
62381
|
+
return;
|
|
62382
|
+
}
|
|
62356
62383
|
const payload = new DataView(this._dataBuffer.buffer, this._dataBuffer.byteOffset, this._dataBuffer.byteLength);
|
|
62357
62384
|
const vertexCount = this._header.vertexCount;
|
|
62358
62385
|
const has = (n) => this._properties.find((p) => p.name === n) != null;
|
|
62359
62386
|
const propIndex = (n) => this._properties.findIndex((p) => p.name === n);
|
|
62387
|
+
const startTime = performance.now();
|
|
62388
|
+
const maxProcessingTime = 5;
|
|
62389
|
+
let processedInThisChunk = 0;
|
|
62360
62390
|
while (this._processedVertices < vertexCount && !this._cancelled) {
|
|
62361
62391
|
const v = this._processedVertices;
|
|
62362
62392
|
const vOffset = v * this._vertexStride;
|
|
62363
62393
|
if (vOffset + this._vertexStride > this._dataOffset) {
|
|
62364
|
-
|
|
62365
|
-
|
|
62366
|
-
if (this._cancelled) {
|
|
62367
|
-
break;
|
|
62394
|
+
this._parseTimeoutId = null;
|
|
62395
|
+
return;
|
|
62368
62396
|
}
|
|
62369
62397
|
const ix = propIndex("x");
|
|
62370
62398
|
const iy = propIndex("y");
|
|
@@ -62430,12 +62458,47 @@ class PlyStreamParser {
|
|
|
62430
62458
|
this._onSplatParsed(splatData, v);
|
|
62431
62459
|
}
|
|
62432
62460
|
this._processedVertices++;
|
|
62461
|
+
processedInThisChunk++;
|
|
62433
62462
|
if (this._processedVertices % this._batchSize === 0) {
|
|
62434
|
-
|
|
62435
|
-
this._parseVertices();
|
|
62436
|
-
}, 0);
|
|
62463
|
+
this._scheduleNextChunk();
|
|
62437
62464
|
return;
|
|
62438
62465
|
}
|
|
62466
|
+
if (processedInThisChunk >= this._verticesPerChunk) {
|
|
62467
|
+
const elapsed = performance.now() - startTime;
|
|
62468
|
+
if (elapsed > maxProcessingTime) {
|
|
62469
|
+
this._scheduleNextChunk();
|
|
62470
|
+
return;
|
|
62471
|
+
}
|
|
62472
|
+
processedInThisChunk = 0;
|
|
62473
|
+
}
|
|
62474
|
+
}
|
|
62475
|
+
this._parseTimeoutId = null;
|
|
62476
|
+
}
|
|
62477
|
+
/**
|
|
62478
|
+
* Schedule next chunk of vertex processing
|
|
62479
|
+
*/
|
|
62480
|
+
_scheduleNextChunk() {
|
|
62481
|
+
if (this._cancelled) {
|
|
62482
|
+
this._parseTimeoutId = null;
|
|
62483
|
+
return;
|
|
62484
|
+
}
|
|
62485
|
+
if (this._useIdleCallback) {
|
|
62486
|
+
this._parseTimeoutId = requestIdleCallback((deadline) => {
|
|
62487
|
+
this._parseTimeoutId = null;
|
|
62488
|
+
if (!this._cancelled && deadline.timeRemaining() > 0) {
|
|
62489
|
+
this._parseVerticesChunk();
|
|
62490
|
+
} else if (!this._cancelled) {
|
|
62491
|
+
this._parseTimeoutId = setTimeout(() => {
|
|
62492
|
+
this._parseTimeoutId = null;
|
|
62493
|
+
this._parseVerticesChunk();
|
|
62494
|
+
}, 0);
|
|
62495
|
+
}
|
|
62496
|
+
}, { timeout: 100 });
|
|
62497
|
+
} else {
|
|
62498
|
+
this._parseTimeoutId = setTimeout(() => {
|
|
62499
|
+
this._parseTimeoutId = null;
|
|
62500
|
+
this._parseVerticesChunk();
|
|
62501
|
+
}, 0);
|
|
62439
62502
|
}
|
|
62440
62503
|
}
|
|
62441
62504
|
/**
|