@miris-inc/core 0.0.8-a97ec5e → 0.0.8-a997939

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/package.json CHANGED
@@ -1,41 +1,35 @@
1
1
  {
2
2
  "name": "@miris-inc/core",
3
- "version": "0.0.8-a97ec5e",
3
+ "version": "0.0.8-a997939",
4
4
  "description": "Core scene-graph runtime for the Miris 3D streaming SDK. WASM-backed Engine, Client, Scene, Stream, and LOD primitives shared by all higher-level packages.",
5
- "license": "Apache-2.0",
6
- "homepage": "https://miris.com",
7
- "author": "Miris, Inc.",
8
- "engines": {
9
- "node": ">=18"
10
- },
11
- "publishConfig": {
12
- "access": "public"
13
- },
14
5
  "keywords": [
15
- "miris",
16
6
  "3d",
17
- "gaussian-splatting",
18
7
  "3dgs",
19
8
  "4dgs",
9
+ "gaussian-splatting",
10
+ "miris",
20
11
  "splats",
21
12
  "streaming",
22
13
  "wasm"
23
14
  ],
24
- "type": "module",
25
- "sideEffects": false,
15
+ "homepage": "https://miris.com",
16
+ "license": "Apache-2.0",
17
+ "author": "Miris, Inc.",
26
18
  "files": [
27
19
  "banner.svg",
20
+ "webshark.d.ts",
21
+ "webshark.js",
22
+ "webshark.wasm",
28
23
  "dist/*.js",
29
24
  "dist/*.d.ts",
30
25
  "dist/*.wasm",
31
- "!dist/*.map",
32
- "webshark.js",
33
- "webshark.wasm",
34
- "webshark.d.ts"
26
+ "!dist/**/*.map"
35
27
  ],
36
- "types": "./dist/core.d.ts",
28
+ "type": "module",
29
+ "sideEffects": false,
37
30
  "main": "./dist/core.prod.js",
38
31
  "module": "./dist/core.prod.js",
32
+ "types": "./dist/core.d.ts",
39
33
  "unpkg": "./dist/core.standalone.prod.js",
40
34
  "jsdelivr": "./dist/core.standalone.prod.js",
41
35
  "exports": {
@@ -46,21 +40,27 @@
46
40
  "import": "./dist/core.prod.js",
47
41
  "default": "./dist/core.prod.js"
48
42
  },
43
+ "./webshark": {
44
+ "types": "./webshark.d.ts",
45
+ "default": "./webshark.js"
46
+ },
49
47
  "./standalone": {
50
48
  "types": "./dist/core.d.ts",
51
49
  "development": "./dist/core.standalone.js",
52
50
  "import": "./dist/core.standalone.prod.js",
53
51
  "default": "./dist/core.standalone.prod.js"
54
- },
55
- "./webshark": {
56
- "types": "./webshark.d.ts",
57
- "default": "./webshark.js"
58
52
  }
59
53
  },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
60
57
  "scripts": {
61
58
  "d": "bun dev",
62
59
  "dev": "vite",
63
60
  "b": "cd ../.. && vite build --mode packages/core",
64
61
  "build": "cd ../.. && vite build --mode packages/core"
62
+ },
63
+ "engines": {
64
+ "node": ">=18"
65
65
  }
66
66
  }
package/webshark.d.ts CHANGED
@@ -7,36 +7,6 @@ export interface Camera {
7
7
  fov: number;
8
8
  }
9
9
 
10
- export interface Ellipsoid {
11
- pos: vec4;
12
- radii: vec4;
13
- orientation: vec4;
14
- }
15
-
16
- export interface SphericalHarmonic {
17
- col: vec4;
18
- sh_0_1: vec4;
19
- sh_0_2: vec4;
20
- sh_0_3: vec4;
21
- }
22
-
23
- export interface AABB {
24
- minExt: vec4;
25
- maxExt: vec4;
26
- }
27
-
28
- export interface EmVector<T> {
29
- push_back(value: T): void;
30
- resize(count: number, value: T): void;
31
- size(): number;
32
- get(index: number): T | undefined;
33
- set(index: number, value: T): boolean;
34
- delete(): void;
35
- }
36
-
37
- export type EllipsoidVector = EmVector<Ellipsoid>;
38
- export type SphericalHarmonicVector = EmVector<SphericalHarmonic>;
39
-
40
10
  export interface SortTypeValue {
41
11
  value: number;
42
12
  }
@@ -45,34 +15,21 @@ export interface TextureFormatValue {
45
15
  value: number;
46
16
  }
47
17
 
48
- export interface SharkComputeInfo {
49
- dispatchCalls: number;
50
- frameDispatchCalls: number;
51
- }
52
-
53
18
  export interface SharkRenderInfo {
54
- totalRenderCalls: number;
55
- frameRenderCalls: number;
56
19
  triangles: number;
57
- splats: number;
58
20
  }
59
21
 
60
22
  export interface SharkInfo {
61
23
  renderCalls: number;
62
- compute: SharkComputeInfo;
63
24
  render: SharkRenderInfo;
64
25
  reset(): void;
65
26
  }
66
27
 
67
28
  export interface RendererWGPU {
68
- configureSurface(width: number, height: number): boolean;
69
29
  getProgramCount(): number;
70
30
  getTextureCount(): number;
71
31
  getEstimatedTextureSize(): number;
72
- getBufferCount(): number;
73
32
  getTotalBufferSize(): number;
74
- getBufferTypeSize(type: number): number;
75
- surfaceFormat: TextureFormatValue;
76
33
  info: SharkInfo;
77
34
  }
78
35
 
@@ -91,16 +48,31 @@ export interface RenderState {
91
48
  initGraphicsState(
92
49
  width: number,
93
50
  height: number,
94
- renderTextureFormat: TextureFormat,
51
+ renderTextureFormat: TextureFormatValue,
52
+ depthTextureFormat: TextureFormatValue,
95
53
  ): void;
96
54
  updateRenderDetails(
97
55
  width: number,
98
56
  height: number,
99
57
  splatTriangles: number,
100
58
  ): void;
101
- uploadEllipsoids(ellipsoids: EllipsoidVector): void;
102
- uploadSphericalHarmonics(sh: SphericalHarmonicVector): void;
103
- uploadSphericalHarmonicsSOGs(sh: SphericalHarmonicVector): void;
59
+ // Decodes Radiance .hdr bytes into roughness-ladder level `level` (0 is the sharp mirror).
60
+ // hdrPtr must address THIS module's heap - _malloc here and copy the bytes in.
61
+ // Returns false for bytes that are not a usable Radiance image, or a level out of range.
62
+ uploadEnvironmentLadderLevelFromHdr(
63
+ level: number,
64
+ sigmaDeg: number,
65
+ hdrPtr: number,
66
+ hdrSizeBytes: number,
67
+ ): boolean;
68
+ // Republish the ladder's shape. Call after any level lands, or it is sampled at whatever shape
69
+ // the last uploadSplatSetData declared. Pass SplatSet.hasReflectionParams().
70
+ uploadReflectionLadderParams(reflectionsEnabled: boolean): void;
71
+ // Debug controls. Drop the reflection term, or replace the surfel colour with one of the layers
72
+ // it is shaded from, numbered as RenderViewModes.h's AOV_* defines. setRenderView below sets
73
+ // the AOV together with the rest of a named view.
74
+ setReflectionsEnabled(enabled: boolean): void;
75
+ setDebugAovMode(mode: number): void;
104
76
  }
105
77
 
106
78
  export interface vec4 {
@@ -116,20 +88,22 @@ export interface SplatSet {
116
88
  // Number of splats actually drawn: ordering[0, activeSplats) holds the unmasked splat indices.
117
89
  // Set alongside orderingView() to restrict the draw to unmasked octant ranges.
118
90
  activeSplats: number;
119
- setData(
120
- splatCount: number,
121
- ellipsoids: number,
122
- sphericalHarmonics: number,
123
- ): void;
91
+ // Selects which ellipsoid layout to allocate and what ellipsoidsView() exposes:
92
+ // packed (16 bytes/splat) or uncompressed (48). Must be set before the first resize.
93
+ usePackedEllipsoids: boolean;
124
94
  // direct-write upload: resize -> write into the views -> finalize.
125
95
  // views are valid only until the next resize.
126
96
  resize(splatCount: number): void;
127
97
  ellipsoidsView(): Uint32Array;
128
- sphericalHarmonicsView(): Uint32Array;
98
+ colorsView(): Uint32Array;
129
99
  sh1View(): Uint32Array;
130
100
  sh2View(): Uint32Array;
131
101
  sh3aView(): Uint32Array;
132
102
  sh3bView(): Uint32Array;
103
+ // mod_depth is a half-float per primitive slot (dense, padded for non-surfels), so this is a
104
+ // Uint16Array unlike every other view here -- do not address it with the uint32 splat strides
105
+ // used for ellipsoids/colors/sh*.
106
+ modDepthView(): Uint16Array;
133
107
  // Per-chunk fade (opacity multiplier), one float per chunk, defaults to 1.0.
134
108
  // Also sizes the chunk slot to model root slot map below, since both are indexed by chunk slot
135
109
  resizeChunkFades(chunkCount: number): void;
@@ -149,88 +123,93 @@ export interface SplatSet {
149
123
  modelRootInverseTransformsView(): Float32Array;
150
124
  // Sized by resizeChunkFades. Defaults to slot 0 (identity) for every chunk
151
125
  chunkModelRootsView(): Int32Array;
126
+ // resizeModelRootSlots resets every slot to the absolute decode. False for a slot outside the table
127
+ setModelRootRootRelativeDecode(
128
+ slot: number,
129
+ originX: number,
130
+ originY: number,
131
+ originZ: number,
132
+ step: number,
133
+ ): boolean;
152
134
  // int32 render-order buffer (sized 2*splatCount after finalize). Valid only until the next resize.
153
135
  orderingView(): Int32Array;
154
136
  finalize(): void;
155
137
  // like finalize() but keeps splats in their delivered (octant-sorted) order — no kd-tree reorder —
156
138
  // so sparse-octant range masking can index child-octant ranges directly. RADIX_SORT only.
157
139
  finalizeBounds(): void;
140
+ // Whether the asset carries per-surfel reflectance records, which is what decides whether
141
+ // reflections are shaded at all. Pass to RenderState.uploadReflectionLadderParams.
142
+ hasReflectionParams(): boolean;
143
+ // Widens packed 26-byte reflectanceDataV1 records into the per-splat GPU records at
144
+ // bufferOffset. wirePtr must address THIS module's heap - _malloc here and copy the bytes in,
145
+ // since the attribute lives in the engine module's. Records cover a node's surfel range, which
146
+ // starts at its first splat. Returns the records written; 0 if the data was rejected.
147
+ decodeReflectionParams(
148
+ wirePtr: number,
149
+ wireSizeBytes: number,
150
+ elementCount: number,
151
+ bufferOffset: number,
152
+ nodeSplatCount: number,
153
+ logId: number,
154
+ ): number;
155
+ // Zeroes records in [startSplat, endSplat). Needed wherever splats are re-packed at fresh
156
+ // offsets, or a reused slot shades its splat from the previous occupant's material.
157
+ clearReflectionParams(startSplat: number, endSplat: number): void;
158
+ // Splats in [0, count) holding a non-zero record. Diagnostic.
159
+ populatedReflectionParamCount(count: number): number;
158
160
  }
159
161
 
160
- export interface WebGPUInternals {
161
- jsObjects: unknown[];
162
- bufferOnUnmaps: Record<number, unknown>;
163
- futures: Promise<unknown>[];
164
- jsObjectInsert(ptr: number, obj: unknown): void;
165
- futureInsert(futureId: number, promise: Promise<unknown>): void;
162
+ export interface GlassMeshRegistry {
163
+ // Decodes one octree node's glass payload and registers it, replacing any previous entry for
164
+ // that object. False for a malformed or empty payload, leaving the registry unchanged.
165
+ //
166
+ // The two slot arguments are different numbers here, unlike on the native path, and swapping
167
+ // them renders glass that does not follow its asset: modelRootSlot scopes the panel dedupe to
168
+ // one asset instance, while chunkModelRootIndex is stamped into every vertex and read back as
169
+ // chunkModelRoots[pos.w], so that one takes the chunk's fade slot.
170
+ //
171
+ // geometryPtr/panelPtr address THIS module's heap - _malloc here and copy the bytes in, since
172
+ // the attributes live in the engine module's. The AABB is the geometry attribute's own range.
173
+ registerObject(
174
+ objectId: number,
175
+ lodIndex: number,
176
+ modelRootSlot: number,
177
+ chunkModelRootIndex: number,
178
+ geometryPtr: number,
179
+ geometryByteCount: number,
180
+ panelPtr: number,
181
+ panelByteCount: number,
182
+ aabbMinX: number,
183
+ aabbMinY: number,
184
+ aabbMinZ: number,
185
+ aabbMaxX: number,
186
+ aabbMaxY: number,
187
+ aabbMaxZ: number,
188
+ ): boolean;
189
+ // Returns true if the object had glass, which is what says the buffers need rebuilding.
190
+ removeObject(objectId: number): boolean;
191
+ clear(): void;
192
+ isDirty(): boolean;
193
+ // Rebuilds the flattened buffers, keeping each panel from its deepest resident LOD. Stays dirty
194
+ // so uploadIfDirty still fires. Walks every registered object, so not per frame.
195
+ flattenIfDirty(): void;
196
+ uploadIfDirty(renderState: RenderState): void;
197
+ vertexCount(): number;
198
+ panelCount(): number;
199
+ delete(): void;
166
200
  }
167
201
 
168
202
  export interface WebGPUInterface {
169
- Internals: WebGPUInternals;
170
-
171
203
  importJsAdapter(adapter: GPUAdapter, parentPtr?: number): number;
172
204
  importJsDevice(device: GPUDevice, parentPtr?: number): number;
173
- importJsBindGroup(obj: GPUBindGroup, parentPtr?: number): number;
174
- importJsBindGroupLayout(obj: GPUBindGroupLayout, parentPtr?: number): number;
175
- importJsBuffer(buffer: GPUBuffer, parentPtr?: number): number;
176
- importJsCommandBuffer(obj: GPUCommandBuffer, parentPtr?: number): number;
177
- importJsCommandEncoder(obj: GPUCommandEncoder, parentPtr?: number): number;
178
- importJsComputePassEncoder(
179
- obj: GPUComputePassEncoder,
180
- parentPtr?: number,
181
- ): number;
182
- importJsComputePipeline(obj: GPUComputePipeline, parentPtr?: number): number;
183
- importJsPipelineLayout(obj: GPUPipelineLayout, parentPtr?: number): number;
184
- importJsQuerySet(obj: GPUQuerySet, parentPtr?: number): number;
185
- importJsQueue(obj: GPUQueue, parentPtr?: number): number;
186
- importJsRenderBundle(obj: GPURenderBundle, parentPtr?: number): number;
187
- importJsRenderBundleEncoder(
188
- obj: GPURenderBundleEncoder,
189
- parentPtr?: number,
190
- ): number;
191
- importJsRenderPassEncoder(
192
- obj: GPURenderPassEncoder,
193
- parentPtr?: number,
194
- ): number;
195
- importJsRenderPipeline(obj: GPURenderPipeline, parentPtr?: number): number;
196
- importJsSampler(obj: GPUSampler, parentPtr?: number): number;
197
- importJsShaderModule(obj: GPUShaderModule, parentPtr?: number): number;
198
205
  importJsTexture(obj: GPUTexture, parentPtr?: number): number;
199
- importJsTextureView(obj: GPUTextureView, parentPtr?: number): number;
200
-
201
- getJsObject(ptr: number): unknown;
202
-
203
- makeStringFromStringView(stringViewPtr: number): string;
204
- makeStringFromOptionalStringView(
205
- stringViewPtr: number,
206
- ): string | undefined | "";
207
- setStringView(ptr: number, data: number, length: number): void;
208
- makeColor(ptr: number): { r: number; g: number; b: number; a: number };
209
- makeExtent3D(ptr: number): {
210
- width: number;
211
- height: number;
212
- depthOrArrayLayers: number;
213
- };
214
- makeOrigin3D(ptr: number): { x: number; y: number; z: number };
215
- fillLimitStruct(limits: GPUSupportedLimits, limitsOutPtr: number): void;
216
- fillAdapterInfoStruct(adapterInfo: GPUAdapterInfo, infoStruct: number): void;
217
- errorCallback(
218
- callback: number,
219
- type: number,
220
- message: string,
221
- userdata: number,
222
- ): void;
223
206
  }
224
207
 
225
208
  export interface MainModule {
226
209
  Camera: new () => Camera;
227
210
  RenderState: new () => RenderState;
228
211
  SplatSet: new () => SplatSet;
229
- AABB: new () => AABB;
230
- Ellipsoid: new () => Ellipsoid;
231
- SphericalHarmonic: new () => SphericalHarmonic;
232
- EllipsoidVector: new () => EllipsoidVector;
233
- SphericalHarmonicVector: new () => SphericalHarmonicVector;
212
+ GlassMeshRegistry: new () => GlassMeshRegistry;
234
213
  vec4: new (x: number, y: number, z: number, w: number) => vec4;
235
214
 
236
215
  SortType: {
@@ -243,6 +222,7 @@ export interface MainModule {
243
222
  TextureFormat: {
244
223
  RGBA32_Float: TextureFormatValue;
245
224
  RGBA16_Float: TextureFormatValue;
225
+ RG16_Float: TextureFormatValue;
246
226
  RGBA32_UInt: TextureFormatValue;
247
227
  RGBA32_SInt: TextureFormatValue;
248
228
  RGBA16_UInt: TextureFormatValue;
@@ -260,38 +240,19 @@ export interface MainModule {
260
240
  BC7RGBA_UNormSrgb: TextureFormatValue;
261
241
  BC3RGBA_UNorm: TextureFormatValue;
262
242
  BC3RGBA_UNormSrgb: TextureFormatValue;
243
+ Depth16Unorm: TextureFormatValue;
244
+ Depth24Plus: TextureFormatValue;
245
+ Depth32Float: TextureFormatValue;
263
246
  };
264
247
 
265
- Usage_CopySrc: number;
266
- Usage_CopyDest: number;
267
- Usage_MapRead: number;
268
- Usage_MapWrite: number;
269
- Usage_Uniform: number;
270
- Usage_Storage: number;
271
- Usage_Index: number;
272
- Usage_Vertex: number;
273
- Usage_QueryResolve: number;
274
-
275
248
  WebGPU: WebGPUInterface;
276
249
 
277
- _malloc(bytes: number): number;
250
+ // Emscripten runtime, exported by modules/shark/CMakeLists.txt. The pointer-taking bindings
251
+ // above address THIS heap, so bytes from the engine module have to be staged through it.
252
+ // HEAPU8 is replaced whenever the heap grows, so read it fresh rather than caching it.
253
+ _malloc(byteCount: number): number;
278
254
  _free(ptr: number): void;
279
- HEAPU32: Uint32Array;
280
-
281
- setupCamera(
282
- minExt: vec4,
283
- maxExt: vec4,
284
- axis: number,
285
- direction: number,
286
- width: number,
287
- height: number,
288
- camera: Camera,
289
- ): void;
290
-
291
- createRendererWGPU(canvasSelector: string): RendererWGPU;
292
- createRendererWGPUWithoutSurface(
293
- colorTargetFormat: TextureFormatValue,
294
- ): RendererWGPU;
255
+ readonly HEAPU8: Uint8Array;
295
256
 
296
257
  uploadSplatSetData(
297
258
  set: SplatSet,
@@ -316,33 +277,27 @@ export interface MainModule {
316
277
  rasterizeWithCompute: boolean,
317
278
  useSOGS: boolean,
318
279
  sortType: SortTypeValue,
280
+ skipSort: boolean,
319
281
  ): number;
320
- renderSplatSet(
321
- splats: number,
322
- set: SplatSet,
323
- renderState: RenderState,
324
- width: number,
325
- height: number,
326
- triangles: number,
327
- rasterizeWithCompute: boolean,
328
- textureView: number,
329
- ): void;
282
+ createRendererWGPUWithoutSurface(
283
+ colorTargetFormat: TextureFormatValue,
284
+ ): RendererWGPU;
330
285
  renderSplatSetToSceneTextures(
331
286
  splatSet: SplatSet,
332
287
  renderState: RenderState,
333
288
  colorTarget: number,
334
289
  depthTarget: number,
290
+ renderGES: boolean,
335
291
  ): void;
336
- mapToAABB(scale: number, minExt: vec4, maxExt: vec4, set: SplatSet): void;
337
- loadPLYIntoSplatSet(filename: string, set: SplatSet): number;
338
- getBoundsSplatSet(set: SplatSet, minExt: vec4, maxExt: vec4): void;
339
- loadPLY(
340
- filename: string,
341
- count: number,
342
- maxSplats: number,
343
- ellipsoids: EllipsoidVector,
344
- sphericalHarmonics: SphericalHarmonicVector,
345
- ): number;
292
+ // Render view registry, indexed as RenderViews.h orders it. setRenderView ignores an index
293
+ // Shark cannot produce.
294
+ setRenderView(viewIndex: number): void;
295
+ renderView(): number;
296
+ renderViewCount(): number;
297
+ renderViewName(viewIndex: number): string;
298
+ renderViewSupported(viewIndex: number): boolean;
299
+ // The next supported view, forwards for direction 1 and backwards for -1.
300
+ stepRenderView(from: number, direction: number): number;
346
301
  }
347
302
 
348
303
  declare function WebShark(