@sanox/sangine-core 0.4.5 → 0.5.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.
- package/dist/gen-types.d.ts +146 -24
- package/dist/gen-types.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +124 -108
- package/dist/rendererService.d.ts +11 -7
- package/dist/rendererService.d.ts.map +1 -1
- package/dist/wasm/decode/{wasm_decode.bf116aa6.js → wasm_decode.b6df9f4e.js} +1 -1
- package/dist/wasm/decode/{wasm_decode_bg.bf116aa6.wasm → wasm_decode_bg.b6df9f4e.wasm} +0 -0
- package/dist/wasm/sangine/{sangine.ecedf539.js → sangine.9ff4232d.js} +91 -44
- package/dist/wasm/sangine/sangine.d.ts +20 -8
- package/dist/wasm/sangine/{sangine_bg.ecedf539.wasm → sangine_bg.9ff4232d.wasm} +0 -0
- package/dist/wasm/sangine/sangine_bg.wasm.d.ts +7 -3
- package/dist/wasm/sbo-decode/{wasm_sbo_decode.5c359661.js → wasm_sbo_decode.63ffe035.js} +39 -6
- package/dist/wasm/sbo-decode/wasm_sbo_decode_bg.63ffe035.wasm +0 -0
- package/dist/wasm-hashes/decode.d.ts +1 -1
- package/dist/wasm-hashes/sangine.d.ts +1 -1
- package/dist/wasm-hashes/sbo-decode.d.ts +2 -0
- package/dist/wasm-hashes/sbo-decode.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/wasm/basis-decode/snippets/basisu_c_sys-273c0aeb51b100af/wasm/basisu_transcoder.js +0 -2
- package/dist/wasm/basis-decode/snippets/basisu_c_sys-273c0aeb51b100af/wasm/basisu_transcoder.wasm +0 -0
- package/dist/wasm/basis-decode/wasm_basis_decode.a8b7eebd.js +0 -553
- package/dist/wasm/basis-decode/wasm_basis_decode.d.ts +0 -58
- package/dist/wasm/basis-decode/wasm_basis_decode_bg.a8b7eebd.wasm +0 -0
- package/dist/wasm/basis-decode/wasm_basis_decode_bg.wasm.d.ts +0 -16
- package/dist/wasm/sbo-decode/wasm_sbo_decode_bg.5c359661.wasm +0 -0
package/dist/gen-types.d.ts
CHANGED
|
@@ -3,6 +3,40 @@
|
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
4
|
* and run json-schema-to-typescript to regenerate this file.
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* This interface was referenced by `Schema`'s JSON-Schema
|
|
8
|
+
* via the `definition` "AnnotationKind".
|
|
9
|
+
*/
|
|
10
|
+
export type AnnotationKind = {
|
|
11
|
+
point: {
|
|
12
|
+
fill_color: AnnotationColor;
|
|
13
|
+
normal: Vec3;
|
|
14
|
+
position: Vec3;
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
sphere: {
|
|
18
|
+
normal: Vec3;
|
|
19
|
+
position: Vec3;
|
|
20
|
+
radius: number;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
polygon: PolygonData;
|
|
24
|
+
} | {
|
|
25
|
+
bezierCurve: BezierData;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @minItems 3
|
|
29
|
+
* @maxItems 3
|
|
30
|
+
*
|
|
31
|
+
* This interface was referenced by `Schema`'s JSON-Schema
|
|
32
|
+
* via the `definition` "Vec3".
|
|
33
|
+
*/
|
|
34
|
+
export type Vec3 = [number, number, number];
|
|
35
|
+
/**
|
|
36
|
+
* This interface was referenced by `Schema`'s JSON-Schema
|
|
37
|
+
* via the `definition` "AnnotationCreateKind".
|
|
38
|
+
*/
|
|
39
|
+
export type AnnotationCreateKind = "point" | "sphere" | "bezierCurve" | "polygon";
|
|
6
40
|
/**
|
|
7
41
|
* This interface was referenced by `Schema`'s JSON-Schema
|
|
8
42
|
* via the `definition` "DecodeTask".
|
|
@@ -69,39 +103,133 @@ export type SangineEvent = "ready" | {
|
|
|
69
103
|
measurementCreated: {
|
|
70
104
|
measurement: Measurement;
|
|
71
105
|
};
|
|
72
|
-
} | {
|
|
73
|
-
routeUnderConstructionUpdated: {
|
|
74
|
-
route: Route;
|
|
75
|
-
};
|
|
76
106
|
} | {
|
|
77
107
|
assetsDownloading: {
|
|
78
108
|
downloading: boolean;
|
|
79
109
|
};
|
|
80
|
-
} | "userInteractionStarted"
|
|
110
|
+
} | "userInteractionStarted" | {
|
|
111
|
+
annotationCreated: AnnotationCreated;
|
|
112
|
+
};
|
|
81
113
|
/**
|
|
82
114
|
* This interface was referenced by `Schema`'s JSON-Schema
|
|
83
115
|
* via the `definition` "UserAction".
|
|
84
116
|
*/
|
|
85
|
-
export type UserAction = "watching" | "
|
|
117
|
+
export type UserAction = ("watching" | "measuring" | "setModelOrientation") | {
|
|
118
|
+
creatingAnnotation: {
|
|
119
|
+
kind: AnnotationCreateKind;
|
|
120
|
+
uuid: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
86
123
|
export interface Schema {
|
|
87
124
|
[k: string]: unknown;
|
|
88
125
|
}
|
|
89
126
|
/**
|
|
90
127
|
* This interface was referenced by `Schema`'s JSON-Schema
|
|
91
|
-
* via the `definition` "
|
|
128
|
+
* via the `definition` "Annotation".
|
|
92
129
|
*/
|
|
93
|
-
export interface
|
|
94
|
-
|
|
95
|
-
|
|
130
|
+
export interface Annotation {
|
|
131
|
+
kind: AnnotationKind;
|
|
132
|
+
props: AnnotationProps;
|
|
96
133
|
}
|
|
97
134
|
/**
|
|
98
135
|
* This interface was referenced by `Schema`'s JSON-Schema
|
|
99
|
-
* via the `definition` "
|
|
136
|
+
* via the `definition` "AnnotationColor".
|
|
137
|
+
*/
|
|
138
|
+
export interface AnnotationColor {
|
|
139
|
+
/**
|
|
140
|
+
* @minItems 4
|
|
141
|
+
* @maxItems 4
|
|
142
|
+
*/
|
|
143
|
+
active: [number, number, number, number];
|
|
144
|
+
/**
|
|
145
|
+
* @minItems 4
|
|
146
|
+
* @maxItems 4
|
|
147
|
+
*/
|
|
148
|
+
default: [number, number, number, number];
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* This interface was referenced by `Schema`'s JSON-Schema
|
|
152
|
+
* via the `definition` "PolygonData".
|
|
153
|
+
*/
|
|
154
|
+
export interface PolygonData {
|
|
155
|
+
fillColor: AnnotationColor;
|
|
156
|
+
normals: Vec3[];
|
|
157
|
+
/**
|
|
158
|
+
* Width in meters.
|
|
159
|
+
*/
|
|
160
|
+
outlineWidth: number;
|
|
161
|
+
positions: Vec3[];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* This interface was referenced by `Schema`'s JSON-Schema
|
|
165
|
+
* via the `definition` "BezierData".
|
|
166
|
+
*/
|
|
167
|
+
export interface BezierData {
|
|
168
|
+
normals: Vec3[];
|
|
169
|
+
positions: Vec3[];
|
|
170
|
+
/**
|
|
171
|
+
* Width in meters
|
|
172
|
+
*/
|
|
173
|
+
width: number;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* This interface was referenced by `Schema`'s JSON-Schema
|
|
177
|
+
* via the `definition` "AnnotationProps".
|
|
178
|
+
*/
|
|
179
|
+
export interface AnnotationProps {
|
|
180
|
+
color: AnnotationColor;
|
|
181
|
+
/**
|
|
182
|
+
* Fade far distances for annotation. If none, doesn't fade far.
|
|
183
|
+
*/
|
|
184
|
+
fadeFar?: FadeDistances | null;
|
|
185
|
+
/**
|
|
186
|
+
* Fade near distances for annotation. If none, doesn't fade close-by.
|
|
187
|
+
*/
|
|
188
|
+
fadeNear?: FadeDistances | null;
|
|
189
|
+
highlight: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Offset from surface in meters.
|
|
192
|
+
*/
|
|
193
|
+
surfaceOffset: number;
|
|
194
|
+
/**
|
|
195
|
+
* Body for textbox. If this and title are none, no textbox is displayed.
|
|
196
|
+
*/
|
|
197
|
+
textBody?: string | null;
|
|
198
|
+
/**
|
|
199
|
+
* Title for textbox. If this and body are none, no textbox is displayed.
|
|
200
|
+
*/
|
|
201
|
+
title?: string | null;
|
|
202
|
+
visible: boolean;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* This interface was referenced by `Schema`'s JSON-Schema
|
|
206
|
+
* via the `definition` "FadeDistances".
|
|
207
|
+
*/
|
|
208
|
+
export interface FadeDistances {
|
|
209
|
+
/**
|
|
210
|
+
* Fade ends at this distance in meters
|
|
211
|
+
*/
|
|
212
|
+
end: number;
|
|
213
|
+
/**
|
|
214
|
+
* Fade starts at this distance in meters
|
|
215
|
+
*/
|
|
216
|
+
start: number;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* This interface was referenced by `Schema`'s JSON-Schema
|
|
220
|
+
* via the `definition` "AnnotationCreated".
|
|
100
221
|
*/
|
|
101
|
-
export interface
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
222
|
+
export interface AnnotationCreated {
|
|
223
|
+
annotation: Annotation;
|
|
224
|
+
uuid: string;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* This interface was referenced by `Schema`'s JSON-Schema
|
|
228
|
+
* via the `definition` "CameraPos".
|
|
229
|
+
*/
|
|
230
|
+
export interface CameraPos {
|
|
231
|
+
position: Vec3;
|
|
232
|
+
target: Vec3;
|
|
105
233
|
}
|
|
106
234
|
/**
|
|
107
235
|
* This interface was referenced by `Schema`'s JSON-Schema
|
|
@@ -214,24 +342,18 @@ export interface SunProperties {
|
|
|
214
342
|
azimuthRad: number;
|
|
215
343
|
lightProperties: IntensityAndTemperature;
|
|
216
344
|
}
|
|
217
|
-
/**
|
|
218
|
-
* This interface was referenced by `Schema`'s JSON-Schema
|
|
219
|
-
* via the `definition` "Route".
|
|
220
|
-
*/
|
|
221
|
-
export interface Route {
|
|
222
|
-
id: string;
|
|
223
|
-
path: number[][];
|
|
224
|
-
}
|
|
225
345
|
/**
|
|
226
346
|
* This interface was referenced by `Schema`'s JSON-Schema
|
|
227
347
|
* via the `definition` "Scene".
|
|
228
348
|
*/
|
|
229
349
|
export interface Scene {
|
|
350
|
+
annotations?: {
|
|
351
|
+
[k: string]: Annotation;
|
|
352
|
+
} | null;
|
|
230
353
|
initialCameraPos?: number[] | null;
|
|
231
354
|
initialCameraTarget?: number[] | null;
|
|
232
355
|
modelCollections: ModelCollection[];
|
|
233
356
|
northOrientation?: number | null;
|
|
234
|
-
routes: Route[];
|
|
235
357
|
scale?: number | null;
|
|
236
358
|
}
|
|
237
359
|
//# sourceMappingURL=gen-types.d.ts.map
|
package/dist/gen-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gen-types.d.ts","sourceRoot":"","sources":["../src/gen-types.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB;IACE,cAAc,EAAE;QACd,QAAQ,EAAE,eAAe,CAAC;QAC1B;;;WAGG;QACH,MAAM,EAAE,MAAM,CAAC;QACf,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,EAAE,eAAe,CAAC;QAC7B,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,GACD;IACE,iBAAiB,EAAE;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC;AACN;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AACtD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC9D;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAChD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,aAAa,CAAC;AAC1F;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,CAAC;AACxC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AACvE;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACpB,OAAO,GACP;IACE,aAAa,EAAE;QACb,MAAM,EAAE,UAAU,CAAC;KACpB,CAAC;CACH,GACD;IACE,kBAAkB,EAAE;QAClB,WAAW,EAAE,WAAW,CAAC;KAC1B,CAAC;CACH,GACD;IACE,
|
|
1
|
+
{"version":3,"file":"gen-types.d.ts","sourceRoot":"","sources":["../src/gen-types.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IACE,KAAK,EAAE;QACL,UAAU,EAAE,eAAe,CAAC;QAC5B,MAAM,EAAE,IAAI,CAAC;QACb,QAAQ,EAAE,IAAI,CAAC;KAChB,CAAC;CACH,GACD;IACE,MAAM,EAAE;QACN,MAAM,EAAE,IAAI,CAAC;QACb,QAAQ,EAAE,IAAI,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,GACD;IACE,OAAO,EAAE,WAAW,CAAC;CACtB,GACD;IACE,WAAW,EAAE,UAAU,CAAC;CACzB,CAAC;AACN;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC5C;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAC;AAClF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB;IACE,cAAc,EAAE;QACd,QAAQ,EAAE,eAAe,CAAC;QAC1B;;;WAGG;QACH,MAAM,EAAE,MAAM,CAAC;QACf,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,EAAE,eAAe,CAAC;QAC7B,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,GACD;IACE,iBAAiB,EAAE;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC;AACN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M,WAAW,eAAe;IAC9B,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B;AACD;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,EAAE,EAAE,YAAY,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC/B;AACD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,uBAAuB,CAAC;IACzC,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,GAAG,EAAE,aAAa,CAAC;CACpB;AACD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,uBAAuB,CAAC;CAC1C;AACD;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,WAAW,CAAC,EAAE;QACZ,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;KACzB,GAAG,IAAI,CAAC;IACT,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACtC,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var g=(a,e,t)=>e in a?f(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var d=(a,e,t)=>g(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y="sangine-assets-v2";let l=null;async function m(a,e,t){if(typeof caches>"u"){const n=await fetch(t);if(!n.ok)throw new Error(`fetch ${t} failed: ${n.status}`);return n.arrayBuffer()}l??(l=caches.open(y));const i=await l,o=`https://sangine-asset-cache/${a}/${e}`,r=await i.match(o);if(r)return r.arrayBuffer();const s=await fetch(t);if(!s.ok)throw new Error(`fetch ${t} failed: ${s.status}`);return i.put(o,s.clone()).catch(()=>{}),s.arrayBuffer()}const u="/static/sangine/wasm",_="9ff4232d";class A{constructor(e,t){d(this,"workers");d(this,"idle");d(this,"queue",[]);this.workers=Array.from({length:t},e),this.idle=[...this.workers]}run(e,t){return new Promise((i,o)=>{const r=this.idle.pop();r?this.dispatch(r,e,t,i,o):this.queue.push({request:e,transfer:t,resolve:i,reject:o})})}dispatch(e,t,i,o,r){const s=h=>{o(h.data),c(),this.release(e)},n=h=>{r(h),c(),this.release(e)},c=()=>{e.removeEventListener("message",s),e.removeEventListener("error",n)};e.addEventListener("message",s,{once:!0}),e.addEventListener("error",n,{once:!0}),e.postMessage(t,i??[])}release(e){const t=this.queue.shift();t?this.dispatch(e,t.request,t.transfer,t.resolve,t.reject):this.idle.push(e)}broadcast(e){for(const t of this.workers)t.postMessage(e)}terminate(){for(const e of this.workers)e.terminate()}}class b{constructor(e){d(this,"wasm",null);d(this,"callbackRegistry",{});d(this,"userActionRegistry",{});d(this,"assetsDownloadingRegistry",{});d(this,"windowCreatedPromiseRegistry",{});d(this,"windowCreatedPromiseResolveRegistry",{});d(this,"_inited",!1);d(this,"decodePool");d(this,"_readyPromise");d(this,"_resolveReady");d(this,"_rejectReady");this.config=e,this._readyPromise=new Promise((t,i)=>{this._resolveReady=t,this._rejectReady=i}),this.config=e}async init(){if(!(typeof window>"u")){if(this._inited)return this._readyPromise;try{const t=await import(new URL(`${u}/sangine/sangine.${_}.js`,window.location.origin).toString());await t.default(),this.wasm=t,this._inited=!0;const i=Math.min(this.config.numWorkers??(navigator.hardwareConcurrency||2)-1,2);this.decodePool=new A(()=>this.config.createDecodeWorker(),Math.max(i,1)),this.wasm.register_asset_decoder(this.decodeAsset.bind(this)),this.wasm.register_event_listener(this.handleSangineEvent.bind(this)),this._resolveReady()}catch(e){throw this._rejectReady(e),e}return this._readyPromise}}ready(){return this._readyPromise}get inited(){return this._inited}getWasm(){if(!this.wasm)throw new Error("RendererService not initialized");return this.wasm}handleActionChanged(e,t){this.userActionRegistry[e]=t;for(const i of this.callbackRegistry[e].actionChanged)i(t)}handleMeasurementCreated(e,t){for(const i of this.callbackRegistry[e].measurementCreated)i(t)}handleAssetsDownloading(e,t){this.assetsDownloadingRegistry[e]=t;for(const i of this.callbackRegistry[e].assetsDownloading)i(t)}handleUserInteractionStarted(e){for(const t of this.callbackRegistry[e].userInteractionStarted)t()}handleAnnotationCreated(e,t){for(const i of this.callbackRegistry[e].annotationCreated)i(t)}handleSangineEvent(e,t){t==="ready"?this.windowCreatedPromiseResolveRegistry[e]():t==="userInteractionStarted"?this.handleUserInteractionStarted(e):"actionChanged"in t?this.handleActionChanged(e,t.actionChanged.action):"measurementCreated"in t?this.handleMeasurementCreated(e,t.measurementCreated.measurement):"assetsDownloading"in t?this.handleAssetsDownloading(e,t.assetsDownloading.downloading):"annotationCreated"in t&&this.handleAnnotationCreated(e,t.annotationCreated)}createWindow(e,t,i){if(!this.wasm)throw new Error("WASM not initialized");let o;const r=new Promise(n=>{o=n}),s=this.wasm.create_window(e,t,i);return this.windowCreatedPromiseResolveRegistry[s]=o,this.callbackRegistry[s]={actionChanged:[],measurementCreated:[],assetsDownloading:[],userInteractionStarted:[],annotationCreated:[]},this.userActionRegistry[s]="watching",this.windowCreatedPromiseRegistry[s]=r,s}getAssetsDownloading(e){return this.assetsDownloadingRegistry[e]||!1}readUserAction(e){return this.userActionRegistry[e]}windowReady(e){return this.windowCreatedPromiseRegistry[e]}registerCallback(e,t,i){this.callbackRegistry[e][t].push(i)}setWindowAction(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_window_action(e,t)}destroyWindow(e){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.destroy_window(e),delete this.callbackRegistry[e],delete this.userActionRegistry[e]}setAnnotationProps(e,t,i){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.annotation_set_props(e,t,i)}setAnnotationKind(e,t,i){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.annotation_set_kind(e,t,i)}addAnnotation(e,t,i){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.annotation_insert(e,t,i)}finishAnnotation(e){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.annotation_finish(e)}annotationRemoveLastPoint(e){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.annotation_remove_last_point(e)}removeAnnotation(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.annotation_remove(e,t)}animateToAnnotation(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.animate_to_annotation(e,t)}setSunProperties(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_sun_properties(e,t)}setAmbientLighting(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_ambient_lighting(e,t)}setLightingMode(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_lighting_mode(e,t)}setNorthCorrection(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_north_correction(e,t)}setGpuMemoryBudgetMb(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_gpu_memory_budget_mb(e,t)}setRenderQuality(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_render_quality(e,t)}readCameraPos(e){if(!this.wasm)throw new Error("WASM not initialized");return this.wasm.read_camera_pos(e)}animateTo(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.animate_to(e,t)}setScale(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_window_scale(e,t)}async decodeAsset(e){if(!this.decodePool)throw new Error("Renderer not initialized");if("texture-file"in e){const{pk:r,url:s,encoding:n,format:c}=e["texture-file"],h=await m("texture",r,s);return n==="ktx2"?this.decodePool.run({kind:"texture-basis",bytes:h,format:c},[h]):this.decodePool.run({kind:"texture-image",bytes:h},[h])}const{pk:t,url:i}=e["model-part-mesh"],o=await m("mesh",t,i);return this.decodePool.run({kind:"model-sbo",bytes:o},[o])}destroy(){var e;(e=this.decodePool)==null||e.terminate()}}const R="b6df9f4e",p=0;function M(a){let e=!1,t=null;async function i(){if(e)return;const r=await import(new URL(`${u}/decode/wasm_decode.${R}.js`,a.location.origin).href);await r.default(),await r.init_basis(),t=r,e=!0}a.onmessage=async o=>{const r=o.data;try{if(r.kind==="texture-basis"){await i();const s=new Uint8Array(r.bytes),n=t.transcode_basis(s,r.format);a.postMessage({success:!0,width:n.width,height:n.height,data:n.data.buffer,format:n.format},[n.data.buffer])}else if(r.kind==="texture-image"){const s=new Blob([r.bytes]),n=await createImageBitmap(s),c=new OffscreenCanvas(n.width,n.height),h=c.getContext("2d");if(h===null)throw new Error("Couldnt create canvas");h.drawImage(n,0,0);const w=h.getImageData(0,0,c.width,c.height);a.postMessage({success:!0,width:c.width,height:c.height,data:w.data.buffer,format:p},[w.data.buffer])}else if(r.kind==="model-sbo"){await i();const s=new Uint8Array(r.bytes),n=t.decode_sbo(s);a.postMessage({success:!0,data:n.buffer},[n.buffer])}else{const s=r;throw new Error(`unknown task kind: ${s.kind}`)}}catch(s){a.postMessage({success:!1,error:s.message})}}}exports.RendererService=b;exports.registerDecodeWorker=M;
|
package/dist/index.es.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var g = (a, e, t) => e in a ? u(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var h = (a, e, t) => g(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
const y = "sangine-assets-v2";
|
|
5
5
|
let l = null;
|
|
6
|
-
async function m(
|
|
6
|
+
async function m(a, e, t) {
|
|
7
7
|
if (typeof caches > "u") {
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
10
|
-
return
|
|
8
|
+
const r = await fetch(t);
|
|
9
|
+
if (!r.ok) throw new Error(`fetch ${t} failed: ${r.status}`);
|
|
10
|
+
return r.arrayBuffer();
|
|
11
11
|
}
|
|
12
12
|
l ?? (l = caches.open(y));
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
return
|
|
18
|
-
}),
|
|
13
|
+
const i = await l, o = `https://sangine-asset-cache/${a}/${e}`, n = await i.match(o);
|
|
14
|
+
if (n) return n.arrayBuffer();
|
|
15
|
+
const s = await fetch(t);
|
|
16
|
+
if (!s.ok) throw new Error(`fetch ${t} failed: ${s.status}`);
|
|
17
|
+
return i.put(o, s.clone()).catch(() => {
|
|
18
|
+
}), s.arrayBuffer();
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
class
|
|
20
|
+
const f = "/static/sangine/wasm", _ = "9ff4232d";
|
|
21
|
+
class A {
|
|
22
22
|
constructor(e, t) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
h(this, "workers");
|
|
24
|
+
h(this, "idle");
|
|
25
|
+
h(this, "queue", []);
|
|
26
26
|
this.workers = Array.from({ length: t }, e), this.idle = [...this.workers];
|
|
27
27
|
}
|
|
28
28
|
run(e, t) {
|
|
29
|
-
return new Promise((
|
|
30
|
-
const
|
|
31
|
-
|
|
29
|
+
return new Promise((i, o) => {
|
|
30
|
+
const n = this.idle.pop();
|
|
31
|
+
n ? this.dispatch(n, e, t, i, o) : this.queue.push({ request: e, transfer: t, resolve: i, reject: o });
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
dispatch(e, t,
|
|
35
|
-
const
|
|
36
|
-
o(
|
|
37
|
-
},
|
|
38
|
-
|
|
34
|
+
dispatch(e, t, i, o, n) {
|
|
35
|
+
const s = (d) => {
|
|
36
|
+
o(d.data), c(), this.release(e);
|
|
37
|
+
}, r = (d) => {
|
|
38
|
+
n(d), c(), this.release(e);
|
|
39
39
|
}, c = () => {
|
|
40
|
-
e.removeEventListener("message",
|
|
40
|
+
e.removeEventListener("message", s), e.removeEventListener("error", r);
|
|
41
41
|
};
|
|
42
|
-
e.addEventListener("message",
|
|
42
|
+
e.addEventListener("message", s, { once: !0 }), e.addEventListener("error", r, { once: !0 }), e.postMessage(t, i ?? []);
|
|
43
43
|
}
|
|
44
44
|
release(e) {
|
|
45
45
|
const t = this.queue.shift();
|
|
@@ -56,19 +56,19 @@ class b {
|
|
|
56
56
|
}
|
|
57
57
|
class M {
|
|
58
58
|
constructor(e) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.config = e, this._readyPromise = new Promise((t,
|
|
71
|
-
this._resolveReady = t, this._rejectReady =
|
|
59
|
+
h(this, "wasm", null);
|
|
60
|
+
h(this, "callbackRegistry", {});
|
|
61
|
+
h(this, "userActionRegistry", {});
|
|
62
|
+
h(this, "assetsDownloadingRegistry", {});
|
|
63
|
+
h(this, "windowCreatedPromiseRegistry", {});
|
|
64
|
+
h(this, "windowCreatedPromiseResolveRegistry", {});
|
|
65
|
+
h(this, "_inited", !1);
|
|
66
|
+
h(this, "decodePool");
|
|
67
|
+
h(this, "_readyPromise");
|
|
68
|
+
h(this, "_resolveReady");
|
|
69
|
+
h(this, "_rejectReady");
|
|
70
|
+
this.config = e, this._readyPromise = new Promise((t, i) => {
|
|
71
|
+
this._resolveReady = t, this._rejectReady = i;
|
|
72
72
|
}), this.config = e;
|
|
73
73
|
}
|
|
74
74
|
async init() {
|
|
@@ -76,17 +76,17 @@ class M {
|
|
|
76
76
|
if (this._inited) return this._readyPromise;
|
|
77
77
|
try {
|
|
78
78
|
const t = await import(new URL(
|
|
79
|
-
`${
|
|
79
|
+
`${f}/sangine/sangine.${_}.js`,
|
|
80
80
|
window.location.origin
|
|
81
81
|
).toString());
|
|
82
82
|
await t.default(), this.wasm = t, this._inited = !0;
|
|
83
|
-
const
|
|
83
|
+
const i = Math.min(
|
|
84
84
|
this.config.numWorkers ?? (navigator.hardwareConcurrency || 2) - 1,
|
|
85
85
|
2
|
|
86
86
|
);
|
|
87
|
-
this.decodePool = new
|
|
87
|
+
this.decodePool = new A(
|
|
88
88
|
() => this.config.createDecodeWorker(),
|
|
89
|
-
Math.max(
|
|
89
|
+
Math.max(i, 1)
|
|
90
90
|
), this.wasm.register_asset_decoder(this.decodeAsset.bind(this)), this.wasm.register_event_listener(this.handleSangineEvent.bind(this)), this._resolveReady();
|
|
91
91
|
} catch (e) {
|
|
92
92
|
throw this._rejectReady(e), e;
|
|
@@ -107,42 +107,42 @@ class M {
|
|
|
107
107
|
}
|
|
108
108
|
handleActionChanged(e, t) {
|
|
109
109
|
this.userActionRegistry[e] = t;
|
|
110
|
-
for (const
|
|
111
|
-
|
|
110
|
+
for (const i of this.callbackRegistry[e].actionChanged)
|
|
111
|
+
i(t);
|
|
112
112
|
}
|
|
113
113
|
handleMeasurementCreated(e, t) {
|
|
114
|
-
for (const
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
handleRouteUpdated(e, t) {
|
|
118
|
-
for (const s of this.callbackRegistry[e].routeUpdated)
|
|
119
|
-
s(t);
|
|
114
|
+
for (const i of this.callbackRegistry[e].measurementCreated)
|
|
115
|
+
i(t);
|
|
120
116
|
}
|
|
121
117
|
handleAssetsDownloading(e, t) {
|
|
122
118
|
this.assetsDownloadingRegistry[e] = t;
|
|
123
|
-
for (const
|
|
124
|
-
|
|
119
|
+
for (const i of this.callbackRegistry[e].assetsDownloading)
|
|
120
|
+
i(t);
|
|
125
121
|
}
|
|
126
122
|
handleUserInteractionStarted(e) {
|
|
127
123
|
for (const t of this.callbackRegistry[e].userInteractionStarted)
|
|
128
124
|
t();
|
|
129
125
|
}
|
|
126
|
+
handleAnnotationCreated(e, t) {
|
|
127
|
+
for (const i of this.callbackRegistry[e].annotationCreated)
|
|
128
|
+
i(t);
|
|
129
|
+
}
|
|
130
130
|
handleSangineEvent(e, t) {
|
|
131
|
-
t === "ready" ? this.windowCreatedPromiseResolveRegistry[e]() : t === "userInteractionStarted" ? this.handleUserInteractionStarted(e) : "actionChanged" in t ? this.handleActionChanged(e, t.actionChanged.action) : "measurementCreated" in t ? this.handleMeasurementCreated(e, t.measurementCreated.measurement) : "
|
|
131
|
+
t === "ready" ? this.windowCreatedPromiseResolveRegistry[e]() : t === "userInteractionStarted" ? this.handleUserInteractionStarted(e) : "actionChanged" in t ? this.handleActionChanged(e, t.actionChanged.action) : "measurementCreated" in t ? this.handleMeasurementCreated(e, t.measurementCreated.measurement) : "assetsDownloading" in t ? this.handleAssetsDownloading(e, t.assetsDownloading.downloading) : "annotationCreated" in t && this.handleAnnotationCreated(e, t.annotationCreated);
|
|
132
132
|
}
|
|
133
|
-
createWindow(e, t,
|
|
133
|
+
createWindow(e, t, i) {
|
|
134
134
|
if (!this.wasm) throw new Error("WASM not initialized");
|
|
135
135
|
let o;
|
|
136
|
-
const
|
|
137
|
-
o =
|
|
138
|
-
}),
|
|
139
|
-
return this.windowCreatedPromiseResolveRegistry[
|
|
136
|
+
const n = new Promise((r) => {
|
|
137
|
+
o = r;
|
|
138
|
+
}), s = this.wasm.create_window(e, t, i);
|
|
139
|
+
return this.windowCreatedPromiseResolveRegistry[s] = o, this.callbackRegistry[s] = {
|
|
140
140
|
actionChanged: [],
|
|
141
|
-
routeUpdated: [],
|
|
142
141
|
measurementCreated: [],
|
|
143
142
|
assetsDownloading: [],
|
|
144
|
-
userInteractionStarted: []
|
|
145
|
-
|
|
143
|
+
userInteractionStarted: [],
|
|
144
|
+
annotationCreated: []
|
|
145
|
+
}, this.userActionRegistry[s] = "watching", this.windowCreatedPromiseRegistry[s] = n, s;
|
|
146
146
|
}
|
|
147
147
|
getAssetsDownloading(e) {
|
|
148
148
|
return this.assetsDownloadingRegistry[e] || !1;
|
|
@@ -153,8 +153,8 @@ class M {
|
|
|
153
153
|
windowReady(e) {
|
|
154
154
|
return this.windowCreatedPromiseRegistry[e];
|
|
155
155
|
}
|
|
156
|
-
registerCallback(e, t,
|
|
157
|
-
this.callbackRegistry[e][t].push(
|
|
156
|
+
registerCallback(e, t, i) {
|
|
157
|
+
this.callbackRegistry[e][t].push(i);
|
|
158
158
|
}
|
|
159
159
|
setWindowAction(e, t) {
|
|
160
160
|
if (!this.wasm) throw new Error("WASM not initialized");
|
|
@@ -164,17 +164,33 @@ class M {
|
|
|
164
164
|
if (!this.wasm) throw new Error("WASM not initialized");
|
|
165
165
|
this.wasm.destroy_window(e), delete this.callbackRegistry[e], delete this.userActionRegistry[e];
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
setAnnotationProps(e, t, i) {
|
|
168
|
+
if (!this.wasm) throw new Error("WASM not initialized");
|
|
169
|
+
this.wasm.annotation_set_props(e, t, i);
|
|
170
|
+
}
|
|
171
|
+
setAnnotationKind(e, t, i) {
|
|
172
|
+
if (!this.wasm) throw new Error("WASM not initialized");
|
|
173
|
+
this.wasm.annotation_set_kind(e, t, i);
|
|
174
|
+
}
|
|
175
|
+
addAnnotation(e, t, i) {
|
|
176
|
+
if (!this.wasm) throw new Error("WASM not initialized");
|
|
177
|
+
this.wasm.annotation_insert(e, t, i);
|
|
178
|
+
}
|
|
179
|
+
finishAnnotation(e) {
|
|
180
|
+
if (!this.wasm) throw new Error("WASM not initialized");
|
|
181
|
+
this.wasm.annotation_finish(e);
|
|
182
|
+
}
|
|
183
|
+
annotationRemoveLastPoint(e) {
|
|
168
184
|
if (!this.wasm) throw new Error("WASM not initialized");
|
|
169
|
-
this.wasm.
|
|
185
|
+
this.wasm.annotation_remove_last_point(e);
|
|
170
186
|
}
|
|
171
|
-
|
|
187
|
+
removeAnnotation(e, t) {
|
|
172
188
|
if (!this.wasm) throw new Error("WASM not initialized");
|
|
173
|
-
this.wasm.
|
|
189
|
+
this.wasm.annotation_remove(e, t);
|
|
174
190
|
}
|
|
175
|
-
|
|
191
|
+
animateToAnnotation(e, t) {
|
|
176
192
|
if (!this.wasm) throw new Error("WASM not initialized");
|
|
177
|
-
this.wasm.
|
|
193
|
+
this.wasm.animate_to_annotation(e, t);
|
|
178
194
|
}
|
|
179
195
|
setSunProperties(e, t) {
|
|
180
196
|
if (!this.wasm) throw new Error("WASM not initialized");
|
|
@@ -215,10 +231,10 @@ class M {
|
|
|
215
231
|
async decodeAsset(e) {
|
|
216
232
|
if (!this.decodePool) throw new Error("Renderer not initialized");
|
|
217
233
|
if ("texture-file" in e) {
|
|
218
|
-
const { pk:
|
|
219
|
-
return
|
|
234
|
+
const { pk: n, url: s, encoding: r, format: c } = e["texture-file"], d = await m("texture", n, s);
|
|
235
|
+
return r === "ktx2" ? this.decodePool.run({ kind: "texture-basis", bytes: d, format: c }, [d]) : this.decodePool.run({ kind: "texture-image", bytes: d }, [d]);
|
|
220
236
|
}
|
|
221
|
-
const { pk: t, url:
|
|
237
|
+
const { pk: t, url: i } = e["model-part-mesh"], o = await m("mesh", t, i);
|
|
222
238
|
return this.decodePool.run({ kind: "model-sbo", bytes: o }, [o]);
|
|
223
239
|
}
|
|
224
240
|
destroy() {
|
|
@@ -226,58 +242,58 @@ class M {
|
|
|
226
242
|
(e = this.decodePool) == null || e.terminate();
|
|
227
243
|
}
|
|
228
244
|
}
|
|
229
|
-
const
|
|
230
|
-
function E(
|
|
245
|
+
const b = "b6df9f4e", R = 0;
|
|
246
|
+
function E(a) {
|
|
231
247
|
let e = !1, t = null;
|
|
232
|
-
async function
|
|
248
|
+
async function i() {
|
|
233
249
|
if (e) return;
|
|
234
|
-
const
|
|
235
|
-
`${
|
|
236
|
-
|
|
250
|
+
const n = await import(new URL(
|
|
251
|
+
`${f}/decode/wasm_decode.${b}.js`,
|
|
252
|
+
a.location.origin
|
|
237
253
|
).href);
|
|
238
|
-
await
|
|
254
|
+
await n.default(), await n.init_basis(), t = n, e = !0;
|
|
239
255
|
}
|
|
240
|
-
|
|
241
|
-
const
|
|
256
|
+
a.onmessage = async (o) => {
|
|
257
|
+
const n = o.data;
|
|
242
258
|
try {
|
|
243
|
-
if (
|
|
244
|
-
await
|
|
245
|
-
const
|
|
246
|
-
|
|
259
|
+
if (n.kind === "texture-basis") {
|
|
260
|
+
await i();
|
|
261
|
+
const s = new Uint8Array(n.bytes), r = t.transcode_basis(s, n.format);
|
|
262
|
+
a.postMessage(
|
|
247
263
|
{
|
|
248
264
|
success: !0,
|
|
249
|
-
width:
|
|
250
|
-
height:
|
|
251
|
-
data:
|
|
252
|
-
format:
|
|
265
|
+
width: r.width,
|
|
266
|
+
height: r.height,
|
|
267
|
+
data: r.data.buffer,
|
|
268
|
+
format: r.format
|
|
253
269
|
},
|
|
254
|
-
[
|
|
270
|
+
[r.data.buffer]
|
|
255
271
|
);
|
|
256
|
-
} else if (
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
259
|
-
|
|
260
|
-
const w =
|
|
261
|
-
|
|
272
|
+
} else if (n.kind === "texture-image") {
|
|
273
|
+
const s = new Blob([n.bytes]), r = await createImageBitmap(s), c = new OffscreenCanvas(r.width, r.height), d = c.getContext("2d");
|
|
274
|
+
if (d === null) throw new Error("Couldnt create canvas");
|
|
275
|
+
d.drawImage(r, 0, 0);
|
|
276
|
+
const w = d.getImageData(0, 0, c.width, c.height);
|
|
277
|
+
a.postMessage(
|
|
262
278
|
{
|
|
263
279
|
success: !0,
|
|
264
280
|
width: c.width,
|
|
265
281
|
height: c.height,
|
|
266
282
|
data: w.data.buffer,
|
|
267
|
-
format:
|
|
283
|
+
format: R
|
|
268
284
|
},
|
|
269
285
|
[w.data.buffer]
|
|
270
286
|
);
|
|
271
|
-
} else if (
|
|
272
|
-
await
|
|
273
|
-
const
|
|
274
|
-
|
|
287
|
+
} else if (n.kind === "model-sbo") {
|
|
288
|
+
await i();
|
|
289
|
+
const s = new Uint8Array(n.bytes), r = t.decode_sbo(s);
|
|
290
|
+
a.postMessage({ success: !0, data: r.buffer }, [r.buffer]);
|
|
275
291
|
} else {
|
|
276
|
-
const
|
|
277
|
-
throw new Error(`unknown task kind: ${
|
|
292
|
+
const s = n;
|
|
293
|
+
throw new Error(`unknown task kind: ${s.kind}`);
|
|
278
294
|
}
|
|
279
|
-
} catch (
|
|
280
|
-
|
|
295
|
+
} catch (s) {
|
|
296
|
+
a.postMessage({ success: !1, error: s.message });
|
|
281
297
|
}
|
|
282
298
|
};
|
|
283
299
|
}
|