@miris-inc/core 0.0.8-e6a94a6 → 0.0.8-e7873f9
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/dist/AquaApi.wasm +0 -0
- package/dist/aqua-parser.wasm +0 -0
- package/dist/core.d.ts +112 -13
- package/dist/core.js +426 -76
- package/dist/core.prod.js +1 -1
- package/dist/core.standalone.js +884 -534
- package/dist/core.standalone.prod.js +1 -1
- package/package.json +8 -1
- package/webshark.d.ts +318 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miris-inc/core",
|
|
3
|
-
"version": "0.0.8-
|
|
3
|
+
"version": "0.0.8-e7873f9",
|
|
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
5
|
"keywords": [
|
|
6
6
|
"3d",
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"author": "Miris, Inc.",
|
|
18
18
|
"files": [
|
|
19
19
|
"banner.svg",
|
|
20
|
+
"webshark.d.ts",
|
|
21
|
+
"webshark.js",
|
|
22
|
+
"webshark.wasm",
|
|
20
23
|
"dist/*.js",
|
|
21
24
|
"dist/*.d.ts",
|
|
22
25
|
"dist/*.wasm",
|
|
@@ -37,6 +40,10 @@
|
|
|
37
40
|
"import": "./dist/core.prod.js",
|
|
38
41
|
"default": "./dist/core.prod.js"
|
|
39
42
|
},
|
|
43
|
+
"./webshark": {
|
|
44
|
+
"types": "./webshark.d.ts",
|
|
45
|
+
"default": "./webshark.js"
|
|
46
|
+
},
|
|
40
47
|
"./standalone": {
|
|
41
48
|
"types": "./dist/core.d.ts",
|
|
42
49
|
"development": "./dist/core.standalone.js",
|
package/webshark.d.ts
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
export interface Camera {
|
|
2
|
+
dir: vec4;
|
|
3
|
+
U: vec4;
|
|
4
|
+
V: vec4;
|
|
5
|
+
eye: vec4;
|
|
6
|
+
l: number;
|
|
7
|
+
fov: number;
|
|
8
|
+
zNear: number;
|
|
9
|
+
zFar: number;
|
|
10
|
+
delete(): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SortTypeValue {
|
|
14
|
+
value: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TextureFormatValue {
|
|
18
|
+
value: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SharkRenderInfo {
|
|
22
|
+
triangles: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SharkInfo {
|
|
26
|
+
renderCalls: number;
|
|
27
|
+
render: SharkRenderInfo;
|
|
28
|
+
reset(): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RendererWGPU {
|
|
32
|
+
getProgramCount(): number;
|
|
33
|
+
getTextureCount(): number;
|
|
34
|
+
getEstimatedTextureSize(): number;
|
|
35
|
+
getTotalBufferSize(): number;
|
|
36
|
+
info: SharkInfo;
|
|
37
|
+
delete(): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface RenderState {
|
|
41
|
+
delete(): void;
|
|
42
|
+
initRenderState(
|
|
43
|
+
renderer: RendererWGPU,
|
|
44
|
+
width: number,
|
|
45
|
+
height: number,
|
|
46
|
+
vertices: number,
|
|
47
|
+
splats: number,
|
|
48
|
+
cubes: number,
|
|
49
|
+
sortThreads: number,
|
|
50
|
+
sortGroupSize: number,
|
|
51
|
+
sortKeySize: number,
|
|
52
|
+
): void;
|
|
53
|
+
initGraphicsState(
|
|
54
|
+
width: number,
|
|
55
|
+
height: number,
|
|
56
|
+
renderTextureFormat: TextureFormatValue,
|
|
57
|
+
depthTextureFormat: TextureFormatValue,
|
|
58
|
+
): void;
|
|
59
|
+
updateRenderDetails(
|
|
60
|
+
width: number,
|
|
61
|
+
height: number,
|
|
62
|
+
splatTriangles: number,
|
|
63
|
+
): void;
|
|
64
|
+
// Decodes Radiance .hdr bytes into roughness-ladder level `level` (0 is the sharp mirror).
|
|
65
|
+
// hdrPtr must address THIS module's heap - _malloc here and copy the bytes in.
|
|
66
|
+
// Returns false for bytes that are not a usable Radiance image, or a level out of range.
|
|
67
|
+
uploadEnvironmentLadderLevelFromHdr(
|
|
68
|
+
level: number,
|
|
69
|
+
sigmaDeg: number,
|
|
70
|
+
hdrPtr: number,
|
|
71
|
+
hdrSizeBytes: number,
|
|
72
|
+
): boolean;
|
|
73
|
+
// Republish the ladder's shape. Call after any level lands, or it is sampled at whatever shape
|
|
74
|
+
// the last uploadSplatSetData declared. Pass SplatSet.hasReflectionParams().
|
|
75
|
+
uploadReflectionLadderParams(reflectionsEnabled: boolean): void;
|
|
76
|
+
// Debug controls. Drop the reflection term, or replace the surfel colour with one of the layers
|
|
77
|
+
// it is shaded from, numbered as RenderViewModes.h's AOV_* defines. setRenderView below sets
|
|
78
|
+
// the AOV together with the rest of a named view.
|
|
79
|
+
setReflectionsEnabled(enabled: boolean): void;
|
|
80
|
+
// Render textured gaussians on pixels no surfel covers, resolved as fvdb's open gate does.
|
|
81
|
+
// Off by default: those pixels show the clear colour.
|
|
82
|
+
setSurfelLessTextureSplatsEnabled(enabled: boolean): void;
|
|
83
|
+
setDebugAovMode(mode: number): void;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface vec4 {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
z: number;
|
|
90
|
+
w: number;
|
|
91
|
+
delete(): void;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface SplatSet {
|
|
95
|
+
splatCount: number;
|
|
96
|
+
// Number of splats actually drawn: ordering[0, activeSplats) holds the unmasked splat indices.
|
|
97
|
+
// Set alongside orderingView() to restrict the draw to unmasked octant ranges.
|
|
98
|
+
activeSplats: number;
|
|
99
|
+
// Selects which ellipsoid layout to allocate and what ellipsoidsView() exposes:
|
|
100
|
+
// packed (16 bytes/splat) or uncompressed (48). Must be set before the first resize.
|
|
101
|
+
usePackedEllipsoids: boolean;
|
|
102
|
+
// direct-write upload: resize -> write into the views -> finalize.
|
|
103
|
+
// views are valid only until the next resize.
|
|
104
|
+
resize(splatCount: number): void;
|
|
105
|
+
ellipsoidsView(): Uint32Array;
|
|
106
|
+
colorsView(): Uint32Array;
|
|
107
|
+
sh1View(): Uint32Array;
|
|
108
|
+
sh2View(): Uint32Array;
|
|
109
|
+
sh3aView(): Uint32Array;
|
|
110
|
+
sh3bView(): Uint32Array;
|
|
111
|
+
// mod_depth is a half-float per primitive slot (dense, padded for non-surfels), so this is a
|
|
112
|
+
// Uint16Array unlike every other view here -- do not address it with the uint32 splat strides
|
|
113
|
+
// used for ellipsoids/colors/sh*.
|
|
114
|
+
modDepthView(): Uint16Array;
|
|
115
|
+
// Per-chunk fade (opacity multiplier), one float per chunk, defaults to 1.0.
|
|
116
|
+
// Also sizes the chunk slot to model root slot map below, since both are indexed by chunk slot
|
|
117
|
+
resizeChunkFades(chunkCount: number): void;
|
|
118
|
+
chunkFadesView(): Float32Array;
|
|
119
|
+
// Per-splat chunk index, defaults to slot 0. Write before finalize()
|
|
120
|
+
chunkIndicesView(): Int32Array;
|
|
121
|
+
// Model transforms, resolved per splat as
|
|
122
|
+
// modelRootTransforms[chunkModelRoots[chunkIndices[splat]]]
|
|
123
|
+
// Slot 0 of both tables is reserved as identity, so real slots start at 1 and a set that
|
|
124
|
+
// never writes them renders untransformed.
|
|
125
|
+
resizeModelRootSlots(modelRootCount: number): void;
|
|
126
|
+
// 16 floats per model root, COLUMN-major - i.e. write THREE's Matrix4.toArray() straight in
|
|
127
|
+
modelRootTransformsView(): Float32Array;
|
|
128
|
+
// The inverses, same slots and layout. The true-perspective projection (Project.glsl) transforms
|
|
129
|
+
// a quadratic form and needs them; writing a transform without its inverse leaves that path
|
|
130
|
+
// projecting the splat as if untransformed. Use Matrix4.invert() on a copy
|
|
131
|
+
modelRootInverseTransformsView(): Float32Array;
|
|
132
|
+
// Sized by resizeChunkFades. Defaults to slot 0 (identity) for every chunk
|
|
133
|
+
chunkModelRootsView(): Int32Array;
|
|
134
|
+
// resizeModelRootSlots resets every slot to the absolute decode. False for a slot outside the table
|
|
135
|
+
setModelRootRootRelativeDecode(
|
|
136
|
+
slot: number,
|
|
137
|
+
originX: number,
|
|
138
|
+
originY: number,
|
|
139
|
+
originZ: number,
|
|
140
|
+
step: number,
|
|
141
|
+
): boolean;
|
|
142
|
+
// int32 render-order buffer (sized 2*splatCount after finalize). Valid only until the next resize.
|
|
143
|
+
orderingView(): Int32Array;
|
|
144
|
+
finalize(): void;
|
|
145
|
+
// like finalize() but keeps splats in their delivered (octant-sorted) order — no kd-tree reorder —
|
|
146
|
+
// so sparse-octant range masking can index child-octant ranges directly. RADIX_SORT only.
|
|
147
|
+
finalizeBounds(): void;
|
|
148
|
+
// Whether the asset carries per-surfel reflectance records, which is what decides whether
|
|
149
|
+
// reflections are shaded at all. Pass to RenderState.uploadReflectionLadderParams.
|
|
150
|
+
hasReflectionParams(): boolean;
|
|
151
|
+
// Widens packed 26-byte reflectanceDataV1 records into the per-splat GPU records at
|
|
152
|
+
// bufferOffset. wirePtr must address THIS module's heap - _malloc here and copy the bytes in,
|
|
153
|
+
// since the attribute lives in the engine module's. Records cover a node's surfel range, which
|
|
154
|
+
// starts at its first splat. Returns the records written; 0 if the data was rejected.
|
|
155
|
+
decodeReflectionParams(
|
|
156
|
+
wirePtr: number,
|
|
157
|
+
wireSizeBytes: number,
|
|
158
|
+
elementCount: number,
|
|
159
|
+
bufferOffset: number,
|
|
160
|
+
nodeSplatCount: number,
|
|
161
|
+
logId: number,
|
|
162
|
+
): number;
|
|
163
|
+
// Zeroes records in [startSplat, endSplat). Needed wherever splats are re-packed at fresh
|
|
164
|
+
// offsets, or a reused slot shades its splat from the previous occupant's material.
|
|
165
|
+
clearReflectionParams(startSplat: number, endSplat: number): void;
|
|
166
|
+
// Splats in [0, count) holding a non-zero record. Diagnostic.
|
|
167
|
+
populatedReflectionParamCount(count: number): number;
|
|
168
|
+
delete(): void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface GlassMeshRegistry {
|
|
172
|
+
// Decodes one octree node's glass payload and registers it, replacing any previous entry for
|
|
173
|
+
// that object. False for a malformed or empty payload, leaving the registry unchanged.
|
|
174
|
+
//
|
|
175
|
+
// The two slot arguments are different numbers here, unlike on the native path, and swapping
|
|
176
|
+
// them renders glass that does not follow its asset: modelRootSlot scopes the panel dedupe to
|
|
177
|
+
// one asset instance, while chunkModelRootIndex is stamped into every vertex and read back as
|
|
178
|
+
// chunkModelRoots[pos.w], so that one takes the chunk's fade slot.
|
|
179
|
+
//
|
|
180
|
+
// geometryPtr/panelPtr address THIS module's heap - _malloc here and copy the bytes in, since
|
|
181
|
+
// the attributes live in the engine module's. The AABB is the geometry attribute's own range.
|
|
182
|
+
registerObject(
|
|
183
|
+
objectId: number,
|
|
184
|
+
lodIndex: number,
|
|
185
|
+
modelRootSlot: number,
|
|
186
|
+
chunkModelRootIndex: number,
|
|
187
|
+
geometryPtr: number,
|
|
188
|
+
geometryByteCount: number,
|
|
189
|
+
panelPtr: number,
|
|
190
|
+
panelByteCount: number,
|
|
191
|
+
aabbMinX: number,
|
|
192
|
+
aabbMinY: number,
|
|
193
|
+
aabbMinZ: number,
|
|
194
|
+
aabbMaxX: number,
|
|
195
|
+
aabbMaxY: number,
|
|
196
|
+
aabbMaxZ: number,
|
|
197
|
+
): boolean;
|
|
198
|
+
// Returns true if the object had glass, which is what says the buffers need rebuilding.
|
|
199
|
+
removeObject(objectId: number): boolean;
|
|
200
|
+
clear(): void;
|
|
201
|
+
isDirty(): boolean;
|
|
202
|
+
// Rebuilds the flattened buffers, keeping each panel from its deepest resident LOD. Stays dirty
|
|
203
|
+
// so uploadIfDirty still fires. Walks every registered object, so not per frame.
|
|
204
|
+
flattenIfDirty(): void;
|
|
205
|
+
uploadIfDirty(renderState: RenderState): void;
|
|
206
|
+
vertexCount(): number;
|
|
207
|
+
panelCount(): number;
|
|
208
|
+
delete(): void;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface WebGPUInterface {
|
|
212
|
+
importJsAdapter(adapter: GPUAdapter, parentPtr?: number): number;
|
|
213
|
+
importJsDevice(device: GPUDevice, parentPtr?: number): number;
|
|
214
|
+
importJsTexture(obj: GPUTexture, parentPtr?: number): number;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface MainModule {
|
|
218
|
+
Camera: new () => Camera;
|
|
219
|
+
RenderState: new () => RenderState;
|
|
220
|
+
SplatSet: new () => SplatSet;
|
|
221
|
+
GlassMeshRegistry: new () => GlassMeshRegistry;
|
|
222
|
+
vec4: new (x: number, y: number, z: number, w: number) => vec4;
|
|
223
|
+
|
|
224
|
+
SortType: {
|
|
225
|
+
RADIX_SORT: SortTypeValue;
|
|
226
|
+
OCTREE_SORT: SortTypeValue;
|
|
227
|
+
KDTREE_SORT: SortTypeValue;
|
|
228
|
+
STD_SORT: SortTypeValue;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
TextureFormat: {
|
|
232
|
+
RGBA32_Float: TextureFormatValue;
|
|
233
|
+
RGBA16_Float: TextureFormatValue;
|
|
234
|
+
RG16_Float: TextureFormatValue;
|
|
235
|
+
RGBA32_UInt: TextureFormatValue;
|
|
236
|
+
RGBA32_SInt: TextureFormatValue;
|
|
237
|
+
RGBA16_UInt: TextureFormatValue;
|
|
238
|
+
RGBA16_SInt: TextureFormatValue;
|
|
239
|
+
RGBA8_UInt: TextureFormatValue;
|
|
240
|
+
RGBA8_SInt: TextureFormatValue;
|
|
241
|
+
RGBA8_UNorm: TextureFormatValue;
|
|
242
|
+
RGBA8_SNorm: TextureFormatValue;
|
|
243
|
+
RGBA16_UNorm: TextureFormatValue;
|
|
244
|
+
RGBA16_SNorm: TextureFormatValue;
|
|
245
|
+
BGRA8_UNorm: TextureFormatValue;
|
|
246
|
+
BC6HRGB_UFloat: TextureFormatValue;
|
|
247
|
+
BC6HRGB_Float: TextureFormatValue;
|
|
248
|
+
BC7RGBA_UNorm: TextureFormatValue;
|
|
249
|
+
BC7RGBA_UNormSrgb: TextureFormatValue;
|
|
250
|
+
BC3RGBA_UNorm: TextureFormatValue;
|
|
251
|
+
BC3RGBA_UNormSrgb: TextureFormatValue;
|
|
252
|
+
Depth16Unorm: TextureFormatValue;
|
|
253
|
+
Depth24Plus: TextureFormatValue;
|
|
254
|
+
Depth32Float: TextureFormatValue;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
WebGPU: WebGPUInterface;
|
|
258
|
+
|
|
259
|
+
// Emscripten runtime, exported by modules/shark/CMakeLists.txt. The pointer-taking bindings
|
|
260
|
+
// above address THIS heap, so bytes from the engine module have to be staged through it.
|
|
261
|
+
// HEAPU8 is replaced whenever the heap grows, so read it fresh rather than caching it.
|
|
262
|
+
_malloc(byteCount: number): number;
|
|
263
|
+
_free(ptr: number): void;
|
|
264
|
+
readonly HEAPU8: Uint8Array;
|
|
265
|
+
|
|
266
|
+
uploadSplatSetData(
|
|
267
|
+
set: SplatSet,
|
|
268
|
+
renderState: RenderState,
|
|
269
|
+
start: number,
|
|
270
|
+
): void;
|
|
271
|
+
uploadChunkFades(set: SplatSet, renderState: RenderState): void;
|
|
272
|
+
// One mat4 per model root, so cheap enough to call every frame while an asset is moving
|
|
273
|
+
uploadModelRootTransforms(set: SplatSet, renderState: RenderState): void;
|
|
274
|
+
processSplatSet(
|
|
275
|
+
camera: Camera,
|
|
276
|
+
set: SplatSet,
|
|
277
|
+
renderState: RenderState,
|
|
278
|
+
width: number,
|
|
279
|
+
height: number,
|
|
280
|
+
triangles: number,
|
|
281
|
+
projectOnGPU: boolean,
|
|
282
|
+
cullEllipsoid: boolean,
|
|
283
|
+
useAffineApprox: boolean,
|
|
284
|
+
depthSortOnGPU: boolean,
|
|
285
|
+
useInvZ: boolean,
|
|
286
|
+
rasterizeWithCompute: boolean,
|
|
287
|
+
useSOGS: boolean,
|
|
288
|
+
sortType: SortTypeValue,
|
|
289
|
+
skipSort: boolean,
|
|
290
|
+
): number;
|
|
291
|
+
createRendererWGPUWithoutSurface(
|
|
292
|
+
colorTargetFormat: TextureFormatValue,
|
|
293
|
+
): RendererWGPU;
|
|
294
|
+
/// Gives back the reference WebGPU.importJsTexture returned for a texture.
|
|
295
|
+
releaseImportedTexture(texture: number): void;
|
|
296
|
+
renderSplatSetToSceneTextures(
|
|
297
|
+
splatSet: SplatSet,
|
|
298
|
+
renderState: RenderState,
|
|
299
|
+
colorTarget: number,
|
|
300
|
+
depthTarget: number,
|
|
301
|
+
renderGES: boolean,
|
|
302
|
+
): void;
|
|
303
|
+
// Render view registry, indexed as RenderViews.h orders it. setRenderView ignores an index
|
|
304
|
+
// Shark cannot produce.
|
|
305
|
+
setRenderView(viewIndex: number): void;
|
|
306
|
+
renderView(): number;
|
|
307
|
+
renderViewCount(): number;
|
|
308
|
+
renderViewName(viewIndex: number): string;
|
|
309
|
+
renderViewSupported(viewIndex: number): boolean;
|
|
310
|
+
// The next supported view, forwards for direction 1 and backwards for -1.
|
|
311
|
+
stepRenderView(from: number, direction: number): number;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
declare function WebShark(
|
|
315
|
+
moduleArg?: Record<string, unknown>,
|
|
316
|
+
): Promise<MainModule>;
|
|
317
|
+
|
|
318
|
+
export default WebShark;
|