@draco-rust/decoder 0.2.0 → 0.3.1

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.
@@ -3,8 +3,8 @@
3
3
 
4
4
  /** The name of a typed array `decode_draco` can convert an attribute to. */
5
5
  export type DracoArrayType =
6
- | "Int8Array" | "Uint8Array" | "Int16Array" | "Uint16Array"
7
- | "Int32Array" | "Uint32Array" | "Float32Array";
6
+ | "Int8Array" | "Uint8Array" | "Int16Array" | "Uint16Array"
7
+ | "Int32Array" | "Uint32Array" | "Float32Array";
8
8
 
9
9
  /** A Draco attribute type, as `semantic` names it. */
10
10
  export type DracoSemantic = "POSITION" | "NORMAL" | "COLOR" | "TEX_COORD" | "GENERIC";
@@ -14,62 +14,58 @@ export type DracoSemantic = "POSITION" | "NORMAL" | "COLOR" | "TEX_COORD" | "GEN
14
14
  * attribute of that type. `name` is handed back unchanged.
15
15
  */
16
16
  export interface DracoAttributeRequest {
17
- name?: string;
18
- id?: number;
19
- semantic?: DracoSemantic;
20
- type?: DracoArrayType;
17
+ name?: string;
18
+ id?: number;
19
+ semantic?: DracoSemantic;
20
+ type?: DracoArrayType;
21
21
  }
22
22
 
23
23
  /** The typed arrays an attribute can come back in. */
24
24
  export type DracoArray =
25
- | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
26
- | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
25
+ | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
26
+ | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
27
27
 
28
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;
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
36
  }
37
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[];
38
+ export interface DracoDecodeOptions {
39
+ /**
40
+ * The index's array: `"Uint32Array"`, the default, or `"auto"`, which uses a
41
+ * `Uint16Array` when every point number fits, at most 65536 points, and
42
+ * halves what a worker sends back.
43
+ */
44
+ index?: "Uint32Array" | "auto";
46
45
  }
47
46
 
48
-
47
+ export interface DracoDecodeResult {
48
+ success: boolean;
49
+ error?: string;
50
+ warnings: string[];
51
+ geometry?: "mesh" | "point_cloud";
52
+ /** Triangle corners for a mesh, `null` for a point cloud. */
53
+ index: Uint32Array | Uint16Array | null;
54
+ attributes: DracoAttribute[];
55
+ }
49
56
 
50
57
  /**
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 }`.
58
+ * Decodes a Draco stream and returns its attributes as typed arrays: every
59
+ * attribute in its own type, or the ones `attributes` requests, converted as
60
+ * upstream's `GetAttributeDataArrayForAllPoints` converts them.
71
61
  */
72
- export function decode_draco(data: Uint8Array, attributes: DracoAttributeRequest[] | undefined): DracoDecodeResult;
62
+ export function decode_draco(
63
+ data: Uint8Array,
64
+ attributes?: DracoAttributeRequest[],
65
+ options?: DracoDecodeOptions,
66
+ ): DracoDecodeResult;
67
+
68
+
73
69
 
74
70
  /**
75
71
  * Install the panic hook, so a panic reads as a message rather than a trap.
@@ -94,38 +90,38 @@ export function version(): string;
94
90
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
95
91
 
96
92
  export interface InitOutput {
97
- readonly memory: WebAssembly.Memory;
98
- readonly decode_draco: (a: number, b: number, c: number) => number;
99
- readonly init: () => void;
100
- readonly parse_drc_bytes: (a: number, b: number) => number;
101
- readonly supported_extensions: (a: number) => void;
102
- readonly version: (a: number) => void;
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;
106
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
107
- readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
108
- readonly __wbindgen_start: () => void;
93
+ readonly memory: WebAssembly.Memory;
94
+ readonly decode_draco: (a: number, b: number, c: number, d: number) => number;
95
+ readonly parse_drc_bytes: (a: number, b: number) => number;
96
+ readonly supported_extensions: (a: number) => void;
97
+ readonly version: (a: number) => void;
98
+ readonly init: () => void;
99
+ readonly __wbindgen_export: (a: number, b: number) => number;
100
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
101
+ readonly __wbindgen_export3: (a: number) => void;
102
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
103
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
104
+ readonly __wbindgen_start: () => void;
109
105
  }
110
106
 
111
107
  export type SyncInitInput = BufferSource | WebAssembly.Module;
112
108
 
113
109
  /**
114
- * Instantiates the given `module`, which can either be bytes or
115
- * a precompiled `WebAssembly.Module`.
116
- *
117
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
118
- *
119
- * @returns {InitOutput}
120
- */
110
+ * Instantiates the given `module`, which can either be bytes or
111
+ * a precompiled `WebAssembly.Module`.
112
+ *
113
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
114
+ *
115
+ * @returns {InitOutput}
116
+ */
121
117
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
122
118
 
123
119
  /**
124
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
125
- * for everything else, calls `WebAssembly.instantiate` directly.
126
- *
127
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
128
- *
129
- * @returns {Promise<InitOutput>}
130
- */
120
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
121
+ * for everything else, calls `WebAssembly.instantiate` directly.
122
+ *
123
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
124
+ *
125
+ * @returns {Promise<InitOutput>}
126
+ */
131
127
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;