minidraco 0.6.0 → 0.8.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/README.md CHANGED
@@ -15,8 +15,7 @@ gltfLoader.setDRACOLoader(new MinidracoLoader())
15
15
  gltfLoader.load('model.glb', gltf => scene.add(gltf.scene))
16
16
  ```
17
17
 
18
- A drop-in for `THREE.DRACOLoader`, no cast needed. Decoding runs on the main thread by default;
19
- opt into a worker pool (with a main-thread fallback) to keep it free:
18
+ A drop-in for `THREE.DRACOLoader`. Decoding runs on the main thread by default. Opt into a worker pool if you prefer to keep it free:
20
19
 
21
20
  ```ts
22
21
  new MinidracoLoader({ workers: true }) // decode in a pool of 4 workers
@@ -39,36 +38,23 @@ const mesh = decodeDracoMesh(new Uint8Array(bytes))
39
38
 
40
39
  ## Performance
41
40
 
42
- Median across an 18-model corpus vs [draco.js](https://github.com/mrdoob/draco.js) and the official
41
+ Median across 18 models vs [draco.js](https://github.com/mrdoob/draco.js) and the official
43
42
  [draco3d](https://www.npmjs.com/package/draco3d) wasm decoder (full results in
44
43
  [BENCH.md](https://github.com/verekia/minidraco/blob/main/BENCH.md)):
45
44
 
46
45
  | benchmark | vs draco.js | vs draco3d wasm |
47
46
  | -------------------------------------------------- | --------------- | --------------- |
48
- | single-threaded decode — bun (JSC) | 🟢 1.37× faster | 🟢 1.49× faster |
49
- | single-threaded decode — Chrome (V8) | 🟢 1.41× faster | 🟢 1.26× faster |
50
- | `GLTFLoader.parse`, warm worker pool — Chrome (V8) | 🟢 1.45× faster | 🟢 1.03× faster |
51
- | `GLTFLoader.parse`, cold first load — Chrome (V8) | 🟢 1.37× faster | 🟢 1.23× faster |
52
-
53
- Faster than draco.js across the corpus, ahead of the wasm decoder single-threaded, and level with
54
- it in a real `GLTFLoader.parse` with `workers: true` and the main thread left free — warm, and
55
- level to ahead on the first load of a session (cold numbers swing run to run), where minidraco's
56
- worker pool is still JIT-warming while the wasm decoder is fetching and compiling its module (no
57
- `draco_decoder.wasm` to host or download here).
47
+ | single-threaded decode — bun (JSC) | 🟢 1.60× faster | 🟢 1.69× faster |
48
+ | single-threaded decode — Chrome (V8) | 🟢 1.57× faster | 🟢 1.43× faster |
49
+ | `GLTFLoader.parse`, warm worker pool — Chrome (V8) | 🟢 1.57× faster | 🟢 1.06× faster |
50
+ | `GLTFLoader.parse`, cold first load — Chrome (V8) | 🟢 1.42× faster | 🟢 1.28× faster |
58
51
 
59
52
  ## Download size
60
53
 
61
- Minified + brotli, vs the same two decoders (regenerate with `bun run sizes`):
62
-
63
- | download (brotli) | minidraco | vs draco.js | vs draco3d wasm |
64
- | ----------------------------- | --------- | ---------------- | ----------------------- |
65
- | single-threaded (default) | 22 KB | ⚪ even (22 KB) | 🟢 3.7× smaller (81 KB) |
66
- | worker pool (`workers: true`) | 45 KB | 🟢 not supported | 🟢 1.8× smaller (81 KB) |
67
-
68
- With `workers: true` the browser also fetches the pool module and a worker chunk holding a second
69
- copy of the decoder on the first decode. draco.js has no worker pool. The wasm path ships three's
70
- `DRACOLoader` in your bundle and fetches the wrapper and `draco_decoder.wasm`, which you must
71
- host, before the first decode.
54
+ | download (brotli) | minidraco | vs draco.js | vs draco3d wasm |
55
+ | ----------------------------- | --------- | ------------------------ | ------------------------ |
56
+ | single-threaded (default) | 21 KB | 🟢 1.05× smaller (22 KB) | 🟢 3.84× smaller (81 KB) |
57
+ | worker pool (`workers: true`) | 43 KB | 🟢 not supported | 🟢 1.85× smaller (81 KB) |
72
58
 
73
59
  ## Monorepo
74
60
 
@@ -84,5 +70,5 @@ bun run bench # cross-decoder benchmark
84
70
 
85
71
  ## License
86
72
 
87
- MIT — derived from [mrdoob/draco.js](https://github.com/mrdoob/draco.js) (MIT), implementing
73
+ MIT — initially derived from [mrdoob/draco.js](https://github.com/mrdoob/draco.js) (MIT), implementing
88
74
  Google's [Draco](https://github.com/google/draco) bitstream (Apache-2.0).
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  declare class DataBuffer {
2
2
  _data: Uint8Array;
3
3
  update(data: Uint8Array | null, size: number): void;
4
- adoptScratch(size: number): void;
5
4
  write(bytePos: number, inArray: Uint8Array, dataSize: number): void;
6
5
  get data(): Uint8Array;
7
6
  _resize(newSize: number): void;
@@ -37,13 +36,6 @@ declare class GeometryAttribute {
37
36
  set uniqueId(id: number);
38
37
  }
39
38
 
40
- declare class AttributeTransformData {
41
- transformType: number;
42
- _values: number[];
43
- _types: string[];
44
- appendParameterValue(value: number, type: string): void;
45
- }
46
-
47
39
  type ExtractTypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
48
40
  type ViewCtor = (new (buffer: ArrayBufferLike) => ExtractTypedArray) & {
49
41
  BYTES_PER_ELEMENT: number;
@@ -53,14 +45,21 @@ declare class PointAttribute extends GeometryAttribute {
53
45
  _numUniqueEntries: number;
54
46
  _indicesMap: number[] | Uint32Array;
55
47
  _attributeBuffer: DataBuffer | null;
56
- _attributeTransformData: AttributeTransformData | null;
57
48
  _cachedViewCtor: ViewCtor | null;
58
49
  _cachedViewBuffer: ArrayBufferLike | null;
59
50
  _cachedView: ExtractTypedArray | null;
51
+ _lazyKind: number;
52
+ _lazyValues: Int32Array | null;
53
+ _lazyMin: number[];
54
+ _lazyScale: number;
55
+ _lazyBounded: boolean;
60
56
  constructor(geometryAttribute?: GeometryAttribute);
61
57
  init(attributeType: number, numComponents: number, dataType: number, normalized: boolean, numAttributeValues: number): void;
62
58
  reset(numAttributeValues: number): boolean;
63
- resetScratch(numAttributeValues: number): boolean;
59
+ resetLazy(numAttributeValues: number): void;
60
+ setLazyInteger(values: Int32Array | null): void;
61
+ setLazyQuantized(values: Int32Array | null, minValues: number[], delta: number, bounded: boolean): void;
62
+ setLazyOctahedron(values: Int32Array | null, scale: number, bounded: boolean): void;
64
63
  get size(): number;
65
64
  mappedIndex(pointIndex: number): number;
66
65
  get isMappingIdentity(): boolean;
@@ -70,10 +69,14 @@ declare class PointAttribute extends GeometryAttribute {
70
69
  setExplicitMappingUnfilled(numPoints: number): void;
71
70
  setExplicitMappingShared(map: Uint32Array): void;
72
71
  setExplicitMappingScratch(numPoints: number): void;
73
- setAttributeTransformData(transformData: AttributeTransformData): void;
74
72
  _view(Ctor: ViewCtor, bufData: Uint8Array): ExtractTypedArray;
75
73
  convertValue(attIndex: number, outVal: number[] | Int32Array | Uint32Array | Float32Array | Float64Array): void;
76
74
  extractTo<C extends new (length: number) => ExtractTypedArray>(OutputTypedArray: C, numPoints: number): InstanceType<C>;
75
+ _lazyMap(numPoints: number): Uint32Array;
76
+ _lazyFloatValues(): Int32Array;
77
+ _extractQuantized(out: ExtractTypedArray, numPoints: number): void;
78
+ _extractOctahedron(out: ExtractTypedArray, numPoints: number): void;
79
+ _extractInteger(out: ExtractTypedArray, numPoints: number): void;
77
80
  }
78
81
 
79
82
  declare class PointCloud {