@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.
Files changed (26) hide show
  1. package/dist/gen-types.d.ts +146 -24
  2. package/dist/gen-types.d.ts.map +1 -1
  3. package/dist/index.cjs.js +1 -1
  4. package/dist/index.es.js +124 -108
  5. package/dist/rendererService.d.ts +11 -7
  6. package/dist/rendererService.d.ts.map +1 -1
  7. package/dist/wasm/decode/{wasm_decode.bf116aa6.js → wasm_decode.b6df9f4e.js} +1 -1
  8. package/dist/wasm/decode/{wasm_decode_bg.bf116aa6.wasm → wasm_decode_bg.b6df9f4e.wasm} +0 -0
  9. package/dist/wasm/sangine/{sangine.ecedf539.js → sangine.9ff4232d.js} +91 -44
  10. package/dist/wasm/sangine/sangine.d.ts +20 -8
  11. package/dist/wasm/sangine/{sangine_bg.ecedf539.wasm → sangine_bg.9ff4232d.wasm} +0 -0
  12. package/dist/wasm/sangine/sangine_bg.wasm.d.ts +7 -3
  13. package/dist/wasm/sbo-decode/{wasm_sbo_decode.5c359661.js → wasm_sbo_decode.63ffe035.js} +39 -6
  14. package/dist/wasm/sbo-decode/wasm_sbo_decode_bg.63ffe035.wasm +0 -0
  15. package/dist/wasm-hashes/decode.d.ts +1 -1
  16. package/dist/wasm-hashes/sangine.d.ts +1 -1
  17. package/dist/wasm-hashes/sbo-decode.d.ts +2 -0
  18. package/dist/wasm-hashes/sbo-decode.d.ts.map +1 -0
  19. package/package.json +1 -1
  20. package/dist/wasm/basis-decode/snippets/basisu_c_sys-273c0aeb51b100af/wasm/basisu_transcoder.js +0 -2
  21. package/dist/wasm/basis-decode/snippets/basisu_c_sys-273c0aeb51b100af/wasm/basisu_transcoder.wasm +0 -0
  22. package/dist/wasm/basis-decode/wasm_basis_decode.a8b7eebd.js +0 -553
  23. package/dist/wasm/basis-decode/wasm_basis_decode.d.ts +0 -58
  24. package/dist/wasm/basis-decode/wasm_basis_decode_bg.a8b7eebd.wasm +0 -0
  25. package/dist/wasm/basis-decode/wasm_basis_decode_bg.wasm.d.ts +0 -16
  26. package/dist/wasm/sbo-decode/wasm_sbo_decode_bg.5c359661.wasm +0 -0
@@ -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" | "creatingRoute" | "measuring" | "setModelOrientation";
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` "CameraPos".
128
+ * via the `definition` "Annotation".
92
129
  */
93
- export interface CameraPos {
94
- position: Vec3;
95
- target: Vec3;
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` "Vec3".
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 Vec3 {
102
- x: number;
103
- y: number;
104
- z: number;
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
@@ -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,6BAA6B,EAAE;QAC7B,KAA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=Object.defineProperty;var f=(n,e,t)=>e in n?g(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var d=(n,e,t)=>f(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y="sangine-assets-v2";let l=null;async function u(n,e,t){if(typeof caches>"u"){const a=await fetch(t);if(!a.ok)throw new Error(`fetch ${t} failed: ${a.status}`);return a.arrayBuffer()}l??(l=caches.open(y));const s=await l,o=`https://sangine-asset-cache/${n}/${e}`,r=await s.match(o);if(r)return r.arrayBuffer();const i=await fetch(t);if(!i.ok)throw new Error(`fetch ${t} failed: ${i.status}`);return s.put(o,i.clone()).catch(()=>{}),i.arrayBuffer()}const m="/static/sangine/wasm",_="ecedf539";class b{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((s,o)=>{const r=this.idle.pop();r?this.dispatch(r,e,t,s,o):this.queue.push({request:e,transfer:t,resolve:s,reject:o})})}dispatch(e,t,s,o,r){const i=h=>{o(h.data),c(),this.release(e)},a=h=>{r(h),c(),this.release(e)},c=()=>{e.removeEventListener("message",i),e.removeEventListener("error",a)};e.addEventListener("message",i,{once:!0}),e.addEventListener("error",a,{once:!0}),e.postMessage(t,s??[])}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 R{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,s)=>{this._resolveReady=t,this._rejectReady=s}),this.config=e}async init(){if(!(typeof window>"u")){if(this._inited)return this._readyPromise;try{const t=await import(new URL(`${m}/sangine/sangine.${_}.js`,window.location.origin).toString());await t.default(),this.wasm=t,this._inited=!0;const s=Math.min(this.config.numWorkers??(navigator.hardwareConcurrency||2)-1,2);this.decodePool=new b(()=>this.config.createDecodeWorker(),Math.max(s,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 s of this.callbackRegistry[e].actionChanged)s(t)}handleMeasurementCreated(e,t){for(const s of this.callbackRegistry[e].measurementCreated)s(t)}handleRouteUpdated(e,t){for(const s of this.callbackRegistry[e].routeUpdated)s(t)}handleAssetsDownloading(e,t){this.assetsDownloadingRegistry[e]=t;for(const s of this.callbackRegistry[e].assetsDownloading)s(t)}handleUserInteractionStarted(e){for(const t of this.callbackRegistry[e].userInteractionStarted)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):"routeUnderConstructionUpdated"in t?this.handleRouteUpdated(e,t.routeUnderConstructionUpdated.route):"assetsDownloading"in t&&this.handleAssetsDownloading(e,t.assetsDownloading.downloading)}createWindow(e,t,s){if(!this.wasm)throw new Error("WASM not initialized");let o;const r=new Promise(a=>{o=a}),i=this.wasm.create_window(e,t,s);return this.windowCreatedPromiseResolveRegistry[i]=o,this.callbackRegistry[i]={actionChanged:[],routeUpdated:[],measurementCreated:[],assetsDownloading:[],userInteractionStarted:[]},this.userActionRegistry[i]="watching",this.windowCreatedPromiseRegistry[i]=r,i}getAssetsDownloading(e){return this.assetsDownloadingRegistry[e]||!1}readUserAction(e){return this.userActionRegistry[e]}windowReady(e){return this.windowCreatedPromiseRegistry[e]}registerCallback(e,t,s){this.callbackRegistry[e][t].push(s)}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]}setRouteHighlight(e,t,s){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_route_highlight(e,t,s)}setRouteVisible(e,t,s){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_route_visible(e,t,s)}animateToRoute(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.animate_to_route(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:i,encoding:a,format:c}=e["texture-file"],h=await u("texture",r,i);return a==="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:s}=e["model-part-mesh"],o=await u("mesh",t,s);return this.decodePool.run({kind:"model-sbo",bytes:o},[o])}destroy(){var e;(e=this.decodePool)==null||e.terminate()}}const p="bf116aa6",A=0;function M(n){let e=!1,t=null;async function s(){if(e)return;const r=await import(new URL(`${m}/decode/wasm_decode.${p}.js`,n.location.origin).href);await r.default(),await r.init_basis(),t=r,e=!0}n.onmessage=async o=>{const r=o.data;try{if(r.kind==="texture-basis"){await s();const i=new Uint8Array(r.bytes),a=t.transcode_basis(i,r.format);n.postMessage({success:!0,width:a.width,height:a.height,data:a.data.buffer,format:a.format},[a.data.buffer])}else if(r.kind==="texture-image"){const i=new Blob([r.bytes]),a=await createImageBitmap(i),c=new OffscreenCanvas(a.width,a.height),h=c.getContext("2d");if(h===null)throw new Error("Couldnt create canvas");h.drawImage(a,0,0);const w=h.getImageData(0,0,c.width,c.height);n.postMessage({success:!0,width:c.width,height:c.height,data:w.data.buffer,format:A},[w.data.buffer])}else if(r.kind==="model-sbo"){await s();const i=new Uint8Array(r.bytes),a=t.decode_sbo(i);n.postMessage({success:!0,data:a.buffer},[a.buffer])}else{const i=r;throw new Error(`unknown task kind: ${i.kind}`)}}catch(i){n.postMessage({success:!1,error:i.message})}}}exports.RendererService=R;exports.registerDecodeWorker=M;
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 g = Object.defineProperty;
2
- var f = (n, e, t) => e in n ? g(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var d = (n, e, t) => f(n, typeof e != "symbol" ? e + "" : e, t);
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(n, e, t) {
6
+ async function m(a, e, t) {
7
7
  if (typeof caches > "u") {
8
- const a = await fetch(t);
9
- if (!a.ok) throw new Error(`fetch ${t} failed: ${a.status}`);
10
- return a.arrayBuffer();
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 s = await l, o = `https://sangine-asset-cache/${n}/${e}`, r = await s.match(o);
14
- if (r) return r.arrayBuffer();
15
- const i = await fetch(t);
16
- if (!i.ok) throw new Error(`fetch ${t} failed: ${i.status}`);
17
- return s.put(o, i.clone()).catch(() => {
18
- }), i.arrayBuffer();
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 u = "/static/sangine/wasm", _ = "ecedf539";
21
- class b {
20
+ const f = "/static/sangine/wasm", _ = "9ff4232d";
21
+ class A {
22
22
  constructor(e, t) {
23
- d(this, "workers");
24
- d(this, "idle");
25
- d(this, "queue", []);
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((s, o) => {
30
- const r = this.idle.pop();
31
- r ? this.dispatch(r, e, t, s, o) : this.queue.push({ request: e, transfer: t, resolve: s, reject: o });
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, s, o, r) {
35
- const i = (h) => {
36
- o(h.data), c(), this.release(e);
37
- }, a = (h) => {
38
- r(h), c(), this.release(e);
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", i), e.removeEventListener("error", a);
40
+ e.removeEventListener("message", s), e.removeEventListener("error", r);
41
41
  };
42
- e.addEventListener("message", i, { once: !0 }), e.addEventListener("error", a, { once: !0 }), e.postMessage(t, s ?? []);
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
- d(this, "wasm", null);
60
- d(this, "callbackRegistry", {});
61
- d(this, "userActionRegistry", {});
62
- d(this, "assetsDownloadingRegistry", {});
63
- d(this, "windowCreatedPromiseRegistry", {});
64
- d(this, "windowCreatedPromiseResolveRegistry", {});
65
- d(this, "_inited", !1);
66
- d(this, "decodePool");
67
- d(this, "_readyPromise");
68
- d(this, "_resolveReady");
69
- d(this, "_rejectReady");
70
- this.config = e, this._readyPromise = new Promise((t, s) => {
71
- this._resolveReady = t, this._rejectReady = s;
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
- `${u}/sangine/sangine.${_}.js`,
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 s = Math.min(
83
+ const i = Math.min(
84
84
  this.config.numWorkers ?? (navigator.hardwareConcurrency || 2) - 1,
85
85
  2
86
86
  );
87
- this.decodePool = new b(
87
+ this.decodePool = new A(
88
88
  () => this.config.createDecodeWorker(),
89
- Math.max(s, 1)
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 s of this.callbackRegistry[e].actionChanged)
111
- s(t);
110
+ for (const i of this.callbackRegistry[e].actionChanged)
111
+ i(t);
112
112
  }
113
113
  handleMeasurementCreated(e, t) {
114
- for (const s of this.callbackRegistry[e].measurementCreated)
115
- s(t);
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 s of this.callbackRegistry[e].assetsDownloading)
124
- s(t);
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) : "routeUnderConstructionUpdated" in t ? this.handleRouteUpdated(e, t.routeUnderConstructionUpdated.route) : "assetsDownloading" in t && this.handleAssetsDownloading(e, t.assetsDownloading.downloading);
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, s) {
133
+ createWindow(e, t, i) {
134
134
  if (!this.wasm) throw new Error("WASM not initialized");
135
135
  let o;
136
- const r = new Promise((a) => {
137
- o = a;
138
- }), i = this.wasm.create_window(e, t, s);
139
- return this.windowCreatedPromiseResolveRegistry[i] = o, this.callbackRegistry[i] = {
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
- }, this.userActionRegistry[i] = "watching", this.windowCreatedPromiseRegistry[i] = r, i;
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, s) {
157
- this.callbackRegistry[e][t].push(s);
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
- setRouteHighlight(e, t, s) {
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.set_route_highlight(e, t, s);
185
+ this.wasm.annotation_remove_last_point(e);
170
186
  }
171
- setRouteVisible(e, t, s) {
187
+ removeAnnotation(e, t) {
172
188
  if (!this.wasm) throw new Error("WASM not initialized");
173
- this.wasm.set_route_visible(e, t, s);
189
+ this.wasm.annotation_remove(e, t);
174
190
  }
175
- animateToRoute(e, t) {
191
+ animateToAnnotation(e, t) {
176
192
  if (!this.wasm) throw new Error("WASM not initialized");
177
- this.wasm.animate_to_route(e, t);
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: r, url: i, encoding: a, format: c } = e["texture-file"], h = await m("texture", r, i);
219
- return a === "ktx2" ? this.decodePool.run({ kind: "texture-basis", bytes: h, format: c }, [h]) : this.decodePool.run({ kind: "texture-image", bytes: h }, [h]);
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: s } = e["model-part-mesh"], o = await m("mesh", t, s);
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 R = "bf116aa6", p = 0;
230
- function E(n) {
245
+ const b = "b6df9f4e", R = 0;
246
+ function E(a) {
231
247
  let e = !1, t = null;
232
- async function s() {
248
+ async function i() {
233
249
  if (e) return;
234
- const r = await import(new URL(
235
- `${u}/decode/wasm_decode.${R}.js`,
236
- n.location.origin
250
+ const n = await import(new URL(
251
+ `${f}/decode/wasm_decode.${b}.js`,
252
+ a.location.origin
237
253
  ).href);
238
- await r.default(), await r.init_basis(), t = r, e = !0;
254
+ await n.default(), await n.init_basis(), t = n, e = !0;
239
255
  }
240
- n.onmessage = async (o) => {
241
- const r = o.data;
256
+ a.onmessage = async (o) => {
257
+ const n = o.data;
242
258
  try {
243
- if (r.kind === "texture-basis") {
244
- await s();
245
- const i = new Uint8Array(r.bytes), a = t.transcode_basis(i, r.format);
246
- n.postMessage(
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: a.width,
250
- height: a.height,
251
- data: a.data.buffer,
252
- format: a.format
265
+ width: r.width,
266
+ height: r.height,
267
+ data: r.data.buffer,
268
+ format: r.format
253
269
  },
254
- [a.data.buffer]
270
+ [r.data.buffer]
255
271
  );
256
- } else if (r.kind === "texture-image") {
257
- const i = new Blob([r.bytes]), a = await createImageBitmap(i), c = new OffscreenCanvas(a.width, a.height), h = c.getContext("2d");
258
- if (h === null) throw new Error("Couldnt create canvas");
259
- h.drawImage(a, 0, 0);
260
- const w = h.getImageData(0, 0, c.width, c.height);
261
- n.postMessage(
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: p
283
+ format: R
268
284
  },
269
285
  [w.data.buffer]
270
286
  );
271
- } else if (r.kind === "model-sbo") {
272
- await s();
273
- const i = new Uint8Array(r.bytes), a = t.decode_sbo(i);
274
- n.postMessage({ success: !0, data: a.buffer }, [a.buffer]);
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 i = r;
277
- throw new Error(`unknown task kind: ${i.kind}`);
292
+ const s = n;
293
+ throw new Error(`unknown task kind: ${s.kind}`);
278
294
  }
279
- } catch (i) {
280
- n.postMessage({ success: !1, error: i.message });
295
+ } catch (s) {
296
+ a.postMessage({ success: !1, error: s.message });
281
297
  }
282
298
  };
283
299
  }