opencroc 1.8.1 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/cli/index.js +755 -8
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/index.d.ts +128 -1
  4. package/dist/index.js +548 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/web/dist/assets/main-Ccg3eDNK.js +1 -0
  7. package/dist/web/dist/assets/office-runtime-B3iNctxE.css +1 -0
  8. package/dist/web/dist/assets/office-runtime-BsCh82Pj.js +183 -0
  9. package/dist/web/dist/assets/pixel-page-3BYGm7dH.js +470 -0
  10. package/dist/web/dist/assets/react-vendor-C8RhVn0h.js +49 -0
  11. package/dist/web/dist/assets/studio-page-BInoyoV2.css +1 -0
  12. package/dist/web/dist/assets/studio-page-o3SCvE_v.js +351 -0
  13. package/dist/web/dist/assets/three-addons-BdrPp04O.js +470 -0
  14. package/dist/web/dist/assets/three-core-CsxM1PCY.js +4057 -0
  15. package/dist/web/dist/index.html +15 -0
  16. package/dist/web/index.html +11 -572
  17. package/dist/web/public/botreview/char_0.png +0 -0
  18. package/dist/web/public/botreview/char_1.png +0 -0
  19. package/dist/web/public/botreview/char_2.png +0 -0
  20. package/dist/web/public/botreview/coffee-machine.gif +0 -0
  21. package/dist/web/public/botreview/server.gif +0 -0
  22. package/dist/web/public/botreview/walls.png +0 -0
  23. package/dist/web/public/star/desk-v3.webp +0 -0
  24. package/dist/web/public/star/office_bg_small.webp +0 -0
  25. package/dist/web/public/star/star-idle-v5.png +0 -0
  26. package/dist/web/public/star/star-working-spritesheet-grid.webp +0 -0
  27. package/dist/web/src/app/AppLayout.tsx +34 -0
  28. package/dist/web/src/app/AppRouter.tsx +46 -0
  29. package/dist/web/src/app/bootstrap.tsx +22 -0
  30. package/dist/web/src/app/routes.tsx +52 -0
  31. package/dist/web/src/features/office/runtime/index.ts +1 -0
  32. package/dist/web/src/features/office/runtime/mount.ts +809 -0
  33. package/dist/web/src/features/pixel/runtime/index.ts +1 -0
  34. package/dist/web/src/features/pixel/runtime/mount.ts +728 -0
  35. package/dist/web/src/features/studio/runtime/index.ts +1 -0
  36. package/dist/web/src/features/studio/runtime/mount.ts +664 -0
  37. package/dist/web/src/features/three/engine/index.ts +1 -0
  38. package/dist/web/src/main.tsx +7 -0
  39. package/dist/web/src/pages/office/index.ts +1 -0
  40. package/dist/web/src/pages/office/page.tsx +283 -0
  41. package/dist/web/src/pages/pixel/index.ts +1 -0
  42. package/dist/web/src/pages/pixel/page.tsx +564 -0
  43. package/dist/web/src/pages/studio/index.ts +1 -0
  44. package/dist/web/src/pages/studio/page.tsx +446 -0
  45. package/dist/web/{js/agents.js → src/runtime/agents.ts} +304 -31
  46. package/dist/web/{js/camera.js → src/runtime/camera.ts} +12 -5
  47. package/dist/web/{js/dataviz.js → src/runtime/dataviz.ts} +38 -14
  48. package/dist/web/{js/effects.js → src/runtime/effects.ts} +139 -2
  49. package/dist/web/{js/engine.js → src/runtime/engine.ts} +45 -6
  50. package/dist/web/{js/office.js → src/runtime/office.ts} +136 -20
  51. package/dist/web/{js/ui.js → src/runtime/ui.ts} +11 -7
  52. package/dist/web/src/shared/assets.ts +4 -0
  53. package/dist/web/src/shared/navigation.ts +47 -0
  54. package/dist/web/src/styles/app-layout.css +19 -0
  55. package/dist/web/src/styles/office.css +268 -0
  56. package/dist/web/tsconfig.json +28 -0
  57. package/dist/web/vite.config.ts +93 -0
  58. package/package.json +11 -2
  59. package/dist/web/index-studio.html +0 -1644
  60. package/dist/web/index-v2-pixel.html +0 -1571
  61. /package/dist/web/{assets → dist}/botreview/char_0.png +0 -0
  62. /package/dist/web/{assets → dist}/botreview/char_1.png +0 -0
  63. /package/dist/web/{assets → dist}/botreview/char_2.png +0 -0
  64. /package/dist/web/{assets → dist}/botreview/coffee-machine.gif +0 -0
  65. /package/dist/web/{assets → dist}/botreview/server.gif +0 -0
  66. /package/dist/web/{assets → dist}/botreview/walls.png +0 -0
  67. /package/dist/web/{assets → dist}/star/desk-v3.webp +0 -0
  68. /package/dist/web/{assets → dist}/star/office_bg_small.webp +0 -0
  69. /package/dist/web/{assets → dist}/star/star-idle-v5.png +0 -0
  70. /package/dist/web/{assets → dist}/star/star-working-spritesheet-grid.webp +0 -0
  71. /package/dist/web/{js/state.js → src/runtime/state.ts} +0 -0
@@ -0,0 +1,470 @@
1
+ import{f as tt,O as et,l as it,y as B,j as T,U as N,V as d,z as L,E as R,N as st,J as at,k as U,u as m,n as ot,g as nt,K as rt,Q as lt,X as ht,Y as ut,Z as ct,_ as dt,A as pt,$ as mt,a0 as ft,a1 as _t,a2 as W,a3 as gt,a4 as bt,a5 as D,a6 as y,a7 as j,a8 as H,a9 as vt,aa as St,ab as xt}from"./three-core-CsxM1PCY.js";const O={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
2
+
3
+ varying vec2 vUv;
4
+
5
+ void main() {
6
+
7
+ vUv = uv;
8
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
9
+
10
+ }`,fragmentShader:`
11
+
12
+ uniform float opacity;
13
+
14
+ uniform sampler2D tDiffuse;
15
+
16
+ varying vec2 vUv;
17
+
18
+ void main() {
19
+
20
+ vec4 texel = texture2D( tDiffuse, vUv );
21
+ gl_FragColor = opacity * texel;
22
+
23
+
24
+ }`};class E{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Tt=new et(-1,1,1,-1,0,1);class yt extends it{constructor(){super(),this.setAttribute("position",new B([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new B([0,2,0,0,2,0],2))}}const Dt=new yt;class k{constructor(t){this._mesh=new tt(Dt,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,Tt)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class Et extends E{constructor(t,e="tDiffuse"){super(),this.textureID=e,this.uniforms=null,this.material=null,t instanceof T?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=N.clone(t.uniforms),this.material=new T({name:t.name!==void 0?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this._fsQuad=new k(this.material)}render(t,e,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this._fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class G extends E{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,i){const s=t.getContext(),a=t.state;a.buffers.color.setMask(!1),a.buffers.depth.setMask(!1),a.buffers.color.setLocked(!0),a.buffers.depth.setLocked(!0);let n,u;this.inverse?(n=0,u=1):(n=1,u=0),a.buffers.stencil.setTest(!0),a.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),a.buffers.stencil.setFunc(s.ALWAYS,n,4294967295),a.buffers.stencil.setClear(u),a.buffers.stencil.setLocked(!0),t.setRenderTarget(i),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),a.buffers.color.setLocked(!1),a.buffers.depth.setLocked(!1),a.buffers.color.setMask(!0),a.buffers.depth.setMask(!0),a.buffers.stencil.setLocked(!1),a.buffers.stencil.setFunc(s.EQUAL,1,4294967295),a.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),a.buffers.stencil.setLocked(!0)}}class Mt extends E{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class Ht{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),e===void 0){const i=t.getSize(new d);this._width=i.width,this._height=i.height,e=new L(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:R}),e.texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Et(O),this.copyPass.material.blending=st,this.timer=new at}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);e!==-1&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){this.timer.update(),t===void 0&&(t=this.timer.getDelta());const e=this.renderer.getRenderTarget();let i=!1;for(let s=0,a=this.passes.length;s<a;s++){const n=this.passes[s];if(n.enabled!==!1){if(n.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(s),n.render(this.renderer,this.writeBuffer,this.readBuffer,t,i),n.needsSwap){if(i){const u=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(u.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),l.setFunc(u.EQUAL,1,4294967295)}this.swapBuffers()}G!==void 0&&(n instanceof G?i=!0:n instanceof Mt&&(i=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(t===void 0){const e=this.renderer.getSize(new d);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,t=this.renderTarget1.clone(),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const i=this._width*this._pixelRatio,s=this._height*this._pixelRatio;this.renderTarget1.setSize(i,s),this.renderTarget2.setSize(i,s);for(let a=0;a<this.passes.length;a++)this.passes[a].setSize(i,s)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class Gt extends E{constructor(t,e,i=null,s=null,a=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=i,this.clearColor=s,this.clearAlpha=a,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new U}render(t,e,i){const s=t.autoClear;t.autoClear=!1;let a,n;this.overrideMaterial!==null&&(n=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor,t.getClearAlpha())),this.clearAlpha!==null&&(a=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:i),this.clear===!0&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),this.clearColor!==null&&t.setClearColor(this._oldClearColor),this.clearAlpha!==null&&t.setClearAlpha(a),this.overrideMaterial!==null&&(this.scene.overrideMaterial=n),t.autoClear=s}}const Pt={uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new U(0)},defaultOpacity:{value:0}},vertexShader:`
25
+
26
+ varying vec2 vUv;
27
+
28
+ void main() {
29
+
30
+ vUv = uv;
31
+
32
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
33
+
34
+ }`,fragmentShader:`
35
+
36
+ uniform sampler2D tDiffuse;
37
+ uniform vec3 defaultColor;
38
+ uniform float defaultOpacity;
39
+ uniform float luminosityThreshold;
40
+ uniform float smoothWidth;
41
+
42
+ varying vec2 vUv;
43
+
44
+ void main() {
45
+
46
+ vec4 texel = texture2D( tDiffuse, vUv );
47
+
48
+ float v = luminance( texel.xyz );
49
+
50
+ vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
51
+
52
+ float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
53
+
54
+ gl_FragColor = mix( outputColor, texel, alpha );
55
+
56
+ }`};class C extends E{constructor(t,e=1,i,s){super(),this.strength=e,this.radius=i,this.threshold=s,this.resolution=t!==void 0?new d(t.x,t.y):new d(256,256),this.clearColor=new U(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let a=Math.round(this.resolution.x/2),n=Math.round(this.resolution.y/2);this.renderTargetBright=new L(a,n,{type:R}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let g=0;g<this.nMips;g++){const M=new L(a,n,{type:R});M.texture.name="UnrealBloomPass.h"+g,M.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(M);const P=new L(a,n,{type:R});P.texture.name="UnrealBloomPass.v"+g,P.texture.generateMipmaps=!1,this.renderTargetsVertical.push(P),a=Math.round(a/2),n=Math.round(n/2)}const u=Pt;this.highPassUniforms=N.clone(u.uniforms),this.highPassUniforms.luminosityThreshold.value=s,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new T({uniforms:this.highPassUniforms,vertexShader:u.vertexShader,fragmentShader:u.fragmentShader}),this.separableBlurMaterials=[];const l=[6,10,14,18,22];a=Math.round(this.resolution.x/2),n=Math.round(this.resolution.y/2);for(let g=0;g<this.nMips;g++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(l[g])),this.separableBlurMaterials[g].uniforms.invSize.value=new d(1/a,1/n),a=Math.round(a/2),n=Math.round(n/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=e,this.compositeMaterial.uniforms.bloomRadius.value=.1;const S=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=S,this.bloomTintColors=[new m(1,1,1),new m(1,1,1),new m(1,1,1),new m(1,1,1),new m(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=N.clone(O.uniforms),this.blendMaterial=new T({uniforms:this.copyUniforms,vertexShader:O.vertexShader,fragmentShader:O.fragmentShader,premultipliedAlpha:!0,blending:ot,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new U,this._oldClearAlpha=1,this._basic=new nt,this._fsQuad=new k(null)}dispose(){for(let t=0;t<this.renderTargetsHorizontal.length;t++)this.renderTargetsHorizontal[t].dispose();for(let t=0;t<this.renderTargetsVertical.length;t++)this.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose();for(let t=0;t<this.separableBlurMaterials.length;t++)this.separableBlurMaterials[t].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(t,e){let i=Math.round(t/2),s=Math.round(e/2);this.renderTargetBright.setSize(i,s);for(let a=0;a<this.nMips;a++)this.renderTargetsHorizontal[a].setSize(i,s),this.renderTargetsVertical[a].setSize(i,s),this.separableBlurMaterials[a].uniforms.invSize.value=new d(1/i,1/s),i=Math.round(i/2),s=Math.round(s/2)}render(t,e,i,s,a){t.getClearColor(this._oldClearColor),this._oldClearAlpha=t.getClearAlpha();const n=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),a&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=i.texture,t.setRenderTarget(null),t.clear(),this._fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=i.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this._fsQuad.render(t);let u=this.renderTargetBright;for(let l=0;l<this.nMips;l++)this._fsQuad.material=this.separableBlurMaterials[l],this.separableBlurMaterials[l].uniforms.colorTexture.value=u.texture,this.separableBlurMaterials[l].uniforms.direction.value=C.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[l]),t.clear(),this._fsQuad.render(t),this.separableBlurMaterials[l].uniforms.colorTexture.value=this.renderTargetsHorizontal[l].texture,this.separableBlurMaterials[l].uniforms.direction.value=C.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[l]),t.clear(),this._fsQuad.render(t),u=this.renderTargetsVertical[l];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this._fsQuad.render(t),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,a&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(i),this._fsQuad.render(t)),t.setClearColor(this._oldClearColor,this._oldClearAlpha),t.autoClear=n}_getSeparableBlurMaterial(t){const e=[],i=t/3;for(let s=0;s<t;s++)e.push(.39894*Math.exp(-.5*s*s/(i*i))/i);return new T({defines:{KERNEL_RADIUS:t},uniforms:{colorTexture:{value:null},invSize:{value:new d(.5,.5)},direction:{value:new d(.5,.5)},gaussianCoefficients:{value:e}},vertexShader:`
57
+
58
+ varying vec2 vUv;
59
+
60
+ void main() {
61
+
62
+ vUv = uv;
63
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
64
+
65
+ }`,fragmentShader:`
66
+
67
+ #include <common>
68
+
69
+ varying vec2 vUv;
70
+
71
+ uniform sampler2D colorTexture;
72
+ uniform vec2 invSize;
73
+ uniform vec2 direction;
74
+ uniform float gaussianCoefficients[KERNEL_RADIUS];
75
+
76
+ void main() {
77
+
78
+ float weightSum = gaussianCoefficients[0];
79
+ vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
80
+
81
+ for ( int i = 1; i < KERNEL_RADIUS; i ++ ) {
82
+
83
+ float x = float( i );
84
+ float w = gaussianCoefficients[i];
85
+ vec2 uvOffset = direction * invSize * x;
86
+ vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
87
+ vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
88
+ diffuseSum += ( sample1 + sample2 ) * w;
89
+
90
+ }
91
+
92
+ gl_FragColor = vec4( diffuseSum, 1.0 );
93
+
94
+ }`})}_getCompositeMaterial(t){return new T({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`
95
+
96
+ varying vec2 vUv;
97
+
98
+ void main() {
99
+
100
+ vUv = uv;
101
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
102
+
103
+ }`,fragmentShader:`
104
+
105
+ varying vec2 vUv;
106
+
107
+ uniform sampler2D blurTexture1;
108
+ uniform sampler2D blurTexture2;
109
+ uniform sampler2D blurTexture3;
110
+ uniform sampler2D blurTexture4;
111
+ uniform sampler2D blurTexture5;
112
+ uniform float bloomStrength;
113
+ uniform float bloomRadius;
114
+ uniform float bloomFactors[NUM_MIPS];
115
+ uniform vec3 bloomTintColors[NUM_MIPS];
116
+
117
+ float lerpBloomFactor( const in float factor ) {
118
+
119
+ float mirrorFactor = 1.2 - factor;
120
+ return mix( factor, mirrorFactor, bloomRadius );
121
+
122
+ }
123
+
124
+ void main() {
125
+
126
+ // 3.0 for backwards compatibility with previous alpha-based intensity
127
+ vec3 bloom = 3.0 * bloomStrength * (
128
+ lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +
129
+ lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +
130
+ lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +
131
+ lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +
132
+ lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb
133
+ );
134
+
135
+ float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );
136
+ gl_FragColor = vec4( bloom, bloomAlpha );
137
+
138
+ }`})}}C.BlurDirectionX=new d(1,0);C.BlurDirectionY=new d(0,1);const Yt={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new d(1/1024,1/512)}},vertexShader:`
139
+
140
+ varying vec2 vUv;
141
+
142
+ void main() {
143
+
144
+ vUv = uv;
145
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
146
+
147
+ }`,fragmentShader:`
148
+
149
+ uniform sampler2D tDiffuse;
150
+ uniform vec2 resolution;
151
+ varying vec2 vUv;
152
+
153
+ #define EDGE_STEP_COUNT 6
154
+ #define EDGE_GUESS 8.0
155
+ #define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0
156
+ const float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );
157
+
158
+ float _ContrastThreshold = 0.0312;
159
+ float _RelativeThreshold = 0.063;
160
+ float _SubpixelBlending = 1.0;
161
+
162
+ vec4 Sample( sampler2D tex2D, vec2 uv ) {
163
+
164
+ return texture( tex2D, uv );
165
+
166
+ }
167
+
168
+ float SampleLuminance( sampler2D tex2D, vec2 uv ) {
169
+
170
+ return dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );
171
+
172
+ }
173
+
174
+ float SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {
175
+
176
+ uv += texSize * vec2(uOffset, vOffset);
177
+ return SampleLuminance(tex2D, uv);
178
+
179
+ }
180
+
181
+ struct LuminanceData {
182
+
183
+ float m, n, e, s, w;
184
+ float ne, nw, se, sw;
185
+ float highest, lowest, contrast;
186
+
187
+ };
188
+
189
+ LuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {
190
+
191
+ LuminanceData l;
192
+ l.m = SampleLuminance( tex2D, uv );
193
+ l.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );
194
+ l.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );
195
+ l.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );
196
+ l.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );
197
+
198
+ l.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );
199
+ l.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );
200
+ l.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );
201
+ l.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );
202
+
203
+ l.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );
204
+ l.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );
205
+ l.contrast = l.highest - l.lowest;
206
+ return l;
207
+
208
+ }
209
+
210
+ bool ShouldSkipPixel( LuminanceData l ) {
211
+
212
+ float threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );
213
+ return l.contrast < threshold;
214
+
215
+ }
216
+
217
+ float DeterminePixelBlendFactor( LuminanceData l ) {
218
+
219
+ float f = 2.0 * ( l.n + l.e + l.s + l.w );
220
+ f += l.ne + l.nw + l.se + l.sw;
221
+ f *= 1.0 / 12.0;
222
+ f = abs( f - l.m );
223
+ f = clamp( f / l.contrast, 0.0, 1.0 );
224
+
225
+ float blendFactor = smoothstep( 0.0, 1.0, f );
226
+ return blendFactor * blendFactor * _SubpixelBlending;
227
+
228
+ }
229
+
230
+ struct EdgeData {
231
+
232
+ bool isHorizontal;
233
+ float pixelStep;
234
+ float oppositeLuminance, gradient;
235
+
236
+ };
237
+
238
+ EdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {
239
+
240
+ EdgeData e;
241
+ float horizontal =
242
+ abs( l.n + l.s - 2.0 * l.m ) * 2.0 +
243
+ abs( l.ne + l.se - 2.0 * l.e ) +
244
+ abs( l.nw + l.sw - 2.0 * l.w );
245
+ float vertical =
246
+ abs( l.e + l.w - 2.0 * l.m ) * 2.0 +
247
+ abs( l.ne + l.nw - 2.0 * l.n ) +
248
+ abs( l.se + l.sw - 2.0 * l.s );
249
+ e.isHorizontal = horizontal >= vertical;
250
+
251
+ float pLuminance = e.isHorizontal ? l.n : l.e;
252
+ float nLuminance = e.isHorizontal ? l.s : l.w;
253
+ float pGradient = abs( pLuminance - l.m );
254
+ float nGradient = abs( nLuminance - l.m );
255
+
256
+ e.pixelStep = e.isHorizontal ? texSize.y : texSize.x;
257
+
258
+ if (pGradient < nGradient) {
259
+
260
+ e.pixelStep = -e.pixelStep;
261
+ e.oppositeLuminance = nLuminance;
262
+ e.gradient = nGradient;
263
+
264
+ } else {
265
+
266
+ e.oppositeLuminance = pLuminance;
267
+ e.gradient = pGradient;
268
+
269
+ }
270
+
271
+ return e;
272
+
273
+ }
274
+
275
+ float DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {
276
+
277
+ vec2 uvEdge = uv;
278
+ vec2 edgeStep;
279
+ if (e.isHorizontal) {
280
+
281
+ uvEdge.y += e.pixelStep * 0.5;
282
+ edgeStep = vec2( texSize.x, 0.0 );
283
+
284
+ } else {
285
+
286
+ uvEdge.x += e.pixelStep * 0.5;
287
+ edgeStep = vec2( 0.0, texSize.y );
288
+
289
+ }
290
+
291
+ float edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;
292
+ float gradientThreshold = e.gradient * 0.25;
293
+
294
+ vec2 puv = uvEdge + edgeStep * edgeSteps[0];
295
+ float pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
296
+ bool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
297
+
298
+ for ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {
299
+
300
+ puv += edgeStep * edgeSteps[i];
301
+ pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
302
+ pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
303
+
304
+ }
305
+
306
+ if ( !pAtEnd ) {
307
+
308
+ puv += edgeStep * EDGE_GUESS;
309
+
310
+ }
311
+
312
+ vec2 nuv = uvEdge - edgeStep * edgeSteps[0];
313
+ float nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
314
+ bool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
315
+
316
+ for ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {
317
+
318
+ nuv -= edgeStep * edgeSteps[i];
319
+ nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
320
+ nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
321
+
322
+ }
323
+
324
+ if ( !nAtEnd ) {
325
+
326
+ nuv -= edgeStep * EDGE_GUESS;
327
+
328
+ }
329
+
330
+ float pDistance, nDistance;
331
+ if ( e.isHorizontal ) {
332
+
333
+ pDistance = puv.x - uv.x;
334
+ nDistance = uv.x - nuv.x;
335
+
336
+ } else {
337
+
338
+ pDistance = puv.y - uv.y;
339
+ nDistance = uv.y - nuv.y;
340
+
341
+ }
342
+
343
+ float shortestDistance;
344
+ bool deltaSign;
345
+ if ( pDistance <= nDistance ) {
346
+
347
+ shortestDistance = pDistance;
348
+ deltaSign = pLuminanceDelta >= 0.0;
349
+
350
+ } else {
351
+
352
+ shortestDistance = nDistance;
353
+ deltaSign = nLuminanceDelta >= 0.0;
354
+
355
+ }
356
+
357
+ if ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {
358
+
359
+ return 0.0;
360
+
361
+ }
362
+
363
+ return 0.5 - shortestDistance / ( pDistance + nDistance );
364
+
365
+ }
366
+
367
+ vec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {
368
+
369
+ LuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );
370
+ if ( ShouldSkipPixel( luminance ) ) {
371
+
372
+ return Sample( tex2D, uv );
373
+
374
+ }
375
+
376
+ float pixelBlend = DeterminePixelBlendFactor( luminance );
377
+ EdgeData edge = DetermineEdge( texSize, luminance );
378
+ float edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );
379
+ float finalBlend = max( pixelBlend, edgeBlend );
380
+
381
+ if (edge.isHorizontal) {
382
+
383
+ uv.y += edge.pixelStep * finalBlend;
384
+
385
+ } else {
386
+
387
+ uv.x += edge.pixelStep * finalBlend;
388
+
389
+ }
390
+
391
+ return Sample( tex2D, uv );
392
+
393
+ }
394
+
395
+ void main() {
396
+
397
+ gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );
398
+
399
+ }`},w={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
400
+ precision highp float;
401
+
402
+ uniform mat4 modelViewMatrix;
403
+ uniform mat4 projectionMatrix;
404
+
405
+ attribute vec3 position;
406
+ attribute vec2 uv;
407
+
408
+ varying vec2 vUv;
409
+
410
+ void main() {
411
+
412
+ vUv = uv;
413
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
414
+
415
+ }`,fragmentShader:`
416
+
417
+ precision highp float;
418
+
419
+ uniform sampler2D tDiffuse;
420
+
421
+ #include <tonemapping_pars_fragment>
422
+ #include <colorspace_pars_fragment>
423
+
424
+ varying vec2 vUv;
425
+
426
+ void main() {
427
+
428
+ gl_FragColor = texture2D( tDiffuse, vUv );
429
+
430
+ // tone mapping
431
+
432
+ #ifdef LINEAR_TONE_MAPPING
433
+
434
+ gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
435
+
436
+ #elif defined( REINHARD_TONE_MAPPING )
437
+
438
+ gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
439
+
440
+ #elif defined( CINEON_TONE_MAPPING )
441
+
442
+ gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
443
+
444
+ #elif defined( ACES_FILMIC_TONE_MAPPING )
445
+
446
+ gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
447
+
448
+ #elif defined( AGX_TONE_MAPPING )
449
+
450
+ gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
451
+
452
+ #elif defined( NEUTRAL_TONE_MAPPING )
453
+
454
+ gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
455
+
456
+ #elif defined( CUSTOM_TONE_MAPPING )
457
+
458
+ gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
459
+
460
+ #endif
461
+
462
+ // color space
463
+
464
+ #ifdef SRGB_TRANSFER
465
+
466
+ gl_FragColor = sRGBTransferOETF( gl_FragColor );
467
+
468
+ #endif
469
+
470
+ }`};class Kt extends E{constructor(){super(),this.isOutputPass=!0,this.uniforms=N.clone(w.uniforms),this.material=new rt({name:w.name,uniforms:this.uniforms,vertexShader:w.vertexShader,fragmentShader:w.fragmentShader}),this._fsQuad=new k(this.material),this._outputColorSpace=null,this._toneMapping=null}render(t,e,i){this.uniforms.tDiffuse.value=i.texture,this.uniforms.toneMappingExposure.value=t.toneMappingExposure,(this._outputColorSpace!==t.outputColorSpace||this._toneMapping!==t.toneMapping)&&(this._outputColorSpace=t.outputColorSpace,this._toneMapping=t.toneMapping,this.material.defines={},lt.getTransfer(this._outputColorSpace)===ht&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===ut?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===ct?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===dt?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===pt?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===mt?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===ft?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===_t&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class Vt extends gt{constructor(t=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=t,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new d(.5,.5),this.addEventListener("removed",function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(t,e){return super.copy(t,e),this.element=t.element.cloneNode(!0),this.center=t.center,this}}const x=new m,Y=new W,K=new W,V=new m,Z=new m;class Zt{constructor(t={}){const e=this;let i,s,a,n;const u={objects:new WeakMap},l=t.element!==void 0?t.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l,this.sortObjects=!0,this.getSize=function(){return{width:i,height:s}},this.render=function(r,c){r.matrixWorldAutoUpdate===!0&&r.updateMatrixWorld(),c.parent===null&&c.matrixWorldAutoUpdate===!0&&c.updateMatrixWorld(),Y.copy(c.matrixWorldInverse),K.multiplyMatrices(c.projectionMatrix,Y),g(r,r,c),this.sortObjects&&J(r)},this.setSize=function(r,c){i=r,s=c,a=i/2,n=s/2,l.style.width=r+"px",l.style.height=c+"px"};function S(r){r.isCSS2DObject&&(r.element.style.display="none");for(let c=0,b=r.children.length;c<b;c++)S(r.children[c])}function g(r,c,b){if(r.visible===!1){S(r);return}if(r.isCSS2DObject){x.setFromMatrixPosition(r.matrixWorld),x.applyMatrix4(K);const f=x.z>=-1&&x.z<=1&&r.layers.test(b.layers)===!0,v=r.element;v.style.display=f===!0?"":"none",f===!0&&(r.onBeforeRender(e,c,b),v.style.transform="translate("+-100*r.center.x+"%,"+-100*r.center.y+"%)translate("+(x.x*a+a)+"px,"+(-x.y*n+n)+"px)",v.parentNode!==l&&l.appendChild(v),r.onAfterRender(e,c,b));const z={distanceToCameraSquared:M(b,r)};u.objects.set(r,z)}for(let f=0,v=r.children.length;f<v;f++)g(r.children[f],c,b)}function M(r,c){return V.setFromMatrixPosition(r.matrixWorld),Z.setFromMatrixPosition(c.matrixWorld),V.distanceToSquared(Z)}function P(r){const c=[];return r.traverseVisible(function(b){b.isCSS2DObject&&c.push(b)}),c}function J(r){const c=P(r).sort(function(f,v){if(f.renderOrder!==v.renderOrder)return v.renderOrder-f.renderOrder;const z=u.objects.get(f).distanceToCameraSquared,$=u.objects.get(v).distanceToCameraSquared;return z-$}),b=c.length;for(let f=0,v=c.length;f<v;f++)c[f].element.style.zIndex=b-f}}}const X={type:"change"},I={type:"start"},q={type:"end"},A=new vt,Q=new St,Ct=Math.cos(70*xt.DEG2RAD),p=new m,_=2*Math.PI,h={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},F=1e-6;class Xt extends bt{constructor(t,e=null){super(t,e),this.state=h.NONE,this.target=new m,this.cursor=new m,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:D.ROTATE,MIDDLE:D.DOLLY,RIGHT:D.PAN},this.touches={ONE:y.ROTATE,TWO:y.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new m,this._lastQuaternion=new j,this._lastTargetPosition=new m,this._quat=new j().setFromUnitVectors(t.up,new m(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new H,this._sphericalDelta=new H,this._scale=1,this._panOffset=new m,this._rotateStart=new d,this._rotateEnd=new d,this._rotateDelta=new d,this._panStart=new d,this._panEnd=new d,this._panDelta=new d,this._dollyStart=new d,this._dollyEnd=new d,this._dollyDelta=new d,this._dollyDirection=new m,this._mouse=new d,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=At.bind(this),this._onPointerDown=wt.bind(this),this._onPointerUp=Lt.bind(this),this._onContextMenu=kt.bind(this),this._onMouseWheel=Nt.bind(this),this._onKeyDown=Ut.bind(this),this._onTouchStart=zt.bind(this),this._onTouchMove=Ft.bind(this),this._onMouseDown=Rt.bind(this),this._onMouseMove=Ot.bind(this),this._interceptControlDown=It.bind(this),this._interceptControlUp=Bt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(t){this._cursorStyle=t,t==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(X),this.update(),this.state=h.NONE}pan(t,e){this._pan(t,e),this.update()}dollyIn(t){this._dollyIn(t),this.update()}dollyOut(t){this._dollyOut(t),this.update()}rotateLeft(t){this._rotateLeft(t),this.update()}rotateUp(t){this._rotateUp(t),this.update()}update(t=null){const e=this.object.position;p.copy(e).sub(this.target),p.applyQuaternion(this._quat),this._spherical.setFromVector3(p),this.autoRotate&&this.state===h.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=_:i>Math.PI&&(i-=_),s<-Math.PI?s+=_:s>Math.PI&&(s-=_),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const n=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=n!=this._spherical.radius}if(p.setFromSpherical(this._spherical),p.applyQuaternion(this._quatInverse),e.copy(this.target).add(p),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let n=null;if(this.object.isPerspectiveCamera){const u=p.length();n=this._clampDistance(u*this._scale);const l=u-n;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),a=!!l}else if(this.object.isOrthographicCamera){const u=new m(this._mouse.x,this._mouse.y,0);u.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=l!==this.object.zoom;const S=new m(this._mouse.x,this._mouse.y,0);S.unproject(this.object),this.object.position.sub(S).add(u),this.object.updateMatrixWorld(),n=p.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;n!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(n).add(this.object.position):(A.origin.copy(this.object.position),A.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(A.direction))<Ct?this.object.lookAt(this.target):(Q.setFromNormalAndCoplanarPoint(this.object.up,this.target),A.intersectPlane(Q,this.target))))}else if(this.object.isOrthographicCamera){const n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),n!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>F||8*(1-this._lastQuaternion.dot(this.object.quaternion))>F||this._lastTargetPosition.distanceToSquared(this.target)>F?(this.dispatchEvent(X),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?_/60*this.autoRotateSpeed*t:_/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){p.setFromMatrixColumn(e,0),p.multiplyScalar(-t),this._panOffset.add(p)}_panUp(t,e){this.screenSpacePanning===!0?p.setFromMatrixColumn(e,1):(p.setFromMatrixColumn(e,0),p.crossVectors(this.object.up,p)),p.multiplyScalar(t),this._panOffset.add(p)}_pan(t,e){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;p.copy(s).sub(this.target);let a=p.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*a/i.clientHeight,this.object.matrix),this._panUp(2*e*a/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=t-i.left,a=e-i.top,n=i.width,u=i.height;this._mouse.x=s/n*2-1,this._mouse.y=-(a/u)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(_*this._rotateDelta.x/e.clientHeight),this._rotateUp(_*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(i,s)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,s=t.pageY-e.y,a=Math.sqrt(i*i+s*s);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const i=this._getSecondPointerPosition(t),s=.5*(t.pageX+i.x),a=.5*(t.pageY+i.y);this._rotateEnd.set(s,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(_*this._rotateDelta.x/e.clientHeight),this._rotateUp(_*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,s=t.pageY-e.y,a=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const n=(t.pageX+e.x)*.5,u=(t.pageY+e.y)*.5;this._updateZoomParameters(n,u)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new d,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,i={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function wt(o){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(o.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(o)&&(this._addPointer(o),o.pointerType==="touch"?this._onTouchStart(o):this._onMouseDown(o),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function At(o){this.enabled!==!1&&(o.pointerType==="touch"?this._onTouchMove(o):this._onMouseMove(o))}function Lt(o){switch(this._removePointer(o),this._pointers.length){case 0:this.domElement.releasePointerCapture(o.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(q),this.state=h.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function Rt(o){let t;switch(o.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case D.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(o),this.state=h.DOLLY;break;case D.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=h.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=h.ROTATE}break;case D.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=h.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=h.PAN}break;default:this.state=h.NONE}this.state!==h.NONE&&this.dispatchEvent(I)}function Ot(o){switch(this.state){case h.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(o);break;case h.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(o);break;case h.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(o);break}}function Nt(o){this.enabled===!1||this.enableZoom===!1||this.state!==h.NONE||(o.preventDefault(),this.dispatchEvent(I),this._handleMouseWheel(this._customWheelEvent(o)),this.dispatchEvent(q))}function Ut(o){this.enabled!==!1&&this._handleKeyDown(o)}function zt(o){switch(this._trackPointer(o),this._pointers.length){case 1:switch(this.touches.ONE){case y.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(o),this.state=h.TOUCH_ROTATE;break;case y.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(o),this.state=h.TOUCH_PAN;break;default:this.state=h.NONE}break;case 2:switch(this.touches.TWO){case y.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(o),this.state=h.TOUCH_DOLLY_PAN;break;case y.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(o),this.state=h.TOUCH_DOLLY_ROTATE;break;default:this.state=h.NONE}break;default:this.state=h.NONE}this.state!==h.NONE&&this.dispatchEvent(I)}function Ft(o){switch(this._trackPointer(o),this.state){case h.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(o),this.update();break;case h.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(o),this.update();break;case h.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(o),this.update();break;case h.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(o),this.update();break;default:this.state=h.NONE}}function kt(o){this.enabled!==!1&&o.preventDefault()}function It(o){o.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Bt(o){o.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}export{Zt as C,Ht as E,Yt as F,Kt as O,Gt as R,Et as S,C as U,Vt as a,Xt as b};