@lumiscaphe/viewer 4.1.13 → 4.1.15
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/lib/index.cjs +25 -0
- package/dist/lib/index.d.ts +833 -0
- package/dist/lib/index.js +1771 -0
- package/package.json +18 -28
- package/.prettierrc +0 -6
- package/dist/Animation.d.ts +0 -7
- package/dist/Basis3.d.ts +0 -10
- package/dist/Canvas2D.d.ts +0 -19
- package/dist/Canvas3D.d.ts +0 -8
- package/dist/Database.d.ts +0 -25
- package/dist/Encoder.d.ts +0 -5
- package/dist/EventHelper.d.ts +0 -5
- package/dist/Hotspot.d.ts +0 -14
- package/dist/Inertia.d.ts +0 -14
- package/dist/InertiaPoint.d.ts +0 -6
- package/dist/InteractiveCamera.d.ts +0 -25
- package/dist/InteractivePosition.d.ts +0 -26
- package/dist/Loader.d.ts +0 -37
- package/dist/LoaderDelegate.d.ts +0 -5
- package/dist/Maths.d.ts +0 -11
- package/dist/Options.d.ts +0 -11
- package/dist/Parameters.d.ts +0 -9
- package/dist/Point.d.ts +0 -6
- package/dist/PointOfView.d.ts +0 -13
- package/dist/Position.d.ts +0 -4
- package/dist/Resolution.d.ts +0 -6
- package/dist/Scene.d.ts +0 -14
- package/dist/Size.d.ts +0 -5
- package/dist/Snapshot.d.ts +0 -10
- package/dist/Spherical.d.ts +0 -11
- package/dist/Transition.d.ts +0 -6
- package/dist/Video.d.ts +0 -8
- package/dist/View.d.ts +0 -20
- package/dist/Viewer.d.ts +0 -67
- package/dist/Viewport.d.ts +0 -19
- package/dist/WRAPIv1.d.ts +0 -37
- package/dist/WRAPIv2.d.ts +0 -355
- package/dist/WebRenderAPIv1.d.ts +0 -16
- package/dist/WebRenderAPIv1Requests.d.ts +0 -35
- package/dist/WebRenderAPIv2.d.ts +0 -14
- package/dist/WebRenderAPIv2Requests.d.ts +0 -220
- package/dist/WebRenderAPIv2Responses.d.ts +0 -3
- package/dist/WebRenderStatic.d.ts +0 -11
- package/dist/WebRenderV1.d.ts +0 -18
- package/dist/WebRenderV2.d.ts +0 -26
- package/dist/Widget.d.ts +0 -21
- package/dist/WidgetImage.d.ts +0 -32
- package/dist/WidgetVRCube.d.ts +0 -45
- package/dist/WidgetVRObject.d.ts +0 -40
- package/dist/WidgetVideo.d.ts +0 -30
- package/dist/index-full.js +0 -20
- package/dist/index-full.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.es.js +0 -2
- package/dist/index.es.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/patches/twgl.js+5.5.3.patch +0 -27
package/dist/Widget.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Hotspot } from './Hotspot';
|
|
2
|
-
import { Resolution } from './Resolution';
|
|
3
|
-
import { Snapshot } from './Snapshot';
|
|
4
|
-
import { WRAPIv2 } from './WRAPIv2';
|
|
5
|
-
export interface Widget {
|
|
6
|
-
destroy(): void;
|
|
7
|
-
show(): void;
|
|
8
|
-
hide(): void;
|
|
9
|
-
load(snapshot: Snapshot, hotspots: Array<string | WRAPIv2.Vector3D>, reset: boolean, fade: boolean): Promise<void>;
|
|
10
|
-
hotspots(resolution: Resolution): Hotspot[];
|
|
11
|
-
pick(snapshot: Snapshot, position: WRAPIv2.Vector2D): Promise<WRAPIv2.PickResult>;
|
|
12
|
-
snapshot(type: string, quality: number): string;
|
|
13
|
-
onMouseDown(e: MouseEvent): void;
|
|
14
|
-
onMouseEnter(e: MouseEvent): void;
|
|
15
|
-
onMouseMove(e: MouseEvent): void;
|
|
16
|
-
onMouseUp(e: MouseEvent): void;
|
|
17
|
-
onTouchStart(e: TouchEvent): void;
|
|
18
|
-
onTouchMove(e: TouchEvent): void;
|
|
19
|
-
onTouchEnd(e: TouchEvent): void;
|
|
20
|
-
onDeviceOrientation(e: DeviceOrientationEvent): void;
|
|
21
|
-
}
|
package/dist/WidgetImage.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Canvas2D } from './Canvas2D';
|
|
2
|
-
import { Hotspot } from './Hotspot';
|
|
3
|
-
import { Loader } from './Loader';
|
|
4
|
-
import { Resolution } from './Resolution';
|
|
5
|
-
import { Snapshot } from './Snapshot';
|
|
6
|
-
import { Widget } from './Widget';
|
|
7
|
-
import { WRAPIv2 } from './WRAPIv2';
|
|
8
|
-
export declare class WidgetImage implements Widget {
|
|
9
|
-
private container;
|
|
10
|
-
private canvas;
|
|
11
|
-
private loader;
|
|
12
|
-
private image?;
|
|
13
|
-
private hotspotList;
|
|
14
|
-
private hotspotsHash?;
|
|
15
|
-
private snapshotHash?;
|
|
16
|
-
constructor(container: HTMLElement, canvas: Canvas2D, loader: Loader);
|
|
17
|
-
destroy(): void;
|
|
18
|
-
show(): void;
|
|
19
|
-
hide(): void;
|
|
20
|
-
load(snapshot: Snapshot, hotspots: Array<string | WRAPIv2.Vector3D>, reset: boolean, fade: boolean): Promise<void>;
|
|
21
|
-
pick(snapshot: Snapshot, position: WRAPIv2.Vector2D): Promise<WRAPIv2.PickResult>;
|
|
22
|
-
hotspots(resolution: Resolution): Hotspot[];
|
|
23
|
-
snapshot(type: string, quality: number): string;
|
|
24
|
-
onMouseDown(e: MouseEvent): void;
|
|
25
|
-
onMouseMove(e: MouseEvent): void;
|
|
26
|
-
onMouseUp(e: MouseEvent): void;
|
|
27
|
-
onMouseEnter(e: MouseEvent): void;
|
|
28
|
-
onTouchStart(e: TouchEvent): void;
|
|
29
|
-
onTouchMove(e: TouchEvent): void;
|
|
30
|
-
onTouchEnd(e: TouchEvent): void;
|
|
31
|
-
onDeviceOrientation(e: DeviceOrientationEvent): void;
|
|
32
|
-
}
|
package/dist/WidgetVRCube.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Canvas3D } from './Canvas3D';
|
|
2
|
-
import { Hotspot } from './Hotspot';
|
|
3
|
-
import { Loader } from './Loader';
|
|
4
|
-
import { PointOfView } from './PointOfView';
|
|
5
|
-
import { Snapshot } from './Snapshot';
|
|
6
|
-
import { WRAPIv2 } from './WRAPIv2';
|
|
7
|
-
import { Widget } from './Widget';
|
|
8
|
-
export declare class WidgetVRCube implements Widget {
|
|
9
|
-
private container;
|
|
10
|
-
private canvas;
|
|
11
|
-
private loader;
|
|
12
|
-
private images;
|
|
13
|
-
private hotspotsList;
|
|
14
|
-
private interaction;
|
|
15
|
-
private onInteraction;
|
|
16
|
-
private gl;
|
|
17
|
-
private programInfo;
|
|
18
|
-
private quad;
|
|
19
|
-
private uniforms;
|
|
20
|
-
private hotspotsHash?;
|
|
21
|
-
private snapshotHash?;
|
|
22
|
-
private animationFrameId?;
|
|
23
|
-
constructor(container: HTMLElement, canvas: Canvas3D, loader: Loader, onInteraction: (...args: any[]) => void);
|
|
24
|
-
destroy(): void;
|
|
25
|
-
show(): void;
|
|
26
|
-
hide(): void;
|
|
27
|
-
get pov(): PointOfView;
|
|
28
|
-
set pov(pov: PointOfView);
|
|
29
|
-
get fov(): number;
|
|
30
|
-
set fov(fov: number);
|
|
31
|
-
load(snapshot: Snapshot, hotspots: Array<string | WRAPIv2.Vector3D>, reset: boolean, fade: boolean): Promise<void>;
|
|
32
|
-
pick(snapshot: Snapshot, position: WRAPIv2.Vector2D): Promise<WRAPIv2.PickResult>;
|
|
33
|
-
hotspots(): Hotspot[];
|
|
34
|
-
snapshot(type: string, quality: number): string;
|
|
35
|
-
private get modelViewProjectionMatrix();
|
|
36
|
-
render(): void;
|
|
37
|
-
onMouseDown(e: MouseEvent): void;
|
|
38
|
-
onMouseMove(e: MouseEvent): void;
|
|
39
|
-
onMouseUp(e: MouseEvent): void;
|
|
40
|
-
onMouseEnter(e: MouseEvent): void;
|
|
41
|
-
onTouchStart(e: TouchEvent): void;
|
|
42
|
-
onTouchMove(e: TouchEvent): void;
|
|
43
|
-
onTouchEnd(e: TouchEvent): void;
|
|
44
|
-
onDeviceOrientation(e: DeviceOrientationEvent): void;
|
|
45
|
-
}
|
package/dist/WidgetVRObject.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Canvas2D } from './Canvas2D';
|
|
2
|
-
import { Hotspot } from './Hotspot';
|
|
3
|
-
import { Loader } from './Loader';
|
|
4
|
-
import { Resolution } from './Resolution';
|
|
5
|
-
import { Snapshot } from './Snapshot';
|
|
6
|
-
import { Widget } from './Widget';
|
|
7
|
-
import { WRAPIv2 } from './WRAPIv2';
|
|
8
|
-
export declare class WidgetVRObject implements Widget {
|
|
9
|
-
private container;
|
|
10
|
-
private canvas;
|
|
11
|
-
private loader;
|
|
12
|
-
private images;
|
|
13
|
-
private frames;
|
|
14
|
-
private hotspotsList;
|
|
15
|
-
private interaction;
|
|
16
|
-
private onInteraction;
|
|
17
|
-
private hotspotsHash?;
|
|
18
|
-
private snapshotHash?;
|
|
19
|
-
private animationFrameId?;
|
|
20
|
-
constructor(container: HTMLElement, canvas: Canvas2D, loader: Loader, onInteraction: (...args: any[]) => void);
|
|
21
|
-
destroy(): void;
|
|
22
|
-
show(): void;
|
|
23
|
-
hide(): void;
|
|
24
|
-
goto(position: number): Promise<void>;
|
|
25
|
-
get position(): number;
|
|
26
|
-
set position(position: number);
|
|
27
|
-
get image(): HTMLImageElement;
|
|
28
|
-
load(snapshot: Snapshot, hotspots: Array<string | WRAPIv2.Vector3D>, reset: boolean, fade: boolean): Promise<void>;
|
|
29
|
-
pick(snapshot: Snapshot, position: WRAPIv2.Vector2D): Promise<WRAPIv2.PickResult>;
|
|
30
|
-
hotspots(resolution: Resolution): Hotspot[];
|
|
31
|
-
snapshot(type: string, quality: number): string;
|
|
32
|
-
onMouseDown(e: MouseEvent): void;
|
|
33
|
-
onMouseMove(e: MouseEvent): void;
|
|
34
|
-
onMouseUp(e: MouseEvent): void;
|
|
35
|
-
onMouseEnter(e: MouseEvent): void;
|
|
36
|
-
onTouchStart(e: TouchEvent): void;
|
|
37
|
-
onTouchMove(e: TouchEvent): void;
|
|
38
|
-
onTouchEnd(e: TouchEvent): void;
|
|
39
|
-
onDeviceOrientation(e: DeviceOrientationEvent): void;
|
|
40
|
-
}
|
package/dist/WidgetVideo.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Hotspot } from './Hotspot';
|
|
2
|
-
import { Loader } from './Loader';
|
|
3
|
-
import { Resolution } from './Resolution';
|
|
4
|
-
import { Snapshot } from './Snapshot';
|
|
5
|
-
import { Video } from './Video';
|
|
6
|
-
import { Widget } from './Widget';
|
|
7
|
-
import { WRAPIv2 } from './WRAPIv2';
|
|
8
|
-
export declare class WidgetVideo implements Widget {
|
|
9
|
-
private container;
|
|
10
|
-
private loader;
|
|
11
|
-
private video;
|
|
12
|
-
private hash?;
|
|
13
|
-
constructor(container: HTMLElement, video: Video, loader: Loader);
|
|
14
|
-
destroy(): void;
|
|
15
|
-
show(): void;
|
|
16
|
-
hide(): void;
|
|
17
|
-
load(snapshot: Snapshot): Promise<void>;
|
|
18
|
-
pick(snapshot: Snapshot, position: WRAPIv2.Vector2D): Promise<WRAPIv2.PickResult>;
|
|
19
|
-
hotspots(resolution: Resolution): Hotspot[];
|
|
20
|
-
snapshot(type: string, quality: number): string;
|
|
21
|
-
play(): Promise<void>;
|
|
22
|
-
onMouseDown(e: MouseEvent): void;
|
|
23
|
-
onMouseMove(e: MouseEvent): void;
|
|
24
|
-
onMouseUp(e: MouseEvent): void;
|
|
25
|
-
onMouseEnter(e: MouseEvent): void;
|
|
26
|
-
onTouchStart(e: TouchEvent): void;
|
|
27
|
-
onTouchMove(e: TouchEvent): void;
|
|
28
|
-
onTouchEnd(e: TouchEvent): void;
|
|
29
|
-
onDeviceOrientation(e: DeviceOrientationEvent): void;
|
|
30
|
-
}
|
package/dist/index-full.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
!function(t){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var e=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=void 0,s=void 0,a=void 0,c=[];return function(){var l=n(e),u=(new Date).getTime(),d=!o||u-o>l;o=u;for(var m=arguments.length,f=Array(m),p=0;p<m;p++)f[p]=arguments[p];if(d&&i.leading)return i.accumulate?Promise.resolve(t.call(this,[f])).then((function(t){return t[0]})):Promise.resolve(t.call.apply(t,[this].concat(f)));if(s?clearTimeout(a):s=r(),c.push(f),a=setTimeout(h.bind(this),l),i.accumulate){var v=c.length-1;return s.promise.then((function(t){return t[v]}))}return s.promise};function h(){var e=s;clearTimeout(a),Promise.resolve(i.accumulate?t.call(this,c):t.apply(this,c[c.length-1])).then(e.resolve,e.reject),c=[],s=null}};function n(t){return"function"==typeof t?t():t}function r(){var t={};return t.promise=new Promise((function(e,n){t.resolve=e,t.reject=n})),t}class i{constructor(t,e){this.width=t,this.height=e}get aspect(){return this.width/this.height}}class o{constructor(t,e,n,r){this.top=t,this.left=e,this.width=n,this.height=r}static fit(t,e,n){const r=t.aspect,i=e.aspect;let s=0,a=0;switch(n){case"contain":s=i<r?e.width:e.height*r,a=i<r?e.width/r:e.height;break;case"cover":default:s=i<r?e.height*r:e.width,a=i<r?e.height:e.width/r;break;case"fill":s=e.width,a=e.height}const c=(e.height-a)/2,h=(e.width-s)/2;return new o(c,h,s,a)}static getStandardAspectRatio(t,e){if(0===t||0===e)return 0;const n=t/e;if(t<e){return Math.abs(3/4-n)<Math.abs(9/16-n)?3/4:9/16}return Math.abs(4/3-n)<Math.abs(16/9-n)?4/3:16/9}static getStandardResolution(t,e){if(0===t||0===e)return new i(0,0);const n=o.getStandardAspectRatio(t,e);if(t<e){const r=o.getStandardQuality(Math.max(e*n,t));return new i(Math.round(r),Math.round(r/n))}const r=o.getStandardQuality(Math.max(t/n,e));return new i(Math.round(r*n),Math.round(r))}static getStandardQuality(t){return t<=240?240:t<=360?360:t<=480?480:t<=720?720:1080}}class s{constructor(t){this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity="0",this.context=this.element.getContext("2d"),this.backCanvas=document.createElement("canvas"),this.backContext=this.backCanvas.getContext("2d"),this.fit=t}destroy(){this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=void 0)}show(t){t?this.element.style.display="block":this.element.style.opacity="1"}hide(t){t?this.element.style.display="none":this.element.style.opacity="0"}resize(t,e,n){this.element.width=t*n,this.element.height=e*n,this.element.style.width=`${t}px`,this.element.style.height=`${e}px`,this.backCanvas.width=t*n,this.backCanvas.height=e*n}draw(t,e,n){if(!t)return;this.requestAnimationId&&(cancelAnimationFrame(this.requestAnimationId),this.requestAnimationId=void 0);const r=o.fit(new i(t.width,t.height),new i(this.element.width,this.element.height),this.fit);e?(this.backContext.drawImage(this.element,0,0),this.context.globalAlpha=0,this.fadeLoop(t,n||0)):(this.context.globalAlpha=1,this.context.drawImage(t,r.left,r.top,r.width,r.height)),this.image=t}fadeLoop(t,e){if(this.context.globalAlpha>=1)return cancelAnimationFrame(this.requestAnimationId),void(this.requestAnimationId=void 0);const n=Math.min(this.context.globalAlpha+e,1),r=o.fit(new i(t.width,t.height),new i(this.element.width,this.element.height),this.fit);this.context.clearRect(0,0,this.element.width,this.element.height),this.context.globalAlpha=1,this.context.drawImage(this.backCanvas,0,0),this.context.globalAlpha=n,this.context.drawImage(t,r.left,r.top,r.width,r.height),this.requestAnimationId=requestAnimationFrame((()=>{this.fadeLoop(t,e)}))}}
|
|
2
|
-
/* @license twgl.js 5.0.4 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
|
|
3
|
-
Available via the MIT license.
|
|
4
|
-
see: http://github.com/greggman/twgl.js for details */let a=Float32Array;function c(t,e,n){const r=new a(3);return t&&(r[0]=t),e&&(r[1]=e),n&&(r[2]=n),r}function h(t,e,n){return(n=n||new a(3))[0]=t[0]+e[0],n[1]=t[1]+e[1],n[2]=t[2]+e[2],n}function l(t,e,n){return(n=n||new a(3))[0]=t[0]-e[0],n[1]=t[1]-e[1],n[2]=t[2]-e[2],n}function u(t,e,n){n=n||new a(3);const r=t[2]*e[0]-t[0]*e[2],i=t[0]*e[1]-t[1]*e[0];return n[0]=t[1]*e[2]-t[2]*e[1],n[1]=r,n[2]=i,n}function d(t,e){e=e||new a(3);const n=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=Math.sqrt(n);return r>1e-5?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=0,e[1]=0,e[2]=0),e}function m(t,e,n){return(n=n||new a(3))[0]=t[0]*e[0],n[1]=t[1]*e[1],n[2]=t[2]*e[2],n}var f=Object.freeze({__proto__:null,add:h,copy:function(t,e){return(e=e||new a(3))[0]=t[0],e[1]=t[1],e[2]=t[2],e},create:c,cross:u,distance:function(t,e){const n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)},distanceSq:function(t,e){const n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return n*n+r*r+i*i},divide:function(t,e,n){return(n=n||new a(3))[0]=t[0]/e[0],n[1]=t[1]/e[1],n[2]=t[2]/e[2],n},divScalar:function(t,e,n){return(n=n||new a(3))[0]=t[0]/e,n[1]=t[1]/e,n[2]=t[2]/e,n},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},lerp:function(t,e,n,r){return(r=r||new a(3))[0]=t[0]+n*(e[0]-t[0]),r[1]=t[1]+n*(e[1]-t[1]),r[2]=t[2]+n*(e[2]-t[2]),r},lerpV:function(t,e,n,r){return(r=r||new a(3))[0]=t[0]+n[0]*(e[0]-t[0]),r[1]=t[1]+n[1]*(e[1]-t[1]),r[2]=t[2]+n[2]*(e[2]-t[2]),r},length:function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])},lengthSq:function(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]},max:function(t,e,n){return(n=n||new a(3))[0]=Math.max(t[0],e[0]),n[1]=Math.max(t[1],e[1]),n[2]=Math.max(t[2],e[2]),n},min:function(t,e,n){return(n=n||new a(3))[0]=Math.min(t[0],e[0]),n[1]=Math.min(t[1],e[1]),n[2]=Math.min(t[2],e[2]),n},mulScalar:function(t,e,n){return(n=n||new a(3))[0]=t[0]*e,n[1]=t[1]*e,n[2]=t[2]*e,n},multiply:m,negate:function(t,e){return(e=e||new a(3))[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},normalize:d,setDefaultType:function(t){const e=a;return a=t,e},subtract:l});let p,v,g,b=Float32Array;function y(t,e){return(e=e||new b(16))[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function w(t){return(t=t||new b(16))[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function x(t,e){e=e||new b(16);const n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],a=t[5],c=t[6],h=t[7],l=t[8],u=t[9],d=t[10],m=t[11],f=t[12],p=t[13],v=t[14],g=t[15],y=d*g,w=v*m,x=c*g,E=v*h,P=c*m,A=d*h,F=i*g,M=v*o,I=i*m,T=d*o,S=i*h,L=c*o,_=l*p,R=f*u,O=s*p,k=f*a,j=s*u,C=l*a,z=n*p,D=f*r,U=n*u,V=l*r,B=n*a,H=s*r,W=y*a+E*u+P*p-(w*a+x*u+A*p),$=w*r+F*u+T*p-(y*r+M*u+I*p),q=x*r+M*a+S*p-(E*r+F*a+L*p),N=A*r+I*a+L*u-(P*r+T*a+S*u),X=1/(n*W+s*$+l*q+f*N);return e[0]=X*W,e[1]=X*$,e[2]=X*q,e[3]=X*N,e[4]=X*(w*s+x*l+A*f-(y*s+E*l+P*f)),e[5]=X*(y*n+M*l+I*f-(w*n+F*l+T*f)),e[6]=X*(E*n+F*s+L*f-(x*n+M*s+S*f)),e[7]=X*(P*n+T*s+S*l-(A*n+I*s+L*l)),e[8]=X*(_*h+k*m+j*g-(R*h+O*m+C*g)),e[9]=X*(R*o+z*m+V*g-(_*o+D*m+U*g)),e[10]=X*(O*o+D*h+B*g-(k*o+z*h+H*g)),e[11]=X*(C*o+U*h+H*m-(j*o+V*h+B*m)),e[12]=X*(O*d+C*v+R*c-(j*v+_*c+k*d)),e[13]=X*(U*v+_*i+D*d-(z*d+V*v+R*i)),e[14]=X*(z*c+H*v+k*i-(B*v+O*i+D*c)),e[15]=X*(B*d+j*i+V*c-(U*c+H*d+C*i)),e}function E(t,e,n){n=n||c();const r=e[0],i=e[1],o=e[2],s=r*t[3]+i*t[7]+o*t[11]+t[15];return n[0]=(r*t[0]+i*t[4]+o*t[8]+t[12])/s,n[1]=(r*t[1]+i*t[5]+o*t[9]+t[13])/s,n[2]=(r*t[2]+i*t[6]+o*t[10]+t[14])/s,n}function P(t,e,n){n=n||c();const r=e[0],i=e[1],o=e[2];return n[0]=r*t[0]+i*t[4]+o*t[8],n[1]=r*t[1]+i*t[5]+o*t[9],n[2]=r*t[2]+i*t[6]+o*t[10],n}var A=Object.freeze({__proto__:null,axisRotate:function(t,e,n,r){r=r||new b(16);let i=e[0],o=e[1],s=e[2];const a=Math.sqrt(i*i+o*o+s*s);i/=a,o/=a,s/=a;const c=i*i,h=o*o,l=s*s,u=Math.cos(n),d=Math.sin(n),m=1-u,f=c+(1-c)*u,p=i*o*m+s*d,v=i*s*m-o*d,g=i*o*m-s*d,y=h+(1-h)*u,w=o*s*m+i*d,x=i*s*m+o*d,E=o*s*m-i*d,P=l+(1-l)*u,A=t[0],F=t[1],M=t[2],I=t[3],T=t[4],S=t[5],L=t[6],_=t[7],R=t[8],O=t[9],k=t[10],j=t[11];return r[0]=f*A+p*T+v*R,r[1]=f*F+p*S+v*O,r[2]=f*M+p*L+v*k,r[3]=f*I+p*_+v*j,r[4]=g*A+y*T+w*R,r[5]=g*F+y*S+w*O,r[6]=g*M+y*L+w*k,r[7]=g*I+y*_+w*j,r[8]=x*A+E*T+P*R,r[9]=x*F+E*S+P*O,r[10]=x*M+E*L+P*k,r[11]=x*I+E*_+P*j,t!==r&&(r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r},axisRotation:function(t,e,n){n=n||new b(16);let r=t[0],i=t[1],o=t[2];const s=Math.sqrt(r*r+i*i+o*o);r/=s,i/=s,o/=s;const a=r*r,c=i*i,h=o*o,l=Math.cos(e),u=Math.sin(e),d=1-l;return n[0]=a+(1-a)*l,n[1]=r*i*d+o*u,n[2]=r*o*d-i*u,n[3]=0,n[4]=r*i*d-o*u,n[5]=c+(1-c)*l,n[6]=i*o*d+r*u,n[7]=0,n[8]=r*o*d+i*u,n[9]=i*o*d-r*u,n[10]=h+(1-h)*l,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},copy:y,create:function(){return new b(16).fill(0)},frustum:function(t,e,n,r,i,o,s){const a=e-t,c=r-n,h=i-o;return(s=s||new b(16))[0]=2*i/a,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2*i/c,s[6]=0,s[7]=0,s[8]=(t+e)/a,s[9]=(r+n)/c,s[10]=o/h,s[11]=-1,s[12]=0,s[13]=0,s[14]=i*o/h,s[15]=0,s},getAxis:function(t,e,n){const r=4*e;return(n=n||c())[0]=t[r+0],n[1]=t[r+1],n[2]=t[r+2],n},getTranslation:function(t,e){return(e=e||c())[0]=t[12],e[1]=t[13],e[2]=t[14],e},identity:w,inverse:x,lookAt:function(t,e,n,r){return r=r||new b(16),p=p||c(),v=v||c(),g=g||c(),d(l(t,e,g),g),d(u(n,g,p),p),d(u(g,p,v),v),r[0]=p[0],r[1]=p[1],r[2]=p[2],r[3]=0,r[4]=v[0],r[5]=v[1],r[6]=v[2],r[7]=0,r[8]=g[0],r[9]=g[1],r[10]=g[2],r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r},multiply:function(t,e,n){n=n||new b(16);const r=t[0],i=t[1],o=t[2],s=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=t[8],d=t[9],m=t[10],f=t[11],p=t[12],v=t[13],g=t[14],y=t[15],w=e[0],x=e[1],E=e[2],P=e[3],A=e[4],F=e[5],M=e[6],I=e[7],T=e[8],S=e[9],L=e[10],_=e[11],R=e[12],O=e[13],k=e[14],j=e[15];return n[0]=r*w+a*x+u*E+p*P,n[1]=i*w+c*x+d*E+v*P,n[2]=o*w+h*x+m*E+g*P,n[3]=s*w+l*x+f*E+y*P,n[4]=r*A+a*F+u*M+p*I,n[5]=i*A+c*F+d*M+v*I,n[6]=o*A+h*F+m*M+g*I,n[7]=s*A+l*F+f*M+y*I,n[8]=r*T+a*S+u*L+p*_,n[9]=i*T+c*S+d*L+v*_,n[10]=o*T+h*S+m*L+g*_,n[11]=s*T+l*S+f*L+y*_,n[12]=r*R+a*O+u*k+p*j,n[13]=i*R+c*O+d*k+v*j,n[14]=o*R+h*O+m*k+g*j,n[15]=s*R+l*O+f*k+y*j,n},negate:function(t,e){return(e=e||new b(16))[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e[4]=-t[4],e[5]=-t[5],e[6]=-t[6],e[7]=-t[7],e[8]=-t[8],e[9]=-t[9],e[10]=-t[10],e[11]=-t[11],e[12]=-t[12],e[13]=-t[13],e[14]=-t[14],e[15]=-t[15],e},ortho:function(t,e,n,r,i,o,s){return(s=s||new b(16))[0]=2/(e-t),s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2/(r-n),s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2/(i-o),s[11]=0,s[12]=(e+t)/(t-e),s[13]=(r+n)/(n-r),s[14]=(o+i)/(i-o),s[15]=1,s},perspective:function(t,e,n,r,i){i=i||new b(16);const o=Math.tan(.5*Math.PI-.5*t),s=1/(n-r);return i[0]=o/e,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=o,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=(n+r)*s,i[11]=-1,i[12]=0,i[13]=0,i[14]=n*r*s*2,i[15]=0,i},rotateX:function(t,e,n){n=n||new b(16);const r=t[4],i=t[5],o=t[6],s=t[7],a=t[8],c=t[9],h=t[10],l=t[11],u=Math.cos(e),d=Math.sin(e);return n[4]=u*r+d*a,n[5]=u*i+d*c,n[6]=u*o+d*h,n[7]=u*s+d*l,n[8]=u*a-d*r,n[9]=u*c-d*i,n[10]=u*h-d*o,n[11]=u*l-d*s,t!==n&&(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n},rotateY:function(t,e,n){n=n||new b(16);const r=t[0],i=t[1],o=t[2],s=t[3],a=t[8],c=t[9],h=t[10],l=t[11],u=Math.cos(e),d=Math.sin(e);return n[0]=u*r-d*a,n[1]=u*i-d*c,n[2]=u*o-d*h,n[3]=u*s-d*l,n[8]=u*a+d*r,n[9]=u*c+d*i,n[10]=u*h+d*o,n[11]=u*l+d*s,t!==n&&(n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n},rotateZ:function(t,e,n){n=n||new b(16);const r=t[0],i=t[1],o=t[2],s=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=Math.cos(e),d=Math.sin(e);return n[0]=u*r+d*a,n[1]=u*i+d*c,n[2]=u*o+d*h,n[3]=u*s+d*l,n[4]=u*a-d*r,n[5]=u*c-d*i,n[6]=u*h-d*o,n[7]=u*l-d*s,t!==n&&(n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n},rotationX:function(t,e){e=e||new b(16);const n=Math.cos(t),r=Math.sin(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},rotationY:function(t,e){e=e||new b(16);const n=Math.cos(t),r=Math.sin(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},rotationZ:function(t,e){e=e||new b(16);const n=Math.cos(t),r=Math.sin(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},scale:function(t,e,n){n=n||new b(16);const r=e[0],i=e[1],o=e[2];return n[0]=r*t[0],n[1]=r*t[1],n[2]=r*t[2],n[3]=r*t[3],n[4]=i*t[4],n[5]=i*t[5],n[6]=i*t[6],n[7]=i*t[7],n[8]=o*t[8],n[9]=o*t[9],n[10]=o*t[10],n[11]=o*t[11],t!==n&&(n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n},scaling:function(t,e){return(e=e||new b(16))[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},setAxis:function(t,e,n,r){r!==t&&(r=y(t,r));const i=4*n;return r[i+0]=e[0],r[i+1]=e[1],r[i+2]=e[2],r},setDefaultType:function(t){const e=b;return b=t,e},setTranslation:function(t,e,n){return t!==(n=n||w())&&(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11]),n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n},transformDirection:P,transformNormal:function(t,e,n){n=n||c();const r=x(t),i=e[0],o=e[1],s=e[2];return n[0]=i*r[0]+o*r[1]+s*r[2],n[1]=i*r[4]+o*r[5]+s*r[6],n[2]=i*r[8]+o*r[9]+s*r[10],n},transformPoint:E,translate:function(t,e,n){n=n||new b(16);const r=e[0],i=e[1],o=e[2],s=t[0],a=t[1],c=t[2],h=t[3],l=t[4],u=t[5],d=t[6],m=t[7],f=t[8],p=t[9],v=t[10],g=t[11],y=t[12],w=t[13],x=t[14],E=t[15];return t!==n&&(n[0]=s,n[1]=a,n[2]=c,n[3]=h,n[4]=l,n[5]=u,n[6]=d,n[7]=m,n[8]=f,n[9]=p,n[10]=v,n[11]=g),n[12]=s*r+l*i+f*o+y,n[13]=a*r+u*i+p*o+w,n[14]=c*r+d*i+v*o+x,n[15]=h*r+m*i+g*o+E,n},translation:function(t,e){return(e=e||new b(16))[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e},transpose:function(t,e){if((e=e||new b(16))===t){let n;return n=t[1],t[1]=t[4],t[4]=n,n=t[2],t[2]=t[8],t[8]=n,n=t[3],t[3]=t[12],t[12]=n,n=t[6],t[6]=t[9],t[9]=n,n=t[7],t[7]=t[13],t[13]=n,n=t[11],t[11]=t[14],t[14]=n,e}const n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],a=t[5],c=t[6],h=t[7],l=t[8],u=t[9],d=t[10],m=t[11],f=t[12],p=t[13],v=t[14],g=t[15];return e[0]=n,e[1]=s,e[2]=l,e[3]=f,e[4]=r,e[5]=a,e[6]=u,e[7]=p,e[8]=i,e[9]=c,e[10]=d,e[11]=v,e[12]=o,e[13]=h,e[14]=m,e[15]=g,e}});const F=5120,M=5121,I=5122,T=5123,S=5124,L=5125,_=5126,R={};{const t=R;t[F]=Int8Array,t[5121]=Uint8Array,t[5122]=Int16Array,t[5123]=Uint16Array,t[S]=Int32Array,t[5125]=Uint32Array,t[5126]=Float32Array,t[32819]=Uint16Array,t[32820]=Uint16Array,t[33635]=Uint16Array,t[5131]=Uint16Array,t[33640]=Uint32Array,t[35899]=Uint32Array,t[35902]=Uint32Array,t[36269]=Uint32Array,t[34042]=Uint32Array}function O(t){if(t instanceof Int8Array)return F;if(t instanceof Uint8Array)return M;if(t instanceof Uint8ClampedArray)return M;if(t instanceof Int16Array)return I;if(t instanceof Uint16Array)return T;if(t instanceof Int32Array)return S;if(t instanceof Uint32Array)return L;if(t instanceof Float32Array)return _;throw new Error("unsupported typed array type")}const k="undefined"!=typeof SharedArrayBuffer?function(t){return t&&t.buffer&&(t.buffer instanceof ArrayBuffer||t.buffer instanceof SharedArrayBuffer)}:function(t){return t&&t.buffer&&t.buffer instanceof ArrayBuffer};function j(...t){console.error(...t)}function C(...t){console.warn(...t)}const z=new Map;function D(t,e){if(!t||"object"!=typeof t)return!1;let n=z.get(e);n||(n=new WeakMap,z.set(e,n));let r=n.get(t);if(void 0===r){const i=Object.prototype.toString.call(t);r=i.substring(8,i.length-1)===e,n.set(t,r)}return r}function U(t,e){return"undefined"!=typeof WebGLTexture&&D(e,"WebGLTexture")}const V=34962,B="";function H(t,e,n,r){if(i=e,"undefined"!=typeof WebGLBuffer&&D(i,"WebGLBuffer"))return e;var i;n=n||V;const o=t.createBuffer();return function(t,e,n,r,i){t.bindBuffer(e,n),t.bufferData(e,r,i||35044)}(t,n,o,e,r),o}function W(t){return"indices"===t}function $(t){return t.length?t:t.data}const q=/coord|texture/i,N=/color|colour/i;function X(t,e){let n;if(n=q.test(t)?2:N.test(t)?4:3,e%n>0)throw new Error(`Can not guess numComponents for attribute '${t}'. Tried ${n} but ${e} values is not evenly divisible by ${n}. You should specify it.`);return n}function G(t,e){return t.numComponents||t.size||X(e,$(t).length)}function Y(t,e){if(k(t))return t;if(k(t.data))return t.data;Array.isArray(t)&&(t={data:t});let n=t.type;return n||(n=W(e)?Uint16Array:Float32Array),new n(t.data)}function Q(t,e){const n={};return Object.keys(e).forEach((function(r){if(!W(r)){const o=e[r],s=o.attrib||o.name||o.attribName||B+r;if(o.value){if(!Array.isArray(o.value)&&!k(o.value))throw new Error("array.value is not array or typedarray");n[s]={value:o.value}}else{let e,a,c,h;if(o.buffer&&o.buffer instanceof WebGLBuffer)e=o.buffer,h=o.numComponents||o.size,a=o.type,c=o.normalize;else if("number"==typeof o||"number"==typeof o.data){const n=o.data||o,s=o.type||Float32Array,l=n*s.BYTES_PER_ELEMENT;a=function(t){if(t===Int8Array)return F;if(t===Uint8Array)return M;if(t===Uint8ClampedArray)return M;if(t===Int16Array)return I;if(t===Uint16Array)return T;if(t===Int32Array)return S;if(t===Uint32Array)return L;if(t===Float32Array)return _;throw new Error("unsupported typed array type")}(s),c=void 0!==o.normalize?o.normalize:(i=s)===Int8Array||i===Uint8Array,h=o.numComponents||o.size||X(r,n),e=t.createBuffer(),t.bindBuffer(V,e),t.bufferData(V,l,o.drawType||35044)}else{const n=Y(o,r);e=H(t,n,void 0,o.drawType),a=O(n),c=void 0!==o.normalize?o.normalize:function(t){return t instanceof Int8Array||t instanceof Uint8Array}(n),h=G(o,r)}n[s]={buffer:e,numComponents:h,type:a,normalize:c,stride:o.stride||0,offset:o.offset||0,divisor:void 0===o.divisor?void 0:o.divisor,drawType:o.drawType}}}var i})),t.bindBuffer(V,null),n}const J=["position","positions","a_position"];function Z(t,e,n){const r=Q(t,e),i=Object.assign({},n||{});i.attribs=Object.assign({},n?n.attribs:{},r);const o=e.indices;if(o){const e=Y(o,"indices");i.indices=H(t,e,34963),i.numElements=e.length,i.elementType=O(e)}else i.numElements||(i.numElements=function(t,e){let n,r;for(r=0;r<J.length&&(n=J[r],!(n in e))&&(n=B+n,!(n in e));++r);r===J.length&&(n=Object.keys(e)[0]);const i=e[n];if(!i.buffer)return 1;t.bindBuffer(V,i.buffer);const o=t.getBufferParameter(V,34660);var s;t.bindBuffer(V,null);const a=o/(5120===(s=i.type)||5121===s?1:5122===s||5123===s?2:5124===s||5125===s||5126===s?4:0),c=i.numComponents||i.size,h=a/c;if(h%1!=0)throw new Error(`numComponents ${c} not correct for length ${length}`);return h}(t,i.attribs));return i}function K(t,e){const n={};return Object.keys(e).forEach((function(r){n[r]=function(t,e,n){const r="indices"===n?34963:V;return H(t,Y(e,n),r)}(t,e[r],r)})),e.indices?(n.numElements=e.indices.length,n.elementType=O(Y(e.indices))):n.numElements=function(t){let e,n;for(n=0;n<J.length&&(e=J[n],!(e in t));++n);n===J.length&&(e=Object.keys(t)[0]);const r=t[e],i=$(r).length;if(void 0===i)return 1;const o=G(r,e),s=i/o;if(i%o>0)throw new Error(`numComponents ${o} not correct for length ${i}`);return s}(e),n}const tt=$,et=G;function nt(t,e){let n=0;return t.push=function(){for(let e=0;e<arguments.length;++e){const r=arguments[e];if(r instanceof Array||k(r))for(let e=0;e<r.length;++e)t[n++]=r[e];else t[n++]=r}},t.reset=function(t){n=t||0},t.numComponents=e,Object.defineProperty(t,"numElements",{get:function(){return this.length/this.numComponents|0}}),t}function rt(t,e,n){return nt(new(n||Float32Array)(t*e),t)}function it(t){return"indices"!==t}function ot(t,e,n){const r=t.length,i=new Float32Array(3);for(let o=0;o<r;o+=3)n(e,[t[o],t[o+1],t[o+2]],i),t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2]}function st(t,e,n){n=n||c();const r=e[0],i=e[1],o=e[2];return n[0]=r*t[0]+i*t[1]+o*t[2],n[1]=r*t[4]+i*t[5]+o*t[6],n[2]=r*t[8]+i*t[9]+o*t[10],n}function at(t,e){return ot(t,e,P),t}function ct(t,e){return ot(t,x(e),st),t}function ht(t,e){return ot(t,e,E),t}function lt(t,e){return Object.keys(t).forEach((function(n){const r=t[n];n.indexOf("pos")>=0?ht(r,e):n.indexOf("tan")>=0||n.indexOf("binorm")>=0?at(r,e):n.indexOf("norm")>=0&&ct(r,e)})),t}function ut(t,e,n){return t=t||2,{position:{numComponents:2,data:[(e=e||0)+-1*(t*=.5),(n=n||0)+-1*t,e+1*t,n+-1*t,e+-1*t,n+1*t,e+1*t,n+1*t]},normal:[0,0,1,0,0,1,0,0,1,0,0,1],texcoord:[0,0,1,0,0,1,1,1],indices:[0,1,2,2,1,3]}}function dt(t,e,n,r,i){t=t||1,e=e||1,n=n||1,r=r||1,i=i||w();const o=(n+1)*(r+1),s=rt(3,o),a=rt(3,o),c=rt(2,o);for(let i=0;i<=r;i++)for(let o=0;o<=n;o++){const h=o/n,l=i/r;s.push(t*h-.5*t,0,e*l-.5*e),a.push(0,1,0),c.push(h,l)}const h=n+1,l=rt(3,n*r*2,Uint16Array);for(let t=0;t<r;t++)for(let e=0;e<n;e++)l.push((t+0)*h+e,(t+1)*h+e,(t+0)*h+e+1),l.push((t+1)*h+e,(t+1)*h+e+1,(t+0)*h+e+1);return lt({position:s,normal:a,texcoord:c,indices:l},i)}function mt(t,e,n,r,i,o,s){if(e<=0||n<=0)throw new Error("subdivisionAxis and subdivisionHeight must be > 0");r=r||0,o=o||0;const a=(i=i||Math.PI)-r,c=(s=s||2*Math.PI)-o,h=(e+1)*(n+1),l=rt(3,h),u=rt(3,h),d=rt(2,h);for(let i=0;i<=n;i++)for(let s=0;s<=e;s++){const h=s/e,m=i/n,f=c*h+o,p=a*m+r,v=Math.sin(f),g=Math.cos(f),b=Math.sin(p),y=g*b,w=Math.cos(p),x=v*b;l.push(t*y,t*w,t*x),u.push(y,w,x),d.push(1-h,m)}const m=e+1,f=rt(3,e*n*2,Uint16Array);for(let t=0;t<e;t++)for(let e=0;e<n;e++)f.push((e+0)*m+t,(e+0)*m+t+1,(e+1)*m+t),f.push((e+1)*m+t,(e+0)*m+t+1,(e+1)*m+t+1);return{position:l,normal:u,texcoord:d,indices:f}}const ft=[[3,7,5,1],[6,2,0,4],[6,7,3,2],[0,1,5,4],[7,6,4,5],[2,3,1,0]];function pt(t){const e=(t=t||1)/2,n=[[-e,-e,-e],[+e,-e,-e],[-e,+e,-e],[+e,+e,-e],[-e,-e,+e],[+e,-e,+e],[-e,+e,+e],[+e,+e,+e]],r=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],i=[[1,0],[0,0],[0,1],[1,1]],o=rt(3,24),s=rt(3,24),a=rt(2,24),c=rt(3,12,Uint16Array);for(let t=0;t<6;++t){const e=ft[t];for(let c=0;c<4;++c){const h=n[e[c]],l=r[t],u=i[c];o.push(h),s.push(l),a.push(u)}const h=4*t;c.push(h+0,h+1,h+2),c.push(h+0,h+2,h+3)}return{position:o,normal:s,texcoord:a,indices:c}}function vt(t,e,n,r,i,o,s){if(r<3)throw new Error("radialSubdivisions must be 3 or greater");if(i<1)throw new Error("verticalSubdivisions must be 1 or greater");const a=void 0===o||o,c=void 0===s||s,h=(a?2:0)+(c?2:0),l=(r+1)*(i+1+h),u=rt(3,l),d=rt(3,l),m=rt(2,l),f=rt(3,r*(i+h/2)*2,Uint16Array),p=r+1,v=Math.atan2(t-e,n),g=Math.cos(v),b=Math.sin(v),y=i+(c?2:0);for(let o=a?-2:0;o<=y;++o){let s,a=o/i,c=n*a;o<0?(c=0,a=1,s=t):o>i?(c=n,a=1,s=e):s=t+o/i*(e-t),-2!==o&&o!==i+2||(s=0,a=0),c-=n/2;for(let t=0;t<p;++t){const e=Math.sin(t*Math.PI*2/r),n=Math.cos(t*Math.PI*2/r);u.push(e*s,c,n*s),o<0?d.push(0,-1,0):o>i?d.push(0,1,0):0===s?d.push(0,0,0):d.push(e*g,b,n*g),m.push(t/r,1-a)}}for(let t=0;t<i+h;++t)if(!(1===t&&a||t===i+h-2&&c))for(let e=0;e<r;++e)f.push(p*(t+0)+0+e,p*(t+0)+1+e,p*(t+1)+1+e),f.push(p*(t+0)+0+e,p*(t+1)+1+e,p*(t+1)+0+e);return{position:u,normal:d,texcoord:m,indices:f}}function gt(t,e){e=e||[];const n=[];for(let r=0;r<t.length;r+=4){const i=t[r],o=t.slice(r+1,r+4);o.push.apply(o,e);for(let t=0;t<i;++t)n.push.apply(n,o)}return n}function bt(){const t=[0,0,0,0,150,0,30,0,0,0,150,0,30,150,0,30,0,0,30,0,0,30,30,0,100,0,0,30,30,0,100,30,0,100,0,0,30,60,0,30,90,0,67,60,0,30,90,0,67,90,0,67,60,0,0,0,30,30,0,30,0,150,30,0,150,30,30,0,30,30,150,30,30,0,30,100,0,30,30,30,30,30,30,30,100,0,30,100,30,30,30,60,30,67,60,30,30,90,30,30,90,30,67,60,30,67,90,30,0,0,0,100,0,0,100,0,30,0,0,0,100,0,30,0,0,30,100,0,0,100,30,0,100,30,30,100,0,0,100,30,30,100,0,30,30,30,0,30,30,30,100,30,30,30,30,0,100,30,30,100,30,0,30,30,0,30,60,30,30,30,30,30,30,0,30,60,0,30,60,30,30,60,0,67,60,30,30,60,30,30,60,0,67,60,0,67,60,30,67,60,0,67,90,30,67,60,30,67,60,0,67,90,0,67,90,30,30,90,0,30,90,30,67,90,30,30,90,0,67,90,30,67,90,0,30,90,0,30,150,30,30,90,30,30,90,0,30,150,0,30,150,30,0,150,0,0,150,30,30,150,30,0,150,0,30,150,30,30,150,0,0,0,0,0,0,30,0,150,30,0,0,0,0,150,30,0,150,0],e=gt([18,0,0,1,18,0,0,-1,6,0,1,0,6,1,0,0,6,0,-1,0,6,1,0,0,6,0,1,0,6,1,0,0,6,0,-1,0,6,1,0,0,6,0,-1,0,6,-1,0,0]),n=gt([18,200,70,120,18,80,70,200,6,70,200,210,6,200,200,70,6,210,100,70,6,210,160,70,6,70,180,210,6,100,70,210,6,76,210,100,6,140,210,80,6,90,130,110,6,160,160,220],[255]),r=t.length/3,i={position:rt(3,r),texcoord:rt(2,r),normal:rt(3,r),color:rt(4,r,Uint8Array),indices:rt(3,r/3,Uint16Array)};i.position.push(t),i.texcoord.push([.22,.19,.22,.79,.34,.19,.22,.79,.34,.79,.34,.19,.34,.19,.34,.31,.62,.19,.34,.31,.62,.31,.62,.19,.34,.43,.34,.55,.49,.43,.34,.55,.49,.55,.49,.43,0,0,1,0,0,1,0,1,1,0,1,1,0,0,1,0,0,1,0,1,1,0,1,1,0,0,1,0,0,1,0,1,1,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,0,1,0,0,1,0,1,1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,0,1,1,1,0]),i.normal.push(e),i.color.push(n);for(let t=0;t<r;++t)i.indices.push(t);return i}function yt(t,e,n,r,i,o,s){if(i<=0)throw new Error("subdivisionDown must be > 0");const a=(s=s||1)-(o=o||0),c=2*(i+1)*4,l=rt(3,c),u=rt(3,c),d=rt(2,c);function f(t,e,n){return t+(e-t)*n}function p(e,n,s,c,p,v){for(let g=0;g<=i;g++){const b=n/1,y=g/i,w=2*(b-.5),x=(o+y*a)*Math.PI,E=Math.sin(x),P=Math.cos(x),A=f(t,e,E),F=w*r,M=P*t,I=E*A;l.push(F,M,I);const T=h(m([0,E,P],s),c);u.push(T),d.push(b*p+v,y)}}for(let t=0;t<2;t++){const r=2*(t/1-.5);p(e,t,[1,1,1],[0,0,0],1,0),p(e,t,[0,0,0],[r,0,0],0,0),p(n,t,[1,1,1],[0,0,0],1,0),p(n,t,[0,0,0],[r,0,0],0,1)}const v=rt(3,2*i*4,Uint16Array);function g(t,e){for(let n=0;n<i;++n)v.push(t+n+0,t+n+1,e+n+0),v.push(t+n+1,e+n+1,e+n+0)}const b=i+1;return g(0*b,4*b),g(5*b,7*b),g(6*b,2*b),g(3*b,1*b),{position:l,normal:u,texcoord:d,indices:v}}function wt(t,e,n,r,i,o){return vt(t,t,e,n,r,i,o)}function xt(t,e,n,r,i,o){if(n<3)throw new Error("radialSubdivisions must be 3 or greater");if(r<3)throw new Error("verticalSubdivisions must be 3 or greater");i=i||0;const s=(o=o||2*Math.PI)-i,a=n+1,c=r+1,h=a*c,l=rt(3,h),u=rt(3,h),d=rt(2,h),m=rt(3,n*r*2,Uint16Array);for(let o=0;o<c;++o){const c=o/r,h=c*Math.PI*2,m=Math.sin(h),f=t+m*e,p=Math.cos(h),v=p*e;for(let t=0;t<a;++t){const e=t/n,r=i+e*s,o=Math.sin(r),a=Math.cos(r),h=o*f,g=a*f,b=o*m,y=a*m;l.push(h,v,g),u.push(b,p,y),d.push(e,1-c)}}for(let t=0;t<r;++t)for(let e=0;e<n;++e){const n=1+e,r=1+t;m.push(a*t+e,a*r+e,a*t+n),m.push(a*r+e,a*r+n,a*t+n)}return{position:l,normal:u,texcoord:d,indices:m}}function Et(t,e,n,r,i){if(e<3)throw new Error("divisions must be at least 3");i=i||1,r=r||0;const o=(e+1)*((n=n||1)+1),s=rt(3,o),a=rt(3,o),c=rt(2,o),h=rt(3,n*e*2,Uint16Array);let l=0;const u=t-r,d=e+1;for(let t=0;t<=n;++t){const o=r+u*Math.pow(t/n,i);for(let r=0;r<=e;++r){const i=2*Math.PI*r/e,u=o*Math.cos(i),m=o*Math.sin(i);if(s.push(u,0,m),a.push(0,1,0),c.push(1-r/e,t/n),t>0&&r!==e){const t=l+(r+1),e=l+r,n=l+r-d,i=l+(r+1)-d;h.push(t,e,n),h.push(t,n,i)}}l+=e+1}return{position:s,normal:a,texcoord:c,indices:h}}function Pt(t){return function(e){const n=t.apply(this,Array.prototype.slice.call(arguments,1));return K(e,n)}}function At(t){return function(e){const n=t.apply(null,Array.prototype.slice.call(arguments,1));return Z(e,n)}}const Ft=["numComponents","size","type","normalize","stride","offset","attrib","name","attribName"];function Mt(t,e,n,r){r=r||0;const i=t.length;for(let o=0;o<i;++o)e[n+o]=t[o]+r}function It(t,e){const n=tt(t),r=new n.constructor(e);let i=r;var o,s;return n.numComponents&&n.numElements&&nt(r,n.numComponents),t.data&&(i={data:r},o=t,s=i,Ft.forEach((function(t){const e=o[t];void 0!==e&&(s[t]=e)}))),i}const Tt=At(bt),St=Pt(bt),Lt=At(pt),_t=Pt(pt),Rt=At(dt),Ot=Pt(dt),kt=At(mt),jt=Pt(mt),Ct=At(vt),zt=Pt(vt),Dt=At(ut),Ut=Pt(ut),Vt=At(yt),Bt=Pt(yt),Ht=At(wt),Wt=Pt(wt),$t=At(xt),qt=Pt(xt),Nt=At(Et),Xt=Pt(Et),Gt=Vt,Yt=Bt,Qt=yt;var Jt=Object.freeze({__proto__:null,create3DFBufferInfo:Tt,create3DFBuffers:St,create3DFVertices:bt,createAugmentedTypedArray:rt,createCubeBufferInfo:Lt,createCubeBuffers:_t,createCubeVertices:pt,createPlaneBufferInfo:Rt,createPlaneBuffers:Ot,createPlaneVertices:dt,createSphereBufferInfo:kt,createSphereBuffers:jt,createSphereVertices:mt,createTruncatedConeBufferInfo:Ct,createTruncatedConeBuffers:zt,createTruncatedConeVertices:vt,createXYQuadBufferInfo:Dt,createXYQuadBuffers:Ut,createXYQuadVertices:ut,createCresentBufferInfo:Gt,createCresentBuffers:Yt,createCresentVertices:Qt,createCrescentBufferInfo:Vt,createCrescentBuffers:Bt,createCrescentVertices:yt,createCylinderBufferInfo:Ht,createCylinderBuffers:Wt,createCylinderVertices:wt,createTorusBufferInfo:$t,createTorusBuffers:qt,createTorusVertices:xt,createDiscBufferInfo:Nt,createDiscBuffers:Xt,createDiscVertices:Et,deindexVertices:function(t){const e=t.indices,n={},r=e.length;return Object.keys(t).filter(it).forEach((function(i){const o=t[i],s=o.numComponents,a=rt(s,r,o.constructor);for(let t=0;t<r;++t){const n=e[t]*s;for(let t=0;t<s;++t)a.push(o[n+t])}n[i]=a})),n},flattenNormals:function(t){if(t.indices)throw new Error("can not flatten normals of indexed vertices. deindex them first");const e=t.normal,n=e.length;for(let t=0;t<n;t+=9){const n=e[t+0],r=e[t+1],i=e[t+2],o=e[t+3],s=e[t+4],a=e[t+5];let c=n+o+e[t+6],h=r+s+e[t+7],l=i+a+e[t+8];const u=Math.sqrt(c*c+h*h+l*l);c/=u,h/=u,l/=u,e[t+0]=c,e[t+1]=h,e[t+2]=l,e[t+3]=c,e[t+4]=h,e[t+5]=l,e[t+6]=c,e[t+7]=h,e[t+8]=l}return t},makeRandomVertexColors:function(t,e){e=e||{};const n=t.position.numElements,r=rt(4,n,Uint8Array),i=e.rand||function(t,e){return e<3?(n=256,Math.random()*n|0):255;var n};if(t.color=r,t.indices)for(let t=0;t<n;++t)r.push(i(t,0),i(t,1),i(t,2),i(t,3));else{const t=e.vertsPerColor||3,o=n/t;for(let e=0;e<o;++e){const n=[i(e,0),i(e,1),i(e,2),i(e,3)];for(let e=0;e<t;++e)r.push(n)}}return t},reorientDirections:at,reorientNormals:ct,reorientPositions:ht,reorientVertices:lt,concatVertices:function(t){const e={};let n;for(let r=0;r<t.length;++r){const i=t[r];Object.keys(i).forEach((function(t){e[t]||(e[t]=[]),n||"indices"===t||(n=t);const r=i[t],o=et(r,t),s=tt(r).length/o;e[t].push(s)}))}const r=e[n],i={};return Object.keys(e).forEach((function(e){const n=function(e){let n,r=0;for(let i=0;i<t.length;++i){const o=t[i][e];r+=tt(o).length,n&&!o.data||(n=o)}return{length:r,spec:n}}(e),o=It(n.spec,n.length);!function(e,n,r){let i=0,o=0;for(let s=0;s<t.length;++s){const a=t[s][e],c=tt(a);"indices"===e?(Mt(c,r,o,i),i+=n[s]):Mt(c,r,o),o+=c.length}}(e,r,tt(o)),i[e]=o})),i},duplicateVertices:function(t){const e={};return Object.keys(t).forEach((function(n){const r=t[n],i=tt(r),o=It(r,i.length);Mt(i,tt(o),0),e[n]=o})),e}});function Zt(t){return!!t.texStorage2D}const Kt=function(){const t={},e={};return function(n,r){return function(n){const r=n.constructor.name;if(!t[r]){for(const t in n)if("number"==typeof n[t]){const r=e[n[t]];e[n[t]]=r?`${r} | ${t}`:t}t[r]=!0}}(n),e[r]||("number"==typeof r?`0x${r.toString(16)}`:r)}}(),te={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},ee=k,ne=function(){let t;return function(){return t=t||("undefined"!=typeof document&&document.createElement?document.createElement("canvas").getContext("2d"):null),t}}(),re=6407,ie=6408,oe=6402,se=33071,ae=3553,ce=34067,he=32879,le=35866,ue=34069,de=10241,me=10240,fe=10242,pe=10243,ve=3317,ge=5120,be=5121,ye=5122,we=5123,xe=5124,Ee=5125,Pe=5126,Ae=5131,Fe=36193,Me=33640,Ie=33319,Te=33320,Se=6403,Le=36244,_e=36248,Re=36249;let Oe;function ke(t){if(!Oe){const t={};t[6406]={textureFormat:6406,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[be,Ae,Fe,Pe]},t[6409]={textureFormat:6409,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[be,Ae,Fe,Pe]},t[6410]={textureFormat:6410,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[be,Ae,Fe,Pe]},t[re]={textureFormat:re,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[be,Ae,Fe,Pe,33635]},t[ie]={textureFormat:ie,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[be,Ae,Fe,Pe,32819,32820]},t[6402]={textureFormat:oe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Ee,we]},t[33321]={textureFormat:Se,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[be]},t[36756]={textureFormat:Se,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[ge]},t[33325]={textureFormat:Se,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[Pe,Ae]},t[33326]={textureFormat:Se,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[Pe]},t[33330]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[be]},t[33329]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[ge]},t[33332]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[we]},t[33331]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ye]},t[33334]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ee]},t[33333]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[xe]},t[33323]={textureFormat:Ie,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[be]},t[36757]={textureFormat:Ie,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[ge]},t[33327]={textureFormat:Ie,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[Pe,Ae]},t[33328]={textureFormat:Ie,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[Pe]},t[33336]={textureFormat:Te,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[be]},t[33335]={textureFormat:Te,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ge]},t[33338]={textureFormat:Te,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[we]},t[33337]={textureFormat:Te,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ye]},t[33340]={textureFormat:Te,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Ee]},t[33339]={textureFormat:Te,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[xe]},t[32849]={textureFormat:re,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[be]},t[35905]={textureFormat:re,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[be]},t[36194]={textureFormat:re,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[be,33635]},t[36758]={textureFormat:re,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[ge]},t[35898]={textureFormat:re,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[Pe,Ae,35899]},t[35901]={textureFormat:re,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[Pe,Ae,35902]},t[34843]={textureFormat:re,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[Pe,Ae]},t[34837]={textureFormat:re,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[Pe]},t[36221]={textureFormat:_e,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[be]},t[36239]={textureFormat:_e,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[ge]},t[36215]={textureFormat:_e,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[we]},t[36233]={textureFormat:_e,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[ye]},t[36209]={textureFormat:_e,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[Ee]},t[36227]={textureFormat:_e,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[xe]},t[32856]={textureFormat:ie,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[be]},t[35907]={textureFormat:ie,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[be]},t[36759]={textureFormat:ie,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[ge]},t[32855]={textureFormat:ie,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[be,32820,Me]},t[32854]={textureFormat:ie,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[be,32819]},t[32857]={textureFormat:ie,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[Me]},t[34842]={textureFormat:ie,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[Pe,Ae]},t[34836]={textureFormat:ie,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[Pe]},t[36220]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[be]},t[36238]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},t[36975]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Me]},t[36214]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[we]},t[36232]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ye]},t[36226]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[xe]},t[36208]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[Ee]},t[33189]={textureFormat:oe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[we,Ee]},t[33190]={textureFormat:oe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ee]},t[36012]={textureFormat:oe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Pe]},t[35056]={textureFormat:34041,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[34042]},t[36013]={textureFormat:34041,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[36269]},Object.keys(t).forEach((function(e){const n=t[e];n.bytesPerElementMap={},n.bytesPerElement.forEach((function(t,e){const r=n.type[e];n.bytesPerElementMap[r]=t}))})),Oe=t}return Oe[t]}function je(t){const e=ke(t);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function Ce(t){return 0==(t&t-1)}function ze(t,e,n,r,i){if(i%1!=0)throw"can't guess dimensions";if(n||r){if(r){if(!n&&(n=i/r)%1)throw"can't guess dimensions"}else if((r=i/n)%1)throw"can't guess dimensions"}else{const t=Math.sqrt(i/(e===ce?6:1));t%1==0?(n=t,r=t):(n=i,r=1)}return{width:n,height:r}}function De(t,e){void 0!==e.colorspaceConversion&&t.pixelStorei(37443,e.colorspaceConversion),void 0!==e.premultiplyAlpha&&t.pixelStorei(37441,e.premultiplyAlpha),void 0!==e.flipY&&t.pixelStorei(37440,e.flipY)}function Ue(t){t.pixelStorei(ve,4),Zt(t)&&(t.pixelStorei(3314,0),t.pixelStorei(32878,0),t.pixelStorei(3316,0),t.pixelStorei(3315,0),t.pixelStorei(32877,0))}function Ve(t,e,n,r){var i;r.minMag&&(n.call(t,e,de,r.minMag),n.call(t,e,me,r.minMag)),r.min&&n.call(t,e,de,r.min),r.mag&&n.call(t,e,me,r.mag),r.wrap&&(n.call(t,e,fe,r.wrap),n.call(t,e,pe,r.wrap),(e===he||(i=e,"undefined"!=typeof WebGLSampler&&D(i,"WebGLSampler")))&&n.call(t,e,32882,r.wrap)),r.wrapR&&n.call(t,e,32882,r.wrapR),r.wrapS&&n.call(t,e,fe,r.wrapS),r.wrapT&&n.call(t,e,pe,r.wrapT),r.minLod&&n.call(t,e,33082,r.minLod),r.maxLod&&n.call(t,e,33083,r.maxLod),r.baseLevel&&n.call(t,e,33084,r.baseLevel),r.maxLevel&&n.call(t,e,33085,r.maxLevel)}function Be(t,e,n){const r=n.target||ae;t.bindTexture(r,e),Ve(t,r,t.texParameteri,n)}function He(t,e,n,r,i,o){n=n||te.textureOptions,o=o||ie;const s=n.target||ae;if(r=r||n.width,i=i||n.height,t.bindTexture(s,e),function(t,e,n,r){if(!Zt(t))return Ce(e)&&Ce(n);const i=ke(r);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}(t,r,i,o))t.generateMipmap(s);else{const e=function(t){const e=ke(t);if(!e)throw"unknown internal format";return e.textureFilterable}(o)?9729:9728;t.texParameteri(s,de,e),t.texParameteri(s,me,e),t.texParameteri(s,fe,se),t.texParameteri(s,pe,se)}}function We(t){return!0===t.auto||void 0===t.auto&&void 0===t.level}function $e(t,e){return(e=e||{}).cubeFaceOrder||[ue,34070,34071,34072,34073,34074]}function qe(t,e){const n=$e(0,e).map((function(t,e){return{face:t,ndx:e}}));return n.sort((function(t,e){return t.face-e.face})),n}function Ne(t,e,n,r){const i=(r=r||te.textureOptions).target||ae,o=r.level||0;let s=n.width,a=n.height;const c=r.internalFormat||r.format||ie,h=je(c),l=r.format||h.format,u=r.type||h.type;if(De(t,r),t.bindTexture(i,e),i===ce){const h=n.width,d=n.height;let m,f;if(h/6===d)m=d,f=[0,0,1,0,2,0,3,0,4,0,5,0];else if(d/6===h)m=h,f=[0,0,0,1,0,2,0,3,0,4,0,5];else if(h/3==d/2)m=h/3,f=[0,0,1,0,2,0,0,1,1,1,2,1];else{if(h/2!=d/3)throw"can't figure out cube map from element: "+(n.src?n.src:n.nodeName);m=h/2,f=[0,0,1,0,0,1,1,1,0,2,1,2]}const p=ne();p?(p.canvas.width=m,p.canvas.height=m,s=m,a=m,qe(0,r).forEach((function(e){const r=f[2*e.ndx+0]*m,i=f[2*e.ndx+1]*m;p.drawImage(n,r,i,m,m,0,0,m,m),t.texImage2D(e.face,o,c,l,u,p.canvas)})),p.canvas.width=1,p.canvas.height=1):"undefined"!=typeof createImageBitmap&&(s=m,a=m,qe(0,r).forEach((function(h){const d=f[2*h.ndx+0]*m,p=f[2*h.ndx+1]*m;t.texImage2D(h.face,o,c,m,m,0,l,u,null),createImageBitmap(n,d,p,m,m,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then((function(n){De(t,r),t.bindTexture(i,e),t.texImage2D(h.face,o,c,l,u,n),We(r)&&He(t,e,r,s,a,c)}))})))}else if(i===he||i===le){const e=Math.min(n.width,n.height),r=Math.max(n.width,n.height),s=r/e;if(s%1!=0)throw"can not compute 3D dimensions of element";const a=n.width===r?1:0,h=n.height===r?1:0;t.pixelStorei(ve,1),t.pixelStorei(3314,n.width),t.pixelStorei(32878,0),t.pixelStorei(32877,0),t.texImage3D(i,o,c,e,e,e,0,l,u,null);for(let r=0;r<s;++r){const s=r*e*a,c=r*e*h;t.pixelStorei(3316,s),t.pixelStorei(3315,c),t.texSubImage3D(i,o,0,0,r,e,e,1,l,u,n)}Ue(t)}else t.texImage2D(i,o,c,l,u,n);We(r)&&He(t,e,r,s,a,c),Be(t,e,r)}function Xe(){}function Ge(t,e){return void 0!==e||function(t){if("undefined"!=typeof document){const e=document.createElement("a");return e.href=t,e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol}{const e=new URL(location.href).origin;return new URL(t,location.href).origin===e}}(t)?e:"anonymous"}function Ye(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof ImageData&&t instanceof ImageData||"undefined"!=typeof HTMLElement&&t instanceof HTMLElement}function Qe(t,e,n){return Ye(t)?(setTimeout((function(){n(null,t)})),t):function(t,e,n){let r;if(n=n||Xe,e=void 0!==e?e:te.crossOrigin,e=Ge(t,e),"undefined"!=typeof Image){r=new Image,void 0!==e&&(r.crossOrigin=e);const i=function(){r.removeEventListener("error",o),r.removeEventListener("load",s),r=null},o=function(){const e="couldn't load image: "+t;j(e),n(e,r),i()},s=function(){n(null,r),i()};return r.addEventListener("error",o),r.addEventListener("load",s),r.src=t,r}if("undefined"!=typeof ImageBitmap){let i,o;const s=function(){n(i,o)},a={};e&&(a.mode="cors"),fetch(t,a).then((function(t){if(!t.ok)throw t;return t.blob()})).then((function(t){return createImageBitmap(t,{premultiplyAlpha:"none",colorSpaceConversion:"none"})})).then((function(t){o=t,setTimeout(s)})).catch((function(t){i=t,setTimeout(s)})),r=null}return r}(t,e,n)}function Je(t,e,n){const r=(n=n||te.textureOptions).target||ae;if(t.bindTexture(r,e),!1===n.color)return;const i=function(t){return t=t||te.textureColor,ee(t)?t:new Uint8Array([255*t[0],255*t[1],255*t[2],255*t[3]])}(n.color);if(r===ce)for(let e=0;e<6;++e)t.texImage2D(ue+e,0,ie,1,1,0,ie,be,i);else r===he||r===le?t.texImage3D(r,0,ie,1,1,1,0,ie,be,i):t.texImage2D(r,0,ie,1,1,0,ie,be,i)}function Ze(t,e,n,r){r=r||Xe;const i=n.src;if(6!==i.length)throw"there must be 6 urls for a cubemap";const o=n.level||0,s=n.internalFormat||n.format||ie,a=je(s),c=n.format||a.format,h=n.type||be,l=n.target||ae;if(l!==ce)throw"target must be TEXTURE_CUBE_MAP";Je(t,e,n),n=Object.assign({},n);let u=6;const d=[],m=$e(0,n);let f;f=i.map((function(i,a){return Qe(i,n.crossOrigin,(p=m[a],function(i,a){--u,i?d.push(i):a.width!==a.height?d.push("cubemap face img is not a square: "+a.src):(De(t,n),t.bindTexture(l,e),5===u?$e().forEach((function(e){t.texImage2D(e,o,s,c,h,a)})):t.texImage2D(p,o,s,c,h,a),We(n)&&t.generateMipmap(l)),0===u&&r(d.length?d:void 0,e,f)}));var p}))}function Ke(t,e,n,r){r=r||Xe;const i=n.src,o=n.internalFormat||n.format||ie,s=je(o),a=n.format||s.format,c=n.type||be,h=n.target||le;if(h!==he&&h!==le)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";Je(t,e,n),n=Object.assign({},n);let l=i.length;const u=[];let d;const m=n.level||0;let f=n.width,p=n.height;const v=i.length;let g=!0;d=i.map((function(i,s){return Qe(i,n.crossOrigin,(b=s,function(i,s){if(--l,i)u.push(i);else{if(De(t,n),t.bindTexture(h,e),g){g=!1,f=n.width||s.width,p=n.height||s.height,t.texImage3D(h,m,o,f,p,v,0,a,c,null);for(let e=0;e<v;++e)t.texSubImage3D(h,m,0,0,e,f,p,1,a,c,s)}else{let e,n=s;s.width===f&&s.height===p||(e=ne(),n=e.canvas,e.canvas.width=f,e.canvas.height=p,e.drawImage(s,0,0,f,p)),t.texSubImage3D(h,m,0,0,b,f,p,1,a,c,n),e&&n===e.canvas&&(e.canvas.width=0,e.canvas.height=0)}We(n)&&t.generateMipmap(h)}0===l&&r(u.length?u:void 0,e,d)}));var b}))}function tn(t,e,n,r){const i=(r=r||te.textureOptions).target||ae;t.bindTexture(i,e);let o=r.width,s=r.height,a=r.depth;const c=r.level||0,h=r.internalFormat||r.format||ie,l=je(h),u=r.format||l.format,d=r.type||function(t,e,n){return ee(e)?O(e):n||be}(0,n,l.type);if(ee(n))n instanceof Uint8ClampedArray&&(n=new Uint8Array(n.buffer));else{const t=function(t){const e=R[t];if(!e)throw new Error("unknown gl type");return e}(d);n=new t(n)}const m=function(t,e){const n=ke(t);if(!n)throw"unknown internal format";const r=n.bytesPerElementMap[e];if(void 0===r)throw"unknown internal format";return r}(h,d),f=n.byteLength/m;if(f%1)throw"length wrong size for format: "+Kt(t,u);let p;if(i===he||i===le)if(o||s||a)!o||s&&a?!s||o&&a?(p=ze(0,i,o,s,f/a),o=p.width,s=p.height):(p=ze(0,i,o,a,f/s),o=p.width,a=p.height):(p=ze(0,i,s,a,f/o),s=p.width,a=p.height);else{const t=Math.cbrt(f);if(t%1!=0)throw"can't guess cube size of array of numElements: "+f;o=t,s=t,a=t}else p=ze(0,i,o,s,f),o=p.width,s=p.height;if(Ue(t),t.pixelStorei(ve,r.unpackAlignment||1),De(t,r),i===ce){const e=f/6*(m/n.BYTES_PER_ELEMENT);qe(0,r).forEach((r=>{const i=e*r.ndx,a=n.subarray(i,i+e);t.texImage2D(r.face,c,h,o,s,0,u,d,a)}))}else i===he||i===le?t.texImage3D(i,c,h,o,s,a,0,u,d,n):t.texImage2D(i,c,h,o,s,0,u,d,n);return{width:o,height:s,depth:a,type:d}}function en(t,e,n){n=n||Xe,e=e||te.textureOptions;const r=t.createTexture(),i=e.target||ae;let o=e.width||1,s=e.height||1;const a=e.internalFormat||ie;t.bindTexture(i,r),i===ce&&(t.texParameteri(i,fe,se),t.texParameteri(i,pe,se));let c=e.src;if(c)if("function"==typeof c&&(c=c(t,e)),"string"==typeof c)!function(t,e,n,r){r=r||Xe,n=n||te.textureOptions,Je(t,e,n),Qe((n=Object.assign({},n)).src,n.crossOrigin,(function(i,o){i?r(i,e,o):(Ne(t,e,o,n),r(null,e,o))}))}(t,r,e,n);else if(ee(c)||Array.isArray(c)&&("number"==typeof c[0]||Array.isArray(c[0])||ee(c[0]))){const n=tn(t,r,c,e);o=n.width,s=n.height}else Array.isArray(c)&&("string"==typeof c[0]||Ye(c[0]))?i===ce?Ze(t,r,e,n):Ke(t,r,e,n):(Ne(t,r,c,e),o=c.width,s=c.height);else!function(t,e,n){const r=n.target||ae;t.bindTexture(r,e);const i=n.level||0,o=n.internalFormat||n.format||ie,s=je(o),a=n.format||s.format,c=n.type||s.type;if(De(t,n),r===ce)for(let e=0;e<6;++e)t.texImage2D(ue+e,i,o,n.width,n.height,0,a,c,null);else r===he||r===le?t.texImage3D(r,i,o,n.width,n.height,n.depth,0,a,c,null):t.texImage2D(r,i,o,n.width,n.height,0,a,c,null)}(t,r,e);return We(e)&&He(t,r,e,o,s,a),Be(t,r,e),r}const nn=j;function rn(t){return"undefined"!=typeof document&&document.getElementById?document.getElementById(t):null}const on=33984,sn=34962,an=5126,cn=5124,hn=5125,ln=3553,un=34067,dn=32879,mn=35866,fn={};function pn(t,e){return fn[e].bindPoint}function vn(t,e){return function(n){t.uniform1i(e,n)}}function gn(t,e){return function(n){t.uniform1iv(e,n)}}function bn(t,e){return function(n){t.uniform2iv(e,n)}}function yn(t,e){return function(n){t.uniform3iv(e,n)}}function wn(t,e){return function(n){t.uniform4iv(e,n)}}function xn(t,e,n,r){const i=pn(0,e);return Zt(t)?function(e){let o,s;U(0,e)?(o=e,s=null):(o=e.texture,s=e.sampler),t.uniform1i(r,n),t.activeTexture(on+n),t.bindTexture(i,o),t.bindSampler(n,s)}:function(e){t.uniform1i(r,n),t.activeTexture(on+n),t.bindTexture(i,e)}}function En(t,e,n,r,i){const o=pn(0,e),s=new Int32Array(i);for(let t=0;t<i;++t)s[t]=n+t;return Zt(t)?function(e){t.uniform1iv(r,s),e.forEach((function(e,r){let i,a;t.activeTexture(on+s[r]),U(0,e)?(i=e,a=null):(i=e.texture,a=e.sampler),t.bindSampler(n,a),t.bindTexture(o,i)}))}:function(e){t.uniform1iv(r,s),e.forEach((function(e,n){t.activeTexture(on+s[n]),t.bindTexture(o,e)}))}}function Pn(t,e){return function(n){if(n.value)switch(t.disableVertexAttribArray(e),n.value.length){case 4:t.vertexAttrib4fv(e,n.value);break;case 3:t.vertexAttrib3fv(e,n.value);break;case 2:t.vertexAttrib2fv(e,n.value);break;case 1:t.vertexAttrib1fv(e,n.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else t.bindBuffer(sn,n.buffer),t.enableVertexAttribArray(e),t.vertexAttribPointer(e,n.numComponents||n.size,n.type||an,n.normalize||!1,n.stride||0,n.offset||0),t.vertexAttribDivisor&&t.vertexAttribDivisor(e,n.divisor||0)}}function An(t,e){return function(n){if(n.value){if(t.disableVertexAttribArray(e),4!==n.value.length)throw new Error("The length of an integer constant value must be 4!");t.vertexAttrib4iv(e,n.value)}else t.bindBuffer(sn,n.buffer),t.enableVertexAttribArray(e),t.vertexAttribIPointer(e,n.numComponents||n.size,n.type||cn,n.stride||0,n.offset||0),t.vertexAttribDivisor&&t.vertexAttribDivisor(e,n.divisor||0)}}function Fn(t,e){return function(n){if(n.value){if(t.disableVertexAttribArray(e),4!==n.value.length)throw new Error("The length of an unsigned integer constant value must be 4!");t.vertexAttrib4uiv(e,n.value)}else t.bindBuffer(sn,n.buffer),t.enableVertexAttribArray(e),t.vertexAttribIPointer(e,n.numComponents||n.size,n.type||hn,n.stride||0,n.offset||0),t.vertexAttribDivisor&&t.vertexAttribDivisor(e,n.divisor||0)}}function Mn(t,e,n){const r=n.size,i=n.count;return function(n){t.bindBuffer(sn,n.buffer);const o=n.size||n.numComponents||r,s=o/i,a=n.type||an,c=fn[a].size*o,h=n.normalize||!1,l=n.offset||0,u=c/i;for(let r=0;r<i;++r)t.enableVertexAttribArray(e+r),t.vertexAttribPointer(e+r,s,a,h,c,l+u*r),t.vertexAttribDivisor&&t.vertexAttribDivisor(e+r,n.divisor||0)}}fn[5126]={Type:Float32Array,size:4,setter:function(t,e){return function(n){t.uniform1f(e,n)}},arraySetter:function(t,e){return function(n){t.uniform1fv(e,n)}}},fn[35664]={Type:Float32Array,size:8,setter:function(t,e){return function(n){t.uniform2fv(e,n)}},cols:2},fn[35665]={Type:Float32Array,size:12,setter:function(t,e){return function(n){t.uniform3fv(e,n)}},cols:3},fn[35666]={Type:Float32Array,size:16,setter:function(t,e){return function(n){t.uniform4fv(e,n)}},cols:4},fn[5124]={Type:Int32Array,size:4,setter:vn,arraySetter:gn},fn[35667]={Type:Int32Array,size:8,setter:bn,cols:2},fn[35668]={Type:Int32Array,size:12,setter:yn,cols:3},fn[35669]={Type:Int32Array,size:16,setter:wn,cols:4},fn[5125]={Type:Uint32Array,size:4,setter:function(t,e){return function(n){t.uniform1ui(e,n)}},arraySetter:function(t,e){return function(n){t.uniform1uiv(e,n)}}},fn[36294]={Type:Uint32Array,size:8,setter:function(t,e){return function(n){t.uniform2uiv(e,n)}},cols:2},fn[36295]={Type:Uint32Array,size:12,setter:function(t,e){return function(n){t.uniform3uiv(e,n)}},cols:3},fn[36296]={Type:Uint32Array,size:16,setter:function(t,e){return function(n){t.uniform4uiv(e,n)}},cols:4},fn[35670]={Type:Uint32Array,size:4,setter:vn,arraySetter:gn},fn[35671]={Type:Uint32Array,size:8,setter:bn,cols:2},fn[35672]={Type:Uint32Array,size:12,setter:yn,cols:3},fn[35673]={Type:Uint32Array,size:16,setter:wn,cols:4},fn[35674]={Type:Float32Array,size:32,setter:function(t,e){return function(n){t.uniformMatrix2fv(e,!1,n)}},rows:2,cols:2},fn[35675]={Type:Float32Array,size:48,setter:function(t,e){return function(n){t.uniformMatrix3fv(e,!1,n)}},rows:3,cols:3},fn[35676]={Type:Float32Array,size:64,setter:function(t,e){return function(n){t.uniformMatrix4fv(e,!1,n)}},rows:4,cols:4},fn[35685]={Type:Float32Array,size:32,setter:function(t,e){return function(n){t.uniformMatrix2x3fv(e,!1,n)}},rows:2,cols:3},fn[35686]={Type:Float32Array,size:32,setter:function(t,e){return function(n){t.uniformMatrix2x4fv(e,!1,n)}},rows:2,cols:4},fn[35687]={Type:Float32Array,size:48,setter:function(t,e){return function(n){t.uniformMatrix3x2fv(e,!1,n)}},rows:3,cols:2},fn[35688]={Type:Float32Array,size:48,setter:function(t,e){return function(n){t.uniformMatrix3x4fv(e,!1,n)}},rows:3,cols:4},fn[35689]={Type:Float32Array,size:64,setter:function(t,e){return function(n){t.uniformMatrix4x2fv(e,!1,n)}},rows:4,cols:2},fn[35690]={Type:Float32Array,size:64,setter:function(t,e){return function(n){t.uniformMatrix4x3fv(e,!1,n)}},rows:4,cols:3},fn[35678]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:ln},fn[35680]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:un},fn[35679]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:dn},fn[35682]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:ln},fn[36289]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:mn},fn[36292]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:mn},fn[36293]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:un},fn[36298]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:ln},fn[36299]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:dn},fn[36300]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:un},fn[36303]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:mn},fn[36306]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:ln},fn[36307]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:dn},fn[36308]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:un},fn[36311]={Type:null,size:0,setter:xn,arraySetter:En,bindPoint:mn};const In={};In[5126]={size:4,setter:Pn},In[35664]={size:8,setter:Pn},In[35665]={size:12,setter:Pn},In[35666]={size:16,setter:Pn},In[5124]={size:4,setter:An},In[35667]={size:8,setter:An},In[35668]={size:12,setter:An},In[35669]={size:16,setter:An},In[5125]={size:4,setter:Fn},In[36294]={size:8,setter:Fn},In[36295]={size:12,setter:Fn},In[36296]={size:16,setter:Fn},In[35670]={size:4,setter:An},In[35671]={size:8,setter:An},In[35672]={size:12,setter:An},In[35673]={size:16,setter:An},In[35674]={size:4,setter:Mn,count:2},In[35675]={size:9,setter:Mn,count:3},In[35676]={size:16,setter:Mn,count:4};const Tn=/ERROR:\s*\d+:(\d+)/gi;const Sn=/^[ \t]*\n/;function Ln(t){let e=0;return Sn.test(t)&&(e=1,t=t.replace(Sn,"")),{lineOffset:e,shaderSource:t}}function _n(t,e){return t.errorCallback(e),t.callback&&setTimeout((()=>{t.callback(`${e}\n${t.errors.join("\n")}`)})),null}function Rn(t,e,n,r){const i=t.createShader(n);return t.shaderSource(i,Ln(e).shaderSource),t.compileShader(i),r.callback||function(t,e,n,r){r=r||nn;const i=t.getShaderParameter(n,35713);if(!i){const i=t.getShaderInfoLog(n),{lineOffset:o,shaderSource:s}=Ln(t.getShaderSource(n));r(`${function(t,e="",n=0){const r=[...e.matchAll(Tn)],i=new Map(r.map(((t,n)=>{const i=parseInt(t[1]),o=r[n+1],s=o?o.index:e.length;return[i-1,e.substring(t.index,s)]})));return t.split("\n").map(((t,e)=>{const r=i.get(e);return`${e+1+n}: ${t}${r?`\n\n^^^ ${r}`:""}`})).join("\n")}(s,i,o)}\nError compiling ${Kt(t,e)}: ${i}`)}return i}(t,n,i,r.errorCallback)?i:(t.deleteShader(i),null)}function On(t,e,n){let r,i,o;if("function"==typeof e&&(n=e,e=void 0),"function"==typeof t)n=t,t=void 0;else if(t&&!Array.isArray(t)){if(t.errorCallback&&t.errors)return t;const e=t;n=e.errorCallback,t=e.attribLocations,r=e.transformFeedbackVaryings,i=e.transformFeedbackMode,o=e.callback}const s=n||nn,a=[],c={errorCallback(t,...e){a.push(t),s(t,...e)},transformFeedbackVaryings:r,transformFeedbackMode:i,callback:o,errors:a};if(t){let n={};Array.isArray(t)?t.forEach((function(t,r){n[t]=e?e[r]:r})):n=t,c.attribLocations=n}return c}const kn=["VERTEX_SHADER","FRAGMENT_SHADER"];function jn(t,e){e.forEach((function(e){t.deleteShader(e)}))}const Cn=(t=0)=>new Promise((e=>setTimeout(e,t)));function zn(t,e,n,r,i){const o=On(n,r,i),s=[],a=[];for(let n=0;n<e.length;++n){let r=e[n];if("string"==typeof r){const e=rn(r),i=e?e.text:r;let s=t[kn[n]];e&&e.type&&(s=((h=e.type).indexOf("frag")>=0?35632:h.indexOf("vert")>=0?35633:void 0)||s),r=Rn(t,i,s,o),a.push(r)}c=r,"undefined"!=typeof WebGLShader&&D(c,"WebGLShader")&&s.push(r)}var c,h;if(s.length!==e.length)return jn(t,a),_n(o,"not enough shaders for program");const l=t.createProgram();s.forEach((function(e){t.attachShader(l,e)})),o.attribLocations&&Object.keys(o.attribLocations).forEach((function(e){t.bindAttribLocation(l,o.attribLocations[e],e)}));let u=o.transformFeedbackVaryings;return u&&(u.attribs&&(u=u.attribs),Array.isArray(u)||(u=Object.keys(u)),t.transformFeedbackVaryings(l,u,o.transformFeedbackMode||35981)),t.linkProgram(l),o.callback?(async function(t,e,n){const r=t.getExtension("KHR_parallel_shader_compile"),i=r?(t,e)=>t.getProgramParameter(e,r.COMPLETION_STATUS_KHR):()=>!0;let o=0;do{await Cn(o),o=1e3/60}while(!i(t,e));const s=Dn(t,e,n.errorCallback),a=s?void 0:n.errors.join("\n");if(!s){(n.errorCallback||nn)(a),t.deleteProgram(e),e=null}n.callback(a,e)}(t,l,o),null):Dn(t,l,o.errorCallback)?l:(t.deleteProgram(l),jn(t,a),null)}function Dn(t,e,n){n=n||nn;const r=t.getProgramParameter(e,35714);if(!r){n(`Error in program linking: ${t.getProgramInfoLog(e)}`)}return r}function Un(t){const e=t.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Vn=/(\.|\[|]|\w+)/g;function Bn(t,e,n,r){const i=t.split(Vn).filter((t=>""!==t));let o=0,s="";for(;;){const t=i[o++];s+=t;const c=(a=t[0])>="0"&&a<="9",h=c?parseInt(t):t;c&&(s+=i[o++]);if(o===i.length){n[h]=e;break}{const t=i[o++],e="["===t,a=n[h]||(e?[]:{});n[h]=a,n=a,r[s]=r[s]||function(t){return function(e){Hn(t,e)}}(a),s+=t}}var a}function Hn(t,e){for(const n in e){const r=t[n];"function"==typeof r?r(e[n]):Hn(t[n],e[n])}}function Wn(t,...e){const n=t.uniformSetters||t,r=e.length;for(let t=0;t<r;++t){const r=e[t];if(Array.isArray(r)){const t=r.length;for(let e=0;e<t;++e)Wn(n,r[e])}else for(const t in r){const e=n[t];e&&e(r[t])}}}function $n(t,e){const n=function(t,e){let n=0;function r(e,r,i){const o=r.name.endsWith("[0]"),s=r.type,a=fn[s];if(!a)throw new Error(`unknown type: 0x${s.toString(16)}`);let c;if(a.bindPoint){const e=n;n+=r.size,c=o?a.arraySetter(t,s,e,i,r.size):a.setter(t,s,e,i,r.size)}else c=a.arraySetter&&o?a.arraySetter(t,i):a.setter(t,i);return c.location=i,c}const i={},o={},s=t.getProgramParameter(e,35718);for(let n=0;n<s;++n){const s=t.getActiveUniform(e,n);if(Un(s))continue;let a=s.name;a.endsWith("[0]")&&(a=a.substr(0,a.length-3));const c=t.getUniformLocation(e,s.name);if(c){const t=r(0,s,c);i[a]=t,Bn(a,t,o,i)}}return i}(t,e),r=function(t,e){const n={},r=t.getProgramParameter(e,35721);for(let i=0;i<r;++i){const r=t.getActiveAttrib(e,i);if(Un(r))continue;const o=t.getAttribLocation(e,r.name),s=In[r.type],a=s.setter(t,o,s);a.location=o,n[r.name]=a}return n}(t,e),i={program:e,uniformSetters:n,attribSetters:r};return Zt(t)&&(i.uniformBlockSpec=function(t,e){const n=t.getProgramParameter(e,35718),r=[],i=[];for(let o=0;o<n;++o){i.push(o),r.push({});const n=t.getActiveUniform(e,o);r[o].name=n.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach((function(n){const o=n[0],s=n[1];t.getActiveUniforms(e,i,t[o]).forEach((function(t,e){r[e][s]=t}))}));const o={},s=t.getProgramParameter(e,35382);for(let n=0;n<s;++n){const r=t.getActiveUniformBlockName(e,n),i={index:t.getUniformBlockIndex(e,r),usedByVertexShader:t.getActiveUniformBlockParameter(e,n,35396),usedByFragmentShader:t.getActiveUniformBlockParameter(e,n,35398),size:t.getActiveUniformBlockParameter(e,n,35392),uniformIndices:t.getActiveUniformBlockParameter(e,n,35395)};i.used=i.usedByVertexShader||i.usedByFragmentShader,o[r]=i}return{blockSpecs:o,uniformData:r}}(t,e),i.transformFeedbackInfo=function(t,e){const n={},r=t.getProgramParameter(e,35971);for(let i=0;i<r;++i){const r=t.getTransformFeedbackVarying(e,i);n[r.name]={index:i,type:r.type,size:r.size}}return n}(t,e)),i}const qn=/\s|{|}|;/;function Nn(t,e,n,r,i){const o=On(n,r,i),s=[];if(e=e.map((function(t){if(!qn.test(t)){const e=rn(t);if(e)t=e.text;else{const e=`no element with id: ${t}`;o.errorCallback(e),s.push(e)}}return t})),s.length)return _n(o,"");const a=o.callback;a&&(o.callback=(e,n)=>{let r;e||(r=$n(t,n)),a(e,r)});const c=function(t,e,n,r,i){const o=On(n,r,i),s=[];for(let n=0;n<e.length;++n){const r=Rn(t,e[n],t[kn[n]],o);if(!o.callback&&!r)return null;s.push(r)}return zn(t,s,o)}(t,e,o);return c?$n(t,c):null}const Xn=/^(.*?)_/;function Gn(t,e){Kt(t,0);const n=t.getExtension(e);if(n){const r={},i=Xn.exec(e)[1],o="_"+i;for(const e in n){const s=n[e],a="function"==typeof s,c=a?i:o;let h=e;e.endsWith(c)&&(h=e.substring(0,e.length-c.length)),void 0!==t[h]?a||t[h]===s||C(h,t[h],s,e):a?t[h]=function(t){return function(){return t.apply(n,arguments)}}(s):(t[h]=s,r[h]=s)}r.constructor={name:n.constructor.name},Kt(r,0)}return n}const Yn=["ANGLE_instanced_arrays","EXT_blend_minmax","EXT_color_buffer_float","EXT_color_buffer_half_float","EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2","EXT_frag_depth","EXT_sRGB","EXT_shader_texture_lod","EXT_texture_filter_anisotropic","OES_element_index_uint","OES_standard_derivatives","OES_texture_float","OES_texture_float_linear","OES_texture_half_float","OES_texture_half_float_linear","OES_vertex_array_object","WEBGL_color_buffer_float","WEBGL_compressed_texture_atc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_depth_texture","WEBGL_draw_buffers"];function Qn(t){for(let e=0;e<Yn.length;++e)Gn(t,Yn[e])}function Jn(t,e){const n=function(t,e){const n=["webgl2","webgl","experimental-webgl"];let r=null;for(let i=0;i<n.length;++i)if(r=t.getContext(n[i],e),r){Qn(r);break}return r}(t,e);return n}class Zn{constructor(){var t;this.element=document.createElement("canvas"),this.element.classList.add("ls-viewer-canvas"),this.element.style.opacity="0",this.context=Jn(this.element,{preserveDrawingBuffer:!0}),t=[1,1,1,1],te.textureColor=new Uint8Array([255*t[0],255*t[1],255*t[2],255*t[3]])}show(){this.element.style.opacity="1"}hide(){this.element.style.opacity="0"}resize(t,e,n){this.element.width=t*n,this.element.height=e*n,this.element.style.width=`${t}px`,this.element.style.height=`${e}px`}}class Kn{static accelerate(t,e){const n=e||1.5;return Math.abs(t)**n*(t>0?1:-1)}static degreesToRadians(t){return t*(Math.PI/180)}static radiansToDegrees(t){return t*(180/Math.PI)}static mod(t,e){return t-e*Math.floor(t/e)}static perspectiveWithFovX(t,e,n,r,i){const o=Math.tan(t/2),s=o/e;return this.perspectiveWithLeft(-o,o,-s,s,n,r,i)}static perspectiveWithFovY(t,e,n,r,i){const o=n*Math.tan(t/2),s=o*e;return this.perspectiveWithLeft(-s,s,-o,o,n,r,i)}static perspectiveWithLeft(t,e,n,r,i,o,s){const a=e+t,c=e-t,h=r+n,l=r-n,u=o-i;return(s=s||new Float32Array(16))[0]=2*i/c,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2*i/l,s[6]=0,s[7]=0,s[8]=a/c,s[9]=h/l,s[10]=-o/u,s[11]=-1,s[12]=0,s[13]=0,s[14]=-o*i/u,s[15]=0,s}}class tr{constructor(){}async animation(t){return t.scene}async image(t){return t.scene}async video(t){return t.scene}async vrCube(t){return t.scene}async vrObject(t){return t.scene}}class er{constructor(t){this.server=t}static buildQuery(t){return Object.entries(t).filter((([t,e])=>null!=e)).map((([t,e])=>`${t}=${e}`)).join("&")}static sceneParameters(t){var e,n;const r=t.scene,i=r.length>1?r.find((t=>t.accessory)):null,o=r.length>1?r.find((t=>t.decor)):null,s=r.find((t=>t!==i&&t!==o));return{databaseId:s.database,configuration:null==s?void 0:s.configuration,animations:null===(e=null==s?void 0:s.animations)||void 0===e?void 0:e.join("/"),accessoryDatabaseId:null==i?void 0:i.database,decorDatabaseId:null==o?void 0:o.database,decorDeltaAltitude:null===(n=null==o?void 0:o.translation)||void 0===n?void 0:n.y}}static renderParameters(t){const{parameters:e,view:n}=t;return{background:n.background,width:e.width,height:e.height,softwareAntialiasing:e.antialiasing,superSampling:e.superSampling}}static encoderParameters(t){const{encoder:e}=t;return{imageFormat:e.format,imageQuality:e.quality}}static async fetch(t){return fetch(t).then((t=>t.text())).then((t=>{const e=t.replace(/&/g,"&").match(this.xmlRegex);return e?e.map((t=>t.replace(this.xmlRegex,"$1"))):Promise.reject()}))}async animation(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},er.sceneParameters(t)),{animation:t.view.animation,bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],frames:t.view.frames,loop:!!t.view.loop}),er.renderParameters(t)),er.encoderParameters(t)),n=er.buildQuery(e);return er.fetch(`${this.server}/ImagesFromAnimation?${n}`)}async image(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},er.sceneParameters(t)),{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1]}),er.renderParameters(t)),er.encoderParameters(t)),n=er.buildQuery(e);return Promise.resolve(`${this.server}/ImageFromBookmark?${n}`)}async video(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},er.sceneParameters(t)),{animation:t.view.animation,bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1],duration:t.view.duration,frames:t.view.frames,loop:!!t.view.loop,reverse:!!t.view.reverse}),er.renderParameters(t)),er.encoderParameters(t)),n=er.buildQuery(e);return Promise.resolve(`${this.server}/ImagesFromAnimation?${n}`)}async vrCube(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},er.sceneParameters(t)),{bookmarkSet:t.view.camera.split("/")[0],bookmark:t.view.camera.split("/")[1]}),er.renderParameters(t)),er.encoderParameters(t));e.width=Math.max(e.width,e.height),e.height=Math.max(e.width,e.height);const n=er.buildQuery(e);return er.fetch(`${this.server}/CubeFromBookmark?${n}`)}async vrObject(t){const e=Object.assign(Object.assign(Object.assign(Object.assign({},er.sceneParameters(t)),{bookmarkSet:t.view.camera}),er.renderParameters(t)),er.encoderParameters(t)),n=er.buildQuery(e);return er.fetch(`${this.server}/ImagesFromBookmarkSet?${n}`)}}er.xmlRegex=/directUrl="([^"]*)"/g;class nr{constructor(t){this.server=t}static scene(t){return t.scene.map((t=>{const e=
|
|
5
|
-
/*! *****************************************************************************
|
|
6
|
-
Copyright (c) Microsoft Corporation.
|
|
7
|
-
|
|
8
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
-
purpose with or without fee is hereby granted.
|
|
10
|
-
|
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */
|
|
19
|
-
function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(t,["accessory","decor"]);return e}))}static renderParameters(t){return Object.assign(Object.assign({},t.parameters),{superSampling:t.parameters.superSampling.toString()})}static encoder(t){switch(t.encoder.format){case"jpeg":return{jpeg:{quality:t.encoder.quality}};case"png":return{png:{compression:t.encoder.compression}};case"webp":return{webp:{quality:t.encoder.quality}}}return{jpeg:{quality:80}}}static async fetchFrame(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t.url))}static async fetchFrameArray(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t.map((t=>t.url))))}static async fetchHotspots(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t))}static async fetchHotspotsArray(t,e){return fetch(t,{method:"POST",body:JSON.stringify(e)}).then((t=>t.json())).then((t=>t))}async image(t){const e={scene:nr.scene(t),mode:{image:{camera:t.view.camera}},renderParameters:nr.renderParameters(t),encoder:nr.encoder(t)};return nr.fetchFrame(`${this.server}/Snapshot`,e)}async vrCube(t){const e={scene:nr.scene(t),mode:{vrCube:{camera:t.view.camera}},renderParameters:nr.renderParameters(t),encoder:nr.encoder(t)};return e.renderParameters.width=Math.max(e.renderParameters.width,e.renderParameters.height),e.renderParameters.height=Math.max(e.renderParameters.width,e.renderParameters.height),nr.fetchFrameArray(`${this.server}/Snapshot`,e)}async vrObject(t){let e;e=t.view.cameraGroup?{images:{cameraGroup:t.view.cameraGroup}}:t.view.frames?{vrObject:{camera:t.view.camera,frames:t.view.frames}}:{vrObject:{camera:t.view.camera,panFrames:t.view.panFrames||1,panFrom:t.view.panFrom||0,panTo:t.view.panTo||0,panLoop:t.view.panLoop||!1,tiltFrames:t.view.tiltFrames||1,tiltFrom:t.view.tiltFrom||0,tiltTo:t.view.tiltTo||0,tiltLoop:t.view.tiltLoop||!1}};const n={scene:nr.scene(t),mode:e,renderParameters:nr.renderParameters(t),encoder:nr.encoder(t)};return nr.fetchFrameArray(`${this.server}/Snapshot`,n)}async animation(t){const e={scene:nr.scene(t),mode:{animation:{id:t.view.animation,camera:t.view.camera,fps:t.view.fps}},renderParameters:nr.renderParameters(t),encoder:nr.encoder(t)};return nr.fetchFrameArray(`${this.server}/Snapshot`,e)}async imageHotspots(t,e){const n={scene:nr.scene(t),mode:{image:{camera:t.view.camera}},renderParameters:nr.renderParameters(t),tags:e};return await nr.fetchHotspots(`${this.server}/Hotspot`,n)}async vrCubeHotspots(t,e){const n={scene:nr.scene(t),mode:{vrCube:{camera:t.view.camera}},renderParameters:nr.renderParameters(t),tags:e};return n.renderParameters.width=Math.max(n.renderParameters.width,n.renderParameters.height),n.renderParameters.height=Math.max(n.renderParameters.width,n.renderParameters.height),await nr.fetchHotspotsArray(`${this.server}/Hotspot`,n)}async vrObjectHotspots(t,e){let n;n=t.view.cameraGroup?{images:{cameraGroup:t.view.cameraGroup}}:t.view.frames?{vrObject:{camera:t.view.camera,frames:t.view.frames}}:{vrObject:{camera:t.view.camera,panFrames:t.view.panFrames||1,panFrom:t.view.panFrom||0,panTo:t.view.panTo||0,panLoop:t.view.panLoop||!1,tiltFrames:t.view.tiltFrames||1,tiltFrom:t.view.tiltFrom||0,tiltTo:t.view.tiltTo||0,tiltLoop:t.view.tiltLoop||!1}};const r={scene:nr.scene(t),mode:n,renderParameters:nr.renderParameters(t),tags:e};return await nr.fetchHotspotsArray(`${this.server}/Hotspot`,r)}}class rr{constructor(t,e,n){switch(e){case"static":this.webrender=new tr;break;case"v1":default:this.webrender=new er(t);break;case"v2":this.webrender=new nr(t)}this.delegate=n,this.loadingId=0,this.loaded=0,this.total=0,this.onLoadStart=n&&n.onLoadStart?n.onLoadStart:()=>{},this.onLoadProgress=n&&n.onLoadProgress?n.onLoadProgress:()=>{},this.onLoadEnd=n&&n.onLoadEnd?n.onLoadEnd:()=>{}}get progress(){return this.total?this.loaded/this.total:0}async loadImageSnapshot(t){this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);const{loadingId:e}=this;return this.webrender.image(t).then((t=>this.loadImage(t,e))).then((t=>(this.onLoadEnd(this.progress),t)))}async loadVideoSnapshot(t,e){this.loadingId+=1,this.loaded=0,this.total=1,this.onLoadStart(this.progress);const{loadingId:n}=this;return this.webrender.video(e).then((r=>this.loadVideo(t,r,!!e.view.loop,n))).then((()=>(this.onLoadEnd(this.progress),t)))}async loadVRCubeSnapshot(t){this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);const{loadingId:e}=this;return this.webrender.vrCube(t).then((t=>{this.total=t.length;const n=t.map((t=>this.loadImage(t,e)));return Promise.all(n)})).then((t=>(this.onLoadEnd(this.progress),t)))}async loadVRObjectSnapshot(t,e){var n;this.loadingId+=1,this.loaded=0,this.total=0,this.onLoadStart(this.progress);const{loadingId:r}=this;return t.view.animation?"mp4"===(null===(n=t.encoder)||void 0===n?void 0:n.format)?this.webrender.video(t).then((e=>this.loadVideoFrames(e,t.view.frames,30,r))):this.webrender.animation(t).then((n=>this.loadImageFrames(n,t.view.loop,e,r))):this.webrender.vrObject(t).then((n=>this.loadImageFrames(n,t.view.loop,e,r)))}async loadImage(t,e){const n=new Image;n.crossOrigin="file:"!==location.protocol||rr.isValidHttpUrl(t)?"anonymous":null;const r=new Promise(((r,i)=>{n.addEventListener("load",(()=>{e===this.loadingId&&(this.loaded+=1,this.onLoadProgress(this.progress),r(n))}),{once:!0}),n.addEventListener("error",(n=>{e===this.loadingId&&i(`${n.type} : ${t}`)}),{once:!0})}));return n.src=t,r}loadImageFrames(t,e,n,r){this.total=t.length;const i=new Array(t.length),o=n||0;for(let n=0,s=t.length;n<s;n+=1){const a=Math.ceil(n/2)*(n%2==0?1:-1),c=e?Kn.mod(o+a,s):n;i[c]=this.loadImage(t[c],r)}return Promise.all(i).then((()=>this.onLoadEnd(this.progress))).catch((()=>{})),i}async loadVideo(t,e,n,r){t.loop=n;const i=new Promise(((n,i)=>{t.addEventListener("canplaythrough",(()=>{r===this.loadingId&&(this.loaded+=1,this.onLoadProgress(this.progress),n())}),{once:!0}),t.addEventListener("error",(t=>{r===this.loadingId&&i(`${t.type} : ${e}`)}),{once:!0})}));return t.src=e,t.load(),i}async loadVideoFrame(t,e,n,r,i){let o=0;return new Promise(((s,a)=>{const c=()=>{if(i!==this.loadingId)return;if(o!==r)return void(o+=1);t.removeEventListener("seeked",c);const a=document.createElement("canvas");a.width=t.videoWidth,a.height=t.videoHeight;a.getContext("2d").drawImage(t,0,0);const h=new Image;h.src=a.toDataURL(),s(h),this.loaded+=1,this.onLoadProgress(this.progress),r!==n-1&&(t.currentTime+=1/e)};t.addEventListener("seeked",c),t.addEventListener("error",(t=>{i===this.loadingId&&a(t)}),{once:!0})}))}loadVideoFrames(t,e,n,r){this.total=e;const i=new Array(e),o=document.createElement("video");for(let t=0,s=e;t<s;t+=1)i[t]=this.loadVideoFrame(o,n,e,t,r);return o.addEventListener("canplaythrough",(()=>{r===this.loadingId&&(o.currentTime=1/n/2)}),{once:!0}),o.src=t,o.load(),Promise.all(i).then((()=>this.onLoadEnd(this.progress))).catch((()=>{})),i}async loadImageHotspots(t,e){return this.webrender instanceof nr?await this.webrender.imageHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}async loadVRCubeHotspots(t,e){return this.webrender instanceof nr?await this.webrender.vrCubeHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}async loadVRObjectHotspots(t,e){return this.webrender instanceof nr?await this.webrender.vrObjectHotspots(t,e):Promise.reject(new Error("Hotspots only available with api V2"))}onLoadStart(t){this.delegate&&this.delegate.onLoadStart(t)}onLoadProgress(t){this.delegate&&this.delegate.onLoadProgress(t)}onLoadEnd(t){this.delegate&&this.delegate.onLoadEnd(t)}static isValidHttpUrl(t){let e;try{e=new URL(t)}catch(t){return!1}return"http:"===e.protocol||"https:"===e.protocol}}class ir{constructor(){this.element=document.createElement("video"),this.element.classList.add("ls-viewer-video"),this.element.style.opacity="0",this.element.setAttribute("muted",""),this.element.setAttribute("playsinline",""),this.element.setAttribute("preload","auto")}show(){this.element.style.opacity="1"}hide(){this.element.style.opacity="0"}resize(t,e,n,r){const s=o.fit(n,new i(t,e),r);this.element.style.top=`${s.top}px`,this.element.style.left=`${s.left}px`,this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,n.width===this.element.width&&n.height===this.element.height||(this.element.width=n.width,this.element.height=n.height)}}class or{constructor(t,e,n){this.container=t,this.canvas=e,this.loader=n,this.hotspots=[]}destroy(){}show(){this.canvas.show(!1),this.container.classList.add("ls-viewer-container-image")}hide(){this.canvas.hide(!1),this.container.classList.remove("ls-viewer-container-image")}async load(t,e,n,r){let i=Promise.resolve();const o=JSON.stringify(t);i=o===this.snapshotHash&&this.image?i.then((()=>this.canvas.draw(this.image,r,.05))):i.then((()=>this.loader.loadImageSnapshot(t).then((t=>{this.canvas.draw(t,r,.05),this.image=t}))));const s=JSON.stringify(e);return!e.length||o===this.snapshotHash&&s===this.tagsHash||(i=i.then((()=>this.loader.loadImageHotspots(t,e).then((t=>{this.hotspots=t}))))),this.snapshotHash=o,this.tagsHash=s,i.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}onMouseDown(t){}onMouseMove(t){}onMouseUp(t){}onMouseEnter(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}onDeviceOrientation(t){}}class sr{constructor(t,e,n){this.container=t,this.loader=n,this.video=e}destroy(){}show(){this.video.show(),this.container.classList.add("ls-viewer-container-video")}hide(){this.video.hide(),this.container.classList.remove("ls-viewer-container-video")}async load(t){const e=JSON.stringify(t);return e===this.hash?(this.video.element.load(),Promise.resolve([])):(this.hash=e,this.loader.loadVideoSnapshot(this.video.element,t).then((()=>Promise.resolve([]))))}snapshot(t,e){return"data:image/gif;base64,R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="}async play(){return new Promise(((t,e)=>{this.video.element.addEventListener("ended",(()=>{t()}),{once:!0}),this.video.element.play().catch(e),this.show()}))}onMouseDown(t){}onMouseMove(t){}onMouseUp(t){}onMouseEnter(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}onDeviceOrientation(t){}}class ar{constructor(t,e){this.x=t,this.y=e}clone(){return new ar(this.x,this.y)}}class cr{static pointFromMouseEvent(t){return new ar(t.screenX,t.screenY)}static pointFromTouchEvent(t){const e=t.targetTouches[0]||t.changedTouches[0];return new ar(e.screenX,e.screenY)}}class hr{constructor(...t){3===t.length?(({0:this.u,1:this.v,2:this.o}=t),this.w=f.cross(this.u,this.v)):4===t.length?({0:this.u,1:this.v,2:this.w,3:this.o}=t):(this.u=[1,0,0],this.v=[0,1,0],this.w=[0,0,1],this.o=[0,0,0])}get localToGlobalMatrix(){return[...[this.u[0],this.u[1],this.u[2],0],...[this.v[0],this.v[1],this.v[2],0],...[this.w[0],this.w[1],this.w[2],0],...[this.o[0],this.o[1],this.o[2],1]]}get globalToLocalMatrix(){return A.inverse(this.localToGlobalMatrix)}}class lr{constructor(t,e,n){this.x=t,this.y=e,this.time=n}}class ur{constructor(t){this.points=[],this.onMotion=t,this.lastPoint=new ar(0,0),this.velocity=new ar(0,0),this.loop=this.loop.bind(this)}destroy(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}track(t){const e=Date.now();this.points=this.points.filter((t=>e-t.time<=100)),this.points.push(new lr(t.x,t.y,e)),this.lastPoint=t}start(){if(0===this.points.length)return;const t=this.points[0],e=this.points[this.points.length-1],n=e.x-t.x,r=e.y-t.y,i=e.time-t.time;this.velocity=new ar(0===i?0:n/(i/15),0===i?0:r/(i/15)),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.animationFrameId=requestAnimationFrame(this.loop)}stop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0),this.points=[]}loop(){if(Math.abs(this.velocity.x)<1&&Math.abs(this.velocity.y)<1)return this.animationFrameId=void 0,void(this.points=[]);this.lastPoint.x+=this.velocity.x,this.lastPoint.y+=this.velocity.y,this.velocity.x*=.9,this.velocity.y*=.9,this.onMotion(this.lastPoint.clone()),this.animationFrameId=requestAnimationFrame(this.loop)}}class dr{constructor(t,e,n){this.target=f.copy(t),this.eye=f.copy(e),this.up=f.copy(n)}get viewVector(){return f.subtract(this.target,this.eye)}get rightVector(){return f.normalize(f.cross(this.viewVector,this.up))}get viewMatrix(){return A.inverse(A.lookAt(this.eye,this.target,this.up))}clone(){return new dr(f.copy(this.target),f.copy(this.eye),f.copy(this.up))}}dr.default=new dr([0,0,0],[2,2,2],[0,1,0]);class mr{constructor(t,e,n){this.isStarted=!1,this.pov=t,this.fov=Kn.degreesToRadians(e),this.orientationMatrix=A.identity(),this.inertia=new ur(this.motion.bind(this)),this.onMotion=n,this.initPov=this.pov,this.initFov=this.fov,this.initOrientation=Kn.degreesToRadians(window.orientation)||0,this.startPov=new dr([0,0,1],[0,0,0],[0,1,0]),this.startSize={width:0,height:0},this.previousPoint=new ar(0,0)}destroy(){this.inertia.destroy()}get orientedPov(){const t=f.normalize(f.cross(this.pov.up,this.pov.target)),e=new hr(t,[0,1,0],this.pov.eye),n=A.identity();A.multiply(n,e.localToGlobalMatrix,n),A.multiply(n,this.orientationMatrix,n),A.multiply(n,e.globalToLocalMatrix,n);const r=A.transformDirection(n,this.pov.target),i=this.pov.eye,o=A.transformDirection(n,this.pov.up);return new dr(r,i,o)}reset(){this.pov=this.initPov.clone(),this.fov=this.initFov}start(t,e){this.isStarted=!0,this.startPov=this.pov,this.startSize=e,this.previousPoint=t,this.inertia.stop()}motion(t){this.isStarted&&this.inertia.track(t);const e={x:t.x-this.previousPoint.x,y:t.y-this.previousPoint.y},n=Kn.accelerate(e.x,1.3)/this.startSize.width*.2*Math.PI*1.5,r=Kn.accelerate(e.y,1.3)/this.startSize.height*.2*Math.PI,i=A.multiply(A.rotationY(-n),A.rotationX(-r)),o=f.normalize(f.cross(this.pov.up,this.pov.target)),s=new hr(o,[0,1,0],this.pov.eye),a=A.identity();A.multiply(a,s.localToGlobalMatrix,a),A.multiply(a,i,a),A.multiply(a,s.globalToLocalMatrix,a);const c=A.transformPoint(a,this.pov.target),h=A.transformDirection(a,this.pov.up);f.cross(h,[0,0,1])[0]>=0&&(this.pov.target=c,this.pov.up=h),this.previousPoint=t,this.onMotion()}end(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())}orientation(t,e,n){const r=Kn.degreesToRadians(window.orientation)||0,i=Kn.degreesToRadians(t),o=Kn.degreesToRadians(-e),s=Kn.degreesToRadians(-n),a=A.rotationX(Kn.degreesToRadians(90));A.rotateZ(a,this.initOrientation,a),A.rotateZ(a,i,a),A.rotateX(a,o,a),A.rotateY(a,s,a),A.rotateZ(a,-r,a),this.orientationMatrix=a,this.onMotion()}}class fr{constructor(t,e,n,r){this.container=t,this.canvas=e,this.loader=n,this.images=[],this.hotspotsList=[[]];const i=new dr([0,0,1],[0,0,0],[0,1,0]),o=A.rotationX(Kn.degreesToRadians(15));A.transformDirection(o,i.target,i.target),A.transformDirection(o,i.up,i.up),this.interaction=new mr(i,60,(()=>{this.animationFrameId=requestAnimationFrame(this.render),this.onInteraction({pov:this.interaction.pov.clone(),fov:this.interaction.fov})})),this.onInteraction=r,this.gl=this.canvas.context,this.programInfo=Nn(this.gl,["attribute vec4 position;uniform mat4 u_matrix;varying vec3 direction;void main(){direction=(u_matrix*position).xyz;gl_Position=position*vec4(-1,1,1,1);}\n","precision mediump float;uniform float u_mix;uniform samplerCube u_texture;uniform samplerCube u_texture_back;varying vec3 direction;void main(){vec4 backColor=textureCube(u_texture_back,direction);vec4 color=textureCube(u_texture,direction);gl_FragColor=mix(backColor,color,u_mix);}\n"]),this.quad=Jt.createXYQuadBufferInfo(this.gl),this.uniforms={u_matrix:A.identity(),u_mix:0,u_texture_back:en(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1}),u_texture:en(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,width:1,height:1})},this.render=this.render.bind(this)}destroy(){this.interaction.destroy(),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}show(){this.canvas.show(),this.container.classList.add("ls-viewer-container-vrcube")}hide(){this.canvas.hide(),this.container.classList.remove("ls-viewer-container-vrcube")}get pov(){return this.interaction.pov}set pov(t){this.interaction.pov.eye.every(((e,n)=>e===t.eye[n]))&&this.interaction.pov.target.every(((e,n)=>e===t.target[n]))&&this.interaction.pov.up.every(((e,n)=>e===t.up[n]))||(this.interaction.pov=t.clone(),this.animationFrameId=requestAnimationFrame(this.render))}get fov(){return Kn.radiansToDegrees(this.interaction.fov)}set fov(t){this.interaction.fov!==t&&(this.interaction.fov=Kn.degreesToRadians(t),this.animationFrameId=requestAnimationFrame(this.render))}get hotspots(){const t=[];this.hotspotsList.flat();const e=this.canvas.element.clientWidth,n=this.canvas.element.clientHeight,r=A.inverse(this.modelViewProjectionMatrix);return this.hotspotsList.forEach(((i,o)=>{i.forEach((i=>{const s=i.position2D.x/this.images[0].width,a=i.position2D.y/this.images[0].height;let c=0,h=0,l=0;switch(o){case 0:if(this.pov.target[2]<0)return;c=2*s-1,h=-1*(2*a-1),l=1;break;case 1:if(this.pov.target[0]<0)return;c=1,h=-1*(2*a-1),l=1-2*s;break;case 2:if(this.pov.target[2]>0)return;c=1-2*s,h=-1*(2*a-1),l=-1;break;case 3:if(this.pov.target[0]>0)return;c=-1,h=-1*(2*a-1),l=2*s-1;break;case 4:if(this.pov.target[1]<0)return;c=2*s-1,h=1,l=2*a-1;break;case 5:if(this.pov.target[1]>0)return;c=2*s-1,h=-1,l=-1*(2*a-1)}const u=f.normalize([c,h,l]),d=A.transformPoint(r,u),m={x:e-.5*e*(d[0]+1),y:n-.5*n*(d[1]+1)};t.push(Object.assign(Object.assign({},i),{position2D:m}))}))})),t}async load(t,e,n,r){let i=Promise.resolve();const o=JSON.stringify(t);o===this.snapshotHash?i=i.then((()=>(this.animationFrameId=requestAnimationFrame(this.render),Promise.resolve()))):(this.images=[],this.animationFrameId=requestAnimationFrame(this.render),i=i.then((()=>this.loader.loadVRCubeSnapshot(t).then((t=>{this.images=t,en(this.gl,{target:this.gl.TEXTURE_CUBE_MAP,minMag:this.gl.LINEAR,auto:!1,cubeFaceOrder:[this.gl.TEXTURE_CUBE_MAP_POSITIVE_Z,this.gl.TEXTURE_CUBE_MAP_POSITIVE_X,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_X,this.gl.TEXTURE_CUBE_MAP_POSITIVE_Y,this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Y],src:t},((t,e)=>{t||(n&&this.interaction.reset(),this.uniforms.u_mix=r?0:1,this.uniforms.u_texture_back=this.uniforms.u_texture,this.uniforms.u_texture=e,this.animationFrameId=requestAnimationFrame(this.render))}))})))));const s=JSON.stringify(e);return!e.length||o===this.snapshotHash&&s===this.tagsHash||(i=i.then((()=>this.loader.loadVRCubeHotspots(t,e).then((t=>{this.hotspotsList=t}))))),this.snapshotHash=o,this.tagsHash=s,i.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}get modelViewProjectionMatrix(){const t=this.canvas.element.clientWidth,e=this.canvas.element.clientHeight,n=t>e?t/e:e/t,r=o.getStandardAspectRatio(t,e),i=this.interaction.fov*(r/n),s=t>e?Kn.perspectiveWithFovY(i,t/e,.5,100):Kn.perspectiveWithFovX(i,t/e,.5,100),a=A.inverse(s),c=this.interaction.orientedPov,h=A.lookAt(c.eye,c.target,c.up);return A.multiply(h,a)}render(){var t,e,n;this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.uniforms.u_matrix=this.modelViewProjectionMatrix,this.gl.useProgram(this.programInfo.program),t=this.gl,e=this.programInfo,(n=this.quad).vertexArrayObject?t.bindVertexArray(n.vertexArrayObject):(function(t,e){for(const n in e){const r=t[n];r&&r(e[n])}}(e.attribSetters||e,n.attribs),n.indices&&t.bindBuffer(34963,n.indices)),Wn(this.programInfo,this.uniforms),function(t,e,n,r,i,o){n=void 0===n?4:n;const s=e.indices,a=e.elementType,c=void 0===r?e.numElements:r;i=void 0===i?0:i,a||s?void 0!==o?t.drawElementsInstanced(n,c,void 0===a?5123:e.elementType,i,o):t.drawElements(n,c,void 0===a?5123:e.elementType,i):void 0!==o?t.drawArraysInstanced(n,i,c,o):t.drawArrays(n,i,c)}(this.gl,this.quad),this.uniforms.u_mix<1&&(this.uniforms.u_mix=Math.min(this.uniforms.u_mix+.05,1),this.animationFrameId=requestAnimationFrame(this.render))}onMouseDown(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(cr.pointFromMouseEvent(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})}onMouseMove(t){this.interaction.isStarted&&(this.interaction.motion(cr.pointFromMouseEvent(t)),t.preventDefault())}onMouseUp(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(cr.pointFromMouseEvent(t),!0))}onMouseEnter(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(cr.pointFromMouseEvent(t),!1))}onTouchStart(t){this.container.classList.add("ls-viewer-container-vrcube-grabbing"),this.interaction.start(cr.pointFromTouchEvent(t),{width:this.gl.canvas.width,height:this.gl.canvas.height})}onTouchMove(t){this.interaction.isStarted&&(this.interaction.motion(cr.pointFromTouchEvent(t)),t.preventDefault())}onTouchEnd(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrcube-grabbing"),this.interaction.end(cr.pointFromTouchEvent(t),!0))}onDeviceOrientation(t){this.interaction.orientation(t.alpha,t.beta,t.gamma)}}var pr={exports:{}};(function(t){function e(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function r(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}var i={order:2,precision:2,period:null};function o(t,e){var n=[],r=[];t.forEach((function(t,i){null!==t[1]&&(r.push(t),n.push(e[i]))}));var i=r.reduce((function(t,e){return t+e[1]}),0)/r.length,o=r.reduce((function(t,e){var n=e[1]-i;return t+n*n}),0);return 1-r.reduce((function(t,e,r){var i=n[r],o=e[1]-i[1];return t+o*o}),0)/o}function s(t,e){for(var n=t,r=t.length-1,i=[e],o=0;o<r;o++){for(var s=o,a=o+1;a<r;a++)Math.abs(n[o][a])>Math.abs(n[o][s])&&(s=a);for(var c=o;c<r+1;c++){var h=n[c][o];n[c][o]=n[c][s],n[c][s]=h}for(var l=o+1;l<r;l++)for(var u=r;u>=o;u--)n[u][l]-=n[u][o]*n[o][l]/n[o][o]}for(var d=r-1;d>=0;d--){for(var m=0,f=d+1;f<r;f++)m+=n[f][d]*i[f];i[d]=(n[r][d]-m)/n[d][d]}return i}function a(t,e){var n=Math.pow(10,e);return Math.round(t*n)/n}var c={linear:function(t,e){for(var n=[0,0,0,0,0],r=0,i=0;i<t.length;i++)null!==t[i][1]&&(r++,n[0]+=t[i][0],n[1]+=t[i][1],n[2]+=t[i][0]*t[i][0],n[3]+=t[i][0]*t[i][1],n[4]+=t[i][1]*t[i][1]);var s=r*n[2]-n[0]*n[0],c=r*n[3]-n[0]*n[1],h=0===s?0:a(c/s,e.precision),l=a(n[1]/r-h*n[0]/r,e.precision),u=function(t){return[a(t,e.precision),a(h*t+l,e.precision)]},d=t.map((function(t){return u(t[0])}));return{points:d,predict:u,equation:[h,l],r2:a(o(t,d),e.precision),string:0===l?"y = "+h+"x":"y = "+h+"x + "+l}},exponential:function(t,e){for(var n=[0,0,0,0,0,0],r=0;r<t.length;r++)null!==t[r][1]&&(n[0]+=t[r][0],n[1]+=t[r][1],n[2]+=t[r][0]*t[r][0]*t[r][1],n[3]+=t[r][1]*Math.log(t[r][1]),n[4]+=t[r][0]*t[r][1]*Math.log(t[r][1]),n[5]+=t[r][0]*t[r][1]);var i=n[1]*n[2]-n[5]*n[5],s=Math.exp((n[2]*n[3]-n[5]*n[4])/i),c=(n[1]*n[4]-n[5]*n[3])/i,h=a(s,e.precision),l=a(c,e.precision),u=function(t){return[a(t,e.precision),a(h*Math.exp(l*t),e.precision)]},d=t.map((function(t){return u(t[0])}));return{points:d,predict:u,equation:[h,l],string:"y = "+h+"e^("+l+"x)",r2:a(o(t,d),e.precision)}},logarithmic:function(t,e){for(var n=[0,0,0,0],r=t.length,i=0;i<r;i++)null!==t[i][1]&&(n[0]+=Math.log(t[i][0]),n[1]+=t[i][1]*Math.log(t[i][0]),n[2]+=t[i][1],n[3]+=Math.pow(Math.log(t[i][0]),2));var s=a((r*n[1]-n[2]*n[0])/(r*n[3]-n[0]*n[0]),e.precision),c=a((n[2]-s*n[0])/r,e.precision),h=function(t){return[a(t,e.precision),a(a(c+s*Math.log(t),e.precision),e.precision)]},l=t.map((function(t){return h(t[0])}));return{points:l,predict:h,equation:[c,s],string:"y = "+c+" + "+s+" ln(x)",r2:a(o(t,l),e.precision)}},power:function(t,e){for(var n=[0,0,0,0,0],r=t.length,i=0;i<r;i++)null!==t[i][1]&&(n[0]+=Math.log(t[i][0]),n[1]+=Math.log(t[i][1])*Math.log(t[i][0]),n[2]+=Math.log(t[i][1]),n[3]+=Math.pow(Math.log(t[i][0]),2));var s=(r*n[1]-n[0]*n[2])/(r*n[3]-Math.pow(n[0],2)),c=(n[2]-s*n[0])/r,h=a(Math.exp(c),e.precision),l=a(s,e.precision),u=function(t){return[a(t,e.precision),a(a(h*Math.pow(t,l),e.precision),e.precision)]},d=t.map((function(t){return u(t[0])}));return{points:d,predict:u,equation:[h,l],string:"y = "+h+"x^"+l,r2:a(o(t,d),e.precision)}},polynomial:function(t,e){for(var n=[],i=[],c=0,h=0,l=t.length,u=e.order+1,d=0;d<u;d++){for(var m=0;m<l;m++)null!==t[m][1]&&(c+=Math.pow(t[m][0],d)*t[m][1]);n.push(c),c=0;for(var f=[],p=0;p<u;p++){for(var v=0;v<l;v++)null!==t[v][1]&&(h+=Math.pow(t[v][0],d+p));f.push(h),h=0}i.push(f)}i.push(n);for(var g=s(i,u).map((function(t){return a(t,e.precision)})),b=function(t){return[a(t,e.precision),a(g.reduce((function(e,n,r){return e+n*Math.pow(t,r)}),0),e.precision)]},y=t.map((function(t){return b(t[0])})),w="y = ",x=g.length-1;x>=0;x--)w+=x>1?g[x]+"x^"+x+" + ":1===x?g[x]+"x + ":g[x];return{string:w,points:y,predict:b,equation:[].concat(r(g)).reverse(),r2:a(o(t,y),e.precision)}}};function h(){var t=function(t,r){return n({_round:a},t,e({},r,(function(t,e){return c[r](t,n({},i,e))})))};return Object.keys(c).reduce(t,{})}t.exports=h()})(pr);var vr=pr.exports;class gr{constructor(t,e,n,r,i){this.isStarted=!1,this.position=t,this.frames=e,this.rows=n,this.loop=r,this.onMotion=i,this.inertia=new ur(this.motion.bind(this)),this.initPosition=this.position,this.startPosition={x:0,y:0},this.startPoint=new ar(0,0),this.startSize={width:0,height:0},this.lastPoints=[],this.lastPointsNumber=20}destroy(){this.inertia.destroy()}reset(){this.position=this.initPosition}get positionIndex(){return this.frames*this.position.y+this.position.x}set positionIndex(t){if(this.positionIndex===t)return;const e=this.loop?Kn.mod(t,this.frames*this.rows):Math.max(0,Math.min(t,this.frames*this.rows));this.position.x=Kn.mod(e,this.frames),this.position.y=Math.floor(e/this.frames)}start(t,e){this.isStarted=!0,this.startPosition=Object.assign({},this.position),this.startPoint=t,this.startSize=e,this.lastPoints=[],this.inertia.stop()}motion(t){this.isStarted&&this.inertia.track(t),this.lastPoints.push({x:t.x,y:t.y}),this.lastPoints.splice(0,this.lastPoints.length-this.lastPointsNumber);const e=vr.linear(this.lastPoints.map((t=>[t.x,t.y])));if(Math.abs(e.equation[0])<1){const e=Kn.accelerate(t.x-this.startPoint.x,1.3)/this.startSize.width*(this.frames/4);let n=this.startPosition.x-Math.round(e);n=this.loop?Kn.mod(n,this.frames):Math.max(0,Math.min(n,this.frames-1)),n!==this.position.x&&(this.position.x=n,this.onMotion());const r=Math.min(...this.lastPoints.map((t=>t.x)));Math.max(...this.lastPoints.map((t=>t.x)))-r>25&&(this.startPoint.y=t.y,this.startPosition.y=this.position.y)}else{const e=Kn.accelerate(t.y-this.startPoint.y,1.7)/this.startSize.height*(this.rows/4);let n=this.startPosition.y+Math.round(e);n=Math.max(0,Math.min(n,this.rows-1)),n!==this.position.y&&(this.position.y=n,this.onMotion());const r=Math.min(...this.lastPoints.map((t=>t.y)));Math.max(...this.lastPoints.map((t=>t.y)))-r>25&&(this.startPoint.x=t.x,this.startPosition.x=this.position.x)}}end(t,e){this.isStarted=!1,e&&(this.inertia.track(t),this.inertia.start())}}class br{constructor(t,e,n,r){this.container=t,this.canvas=e,this.loader=n,this.images=[],this.frames=24,this.hotspotsList=[[]],this.interaction=new gr({x:0,y:0},1,1,!1,(()=>{this.canvas.draw(this.image,!0,.5),this.onInteraction({position:this.interaction.positionIndex})})),this.onInteraction=r}destroy(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}show(){this.canvas.show(!1),this.container.classList.add("ls-viewer-container-vrobject")}hide(){this.canvas.hide(!1),this.container.classList.remove("ls-viewer-container-vrobject")}async goto(t){return new Promise((e=>{let n=this.interaction.positionIndex;const r=()=>{if(this.interaction.positionIndex===t)e();else{let e=n>t?-1:1;this.interaction.loop&&this.interaction.frames-n+t<Math.abs(t-n)&&(e*=-1),n+=.5*e,this.position=Math.floor(n),this.animationFrameId=requestAnimationFrame(r)}};this.animationFrameId=requestAnimationFrame(r)}))}get position(){return this.interaction.positionIndex}set position(t){this.interaction.positionIndex=t,this.canvas.draw(this.image,!0,.5)}get image(){return this.images[this.interaction.positionIndex]}get hotspots(){return this.hotspotsList[this.interaction.positionIndex]||[]}async load(t,e,n,r){let i=Promise.resolve();n&&this.interaction.reset();const o=JSON.stringify(t);o===this.snapshotHash&&this.image?i=i.then((()=>this.canvas.draw(this.image,r,.05))):(this.images=[],i=i.then((()=>this.loader.loadVRObjectSnapshot(t,this.interaction.positionIndex).then((e=>{const i=e.length;return this.images=new Array(i),this.interaction.frames=t.view.frames||this.frames,this.interaction.rows=i/this.interaction.frames,this.interaction.loop=!!t.view.loop,n&&this.interaction.reset(),e.forEach(((t,e)=>{t.then((t=>{this.images[e]=t,t===this.image&&this.canvas.draw(this.image,r,.05)})).catch((()=>{}))})),e[this.interaction.positionIndex].then((()=>Promise.resolve()))})))));const s=JSON.stringify(e);return!e.length||o===this.snapshotHash&&s===this.tagsHash||(i=i.then((()=>this.loader.loadVRObjectHotspots(t,e).then((t=>{this.hotspotsList=t}))))),this.snapshotHash=o,this.tagsHash=s,i.then((()=>Promise.resolve(this.hotspots)))}snapshot(t,e){return this.canvas.element.toDataURL(t,e)}onMouseDown(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(cr.pointFromMouseEvent(t),{width:this.canvas.element.width,height:this.canvas.element.height})}onMouseMove(t){this.interaction.isStarted&&(this.interaction.motion(cr.pointFromMouseEvent(t)),t.preventDefault())}onMouseUp(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(cr.pointFromMouseEvent(t),!0))}onMouseEnter(t){this.interaction.isStarted&&0===t.buttons&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(cr.pointFromMouseEvent(t),!1))}onTouchStart(t){this.container.classList.add("ls-viewer-container-vrobject-grabbing"),this.interaction.start(cr.pointFromTouchEvent(t),{width:this.canvas.element.width,height:this.canvas.element.height})}onTouchMove(t){this.interaction.isStarted&&(this.interaction.motion(cr.pointFromTouchEvent(t)),t.preventDefault())}onTouchEnd(t){this.interaction.isStarted&&(this.container.classList.remove("ls-viewer-container-vrobject-grabbing"),this.interaction.end(cr.pointFromTouchEvent(t),!0))}onDeviceOrientation(t){}}var yr,wr,xr,Er;!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}(".ls-viewer-container{display:block;height:100%;overflow:hidden;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:100%}.ls-viewer-container-image,.ls-viewer-container-video{cursor:default;pointer-events:none}.ls-viewer-container-vrcube{cursor:pointer;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrcube-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-vrobject{cursor:move;cursor:-webkit-grab;cursor:grab}.ls-viewer-container-vrobject-grabbing{cursor:move;cursor:-webkit-grabbing;cursor:grabbing}.ls-viewer-container-loading{cursor:progress}.ls-viewer-canvas{opacity:0;position:absolute;-webkit-transition:opacity .5s;transition:opacity .5s}.ls-viewer-video{position:absolute}");t.WRAPIv2=void 0,yr=t.WRAPIv2||(t.WRAPIv2={}),(wr=yr.SunShadowQualityMode||(yr.SunShadowQualityMode={})).VeryLow="veryLow",wr.Low="low",wr.Medium="medium",wr.Fine="fine",wr.Ultra="ultra",(xr=yr.SunShadowSmoothnessMode||(yr.SunShadowSmoothnessMode={})).None="none",xr.Weak="weak",xr.Normal="normal",xr.Fine="fine",xr.UltraFine="ultraFine",xr.Max="max",(Er=yr.SunUseCaseMode||(yr.SunUseCaseMode={})).Manual="manual",Er.ExtractedFromEnv="extractedFromEnv",t.Viewer=class{constructor(t,n){this.checkResize=this.checkResize.bind(this),this.onDeviceOrientation=this.onDeviceOrientation.bind(this),this.onResize=this.onResize.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseEnter=this.onMouseEnter.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onLoadStart=this.onLoadStart.bind(this),this.onLoadProgress=this.onLoadProgress.bind(this),this.onLoadEnd=this.onLoadEnd.bind(this),this.onLoadError=this.onLoadError.bind(this),this.onHotspotsChange=this.onHotspotsChange.bind(this),this.onVrcubeInteraction=this.onVrcubeInteraction.bind(this),this.onVrobjectInteraction=this.onVrobjectInteraction.bind(this),this.options=Object.assign({server:"localhost",api:"v1",fit:"cover",image:{},video:{},vrcube:{},vrobject:{},events:{}},n),this.options.events=Object.assign({onLoadStart:()=>{},onLoadProgress:()=>{},onLoadEnd:()=>{},onLoadError:()=>{},onInteraction:()=>{},onVrcubeInteraction:()=>{},onVrobjectInteraction:()=>{},onHotspotsChange:()=>{}},n.events),this.options.events.onLoadError=e(this.options.events.onLoadError,10),this.container=t,this.container.classList.add("ls-viewer-container"),this.containerWidth=0,this.containerHeight=0,this.canvas2D=new s(this.options.fit),this.container.appendChild(this.canvas2D.element),this.canvas3D=new Zn,this.container.appendChild(this.canvas3D.element),this.video=new ir,this.container.appendChild(this.video.element),this.loader=new rr(this.options.server,this.options.api,this),this.resolution=new i(0,0),this.parameters={width:0,height:0,antialiasing:!1,superSampling:2},this.encoder={format:"jpeg",quality:80},this.widgetImage=new or(t,this.canvas2D,this.loader),this.widgetVideo=new sr(t,this.video,this.loader),this.widgetVRCube=new fr(t,this.canvas3D,this.loader,this.onVrcubeInteraction),this.widgetVRObject=new br(t,this.canvas2D,this.loader,this.onVrobjectInteraction),this.widget=this.widgetImage,this.isDestroyed=!1,this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mouseenter",this.onMouseEnter),this.container.addEventListener("touchstart",this.onTouchStart),document.addEventListener("mousemove",this.onMouseMove,{passive:!1}),document.addEventListener("mouseup",this.onMouseUp),document.addEventListener("touchmove",this.onTouchMove,{passive:!1}),document.addEventListener("touchend",this.onTouchEnd),this.checkResize(),this.loadWidget=e(this.loadWidget,10),this.onResize=e(this.onResize,250)}destroy(){this.canvas2D.destroy(),this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mouseenter",this.onMouseEnter),this.container.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd),this.isDestroyed=!0}async load(t,e){let n=Promise.resolve();return(null==e?void 0:e.animation)&&(n=n.then((()=>this.loadAnimation(e.animation)))),this.view&&void 0!==(null==e?void 0:e.fromPosition)&&this.viewWidget instanceof br&&(this.view.mode,n=n.then((()=>this.viewWidget.goto(e.fromPosition)))),(null==e?void 0:e.animation)&&(n=n.then((()=>this.widgetVideo.play()))),n=n.then((()=>(this.scene=Array.isArray(t)?[...t]:[t],this.loadWidget(!1,!(e&&e.animation))))),n.catch((t=>{this.onLoadError(t)})),n}async setEncoder(t){this.encoder=Object.assign({},t);let e=Promise.resolve();return e=e.then((()=>this.loadWidget(!1,!0))),e.catch((t=>{this.onLoadError(t)})),e}setParameters(t){this.parameters=Object.assign({},t),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height;let e=Promise.resolve();return e=e.then((()=>this.loadWidget(!1,!0))),e.catch((t=>{this.onLoadError(t)})),e}setTags(t){this.tags=t,this.loadWidget(!1,!1)}async setView(t,e){let n=Promise.resolve();return(null==e?void 0:e.animation)&&(n=n.then((()=>this.loadAnimation(e.animation)))),this.view&&void 0!==(null==e?void 0:e.fromPosition)&&this.viewWidget instanceof br&&(n=n.then((()=>this.viewWidget.goto(e.fromPosition)))),(null==e?void 0:e.animation)&&(n=n.then((()=>this.widgetVideo.play()))),n=n.then((()=>{let n=!0;return this.view=Object.assign({},t),this.view&&this.viewWidget instanceof br&&void 0!==(null==e?void 0:e.toPosition)&&(n=!1,this.viewWidget.position=e.toPosition),this.loadWidget(n,!(e&&e.animation))})),n.catch((t=>{this.onLoadError(t)})),n}setVrcube(t){Object.assign(this.widgetVRCube,t)}setVrobject(t){Object.assign(this.widgetVRObject,t)}async loadAnimation(t){var e;const n={scene:this.scene,view:{animation:t.name,camera:t.camera,duration:t.duration,loop:t.loop,reverse:t.reverse},parameters:this.parameters,encoder:{format:"mp4"}};return(null===(e=n.view)||void 0===e?void 0:e.background)||(n.view.background="product"),this.widgetVideo.load(n).then((()=>Promise.resolve()))}async playAnimation(t){return this.loadAnimation(t).then((()=>this.widgetVideo.play())).catch((t=>{this.onLoadError(t)}))}stopAnimation(){this.widgetVideo.hide()}snapshot(t,e){return this.viewWidget.snapshot(t,e)}async loadWidget(t,e){if(!this.scene||!this.view)return Promise.resolve();if(!this.parameters.width||!this.parameters.height)return Promise.resolve();const n=this.viewWidget;if(!n)return Promise.reject(new Error("Unknown view mode"));const r={scene:this.scene,view:this.view,parameters:this.parameters,encoder:this.encoder};return r.view.background||(r.view.background="product"),n.load(r,this.tags||[],t,e).then((t=>{this.widget.hide(),this.widget=n,this.widget.show(),this.widgetVideo.hide(),this.onHotspotsChange(t)}))}get viewWidget(){var t;switch(null===(t=this.view)||void 0===t?void 0:t.mode){case"image":default:return this.widgetImage;case"video":return this.widgetVideo;case"vrcube":return this.widgetVRCube;case"vrobject":return this.widgetVRObject}}checkResize(){if(this.isDestroyed)return;const t=this.container.clientWidth,e=this.container.clientHeight;t===this.containerWidth&&e===this.containerHeight||(this.containerWidth=t,this.containerHeight=e,this.onResize()),this.isDestroyed||requestAnimationFrame(this.checkResize)}onMouseDown(t){this.widget.onMouseDown(t)}onMouseEnter(t){this.widget.onMouseEnter(t)}onMouseMove(t){this.widget.onMouseMove(t)}onMouseUp(t){this.widget.onMouseUp(t)}onTouchStart(t){this.widget.onTouchStart(t)}onTouchMove(t){this.widget.onTouchMove(t)}onTouchEnd(t){this.widget.onTouchEnd(t)}onDeviceOrientation(t){this.widget.onDeviceOrientation(t)}onResize(){const t=this.container.clientWidth,e=this.container.clientHeight;this.resolution=o.getStandardResolution(t*window.devicePixelRatio,e*window.devicePixelRatio),this.parameters.width=this.resolution.width,this.parameters.height=this.resolution.height,this.canvas2D.resize(t,e,window.devicePixelRatio),this.canvas3D.resize(t,e,window.devicePixelRatio),this.video.resize(t,e,this.resolution,this.options.fit),this.loadWidget(!1,!1).catch((t=>{this.onLoadError(t)}))}onVrcubeInteraction(...t){this.options.events.onHotspotsChange(this.widgetVRCube.hotspots),this.options.events.onInteraction(...t),this.options.events.onVrcubeInteraction(...t)}onVrobjectInteraction(...t){this.options.events.onHotspotsChange(this.widgetVRObject.hotspots),this.options.events.onInteraction(...t),this.options.events.onVrobjectInteraction(...t)}onHotspotsChange(...t){this.options.events.onHotspotsChange(...t)}onLoadStart(...t){this.container.classList.add("ls-viewer-container-loading"),this.options.events.onLoadStart(...t)}onLoadProgress(...t){this.options.events.onLoadProgress(...t)}onLoadEnd(...t){this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadEnd(...t)}onLoadError(...t){this.container.classList.remove("ls-viewer-container-loading"),this.options.events.onLoadError(...t)}},t.WidgetImage=or,t.WidgetVRCube=fr,t.WidgetVRObject=br,t.WidgetVideo=sr,Object.defineProperty(t,"__esModule",{value:!0})}({});
|
|
20
|
-
//# sourceMappingURL=index-full.js.map
|