@rings-webgpu/core 1.0.47 → 1.0.49

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