minidraco 0.7.0 → 0.9.0

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/pool.js CHANGED
@@ -7,70 +7,70 @@ var decodeError = (message) => {
7
7
  var WorkerPool = class {
8
8
  // Pool size; the loader keeps it in sync with setWorkerLimit().
9
9
  limit;
10
- Ha;
10
+ Ga;
11
11
  D = [];
12
- Gc = 0;
13
- _ = /* @__PURE__ */ new Map();
12
+ Ec = 0;
13
+ da = /* @__PURE__ */ new Map();
14
14
  // Tasks queued during the current microtask; flushed as one batched message
15
15
  // per worker (a 488-primitive scene costs 4 postMessages, not 488).
16
- Ia = [];
17
- Za = false;
16
+ Ha = [];
17
+ Ya = false;
18
18
  // Set when spawning a worker fails (bundler without module-worker support,
19
19
  // file:// pages, …) or a worker errors: the loader then decodes on the main
20
20
  // thread.
21
21
  broken = false;
22
22
  // Same-origin blob bootstrap used when the worker asset lives on a CDN
23
23
  // origin (created lazily, revoked on dispose).
24
- pa = null;
24
+ oa = null;
25
25
  constructor(limit, workerUrl) {
26
26
  this.limit = limit;
27
- this.Ha = workerUrl;
27
+ this.Ga = workerUrl;
28
28
  }
29
29
  // Spawns the whole pool up front: each fresh worker runs a short JIT warmup
30
30
  // at startup (see worker.ts), so spawning early lets that overlap the model
31
31
  // download instead of the first decode burst.
32
32
  spawnAll() {
33
- while (this.D.length < this.limit && this.cc() !== null) {
33
+ while (this.D.length < this.limit && this.ac() !== null) {
34
34
  }
35
35
  }
36
36
  dispose() {
37
37
  for (const entry of this.D) entry.worker.terminate();
38
38
  this.D = [];
39
39
  const error = decodeError("MinidracoLoader: disposed while decoding");
40
- for (const task of this.Ia) task.reject(error);
41
- this.Ia = [];
42
- this.Za = false;
43
- for (const [, task] of this._) task.reject(error);
44
- this._.clear();
45
- if (this.pa !== null) {
46
- URL.revokeObjectURL(this.pa);
47
- this.pa = null;
40
+ for (const task of this.Ha) task.reject(error);
41
+ this.Ha = [];
42
+ this.Ya = false;
43
+ for (const [, task] of this.da) task.reject(error);
44
+ this.da.clear();
45
+ if (this.oa !== null) {
46
+ URL.revokeObjectURL(this.oa);
47
+ this.oa = null;
48
48
  }
49
49
  }
50
50
  decode(buffer, taskConfig) {
51
- const id = this.Gc++;
51
+ const id = this.Ec++;
52
52
  return new Promise((resolve, reject) => {
53
- this.Ia.push({ id, buffer, taskConfig, resolve, reject });
54
- if (!this.Za) {
55
- this.Za = true;
56
- queueMicrotask(() => this.Hc());
53
+ this.Ha.push({ id, buffer, taskConfig, resolve, reject });
54
+ if (!this.Ya) {
55
+ this.Ya = true;
56
+ queueMicrotask(() => this.Fc());
57
57
  }
58
58
  });
59
59
  }
60
- cc() {
60
+ ac() {
61
61
  if (this.broken) return null;
62
62
  if (this.D.length < this.limit) {
63
- const workerUrl = this.Ha ?? new URL("./worker.js", import.meta.url);
63
+ const workerUrl = this.Ga ?? new URL("./worker.js", import.meta.url);
64
64
  let worker;
65
65
  try {
66
66
  worker = new Worker(workerUrl, { type: "module" });
67
67
  } catch {
68
68
  try {
69
- if (this.pa === null) {
69
+ if (this.oa === null) {
70
70
  const bootstrap = `import ${JSON.stringify(String(workerUrl))};`;
71
- this.pa = URL.createObjectURL(new Blob([bootstrap], { type: "text/javascript" }));
71
+ this.oa = URL.createObjectURL(new Blob([bootstrap], { type: "text/javascript" }));
72
72
  }
73
- worker = new Worker(this.pa, { type: "module" });
73
+ worker = new Worker(this.oa, { type: "module" });
74
74
  } catch {
75
75
  this.broken = true;
76
76
  return null;
@@ -79,9 +79,9 @@ var WorkerPool = class {
79
79
  const entry = { worker, pending: 0 };
80
80
  worker.onmessage = (event) => {
81
81
  for (const { id, ok, indices, attributes, error } of event.data.results) {
82
- const task = this._.get(id);
82
+ const task = this.da.get(id);
83
83
  if (!task) continue;
84
- this._.delete(id);
84
+ this.da.delete(id);
85
85
  task.entry.pending--;
86
86
  if (ok) {
87
87
  task.resolve({ indices, attributes });
@@ -92,9 +92,9 @@ var WorkerPool = class {
92
92
  };
93
93
  worker.onerror = (event) => {
94
94
  this.broken = true;
95
- for (const [id, task] of this._) {
95
+ for (const [id, task] of this.da) {
96
96
  if (task.entry.worker === worker) {
97
- this._.delete(id);
97
+ this.da.delete(id);
98
98
  task.reject(new Error(`MinidracoLoader worker failed: ${event.message ?? "unknown error"}`));
99
99
  }
100
100
  }
@@ -106,12 +106,12 @@ var WorkerPool = class {
106
106
  for (const entry of this.D) if (entry.pending < best.pending) best = entry;
107
107
  return best;
108
108
  }
109
- Hc() {
110
- this.Za = false;
111
- const batch = this.Ia;
109
+ Fc() {
110
+ this.Ya = false;
111
+ const batch = this.Ha;
112
112
  if (batch.length === 0) return;
113
- this.Ia = [];
114
- while (this.D.length < Math.min(this.limit, batch.length) && this.cc() !== null) {
113
+ this.Ha = [];
114
+ while (this.D.length < Math.min(this.limit, batch.length) && this.ac() !== null) {
115
115
  }
116
116
  if (this.broken || this.D.length === 0) {
117
117
  const error = new Error("MinidracoLoader: worker unavailable");
@@ -136,7 +136,7 @@ var WorkerPool = class {
136
136
  for (const { entry, tasks } of buckets) {
137
137
  if (tasks.length === 0) continue;
138
138
  entry.pending += tasks.length;
139
- for (const task of tasks) this._.set(task.id, { resolve: task.resolve, reject: task.reject, entry });
139
+ for (const task of tasks) this.da.set(task.id, { resolve: task.resolve, reject: task.reject, entry });
140
140
  entry.worker.postMessage({
141
141
  tasks: tasks.map((task) => ({
142
142
  id: task.id,
package/dist/three.d.ts CHANGED
@@ -45,13 +45,15 @@ declare class PointAttribute extends GeometryAttribute {
45
45
  _lazyValues: Int32Array | null;
46
46
  _lazyMin: number[];
47
47
  _lazyScale: number;
48
+ _lazyBounded: boolean;
48
49
  constructor(geometryAttribute?: GeometryAttribute);
49
50
  init(attributeType: number, numComponents: number, dataType: number, normalized: boolean, numAttributeValues: number): void;
50
51
  reset(numAttributeValues: number): boolean;
52
+ resetWithData(data: Uint8Array, numAttributeValues: number): void;
51
53
  resetLazy(numAttributeValues: number): void;
52
54
  setLazyInteger(values: Int32Array | null): void;
53
- setLazyQuantized(values: Int32Array | null, minValues: number[], delta: number): void;
54
- setLazyOctahedron(values: Int32Array | null, scale: number): void;
55
+ setLazyQuantized(values: Int32Array | null, minValues: number[], delta: number, bounded: boolean): void;
56
+ setLazyOctahedron(values: Int32Array | null, scale: number, bounded: boolean): void;
55
57
  get size(): number;
56
58
  mappedIndex(pointIndex: number): number;
57
59
  get isMappingIdentity(): boolean;
@@ -66,8 +68,8 @@ declare class PointAttribute extends GeometryAttribute {
66
68
  extractTo<C extends new (length: number) => ExtractTypedArray>(OutputTypedArray: C, numPoints: number): InstanceType<C>;
67
69
  _lazyMap(numPoints: number): Uint32Array;
68
70
  _lazyFloatValues(): Int32Array;
69
- _extractQuantized(out: ExtractTypedArray, numPoints: number): void;
70
- _extractOctahedron(out: ExtractTypedArray, numPoints: number): void;
71
+ _extractQuantized(out: Float32Array, numPoints: number): void;
72
+ _extractOctahedron(out: Float32Array, numPoints: number): void;
71
73
  _extractInteger(out: ExtractTypedArray, numPoints: number): void;
72
74
  }
73
75