@niivue/niivue 1.0.0-rc.21 → 1.0.0-rc.23

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
@@ -87,10 +87,13 @@ Add a `<canvas>` to your page and attach NiiVue to it:
87
87
 
88
88
  ### Backend-specific distributions
89
89
 
90
- By default, `@niivue/niivue` includes both backends (WebGPU + WebGL2 fallback):
90
+ By default, `@niivue/niivue` includes both backends and renders with WebGL2. Opt in to WebGPU with the `backend` option; if WebGPU is unavailable or fails to initialize, it falls back to WebGL2:
91
91
 
92
92
  ```js
93
93
  import NiiVue from '@niivue/niivue'
94
+
95
+ const nv = new NiiVue() // WebGL2
96
+ const nvGpu = new NiiVue({ backend: 'webgpu' }) // WebGPU, WebGL2 fallback
94
97
  ```
95
98
 
96
99
  You can also import backend-only builds to reduce package size:
@@ -153,7 +153,7 @@ export type NVDocumentSlidePlane = {
153
153
  export type NVDocumentData = {
154
154
  version: number;
155
155
  created: string;
156
- scene: {
156
+ scene?: {
157
157
  azimuth?: number;
158
158
  elevation?: number;
159
159
  scaleMultiplier?: number;
@@ -164,19 +164,19 @@ export type NVDocumentData = {
164
164
  clipPlaneColor?: number[];
165
165
  isClipPlaneCutaway?: boolean;
166
166
  };
167
- layout: Partial<LayoutConfig>;
168
- ui: Partial<UIConfig>;
169
- volume: Partial<VolumeRenderConfig>;
170
- mesh: Partial<MeshRenderConfig>;
171
- draw: Partial<DrawConfig>;
172
- interaction: Partial<InteractionConfig>;
173
- clipPlanes: number[];
167
+ layout?: Partial<LayoutConfig>;
168
+ ui?: Partial<UIConfig>;
169
+ volume?: Partial<VolumeRenderConfig>;
170
+ mesh?: Partial<MeshRenderConfig>;
171
+ draw?: Partial<DrawConfig>;
172
+ interaction?: Partial<InteractionConfig>;
173
+ clipPlanes?: number[];
174
174
  /** RLE-compressed drawing bitmap (if a drawing was active) */
175
175
  drawingBitmapRLE?: Uint8Array;
176
176
  /** Uncompressed length of drawing bitmap */
177
177
  drawingBitmapLength?: number;
178
- volumes: NVDocumentVolume[];
179
- meshes: NVDocumentMesh[];
178
+ volumes?: NVDocumentVolume[];
179
+ meshes?: NVDocumentMesh[];
180
180
  signals?: SerializedSignal[];
181
181
  annotations?: VectorAnnotation[];
182
182
  annotationConfig?: Partial<AnnotationConfig>;
package/dist/NVTypes.d.ts CHANGED
@@ -1024,6 +1024,7 @@ export type GraphConfig = {
1024
1024
  export type NiiVueOptions = {
1025
1025
  instances?: NVInstance[];
1026
1026
  globalCamera?: NVGlobalCamera;
1027
+ /** Rendering backend. Defaults to 'webgl2' ('webgpu' in the WebGPU-only build). */
1027
1028
  backend?: BackendType;
1028
1029
  isAntiAlias?: boolean;
1029
1030
  devicePixelRatio?: number;
@@ -1,6 +1,11 @@
1
- /** Serialize an NVD document object to a JSON string, tagging typed arrays. */
1
+ /** Serialize an NVD document object to a JSON string, tagging typed arrays
2
+ * and non-finite numbers. Throws on a typed-array kind the decoder cannot
3
+ * rebuild (BigInt64Array, ...) rather than emitting a tag it would not
4
+ * recognise. */
2
5
  export declare function encodeDocumentJSON(doc: unknown): string;
3
- /** Parse a JSON NVD document string, reconstructing tagged typed arrays. */
6
+ /** Parse a JSON NVD document string, reconstructing tagged typed arrays and
7
+ * non-finite numbers. A bare `null` (what an older encoder wrote for a
8
+ * non-finite number) is left as `null`. */
4
9
  export declare function decodeDocumentJSON(text: string): unknown;
5
10
  /** True when the bytes are a JSON document (first non-whitespace byte is `{`).
6
11
  * CBOR NVDs start with a map marker (>= 0xa0), never `{` (0x7b), so this cleanly