@draco-rust/decoder 0.1.1 → 0.1.2
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 +82 -7
- package/index.d.ts +75 -3
- package/index.js +236 -4
- package/index_bg.wasm +0 -0
- package/index_bg.wasm.d.ts +5 -3
- package/legacy/index.d.ts +75 -3
- package/legacy/index.js +236 -4
- package/legacy/index_bg.wasm +0 -0
- package/legacy/index_bg.wasm.d.ts +5 -3
- package/legacy/pool.d.ts +45 -0
- package/legacy/pool.js +193 -0
- package/legacy/three.d.ts +65 -0
- package/legacy/three.js +123 -0
- package/legacy/worker.js +28 -0
- package/mesh/index.d.ts +75 -3
- package/mesh/index.js +236 -4
- package/mesh/index_bg.wasm +0 -0
- package/mesh/index_bg.wasm.d.ts +5 -3
- package/mesh/pool.d.ts +45 -0
- package/mesh/pool.js +193 -0
- package/mesh/three.d.ts +65 -0
- package/mesh/three.js +123 -0
- package/mesh/worker.js +28 -0
- package/package.json +21 -5
- package/point-cloud/index.d.ts +75 -3
- package/point-cloud/index.js +236 -4
- package/point-cloud/index_bg.wasm +0 -0
- package/point-cloud/index_bg.wasm.d.ts +5 -3
- package/point-cloud/pool.d.ts +45 -0
- package/point-cloud/pool.js +193 -0
- package/point-cloud/three.d.ts +65 -0
- package/point-cloud/three.js +123 -0
- package/point-cloud/worker.js +28 -0
- package/pool.d.ts +45 -0
- package/pool.js +193 -0
- package/three.d.ts +65 -0
- package/three.js +123 -0
- package/worker.js +28 -0
package/README.md
CHANGED
|
@@ -11,10 +11,14 @@ Each entry is a separate module. A bundler includes only the one you import.
|
|
|
11
11
|
|
|
12
12
|
| import | decodes | gzip |
|
|
13
13
|
|---|---|---|
|
|
14
|
-
| `@draco-rust/decoder` | meshes and point clouds | ~
|
|
15
|
-
| `@draco-rust/decoder/mesh` | meshes only, which is all glTF's `KHR_draco_mesh_compression` allows | ~
|
|
16
|
-
| `@draco-rust/decoder/point-cloud` | point clouds only (scans, splats) | ~
|
|
17
|
-
| `@draco-rust/decoder/legacy` | meshes and point clouds, plus bitstreams older than 2.2 | ~
|
|
14
|
+
| `@draco-rust/decoder` | meshes and point clouds | ~92 KiB |
|
|
15
|
+
| `@draco-rust/decoder/mesh` | meshes only, which is all glTF's `KHR_draco_mesh_compression` allows | ~77 KiB |
|
|
16
|
+
| `@draco-rust/decoder/point-cloud` | point clouds only (scans, splats) | ~63 KiB |
|
|
17
|
+
| `@draco-rust/decoder/legacy` | meshes and point clouds, plus bitstreams older than 2.2 | ~103 KiB |
|
|
18
|
+
|
|
19
|
+
Each entry also has a worker pool and a three.js loader of its own, which use
|
|
20
|
+
that entry's module: `@draco-rust/decoder/pool` and `@draco-rust/decoder/three`,
|
|
21
|
+
or `@draco-rust/decoder/mesh/pool`, `@draco-rust/decoder/mesh/three` and so on.
|
|
18
22
|
|
|
19
23
|
## Usage
|
|
20
24
|
|
|
@@ -36,6 +40,77 @@ triangle corners, which is empty for a point cloud. `normals` and `uvs` are
|
|
|
36
40
|
such attribute. Attributes the stream carries beyond those are in
|
|
37
41
|
`meshes[0].extras`, and `result.warnings` says what was not interpreted.
|
|
38
42
|
|
|
43
|
+
### Attributes the way a loader asks for them
|
|
44
|
+
|
|
45
|
+
`decode_draco` returns every attribute as a typed array, or the ones a loader
|
|
46
|
+
asks for, converted to the array type it needs. Upstream Draco's decoder makes
|
|
47
|
+
the same conversions, and this one matches it byte for byte, refusing where it
|
|
48
|
+
refuses.
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import init, { decode_draco } from "@draco-rust/decoder/mesh";
|
|
52
|
+
|
|
53
|
+
await init();
|
|
54
|
+
// By unique id, as glTF's KHR_draco_mesh_compression names them, or by type.
|
|
55
|
+
const result = decode_draco(bytes, [
|
|
56
|
+
{ name: "position", id: 0, type: "Float32Array" },
|
|
57
|
+
{ name: "color", semantic: "COLOR", type: "Uint16Array" },
|
|
58
|
+
]);
|
|
59
|
+
if (!result.success) throw new Error(result.error);
|
|
60
|
+
const { index, attributes } = result; // attributes[i]: { name, array, itemSize, normalized, ... }
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Without the second argument every attribute comes back in its own type.
|
|
64
|
+
|
|
65
|
+
### On workers
|
|
66
|
+
|
|
67
|
+
Decoding runs on the calling thread. `createDecoderPool` runs it on workers
|
|
68
|
+
instead, so a page stays responsive while several streams decode at once:
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
import { createDecoderPool } from "@draco-rust/decoder/mesh/pool";
|
|
72
|
+
|
|
73
|
+
const pool = createDecoderPool({ workers: 4 }); // default: cores - 1, at most 4
|
|
74
|
+
const result = await pool.decode(bytes, requests); // what decode_draco returns
|
|
75
|
+
pool.dispose();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The workers start as work arrives, and the wasm is compiled once for all of
|
|
79
|
+
them. The stream is copied to the worker; `pool.decode(bytes, requests, {
|
|
80
|
+
transfer: true })` hands over the buffer itself instead. The pool runs on Web
|
|
81
|
+
Workers, on Node's worker threads (Node 20.16 and later), and from a CDN. With
|
|
82
|
+
`workers: 0`, or where there are no workers, it decodes on the calling thread.
|
|
83
|
+
A bundler that follows `new URL("./worker.js", import.meta.url)`, as Vite and
|
|
84
|
+
webpack do, emits the worker on its own.
|
|
85
|
+
|
|
86
|
+
### With three.js
|
|
87
|
+
|
|
88
|
+
`createDracoLoader` stands in for three.js's `DRACOLoader`, on the pool. It
|
|
89
|
+
takes three's classes rather than importing three, so it builds with your own
|
|
90
|
+
copy:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import * as THREE from "three";
|
|
94
|
+
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
|
95
|
+
import { createDracoLoader } from "@draco-rust/decoder/mesh/three";
|
|
96
|
+
|
|
97
|
+
const gltfLoader = new GLTFLoader();
|
|
98
|
+
gltfLoader.setDRACOLoader(createDracoLoader(THREE));
|
|
99
|
+
const gltf = await gltfLoader.loadAsync("model.glb");
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For a `.drc` file, `await loader.parseAsync(arrayBuffer)` returns a
|
|
103
|
+
`BufferGeometry`, and `parse(buffer, onLoad, onError)` works as DRACOLoader's
|
|
104
|
+
does. Vertex colours from a `.drc` file are converted from sRGB, as
|
|
105
|
+
DRACOLoader converts them, and an attribute whose items are not a multiple of
|
|
106
|
+
four bytes is padded and interleaved, as DRACOLoader pads it since r181. The
|
|
107
|
+
geometry is the one DRACOLoader builds, byte for byte, with one difference: an
|
|
108
|
+
attribute that does not convert to the type asked for -- a negative value
|
|
109
|
+
into a `Uint16Array`, say -- is an error here, where DRACOLoader fills the
|
|
110
|
+
attribute with whatever its failed conversion left in memory. `setWorkerLimit`,
|
|
111
|
+
`preload` and `dispose` are there too. In TypeScript, `setDRACOLoader` expects the `DRACOLoader` class, so cast
|
|
112
|
+
the loader: `createDracoLoader(THREE) as unknown as DRACOLoader`.
|
|
113
|
+
|
|
39
114
|
### From a CDN, without a bundler
|
|
40
115
|
|
|
41
116
|
```js
|
|
@@ -61,9 +136,9 @@ For a subpath entry, resolve its own file, for example
|
|
|
61
136
|
|
|
62
137
|
- Runs in every browser with WebAssembly, in Node 20.6 and later, in Deno and
|
|
63
138
|
in Bun.
|
|
64
|
-
-
|
|
65
|
-
|
|
139
|
+
- `parse_drc_bytes` and `decode_draco` decode on the calling thread; the pool
|
|
140
|
+
decodes on workers.
|
|
66
141
|
- Licensed under Apache-2.0, like Draco.
|
|
67
142
|
## This build
|
|
68
143
|
|
|
69
|
-
`@draco-rust/decoder@0.1.
|
|
144
|
+
`@draco-rust/decoder@0.1.2` was built from draco-rust commit `6bc95d5c`, with draco-core 2.3.2, draco-io 0.6.0, draco-gltf 0.7.0.
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,76 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/** The name of a typed array `decode_draco` can convert an attribute to. */
|
|
5
|
+
export type DracoArrayType =
|
|
6
|
+
| "Int8Array" | "Uint8Array" | "Int16Array" | "Uint16Array"
|
|
7
|
+
| "Int32Array" | "Uint32Array" | "Float32Array";
|
|
8
|
+
|
|
9
|
+
/** A Draco attribute type, as `semantic` names it. */
|
|
10
|
+
export type DracoSemantic = "POSITION" | "NORMAL" | "COLOR" | "TEX_COORD" | "GENERIC";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One attribute to decode: by `id`, its unique id, or by `semantic`, the first
|
|
14
|
+
* attribute of that type. `name` is handed back unchanged.
|
|
15
|
+
*/
|
|
16
|
+
export interface DracoAttributeRequest {
|
|
17
|
+
name?: string;
|
|
18
|
+
id?: number;
|
|
19
|
+
semantic?: DracoSemantic;
|
|
20
|
+
type?: DracoArrayType;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The typed arrays an attribute can come back in. */
|
|
24
|
+
export type DracoArray =
|
|
25
|
+
| Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
|
|
26
|
+
| Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
27
|
+
|
|
28
|
+
export interface DracoAttribute {
|
|
29
|
+
/** The request's `name`, or else the name the stream's metadata gives it. */
|
|
30
|
+
name?: string;
|
|
31
|
+
uniqueId: number;
|
|
32
|
+
semantic: DracoSemantic;
|
|
33
|
+
array: DracoArray;
|
|
34
|
+
itemSize: number;
|
|
35
|
+
normalized: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface DracoDecodeResult {
|
|
39
|
+
success: boolean;
|
|
40
|
+
error?: string;
|
|
41
|
+
warnings: string[];
|
|
42
|
+
geometry?: "mesh" | "point_cloud";
|
|
43
|
+
/** Triangle corners for a mesh, `null` for a point cloud. */
|
|
44
|
+
index: Uint32Array | null;
|
|
45
|
+
attributes: DracoAttribute[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Decodes a Draco stream and returns its attributes as typed arrays.
|
|
52
|
+
*
|
|
53
|
+
* `attributes` is `undefined` for every attribute in its own component type,
|
|
54
|
+
* or an array of requests `{ name, id, semantic, type }`:
|
|
55
|
+
*
|
|
56
|
+
* - `id`, a unique id, finds that attribute, as glTF's
|
|
57
|
+
* `KHR_draco_mesh_compression` names them; a missing one is an error.
|
|
58
|
+
* - `semantic` (`"POSITION"`, `"NORMAL"`, `"COLOR"`, `"TEX_COORD"` or
|
|
59
|
+
* `"GENERIC"`) finds the first attribute of that type instead, as a `.drc`
|
|
60
|
+
* file is read; a missing one is left out.
|
|
61
|
+
* - `type`, a typed array's name such as `"Float32Array"` or
|
|
62
|
+
* `"Uint16Array"`, converts the values the way upstream's
|
|
63
|
+
* `GetAttributeDataArrayForAllPoints` does; without it the values keep
|
|
64
|
+
* their own type. A value the type cannot hold is an error.
|
|
65
|
+
*
|
|
66
|
+
* The result is `{ success, error, warnings, geometry, index, attributes }`,
|
|
67
|
+
* where `geometry` is `"mesh"` or `"point_cloud"` as the stream's header says,
|
|
68
|
+
* `index` a `Uint32Array` of triangle corners for a mesh and `null` for a
|
|
69
|
+
* point cloud, and each attribute `{ name, uniqueId, semantic, array,
|
|
70
|
+
* itemSize, normalized }`.
|
|
71
|
+
*/
|
|
72
|
+
export function decode_draco(data: Uint8Array, attributes: DracoAttributeRequest[] | undefined): DracoDecodeResult;
|
|
73
|
+
|
|
4
74
|
/**
|
|
5
75
|
* Install the panic hook, so a panic reads as a message rather than a trap.
|
|
6
76
|
*/
|
|
@@ -25,14 +95,16 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
25
95
|
|
|
26
96
|
export interface InitOutput {
|
|
27
97
|
readonly memory: WebAssembly.Memory;
|
|
98
|
+
readonly decode_draco: (a: number, b: number, c: number) => number;
|
|
28
99
|
readonly init: () => void;
|
|
29
100
|
readonly parse_drc_bytes: (a: number, b: number) => number;
|
|
30
101
|
readonly supported_extensions: (a: number) => void;
|
|
31
102
|
readonly version: (a: number) => void;
|
|
32
|
-
readonly __wbindgen_export: (a: number) =>
|
|
33
|
-
readonly __wbindgen_export2: (a: number, b: number) => number;
|
|
103
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
104
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
105
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
34
106
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
35
|
-
readonly
|
|
107
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
36
108
|
readonly __wbindgen_start: () => void;
|
|
37
109
|
}
|
|
38
110
|
|
package/index.js
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
/* @ts-self-types="./index.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a Draco stream and returns its attributes as typed arrays.
|
|
5
|
+
*
|
|
6
|
+
* `attributes` is `undefined` for every attribute in its own component type,
|
|
7
|
+
* or an array of requests `{ name, id, semantic, type }`:
|
|
8
|
+
*
|
|
9
|
+
* - `id`, a unique id, finds that attribute, as glTF's
|
|
10
|
+
* `KHR_draco_mesh_compression` names them; a missing one is an error.
|
|
11
|
+
* - `semantic` (`"POSITION"`, `"NORMAL"`, `"COLOR"`, `"TEX_COORD"` or
|
|
12
|
+
* `"GENERIC"`) finds the first attribute of that type instead, as a `.drc`
|
|
13
|
+
* file is read; a missing one is left out.
|
|
14
|
+
* - `type`, a typed array's name such as `"Float32Array"` or
|
|
15
|
+
* `"Uint16Array"`, converts the values the way upstream's
|
|
16
|
+
* `GetAttributeDataArrayForAllPoints` does; without it the values keep
|
|
17
|
+
* their own type. A value the type cannot hold is an error.
|
|
18
|
+
*
|
|
19
|
+
* The result is `{ success, error, warnings, geometry, index, attributes }`,
|
|
20
|
+
* where `geometry` is `"mesh"` or `"point_cloud"` as the stream's header says,
|
|
21
|
+
* `index` a `Uint32Array` of triangle corners for a mesh and `null` for a
|
|
22
|
+
* point cloud, and each attribute `{ name, uniqueId, semantic, array,
|
|
23
|
+
* itemSize, normalized }`.
|
|
24
|
+
* @param {Uint8Array} data
|
|
25
|
+
* @param {DracoAttributeRequest[] | undefined} attributes
|
|
26
|
+
* @returns {DracoDecodeResult}
|
|
27
|
+
*/
|
|
28
|
+
export function decode_draco(data, attributes) {
|
|
29
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
30
|
+
const len0 = WASM_VECTOR_LEN;
|
|
31
|
+
const ret = wasm.decode_draco(ptr0, len0, addHeapObject(attributes));
|
|
32
|
+
return takeObject(ret);
|
|
33
|
+
}
|
|
34
|
+
|
|
3
35
|
/**
|
|
4
36
|
* Install the panic hook, so a panic reads as a message rather than a trap.
|
|
5
37
|
*/
|
|
@@ -13,7 +45,7 @@ export function init() {
|
|
|
13
45
|
* @returns {any}
|
|
14
46
|
*/
|
|
15
47
|
export function parse_drc_bytes(data) {
|
|
16
|
-
const ptr0 = passArray8ToWasm0(data, wasm.
|
|
48
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
17
49
|
const len0 = WASM_VECTOR_LEN;
|
|
18
50
|
const ret = wasm.parse_drc_bytes(ptr0, len0);
|
|
19
51
|
return takeObject(ret);
|
|
@@ -30,7 +62,7 @@ export function supported_extensions() {
|
|
|
30
62
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
31
63
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
32
64
|
var v1 = getArrayJsValueFromWasm0(r0, r1);
|
|
33
|
-
wasm.
|
|
65
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
34
66
|
return v1;
|
|
35
67
|
} finally {
|
|
36
68
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -54,15 +86,53 @@ export function version() {
|
|
|
54
86
|
return getStringFromWasm0(r0, r1);
|
|
55
87
|
} finally {
|
|
56
88
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
57
|
-
wasm.
|
|
89
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
58
90
|
}
|
|
59
91
|
}
|
|
60
92
|
function __wbg_get_imports() {
|
|
61
93
|
const import0 = {
|
|
62
94
|
__proto__: null,
|
|
95
|
+
__wbg___wbindgen_is_null_e343b7d08827ba72: function(arg0) {
|
|
96
|
+
const ret = getObject(arg0) === null;
|
|
97
|
+
return ret;
|
|
98
|
+
},
|
|
99
|
+
__wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
|
|
100
|
+
const ret = getObject(arg0) === undefined;
|
|
101
|
+
return ret;
|
|
102
|
+
},
|
|
103
|
+
__wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
|
|
104
|
+
const obj = getObject(arg1);
|
|
105
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
106
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
107
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
108
|
+
},
|
|
109
|
+
__wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
|
|
110
|
+
const obj = getObject(arg1);
|
|
111
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
112
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
113
|
+
var len1 = WASM_VECTOR_LEN;
|
|
114
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
115
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
116
|
+
},
|
|
63
117
|
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
64
118
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
65
119
|
},
|
|
120
|
+
__wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
|
|
121
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
122
|
+
return addHeapObject(ret);
|
|
123
|
+
}, arguments); },
|
|
124
|
+
__wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
|
|
125
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
126
|
+
return addHeapObject(ret);
|
|
127
|
+
},
|
|
128
|
+
__wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
|
|
129
|
+
const ret = Array.isArray(getObject(arg0));
|
|
130
|
+
return ret;
|
|
131
|
+
},
|
|
132
|
+
__wbg_length_d4bdea10311bd9cf: function(arg0) {
|
|
133
|
+
const ret = getObject(arg0).length;
|
|
134
|
+
return ret;
|
|
135
|
+
},
|
|
66
136
|
__wbg_new_617a8cdb8bb1130e: function() {
|
|
67
137
|
const ret = new Object();
|
|
68
138
|
return addHeapObject(ret);
|
|
@@ -71,14 +141,34 @@ function __wbg_get_imports() {
|
|
|
71
141
|
const ret = new Array();
|
|
72
142
|
return addHeapObject(ret);
|
|
73
143
|
},
|
|
144
|
+
__wbg_new_from_slice_23f60f47cde8d664: function(arg0, arg1) {
|
|
145
|
+
const ret = new Uint16Array(getArrayU16FromWasm0(arg0, arg1));
|
|
146
|
+
return addHeapObject(ret);
|
|
147
|
+
},
|
|
148
|
+
__wbg_new_from_slice_2443ca2017fac0fd: function(arg0, arg1) {
|
|
149
|
+
const ret = new Int16Array(getArrayI16FromWasm0(arg0, arg1));
|
|
150
|
+
return addHeapObject(ret);
|
|
151
|
+
},
|
|
152
|
+
__wbg_new_from_slice_36f6b4e63daa7f59: function(arg0, arg1) {
|
|
153
|
+
const ret = new Int8Array(getArrayI8FromWasm0(arg0, arg1));
|
|
154
|
+
return addHeapObject(ret);
|
|
155
|
+
},
|
|
74
156
|
__wbg_new_from_slice_37a3c3a194266cb8: function(arg0, arg1) {
|
|
75
157
|
const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
|
|
76
158
|
return addHeapObject(ret);
|
|
77
159
|
},
|
|
160
|
+
__wbg_new_from_slice_911f717853b222c7: function(arg0, arg1) {
|
|
161
|
+
const ret = new Int32Array(getArrayI32FromWasm0(arg0, arg1));
|
|
162
|
+
return addHeapObject(ret);
|
|
163
|
+
},
|
|
78
164
|
__wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
|
|
79
165
|
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
80
166
|
return addHeapObject(ret);
|
|
81
167
|
},
|
|
168
|
+
__wbg_new_from_slice_aa8f37bd5e72dcc7: function(arg0, arg1) {
|
|
169
|
+
const ret = new BigInt64Array(getArrayI64FromWasm0(arg0, arg1));
|
|
170
|
+
return addHeapObject(ret);
|
|
171
|
+
},
|
|
82
172
|
__wbg_new_from_slice_ca6ad97db1f4779a: function(arg0, arg1) {
|
|
83
173
|
const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
|
|
84
174
|
return addHeapObject(ret);
|
|
@@ -87,6 +177,10 @@ function __wbg_get_imports() {
|
|
|
87
177
|
const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
|
|
88
178
|
return addHeapObject(ret);
|
|
89
179
|
},
|
|
180
|
+
__wbg_new_from_slice_f6cd96ab370a57b3: function(arg0, arg1) {
|
|
181
|
+
const ret = new BigUint64Array(getArrayU64FromWasm0(arg0, arg1));
|
|
182
|
+
return addHeapObject(ret);
|
|
183
|
+
},
|
|
90
184
|
__wbg_push_2baf45db356cf468: function(arg0, arg1) {
|
|
91
185
|
const ret = getObject(arg0).push(getObject(arg1));
|
|
92
186
|
return ret;
|
|
@@ -140,6 +234,26 @@ function getArrayF64FromWasm0(ptr, len) {
|
|
|
140
234
|
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
141
235
|
}
|
|
142
236
|
|
|
237
|
+
function getArrayI16FromWasm0(ptr, len) {
|
|
238
|
+
ptr = ptr >>> 0;
|
|
239
|
+
return getInt16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function getArrayI32FromWasm0(ptr, len) {
|
|
243
|
+
ptr = ptr >>> 0;
|
|
244
|
+
return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function getArrayI64FromWasm0(ptr, len) {
|
|
248
|
+
ptr = ptr >>> 0;
|
|
249
|
+
return getBigInt64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function getArrayI8FromWasm0(ptr, len) {
|
|
253
|
+
ptr = ptr >>> 0;
|
|
254
|
+
return getInt8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
255
|
+
}
|
|
256
|
+
|
|
143
257
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
144
258
|
ptr = ptr >>> 0;
|
|
145
259
|
const mem = getDataViewMemory0();
|
|
@@ -150,16 +264,42 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
150
264
|
return result;
|
|
151
265
|
}
|
|
152
266
|
|
|
267
|
+
function getArrayU16FromWasm0(ptr, len) {
|
|
268
|
+
ptr = ptr >>> 0;
|
|
269
|
+
return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
270
|
+
}
|
|
271
|
+
|
|
153
272
|
function getArrayU32FromWasm0(ptr, len) {
|
|
154
273
|
ptr = ptr >>> 0;
|
|
155
274
|
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
156
275
|
}
|
|
157
276
|
|
|
277
|
+
function getArrayU64FromWasm0(ptr, len) {
|
|
278
|
+
ptr = ptr >>> 0;
|
|
279
|
+
return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
280
|
+
}
|
|
281
|
+
|
|
158
282
|
function getArrayU8FromWasm0(ptr, len) {
|
|
159
283
|
ptr = ptr >>> 0;
|
|
160
284
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
161
285
|
}
|
|
162
286
|
|
|
287
|
+
let cachedBigInt64ArrayMemory0 = null;
|
|
288
|
+
function getBigInt64ArrayMemory0() {
|
|
289
|
+
if (cachedBigInt64ArrayMemory0 === null || cachedBigInt64ArrayMemory0.byteLength === 0) {
|
|
290
|
+
cachedBigInt64ArrayMemory0 = new BigInt64Array(wasm.memory.buffer);
|
|
291
|
+
}
|
|
292
|
+
return cachedBigInt64ArrayMemory0;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
let cachedBigUint64ArrayMemory0 = null;
|
|
296
|
+
function getBigUint64ArrayMemory0() {
|
|
297
|
+
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
298
|
+
cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
|
|
299
|
+
}
|
|
300
|
+
return cachedBigUint64ArrayMemory0;
|
|
301
|
+
}
|
|
302
|
+
|
|
163
303
|
let cachedDataViewMemory0 = null;
|
|
164
304
|
function getDataViewMemory0() {
|
|
165
305
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
@@ -184,10 +324,42 @@ function getFloat64ArrayMemory0() {
|
|
|
184
324
|
return cachedFloat64ArrayMemory0;
|
|
185
325
|
}
|
|
186
326
|
|
|
327
|
+
let cachedInt16ArrayMemory0 = null;
|
|
328
|
+
function getInt16ArrayMemory0() {
|
|
329
|
+
if (cachedInt16ArrayMemory0 === null || cachedInt16ArrayMemory0.byteLength === 0) {
|
|
330
|
+
cachedInt16ArrayMemory0 = new Int16Array(wasm.memory.buffer);
|
|
331
|
+
}
|
|
332
|
+
return cachedInt16ArrayMemory0;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
let cachedInt32ArrayMemory0 = null;
|
|
336
|
+
function getInt32ArrayMemory0() {
|
|
337
|
+
if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
|
|
338
|
+
cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
|
|
339
|
+
}
|
|
340
|
+
return cachedInt32ArrayMemory0;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
let cachedInt8ArrayMemory0 = null;
|
|
344
|
+
function getInt8ArrayMemory0() {
|
|
345
|
+
if (cachedInt8ArrayMemory0 === null || cachedInt8ArrayMemory0.byteLength === 0) {
|
|
346
|
+
cachedInt8ArrayMemory0 = new Int8Array(wasm.memory.buffer);
|
|
347
|
+
}
|
|
348
|
+
return cachedInt8ArrayMemory0;
|
|
349
|
+
}
|
|
350
|
+
|
|
187
351
|
function getStringFromWasm0(ptr, len) {
|
|
188
352
|
return decodeText(ptr >>> 0, len);
|
|
189
353
|
}
|
|
190
354
|
|
|
355
|
+
let cachedUint16ArrayMemory0 = null;
|
|
356
|
+
function getUint16ArrayMemory0() {
|
|
357
|
+
if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
|
|
358
|
+
cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
|
|
359
|
+
}
|
|
360
|
+
return cachedUint16ArrayMemory0;
|
|
361
|
+
}
|
|
362
|
+
|
|
191
363
|
let cachedUint32ArrayMemory0 = null;
|
|
192
364
|
function getUint32ArrayMemory0() {
|
|
193
365
|
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
@@ -210,7 +382,7 @@ function handleError(f, args) {
|
|
|
210
382
|
try {
|
|
211
383
|
return f.apply(this, args);
|
|
212
384
|
} catch (e) {
|
|
213
|
-
wasm.
|
|
385
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
214
386
|
}
|
|
215
387
|
}
|
|
216
388
|
|
|
@@ -219,6 +391,10 @@ heap.push(undefined, null, true, false);
|
|
|
219
391
|
|
|
220
392
|
let heap_next = heap.length;
|
|
221
393
|
|
|
394
|
+
function isLikeNone(x) {
|
|
395
|
+
return x === undefined || x === null;
|
|
396
|
+
}
|
|
397
|
+
|
|
222
398
|
function passArray8ToWasm0(arg, malloc) {
|
|
223
399
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
224
400
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
@@ -226,6 +402,43 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
226
402
|
return ptr;
|
|
227
403
|
}
|
|
228
404
|
|
|
405
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
406
|
+
if (realloc === undefined) {
|
|
407
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
408
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
409
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
410
|
+
WASM_VECTOR_LEN = buf.length;
|
|
411
|
+
return ptr;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
let len = arg.length;
|
|
415
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
416
|
+
|
|
417
|
+
const mem = getUint8ArrayMemory0();
|
|
418
|
+
|
|
419
|
+
let offset = 0;
|
|
420
|
+
|
|
421
|
+
for (; offset < len; offset++) {
|
|
422
|
+
const code = arg.charCodeAt(offset);
|
|
423
|
+
if (code > 0x7F) break;
|
|
424
|
+
mem[ptr + offset] = code;
|
|
425
|
+
}
|
|
426
|
+
if (offset !== len) {
|
|
427
|
+
if (offset !== 0) {
|
|
428
|
+
arg = arg.slice(offset);
|
|
429
|
+
}
|
|
430
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
431
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
432
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
433
|
+
|
|
434
|
+
offset += ret.written;
|
|
435
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
WASM_VECTOR_LEN = offset;
|
|
439
|
+
return ptr;
|
|
440
|
+
}
|
|
441
|
+
|
|
229
442
|
function takeObject(idx) {
|
|
230
443
|
const ret = getObject(idx);
|
|
231
444
|
dropObject(idx);
|
|
@@ -246,6 +459,19 @@ function decodeText(ptr, len) {
|
|
|
246
459
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
247
460
|
}
|
|
248
461
|
|
|
462
|
+
const cachedTextEncoder = new TextEncoder();
|
|
463
|
+
|
|
464
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
465
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
466
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
467
|
+
view.set(buf);
|
|
468
|
+
return {
|
|
469
|
+
read: arg.length,
|
|
470
|
+
written: buf.length
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
|
|
249
475
|
let WASM_VECTOR_LEN = 0;
|
|
250
476
|
|
|
251
477
|
let wasmModule, wasmInstance, wasm;
|
|
@@ -253,9 +479,15 @@ function __wbg_finalize_init(instance, module) {
|
|
|
253
479
|
wasmInstance = instance;
|
|
254
480
|
wasm = instance.exports;
|
|
255
481
|
wasmModule = module;
|
|
482
|
+
cachedBigInt64ArrayMemory0 = null;
|
|
483
|
+
cachedBigUint64ArrayMemory0 = null;
|
|
256
484
|
cachedDataViewMemory0 = null;
|
|
257
485
|
cachedFloat32ArrayMemory0 = null;
|
|
258
486
|
cachedFloat64ArrayMemory0 = null;
|
|
487
|
+
cachedInt16ArrayMemory0 = null;
|
|
488
|
+
cachedInt32ArrayMemory0 = null;
|
|
489
|
+
cachedInt8ArrayMemory0 = null;
|
|
490
|
+
cachedUint16ArrayMemory0 = null;
|
|
259
491
|
cachedUint32ArrayMemory0 = null;
|
|
260
492
|
cachedUint8ArrayMemory0 = null;
|
|
261
493
|
wasm.__wbindgen_start();
|
package/index_bg.wasm
CHANGED
|
Binary file
|
package/index_bg.wasm.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const decode_draco: (a: number, b: number, c: number) => number;
|
|
4
5
|
export const init: () => void;
|
|
5
6
|
export const parse_drc_bytes: (a: number, b: number) => number;
|
|
6
7
|
export const supported_extensions: (a: number) => void;
|
|
7
8
|
export const version: (a: number) => void;
|
|
8
|
-
export const __wbindgen_export: (a: number) =>
|
|
9
|
-
export const __wbindgen_export2: (a: number, b: number) => number;
|
|
9
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
10
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
11
|
+
export const __wbindgen_export3: (a: number) => void;
|
|
10
12
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
11
|
-
export const
|
|
13
|
+
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
12
14
|
export const __wbindgen_start: () => void;
|
package/legacy/index.d.ts
CHANGED
|
@@ -1,6 +1,76 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/** The name of a typed array `decode_draco` can convert an attribute to. */
|
|
5
|
+
export type DracoArrayType =
|
|
6
|
+
| "Int8Array" | "Uint8Array" | "Int16Array" | "Uint16Array"
|
|
7
|
+
| "Int32Array" | "Uint32Array" | "Float32Array";
|
|
8
|
+
|
|
9
|
+
/** A Draco attribute type, as `semantic` names it. */
|
|
10
|
+
export type DracoSemantic = "POSITION" | "NORMAL" | "COLOR" | "TEX_COORD" | "GENERIC";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One attribute to decode: by `id`, its unique id, or by `semantic`, the first
|
|
14
|
+
* attribute of that type. `name` is handed back unchanged.
|
|
15
|
+
*/
|
|
16
|
+
export interface DracoAttributeRequest {
|
|
17
|
+
name?: string;
|
|
18
|
+
id?: number;
|
|
19
|
+
semantic?: DracoSemantic;
|
|
20
|
+
type?: DracoArrayType;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The typed arrays an attribute can come back in. */
|
|
24
|
+
export type DracoArray =
|
|
25
|
+
| Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
|
|
26
|
+
| Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
27
|
+
|
|
28
|
+
export interface DracoAttribute {
|
|
29
|
+
/** The request's `name`, or else the name the stream's metadata gives it. */
|
|
30
|
+
name?: string;
|
|
31
|
+
uniqueId: number;
|
|
32
|
+
semantic: DracoSemantic;
|
|
33
|
+
array: DracoArray;
|
|
34
|
+
itemSize: number;
|
|
35
|
+
normalized: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface DracoDecodeResult {
|
|
39
|
+
success: boolean;
|
|
40
|
+
error?: string;
|
|
41
|
+
warnings: string[];
|
|
42
|
+
geometry?: "mesh" | "point_cloud";
|
|
43
|
+
/** Triangle corners for a mesh, `null` for a point cloud. */
|
|
44
|
+
index: Uint32Array | null;
|
|
45
|
+
attributes: DracoAttribute[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Decodes a Draco stream and returns its attributes as typed arrays.
|
|
52
|
+
*
|
|
53
|
+
* `attributes` is `undefined` for every attribute in its own component type,
|
|
54
|
+
* or an array of requests `{ name, id, semantic, type }`:
|
|
55
|
+
*
|
|
56
|
+
* - `id`, a unique id, finds that attribute, as glTF's
|
|
57
|
+
* `KHR_draco_mesh_compression` names them; a missing one is an error.
|
|
58
|
+
* - `semantic` (`"POSITION"`, `"NORMAL"`, `"COLOR"`, `"TEX_COORD"` or
|
|
59
|
+
* `"GENERIC"`) finds the first attribute of that type instead, as a `.drc`
|
|
60
|
+
* file is read; a missing one is left out.
|
|
61
|
+
* - `type`, a typed array's name such as `"Float32Array"` or
|
|
62
|
+
* `"Uint16Array"`, converts the values the way upstream's
|
|
63
|
+
* `GetAttributeDataArrayForAllPoints` does; without it the values keep
|
|
64
|
+
* their own type. A value the type cannot hold is an error.
|
|
65
|
+
*
|
|
66
|
+
* The result is `{ success, error, warnings, geometry, index, attributes }`,
|
|
67
|
+
* where `geometry` is `"mesh"` or `"point_cloud"` as the stream's header says,
|
|
68
|
+
* `index` a `Uint32Array` of triangle corners for a mesh and `null` for a
|
|
69
|
+
* point cloud, and each attribute `{ name, uniqueId, semantic, array,
|
|
70
|
+
* itemSize, normalized }`.
|
|
71
|
+
*/
|
|
72
|
+
export function decode_draco(data: Uint8Array, attributes: DracoAttributeRequest[] | undefined): DracoDecodeResult;
|
|
73
|
+
|
|
4
74
|
/**
|
|
5
75
|
* Install the panic hook, so a panic reads as a message rather than a trap.
|
|
6
76
|
*/
|
|
@@ -25,14 +95,16 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
25
95
|
|
|
26
96
|
export interface InitOutput {
|
|
27
97
|
readonly memory: WebAssembly.Memory;
|
|
98
|
+
readonly decode_draco: (a: number, b: number, c: number) => number;
|
|
28
99
|
readonly init: () => void;
|
|
29
100
|
readonly parse_drc_bytes: (a: number, b: number) => number;
|
|
30
101
|
readonly supported_extensions: (a: number) => void;
|
|
31
102
|
readonly version: (a: number) => void;
|
|
32
|
-
readonly __wbindgen_export: (a: number) =>
|
|
33
|
-
readonly __wbindgen_export2: (a: number, b: number) => number;
|
|
103
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
104
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
105
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
34
106
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
35
|
-
readonly
|
|
107
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
36
108
|
readonly __wbindgen_start: () => void;
|
|
37
109
|
}
|
|
38
110
|
|