diff --git a/CONTEXT.md b/CONTEXT.md
index 7facf288..4875db4e 100644
--- a/CONTEXT.md
+++ b/CONTEXT.md
@@ -84,26 +84,28 @@ Switch / Slider 的白底圆钮。
决策状态:✅ 2026-06-29 确认
-#### 例外:首屏 3D 场景分镜(ADR-0016,2026-12-02)
+#### ~~例外:首屏 3D 场景分镜~~ [已撤回]
-**只对首页首屏的 3D 场景层**开一档窄例外,允许**分镜式编排**(多机位时间线 + 压黑转场)。
-依据:对标 Porsche Consulting 的 hero 本就是「一条片子里的几个镜头」;本站没有实拍素材,
-用闭合运镜模拟「一直在走」。
+**2026-12-02 晚撤回**:该例外唯一的作用对象(`src/components/home/hero-scene.tsx`,机房分镜)
+已整体退役,理由是**题材不成立**,不是实现有缺陷:
-例外同时受四条约束,缺一条即不成立:
+- 机房语义是「数据的存放地」,而首屏要讲的是「数据如何变成判断」—— 画面里从来没有
+ 「选项 / 判据 / 结论」这些对象,任何光效最多表达「设备在运行」;
+- 换成「抽象数据场」后,三拍仍是分镜式编排,但**例外条款本身不再需要**:
+ 它当初是为了给「循环」开一档窄口子,而新的三拍节奏(43.26s)由具体实现自行满足
+ ①–④,没有再走例外。
-| # | 约束 | 判据 |
-|---|---|---|
-| ① | **一轮周期落在 [20s, 60s]** | `check:grammar` **R26** 解析 `ms:` 与 `DIP_MS` 求和 |
-| ② | **不得脉冲式重复**(同一动画等间隔重复仍禁 —— 这正是 E 案拒掉 `pulseVertical` 的理由) | 无静态形态,人工评审兜(R26 note 明写) |
-| ③ | **`prefers-reduced-motion` 必须定格** | R26 检查 `prefers-reduced-motion` 存在 |
-| ④ | **离屏 / 切后台必须停** | R26 检查 `IntersectionObserver` + `visibilitychange` 同时存在 |
+随之撤回的还有:`check:grammar` 的 **R26**(其唯一判据就是解析该文件的 `ms:` 与 `DIP_MS`)、
+海报帧 `hero-scene-poster.webp`、CC0 资产 `server-rack.glb`,以及 R22 登记表里的对应条目
+(登记表因此归零 —— 首屏回到**零视觉层**)。
-另禁 `autoRotate`(自转=同一动画重复播放),由 R26 直接判红。
+⚠ **对新场景的约束已随落地重建(2026-12-02 晚)**:抽象数据场已进
+`src/components/home/hero-field.tsx`(flag `NEXT_PUBLIC_HERO_FIELD` 样期,默认关),
+R26 **已重建并指向新组件**(判据同前:周期上限 / reduced-motion 定格 / 离屏停 / 禁自转)。
+海报帧 `hero-field-poster.webp` 由 `scripts/capture-hero-field-poster.mjs` 生成(登记于 asset-provenance §6)。
+R22 登记表从归零恢复为一条(marker `HeroField`)。flag 关 ⇒ 首屏仍是 E 案,基线零影响。
-⚠ 例外**不外溢**:营销页正文、卡片、导航、移动档一律不适用;移动档首屏不跑 WebGL(落 E 案)。
-
-决策状态:✅ 2026-12-02 用户认可(ADR-0016 §10.5;R26 已落地,含三向自证与突变验证)
+决策状态:❌ 2026-12-02 撤回(ADR-0016 §12 撤回段)
### 服务编号+色条编码(Service Number + Color Bar)
服务模块的区分方式,取代纯颜色编码:
diff --git a/demo/hero-content/index.html b/demo/hero-content/index.html
new file mode 100644
index 00000000..62557128
--- /dev/null
+++ b/demo/hero-content/index.html
@@ -0,0 +1,936 @@
+
+
+
+
+
+Hero 内容方案对照 · 数据驱动决策
+
+
+
+
+
+
+
+
+
+
企业数字化转型
+
让每一家企业都拥有数据驱动的决策能力
+
专业核心团队,以结果导向的服务理念,做中国企业数字化转型的同行者与成长伙伴,从战略诊断到系统落地、再到持续陪跑。
+
预约咨询看行业实践
+
+
+01 噪声数据尚未被理解
+
+
+
Hero 内容方案对照
+
三拍等长(16 / 13 / 13s + 压黑),只换「动画讲什么」。
+
+
+
+
+
+
+
+
0s16.4s29.8s42.8s
+
+
+
+
+
拍 1k 0.00t 0.0s
+
+
+键盘 1–3 切方案 · 空格播放/暂停
+
+
+
+
+
+
+
diff --git a/demo/hero-content/vendor/addons/postprocessing/AfterimagePass.js b/demo/hero-content/vendor/addons/postprocessing/AfterimagePass.js
new file mode 100644
index 00000000..a4900c0d
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/AfterimagePass.js
@@ -0,0 +1,187 @@
+import {
+ HalfFloatType,
+ NearestFilter,
+ NoBlending,
+ ShaderMaterial,
+ UniformsUtils,
+ WebGLRenderTarget
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { CopyShader } from '../shaders/CopyShader.js';
+import { AfterimageShader } from '../shaders/AfterimageShader.js';
+
+/**
+ * Pass for a basic after image effect.
+ *
+ * ```js
+ * const afterimagePass = new AfterimagePass( 0.9 );
+ * composer.addPass( afterimagePass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { AfterimagePass } from 'three/addons/postprocessing/AfterimagePass.js';
+ */
+class AfterimagePass extends Pass {
+
+ /**
+ * Constructs a new after image pass.
+ *
+ * @param {number} [damp=0.96] - The damping intensity. A higher value means a stronger after image effect.
+ */
+ constructor( damp = 0.96 ) {
+
+ super();
+
+ /**
+ * The pass uniforms. Use this object if you want to update the
+ * `damp` value at runtime.
+ * ```js
+ * pass.uniforms.damp.value = 0.9;
+ * ```
+ *
+ * @type {Object}
+ */
+ this.uniforms = UniformsUtils.clone( AfterimageShader.uniforms );
+
+ this.damp = damp;
+
+ /**
+ * The composition material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.compFsMaterial = new ShaderMaterial( {
+
+ uniforms: this.uniforms,
+ vertexShader: AfterimageShader.vertexShader,
+ fragmentShader: AfterimageShader.fragmentShader
+
+ } );
+
+ /**
+ * The copy material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.copyFsMaterial = new ShaderMaterial( {
+ uniforms: UniformsUtils.clone( CopyShader.uniforms ),
+ vertexShader: CopyShader.vertexShader,
+ fragmentShader: CopyShader.fragmentShader,
+ blending: NoBlending,
+ depthTest: false,
+ depthWrite: false
+ } );
+
+ // internals
+
+ this._textureComp = new WebGLRenderTarget( window.innerWidth, window.innerHeight, {
+ magFilter: NearestFilter,
+ type: HalfFloatType,
+ depthBuffer: false
+ } );
+
+ this._textureOld = new WebGLRenderTarget( window.innerWidth, window.innerHeight, {
+ magFilter: NearestFilter,
+ type: HalfFloatType,
+ depthBuffer: false
+ } );
+
+ this._compFsQuad = new FullScreenQuad( this.compFsMaterial );
+ this._copyFsQuad = new FullScreenQuad( this.copyFsMaterial );
+
+ }
+
+ /**
+ * The damping intensity, from 0.0 to 1.0. A higher value means a stronger after image effect.
+ *
+ * @type {number}
+ */
+ get damp() {
+
+ return this.uniforms[ 'damp' ].value;
+
+ }
+
+ set damp( value ) {
+
+ this.uniforms[ 'damp' ].value = value;
+
+ }
+
+ /**
+ * Performs the after image pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
+
+ this.uniforms[ 'tOld' ].value = this._textureOld.texture;
+ this.uniforms[ 'tNew' ].value = readBuffer.texture;
+
+ renderer.setRenderTarget( this._textureComp );
+ this._compFsQuad.render( renderer );
+
+ this._copyFsQuad.material.uniforms.tDiffuse.value = this._textureComp.texture;
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+ this._copyFsQuad.render( renderer );
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+
+ if ( this.clear ) renderer.clear();
+
+ this._copyFsQuad.render( renderer );
+
+ }
+
+ // Swap buffers.
+ const temp = this._textureOld;
+ this._textureOld = this._textureComp;
+ this._textureComp = temp;
+ // Now textureOld contains the latest image, ready for the next frame.
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this._textureComp.setSize( width, height );
+ this._textureOld.setSize( width, height );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this._textureComp.dispose();
+ this._textureOld.dispose();
+
+ this.compFsMaterial.dispose();
+ this.copyFsMaterial.dispose();
+
+ this._compFsQuad.dispose();
+ this._copyFsQuad.dispose();
+
+ }
+
+}
+
+export { AfterimagePass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/BloomPass.js b/demo/hero-content/vendor/addons/postprocessing/BloomPass.js
new file mode 100644
index 00000000..0b2b8cbb
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/BloomPass.js
@@ -0,0 +1,274 @@
+import {
+ AdditiveBlending,
+ HalfFloatType,
+ ShaderMaterial,
+ UniformsUtils,
+ Vector2,
+ WebGLRenderTarget
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { ConvolutionShader } from '../shaders/ConvolutionShader.js';
+
+/**
+ * A pass for a basic Bloom effect.
+ *
+ * {@link UnrealBloomPass} produces a more advanced Bloom but is also
+ * more expensive.
+ *
+ * ```js
+ * const effectBloom = new BloomPass( 0.75 );
+ * composer.addPass( effectBloom );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { BloomPass } from 'three/addons/postprocessing/BloomPass.js';
+ */
+class BloomPass extends Pass {
+
+ /**
+ * Constructs a new Bloom pass.
+ *
+ * @param {number} [strength=1] - The Bloom strength.
+ * @param {number} [kernelSize=25] - The kernel size.
+ * @param {number} [sigma=4] - The sigma.
+ */
+ constructor( strength = 1, kernelSize = 25, sigma = 4 ) {
+
+ super();
+
+ // combine material
+
+ /**
+ * The combine pass uniforms.
+ *
+ * @type {Object}
+ */
+ this.combineUniforms = UniformsUtils.clone( CombineShader.uniforms );
+ this.combineUniforms[ 'strength' ].value = strength;
+
+ /**
+ * The combine pass material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.materialCombine = new ShaderMaterial( {
+
+ name: CombineShader.name,
+ uniforms: this.combineUniforms,
+ vertexShader: CombineShader.vertexShader,
+ fragmentShader: CombineShader.fragmentShader,
+ blending: AdditiveBlending,
+ transparent: true
+
+ } );
+
+ // convolution material
+
+ const convolutionShader = ConvolutionShader;
+
+ /**
+ * The convolution pass uniforms.
+ *
+ * @type {Object}
+ */
+ this.convolutionUniforms = UniformsUtils.clone( convolutionShader.uniforms );
+
+ this.convolutionUniforms[ 'uImageIncrement' ].value = BloomPass.blurX;
+ this.convolutionUniforms[ 'cKernel' ].value = buildKernel( sigma );
+
+ /**
+ * The convolution pass material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.materialConvolution = new ShaderMaterial( {
+
+ name: convolutionShader.name,
+ uniforms: this.convolutionUniforms,
+ vertexShader: convolutionShader.vertexShader,
+ fragmentShader: convolutionShader.fragmentShader,
+ defines: {
+ 'KERNEL_SIZE_FLOAT': kernelSize.toFixed( 1 ),
+ 'KERNEL_SIZE_INT': kernelSize.toFixed( 0 )
+ }
+
+ } );
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ // internals
+
+ this._renderTargetX = new WebGLRenderTarget( 1, 1, { type: HalfFloatType, depthBuffer: false } ); // will be resized later
+ this._renderTargetX.texture.name = 'BloomPass.x';
+ this._renderTargetY = new WebGLRenderTarget( 1, 1, { type: HalfFloatType, depthBuffer: false } ); // will be resized later
+ this._renderTargetY.texture.name = 'BloomPass.y';
+
+ this._fsQuad = new FullScreenQuad( null );
+
+ }
+
+ /**
+ * Performs the Bloom pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
+
+ if ( maskActive ) renderer.state.buffers.stencil.setTest( false );
+
+ // Render quad with blurred scene into texture (convolution pass 1)
+
+ this._fsQuad.material = this.materialConvolution;
+
+ this.convolutionUniforms[ 'tDiffuse' ].value = readBuffer.texture;
+ this.convolutionUniforms[ 'uImageIncrement' ].value = BloomPass.blurX;
+
+ renderer.setRenderTarget( this._renderTargetX );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+
+ // Render quad with blurred scene into texture (convolution pass 2)
+
+ this.convolutionUniforms[ 'tDiffuse' ].value = this._renderTargetX.texture;
+ this.convolutionUniforms[ 'uImageIncrement' ].value = BloomPass.blurY;
+
+ renderer.setRenderTarget( this._renderTargetY );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ // Render original scene with superimposed blur to texture
+
+ this._fsQuad.material = this.materialCombine;
+
+ this.combineUniforms[ 'tDiffuse' ].value = this._renderTargetY.texture;
+
+ if ( maskActive ) renderer.state.buffers.stencil.setTest( true );
+
+ renderer.setRenderTarget( readBuffer );
+ if ( this.clear ) renderer.clear();
+ this._fsQuad.render( renderer );
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this._renderTargetX.setSize( width, height );
+ this._renderTargetY.setSize( width, height );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this._renderTargetX.dispose();
+ this._renderTargetY.dispose();
+
+ this.materialCombine.dispose();
+ this.materialConvolution.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+}
+
+const CombineShader = {
+
+ name: 'CombineShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'strength': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float strength;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 texel = texture2D( tDiffuse, vUv );
+ gl_FragColor = strength * texel;
+
+ }`
+
+};
+
+BloomPass.blurX = new Vector2( 0.001953125, 0.0 );
+BloomPass.blurY = new Vector2( 0.0, 0.001953125 );
+
+
+function gauss( x, sigma ) {
+
+ return Math.exp( - ( x * x ) / ( 2.0 * sigma * sigma ) );
+
+}
+
+function buildKernel( sigma ) {
+
+ // We loop off the sqrt(2 * pi) * sigma term, since we're going to normalize anyway.
+
+ const kMaxKernelSize = 25;
+ let kernelSize = 2 * Math.ceil( sigma * 3.0 ) + 1;
+
+ if ( kernelSize > kMaxKernelSize ) kernelSize = kMaxKernelSize;
+
+ const halfWidth = ( kernelSize - 1 ) * 0.5;
+
+ const values = new Array( kernelSize );
+ let sum = 0.0;
+ for ( let i = 0; i < kernelSize; ++ i ) {
+
+ values[ i ] = gauss( i - halfWidth, sigma );
+ sum += values[ i ];
+
+ }
+
+ // normalize the kernel
+
+ for ( let i = 0; i < kernelSize; ++ i ) values[ i ] /= sum;
+
+ return values;
+
+}
+
+export { BloomPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/BokehPass.js b/demo/hero-content/vendor/addons/postprocessing/BokehPass.js
new file mode 100644
index 00000000..30444657
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/BokehPass.js
@@ -0,0 +1,218 @@
+import {
+ Color,
+ HalfFloatType,
+ MeshDepthMaterial,
+ NearestFilter,
+ NoBlending,
+ RGBADepthPacking,
+ ShaderMaterial,
+ UniformsUtils,
+ WebGLRenderTarget
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { BokehShader } from '../shaders/BokehShader.js';
+
+/**
+ * Pass for creating depth of field (DOF) effect.
+ *
+ * ```js
+ * const bokehPass = new BokehPass( scene, camera, {
+ * focus: 500,
+ * aperture: 5,
+ * maxblur: 0.01
+ * } );
+ * composer.addPass( bokehPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { BokehPass } from 'three/addons/postprocessing/BokehPass.js';
+ */
+class BokehPass extends Pass {
+
+ /**
+ * Constructs a new Bokeh pass.
+ *
+ * @param {Scene} scene - The scene to render the DOF for.
+ * @param {Camera} camera - The camera.
+ * @param {BokehPass~Options} params - The pass options.
+ */
+ constructor( scene, camera, params ) {
+
+ super();
+
+ /**
+ * The scene to render the DOF for.
+ *
+ * @type {Scene}
+ */
+ this.scene = scene;
+
+ /**
+ * The camera.
+ *
+ * @type {Camera}
+ */
+ this.camera = camera;
+
+ const focus = ( params.focus !== undefined ) ? params.focus : 1.0;
+ const aperture = ( params.aperture !== undefined ) ? params.aperture : 0.025;
+ const maxblur = ( params.maxblur !== undefined ) ? params.maxblur : 1.0;
+
+ // render targets
+
+ this._renderTargetDepth = new WebGLRenderTarget( 1, 1, { // will be resized later
+ minFilter: NearestFilter,
+ magFilter: NearestFilter,
+ type: HalfFloatType
+ } );
+
+ this._renderTargetDepth.texture.name = 'BokehPass.depth';
+
+ // depth material
+
+ this._materialDepth = new MeshDepthMaterial();
+ this._materialDepth.depthPacking = RGBADepthPacking;
+ this._materialDepth.blending = NoBlending;
+
+ // bokeh material
+
+ const bokehUniforms = UniformsUtils.clone( BokehShader.uniforms );
+
+ bokehUniforms[ 'tDepth' ].value = this._renderTargetDepth.texture;
+
+ bokehUniforms[ 'focus' ].value = focus;
+ bokehUniforms[ 'aspect' ].value = camera.aspect;
+ bokehUniforms[ 'aperture' ].value = aperture;
+ bokehUniforms[ 'maxblur' ].value = maxblur;
+ bokehUniforms[ 'nearClip' ].value = camera.near;
+ bokehUniforms[ 'farClip' ].value = camera.far;
+
+ /**
+ * The pass bokeh material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.materialBokeh = new ShaderMaterial( {
+ defines: Object.assign( {}, BokehShader.defines ),
+ uniforms: bokehUniforms,
+ vertexShader: BokehShader.vertexShader,
+ fragmentShader: BokehShader.fragmentShader
+ } );
+
+ /**
+ * The pass uniforms. Use this object if you want to update the
+ * `focus`, `aperture` or `maxblur` values at runtime.
+ *
+ * ```js
+ * pass.uniforms.focus.value = focus;
+ * pass.uniforms.aperture.value = aperture;
+ * pass.uniforms.maxblur.value = maxblur;
+ * ```
+ *
+ * @type {Object}
+ */
+ this.uniforms = bokehUniforms;
+
+ // internals
+
+ this._fsQuad = new FullScreenQuad( this.materialBokeh );
+
+ this._oldClearColor = new Color();
+
+ }
+
+ /**
+ * Performs the Bokeh pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
+
+ // Render depth into texture
+
+ this.scene.overrideMaterial = this._materialDepth;
+
+ renderer.getClearColor( this._oldClearColor );
+ const oldClearAlpha = renderer.getClearAlpha();
+ const oldAutoClear = renderer.autoClear;
+ renderer.autoClear = false;
+
+ renderer.setClearColor( 0xffffff );
+ renderer.setClearAlpha( 1.0 );
+ renderer.setRenderTarget( this._renderTargetDepth );
+ renderer.clear();
+ renderer.render( this.scene, this.camera );
+
+ // Render bokeh composite
+
+ this.uniforms[ 'tColor' ].value = readBuffer.texture;
+ this.uniforms[ 'nearClip' ].value = this.camera.near;
+ this.uniforms[ 'farClip' ].value = this.camera.far;
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+ this._fsQuad.render( renderer );
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ }
+
+ this.scene.overrideMaterial = null;
+ renderer.setClearColor( this._oldClearColor );
+ renderer.setClearAlpha( oldClearAlpha );
+ renderer.autoClear = oldAutoClear;
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this.materialBokeh.uniforms[ 'aspect' ].value = width / height;
+
+ this._renderTargetDepth.setSize( width, height );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this._renderTargetDepth.dispose();
+
+ this._materialDepth.dispose();
+ this.materialBokeh.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+}
+
+/**
+ * Constructor options of `BokehPass`.
+ *
+ * @typedef {Object} BokehPass~Options
+ * @property {number} [focus=1] - Defines the effect's focus which is the distance along the camera's look direction in world units.
+ * @property {number} [aperture=0.025] - Defines the effect's aperture.
+ * @property {number} [maxblur=1] - Defines the effect's maximum blur.
+ **/
+
+export { BokehPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/ClearPass.js b/demo/hero-content/vendor/addons/postprocessing/ClearPass.js
new file mode 100644
index 00000000..9b1cc0e1
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/ClearPass.js
@@ -0,0 +1,97 @@
+import {
+ Color
+} from 'three';
+import { Pass } from './Pass.js';
+
+/**
+ * This class can be used to force a clear operation for the current read or
+ * default framebuffer (when rendering to screen).
+ *
+ * ```js
+ * const clearPass = new ClearPass();
+ * composer.addPass( clearPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { ClearPass } from 'three/addons/postprocessing/ClearPass.js';
+ */
+class ClearPass extends Pass {
+
+ /**
+ * Constructs a new clear pass.
+ *
+ * @param {(number|Color|string)} [clearColor=0x000000] - The clear color.
+ * @param {number} [clearAlpha=0] - The clear alpha.
+ */
+ constructor( clearColor = 0x000000, clearAlpha = 0 ) {
+
+ super();
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ /**
+ * The clear color.
+ *
+ * @type {(number|Color|string)}
+ * @default 0x000000
+ */
+ this.clearColor = clearColor;
+
+ /**
+ * The clear alpha.
+ *
+ * @type {number}
+ * @default 0
+ */
+ this.clearAlpha = clearAlpha;
+
+ // internals
+
+ this._oldClearColor = new Color();
+
+ }
+
+ /**
+ * Performs the clear operation. This affects the current read or the default framebuffer.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+
+ let oldClearAlpha;
+
+ if ( this.clearColor ) {
+
+ renderer.getClearColor( this._oldClearColor );
+ oldClearAlpha = renderer.getClearAlpha();
+
+ renderer.setClearColor( this.clearColor, this.clearAlpha );
+
+ }
+
+ renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
+ renderer.clear();
+
+ if ( this.clearColor ) {
+
+ renderer.setClearColor( this._oldClearColor, oldClearAlpha );
+
+ }
+
+ }
+
+}
+
+export { ClearPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/CubeTexturePass.js b/demo/hero-content/vendor/addons/postprocessing/CubeTexturePass.js
new file mode 100644
index 00000000..8089e2b4
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/CubeTexturePass.js
@@ -0,0 +1,146 @@
+import {
+ BackSide,
+ BoxGeometry,
+ Mesh,
+ PerspectiveCamera,
+ Scene,
+ ShaderLib,
+ ShaderMaterial,
+ UniformsUtils
+} from 'three';
+import { Pass } from './Pass.js';
+
+/**
+ * This pass can be used to render a cube texture over the entire screen.
+ *
+ * ```js
+ * const cubeMap = new THREE.CubeTextureLoader().load( urls );
+ *
+ * const cubeTexturePass = new CubeTexturePass( camera, cubemap );
+ * composer.addPass( cubeTexturePass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { CubeTexturePass } from 'three/addons/postprocessing/CubeTexturePass.js';
+ */
+class CubeTexturePass extends Pass {
+
+ /**
+ * Constructs a new cube texture pass.
+ *
+ * @param {PerspectiveCamera} camera - The camera.
+ * @param {CubeTexture} tCube - The cube texture to render.
+ * @param {number} [opacity=1] - The opacity.
+ */
+ constructor( camera, tCube, opacity = 1 ) {
+
+ super();
+
+ /**
+ * The camera.
+ *
+ * @type {PerspectiveCamera}
+ */
+ this.camera = camera;
+
+ /**
+ * The cube texture to render.
+ *
+ * @type {CubeTexture}
+ */
+ this.tCube = tCube;
+
+ /**
+ * The opacity.
+ *
+ * @type {number}
+ * @default 1
+ */
+ this.opacity = opacity;
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ // internals
+
+ const cubeShader = ShaderLib[ 'cube' ];
+
+ this._cubeMesh = new Mesh(
+ new BoxGeometry( 10, 10, 10 ),
+ new ShaderMaterial( {
+ uniforms: UniformsUtils.clone( cubeShader.uniforms ),
+ vertexShader: cubeShader.vertexShader,
+ fragmentShader: cubeShader.fragmentShader,
+ depthTest: false,
+ depthWrite: false,
+ side: BackSide
+ } )
+ );
+
+ Object.defineProperty( this._cubeMesh.material, 'envMap', {
+
+ get: function () {
+
+ return this.uniforms.tCube.value;
+
+ }
+
+ } );
+
+ this._cubeScene = new Scene();
+ this._cubeCamera = new PerspectiveCamera();
+ this._cubeScene.add( this._cubeMesh );
+
+ }
+
+ /**
+ * Performs the cube texture pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
+
+ const oldAutoClear = renderer.autoClear;
+ renderer.autoClear = false;
+
+ this._cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix );
+ this._cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld );
+
+ this._cubeMesh.material.uniforms.tCube.value = this.tCube;
+ this._cubeMesh.material.uniforms.tFlip.value = ( this.tCube.isCubeTexture && this.tCube.isRenderTargetTexture === false ) ? - 1 : 1;
+ this._cubeMesh.material.uniforms.opacity.value = this.opacity;
+ this._cubeMesh.material.transparent = ( this.opacity < 1.0 );
+
+ renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
+ if ( this.clear ) renderer.clear();
+ renderer.render( this._cubeScene, this._cubeCamera );
+
+ renderer.autoClear = oldAutoClear;
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this._cubeMesh.geometry.dispose();
+ this._cubeMesh.material.dispose();
+
+ }
+
+}
+
+export { CubeTexturePass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/DotScreenPass.js b/demo/hero-content/vendor/addons/postprocessing/DotScreenPass.js
new file mode 100644
index 00000000..8efc56be
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/DotScreenPass.js
@@ -0,0 +1,114 @@
+import {
+ ShaderMaterial,
+ UniformsUtils
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { DotScreenShader } from '../shaders/DotScreenShader.js';
+
+/**
+ * Pass for creating a dot-screen effect.
+ *
+ * ```js
+ * const pass = new DotScreenPass( new THREE.Vector2( 0, 0 ), 0.5, 0.8 );
+ * composer.addPass( pass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { DotScreenPass } from 'three/addons/postprocessing/DotScreenPass.js';
+ */
+class DotScreenPass extends Pass {
+
+ /**
+ * Constructs a new dot screen pass.
+ *
+ * @param {Vector2} center - The center point.
+ * @param {number} angle - The rotation of the effect in radians.
+ * @param {number} scale - The scale of the effect. A higher value means smaller dots.
+ */
+ constructor( center, angle, scale ) {
+
+ super();
+
+ /**
+ * The pass uniforms. Use this object if you want to update the
+ * `center`, `angle` or `scale` values at runtime.
+ * ```js
+ * pass.uniforms.center.value.copy( center );
+ * pass.uniforms.angle.value = 0;
+ * pass.uniforms.scale.value = 0.5;
+ * ```
+ *
+ * @type {Object}
+ */
+ this.uniforms = UniformsUtils.clone( DotScreenShader.uniforms );
+
+ if ( center !== undefined ) this.uniforms[ 'center' ].value.copy( center );
+ if ( angle !== undefined ) this.uniforms[ 'angle' ].value = angle;
+ if ( scale !== undefined ) this.uniforms[ 'scale' ].value = scale;
+
+ /**
+ * The pass material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.material = new ShaderMaterial( {
+
+ name: DotScreenShader.name,
+ uniforms: this.uniforms,
+ vertexShader: DotScreenShader.vertexShader,
+ fragmentShader: DotScreenShader.fragmentShader
+
+ } );
+
+ // internals
+
+ this._fsQuad = new FullScreenQuad( this.material );
+
+ }
+
+ /**
+ * Performs the dot screen pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+
+ this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
+ this.uniforms[ 'tSize' ].value.set( readBuffer.width, readBuffer.height );
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+ this._fsQuad.render( renderer );
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+ if ( this.clear ) renderer.clear();
+ this._fsQuad.render( renderer );
+
+ }
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.material.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+}
+
+export { DotScreenPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/EffectComposer.js b/demo/hero-content/vendor/addons/postprocessing/EffectComposer.js
new file mode 100644
index 00000000..a16d97ea
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/EffectComposer.js
@@ -0,0 +1,365 @@
+import {
+ HalfFloatType,
+ NoBlending,
+ Timer,
+ Vector2,
+ WebGLRenderTarget
+} from 'three';
+import { CopyShader } from '../shaders/CopyShader.js';
+import { ShaderPass } from './ShaderPass.js';
+import { ClearMaskPass, MaskPass } from './MaskPass.js';
+
+/**
+ * Used to implement post-processing effects in three.js.
+ * The class manages a chain of post-processing passes to produce the final visual result.
+ * Post-processing passes are executed in order of their addition/insertion.
+ * The last pass is automatically rendered to screen.
+ *
+ * This module can only be used with {@link WebGLRenderer}.
+ *
+ * ```js
+ * const composer = new EffectComposer( renderer );
+ *
+ * // adding some passes
+ * const renderPass = new RenderPass( scene, camera );
+ * composer.addPass( renderPass );
+ *
+ * const glitchPass = new GlitchPass();
+ * composer.addPass( glitchPass );
+ *
+ * const outputPass = new OutputPass()
+ * composer.addPass( outputPass );
+ *
+ * function animate() {
+ *
+ * composer.render(); // instead of renderer.render()
+ *
+ * }
+ * ```
+ *
+ * @three_import import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
+ */
+class EffectComposer {
+
+ /**
+ * Constructs a new effect composer.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} [renderTarget] - This render target and a clone will
+ * be used as the internal read and write buffers. If not given, the composer creates
+ * the buffers automatically.
+ */
+ constructor( renderer, renderTarget ) {
+
+ /**
+ * The renderer.
+ *
+ * @type {WebGLRenderer}
+ */
+ this.renderer = renderer;
+
+ this._pixelRatio = renderer.getPixelRatio();
+
+ if ( renderTarget === undefined ) {
+
+ const size = renderer.getSize( new Vector2() );
+ this._width = size.width;
+ this._height = size.height;
+
+ renderTarget = new WebGLRenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, { type: HalfFloatType } );
+ renderTarget.texture.name = 'EffectComposer.rt1';
+
+ } else {
+
+ this._width = renderTarget.width;
+ this._height = renderTarget.height;
+
+ }
+
+ this.renderTarget1 = renderTarget;
+ this.renderTarget2 = renderTarget.clone();
+ this.renderTarget2.texture.name = 'EffectComposer.rt2';
+
+ /**
+ * A reference to the internal write buffer. Passes usually write
+ * their result into this buffer.
+ *
+ * @type {WebGLRenderTarget}
+ */
+ this.writeBuffer = this.renderTarget1;
+
+ /**
+ * A reference to the internal read buffer. Passes usually read
+ * the previous render result from this buffer.
+ *
+ * @type {WebGLRenderTarget}
+ */
+ this.readBuffer = this.renderTarget2;
+
+ /**
+ * Whether the final pass is rendered to the screen (default framebuffer) or not.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.renderToScreen = true;
+
+ /**
+ * An array representing the (ordered) chain of post-processing passes.
+ *
+ * @type {Array}
+ */
+ this.passes = [];
+
+ /**
+ * A copy pass used for internal swap operations.
+ *
+ * @private
+ * @type {ShaderPass}
+ */
+ this.copyPass = new ShaderPass( CopyShader );
+ this.copyPass.material.blending = NoBlending;
+
+ /**
+ * The internal timer for managing time data.
+ *
+ * @private
+ * @type {Timer}
+ */
+ this.timer = new Timer();
+
+ }
+
+ /**
+ * Swaps the internal read/write buffers.
+ */
+ swapBuffers() {
+
+ const tmp = this.readBuffer;
+ this.readBuffer = this.writeBuffer;
+ this.writeBuffer = tmp;
+
+ }
+
+ /**
+ * Adds the given pass to the pass chain.
+ *
+ * @param {Pass} pass - The pass to add.
+ */
+ addPass( pass ) {
+
+ this.passes.push( pass );
+ pass.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
+
+ }
+
+ /**
+ * Inserts the given pass at a given index.
+ *
+ * @param {Pass} pass - The pass to insert.
+ * @param {number} index - The index into the pass chain.
+ */
+ insertPass( pass, index ) {
+
+ this.passes.splice( index, 0, pass );
+ pass.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
+
+ }
+
+ /**
+ * Removes the given pass from the pass chain.
+ *
+ * @param {Pass} pass - The pass to remove.
+ */
+ removePass( pass ) {
+
+ const index = this.passes.indexOf( pass );
+
+ if ( index !== - 1 ) {
+
+ this.passes.splice( index, 1 );
+
+ }
+
+ }
+
+ /**
+ * Returns `true` if the pass for the given index is the last enabled pass in the pass chain.
+ *
+ * @param {number} passIndex - The pass index.
+ * @return {boolean} Whether the pass for the given index is the last pass in the pass chain.
+ */
+ isLastEnabledPass( passIndex ) {
+
+ for ( let i = passIndex + 1; i < this.passes.length; i ++ ) {
+
+ if ( this.passes[ i ].enabled ) {
+
+ return false;
+
+ }
+
+ }
+
+ return true;
+
+ }
+
+ /**
+ * Executes all enabled post-processing passes in order to produce the final frame.
+ *
+ * @param {number} deltaTime - The delta time in seconds. If not given, the composer computes
+ * its own time delta value.
+ */
+ render( deltaTime ) {
+
+ // deltaTime value is in seconds
+
+ this.timer.update();
+
+ if ( deltaTime === undefined ) {
+
+ deltaTime = this.timer.getDelta();
+
+ }
+
+ const currentRenderTarget = this.renderer.getRenderTarget();
+
+ let maskActive = false;
+
+ for ( let i = 0, il = this.passes.length; i < il; i ++ ) {
+
+ const pass = this.passes[ i ];
+
+ if ( pass.enabled === false ) continue;
+
+ pass.renderToScreen = ( this.renderToScreen && this.isLastEnabledPass( i ) );
+ pass.render( this.renderer, this.writeBuffer, this.readBuffer, deltaTime, maskActive );
+
+ if ( pass.needsSwap ) {
+
+ if ( maskActive ) {
+
+ const context = this.renderer.getContext();
+ const stencil = this.renderer.state.buffers.stencil;
+
+ //context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
+ stencil.setFunc( context.NOTEQUAL, 1, 0xffffffff );
+
+ this.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, deltaTime );
+
+ //context.stencilFunc( context.EQUAL, 1, 0xffffffff );
+ stencil.setFunc( context.EQUAL, 1, 0xffffffff );
+
+ }
+
+ this.swapBuffers();
+
+ }
+
+ if ( MaskPass !== undefined ) {
+
+ if ( pass instanceof MaskPass ) {
+
+ maskActive = true;
+
+ } else if ( pass instanceof ClearMaskPass ) {
+
+ maskActive = false;
+
+ }
+
+ }
+
+ }
+
+ this.renderer.setRenderTarget( currentRenderTarget );
+
+ }
+
+ /**
+ * Resets the internal state of the EffectComposer.
+ *
+ * @param {WebGLRenderTarget} [renderTarget] - This render target has the same purpose like
+ * the one from the constructor. If set, it is used to setup the read and write buffers.
+ */
+ reset( renderTarget ) {
+
+ if ( renderTarget === undefined ) {
+
+ const size = this.renderer.getSize( new Vector2() );
+ this._pixelRatio = this.renderer.getPixelRatio();
+ this._width = size.width;
+ this._height = size.height;
+
+ renderTarget = this.renderTarget1.clone();
+ renderTarget.setSize( this._width * this._pixelRatio, this._height * this._pixelRatio );
+
+ }
+
+ this.renderTarget1.dispose();
+ this.renderTarget2.dispose();
+ this.renderTarget1 = renderTarget;
+ this.renderTarget2 = renderTarget.clone();
+
+ this.writeBuffer = this.renderTarget1;
+ this.readBuffer = this.renderTarget2;
+
+ }
+
+ /**
+ * Resizes the internal read and write buffers as well as all passes. Similar to {@link WebGLRenderer#setSize},
+ * this method honors the current pixel ration.
+ *
+ * @param {number} width - The width in logical pixels.
+ * @param {number} height - The height in logical pixels.
+ */
+ setSize( width, height ) {
+
+ this._width = width;
+ this._height = height;
+
+ const effectiveWidth = this._width * this._pixelRatio;
+ const effectiveHeight = this._height * this._pixelRatio;
+
+ this.renderTarget1.setSize( effectiveWidth, effectiveHeight );
+ this.renderTarget2.setSize( effectiveWidth, effectiveHeight );
+
+ for ( let i = 0; i < this.passes.length; i ++ ) {
+
+ this.passes[ i ].setSize( effectiveWidth, effectiveHeight );
+
+ }
+
+ }
+
+ /**
+ * Sets device pixel ratio. This is usually used for HiDPI device to prevent blurring output.
+ * Setting the pixel ratio will automatically resize the composer.
+ *
+ * @param {number} pixelRatio - The pixel ratio to set.
+ */
+ setPixelRatio( pixelRatio ) {
+
+ this._pixelRatio = pixelRatio;
+
+ this.setSize( this._width, this._height );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the composer is no longer used in your app.
+ */
+ dispose() {
+
+ this.renderTarget1.dispose();
+ this.renderTarget2.dispose();
+
+ this.copyPass.dispose();
+
+ }
+
+}
+
+export { EffectComposer };
diff --git a/demo/hero-content/vendor/addons/postprocessing/FXAAPass.js b/demo/hero-content/vendor/addons/postprocessing/FXAAPass.js
new file mode 100644
index 00000000..50c52876
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/FXAAPass.js
@@ -0,0 +1,40 @@
+import { FXAAShader } from '../shaders/FXAAShader.js';
+import { ShaderPass } from './ShaderPass.js';
+
+/**
+ * A pass for applying FXAA.
+ *
+ * ```js
+ * const fxaaPass = new FXAAPass();
+ * composer.addPass( fxaaPass );
+ * ```
+ *
+ * @augments ShaderPass
+ * @three_import import { FXAAPass } from 'three/addons/postprocessing/FXAAPass.js';
+ */
+class FXAAPass extends ShaderPass {
+
+ /**
+ * Constructs a new FXAA pass.
+ */
+ constructor() {
+
+ super( FXAAShader );
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this.material.uniforms[ 'resolution' ].value.set( 1 / width, 1 / height );
+
+ }
+
+}
+
+export { FXAAPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/FilmPass.js b/demo/hero-content/vendor/addons/postprocessing/FilmPass.js
new file mode 100644
index 00000000..00017af6
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/FilmPass.js
@@ -0,0 +1,113 @@
+import {
+ ShaderMaterial,
+ UniformsUtils
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { FilmShader } from '../shaders/FilmShader.js';
+
+/**
+ * This pass can be used to create a film grain effect.
+ *
+ * ```js
+ * const filmPass = new FilmPass();
+ * composer.addPass( filmPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { FilmPass } from 'three/addons/postprocessing/FilmPass.js';
+ */
+class FilmPass extends Pass {
+
+ /**
+ * Constructs a new film pass.
+ *
+ * @param {number} [intensity=0.5] - The grain intensity in the range `[0,1]` (0 = no effect, 1 = full effect).
+ * @param {boolean} [grayscale=false] - Whether to apply a grayscale effect or not.
+ */
+ constructor( intensity = 0.5, grayscale = false ) {
+
+ super();
+
+ const shader = FilmShader;
+
+ /**
+ * The pass uniforms. Use this object if you want to update the
+ * `intensity` or `grayscale` values at runtime.
+ * ```js
+ * pass.uniforms.intensity.value = 1;
+ * pass.uniforms.grayscale.value = true;
+ * ```
+ *
+ * @type {Object}
+ */
+ this.uniforms = UniformsUtils.clone( shader.uniforms );
+
+ /**
+ * The pass material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.material = new ShaderMaterial( {
+
+ name: shader.name,
+ uniforms: this.uniforms,
+ vertexShader: shader.vertexShader,
+ fragmentShader: shader.fragmentShader
+
+ } );
+
+ this.uniforms.intensity.value = intensity;
+ this.uniforms.grayscale.value = grayscale;
+
+ // internals
+
+ this._fsQuad = new FullScreenQuad( this.material );
+
+ }
+
+ /**
+ * Performs the film pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer, deltaTime /*, maskActive */ ) {
+
+ this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
+ this.uniforms[ 'time' ].value += deltaTime;
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+ this._fsQuad.render( renderer );
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+ if ( this.clear ) renderer.clear();
+ this._fsQuad.render( renderer );
+
+ }
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.material.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+}
+
+export { FilmPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/GTAOPass.js b/demo/hero-content/vendor/addons/postprocessing/GTAOPass.js
new file mode 100644
index 00000000..7666f32c
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/GTAOPass.js
@@ -0,0 +1,735 @@
+import {
+ AddEquation,
+ Color,
+ CustomBlending,
+ DataTexture,
+ DepthTexture,
+ DepthStencilFormat,
+ DstAlphaFactor,
+ DstColorFactor,
+ HalfFloatType,
+ MeshNormalMaterial,
+ NearestFilter,
+ NoBlending,
+ RepeatWrapping,
+ RGBAFormat,
+ ShaderMaterial,
+ UniformsUtils,
+ UnsignedByteType,
+ UnsignedInt248Type,
+ WebGLRenderTarget,
+ ZeroFactor
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { generateMagicSquareNoise, GTAOShader, GTAODepthShader, GTAOBlendShader } from '../shaders/GTAOShader.js';
+import { generatePdSamplePointInitializer, PoissonDenoiseShader } from '../shaders/PoissonDenoiseShader.js';
+import { CopyShader } from '../shaders/CopyShader.js';
+import { SimplexNoise } from '../math/SimplexNoise.js';
+
+/**
+ * A pass for an GTAO effect.
+ *
+ * `GTAOPass` provides better quality than {@link SSAOPass} but is also more expensive.
+ *
+ * ```js
+ * const gtaoPass = new GTAOPass( scene, camera, width, height );
+ * gtaoPass.output = GTAOPass.OUTPUT.Denoise;
+ * composer.addPass( gtaoPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { GTAOPass } from 'three/addons/postprocessing/GTAOPass.js';
+ */
+class GTAOPass extends Pass {
+
+ /**
+ * Constructs a new GTAO pass.
+ *
+ * @param {Scene} scene - The scene to compute the AO for.
+ * @param {Camera} camera - The camera.
+ * @param {number} [width=512] - The width of the effect.
+ * @param {number} [height=512] - The height of the effect.
+ * @param {Object} [parameters] - The pass parameters.
+ * @param {Object} [aoParameters] - The AO parameters.
+ * @param {Object} [pdParameters] - The denoise parameters.
+ */
+ constructor( scene, camera, width = 512, height = 512, parameters, aoParameters, pdParameters ) {
+
+ super();
+
+ /**
+ * The width of the effect.
+ *
+ * @type {number}
+ * @default 512
+ */
+ this.width = width;
+
+ /**
+ * The height of the effect.
+ *
+ * @type {number}
+ * @default 512
+ */
+ this.height = height;
+
+ /**
+ * Overwritten to perform a clear operation by default.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.clear = true;
+
+ /**
+ * The camera.
+ *
+ * @type {Camera}
+ */
+ this.camera = camera;
+
+ /**
+ * The scene to render the AO for.
+ *
+ * @type {Scene}
+ */
+ this.scene = scene;
+
+ /**
+ * The output configuration.
+ *
+ * @type {number}
+ * @default 0
+ */
+ this.output = 0;
+ this._renderGBuffer = true;
+ this._visibilityCache = [];
+
+ /**
+ * The AO blend intensity.
+ *
+ * @type {number}
+ * @default 1
+ */
+ this.blendIntensity = 1.;
+
+ /**
+ * The number of Poisson Denoise rings.
+ *
+ * @type {number}
+ * @default 2
+ */
+ this.pdRings = 2.;
+
+ /**
+ * The Poisson Denoise radius exponent.
+ *
+ * @type {number}
+ * @default 2
+ */
+ this.pdRadiusExponent = 2.;
+
+ /**
+ * The Poisson Denoise sample count.
+ *
+ * @type {number}
+ * @default 16
+ */
+ this.pdSamples = 16;
+
+ this.gtaoNoiseTexture = generateMagicSquareNoise();
+ this.pdNoiseTexture = this._generateNoise();
+
+ this.gtaoRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType, depthBuffer: false } );
+ this.pdRenderTarget = this.gtaoRenderTarget.clone();
+
+ this.gtaoMaterial = new ShaderMaterial( {
+ defines: Object.assign( {}, GTAOShader.defines ),
+ uniforms: UniformsUtils.clone( GTAOShader.uniforms ),
+ vertexShader: GTAOShader.vertexShader,
+ fragmentShader: GTAOShader.fragmentShader,
+ blending: NoBlending,
+ depthTest: false,
+ depthWrite: false,
+ } );
+ this.gtaoMaterial.defines.PERSPECTIVE_CAMERA = this.camera.isPerspectiveCamera ? 1 : 0;
+ this.gtaoMaterial.uniforms.tNoise.value = this.gtaoNoiseTexture;
+ this.gtaoMaterial.uniforms.resolution.value.set( this.width, this.height );
+ this.gtaoMaterial.uniforms.cameraNear.value = this.camera.near;
+ this.gtaoMaterial.uniforms.cameraFar.value = this.camera.far;
+
+ this.normalMaterial = new MeshNormalMaterial();
+ this.normalMaterial.blending = NoBlending;
+
+ this.pdMaterial = new ShaderMaterial( {
+ defines: Object.assign( {}, PoissonDenoiseShader.defines ),
+ uniforms: UniformsUtils.clone( PoissonDenoiseShader.uniforms ),
+ vertexShader: PoissonDenoiseShader.vertexShader,
+ fragmentShader: PoissonDenoiseShader.fragmentShader,
+ depthTest: false,
+ depthWrite: false,
+ } );
+ this.pdMaterial.uniforms.tDiffuse.value = this.gtaoRenderTarget.texture;
+ this.pdMaterial.uniforms.tNoise.value = this.pdNoiseTexture;
+ this.pdMaterial.uniforms.resolution.value.set( this.width, this.height );
+ this.pdMaterial.uniforms.lumaPhi.value = 10;
+ this.pdMaterial.uniforms.depthPhi.value = 2;
+ this.pdMaterial.uniforms.normalPhi.value = 3;
+ this.pdMaterial.uniforms.radius.value = 8;
+
+ this.depthRenderMaterial = new ShaderMaterial( {
+ defines: Object.assign( {}, GTAODepthShader.defines ),
+ uniforms: UniformsUtils.clone( GTAODepthShader.uniforms ),
+ vertexShader: GTAODepthShader.vertexShader,
+ fragmentShader: GTAODepthShader.fragmentShader,
+ blending: NoBlending
+ } );
+ this.depthRenderMaterial.uniforms.cameraNear.value = this.camera.near;
+ this.depthRenderMaterial.uniforms.cameraFar.value = this.camera.far;
+
+ this.copyMaterial = new ShaderMaterial( {
+ uniforms: UniformsUtils.clone( CopyShader.uniforms ),
+ vertexShader: CopyShader.vertexShader,
+ fragmentShader: CopyShader.fragmentShader,
+ transparent: true,
+ depthTest: false,
+ depthWrite: false,
+ blendSrc: DstColorFactor,
+ blendDst: ZeroFactor,
+ blendEquation: AddEquation,
+ blendSrcAlpha: DstAlphaFactor,
+ blendDstAlpha: ZeroFactor,
+ blendEquationAlpha: AddEquation
+ } );
+
+ this.blendMaterial = new ShaderMaterial( {
+ uniforms: UniformsUtils.clone( GTAOBlendShader.uniforms ),
+ vertexShader: GTAOBlendShader.vertexShader,
+ fragmentShader: GTAOBlendShader.fragmentShader,
+ transparent: true,
+ depthTest: false,
+ depthWrite: false,
+ blending: CustomBlending,
+ blendSrc: DstColorFactor,
+ blendDst: ZeroFactor,
+ blendEquation: AddEquation,
+ blendSrcAlpha: DstAlphaFactor,
+ blendDstAlpha: ZeroFactor,
+ blendEquationAlpha: AddEquation
+ } );
+
+ this._fsQuad = new FullScreenQuad( null );
+
+ this._originalClearColor = new Color();
+
+ this.setGBuffer( parameters ? parameters.depthTexture : undefined, parameters ? parameters.normalTexture : undefined );
+
+ if ( aoParameters !== undefined ) {
+
+ this.updateGtaoMaterial( aoParameters );
+
+ }
+
+ if ( pdParameters !== undefined ) {
+
+ this.updatePdMaterial( pdParameters );
+
+ }
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this.width = width;
+ this.height = height;
+
+ this.gtaoRenderTarget.setSize( width, height );
+ if ( this.normalRenderTarget ) this.normalRenderTarget.setSize( width, height );
+ this.pdRenderTarget.setSize( width, height );
+
+ this.gtaoMaterial.uniforms.resolution.value.set( width, height );
+ this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy( this.camera.projectionMatrix );
+ this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy( this.camera.projectionMatrixInverse );
+
+ this.pdMaterial.uniforms.resolution.value.set( width, height );
+ this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy( this.camera.projectionMatrixInverse );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.gtaoNoiseTexture.dispose();
+ this.pdNoiseTexture.dispose();
+ if ( this.normalRenderTarget ) this.normalRenderTarget.dispose();
+ this.gtaoRenderTarget.dispose();
+ this.pdRenderTarget.dispose();
+ this.normalMaterial.dispose();
+ this.pdMaterial.dispose();
+ this.copyMaterial.dispose();
+ this.depthRenderMaterial.dispose();
+ this._fsQuad.dispose();
+
+ }
+
+ /**
+ * A texture holding the computed AO.
+ *
+ * @type {Texture}
+ * @readonly
+ */
+ get gtaoMap() {
+
+ return this.pdRenderTarget.texture;
+
+ }
+
+ /**
+ * Configures the GBuffer of this pass. If no arguments are passed,
+ * the pass creates an internal render target for holding depth
+ * and normal data. External depth and normal data must use separate
+ * textures and remain owned by the caller.
+ * If no normal texture is supplied, normals are reconstructed from depth
+ * for AO and denoising, and the normal output displays black.
+ *
+ * @param {DepthTexture} [depthTexture] - The depth texture.
+ * @param {Texture} [normalTexture] - The normal texture.
+ */
+ setGBuffer( depthTexture, normalTexture ) {
+
+ if ( depthTexture !== undefined ) {
+
+ this.depthTexture = depthTexture;
+ this.normalTexture = normalTexture;
+ this._renderGBuffer = false;
+
+ } else {
+
+ if ( this.normalRenderTarget === undefined ) {
+
+ const depthTexture = new DepthTexture();
+ depthTexture.format = DepthStencilFormat;
+ depthTexture.type = UnsignedInt248Type;
+ this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+ minFilter: NearestFilter,
+ magFilter: NearestFilter,
+ type: HalfFloatType,
+ depthTexture: depthTexture
+ } );
+
+ }
+
+ this.depthTexture = this.normalRenderTarget.depthTexture;
+ this.normalTexture = this.normalRenderTarget.texture;
+ this._renderGBuffer = true;
+
+ }
+
+ const normalVectorType = ( this.normalTexture ) ? 1 : 0;
+
+ this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE = normalVectorType;
+ this.gtaoMaterial.needsUpdate = true;
+ this.gtaoMaterial.uniforms.tNormal.value = this.normalTexture;
+ this.gtaoMaterial.uniforms.tDepth.value = this.depthTexture;
+
+ this.pdMaterial.defines.NORMAL_VECTOR_TYPE = normalVectorType;
+ this.pdMaterial.needsUpdate = true;
+ this.pdMaterial.uniforms.tNormal.value = this.normalTexture;
+ this.pdMaterial.uniforms.tDepth.value = this.depthTexture;
+
+ this.depthRenderMaterial.uniforms.tDepth.value = this.depthTexture;
+
+ }
+
+ /**
+ * Configures the clip box of the GTAO shader with the given AABB.
+ *
+ * @param {?Box3} box - The AABB enclosing the scene that should receive AO. When passing
+ * `null`, to clip box is used.
+ */
+ setSceneClipBox( box ) {
+
+ if ( box ) {
+
+ this.gtaoMaterial.needsUpdate = this.gtaoMaterial.defines.SCENE_CLIP_BOX !== 1;
+ this.gtaoMaterial.defines.SCENE_CLIP_BOX = 1;
+ this.gtaoMaterial.uniforms.sceneBoxMin.value.copy( box.min );
+ this.gtaoMaterial.uniforms.sceneBoxMax.value.copy( box.max );
+
+ } else {
+
+ this.gtaoMaterial.needsUpdate = this.gtaoMaterial.defines.SCENE_CLIP_BOX === 0;
+ this.gtaoMaterial.defines.SCENE_CLIP_BOX = 0;
+
+ }
+
+ }
+
+ /**
+ * Updates the GTAO material from the given parameter object.
+ *
+ * @param {Object} parameters - The GTAO material parameters.
+ */
+ updateGtaoMaterial( parameters ) {
+
+ if ( parameters.radius !== undefined ) {
+
+ this.gtaoMaterial.uniforms.radius.value = parameters.radius;
+
+ }
+
+ if ( parameters.distanceExponent !== undefined ) {
+
+ this.gtaoMaterial.uniforms.distanceExponent.value = parameters.distanceExponent;
+
+ }
+
+ if ( parameters.thickness !== undefined ) {
+
+ this.gtaoMaterial.uniforms.thickness.value = parameters.thickness;
+
+ }
+
+ if ( parameters.distanceFallOff !== undefined ) {
+
+ this.gtaoMaterial.uniforms.distanceFallOff.value = parameters.distanceFallOff;
+ this.gtaoMaterial.needsUpdate = true;
+
+ }
+
+ if ( parameters.scale !== undefined ) {
+
+ this.gtaoMaterial.uniforms.scale.value = parameters.scale;
+
+ }
+
+ if ( parameters.samples !== undefined && parameters.samples !== this.gtaoMaterial.defines.SAMPLES ) {
+
+ this.gtaoMaterial.defines.SAMPLES = parameters.samples;
+ this.gtaoMaterial.needsUpdate = true;
+
+ }
+
+ if ( parameters.screenSpaceRadius !== undefined && ( parameters.screenSpaceRadius ? 1 : 0 ) !== this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS ) {
+
+ this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS = parameters.screenSpaceRadius ? 1 : 0;
+ this.gtaoMaterial.needsUpdate = true;
+
+ }
+
+ }
+
+ /**
+ * Updates the Denoise material from the given parameter object.
+ *
+ * @param {Object} parameters - The denoise parameters.
+ */
+ updatePdMaterial( parameters ) {
+
+ let updateShader = false;
+
+ if ( parameters.lumaPhi !== undefined ) {
+
+ this.pdMaterial.uniforms.lumaPhi.value = parameters.lumaPhi;
+
+ }
+
+ if ( parameters.depthPhi !== undefined ) {
+
+ this.pdMaterial.uniforms.depthPhi.value = parameters.depthPhi;
+
+ }
+
+ if ( parameters.normalPhi !== undefined ) {
+
+ this.pdMaterial.uniforms.normalPhi.value = parameters.normalPhi;
+
+ }
+
+ if ( parameters.radius !== undefined && parameters.radius !== this.radius ) {
+
+ this.pdMaterial.uniforms.radius.value = parameters.radius;
+
+ }
+
+ if ( parameters.radiusExponent !== undefined && parameters.radiusExponent !== this.pdRadiusExponent ) {
+
+ this.pdRadiusExponent = parameters.radiusExponent;
+ updateShader = true;
+
+ }
+
+ if ( parameters.rings !== undefined && parameters.rings !== this.pdRings ) {
+
+ this.pdRings = parameters.rings;
+ updateShader = true;
+
+ }
+
+ if ( parameters.samples !== undefined && parameters.samples !== this.pdSamples ) {
+
+ this.pdSamples = parameters.samples;
+ updateShader = true;
+
+ }
+
+ if ( updateShader ) {
+
+ this.pdMaterial.defines.SAMPLES = this.pdSamples;
+ this.pdMaterial.defines.SAMPLE_VECTORS = generatePdSamplePointInitializer( this.pdSamples, this.pdRings, this.pdRadiusExponent );
+ this.pdMaterial.needsUpdate = true;
+
+ }
+
+ }
+
+ /**
+ * Performs the GTAO pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+
+ // render normals and depth (honor only meshes, points and lines do not contribute to AO)
+
+ if ( this._renderGBuffer ) {
+
+ this._overrideVisibility();
+ this._renderOverride( renderer, this.normalMaterial, this.normalRenderTarget, 0x7777ff, 1.0 );
+ this._restoreVisibility();
+
+ }
+
+ // render AO
+
+ this.gtaoMaterial.uniforms.cameraNear.value = this.camera.near;
+ this.gtaoMaterial.uniforms.cameraFar.value = this.camera.far;
+ this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy( this.camera.projectionMatrix );
+ this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy( this.camera.projectionMatrixInverse );
+ this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy( this.camera.matrixWorld );
+ this._renderPass( renderer, this.gtaoMaterial, this.gtaoRenderTarget, 0xffffff, 1.0 );
+
+ // render poisson denoise
+
+ this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy( this.camera.projectionMatrixInverse );
+ this._renderPass( renderer, this.pdMaterial, this.pdRenderTarget, 0xffffff, 1.0 );
+
+ // output result to screen
+
+ switch ( this.output ) {
+
+ case GTAOPass.OUTPUT.Off:
+ break;
+
+ case GTAOPass.OUTPUT.Diffuse:
+
+ this.copyMaterial.uniforms.tDiffuse.value = readBuffer.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ break;
+
+ case GTAOPass.OUTPUT.AO:
+
+ this.copyMaterial.uniforms.tDiffuse.value = this.gtaoRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ break;
+
+ case GTAOPass.OUTPUT.Denoise:
+
+ this.copyMaterial.uniforms.tDiffuse.value = this.pdRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ break;
+
+ case GTAOPass.OUTPUT.Depth:
+
+ this.depthRenderMaterial.uniforms.cameraNear.value = this.camera.near;
+ this.depthRenderMaterial.uniforms.cameraFar.value = this.camera.far;
+ this._renderPass( renderer, this.depthRenderMaterial, this.renderToScreen ? null : writeBuffer );
+
+ break;
+
+ case GTAOPass.OUTPUT.Normal:
+
+ this.copyMaterial.uniforms.tDiffuse.value = this.normalTexture || null;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ break;
+
+ case GTAOPass.OUTPUT.Default:
+
+ this.copyMaterial.uniforms.tDiffuse.value = readBuffer.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ this.blendMaterial.uniforms.intensity.value = this.blendIntensity;
+ this.blendMaterial.uniforms.tDiffuse.value = this.pdRenderTarget.texture;
+ this._renderPass( renderer, this.blendMaterial, this.renderToScreen ? null : writeBuffer );
+
+ break;
+
+ default:
+ console.warn( 'THREE.GTAOPass: Unknown output type.' );
+
+ }
+
+ }
+
+ // internals
+
+ _renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+
+ // save original state
+ renderer.getClearColor( this._originalClearColor );
+ const originalClearAlpha = renderer.getClearAlpha();
+ const originalAutoClear = renderer.autoClear;
+
+ renderer.setRenderTarget( renderTarget );
+
+ // setup pass state
+ renderer.autoClear = false;
+ if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
+
+ renderer.setClearColor( clearColor );
+ renderer.setClearAlpha( clearAlpha || 0.0 );
+ renderer.clear();
+
+ }
+
+ this._fsQuad.material = passMaterial;
+ this._fsQuad.render( renderer );
+
+ // restore original state
+ renderer.autoClear = originalAutoClear;
+ renderer.setClearColor( this._originalClearColor );
+ renderer.setClearAlpha( originalClearAlpha );
+
+ }
+
+ _renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+
+ renderer.getClearColor( this._originalClearColor );
+ const originalClearAlpha = renderer.getClearAlpha();
+ const originalAutoClear = renderer.autoClear;
+
+ renderer.setRenderTarget( renderTarget );
+ renderer.autoClear = false;
+
+ clearColor = overrideMaterial.clearColor || clearColor;
+ clearAlpha = overrideMaterial.clearAlpha || clearAlpha;
+
+ if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
+
+ renderer.setClearColor( clearColor );
+ renderer.setClearAlpha( clearAlpha || 0.0 );
+ renderer.clear();
+
+ }
+
+ this.scene.overrideMaterial = overrideMaterial;
+ renderer.render( this.scene, this.camera );
+ this.scene.overrideMaterial = null;
+
+ renderer.autoClear = originalAutoClear;
+ renderer.setClearColor( this._originalClearColor );
+ renderer.setClearAlpha( originalClearAlpha );
+
+ }
+
+ _overrideVisibility() {
+
+ const scene = this.scene;
+ const cache = this._visibilityCache;
+
+ scene.traverse( function ( object ) {
+
+ if ( ( object.isPoints || object.isLine || object.isLine2 ) && object.visible ) {
+
+ object.visible = false;
+ cache.push( object );
+
+ }
+
+ } );
+
+ }
+
+ _restoreVisibility() {
+
+ const cache = this._visibilityCache;
+
+ for ( let i = 0; i < cache.length; i ++ ) {
+
+ cache[ i ].visible = true;
+
+ }
+
+ cache.length = 0;
+
+ }
+
+ _generateNoise( size = 64 ) {
+
+ const simplex = new SimplexNoise();
+
+ const arraySize = size * size * 4;
+ const data = new Uint8Array( arraySize );
+
+ for ( let i = 0; i < size; i ++ ) {
+
+ for ( let j = 0; j < size; j ++ ) {
+
+ const x = i;
+ const y = j;
+
+ data[ ( i * size + j ) * 4 ] = ( simplex.noise( x, y ) * 0.5 + 0.5 ) * 255;
+ data[ ( i * size + j ) * 4 + 1 ] = ( simplex.noise( x + size, y ) * 0.5 + 0.5 ) * 255;
+ data[ ( i * size + j ) * 4 + 2 ] = ( simplex.noise( x, y + size ) * 0.5 + 0.5 ) * 255;
+ data[ ( i * size + j ) * 4 + 3 ] = ( simplex.noise( x + size, y + size ) * 0.5 + 0.5 ) * 255;
+
+ }
+
+ }
+
+ const noiseTexture = new DataTexture( data, size, size, RGBAFormat, UnsignedByteType );
+ noiseTexture.wrapS = RepeatWrapping;
+ noiseTexture.wrapT = RepeatWrapping;
+ noiseTexture.needsUpdate = true;
+
+ return noiseTexture;
+
+ }
+
+}
+
+GTAOPass.OUTPUT = {
+ 'Off': - 1,
+ 'Default': 0,
+ 'Diffuse': 1,
+ 'Depth': 2,
+ 'Normal': 3,
+ 'AO': 4,
+ 'Denoise': 5,
+};
+
+export { GTAOPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/GlitchPass.js b/demo/hero-content/vendor/addons/postprocessing/GlitchPass.js
new file mode 100644
index 00000000..eba211c7
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/GlitchPass.js
@@ -0,0 +1,177 @@
+import {
+ DataTexture,
+ FloatType,
+ MathUtils,
+ RedFormat,
+ ShaderMaterial,
+ UniformsUtils
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { DigitalGlitch } from '../shaders/DigitalGlitch.js';
+
+/**
+ * Pass for creating a glitch effect.
+ *
+ * ```js
+ * const glitchPass = new GlitchPass();
+ * composer.addPass( glitchPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { GlitchPass } from 'three/addons/postprocessing/GlitchPass.js';
+ */
+class GlitchPass extends Pass {
+
+ /**
+ * Constructs a new glitch pass.
+ *
+ * @param {number} [dt_size=64] - The size of the displacement texture
+ * for digital glitch squares.
+ */
+ constructor( dt_size = 64 ) {
+
+ super();
+
+ /**
+ * The pass uniforms.
+ *
+ * @type {Object}
+ */
+ this.uniforms = UniformsUtils.clone( DigitalGlitch.uniforms );
+
+ /**
+ * The pass material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.material = new ShaderMaterial( {
+ uniforms: this.uniforms,
+ vertexShader: DigitalGlitch.vertexShader,
+ fragmentShader: DigitalGlitch.fragmentShader
+ } );
+
+ /**
+ * Whether to noticeably increase the effect intensity or not.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.goWild = false;
+
+ // internals
+
+ this._heightMap = this._generateHeightmap( dt_size );
+ this.uniforms[ 'tDisp' ].value = this._heightMap;
+
+ this._fsQuad = new FullScreenQuad( this.material );
+
+ this._curF = 0;
+ this._randX = 0;
+
+ this._generateTrigger();
+
+ }
+
+ /**
+ * Performs the glitch pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+
+ this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
+ this.uniforms[ 'seed' ].value = Math.random(); // default seeding
+ this.uniforms[ 'byp' ].value = 0;
+
+ if ( this._curF % this._randX == 0 || this.goWild == true ) {
+
+ this.uniforms[ 'amount' ].value = Math.random() / 30;
+ this.uniforms[ 'angle' ].value = MathUtils.randFloat( - Math.PI, Math.PI );
+ this.uniforms[ 'seed_x' ].value = MathUtils.randFloat( - 1, 1 );
+ this.uniforms[ 'seed_y' ].value = MathUtils.randFloat( - 1, 1 );
+ this.uniforms[ 'distortion_x' ].value = MathUtils.randFloat( 0, 1 );
+ this.uniforms[ 'distortion_y' ].value = MathUtils.randFloat( 0, 1 );
+ this._curF = 0;
+ this._generateTrigger();
+
+ } else if ( this._curF % this._randX < this._randX / 5 ) {
+
+ this.uniforms[ 'amount' ].value = Math.random() / 90;
+ this.uniforms[ 'angle' ].value = MathUtils.randFloat( - Math.PI, Math.PI );
+ this.uniforms[ 'distortion_x' ].value = MathUtils.randFloat( 0, 1 );
+ this.uniforms[ 'distortion_y' ].value = MathUtils.randFloat( 0, 1 );
+ this.uniforms[ 'seed_x' ].value = MathUtils.randFloat( - 0.3, 0.3 );
+ this.uniforms[ 'seed_y' ].value = MathUtils.randFloat( - 0.3, 0.3 );
+
+ } else if ( this.goWild == false ) {
+
+ this.uniforms[ 'byp' ].value = 1;
+
+ }
+
+ this._curF ++;
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+ this._fsQuad.render( renderer );
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+ if ( this.clear ) renderer.clear();
+ this._fsQuad.render( renderer );
+
+ }
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.material.dispose();
+
+ this._heightMap.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+ // internals
+
+ _generateTrigger() {
+
+ this._randX = MathUtils.randInt( 120, 240 );
+
+ }
+
+ _generateHeightmap( dt_size ) {
+
+ const data_arr = new Float32Array( dt_size * dt_size );
+ const length = dt_size * dt_size;
+
+ for ( let i = 0; i < length; i ++ ) {
+
+ const val = MathUtils.randFloat( 0, 1 );
+ data_arr[ i ] = val;
+
+ }
+
+ const texture = new DataTexture( data_arr, dt_size, dt_size, RedFormat, FloatType );
+ texture.needsUpdate = true;
+ return texture;
+
+ }
+
+}
+
+export { GlitchPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/HalftonePass.js b/demo/hero-content/vendor/addons/postprocessing/HalftonePass.js
new file mode 100644
index 00000000..5445cdcb
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/HalftonePass.js
@@ -0,0 +1,134 @@
+import {
+ ShaderMaterial,
+ UniformsUtils
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { HalftoneShader } from '../shaders/HalftoneShader.js';
+
+/**
+ * Pass for creating a RGB halftone effect.
+ *
+ * ```js
+ * const params = {
+ * shape: 1,
+ * radius: 4,
+ * rotateR: Math.PI / 12,
+ * rotateB: Math.PI / 12 * 2,
+ * rotateG: Math.PI / 12 * 3,
+ * scatter: 0,
+ * blending: 1,
+ * blendingMode: 1,
+ * greyscale: false,
+ * disable: false
+ * };
+ * const halftonePass = new HalftonePass( params );
+ * composer.addPass( halftonePass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { HalftonePass } from 'three/addons/postprocessing/HalftonePass.js';
+ */
+class HalftonePass extends Pass {
+
+ /**
+ * Constructs a new halftone pass.
+ *
+ * @param {Object} params - The halftone shader parameter.
+ */
+ constructor( params ) {
+
+ super();
+
+ /**
+ * The pass uniforms.
+ *
+ * @type {Object}
+ */
+ this.uniforms = UniformsUtils.clone( HalftoneShader.uniforms );
+
+ /**
+ * The pass material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.material = new ShaderMaterial( {
+ uniforms: this.uniforms,
+ fragmentShader: HalftoneShader.fragmentShader,
+ vertexShader: HalftoneShader.vertexShader
+ } );
+
+
+ for ( const key in params ) {
+
+ if ( params.hasOwnProperty( key ) && this.uniforms.hasOwnProperty( key ) ) {
+
+ this.uniforms[ key ].value = params[ key ];
+
+ }
+
+ }
+
+ // internals
+
+ this._fsQuad = new FullScreenQuad( this.material );
+
+ }
+
+ /**
+ * Performs the halftone pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
+
+ this.material.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+ this._fsQuad.render( renderer );
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+ if ( this.clear ) renderer.clear();
+ this._fsQuad.render( renderer );
+
+ }
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this.uniforms.width.value = width;
+ this.uniforms.height.value = height;
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.material.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+}
+
+export { HalftonePass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/LUTPass.js b/demo/hero-content/vendor/addons/postprocessing/LUTPass.js
new file mode 100644
index 00000000..4ddffb94
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/LUTPass.js
@@ -0,0 +1,138 @@
+import { ShaderPass } from './ShaderPass.js';
+
+const LUTShader = {
+
+ name: 'LUTShader',
+
+ uniforms: {
+
+ lut: { value: null },
+ lutSize: { value: 0 },
+
+ tDiffuse: { value: null },
+ intensity: { value: 1.0 },
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }
+
+ `,
+
+ fragmentShader: /* glsl */`
+
+ uniform float lutSize;
+ uniform sampler3D lut;
+
+ varying vec2 vUv;
+ uniform float intensity;
+ uniform sampler2D tDiffuse;
+ void main() {
+
+ vec4 val = texture2D( tDiffuse, vUv );
+ vec4 lutVal;
+
+ // pull the sample in by half a pixel so the sample begins
+ // at the center of the edge pixels.
+ float pixelWidth = 1.0 / lutSize;
+ float halfPixelWidth = 0.5 / lutSize;
+ vec3 uvw = vec3( halfPixelWidth ) + val.rgb * ( 1.0 - pixelWidth );
+
+
+ lutVal = vec4( texture( lut, uvw ).rgb, val.a );
+
+ gl_FragColor = vec4( mix( val, lutVal, intensity ) );
+
+ }
+
+ `,
+
+};
+
+/**
+ * Pass for color grading via lookup tables.
+ *
+ * ```js
+ * const lutPass = new LUTPass( { lut: lut.texture3D } );
+ * composer.addPass( lutPass );
+ * ```
+ *
+ * @augments ShaderPass
+ * @three_import import { LUTPass } from 'three/addons/postprocessing/LUTPass.js';
+ */
+class LUTPass extends ShaderPass {
+
+ /**
+ * Constructs a LUT pass.
+ *
+ * @param {{lut:Data3DTexture,intensity:number}} [options={}] - The pass options.
+ */
+ constructor( options = {} ) {
+
+ super( LUTShader );
+
+ /**
+ * The LUT as a 3D texture.
+ *
+ * @type {?Data3DTexture}
+ * @default null
+ */
+ this.lut = options.lut || null;
+
+ /**
+ * The intensity.
+ *
+ * @type {?number}
+ * @default 1
+ */
+ this.intensity = 'intensity' in options ? options.intensity : 1;
+
+ }
+
+ set lut( v ) {
+
+ const material = this.material;
+
+ if ( v !== this.lut ) {
+
+ material.uniforms.lut.value = null;
+
+ if ( v ) {
+
+ material.uniforms.lutSize.value = v.image.width;
+ material.uniforms.lut.value = v;
+
+ }
+
+ }
+
+ }
+
+ get lut() {
+
+ return this.material.uniforms.lut.value;
+
+ }
+
+ set intensity( v ) {
+
+ this.material.uniforms.intensity.value = v;
+
+ }
+
+ get intensity() {
+
+ return this.material.uniforms.intensity.value;
+
+ }
+
+}
+
+export { LUTPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/MaskPass.js b/demo/hero-content/vendor/addons/postprocessing/MaskPass.js
new file mode 100644
index 00000000..3a2afff8
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/MaskPass.js
@@ -0,0 +1,195 @@
+import { Pass } from './Pass.js';
+
+/**
+ * This pass can be used to define a mask during post processing.
+ * Meaning only areas of subsequent post processing are affected
+ * which lie in the masking area of this pass. Internally, the masking
+ * is implemented with the stencil buffer.
+ *
+ * ```js
+ * const maskPass = new MaskPass( scene, camera );
+ * composer.addPass( maskPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { MaskPass } from 'three/addons/postprocessing/MaskPass.js';
+ */
+class MaskPass extends Pass {
+
+ /**
+ * Constructs a new mask pass.
+ *
+ * @param {Scene} scene - The 3D objects in this scene will define the mask.
+ * @param {Camera} camera - The camera.
+ */
+ constructor( scene, camera ) {
+
+ super();
+
+ /**
+ * The scene that defines the mask.
+ *
+ * @type {Scene}
+ */
+ this.scene = scene;
+
+ /**
+ * The camera.
+ *
+ * @type {Camera}
+ */
+ this.camera = camera;
+
+ /**
+ * Overwritten to perform a clear operation by default.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.clear = true;
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ /**
+ * Whether to inverse the mask or not.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.inverse = false;
+
+ }
+
+ /**
+ * Performs a mask pass with the configured scene and camera.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+
+ const context = renderer.getContext();
+ const state = renderer.state;
+
+ // don't update color or depth
+
+ state.buffers.color.setMask( false );
+ state.buffers.depth.setMask( false );
+
+ // lock buffers
+
+ state.buffers.color.setLocked( true );
+ state.buffers.depth.setLocked( true );
+
+ // set up stencil
+
+ let writeValue, clearValue;
+
+ if ( this.inverse ) {
+
+ writeValue = 0;
+ clearValue = 1;
+
+ } else {
+
+ writeValue = 1;
+ clearValue = 0;
+
+ }
+
+ state.buffers.stencil.setTest( true );
+ state.buffers.stencil.setOp( context.REPLACE, context.REPLACE, context.REPLACE );
+ state.buffers.stencil.setFunc( context.ALWAYS, writeValue, 0xffffffff );
+ state.buffers.stencil.setClear( clearValue );
+ state.buffers.stencil.setLocked( true );
+
+ // draw into the stencil buffer
+
+ renderer.setRenderTarget( readBuffer );
+ if ( this.clear ) renderer.clear();
+ renderer.render( this.scene, this.camera );
+
+ renderer.setRenderTarget( writeBuffer );
+ if ( this.clear ) renderer.clear();
+ renderer.render( this.scene, this.camera );
+
+ // unlock color and depth buffer and make them writable for subsequent rendering/clearing
+
+ state.buffers.color.setLocked( false );
+ state.buffers.depth.setLocked( false );
+
+ state.buffers.color.setMask( true );
+ state.buffers.depth.setMask( true );
+
+ // only render where stencil is set to 1
+
+ state.buffers.stencil.setLocked( false );
+ state.buffers.stencil.setFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1
+ state.buffers.stencil.setOp( context.KEEP, context.KEEP, context.KEEP );
+ state.buffers.stencil.setLocked( true );
+
+ }
+
+}
+
+/**
+ * This pass can be used to clear a mask previously defined with {@link MaskPass}.
+ *
+ * ```js
+ * const clearPass = new ClearMaskPass();
+ * composer.addPass( clearPass );
+ * ```
+ *
+ * @augments Pass
+ */
+class ClearMaskPass extends Pass {
+
+ /**
+ * Constructs a new clear mask pass.
+ */
+ constructor() {
+
+ super();
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ }
+
+ /**
+ * Performs the clear of the currently defined mask.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer /*, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
+
+ renderer.state.buffers.stencil.setLocked( false );
+ renderer.state.buffers.stencil.setTest( false );
+
+ }
+
+}
+
+export { MaskPass, ClearMaskPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/OutlinePass.js b/demo/hero-content/vendor/addons/postprocessing/OutlinePass.js
new file mode 100644
index 00000000..880aab47
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/OutlinePass.js
@@ -0,0 +1,776 @@
+import {
+ AdditiveBlending,
+ Color,
+ DoubleSide,
+ HalfFloatType,
+ Matrix4,
+ MeshDepthMaterial,
+ NoBlending,
+ RGBADepthPacking,
+ ShaderMaterial,
+ UniformsUtils,
+ Vector2,
+ Vector3,
+ WebGLRenderTarget
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { CopyShader } from '../shaders/CopyShader.js';
+
+/**
+ * A pass for rendering outlines around selected objects.
+ *
+ * ```js
+ * const resolution = new THREE.Vector2( window.innerWidth, window.innerHeight );
+ * const outlinePass = new OutlinePass( resolution, scene, camera );
+ * composer.addPass( outlinePass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { OutlinePass } from 'three/addons/postprocessing/OutlinePass.js';
+ */
+class OutlinePass extends Pass {
+
+ /**
+ * Constructs a new outline pass.
+ *
+ * @param {Vector2} [resolution] - The effect's resolution.
+ * @param {Scene} scene - The scene to render.
+ * @param {Camera} camera - The camera.
+ * @param {Array} [selectedObjects] - The selected 3D objects that should receive an outline.
+ *
+ */
+ constructor( resolution, scene, camera, selectedObjects ) {
+
+ super();
+
+ /**
+ * The scene to render.
+ *
+ * @type {Object}
+ */
+ this.renderScene = scene;
+
+ /**
+ * The camera.
+ *
+ * @type {Object}
+ */
+ this.renderCamera = camera;
+
+ /**
+ * The selected 3D objects that should receive an outline.
+ *
+ * @type {Array}
+ */
+ this.selectedObjects = selectedObjects !== undefined ? selectedObjects : [];
+
+ /**
+ * The visible edge color.
+ *
+ * @type {Color}
+ * @default (1,1,1)
+ */
+ this.visibleEdgeColor = new Color( 1, 1, 1 );
+
+ /**
+ * The hidden edge color.
+ *
+ * @type {Color}
+ * @default (0.1,0.04,0.02)
+ */
+ this.hiddenEdgeColor = new Color( 0.1, 0.04, 0.02 );
+
+ /**
+ * Can be used for an animated glow/pulse effect.
+ *
+ * @type {number}
+ * @default 0
+ */
+ this.edgeGlow = 0.0;
+
+ /**
+ * Whether to use a pattern texture for to highlight selected
+ * 3D objects or not.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.usePatternTexture = false;
+
+ /**
+ * Can be used to highlight selected 3D objects. Requires to set
+ * {@link OutlinePass#usePatternTexture} to `true`.
+ *
+ * @type {?Texture}
+ * @default null
+ */
+ this.patternTexture = null;
+
+ /**
+ * The edge thickness.
+ *
+ * @type {number}
+ * @default 1
+ */
+ this.edgeThickness = 1.0;
+
+ /**
+ * The edge strength.
+ *
+ * @type {number}
+ * @default 3
+ */
+ this.edgeStrength = 3.0;
+
+ /**
+ * The downsample ratio. The effect can be rendered in a much
+ * lower resolution than the beauty pass.
+ *
+ * @type {number}
+ * @default 2
+ */
+ this.downSampleRatio = 2;
+
+ /**
+ * The pulse period.
+ *
+ * @type {number}
+ * @default 0
+ */
+ this.pulsePeriod = 0;
+
+ this._visibilityCache = new Map();
+ this._selectionCache = new Set();
+
+ /**
+ * The effect's resolution.
+ *
+ * @type {Vector2}
+ * @default (256,256)
+ */
+ this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 );
+
+ const resx = Math.round( this.resolution.x / this.downSampleRatio );
+ const resy = Math.round( this.resolution.y / this.downSampleRatio );
+
+ this.renderTargetMaskBuffer = new WebGLRenderTarget( this.resolution.x, this.resolution.y );
+ this.renderTargetMaskBuffer.texture.name = 'OutlinePass.mask';
+ this.renderTargetMaskBuffer.texture.generateMipmaps = false;
+
+ this.depthMaterial = new MeshDepthMaterial();
+ this.depthMaterial.side = DoubleSide;
+ this.depthMaterial.depthPacking = RGBADepthPacking;
+ this.depthMaterial.blending = NoBlending;
+
+ this.prepareMaskMaterial = this._getPrepareMaskMaterial();
+ this.prepareMaskMaterial.side = DoubleSide;
+ this.prepareMaskMaterial.fragmentShader = replaceDepthToViewZ( this.prepareMaskMaterial.fragmentShader, this.renderCamera );
+
+ this.renderTargetDepthBuffer = new WebGLRenderTarget( this.resolution.x, this.resolution.y, { type: HalfFloatType } );
+ this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth';
+ this.renderTargetDepthBuffer.texture.generateMipmaps = false;
+
+ this.renderTargetMaskDownSampleBuffer = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
+ this.renderTargetMaskDownSampleBuffer.texture.name = 'OutlinePass.depthDownSample';
+ this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false;
+
+ this.renderTargetBlurBuffer1 = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
+ this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1';
+ this.renderTargetBlurBuffer1.texture.generateMipmaps = false;
+ this.renderTargetBlurBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), { type: HalfFloatType, depthBuffer: false } );
+ this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2';
+ this.renderTargetBlurBuffer2.texture.generateMipmaps = false;
+
+ this.edgeDetectionMaterial = this._getEdgeDetectionMaterial();
+ this.renderTargetEdgeBuffer1 = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
+ this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1';
+ this.renderTargetEdgeBuffer1.texture.generateMipmaps = false;
+ this.renderTargetEdgeBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), { type: HalfFloatType, depthBuffer: false } );
+ this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2';
+ this.renderTargetEdgeBuffer2.texture.generateMipmaps = false;
+
+ const MAX_EDGE_THICKNESS = 4;
+ const MAX_EDGE_GLOW = 4;
+
+ this.separableBlurMaterial1 = this._getSeparableBlurMaterial( MAX_EDGE_THICKNESS );
+ this.separableBlurMaterial1.uniforms[ 'texSize' ].value.set( resx, resy );
+ this.separableBlurMaterial1.uniforms[ 'kernelRadius' ].value = 1;
+ this.separableBlurMaterial2 = this._getSeparableBlurMaterial( MAX_EDGE_GLOW );
+ this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( Math.round( resx / 2 ), Math.round( resy / 2 ) );
+ this.separableBlurMaterial2.uniforms[ 'kernelRadius' ].value = MAX_EDGE_GLOW;
+
+ // Overlay material
+ this.overlayMaterial = this._getOverlayMaterial();
+
+ // copy material
+
+ const copyShader = CopyShader;
+
+ this.copyUniforms = UniformsUtils.clone( copyShader.uniforms );
+
+ this.materialCopy = new ShaderMaterial( {
+ uniforms: this.copyUniforms,
+ vertexShader: copyShader.vertexShader,
+ fragmentShader: copyShader.fragmentShader,
+ blending: NoBlending,
+ depthTest: false,
+ depthWrite: false
+ } );
+
+ this.enabled = true;
+ this.needsSwap = false;
+
+ this._oldClearColor = new Color();
+ this.oldClearAlpha = 1;
+
+ this._fsQuad = new FullScreenQuad( null );
+
+ this.tempPulseColor1 = new Color();
+ this.tempPulseColor2 = new Color();
+ this.textureMatrix = new Matrix4();
+
+ function replaceDepthToViewZ( string, camera ) {
+
+ const type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic';
+
+ return string.replace( /DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ' );
+
+ }
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.renderTargetMaskBuffer.dispose();
+ this.renderTargetDepthBuffer.dispose();
+ this.renderTargetMaskDownSampleBuffer.dispose();
+ this.renderTargetBlurBuffer1.dispose();
+ this.renderTargetBlurBuffer2.dispose();
+ this.renderTargetEdgeBuffer1.dispose();
+ this.renderTargetEdgeBuffer2.dispose();
+
+ this.depthMaterial.dispose();
+ this.prepareMaskMaterial.dispose();
+ this.edgeDetectionMaterial.dispose();
+ this.separableBlurMaterial1.dispose();
+ this.separableBlurMaterial2.dispose();
+ this.overlayMaterial.dispose();
+ this.materialCopy.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this.renderTargetMaskBuffer.setSize( width, height );
+ this.renderTargetDepthBuffer.setSize( width, height );
+
+ let resx = Math.round( width / this.downSampleRatio );
+ let resy = Math.round( height / this.downSampleRatio );
+ this.renderTargetMaskDownSampleBuffer.setSize( resx, resy );
+ this.renderTargetBlurBuffer1.setSize( resx, resy );
+ this.renderTargetEdgeBuffer1.setSize( resx, resy );
+ this.separableBlurMaterial1.uniforms[ 'texSize' ].value.set( resx, resy );
+
+ resx = Math.round( resx / 2 );
+ resy = Math.round( resy / 2 );
+
+ this.renderTargetBlurBuffer2.setSize( resx, resy );
+ this.renderTargetEdgeBuffer2.setSize( resx, resy );
+
+ this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( resx, resy );
+
+ }
+
+ /**
+ * Performs the Outline pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
+
+ if ( this.selectedObjects.length > 0 ) {
+
+ renderer.getClearColor( this._oldClearColor );
+ this.oldClearAlpha = renderer.getClearAlpha();
+ const oldAutoClear = renderer.autoClear;
+
+ renderer.autoClear = false;
+
+ if ( maskActive ) renderer.state.buffers.stencil.setTest( false );
+
+ renderer.setClearColor( 0xffffff, 1 );
+
+ this._updateSelectionCache();
+
+ // Make selected objects invisible
+ this._changeVisibilityOfSelectedObjects( false );
+
+ const currentBackground = this.renderScene.background;
+ const currentOverrideMaterial = this.renderScene.overrideMaterial;
+ this.renderScene.background = null;
+
+ // 1. Draw Non Selected objects in the depth buffer
+ this.renderScene.overrideMaterial = this.depthMaterial;
+ renderer.setRenderTarget( this.renderTargetDepthBuffer );
+ renderer.clear();
+ renderer.render( this.renderScene, this.renderCamera );
+
+ // Make selected objects visible
+ this._changeVisibilityOfSelectedObjects( true );
+ this._visibilityCache.clear();
+
+ // Update Texture Matrix for Depth compare
+ this._updateTextureMatrix();
+
+ // Make non selected objects invisible, and draw only the selected objects, by comparing the depth buffer of non selected objects
+ this._changeVisibilityOfNonSelectedObjects( false );
+ this.renderScene.overrideMaterial = this.prepareMaskMaterial;
+ this.prepareMaskMaterial.uniforms[ 'cameraNearFar' ].value.set( this.renderCamera.near, this.renderCamera.far );
+ this.prepareMaskMaterial.uniforms[ 'depthTexture' ].value = this.renderTargetDepthBuffer.texture;
+ this.prepareMaskMaterial.uniforms[ 'textureMatrix' ].value = this.textureMatrix;
+ renderer.setRenderTarget( this.renderTargetMaskBuffer );
+ renderer.clear();
+ renderer.render( this.renderScene, this.renderCamera );
+ this._changeVisibilityOfNonSelectedObjects( true );
+ this._visibilityCache.clear();
+ this._selectionCache.clear();
+
+ this.renderScene.background = currentBackground;
+ this.renderScene.overrideMaterial = currentOverrideMaterial;
+
+ // 2. Downsample to Half resolution
+ this._fsQuad.material = this.materialCopy;
+ this.copyUniforms[ 'tDiffuse' ].value = this.renderTargetMaskBuffer.texture;
+ renderer.setRenderTarget( this.renderTargetMaskDownSampleBuffer );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ this.tempPulseColor1.copy( this.visibleEdgeColor );
+ this.tempPulseColor2.copy( this.hiddenEdgeColor );
+
+ if ( this.pulsePeriod > 0 ) {
+
+ const scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01 / this.pulsePeriod ) * ( 1.0 - 0.25 ) / 2;
+ this.tempPulseColor1.multiplyScalar( scalar );
+ this.tempPulseColor2.multiplyScalar( scalar );
+
+ }
+
+ // 3. Apply Edge Detection Pass
+ this._fsQuad.material = this.edgeDetectionMaterial;
+ this.edgeDetectionMaterial.uniforms[ 'maskTexture' ].value = this.renderTargetMaskDownSampleBuffer.texture;
+ this.edgeDetectionMaterial.uniforms[ 'texSize' ].value.set( this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height );
+ this.edgeDetectionMaterial.uniforms[ 'visibleEdgeColor' ].value = this.tempPulseColor1;
+ this.edgeDetectionMaterial.uniforms[ 'hiddenEdgeColor' ].value = this.tempPulseColor2;
+ renderer.setRenderTarget( this.renderTargetEdgeBuffer1 );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ // 4. Apply Blur on Half res
+ this._fsQuad.material = this.separableBlurMaterial1;
+ this.separableBlurMaterial1.uniforms[ 'colorTexture' ].value = this.renderTargetEdgeBuffer1.texture;
+ this.separableBlurMaterial1.uniforms[ 'direction' ].value = OutlinePass.BlurDirectionX;
+ this.separableBlurMaterial1.uniforms[ 'kernelRadius' ].value = this.edgeThickness;
+ renderer.setRenderTarget( this.renderTargetBlurBuffer1 );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+ this.separableBlurMaterial1.uniforms[ 'colorTexture' ].value = this.renderTargetBlurBuffer1.texture;
+ this.separableBlurMaterial1.uniforms[ 'direction' ].value = OutlinePass.BlurDirectionY;
+ renderer.setRenderTarget( this.renderTargetEdgeBuffer1 );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ // Apply Blur on quarter res
+ this._fsQuad.material = this.separableBlurMaterial2;
+ this.separableBlurMaterial2.uniforms[ 'colorTexture' ].value = this.renderTargetEdgeBuffer1.texture;
+ this.separableBlurMaterial2.uniforms[ 'direction' ].value = OutlinePass.BlurDirectionX;
+ renderer.setRenderTarget( this.renderTargetBlurBuffer2 );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+ this.separableBlurMaterial2.uniforms[ 'colorTexture' ].value = this.renderTargetBlurBuffer2.texture;
+ this.separableBlurMaterial2.uniforms[ 'direction' ].value = OutlinePass.BlurDirectionY;
+ renderer.setRenderTarget( this.renderTargetEdgeBuffer2 );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ // Blend it additively over the input texture
+ this._fsQuad.material = this.overlayMaterial;
+ this.overlayMaterial.uniforms[ 'maskTexture' ].value = this.renderTargetMaskBuffer.texture;
+ this.overlayMaterial.uniforms[ 'edgeTexture1' ].value = this.renderTargetEdgeBuffer1.texture;
+ this.overlayMaterial.uniforms[ 'edgeTexture2' ].value = this.renderTargetEdgeBuffer2.texture;
+ this.overlayMaterial.uniforms[ 'patternTexture' ].value = this.patternTexture;
+ this.overlayMaterial.uniforms[ 'edgeStrength' ].value = this.edgeStrength;
+ this.overlayMaterial.uniforms[ 'edgeGlow' ].value = this.edgeGlow;
+ this.overlayMaterial.uniforms[ 'usePatternTexture' ].value = this.usePatternTexture;
+
+
+ if ( maskActive ) renderer.state.buffers.stencil.setTest( true );
+
+ renderer.setRenderTarget( readBuffer );
+ this._fsQuad.render( renderer );
+
+ renderer.setClearColor( this._oldClearColor, this.oldClearAlpha );
+ renderer.autoClear = oldAutoClear;
+
+ }
+
+ if ( this.renderToScreen ) {
+
+ this._fsQuad.material = this.materialCopy;
+ this.copyUniforms[ 'tDiffuse' ].value = readBuffer.texture;
+ renderer.setRenderTarget( null );
+ this._fsQuad.render( renderer );
+
+ }
+
+ }
+
+ // internals
+
+ _updateSelectionCache() {
+
+ const cache = this._selectionCache;
+
+ function gatherSelectedMeshesCallBack( object ) {
+
+ if ( object.isMesh ) cache.add( object );
+
+ }
+
+ cache.clear();
+
+ for ( let i = 0; i < this.selectedObjects.length; i ++ ) {
+
+ const selectedObject = this.selectedObjects[ i ];
+ selectedObject.traverse( gatherSelectedMeshesCallBack );
+
+ }
+
+ }
+
+ _changeVisibilityOfSelectedObjects( bVisible ) {
+
+ const cache = this._visibilityCache;
+
+ for ( const mesh of this._selectionCache ) {
+
+ if ( bVisible === true ) {
+
+ mesh.visible = cache.get( mesh );
+
+ } else {
+
+ cache.set( mesh, mesh.visible );
+ mesh.visible = bVisible;
+
+ }
+
+ }
+
+ }
+
+ _changeVisibilityOfNonSelectedObjects( bVisible ) {
+
+ const visibilityCache = this._visibilityCache;
+ const selectionCache = this._selectionCache;
+
+ function VisibilityChangeCallBack( object ) {
+
+ if ( object.isPoints || object.isLine || object.isLine2 ) {
+
+ // the visibility of points and lines is always set to false in order to
+ // not affect the outline computation
+
+ if ( bVisible === true ) {
+
+ object.visible = visibilityCache.get( object ); // restore
+
+ } else {
+
+ visibilityCache.set( object, object.visible );
+ object.visible = bVisible;
+
+ }
+
+ } else if ( object.isMesh || object.isSprite ) {
+
+ // only meshes and sprites are supported by OutlinePass
+
+ if ( ! selectionCache.has( object ) ) {
+
+ const visibility = object.visible;
+
+ if ( bVisible === false || visibilityCache.get( object ) === true ) {
+
+ object.visible = bVisible;
+
+ }
+
+ visibilityCache.set( object, visibility );
+
+ }
+
+ }
+
+ }
+
+ this.renderScene.traverse( VisibilityChangeCallBack );
+
+ }
+
+ _updateTextureMatrix() {
+
+ this.textureMatrix.set( 0.5, 0.0, 0.0, 0.5,
+ 0.0, 0.5, 0.0, 0.5,
+ 0.0, 0.0, 0.5, 0.5,
+ 0.0, 0.0, 0.0, 1.0 );
+ this.textureMatrix.multiply( this.renderCamera.projectionMatrix );
+ this.textureMatrix.multiply( this.renderCamera.matrixWorldInverse );
+
+ }
+
+ _getPrepareMaskMaterial() {
+
+ return new ShaderMaterial( {
+
+ uniforms: {
+ 'depthTexture': { value: null },
+ 'cameraNearFar': { value: new Vector2( 0.5, 0.5 ) },
+ 'textureMatrix': { value: null }
+ },
+
+ vertexShader:
+ `#include
+ #include
+ #include
+
+ varying vec4 projTexCoord;
+ varying vec4 vPosition;
+ uniform mat4 textureMatrix;
+
+ void main() {
+
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ vPosition = mvPosition;
+
+ vec4 worldPosition = vec4( transformed, 1.0 );
+
+ #ifdef USE_INSTANCING
+
+ worldPosition = instanceMatrix * worldPosition;
+
+ #endif
+
+ worldPosition = modelMatrix * worldPosition;
+
+ projTexCoord = textureMatrix * worldPosition;
+
+ }`,
+
+ fragmentShader:
+ `#include
+ varying vec4 vPosition;
+ varying vec4 projTexCoord;
+ uniform sampler2D depthTexture;
+ uniform vec2 cameraNearFar;
+
+ void main() {
+
+ float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));
+ float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );
+ float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;
+ gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);
+
+ }`
+
+ } );
+
+ }
+
+ _getEdgeDetectionMaterial() {
+
+ return new ShaderMaterial( {
+
+ uniforms: {
+ 'maskTexture': { value: null },
+ 'texSize': { value: new Vector2( 0.5, 0.5 ) },
+ 'visibleEdgeColor': { value: new Vector3( 1.0, 1.0, 1.0 ) },
+ 'hiddenEdgeColor': { value: new Vector3( 1.0, 1.0, 1.0 ) },
+ },
+
+ vertexShader:
+ `varying vec2 vUv;
+
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,
+
+ fragmentShader:
+ `varying vec2 vUv;
+
+ uniform sampler2D maskTexture;
+ uniform vec2 texSize;
+ uniform vec3 visibleEdgeColor;
+ uniform vec3 hiddenEdgeColor;
+
+ void main() {
+ vec2 invSize = 1.0 / texSize;
+ vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);
+ vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);
+ vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);
+ vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);
+ vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);
+ float diff1 = (c1.r - c2.r)*0.5;
+ float diff2 = (c3.r - c4.r)*0.5;
+ float d = length( vec2(diff1, diff2) );
+ float a1 = min(c1.g, c2.g);
+ float a2 = min(c3.g, c4.g);
+ float visibilityFactor = min(a1, a2);
+ vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;
+ gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);
+ }`
+ } );
+
+ }
+
+ _getSeparableBlurMaterial( maxRadius ) {
+
+ return new ShaderMaterial( {
+
+ defines: {
+ 'MAX_RADIUS': maxRadius,
+ },
+
+ uniforms: {
+ 'colorTexture': { value: null },
+ 'texSize': { value: new Vector2( 0.5, 0.5 ) },
+ 'direction': { value: new Vector2( 0.5, 0.5 ) },
+ 'kernelRadius': { value: 1.0 }
+ },
+
+ vertexShader:
+ `varying vec2 vUv;
+
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,
+
+ fragmentShader:
+ `#include
+ varying vec2 vUv;
+ uniform sampler2D colorTexture;
+ uniform vec2 texSize;
+ uniform vec2 direction;
+ uniform float kernelRadius;
+
+ float gaussianPdf(in float x, in float sigma) {
+ return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
+ }
+
+ void main() {
+ vec2 invSize = 1.0 / texSize;
+ float sigma = kernelRadius/2.0;
+ float weightSum = gaussianPdf(0.0, sigma);
+ vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;
+ vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);
+ vec2 uvOffset = delta;
+ for( int i = 1; i <= MAX_RADIUS; i ++ ) {
+ float x = kernelRadius * float(i) / float(MAX_RADIUS);
+ float w = gaussianPdf(x, sigma);
+ vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);
+ vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);
+ diffuseSum += ((sample1 + sample2) * w);
+ weightSum += (2.0 * w);
+ uvOffset += delta;
+ }
+ gl_FragColor = diffuseSum/weightSum;
+ }`
+ } );
+
+ }
+
+ _getOverlayMaterial() {
+
+ return new ShaderMaterial( {
+
+ uniforms: {
+ 'maskTexture': { value: null },
+ 'edgeTexture1': { value: null },
+ 'edgeTexture2': { value: null },
+ 'patternTexture': { value: null },
+ 'edgeStrength': { value: 1.0 },
+ 'edgeGlow': { value: 1.0 },
+ 'usePatternTexture': { value: 0.0 }
+ },
+
+ vertexShader:
+ `varying vec2 vUv;
+
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,
+
+ fragmentShader:
+ `varying vec2 vUv;
+
+ uniform sampler2D maskTexture;
+ uniform sampler2D edgeTexture1;
+ uniform sampler2D edgeTexture2;
+ uniform sampler2D patternTexture;
+ uniform float edgeStrength;
+ uniform float edgeGlow;
+ uniform bool usePatternTexture;
+
+ void main() {
+ vec4 edgeValue1 = texture2D(edgeTexture1, vUv);
+ vec4 edgeValue2 = texture2D(edgeTexture2, vUv);
+ vec4 maskColor = texture2D(maskTexture, vUv);
+ vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);
+ float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;
+ vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;
+ vec4 finalColor = edgeStrength * maskColor.r * edgeValue;
+ if(usePatternTexture)
+ finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);
+ gl_FragColor = finalColor;
+ }`,
+ blending: AdditiveBlending,
+ depthTest: false,
+ depthWrite: false,
+ transparent: true
+ } );
+
+ }
+
+}
+
+OutlinePass.BlurDirectionX = new Vector2( 1.0, 0.0 );
+OutlinePass.BlurDirectionY = new Vector2( 0.0, 1.0 );
+
+export { OutlinePass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/OutputPass.js b/demo/hero-content/vendor/addons/postprocessing/OutputPass.js
new file mode 100644
index 00000000..1366c6e1
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/OutputPass.js
@@ -0,0 +1,148 @@
+import {
+ ColorManagement,
+ RawShaderMaterial,
+ UniformsUtils,
+ LinearToneMapping,
+ ReinhardToneMapping,
+ CineonToneMapping,
+ AgXToneMapping,
+ ACESFilmicToneMapping,
+ NeutralToneMapping,
+ CustomToneMapping,
+ SRGBTransfer
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { OutputShader } from '../shaders/OutputShader.js';
+
+/**
+ * This pass is responsible for including tone mapping and color space conversion
+ * into your pass chain. In most cases, this pass should be included at the end
+ * of each pass chain. If a pass requires sRGB input (e.g. like FXAA), the pass
+ * must follow `OutputPass` in the pass chain.
+ *
+ * The tone mapping and color space settings are extracted from the renderer.
+ *
+ * ```js
+ * const outputPass = new OutputPass();
+ * composer.addPass( outputPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
+ */
+class OutputPass extends Pass {
+
+ /**
+ * Constructs a new output pass.
+ */
+ constructor() {
+
+ super();
+
+ /**
+ * This flag indicates that this is an output pass.
+ *
+ * @type {boolean}
+ * @readonly
+ * @default true
+ */
+ this.isOutputPass = true;
+
+ /**
+ * The pass uniforms.
+ *
+ * @type {Object}
+ */
+ this.uniforms = UniformsUtils.clone( OutputShader.uniforms );
+
+ /**
+ * The pass material.
+ *
+ * @type {RawShaderMaterial}
+ */
+ this.material = new RawShaderMaterial( {
+ name: OutputShader.name,
+ uniforms: this.uniforms,
+ vertexShader: OutputShader.vertexShader,
+ fragmentShader: OutputShader.fragmentShader
+ } );
+
+ // internals
+
+ this._fsQuad = new FullScreenQuad( this.material );
+
+ this._outputColorSpace = null;
+ this._toneMapping = null;
+
+ }
+
+ /**
+ * Performs the output pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive */ ) {
+
+ this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
+ this.uniforms[ 'toneMappingExposure' ].value = renderer.toneMappingExposure;
+
+ // rebuild defines if required
+
+ if ( this._outputColorSpace !== renderer.outputColorSpace || this._toneMapping !== renderer.toneMapping ) {
+
+ this._outputColorSpace = renderer.outputColorSpace;
+ this._toneMapping = renderer.toneMapping;
+
+ this.material.defines = {};
+
+ if ( ColorManagement.getTransfer( this._outputColorSpace ) === SRGBTransfer ) this.material.defines.SRGB_TRANSFER = '';
+
+ if ( this._toneMapping === LinearToneMapping ) this.material.defines.LINEAR_TONE_MAPPING = '';
+ else if ( this._toneMapping === ReinhardToneMapping ) this.material.defines.REINHARD_TONE_MAPPING = '';
+ else if ( this._toneMapping === CineonToneMapping ) this.material.defines.CINEON_TONE_MAPPING = '';
+ else if ( this._toneMapping === ACESFilmicToneMapping ) this.material.defines.ACES_FILMIC_TONE_MAPPING = '';
+ else if ( this._toneMapping === AgXToneMapping ) this.material.defines.AGX_TONE_MAPPING = '';
+ else if ( this._toneMapping === NeutralToneMapping ) this.material.defines.NEUTRAL_TONE_MAPPING = '';
+ else if ( this._toneMapping === CustomToneMapping ) this.material.defines.CUSTOM_TONE_MAPPING = '';
+
+ this.material.needsUpdate = true;
+
+ }
+
+ //
+
+ if ( this.renderToScreen === true ) {
+
+ renderer.setRenderTarget( null );
+ this._fsQuad.render( renderer );
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+ if ( this.clear ) renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
+ this._fsQuad.render( renderer );
+
+ }
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.material.dispose();
+ this._fsQuad.dispose();
+
+ }
+
+}
+
+export { OutputPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/Pass.js b/demo/hero-content/vendor/addons/postprocessing/Pass.js
new file mode 100644
index 00000000..50acb478
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/Pass.js
@@ -0,0 +1,191 @@
+import {
+ BufferGeometry,
+ Float32BufferAttribute,
+ OrthographicCamera,
+ Mesh
+} from 'three';
+
+/**
+ * Abstract base class for all post processing passes.
+ *
+ * This module is only relevant for post processing with {@link WebGLRenderer}.
+ *
+ * @abstract
+ * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';
+ */
+class Pass {
+
+ /**
+ * Constructs a new pass.
+ */
+ constructor() {
+
+ /**
+ * This flag can be used for type testing.
+ *
+ * @type {boolean}
+ * @readonly
+ * @default true
+ */
+ this.isPass = true;
+
+ /**
+ * If set to `true`, the pass is processed by the composer.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.enabled = true;
+
+ /**
+ * If set to `true`, the pass indicates to swap read and write buffer after rendering.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.needsSwap = true;
+
+ /**
+ * If set to `true`, the pass clears its buffer before rendering
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.clear = false;
+
+ /**
+ * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers
+ * pass chain gets automatically rendered to screen, no matter how this property is configured.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.renderToScreen = false;
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @abstract
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( /* width, height */ ) {}
+
+ /**
+ * This method holds the render logic of a pass. It must be implemented in all derived classes.
+ *
+ * @abstract
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
+
+ console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ *
+ * @abstract
+ */
+ dispose() {}
+
+}
+
+// Helper for passes that need to fill the viewport with a single quad.
+
+const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
+
+// https://github.com/mrdoob/three.js/pull/21358
+
+class FullscreenTriangleGeometry extends BufferGeometry {
+
+ constructor() {
+
+ super();
+
+ this.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
+ this.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
+
+ }
+
+}
+
+const _geometry = new FullscreenTriangleGeometry();
+
+
+/**
+ * This module is a helper for passes which need to render a full
+ * screen effect which is quite common in context of post processing.
+ *
+ * The intended usage is to reuse a single full screen quad for rendering
+ * subsequent passes by just reassigning the `material` reference.
+ *
+ * This module can only be used with {@link WebGLRenderer}.
+ *
+ * @augments Mesh
+ * @three_import import { FullScreenQuad } from 'three/addons/postprocessing/Pass.js';
+ */
+class FullScreenQuad {
+
+ /**
+ * Constructs a new full screen quad.
+ *
+ * @param {?Material} material - The material to render te full screen quad with.
+ */
+ constructor( material ) {
+
+ this._mesh = new Mesh( _geometry, material );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the instance is no longer used in your app.
+ */
+ dispose() {
+
+ this._mesh.geometry.dispose();
+
+ }
+
+ /**
+ * Renders the full screen quad.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ */
+ render( renderer ) {
+
+ renderer.render( this._mesh, _camera );
+
+ }
+
+ /**
+ * The quad's material.
+ *
+ * @type {?Material}
+ */
+ get material() {
+
+ return this._mesh.material;
+
+ }
+
+ set material( value ) {
+
+ this._mesh.material = value;
+
+ }
+
+}
+
+export { Pass, FullScreenQuad };
diff --git a/demo/hero-content/vendor/addons/postprocessing/RenderPass.js b/demo/hero-content/vendor/addons/postprocessing/RenderPass.js
new file mode 100644
index 00000000..e8428a1c
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/RenderPass.js
@@ -0,0 +1,193 @@
+import {
+ Color
+} from 'three';
+import { Pass } from './Pass.js';
+
+/**
+ * This class represents a render pass. It takes a camera and a scene and produces
+ * a beauty pass for subsequent post processing effects.
+ *
+ * ```js
+ * const renderPass = new RenderPass( scene, camera );
+ * composer.addPass( renderPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
+ */
+class RenderPass extends Pass {
+
+ /**
+ * Constructs a new render pass.
+ *
+ * @param {Scene} scene - The scene to render.
+ * @param {Camera} camera - The camera.
+ * @param {?Material} [overrideMaterial=null] - The override material. If set, this material is used
+ * for all objects in the scene.
+ * @param {?(number|Color|string)} [clearColor=null] - The clear color of the render pass.
+ * @param {?number} [clearAlpha=null] - The clear alpha of the render pass.
+ */
+ constructor( scene, camera, overrideMaterial = null, clearColor = null, clearAlpha = null ) {
+
+ super();
+
+ /**
+ * The scene to render.
+ *
+ * @type {Scene}
+ */
+ this.scene = scene;
+
+ /**
+ * The camera.
+ *
+ * @type {Camera}
+ */
+ this.camera = camera;
+
+ /**
+ * The override material. If set, this material is used
+ * for all objects in the scene.
+ *
+ * @type {?Material}
+ * @default null
+ */
+ this.overrideMaterial = overrideMaterial;
+
+ /**
+ * The clear color of the render pass.
+ *
+ * @type {?(number|Color|string)}
+ * @default null
+ */
+ this.clearColor = clearColor;
+
+ /**
+ * The clear alpha of the render pass.
+ *
+ * @type {?number}
+ * @default null
+ */
+ this.clearAlpha = clearAlpha;
+
+ /**
+ * Overwritten to perform a clear operation by default.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.clear = true;
+
+ /**
+ * If set to `true`, only the depth can be cleared when `clear` is to `false`.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.clearDepth = false;
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ /**
+ * This flag indicates that this pass renders the scene itself.
+ *
+ * @type {boolean}
+ * @readonly
+ * @default true
+ */
+ this.isRenderPass = true;
+
+ this._oldClearColor = new Color();
+
+ }
+
+ /**
+ * Performs a beauty pass with the configured scene and camera.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+
+ const oldAutoClear = renderer.autoClear;
+ renderer.autoClear = false;
+
+ let oldClearAlpha, oldOverrideMaterial;
+
+ if ( this.overrideMaterial !== null ) {
+
+ oldOverrideMaterial = this.scene.overrideMaterial;
+
+ this.scene.overrideMaterial = this.overrideMaterial;
+
+ }
+
+ if ( this.clearColor !== null ) {
+
+ renderer.getClearColor( this._oldClearColor );
+ renderer.setClearColor( this.clearColor, renderer.getClearAlpha() );
+
+ }
+
+ if ( this.clearAlpha !== null ) {
+
+ oldClearAlpha = renderer.getClearAlpha();
+ renderer.setClearAlpha( this.clearAlpha );
+
+ }
+
+ if ( this.clearDepth == true ) {
+
+ renderer.clearDepth();
+
+ }
+
+ renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
+
+ if ( this.clear === true ) {
+
+ // TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
+ renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
+
+ }
+
+ renderer.render( this.scene, this.camera );
+
+ // restore
+
+ if ( this.clearColor !== null ) {
+
+ renderer.setClearColor( this._oldClearColor );
+
+ }
+
+ if ( this.clearAlpha !== null ) {
+
+ renderer.setClearAlpha( oldClearAlpha );
+
+ }
+
+ if ( this.overrideMaterial !== null ) {
+
+ this.scene.overrideMaterial = oldOverrideMaterial;
+
+ }
+
+ renderer.autoClear = oldAutoClear;
+
+ }
+
+}
+
+export { RenderPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/RenderPixelatedPass.js b/demo/hero-content/vendor/addons/postprocessing/RenderPixelatedPass.js
new file mode 100644
index 00000000..4eebcfa3
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/RenderPixelatedPass.js
@@ -0,0 +1,314 @@
+import {
+ WebGLRenderTarget,
+ MeshNormalMaterial,
+ ShaderMaterial,
+ Vector2,
+ Vector4,
+ DepthTexture,
+ NearestFilter,
+ HalfFloatType
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+
+/**
+ * A special type of render pass that produces a pixelated beauty pass.
+ *
+ * ```js
+ * const renderPixelatedPass = new RenderPixelatedPass( 6, scene, camera );
+ * composer.addPass( renderPixelatedPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { RenderPixelatedPass } from 'three/addons/postprocessing/RenderPixelatedPass.js';
+ */
+class RenderPixelatedPass extends Pass {
+
+ /**
+ * Constructs a new render pixelated pass.
+ *
+ * @param {number} pixelSize - The effect's pixel size.
+ * @param {Scene} scene - The scene to render.
+ * @param {Camera} camera - The camera.
+ * @param {{normalEdgeStrength:number,depthEdgeStrength:number}} options - The pass options.
+ */
+ constructor( pixelSize, scene, camera, options = {} ) {
+
+ super();
+
+ /**
+ * The effect's pixel size.
+ *
+ * @type {number}
+ */
+ this.pixelSize = pixelSize;
+
+ /**
+ * The scene to render.
+ *
+ * @type {Scene}
+ */
+ this.scene = scene;
+
+ /**
+ * The camera.
+ *
+ * @type {Camera}
+ */
+ this.camera = camera;
+
+ /**
+ * The normal edge strength.
+ *
+ * @type {number}
+ * @default 0.3
+ */
+ this.normalEdgeStrength = options.normalEdgeStrength || 0.3;
+
+ /**
+ * The normal edge strength.
+ *
+ * @type {number}
+ * @default 0.4
+ */
+ this.depthEdgeStrength = options.depthEdgeStrength || 0.4;
+
+ /**
+ * The pixelated material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.pixelatedMaterial = this._createPixelatedMaterial();
+
+ // internals
+
+ this._resolution = new Vector2();
+ this._renderResolution = new Vector2();
+
+ this._normalMaterial = new MeshNormalMaterial();
+
+ this._beautyRenderTarget = new WebGLRenderTarget();
+ this._beautyRenderTarget.texture.minFilter = NearestFilter;
+ this._beautyRenderTarget.texture.magFilter = NearestFilter;
+ this._beautyRenderTarget.texture.type = HalfFloatType;
+ this._beautyRenderTarget.depthTexture = new DepthTexture();
+
+ this._normalRenderTarget = new WebGLRenderTarget();
+ this._normalRenderTarget.texture.minFilter = NearestFilter;
+ this._normalRenderTarget.texture.magFilter = NearestFilter;
+ this._normalRenderTarget.texture.type = HalfFloatType;
+
+ this._fsQuad = new FullScreenQuad( this.pixelatedMaterial );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this._beautyRenderTarget.dispose();
+ this._normalRenderTarget.dispose();
+
+ this.pixelatedMaterial.dispose();
+ this._normalMaterial.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this._resolution.set( width, height );
+ this._renderResolution.set( ( width / this.pixelSize ) | 0, ( height / this.pixelSize ) | 0 );
+ const { x, y } = this._renderResolution;
+ this._beautyRenderTarget.setSize( x, y );
+ this._normalRenderTarget.setSize( x, y );
+ this._fsQuad.material.uniforms.resolution.value.set( x, y, 1 / x, 1 / y );
+
+ }
+
+ /**
+ * Sets the effect's pixel size.
+ *
+ * @param {number} pixelSize - The pixel size to set.
+ */
+ setPixelSize( pixelSize ) {
+
+ this.pixelSize = pixelSize;
+ this.setSize( this._resolution.x, this._resolution.y );
+
+ }
+
+ /**
+ * Performs the pixelation pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer/*, readBuffer , deltaTime, maskActive */ ) {
+
+ const uniforms = this._fsQuad.material.uniforms;
+ uniforms.normalEdgeStrength.value = this.normalEdgeStrength;
+ uniforms.depthEdgeStrength.value = this.depthEdgeStrength;
+
+ renderer.setRenderTarget( this._beautyRenderTarget );
+ renderer.render( this.scene, this.camera );
+
+ const overrideMaterial_old = this.scene.overrideMaterial;
+ renderer.setRenderTarget( this._normalRenderTarget );
+ this.scene.overrideMaterial = this._normalMaterial;
+ renderer.render( this.scene, this.camera );
+ this.scene.overrideMaterial = overrideMaterial_old;
+
+ uniforms.tDiffuse.value = this._beautyRenderTarget.texture;
+ uniforms.tDepth.value = this._beautyRenderTarget.depthTexture;
+ uniforms.tNormal.value = this._normalRenderTarget.texture;
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+
+ if ( this.clear ) renderer.clear();
+
+ }
+
+ this._fsQuad.render( renderer );
+
+ }
+
+ // internals
+
+ _createPixelatedMaterial() {
+
+ return new ShaderMaterial( {
+ uniforms: {
+ tDiffuse: { value: null },
+ tDepth: { value: null },
+ tNormal: { value: null },
+ resolution: { value: new Vector4() },
+ normalEdgeStrength: { value: 0 },
+ depthEdgeStrength: { value: 0 }
+ },
+ vertexShader: /* glsl */`
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }
+ `,
+ fragmentShader: /* glsl */`
+ uniform sampler2D tDiffuse;
+ uniform sampler2D tDepth;
+ uniform sampler2D tNormal;
+ uniform vec4 resolution;
+ uniform float normalEdgeStrength;
+ uniform float depthEdgeStrength;
+ varying vec2 vUv;
+
+ float getDepth(int x, int y) {
+
+ return texture2D( tDepth, vUv + vec2(x, y) * resolution.zw ).r;
+
+ }
+
+ vec3 getNormal(int x, int y) {
+
+ return texture2D( tNormal, vUv + vec2(x, y) * resolution.zw ).rgb * 2.0 - 1.0;
+
+ }
+
+ float depthEdgeIndicator(float depth, vec3 normal) {
+
+ float diff = 0.0;
+ diff += clamp(getDepth(1, 0) - depth, 0.0, 1.0);
+ diff += clamp(getDepth(-1, 0) - depth, 0.0, 1.0);
+ diff += clamp(getDepth(0, 1) - depth, 0.0, 1.0);
+ diff += clamp(getDepth(0, -1) - depth, 0.0, 1.0);
+ return floor(smoothstep(0.01, 0.02, diff) * 2.) / 2.;
+
+ }
+
+ float neighborNormalEdgeIndicator(int x, int y, float depth, vec3 normal) {
+
+ float depthDiff = getDepth(x, y) - depth;
+ vec3 neighborNormal = getNormal(x, y);
+
+ // Edge pixels should yield to faces who's normals are closer to the bias normal.
+ vec3 normalEdgeBias = vec3(1., 1., 1.); // This should probably be a parameter.
+ float normalDiff = dot(normal - neighborNormal, normalEdgeBias);
+ float normalIndicator = clamp(smoothstep(-.01, .01, normalDiff), 0.0, 1.0);
+
+ // Only the shallower pixel should detect the normal edge.
+ float depthIndicator = clamp(sign(depthDiff * .25 + .0025), 0.0, 1.0);
+
+ return (1.0 - dot(normal, neighborNormal)) * depthIndicator * normalIndicator;
+
+ }
+
+ float normalEdgeIndicator(float depth, vec3 normal) {
+
+ float indicator = 0.0;
+
+ indicator += neighborNormalEdgeIndicator(0, -1, depth, normal);
+ indicator += neighborNormalEdgeIndicator(0, 1, depth, normal);
+ indicator += neighborNormalEdgeIndicator(-1, 0, depth, normal);
+ indicator += neighborNormalEdgeIndicator(1, 0, depth, normal);
+
+ return step(0.1, indicator);
+
+ }
+
+ void main() {
+
+ vec4 texel = texture2D( tDiffuse, vUv );
+
+ float depth = 0.0;
+ vec3 normal = vec3(0.0);
+
+ if (depthEdgeStrength > 0.0 || normalEdgeStrength > 0.0) {
+
+ depth = getDepth(0, 0);
+ normal = getNormal(0, 0);
+
+ }
+
+ float dei = 0.0;
+ if (depthEdgeStrength > 0.0)
+ dei = depthEdgeIndicator(depth, normal);
+
+ float nei = 0.0;
+ if (normalEdgeStrength > 0.0)
+ nei = normalEdgeIndicator(depth, normal);
+
+ float Strength = dei > 0.0 ? (1.0 - depthEdgeStrength * dei) : (1.0 + normalEdgeStrength * nei);
+
+ gl_FragColor = texel * Strength;
+
+ }
+ `
+ } );
+
+ }
+
+}
+
+export { RenderPixelatedPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/RenderTransitionPass.js b/demo/hero-content/vendor/addons/postprocessing/RenderTransitionPass.js
new file mode 100644
index 00000000..70086045
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/RenderTransitionPass.js
@@ -0,0 +1,267 @@
+import {
+ HalfFloatType,
+ ShaderMaterial,
+ WebGLRenderTarget
+} from 'three';
+import { FullScreenQuad, Pass } from './Pass.js';
+
+/**
+ * A special type of render pass for implementing transition effects.
+ * When active, the pass will transition from scene A to scene B.
+ *
+ * ```js
+ * const renderTransitionPass = new RenderTransitionPass( fxSceneA.scene, fxSceneA.camera, fxSceneB.scene, fxSceneB.camera );
+ * renderTransitionPass.setTexture( textures[ 0 ] );
+ * composer.addPass( renderTransitionPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { RenderTransitionPass } from 'three/addons/postprocessing/RenderTransitionPass.js';
+ */
+class RenderTransitionPass extends Pass {
+
+ /**
+ * Constructs a render transition pass.
+ *
+ * @param {Scene} sceneA - The first scene.
+ * @param {Camera} cameraA - The camera of the first scene.
+ * @param {Scene} sceneB - The second scene.
+ * @param {Camera} cameraB - The camera of the second scene.
+ */
+ constructor( sceneA, cameraA, sceneB, cameraB ) {
+
+ super();
+
+ /**
+ * The first scene.
+ *
+ * @type {Scene}
+ */
+ this.sceneA = sceneA;
+
+
+ /**
+ * The camera of the first scene.
+ *
+ * @type {Camera}
+ */
+ this.cameraA = cameraA;
+
+ /**
+ * The second scene.
+ *
+ * @type {Scene}
+ */
+ this.sceneB = sceneB;
+
+ /**
+ * The camera of the second scene.
+ *
+ * @type {Camera}
+ */
+ this.cameraB = cameraB;
+
+ /**
+ * The pass material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.material = this._createMaterial();
+
+ // internals
+
+ this._renderTargetA = new WebGLRenderTarget();
+ this._renderTargetA.texture.type = HalfFloatType;
+ this._renderTargetB = new WebGLRenderTarget();
+ this._renderTargetB.texture.type = HalfFloatType;
+
+ this._fsQuad = new FullScreenQuad( this.material );
+
+ }
+
+ /**
+ * Sets the transition factor. Must be in the range `[0,1]`.
+ * This value determines to what degree both scenes are mixed.
+ *
+ * @param {boolean|number} value - The transition factor.
+ */
+ setTransition( value ) {
+
+ this.material.uniforms.mixRatio.value = value;
+
+ }
+
+ /**
+ * Toggles the usage of a texture for the effect.
+ *
+ * @param {boolean} value - Whether to use a texture for the transition effect or not.
+ */
+ useTexture( value ) {
+
+ this.material.uniforms.useTexture.value = value ? 1 : 0;
+
+ }
+
+ /**
+ * Sets the effect texture.
+ *
+ * @param {Texture} value - The effect texture.
+ */
+ setTexture( value ) {
+
+ this.material.uniforms.tMixTexture.value = value;
+
+ }
+
+ /**
+ * Sets the texture threshold. This value defines how strong the texture effects
+ * the transition. Must be in the range `[0,1]` (0 means full effect, 1 means no effect).
+ *
+ * @param {boolean|number} value - The threshold value.
+ */
+ setTextureThreshold( value ) {
+
+ this.material.uniforms.threshold.value = value;
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this._renderTargetA.setSize( width, height );
+ this._renderTargetB.setSize( width, height );
+
+ }
+
+ /**
+ * Performs the transition pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer/*, readBuffer , deltaTime, maskActive */ ) {
+
+ renderer.setRenderTarget( this._renderTargetA );
+ renderer.render( this.sceneA, this.cameraA );
+ renderer.setRenderTarget( this._renderTargetB );
+ renderer.render( this.sceneB, this.cameraB );
+
+ const uniforms = this._fsQuad.material.uniforms;
+ uniforms.tDiffuse1.value = this._renderTargetA.texture;
+ uniforms.tDiffuse2.value = this._renderTargetB.texture;
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+ renderer.clear();
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+ if ( this.clear ) renderer.clear();
+
+ }
+
+ this._fsQuad.render( renderer );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.material.dispose();
+
+ this._renderTargetA.dispose();
+ this._renderTargetB.dispose();
+ this._fsQuad.dispose();
+
+ }
+
+ // internals
+
+ _createMaterial() {
+
+ return new ShaderMaterial( {
+ uniforms: {
+ tDiffuse1: {
+ value: null
+ },
+ tDiffuse2: {
+ value: null
+ },
+ mixRatio: {
+ value: 0.0
+ },
+ threshold: {
+ value: 0.1
+ },
+ useTexture: {
+ value: 1
+ },
+ tMixTexture: {
+ value: null
+ }
+ },
+ vertexShader: /* glsl */`
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = vec2( uv.x, uv.y );
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }
+ `,
+ fragmentShader: /* glsl */`
+ uniform float mixRatio;
+
+ uniform sampler2D tDiffuse1;
+ uniform sampler2D tDiffuse2;
+ uniform sampler2D tMixTexture;
+
+ uniform int useTexture;
+ uniform float threshold;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 texel1 = texture2D( tDiffuse1, vUv );
+ vec4 texel2 = texture2D( tDiffuse2, vUv );
+
+ if (useTexture == 1) {
+
+ vec4 transitionTexel = texture2D( tMixTexture, vUv );
+ float r = mixRatio * ( 1.0 + threshold * 2.0 ) - threshold;
+ float mixf = clamp( ( transitionTexel.r - r ) * ( 1.0 / threshold ), 0.0, 1.0 );
+
+ gl_FragColor = mix( texel1, texel2, mixf );
+
+ } else {
+
+ gl_FragColor = mix( texel2, texel1, mixRatio );
+
+ }
+
+ }
+ `
+ } );
+
+ }
+
+}
+
+export { RenderTransitionPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/SAOPass.js b/demo/hero-content/vendor/addons/postprocessing/SAOPass.js
new file mode 100644
index 00000000..0adaee0b
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/SAOPass.js
@@ -0,0 +1,407 @@
+import {
+ AddEquation,
+ Color,
+ CustomBlending,
+ DepthTexture,
+ DstAlphaFactor,
+ DstColorFactor,
+ HalfFloatType,
+ MeshNormalMaterial,
+ NearestFilter,
+ NoBlending,
+ ShaderMaterial,
+ UniformsUtils,
+ DepthStencilFormat,
+ UnsignedInt248Type,
+ Vector2,
+ WebGLRenderTarget,
+ ZeroFactor
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { SAOShader } from '../shaders/SAOShader.js';
+import { BlurShaderUtils, DepthLimitedBlurShader } from '../shaders/DepthLimitedBlurShader.js';
+import { CopyShader } from '../shaders/CopyShader.js';
+
+/**
+ * A SAO implementation inspired from @bhouston previous SAO work.
+ *
+ * `SAOPass` provides better quality than {@link SSAOPass} but is also more expensive.
+ *
+ * ```js
+ * const saoPass = new SAOPass( scene, camera );
+ * composer.addPass( saoPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { SAOPass } from 'three/addons/postprocessing/SAOPass.js';
+ */
+class SAOPass extends Pass {
+
+ /**
+ * Constructs a new SAO pass.
+ *
+ * @param {Scene} scene - The scene to compute the AO for.
+ * @param {Camera} camera - The camera.
+ * @param {Vector2} [resolution] - The effect's resolution.
+ */
+ constructor( scene, camera, resolution = new Vector2( 256, 256 ) ) {
+
+ super();
+
+ /**
+ * The scene to render the AO for.
+ *
+ * @type {Scene}
+ */
+ this.scene = scene;
+
+ /**
+ * The camera.
+ *
+ * @type {Camera}
+ */
+ this.camera = camera;
+
+ /**
+ * Overwritten to perform a clear operation by default.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.clear = true;
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ this._originalClearColor = new Color();
+ this._oldClearColor = new Color();
+ this._oldClearAlpha = 1;
+
+ /**
+ * The SAO parameter.
+ *
+ * @type {Object}
+ */
+ this.params = {
+ output: 0,
+ saoBias: 0.5,
+ saoIntensity: 0.18,
+ saoScale: 1,
+ saoKernelRadius: 100,
+ saoMinResolution: 0,
+ saoBlur: true,
+ saoBlurRadius: 8,
+ saoBlurStdDev: 4,
+ saoBlurDepthCutoff: 0.01
+ };
+
+ /**
+ * The effect's resolution.
+ *
+ * @type {Vector2}
+ * @default (256,256)
+ */
+ this.resolution = new Vector2( resolution.x, resolution.y );
+
+ this.saoRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, { type: HalfFloatType, depthBuffer: false } );
+ this.blurIntermediateRenderTarget = this.saoRenderTarget.clone();
+
+ const depthTexture = new DepthTexture();
+ depthTexture.format = DepthStencilFormat;
+ depthTexture.type = UnsignedInt248Type;
+
+ this.normalRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, {
+ minFilter: NearestFilter,
+ magFilter: NearestFilter,
+ type: HalfFloatType,
+ depthTexture: depthTexture
+ } );
+
+ this.normalMaterial = new MeshNormalMaterial();
+ this.normalMaterial.blending = NoBlending;
+
+ this.saoMaterial = new ShaderMaterial( {
+ defines: Object.assign( {}, SAOShader.defines ),
+ fragmentShader: SAOShader.fragmentShader,
+ vertexShader: SAOShader.vertexShader,
+ uniforms: UniformsUtils.clone( SAOShader.uniforms )
+ } );
+ this.saoMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
+ this.saoMaterial.uniforms[ 'tDepth' ].value = depthTexture;
+ this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
+ this.saoMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
+ this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
+ this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix;
+ this.saoMaterial.blending = NoBlending;
+
+ this.vBlurMaterial = new ShaderMaterial( {
+ uniforms: UniformsUtils.clone( DepthLimitedBlurShader.uniforms ),
+ defines: Object.assign( {}, DepthLimitedBlurShader.defines ),
+ vertexShader: DepthLimitedBlurShader.vertexShader,
+ fragmentShader: DepthLimitedBlurShader.fragmentShader
+ } );
+ this.vBlurMaterial.defines[ 'DEPTH_PACKING' ] = 0;
+ this.vBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
+ this.vBlurMaterial.uniforms[ 'tDiffuse' ].value = this.saoRenderTarget.texture;
+ this.vBlurMaterial.uniforms[ 'tDepth' ].value = depthTexture;
+ this.vBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
+ this.vBlurMaterial.blending = NoBlending;
+
+ this.hBlurMaterial = new ShaderMaterial( {
+ uniforms: UniformsUtils.clone( DepthLimitedBlurShader.uniforms ),
+ defines: Object.assign( {}, DepthLimitedBlurShader.defines ),
+ vertexShader: DepthLimitedBlurShader.vertexShader,
+ fragmentShader: DepthLimitedBlurShader.fragmentShader
+ } );
+ this.hBlurMaterial.defines[ 'DEPTH_PACKING' ] = 0;
+ this.hBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
+ this.hBlurMaterial.uniforms[ 'tDiffuse' ].value = this.blurIntermediateRenderTarget.texture;
+ this.hBlurMaterial.uniforms[ 'tDepth' ].value = depthTexture;
+ this.hBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
+ this.hBlurMaterial.blending = NoBlending;
+
+ this.materialCopy = new ShaderMaterial( {
+ uniforms: UniformsUtils.clone( CopyShader.uniforms ),
+ vertexShader: CopyShader.vertexShader,
+ fragmentShader: CopyShader.fragmentShader,
+ blending: NoBlending
+ } );
+ this.materialCopy.transparent = true;
+ this.materialCopy.depthTest = false;
+ this.materialCopy.depthWrite = false;
+ this.materialCopy.blending = CustomBlending;
+ this.materialCopy.blendSrc = DstColorFactor;
+ this.materialCopy.blendDst = ZeroFactor;
+ this.materialCopy.blendEquation = AddEquation;
+ this.materialCopy.blendSrcAlpha = DstAlphaFactor;
+ this.materialCopy.blendDstAlpha = ZeroFactor;
+ this.materialCopy.blendEquationAlpha = AddEquation;
+
+ this.fsQuad = new FullScreenQuad( null );
+
+ }
+
+ /**
+ * Performs the SAO pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
+
+ // Rendering readBuffer first when rendering to screen
+ if ( this.renderToScreen ) {
+
+ this.materialCopy.blending = NoBlending;
+ this.materialCopy.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
+ this.materialCopy.needsUpdate = true;
+ this._renderPass( renderer, this.materialCopy, null );
+
+ }
+
+ renderer.getClearColor( this._oldClearColor );
+ this._oldClearAlpha = renderer.getClearAlpha();
+ const oldAutoClear = renderer.autoClear;
+ renderer.autoClear = false;
+
+ this.saoMaterial.uniforms[ 'bias' ].value = this.params.saoBias;
+ this.saoMaterial.uniforms[ 'intensity' ].value = this.params.saoIntensity;
+ this.saoMaterial.uniforms[ 'scale' ].value = this.params.saoScale;
+ this.saoMaterial.uniforms[ 'kernelRadius' ].value = this.params.saoKernelRadius;
+ this.saoMaterial.uniforms[ 'minResolution' ].value = this.params.saoMinResolution;
+ this.saoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+ this.saoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+ // this.saoMaterial.uniforms['randomSeed'].value = Math.random();
+
+ const depthCutoff = this.params.saoBlurDepthCutoff * ( this.camera.far - this.camera.near );
+ this.vBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff;
+ this.hBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff;
+
+ this.vBlurMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+ this.vBlurMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+ this.hBlurMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+ this.hBlurMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+
+ this.params.saoBlurRadius = Math.floor( this.params.saoBlurRadius );
+ if ( ( this.prevStdDev !== this.params.saoBlurStdDev ) || ( this.prevNumSamples !== this.params.saoBlurRadius ) ) {
+
+ BlurShaderUtils.configure( this.vBlurMaterial, this.params.saoBlurRadius, this.params.saoBlurStdDev, new Vector2( 0, 1 ) );
+ BlurShaderUtils.configure( this.hBlurMaterial, this.params.saoBlurRadius, this.params.saoBlurStdDev, new Vector2( 1, 0 ) );
+ this.prevStdDev = this.params.saoBlurStdDev;
+ this.prevNumSamples = this.params.saoBlurRadius;
+
+ }
+
+ // render normal and depth
+ this._renderOverride( renderer, this.normalMaterial, this.normalRenderTarget, 0x7777ff, 1.0 );
+
+ // Rendering SAO texture
+ this._renderPass( renderer, this.saoMaterial, this.saoRenderTarget, 0xffffff, 1.0 );
+
+ // Blurring SAO texture
+ if ( this.params.saoBlur ) {
+
+ this._renderPass( renderer, this.vBlurMaterial, this.blurIntermediateRenderTarget, 0xffffff, 1.0 );
+ this._renderPass( renderer, this.hBlurMaterial, this.saoRenderTarget, 0xffffff, 1.0 );
+
+ }
+
+ const outputMaterial = this.materialCopy;
+
+ // Setting up SAO rendering
+ if ( this.params.output === SAOPass.OUTPUT.Normal ) {
+
+ this.materialCopy.uniforms[ 'tDiffuse' ].value = this.normalRenderTarget.texture;
+ this.materialCopy.needsUpdate = true;
+
+ } else {
+
+ this.materialCopy.uniforms[ 'tDiffuse' ].value = this.saoRenderTarget.texture;
+ this.materialCopy.needsUpdate = true;
+
+ }
+
+ // Blending depends on output
+ if ( this.params.output === SAOPass.OUTPUT.Default ) {
+
+ outputMaterial.blending = CustomBlending;
+
+ } else {
+
+ outputMaterial.blending = NoBlending;
+
+ }
+
+ // Rendering SAOPass result on top of previous pass
+ this._renderPass( renderer, outputMaterial, this.renderToScreen ? null : readBuffer );
+
+ renderer.setClearColor( this._oldClearColor, this._oldClearAlpha );
+ renderer.autoClear = oldAutoClear;
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this.saoRenderTarget.setSize( width, height );
+ this.blurIntermediateRenderTarget.setSize( width, height );
+ this.normalRenderTarget.setSize( width, height );
+
+ this.saoMaterial.uniforms[ 'size' ].value.set( width, height );
+ this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
+ this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix;
+ this.saoMaterial.needsUpdate = true;
+
+ this.vBlurMaterial.uniforms[ 'size' ].value.set( width, height );
+ this.vBlurMaterial.needsUpdate = true;
+
+ this.hBlurMaterial.uniforms[ 'size' ].value.set( width, height );
+ this.hBlurMaterial.needsUpdate = true;
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.saoRenderTarget.dispose();
+ this.blurIntermediateRenderTarget.dispose();
+ this.normalRenderTarget.dispose();
+
+ this.normalMaterial.dispose();
+ this.saoMaterial.dispose();
+ this.vBlurMaterial.dispose();
+ this.hBlurMaterial.dispose();
+ this.materialCopy.dispose();
+
+ this.fsQuad.dispose();
+
+ }
+
+ // internal
+
+ _renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+
+ // save original state
+ renderer.getClearColor( this._originalClearColor );
+ const originalClearAlpha = renderer.getClearAlpha();
+ const originalAutoClear = renderer.autoClear;
+
+ renderer.setRenderTarget( renderTarget );
+
+ // setup pass state
+ renderer.autoClear = false;
+ if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
+
+ renderer.setClearColor( clearColor );
+ renderer.setClearAlpha( clearAlpha || 0.0 );
+ renderer.clear();
+
+ }
+
+ this.fsQuad.material = passMaterial;
+ this.fsQuad.render( renderer );
+
+ // restore original state
+ renderer.autoClear = originalAutoClear;
+ renderer.setClearColor( this._originalClearColor );
+ renderer.setClearAlpha( originalClearAlpha );
+
+ }
+
+ _renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+
+ renderer.getClearColor( this._originalClearColor );
+ const originalClearAlpha = renderer.getClearAlpha();
+ const originalAutoClear = renderer.autoClear;
+
+ renderer.setRenderTarget( renderTarget );
+ renderer.autoClear = false;
+
+ clearColor = overrideMaterial.clearColor || clearColor;
+ clearAlpha = overrideMaterial.clearAlpha || clearAlpha;
+ if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
+
+ renderer.setClearColor( clearColor );
+ renderer.setClearAlpha( clearAlpha || 0.0 );
+ renderer.clear();
+
+ }
+
+ this.scene.overrideMaterial = overrideMaterial;
+ renderer.render( this.scene, this.camera );
+ this.scene.overrideMaterial = null;
+
+ // restore original state
+ renderer.autoClear = originalAutoClear;
+ renderer.setClearColor( this._originalClearColor );
+ renderer.setClearAlpha( originalClearAlpha );
+
+ }
+
+}
+
+SAOPass.OUTPUT = {
+ 'Default': 0,
+ 'SAO': 1,
+ 'Normal': 2
+};
+
+export { SAOPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/SMAAPass.js b/demo/hero-content/vendor/addons/postprocessing/SMAAPass.js
new file mode 100644
index 00000000..e330f904
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/SMAAPass.js
@@ -0,0 +1,230 @@
+import {
+ HalfFloatType,
+ LinearFilter,
+ NearestFilter,
+ ShaderMaterial,
+ Texture,
+ UniformsUtils,
+ WebGLRenderTarget
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { SMAABlendShader, SMAAEdgesShader, SMAAWeightsShader } from '../shaders/SMAAShader.js';
+
+/**
+ * A pass for applying SMAA. Unlike {@link FXAAPass}, `SMAAPass` operates in
+ * `linear-srgb` so this pass must be executed before {@link OutputPass}.
+ *
+ * ```js
+ * const smaaPass = new SMAAPass();
+ * composer.addPass( smaaPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { SMAAPass } from 'three/addons/postprocessing/SMAAPass.js';
+ */
+class SMAAPass extends Pass {
+
+ /**
+ * Constructs a new SMAA pass.
+ */
+ constructor( ) {
+
+ super();
+
+ // render targets
+
+ this._edgesRT = new WebGLRenderTarget( 1, 1, {
+ depthBuffer: false,
+ type: HalfFloatType
+ } );
+ this._edgesRT.texture.name = 'SMAAPass.edges';
+
+ this._weightsRT = new WebGLRenderTarget( 1, 1, {
+ depthBuffer: false,
+ type: HalfFloatType
+ } );
+ this._weightsRT.texture.name = 'SMAAPass.weights';
+
+ // textures
+ const scope = this;
+
+ const areaTextureImage = new Image();
+ areaTextureImage.src = this._getAreaTexture();
+ areaTextureImage.onload = function () {
+
+ // assigning data to HTMLImageElement.src is asynchronous (see #15162)
+ scope._areaTexture.needsUpdate = true;
+
+ };
+
+ this._areaTexture = new Texture();
+ this._areaTexture.name = 'SMAAPass.area';
+ this._areaTexture.image = areaTextureImage;
+ this._areaTexture.minFilter = LinearFilter;
+ this._areaTexture.generateMipmaps = false;
+ this._areaTexture.flipY = false;
+
+ const searchTextureImage = new Image();
+ searchTextureImage.src = this._getSearchTexture();
+ searchTextureImage.onload = function () {
+
+ // assigning data to HTMLImageElement.src is asynchronous (see #15162)
+ scope._searchTexture.needsUpdate = true;
+
+ };
+
+ this._searchTexture = new Texture();
+ this._searchTexture.name = 'SMAAPass.search';
+ this._searchTexture.image = searchTextureImage;
+ this._searchTexture.magFilter = NearestFilter;
+ this._searchTexture.minFilter = NearestFilter;
+ this._searchTexture.generateMipmaps = false;
+ this._searchTexture.flipY = false;
+
+ // materials - pass 1
+
+ this._uniformsEdges = UniformsUtils.clone( SMAAEdgesShader.uniforms );
+
+ this._materialEdges = new ShaderMaterial( {
+ defines: Object.assign( {}, SMAAEdgesShader.defines ),
+ uniforms: this._uniformsEdges,
+ vertexShader: SMAAEdgesShader.vertexShader,
+ fragmentShader: SMAAEdgesShader.fragmentShader
+ } );
+
+ // materials - pass 2
+
+ this._uniformsWeights = UniformsUtils.clone( SMAAWeightsShader.uniforms );
+
+ this._uniformsWeights[ 'tDiffuse' ].value = this._edgesRT.texture;
+ this._uniformsWeights[ 'tArea' ].value = this._areaTexture;
+ this._uniformsWeights[ 'tSearch' ].value = this._searchTexture;
+
+ this._materialWeights = new ShaderMaterial( {
+ defines: Object.assign( {}, SMAAWeightsShader.defines ),
+ uniforms: this._uniformsWeights,
+ vertexShader: SMAAWeightsShader.vertexShader,
+ fragmentShader: SMAAWeightsShader.fragmentShader
+ } );
+
+ // materials - pass 3
+
+ this._uniformsBlend = UniformsUtils.clone( SMAABlendShader.uniforms );
+ this._uniformsBlend[ 'tDiffuse' ].value = this._weightsRT.texture;
+
+ this._materialBlend = new ShaderMaterial( {
+ uniforms: this._uniformsBlend,
+ vertexShader: SMAABlendShader.vertexShader,
+ fragmentShader: SMAABlendShader.fragmentShader
+ } );
+
+ this._fsQuad = new FullScreenQuad( null );
+
+ }
+
+ /**
+ * Performs the SMAA pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive*/ ) {
+
+ // pass 1
+
+ this._uniformsEdges[ 'tDiffuse' ].value = readBuffer.texture;
+
+ this._fsQuad.material = this._materialEdges;
+
+ renderer.setRenderTarget( this._edgesRT );
+ if ( this.clear ) renderer.clear();
+ this._fsQuad.render( renderer );
+
+ // pass 2
+
+ this._fsQuad.material = this._materialWeights;
+
+ renderer.setRenderTarget( this._weightsRT );
+ if ( this.clear ) renderer.clear();
+ this._fsQuad.render( renderer );
+
+ // pass 3
+
+ this._uniformsBlend[ 'tColor' ].value = readBuffer.texture;
+
+ this._fsQuad.material = this._materialBlend;
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+ this._fsQuad.render( renderer );
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+ if ( this.clear ) renderer.clear();
+ this._fsQuad.render( renderer );
+
+ }
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this._edgesRT.setSize( width, height );
+ this._weightsRT.setSize( width, height );
+
+ this._materialEdges.uniforms[ 'resolution' ].value.set( 1 / width, 1 / height );
+ this._materialWeights.uniforms[ 'resolution' ].value.set( 1 / width, 1 / height );
+ this._materialBlend.uniforms[ 'resolution' ].value.set( 1 / width, 1 / height );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this._edgesRT.dispose();
+ this._weightsRT.dispose();
+
+ this._areaTexture.dispose();
+ this._searchTexture.dispose();
+
+ this._materialEdges.dispose();
+ this._materialWeights.dispose();
+ this._materialBlend.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+ // internals
+
+ _getAreaTexture() {
+
+ return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzMiw2jAWtgwC8WR5Q8mDFHZLNHTarZGrLJJllt1W2qKrsumZWZcTvn7L3W54e1vrXX3vuciLPPORFR1XE2EomorB0nVuz//r71re/y/1eMvb4Cb3N11xV/PP/2v4UBAwJG/7H8urx6/25/Gf8O5hypMQ0EEEQwAqLfoN/Z+97f/SW+/NvcgQk4sGBJK6H7N4PFVL+K+e0N11yNfkKvwUdwdlUAXPHHL38oa15f/i/46Ih6SuMSPmLAYAwyRKn7dfMGH97jaMFBYCJUgotIC2YAdu+LyW9vvubxAP8kAL8H/koAuOKP3+q6+xGnd5kdYCeECnGIJViwGJMAkQKfDvB3WZxjLKGh8VSCCzhwEWBpMc5/kBbjawT4HnwJfhr+pPBIu7uu+OOTo9vsmtQcniMBGkKFd4jDWMSCRUpLjJYNJkM+IRzQ+PQvIeAMTrBS2LEiaiR9b/5PuT6Ap/AcfAFO4Y3dA3DF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T3dYeLGH+ShrWNwZgN0b2YL7qznr3g8JYAo5bQBziPjx7BPZ0d9RCQp4UZbnFdzBddor4XHN4KYMrB2qHFRIzzcLAHQZ5the5ovui94PCWAPefaYnxIdzRwdHCbuR4B+tbiy96Lzi8E4D7z7S0mEPd+eqO3cT53Z0Y8SV80XvB4Z0ADJi/f7X113f+7p7/+UYBvur6657/+YYBvur6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+VMA8FXWX/f8z58OgK+y/rrnf75RgLna+uue//lTA/CV1V/3/M837aKvvv6653++UQvmauuve/7nTwfAV1N/3fM/fzr24Cuuv+75nz8FFnxl9dc9//MOr/8/glixwRuUfM4AAAAASUVORK5CYII=';
+
+ }
+
+ _getSearchTexture() {
+
+ return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=';
+
+ }
+
+}
+
+export { SMAAPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/SSAARenderPass.js b/demo/hero-content/vendor/addons/postprocessing/SSAARenderPass.js
new file mode 100644
index 00000000..797c466f
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/SSAARenderPass.js
@@ -0,0 +1,313 @@
+import {
+ AdditiveBlending,
+ Color,
+ HalfFloatType,
+ ShaderMaterial,
+ UniformsUtils,
+ WebGLRenderTarget
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { CopyShader } from '../shaders/CopyShader.js';
+
+/**
+ * Supersample Anti-Aliasing Render Pass.
+ *
+ * This manual approach to SSAA re-renders the scene ones for each sample with camera jitter and accumulates the results.
+ *
+ * ```js
+ * const ssaaRenderPass = new SSAARenderPass( scene, camera );
+ * ssaaRenderPass.sampleLevel = 3;
+ * composer.addPass( ssaaRenderPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { SSAARenderPass } from 'three/addons/postprocessing/SSAARenderPass.js';
+ */
+class SSAARenderPass extends Pass {
+
+ /**
+ * Constructs a new SSAA render pass.
+ *
+ * @param {Scene} scene - The scene to render.
+ * @param {Camera} camera - The camera.
+ * @param {?(number|Color|string)} [clearColor=0x000000] - The clear color of the render pass.
+ * @param {?number} [clearAlpha=0] - The clear alpha of the render pass.
+ */
+ constructor( scene, camera, clearColor = 0x000000, clearAlpha = 0 ) {
+
+ super();
+
+ /**
+ * The scene to render.
+ *
+ * @type {Scene}
+ */
+ this.scene = scene;
+
+ /**
+ * The camera.
+ *
+ * @type {Camera}
+ */
+ this.camera = camera;
+
+ /**
+ * The sample level. Specified as n, where the number of
+ * samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
+ *
+ * @type {number}
+ * @default 4
+ */
+ this.sampleLevel = 4;
+
+ /**
+ * Whether the pass should be unbiased or not. This property has the most
+ * visible effect when rendering to a RGBA8 buffer because it mitigates
+ * rounding errors. By default RGBA16F is used.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.unbiased = true;
+
+ /**
+ * Whether to use a stencil buffer or not. This property can't
+ * be changed after the first render.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.stencilBuffer = false;
+
+ /**
+ * The clear color of the render pass.
+ *
+ * @type {?(number|Color|string)}
+ * @default 0x000000
+ */
+ this.clearColor = clearColor;
+
+ /**
+ * The clear alpha of the render pass.
+ *
+ * @type {?number}
+ * @default 0
+ */
+ this.clearAlpha = clearAlpha;
+
+ // internals
+
+ this._sampleRenderTarget = null;
+
+ this._oldClearColor = new Color();
+
+ this._copyUniforms = UniformsUtils.clone( CopyShader.uniforms );
+
+ this._copyMaterial = new ShaderMaterial( {
+ uniforms: this._copyUniforms,
+ vertexShader: CopyShader.vertexShader,
+ fragmentShader: CopyShader.fragmentShader,
+ transparent: true,
+ depthTest: false,
+ depthWrite: false,
+ premultipliedAlpha: true,
+ blending: AdditiveBlending
+ } );
+
+ this._fsQuad = new FullScreenQuad( this._copyMaterial );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ if ( this._sampleRenderTarget ) {
+
+ this._sampleRenderTarget.dispose();
+ this._sampleRenderTarget = null;
+
+ }
+
+ this._copyMaterial.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ if ( this._sampleRenderTarget ) this._sampleRenderTarget.setSize( width, height );
+
+ }
+
+ /**
+ * Performs the SSAA render pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive */ ) {
+
+ if ( ! this._sampleRenderTarget ) {
+
+ this._sampleRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType, stencilBuffer: this.stencilBuffer } );
+ this._sampleRenderTarget.texture.name = 'SSAARenderPass.sample';
+
+ }
+
+ const jitterOffsets = _JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ];
+
+ const autoClear = renderer.autoClear;
+ renderer.autoClear = false;
+
+ renderer.getClearColor( this._oldClearColor );
+ const oldClearAlpha = renderer.getClearAlpha();
+
+ const baseSampleWeight = 1.0 / jitterOffsets.length;
+ const roundingRange = 1 / 32;
+ this._copyUniforms[ 'tDiffuse' ].value = this._sampleRenderTarget.texture;
+
+ const viewOffset = {
+
+ fullWidth: readBuffer.width,
+ fullHeight: readBuffer.height,
+ offsetX: 0,
+ offsetY: 0,
+ width: readBuffer.width,
+ height: readBuffer.height
+
+ };
+
+ const originalViewOffset = Object.assign( {}, this.camera.view );
+
+ if ( originalViewOffset.enabled ) Object.assign( viewOffset, originalViewOffset );
+
+ // render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
+ for ( let i = 0; i < jitterOffsets.length; i ++ ) {
+
+ const jitterOffset = jitterOffsets[ i ];
+
+ if ( this.camera.setViewOffset ) {
+
+ this.camera.setViewOffset(
+
+ viewOffset.fullWidth, viewOffset.fullHeight,
+
+ viewOffset.offsetX + jitterOffset[ 0 ] * 0.0625, viewOffset.offsetY + jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16
+
+ viewOffset.width, viewOffset.height
+
+ );
+
+ }
+
+ let sampleWeight = baseSampleWeight;
+
+ if ( this.unbiased ) {
+
+ // the theory is that equal weights for each sample lead to an accumulation of rounding errors.
+ // The following equation varies the sampleWeight per sample so that it is uniformly distributed
+ // across a range of values whose rounding errors cancel each other out.
+
+ const uniformCenteredDistribution = ( - 0.5 + ( i + 0.5 ) / jitterOffsets.length );
+ sampleWeight += roundingRange * uniformCenteredDistribution;
+
+ }
+
+ this._copyUniforms[ 'opacity' ].value = sampleWeight;
+ renderer.setClearColor( this.clearColor, this.clearAlpha );
+ renderer.setRenderTarget( this._sampleRenderTarget );
+ renderer.clear();
+ renderer.render( this.scene, this.camera );
+
+ renderer.setRenderTarget( this.renderToScreen ? null : writeBuffer );
+
+ if ( i === 0 ) {
+
+ renderer.setClearColor( 0x000000, 0.0 );
+ renderer.clear();
+
+ }
+
+ this._fsQuad.render( renderer );
+
+ }
+
+ if ( this.camera.setViewOffset && originalViewOffset.enabled ) {
+
+ this.camera.setViewOffset(
+
+ originalViewOffset.fullWidth, originalViewOffset.fullHeight,
+
+ originalViewOffset.offsetX, originalViewOffset.offsetY,
+
+ originalViewOffset.width, originalViewOffset.height
+
+ );
+
+ } else if ( this.camera.clearViewOffset ) {
+
+ this.camera.clearViewOffset();
+
+ }
+
+ renderer.autoClear = autoClear;
+ renderer.setClearColor( this._oldClearColor, oldClearAlpha );
+
+ }
+
+}
+
+
+// These jitter vectors are specified in integers because it is easier.
+// I am assuming a [-8,8) integer grid, but it needs to be mapped onto [-0.5,0.5)
+// before being used, thus these integers need to be scaled by 1/16.
+//
+// Sample patterns reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
+const _JitterVectors = [
+ [
+ [ 0, 0 ]
+ ],
+ [
+ [ 4, 4 ], [ - 4, - 4 ]
+ ],
+ [
+ [ - 2, - 6 ], [ 6, - 2 ], [ - 6, 2 ], [ 2, 6 ]
+ ],
+ [
+ [ 1, - 3 ], [ - 1, 3 ], [ 5, 1 ], [ - 3, - 5 ],
+ [ - 5, 5 ], [ - 7, - 1 ], [ 3, 7 ], [ 7, - 7 ]
+ ],
+ [
+ [ 1, 1 ], [ - 1, - 3 ], [ - 3, 2 ], [ 4, - 1 ],
+ [ - 5, - 2 ], [ 2, 5 ], [ 5, 3 ], [ 3, - 5 ],
+ [ - 2, 6 ], [ 0, - 7 ], [ - 4, - 6 ], [ - 6, 4 ],
+ [ - 8, 0 ], [ 7, - 4 ], [ 6, 7 ], [ - 7, - 8 ]
+ ],
+ [
+ [ - 4, - 7 ], [ - 7, - 5 ], [ - 3, - 5 ], [ - 5, - 4 ],
+ [ - 1, - 4 ], [ - 2, - 2 ], [ - 6, - 1 ], [ - 4, 0 ],
+ [ - 7, 1 ], [ - 1, 2 ], [ - 6, 3 ], [ - 3, 3 ],
+ [ - 7, 6 ], [ - 3, 6 ], [ - 5, 7 ], [ - 1, 7 ],
+ [ 5, - 7 ], [ 1, - 6 ], [ 6, - 5 ], [ 4, - 4 ],
+ [ 2, - 3 ], [ 7, - 2 ], [ 1, - 1 ], [ 4, - 1 ],
+ [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],
+ [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]
+ ]
+];
+
+export { SSAARenderPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/SSAOPass.js b/demo/hero-content/vendor/addons/postprocessing/SSAOPass.js
new file mode 100644
index 00000000..62a1ae76
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/SSAOPass.js
@@ -0,0 +1,527 @@
+import {
+ AddEquation,
+ Color,
+ CustomBlending,
+ DataTexture,
+ DepthTexture,
+ DstAlphaFactor,
+ DstColorFactor,
+ FloatType,
+ HalfFloatType,
+ MathUtils,
+ MeshNormalMaterial,
+ NearestFilter,
+ NoBlending,
+ RedFormat,
+ DepthStencilFormat,
+ UnsignedInt248Type,
+ RepeatWrapping,
+ ShaderMaterial,
+ UniformsUtils,
+ Vector3,
+ WebGLRenderTarget,
+ ZeroFactor
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { SimplexNoise } from '../math/SimplexNoise.js';
+import { SSAOBlurShader, SSAODepthShader, SSAOShader } from '../shaders/SSAOShader.js';
+import { CopyShader } from '../shaders/CopyShader.js';
+
+/**
+ * A pass for a basic SSAO effect.
+ *
+ * {@link SAOPass} and {@link GTAPass} produce a more advanced AO but are also
+ * more expensive.
+ *
+ * ```js
+ * const ssaoPass = new SSAOPass( scene, camera, width, height );
+ * composer.addPass( ssaoPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { SSAOPass } from 'three/addons/postprocessing/SSAOPass.js';
+ */
+class SSAOPass extends Pass {
+
+ /**
+ * Constructs a new SSAO pass.
+ *
+ * @param {Scene} scene - The scene to compute the AO for.
+ * @param {Camera} camera - The camera.
+ * @param {number} [width=512] - The width of the effect.
+ * @param {number} [height=512] - The height of the effect.
+ * @param {number} [kernelSize=32] - The kernel size.
+ */
+ constructor( scene, camera, width = 512, height = 512, kernelSize = 32 ) {
+
+ super();
+
+ /**
+ * The width of the effect.
+ *
+ * @type {number}
+ * @default 512
+ */
+ this.width = width;
+
+ /**
+ * The height of the effect.
+ *
+ * @type {number}
+ * @default 512
+ */
+ this.height = height;
+
+ /**
+ * Overwritten to perform a clear operation by default.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.clear = true;
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ /**
+ * The camera.
+ *
+ * @type {Camera}
+ */
+ this.camera = camera;
+
+ /**
+ * The scene to render the AO for.
+ *
+ * @type {Scene}
+ */
+ this.scene = scene;
+
+ /**
+ * The kernel radius controls how wide the
+ * AO spreads.
+ *
+ * @type {number}
+ * @default 8
+ */
+ this.kernelRadius = 8;
+ this.kernel = [];
+ this.noiseTexture = null;
+
+ /**
+ * The output configuration.
+ *
+ * @type {number}
+ * @default 0
+ */
+ this.output = 0;
+
+ /**
+ * Defines the minimum distance that should be
+ * affected by the AO.
+ *
+ * @type {number}
+ * @default 0.005
+ */
+ this.minDistance = 0.005;
+
+ /**
+ * Defines the maximum distance that should be
+ * affected by the AO.
+ *
+ * @type {number}
+ * @default 0.1
+ */
+ this.maxDistance = 0.1;
+
+ this._visibilityCache = [];
+
+ //
+
+ this._generateSampleKernel( kernelSize );
+ this._generateRandomKernelRotations();
+
+ // depth texture
+
+ const depthTexture = new DepthTexture();
+ depthTexture.format = DepthStencilFormat;
+ depthTexture.type = UnsignedInt248Type;
+
+ // normal render target with depth buffer
+
+ this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+ minFilter: NearestFilter,
+ magFilter: NearestFilter,
+ type: HalfFloatType,
+ depthTexture: depthTexture
+ } );
+
+ // ssao render target
+
+ this.ssaoRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType, depthBuffer: false } );
+
+ this.blurRenderTarget = this.ssaoRenderTarget.clone();
+
+ // ssao material
+
+ this.ssaoMaterial = new ShaderMaterial( {
+ defines: Object.assign( {}, SSAOShader.defines ),
+ uniforms: UniformsUtils.clone( SSAOShader.uniforms ),
+ vertexShader: SSAOShader.vertexShader,
+ fragmentShader: SSAOShader.fragmentShader,
+ blending: NoBlending
+ } );
+
+ this.ssaoMaterial.defines[ 'KERNEL_SIZE' ] = kernelSize;
+
+ this.ssaoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
+ this.ssaoMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
+ this.ssaoMaterial.uniforms[ 'tNoise' ].value = this.noiseTexture;
+ this.ssaoMaterial.uniforms[ 'kernel' ].value = this.kernel;
+ this.ssaoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+ this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+ this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+ this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
+ this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
+
+ // normal material
+
+ this.normalMaterial = new MeshNormalMaterial();
+ this.normalMaterial.blending = NoBlending;
+
+ // blur material
+
+ this.blurMaterial = new ShaderMaterial( {
+ defines: Object.assign( {}, SSAOBlurShader.defines ),
+ uniforms: UniformsUtils.clone( SSAOBlurShader.uniforms ),
+ vertexShader: SSAOBlurShader.vertexShader,
+ fragmentShader: SSAOBlurShader.fragmentShader
+ } );
+ this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssaoRenderTarget.texture;
+ this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+
+ // material for rendering the depth
+
+ this.depthRenderMaterial = new ShaderMaterial( {
+ defines: Object.assign( {}, SSAODepthShader.defines ),
+ uniforms: UniformsUtils.clone( SSAODepthShader.uniforms ),
+ vertexShader: SSAODepthShader.vertexShader,
+ fragmentShader: SSAODepthShader.fragmentShader,
+ blending: NoBlending
+ } );
+ this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
+ this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+ this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+
+ // material for rendering the content of a render target
+
+ this.copyMaterial = new ShaderMaterial( {
+ uniforms: UniformsUtils.clone( CopyShader.uniforms ),
+ vertexShader: CopyShader.vertexShader,
+ fragmentShader: CopyShader.fragmentShader,
+ transparent: true,
+ depthTest: false,
+ depthWrite: false,
+ blendSrc: DstColorFactor,
+ blendDst: ZeroFactor,
+ blendEquation: AddEquation,
+ blendSrcAlpha: DstAlphaFactor,
+ blendDstAlpha: ZeroFactor,
+ blendEquationAlpha: AddEquation
+ } );
+
+ // internals
+
+ this._fsQuad = new FullScreenQuad( null );
+
+ this._originalClearColor = new Color();
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ // dispose render targets
+
+ this.normalRenderTarget.dispose();
+ this.ssaoRenderTarget.dispose();
+ this.blurRenderTarget.dispose();
+
+ // dispose materials
+
+ this.normalMaterial.dispose();
+ this.blurMaterial.dispose();
+ this.copyMaterial.dispose();
+ this.depthRenderMaterial.dispose();
+
+ // dispose full screen quad
+
+ this._fsQuad.dispose();
+
+ }
+
+ /**
+ * Performs the SSAO pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+
+ // render normals and depth (honor only meshes, points and lines do not contribute to SSAO)
+
+ this._overrideVisibility();
+ this._renderOverride( renderer, this.normalMaterial, this.normalRenderTarget, 0x7777ff, 1.0 );
+ this._restoreVisibility();
+
+ // render SSAO
+
+ this.ssaoMaterial.uniforms[ 'kernelRadius' ].value = this.kernelRadius;
+ this.ssaoMaterial.uniforms[ 'minDistance' ].value = this.minDistance;
+ this.ssaoMaterial.uniforms[ 'maxDistance' ].value = this.maxDistance;
+ this._renderPass( renderer, this.ssaoMaterial, this.ssaoRenderTarget );
+
+ // render blur
+
+ this._renderPass( renderer, this.blurMaterial, this.blurRenderTarget );
+
+ // output result to screen
+
+ switch ( this.output ) {
+
+ case SSAOPass.OUTPUT.SSAO:
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssaoRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : readBuffer );
+
+ break;
+
+ case SSAOPass.OUTPUT.Blur:
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : readBuffer );
+
+ break;
+
+ case SSAOPass.OUTPUT.Depth:
+
+ this._renderPass( renderer, this.depthRenderMaterial, this.renderToScreen ? null : readBuffer );
+
+ break;
+
+ case SSAOPass.OUTPUT.Normal:
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.normalRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : readBuffer );
+
+ break;
+
+ case SSAOPass.OUTPUT.Default:
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget.texture;
+ this.copyMaterial.blending = CustomBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : readBuffer );
+
+ break;
+
+ default:
+ console.warn( 'THREE.SSAOPass: Unknown output type.' );
+
+ }
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this.width = width;
+ this.height = height;
+
+ this.ssaoRenderTarget.setSize( width, height );
+ this.normalRenderTarget.setSize( width, height );
+ this.blurRenderTarget.setSize( width, height );
+
+ this.ssaoMaterial.uniforms[ 'resolution' ].value.set( width, height );
+ this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
+ this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
+
+ this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height );
+
+ }
+
+ // internals
+
+ _renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+
+ // save original state
+ renderer.getClearColor( this._originalClearColor );
+ const originalClearAlpha = renderer.getClearAlpha();
+ const originalAutoClear = renderer.autoClear;
+
+ renderer.setRenderTarget( renderTarget );
+
+ // setup pass state
+ renderer.autoClear = false;
+ if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
+
+ renderer.setClearColor( clearColor );
+ renderer.setClearAlpha( clearAlpha || 0.0 );
+ renderer.clear();
+
+ }
+
+ this._fsQuad.material = passMaterial;
+ this._fsQuad.render( renderer );
+
+ // restore original state
+ renderer.autoClear = originalAutoClear;
+ renderer.setClearColor( this._originalClearColor );
+ renderer.setClearAlpha( originalClearAlpha );
+
+ }
+
+ _renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+
+ renderer.getClearColor( this._originalClearColor );
+ const originalClearAlpha = renderer.getClearAlpha();
+ const originalAutoClear = renderer.autoClear;
+
+ renderer.setRenderTarget( renderTarget );
+ renderer.autoClear = false;
+
+ clearColor = overrideMaterial.clearColor || clearColor;
+ clearAlpha = overrideMaterial.clearAlpha || clearAlpha;
+
+ if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
+
+ renderer.setClearColor( clearColor );
+ renderer.setClearAlpha( clearAlpha || 0.0 );
+ renderer.clear();
+
+ }
+
+ this.scene.overrideMaterial = overrideMaterial;
+ renderer.render( this.scene, this.camera );
+ this.scene.overrideMaterial = null;
+
+ // restore original state
+
+ renderer.autoClear = originalAutoClear;
+ renderer.setClearColor( this._originalClearColor );
+ renderer.setClearAlpha( originalClearAlpha );
+
+ }
+
+ _generateSampleKernel( kernelSize ) {
+
+ const kernel = this.kernel;
+
+ for ( let i = 0; i < kernelSize; i ++ ) {
+
+ const sample = new Vector3();
+ sample.x = ( Math.random() * 2 ) - 1;
+ sample.y = ( Math.random() * 2 ) - 1;
+ sample.z = Math.random();
+
+ sample.normalize();
+
+ let scale = i / kernelSize;
+ scale = MathUtils.lerp( 0.1, 1, scale * scale );
+ sample.multiplyScalar( scale );
+
+ kernel.push( sample );
+
+ }
+
+ }
+
+ _generateRandomKernelRotations() {
+
+ const width = 4, height = 4;
+
+ const simplex = new SimplexNoise();
+
+ const size = width * height;
+ const data = new Float32Array( size );
+
+ for ( let i = 0; i < size; i ++ ) {
+
+ const x = ( Math.random() * 2 ) - 1;
+ const y = ( Math.random() * 2 ) - 1;
+ const z = 0;
+
+ data[ i ] = simplex.noise3d( x, y, z );
+
+ }
+
+ this.noiseTexture = new DataTexture( data, width, height, RedFormat, FloatType );
+ this.noiseTexture.wrapS = RepeatWrapping;
+ this.noiseTexture.wrapT = RepeatWrapping;
+ this.noiseTexture.needsUpdate = true;
+
+ }
+
+ _overrideVisibility() {
+
+ const scene = this.scene;
+ const cache = this._visibilityCache;
+
+ scene.traverse( function ( object ) {
+
+ if ( ( object.isPoints || object.isLine || object.isLine2 ) && object.visible ) {
+
+ object.visible = false;
+ cache.push( object );
+
+ }
+
+ } );
+
+ }
+
+ _restoreVisibility() {
+
+ const cache = this._visibilityCache;
+
+ for ( let i = 0; i < cache.length; i ++ ) {
+
+ cache[ i ].visible = true;
+
+ }
+
+ cache.length = 0;
+
+ }
+
+}
+
+SSAOPass.OUTPUT = {
+ 'Default': 0,
+ 'SSAO': 1,
+ 'Blur': 2,
+ 'Depth': 3,
+ 'Normal': 4
+};
+
+export { SSAOPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/SSRPass.js b/demo/hero-content/vendor/addons/postprocessing/SSRPass.js
new file mode 100644
index 00000000..1ef29515
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/SSRPass.js
@@ -0,0 +1,858 @@
+import {
+ AddEquation,
+ Color,
+ NormalBlending,
+ DepthTexture,
+ SrcAlphaFactor,
+ OneMinusSrcAlphaFactor,
+ MeshNormalMaterial,
+ MeshBasicMaterial,
+ NearestFilter,
+ NoBlending,
+ ShaderMaterial,
+ UniformsUtils,
+ UnsignedShortType,
+ WebGLRenderTarget,
+ HalfFloatType,
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { SSRBlurShader, SSRDepthShader, SSRShader } from '../shaders/SSRShader.js';
+import { CopyShader } from '../shaders/CopyShader.js';
+
+/**
+ * A pass for a basic SSR effect.
+ *
+ * ```js
+ * const ssrPass = new SSRPass( {
+ * renderer,
+ * scene,
+ * camera,
+ * width: innerWidth,
+ * height: innerHeight
+ * } );
+ * composer.addPass( ssrPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { SSRPass } from 'three/addons/postprocessing/SSRPass.js';
+ */
+class SSRPass extends Pass {
+
+ /**
+ * Constructs a new SSR pass.
+ *
+ * @param {SSRPass~Options} options - The pass options.
+ */
+ constructor( { renderer, scene, camera, width = 512, height = 512, selects = null, bouncing = false, groundReflector = null } ) {
+
+ super();
+
+ /**
+ * The width of the effect.
+ *
+ * @type {number}
+ * @default 512
+ */
+ this.width = width;
+
+ /**
+ * The height of the effect.
+ *
+ * @type {number}
+ * @default 512
+ */
+ this.height = height;
+
+ /**
+ * Overwritten to perform a clear operation by default.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.clear = true;
+
+ /**
+ * The renderer.
+ *
+ * @type {WebGLRenderer}
+ */
+ this.renderer = renderer;
+
+ /**
+ * The scene to render.
+ *
+ * @type {Scene}
+ */
+ this.scene = scene;
+
+ /**
+ * The camera.
+ *
+ * @type {Camera}
+ */
+ this.camera = camera;
+
+ /**
+ * The ground reflector.
+ *
+ * @type {?ReflectorForSSRPass}
+ * @default 0
+ */
+ this.groundReflector = groundReflector;
+
+ /**
+ * The opacity.
+ *
+ * @type {number}
+ * @default 0.5
+ */
+ this.opacity = SSRShader.uniforms.opacity.value;
+
+ /**
+ * The output configuration.
+ *
+ * @type {number}
+ * @default 0
+ */
+ this.output = 0;
+
+ /**
+ * Controls how far a fragment can reflect.
+ *
+ * @type {number}
+ * @default 180
+ */
+ this.maxDistance = SSRShader.uniforms.maxDistance.value;
+
+ /**
+ * Controls the cutoff between what counts as a
+ * possible reflection hit and what does not.
+ *
+ * @type {number}
+ * @default .018
+ */
+ this.thickness = SSRShader.uniforms.thickness.value;
+
+ this.tempColor = new Color();
+
+ this._selects = selects;
+
+ this._resolutionScale = 1;
+
+ /**
+ * Whether the pass is selective or not.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.selective = Array.isArray( this._selects );
+
+ /**
+ * Which 3D objects should be affected by SSR. If not set, the entire scene is affected.
+ *
+ * @name SSRPass#selects
+ * @type {?Array}
+ * @default null
+ */
+ Object.defineProperty( this, 'selects', {
+ get() {
+
+ return this._selects;
+
+ },
+ set( val ) {
+
+ if ( this._selects === val ) return;
+ this._selects = val;
+ if ( Array.isArray( val ) ) {
+
+ this.selective = true;
+ this.ssrMaterial.defines.SELECTIVE = true;
+ this.ssrMaterial.needsUpdate = true;
+
+ } else {
+
+ this.selective = false;
+ this.ssrMaterial.defines.SELECTIVE = false;
+ this.ssrMaterial.needsUpdate = true;
+
+ }
+
+ }
+ } );
+
+ this._bouncing = bouncing;
+
+ /**
+ * Whether bouncing is enabled or not.
+ *
+ * @name SSRPass#bouncing
+ * @type {boolean}
+ * @default false
+ */
+ Object.defineProperty( this, 'bouncing', {
+ get() {
+
+ return this._bouncing;
+
+ },
+ set( val ) {
+
+ if ( this._bouncing === val ) return;
+ this._bouncing = val;
+ if ( val ) {
+
+ this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.prevRenderTarget.texture;
+
+ } else {
+
+ this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+
+ }
+
+ }
+ } );
+
+ /**
+ * Whether to blur reflections or not.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.blur = true;
+
+ this._distanceAttenuation = SSRShader.defines.DISTANCE_ATTENUATION;
+
+ /**
+ * Whether to use distance attenuation or not.
+ *
+ * @name SSRPass#distanceAttenuation
+ * @type {boolean}
+ * @default true
+ */
+ Object.defineProperty( this, 'distanceAttenuation', {
+ get() {
+
+ return this._distanceAttenuation;
+
+ },
+ set( val ) {
+
+ if ( this._distanceAttenuation === val ) return;
+ this._distanceAttenuation = val;
+ this.ssrMaterial.defines.DISTANCE_ATTENUATION = val;
+ this.ssrMaterial.needsUpdate = true;
+
+ }
+ } );
+
+
+ this._fresnel = SSRShader.defines.FRESNEL;
+
+ /**
+ * Whether to use fresnel or not.
+ *
+ * @name SSRPass#fresnel
+ * @type {boolean}
+ * @default true
+ */
+ Object.defineProperty( this, 'fresnel', {
+ get() {
+
+ return this._fresnel;
+
+ },
+ set( val ) {
+
+ if ( this._fresnel === val ) return;
+ this._fresnel = val;
+ this.ssrMaterial.defines.FRESNEL = val;
+ this.ssrMaterial.needsUpdate = true;
+
+ }
+ } );
+
+ this._infiniteThick = SSRShader.defines.INFINITE_THICK;
+
+ /**
+ * Whether to use infinite thickness or not.
+ *
+ * @name SSRPass#infiniteThick
+ * @type {boolean}
+ * @default false
+ */
+ Object.defineProperty( this, 'infiniteThick', {
+ get() {
+
+ return this._infiniteThick;
+
+ },
+ set( val ) {
+
+ if ( this._infiniteThick === val ) return;
+ this._infiniteThick = val;
+ this.ssrMaterial.defines.INFINITE_THICK = val;
+ this.ssrMaterial.needsUpdate = true;
+
+ }
+ } );
+
+ // beauty render target with depth buffer
+
+ const depthTexture = new DepthTexture();
+ depthTexture.type = UnsignedShortType;
+ depthTexture.minFilter = NearestFilter;
+ depthTexture.magFilter = NearestFilter;
+
+ this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+ minFilter: NearestFilter,
+ magFilter: NearestFilter,
+ type: HalfFloatType,
+ depthTexture: depthTexture,
+ depthBuffer: true
+ } );
+
+ //for bouncing
+ this.prevRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+ minFilter: NearestFilter,
+ magFilter: NearestFilter,
+ depthBuffer: false
+ } );
+
+ // normal render target
+
+ this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+ minFilter: NearestFilter,
+ magFilter: NearestFilter,
+ type: HalfFloatType,
+ } );
+
+ // metalness render target
+
+ this.metalnessRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+ minFilter: NearestFilter,
+ magFilter: NearestFilter,
+ type: HalfFloatType,
+ } );
+
+
+
+ // ssr render target
+
+ this.ssrRenderTarget = new WebGLRenderTarget( this.width, this.height, {
+ minFilter: NearestFilter,
+ magFilter: NearestFilter,
+ depthBuffer: false
+ } );
+
+ this.blurRenderTarget = this.ssrRenderTarget.clone();
+ this.blurRenderTarget2 = this.ssrRenderTarget.clone();
+ // this.blurRenderTarget3 = this.ssrRenderTarget.clone();
+
+ // ssr material
+
+ this.ssrMaterial = new ShaderMaterial( {
+ defines: Object.assign( {}, SSRShader.defines, {
+ MAX_STEP: Math.sqrt( this.width * this.width + this.height * this.height )
+ } ),
+ uniforms: UniformsUtils.clone( SSRShader.uniforms ),
+ vertexShader: SSRShader.vertexShader,
+ fragmentShader: SSRShader.fragmentShader,
+ blending: NoBlending
+ } );
+
+ this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+ this.ssrMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
+ this.ssrMaterial.defines.SELECTIVE = this.selective;
+ this.ssrMaterial.needsUpdate = true;
+ this.ssrMaterial.uniforms[ 'tMetalness' ].value = this.metalnessRenderTarget.texture;
+ this.ssrMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
+ this.ssrMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+ this.ssrMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+ this.ssrMaterial.uniforms[ 'thickness' ].value = this.thickness;
+ this.ssrMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+ this.ssrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
+ this.ssrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
+
+ // normal material
+
+ this.normalMaterial = new MeshNormalMaterial();
+ this.normalMaterial.blending = NoBlending;
+
+ // metalnessOn material
+
+ this.metalnessOnMaterial = new MeshBasicMaterial( {
+ color: 'white'
+ } );
+
+ // metalnessOff material
+
+ this.metalnessOffMaterial = new MeshBasicMaterial( {
+ color: 'black'
+ } );
+
+ // blur material
+
+ this.blurMaterial = new ShaderMaterial( {
+ defines: Object.assign( {}, SSRBlurShader.defines ),
+ uniforms: UniformsUtils.clone( SSRBlurShader.uniforms ),
+ vertexShader: SSRBlurShader.vertexShader,
+ fragmentShader: SSRBlurShader.fragmentShader
+ } );
+ this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
+ this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
+
+ // blur material 2
+
+ this.blurMaterial2 = new ShaderMaterial( {
+ defines: Object.assign( {}, SSRBlurShader.defines ),
+ uniforms: UniformsUtils.clone( SSRBlurShader.uniforms ),
+ vertexShader: SSRBlurShader.vertexShader,
+ fragmentShader: SSRBlurShader.fragmentShader
+ } );
+ this.blurMaterial2.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget.texture;
+ this.blurMaterial2.uniforms[ 'resolution' ].value.set( this.width, this.height );
+
+ // // blur material 3
+
+ // this.blurMaterial3 = new ShaderMaterial({
+ // defines: Object.assign({}, SSRBlurShader.defines),
+ // uniforms: UniformsUtils.clone(SSRBlurShader.uniforms),
+ // vertexShader: SSRBlurShader.vertexShader,
+ // fragmentShader: SSRBlurShader.fragmentShader
+ // });
+ // this.blurMaterial3.uniforms['tDiffuse'].value = this.blurRenderTarget2.texture;
+ // this.blurMaterial3.uniforms['resolution'].value.set(this.width, this.height);
+
+ // material for rendering the depth
+
+ this.depthRenderMaterial = new ShaderMaterial( {
+ defines: Object.assign( {}, SSRDepthShader.defines ),
+ uniforms: UniformsUtils.clone( SSRDepthShader.uniforms ),
+ vertexShader: SSRDepthShader.vertexShader,
+ fragmentShader: SSRDepthShader.fragmentShader,
+ blending: NoBlending
+ } );
+ this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
+ this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
+ this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
+
+ // material for rendering the content of a render target
+
+ this.copyMaterial = new ShaderMaterial( {
+ uniforms: UniformsUtils.clone( CopyShader.uniforms ),
+ vertexShader: CopyShader.vertexShader,
+ fragmentShader: CopyShader.fragmentShader,
+ transparent: true,
+ depthTest: false,
+ depthWrite: false,
+ blendSrc: SrcAlphaFactor,
+ blendDst: OneMinusSrcAlphaFactor,
+ blendEquation: AddEquation,
+ blendSrcAlpha: SrcAlphaFactor,
+ blendDstAlpha: OneMinusSrcAlphaFactor,
+ blendEquationAlpha: AddEquation,
+ // premultipliedAlpha:true,
+ } );
+
+ this.fsQuad = new FullScreenQuad( null );
+
+ this.originalClearColor = new Color();
+
+ }
+
+
+ /**
+ * The resolution scale. Valid values are in the range
+ * `[0,1]`. `1` means best quality but also results in
+ * more computational overhead. Setting to `0.5` means
+ * the effect is computed in half-resolution.
+ *
+ * @type {number}
+ * @default 1
+ */
+ get resolutionScale() {
+
+ return this._resolutionScale;
+
+ }
+
+ set resolutionScale( value ) {
+
+ this._resolutionScale = value;
+ this.setSize( this.width, this.height ); // force a resize when resolution scaling changes
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ // dispose render targets
+
+ this.beautyRenderTarget.dispose();
+ this.prevRenderTarget.dispose();
+ this.normalRenderTarget.dispose();
+ this.metalnessRenderTarget.dispose();
+ this.ssrRenderTarget.dispose();
+ this.blurRenderTarget.dispose();
+ this.blurRenderTarget2.dispose();
+ // this.blurRenderTarget3.dispose();
+
+ // dispose materials
+
+ this.normalMaterial.dispose();
+ this.metalnessOnMaterial.dispose();
+ this.metalnessOffMaterial.dispose();
+ this.blurMaterial.dispose();
+ this.blurMaterial2.dispose();
+ this.copyMaterial.dispose();
+ this.depthRenderMaterial.dispose();
+
+ // dispose full screen quad
+
+ this.fsQuad.dispose();
+
+ }
+
+ /**
+ * Performs the SSR pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer /*, readBuffer, deltaTime, maskActive */ ) {
+
+ // render beauty and depth
+
+ renderer.setRenderTarget( this.beautyRenderTarget );
+ renderer.clear();
+ if ( this.groundReflector ) {
+
+ this.groundReflector.visible = false;
+ this.groundReflector.doRender( this.renderer, this.scene, this.camera );
+ this.groundReflector.visible = true;
+
+ }
+
+ renderer.render( this.scene, this.camera );
+ if ( this.groundReflector ) this.groundReflector.visible = false;
+
+ // render normals
+
+ this._renderOverride( renderer, this.normalMaterial, this.normalRenderTarget, 0, 0 );
+
+ // render metalnesses
+
+ if ( this.selective ) {
+
+ this._renderMetalness( renderer, this.metalnessOnMaterial, this.metalnessRenderTarget, 0, 0 );
+
+ }
+
+ // render SSR
+
+ this.ssrMaterial.uniforms[ 'opacity' ].value = this.opacity;
+ this.ssrMaterial.uniforms[ 'maxDistance' ].value = this.maxDistance;
+ this.ssrMaterial.uniforms[ 'thickness' ].value = this.thickness;
+ this._renderPass( renderer, this.ssrMaterial, this.ssrRenderTarget );
+
+
+ // render blur
+
+ if ( this.blur ) {
+
+ this._renderPass( renderer, this.blurMaterial, this.blurRenderTarget );
+ this._renderPass( renderer, this.blurMaterial2, this.blurRenderTarget2 );
+ // this._renderPass(renderer, this.blurMaterial3, this.blurRenderTarget3);
+
+ }
+
+ // output result to screen
+
+ switch ( this.output ) {
+
+ case SSRPass.OUTPUT.Default:
+
+ if ( this.bouncing ) {
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.prevRenderTarget );
+
+ if ( this.blur )
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget2.texture;
+ else
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
+ this.copyMaterial.blending = NormalBlending;
+ this._renderPass( renderer, this.copyMaterial, this.prevRenderTarget );
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.prevRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ } else {
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ if ( this.blur )
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget2.texture;
+ else
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
+ this.copyMaterial.blending = NormalBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ }
+
+ break;
+ case SSRPass.OUTPUT.SSR:
+
+ if ( this.blur )
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget2.texture;
+ else
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ if ( this.bouncing ) {
+
+ if ( this.blur )
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget2.texture;
+ else
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.prevRenderTarget );
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
+ this.copyMaterial.blending = NormalBlending;
+ this._renderPass( renderer, this.copyMaterial, this.prevRenderTarget );
+
+ }
+
+ break;
+
+ case SSRPass.OUTPUT.Beauty:
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ break;
+
+ case SSRPass.OUTPUT.Depth:
+
+ this._renderPass( renderer, this.depthRenderMaterial, this.renderToScreen ? null : writeBuffer );
+
+ break;
+
+ case SSRPass.OUTPUT.Normal:
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.normalRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ break;
+
+ case SSRPass.OUTPUT.Metalness:
+
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.metalnessRenderTarget.texture;
+ this.copyMaterial.blending = NoBlending;
+ this._renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
+
+ break;
+
+ default:
+ console.warn( 'THREE.SSRPass: Unknown output type.' );
+
+ }
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this.width = width;
+ this.height = height;
+
+ const effectiveWidth = Math.round( this.resolutionScale * width );
+ const effectiveHeight = Math.round( this.resolutionScale * height );
+
+ this.ssrMaterial.defines.MAX_STEP = Math.sqrt( effectiveWidth * effectiveWidth + effectiveHeight * effectiveHeight );
+ this.ssrMaterial.needsUpdate = true;
+
+ this.beautyRenderTarget.setSize( width, height );
+ this.normalRenderTarget.setSize( width, height );
+ this.metalnessRenderTarget.setSize( width, height );
+ this.ssrRenderTarget.setSize( effectiveWidth, effectiveHeight );
+ this.prevRenderTarget.setSize( effectiveWidth, effectiveHeight );
+ this.blurRenderTarget.setSize( effectiveWidth, effectiveHeight );
+ this.blurRenderTarget2.setSize( effectiveWidth, effectiveHeight );
+ // this.blurRenderTarget3.setSize(width, height);
+
+ this.ssrMaterial.uniforms[ 'resolution' ].value.set( effectiveWidth, effectiveHeight );
+ this.ssrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
+ this.ssrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
+
+ this.blurMaterial.uniforms[ 'resolution' ].value.set( effectiveWidth, effectiveHeight );
+ this.blurMaterial2.uniforms[ 'resolution' ].value.set( effectiveWidth, effectiveHeight );
+
+ }
+
+ // internals
+
+ _renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
+
+ // save original state
+ this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
+ const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+ const originalAutoClear = renderer.autoClear;
+
+ renderer.setRenderTarget( renderTarget );
+
+ // setup pass state
+ renderer.autoClear = false;
+ if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
+
+ renderer.setClearColor( clearColor );
+ renderer.setClearAlpha( clearAlpha || 0.0 );
+ renderer.clear();
+
+ }
+
+ this.fsQuad.material = passMaterial;
+ this.fsQuad.render( renderer );
+
+ // restore original state
+ renderer.autoClear = originalAutoClear;
+ renderer.setClearColor( this.originalClearColor );
+ renderer.setClearAlpha( originalClearAlpha );
+
+ }
+
+ _renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+
+ this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
+ const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+ const originalAutoClear = renderer.autoClear;
+
+ renderer.setRenderTarget( renderTarget );
+ renderer.autoClear = false;
+
+ clearColor = overrideMaterial.clearColor || clearColor;
+ clearAlpha = overrideMaterial.clearAlpha || clearAlpha;
+
+ if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
+
+ renderer.setClearColor( clearColor );
+ renderer.setClearAlpha( clearAlpha || 0.0 );
+ renderer.clear();
+
+ }
+
+ this.scene.overrideMaterial = overrideMaterial;
+ renderer.render( this.scene, this.camera );
+ this.scene.overrideMaterial = null;
+
+ // restore original state
+
+ renderer.autoClear = originalAutoClear;
+ renderer.setClearColor( this.originalClearColor );
+ renderer.setClearAlpha( originalClearAlpha );
+
+ }
+
+ _renderMetalness( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
+
+ this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
+ const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
+ const originalAutoClear = renderer.autoClear;
+ const originalBackground = this.scene.background;
+ const originalFog = this.scene.fog;
+
+ renderer.setRenderTarget( renderTarget );
+ renderer.autoClear = false;
+ this.scene.background = null;
+ this.scene.fog = null;
+
+ clearColor = overrideMaterial.clearColor || clearColor;
+ clearAlpha = overrideMaterial.clearAlpha || clearAlpha;
+
+ if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
+
+ renderer.setClearColor( clearColor );
+ renderer.setClearAlpha( clearAlpha || 0.0 );
+ renderer.clear();
+
+ }
+
+ this.scene.traverseVisible( child => {
+
+ child._SSRPassBackupMaterial = child.material;
+ if ( this._selects.includes( child ) ) {
+
+ child.material = this.metalnessOnMaterial;
+
+ } else {
+
+ child.material = this.metalnessOffMaterial;
+
+ }
+
+ } );
+ renderer.render( this.scene, this.camera );
+ this.scene.traverseVisible( child => {
+
+ child.material = child._SSRPassBackupMaterial;
+
+ } );
+
+ // restore original state
+
+ renderer.autoClear = originalAutoClear;
+ renderer.setClearColor( this.originalClearColor );
+ renderer.setClearAlpha( originalClearAlpha );
+ this.scene.background = originalBackground;
+ this.scene.fog = originalFog;
+
+ }
+
+}
+
+/**
+ * Constructor options of `SSRPass`.
+ *
+ * @typedef {Object} SSRPass~Options
+ * @property {WebGLRenderer} renderer - The renderer.
+ * @property {Scene} scene - The scene to render.
+ * @property {Camera} camera - The camera.
+ * @property {number} [width=512] - The width of the effect.
+ * @property {number} [height=512] - The width of the effect.
+ * @property {?Array} [selects=null] - Which 3D objects should be affected by SSR. If not set, the entire scene is affected.
+ * @property {boolean} [bouncing=false] - Whether bouncing is enabled or not.
+ * @property {?ReflectorForSSRPass} [groundReflector=null] - A ground reflector.
+ **/
+
+SSRPass.OUTPUT = {
+ 'Default': 0,
+ 'SSR': 1,
+ 'Beauty': 3,
+ 'Depth': 4,
+ 'Normal': 5,
+ 'Metalness': 7,
+};
+
+export { SSRPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/SavePass.js b/demo/hero-content/vendor/addons/postprocessing/SavePass.js
new file mode 100644
index 00000000..d270235b
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/SavePass.js
@@ -0,0 +1,132 @@
+import {
+ HalfFloatType,
+ NoBlending,
+ ShaderMaterial,
+ UniformsUtils,
+ WebGLRenderTarget
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { CopyShader } from '../shaders/CopyShader.js';
+
+/**
+ * A pass that saves the contents of the current read buffer in a render target.
+ *
+ * ```js
+ * const savePass = new SavePass( customRenderTarget );
+ * composer.addPass( savePass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { SavePass } from 'three/addons/postprocessing/SavePass.js';
+ */
+class SavePass extends Pass {
+
+ /**
+ * Constructs a new save pass.
+ *
+ * @param {WebGLRenderTarget} [renderTarget] - The render target for saving the read buffer.
+ * If not provided, the pass automatically creates a render target.
+ */
+ constructor( renderTarget ) {
+
+ super();
+
+ /**
+ * The pass uniforms.
+ *
+ * @type {Object}
+ */
+ this.uniforms = UniformsUtils.clone( CopyShader.uniforms );
+
+ /**
+ * The pass material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.material = new ShaderMaterial( {
+
+ uniforms: this.uniforms,
+ vertexShader: CopyShader.vertexShader,
+ fragmentShader: CopyShader.fragmentShader,
+ blending: NoBlending
+
+ } );
+
+ /**
+ * The render target which is used to save the read buffer.
+ *
+ * @type {WebGLRenderTarget}
+ */
+ this.renderTarget = renderTarget;
+
+ if ( this.renderTarget === undefined ) {
+
+ this.renderTarget = new WebGLRenderTarget( 1, 1, { type: HalfFloatType, depthBuffer: false } ); // will be resized later
+ this.renderTarget.texture.name = 'SavePass.rt';
+
+ }
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ // internals
+
+ this._fsQuad = new FullScreenQuad( this.material );
+
+ }
+
+ /**
+ * Performs the save pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive */ ) {
+
+ this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
+
+ renderer.setRenderTarget( this.renderTarget );
+ if ( this.clear ) renderer.clear();
+ this._fsQuad.render( renderer );
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ this.renderTarget.setSize( width, height );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.renderTarget.dispose();
+
+ this.material.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+}
+
+export { SavePass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/ShaderPass.js b/demo/hero-content/vendor/addons/postprocessing/ShaderPass.js
new file mode 100644
index 00000000..ce72fcf1
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/ShaderPass.js
@@ -0,0 +1,135 @@
+import {
+ ShaderMaterial,
+ UniformsUtils
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+
+/**
+ * This pass can be used to create a post processing effect
+ * with a raw GLSL shader object. Useful for implementing custom
+ * effects.
+ *
+ * ```js
+ * const fxaaPass = new ShaderPass( FXAAShader );
+ * composer.addPass( fxaaPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
+ */
+class ShaderPass extends Pass {
+
+ /**
+ * Constructs a new shader pass.
+ *
+ * @param {Object|ShaderMaterial} [shader] - A shader object holding vertex and fragment shader as well as
+ * defines and uniforms. It's also valid to pass a custom shader material.
+ * @param {string} [textureID='tDiffuse'] - The name of the texture uniform that should sample
+ * the read buffer.
+ */
+ constructor( shader, textureID = 'tDiffuse' ) {
+
+ super();
+
+ /**
+ * The name of the texture uniform that should sample the read buffer.
+ *
+ * @type {string}
+ * @default 'tDiffuse'
+ */
+ this.textureID = textureID;
+
+ /**
+ * The pass uniforms.
+ *
+ * @type {?Object}
+ */
+ this.uniforms = null;
+
+ /**
+ * The pass material.
+ *
+ * @type {?ShaderMaterial}
+ */
+ this.material = null;
+
+ if ( shader instanceof ShaderMaterial ) {
+
+ this.uniforms = shader.uniforms;
+
+ this.material = shader;
+
+ } else if ( shader ) {
+
+ this.uniforms = UniformsUtils.clone( shader.uniforms );
+
+ this.material = new ShaderMaterial( {
+
+ name: ( shader.name !== undefined ) ? shader.name : 'unspecified',
+ defines: Object.assign( {}, shader.defines ),
+ uniforms: this.uniforms,
+ vertexShader: shader.vertexShader,
+ fragmentShader: shader.fragmentShader
+
+ } );
+
+ }
+
+ // internals
+
+ this._fsQuad = new FullScreenQuad( this.material );
+
+ }
+
+ /**
+ * Performs the shader pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+
+ if ( this.uniforms[ this.textureID ] ) {
+
+ this.uniforms[ this.textureID ].value = readBuffer.texture;
+
+ }
+
+ this._fsQuad.material = this.material;
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+ this._fsQuad.render( renderer );
+
+ } else {
+
+ renderer.setRenderTarget( writeBuffer );
+ // TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
+ if ( this.clear ) renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
+ this._fsQuad.render( renderer );
+
+ }
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.material.dispose();
+
+ this._fsQuad.dispose();
+
+ }
+
+}
+
+export { ShaderPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/TAARenderPass.js b/demo/hero-content/vendor/addons/postprocessing/TAARenderPass.js
new file mode 100644
index 00000000..a8973256
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/TAARenderPass.js
@@ -0,0 +1,243 @@
+import {
+ HalfFloatType,
+ WebGLRenderTarget
+} from 'three';
+import { SSAARenderPass } from './SSAARenderPass.js';
+
+/**
+ *
+ * Temporal Anti-Aliasing Render Pass.
+ *
+ * When there is no motion in the scene, the TAA render pass accumulates jittered camera
+ * samples across frames to create a high quality anti-aliased result.
+ *
+ * Note: This effect uses no reprojection so it is no TRAA implementation.
+ *
+ * ```js
+ * const taaRenderPass = new TAARenderPass( scene, camera );
+ * taaRenderPass.unbiased = false;
+ * composer.addPass( taaRenderPass );
+ * ```
+ *
+ * @augments SSAARenderPass
+ * @three_import import { TAARenderPass } from 'three/addons/postprocessing/TAARenderPass.js';
+ */
+class TAARenderPass extends SSAARenderPass {
+
+ /**
+ * Constructs a new TAA render pass.
+ *
+ * @param {Scene} scene - The scene to render.
+ * @param {Camera} camera - The camera.
+ * @param {?(number|Color|string)} [clearColor=0x000000] - The clear color of the render pass.
+ * @param {?number} [clearAlpha=0] - The clear alpha of the render pass.
+ */
+ constructor( scene, camera, clearColor, clearAlpha ) {
+
+ super( scene, camera, clearColor, clearAlpha );
+
+ /**
+ * Overwritten and set to 0 by default.
+ *
+ * @type {number}
+ * @default 0
+ */
+ this.sampleLevel = 0;
+
+ /**
+ * Whether to accumulate frames or not. This enables
+ * the TAA.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.accumulate = false;
+
+ /**
+ * The accumulation index.
+ *
+ * @type {number}
+ * @default -1
+ */
+ this.accumulateIndex = - 1;
+
+ // internals
+
+ this._sampleRenderTarget = null;
+ this._holdRenderTarget = null;
+
+ }
+
+ /**
+ * Performs the TAA render pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer, deltaTime/*, maskActive*/ ) {
+
+ if ( this.accumulate === false ) {
+
+ super.render( renderer, writeBuffer, readBuffer, deltaTime );
+
+ this.accumulateIndex = - 1;
+ return;
+
+ }
+
+ const jitterOffsets = _JitterVectors[ 5 ];
+
+ if ( this._sampleRenderTarget === null ) {
+
+ this._sampleRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType } );
+ this._sampleRenderTarget.texture.name = 'TAARenderPass.sample';
+
+ }
+
+ if ( this._holdRenderTarget === null ) {
+
+ this._holdRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType, depthBuffer: false } );
+ this._holdRenderTarget.texture.name = 'TAARenderPass.hold';
+
+ }
+
+ if ( this.accumulateIndex === - 1 ) {
+
+ super.render( renderer, this._holdRenderTarget, readBuffer, deltaTime );
+
+ this.accumulateIndex = 0;
+
+ }
+
+ const autoClear = renderer.autoClear;
+ renderer.autoClear = false;
+
+ renderer.getClearColor( this._oldClearColor );
+ const oldClearAlpha = renderer.getClearAlpha();
+
+ const sampleWeight = 1.0 / ( jitterOffsets.length );
+
+ if ( this.accumulateIndex >= 0 && this.accumulateIndex < jitterOffsets.length ) {
+
+ this._copyUniforms[ 'opacity' ].value = sampleWeight;
+ this._copyUniforms[ 'tDiffuse' ].value = writeBuffer.texture;
+
+ // render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
+ const numSamplesPerFrame = Math.pow( 2, this.sampleLevel );
+ for ( let i = 0; i < numSamplesPerFrame; i ++ ) {
+
+ const j = this.accumulateIndex;
+ const jitterOffset = jitterOffsets[ j ];
+
+ if ( this.camera.setViewOffset ) {
+
+ this.camera.setViewOffset( readBuffer.width, readBuffer.height,
+ jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16
+ readBuffer.width, readBuffer.height );
+
+ }
+
+ renderer.setRenderTarget( writeBuffer );
+ renderer.setClearColor( this.clearColor, this.clearAlpha );
+ renderer.clear();
+ renderer.render( this.scene, this.camera );
+
+ renderer.setRenderTarget( this._sampleRenderTarget );
+ if ( this.accumulateIndex === 0 ) {
+
+ renderer.setClearColor( 0x000000, 0.0 );
+ renderer.clear();
+
+ }
+
+ this._fsQuad.render( renderer );
+
+ this.accumulateIndex ++;
+
+ if ( this.accumulateIndex >= jitterOffsets.length ) break;
+
+ }
+
+ if ( this.camera.clearViewOffset ) this.camera.clearViewOffset();
+
+ }
+
+ renderer.setClearColor( this.clearColor, this.clearAlpha );
+ const accumulationWeight = this.accumulateIndex * sampleWeight;
+
+ if ( accumulationWeight > 0 ) {
+
+ this._copyUniforms[ 'opacity' ].value = 1.0;
+ this._copyUniforms[ 'tDiffuse' ].value = this._sampleRenderTarget.texture;
+ renderer.setRenderTarget( writeBuffer );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ }
+
+ if ( accumulationWeight < 1.0 ) {
+
+ this._copyUniforms[ 'opacity' ].value = 1.0 - accumulationWeight;
+ this._copyUniforms[ 'tDiffuse' ].value = this._holdRenderTarget.texture;
+ renderer.setRenderTarget( writeBuffer );
+ this._fsQuad.render( renderer );
+
+ }
+
+ renderer.autoClear = autoClear;
+ renderer.setClearColor( this._oldClearColor, oldClearAlpha );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ super.dispose();
+
+ if ( this._holdRenderTarget ) this._holdRenderTarget.dispose();
+
+ }
+
+}
+
+const _JitterVectors = [
+ [
+ [ 0, 0 ]
+ ],
+ [
+ [ 4, 4 ], [ - 4, - 4 ]
+ ],
+ [
+ [ - 2, - 6 ], [ 6, - 2 ], [ - 6, 2 ], [ 2, 6 ]
+ ],
+ [
+ [ 1, - 3 ], [ - 1, 3 ], [ 5, 1 ], [ - 3, - 5 ],
+ [ - 5, 5 ], [ - 7, - 1 ], [ 3, 7 ], [ 7, - 7 ]
+ ],
+ [
+ [ 1, 1 ], [ - 1, - 3 ], [ - 3, 2 ], [ 4, - 1 ],
+ [ - 5, - 2 ], [ 2, 5 ], [ 5, 3 ], [ 3, - 5 ],
+ [ - 2, 6 ], [ 0, - 7 ], [ - 4, - 6 ], [ - 6, 4 ],
+ [ - 8, 0 ], [ 7, - 4 ], [ 6, 7 ], [ - 7, - 8 ]
+ ],
+ [
+ [ - 4, - 7 ], [ - 7, - 5 ], [ - 3, - 5 ], [ - 5, - 4 ],
+ [ - 1, - 4 ], [ - 2, - 2 ], [ - 6, - 1 ], [ - 4, 0 ],
+ [ - 7, 1 ], [ - 1, 2 ], [ - 6, 3 ], [ - 3, 3 ],
+ [ - 7, 6 ], [ - 3, 6 ], [ - 5, 7 ], [ - 1, 7 ],
+ [ 5, - 7 ], [ 1, - 6 ], [ 6, - 5 ], [ 4, - 4 ],
+ [ 2, - 3 ], [ 7, - 2 ], [ 1, - 1 ], [ 4, - 1 ],
+ [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],
+ [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]
+ ]
+];
+
+export { TAARenderPass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/TexturePass.js b/demo/hero-content/vendor/addons/postprocessing/TexturePass.js
new file mode 100644
index 00000000..649a2354
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/TexturePass.js
@@ -0,0 +1,131 @@
+import {
+ ShaderMaterial,
+ UniformsUtils
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { CopyShader } from '../shaders/CopyShader.js';
+
+/**
+ * This pass can be used to render a texture over the entire screen.
+ *
+ * ```js
+ * const texture = new THREE.TextureLoader().load( 'textures/2294472375_24a3b8ef46_o.jpg' );
+ * texture.colorSpace = THREE.SRGBColorSpace;
+ *
+ * const texturePass = new TexturePass( texture );
+ * composer.addPass( texturePass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { TexturePass } from 'three/addons/postprocessing/TexturePass.js';
+ */
+class TexturePass extends Pass {
+
+ /**
+ * Constructs a new texture pass.
+ *
+ * @param {Texture} map - The texture to render.
+ * @param {number} [opacity=1] - The opacity.
+ */
+ constructor( map, opacity = 1 ) {
+
+ super();
+
+ const shader = CopyShader;
+
+ /**
+ * The texture to render.
+ *
+ * @type {Texture}
+ */
+ this.map = map;
+
+ /**
+ * The opacity.
+ *
+ * @type {number}
+ * @default 1
+ */
+ this.opacity = opacity;
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ /**
+ * The pass uniforms.
+ *
+ * @type {Object}
+ */
+ this.uniforms = UniformsUtils.clone( shader.uniforms );
+
+ /**
+ * The pass material.
+ *
+ * @type {ShaderMaterial}
+ */
+ this.material = new ShaderMaterial( {
+
+ uniforms: this.uniforms,
+ vertexShader: shader.vertexShader,
+ fragmentShader: shader.fragmentShader,
+ depthTest: false,
+ depthWrite: false,
+ premultipliedAlpha: true
+
+ } );
+
+ // internals
+
+ this._fsQuad = new FullScreenQuad( null );
+
+ }
+
+ /**
+ * Performs the texture pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
+
+ const oldAutoClear = renderer.autoClear;
+ renderer.autoClear = false;
+
+ this._fsQuad.material = this.material;
+
+ this.uniforms[ 'opacity' ].value = this.opacity;
+ this.uniforms[ 'tDiffuse' ].value = this.map;
+ this.material.transparent = ( this.opacity < 1.0 );
+
+ renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
+ if ( this.clear ) renderer.clear();
+ this._fsQuad.render( renderer );
+
+ renderer.autoClear = oldAutoClear;
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ this.material.dispose();
+ this._fsQuad.dispose();
+
+ }
+
+}
+
+export { TexturePass };
diff --git a/demo/hero-content/vendor/addons/postprocessing/UnrealBloomPass.js b/demo/hero-content/vendor/addons/postprocessing/UnrealBloomPass.js
new file mode 100644
index 00000000..05b3f63c
--- /dev/null
+++ b/demo/hero-content/vendor/addons/postprocessing/UnrealBloomPass.js
@@ -0,0 +1,541 @@
+import {
+ AdditiveBlending,
+ Color,
+ HalfFloatType,
+ MeshBasicMaterial,
+ ShaderMaterial,
+ UniformsUtils,
+ Vector2,
+ Vector3,
+ WebGLRenderTarget
+} from 'three';
+import { Pass, FullScreenQuad } from './Pass.js';
+import { CopyShader } from '../shaders/CopyShader.js';
+import { LuminosityHighPassShader } from '../shaders/LuminosityHighPassShader.js';
+
+/**
+ * This pass is inspired by the bloom pass of Unreal Engine. It creates a
+ * mip map chain of bloom textures and blurs them with different radii. Because
+ * of the weighted combination of mips, and because larger blurs are done on
+ * higher mips, this effect provides good quality and performance.
+ *
+ * When using this pass, tone mapping must be enabled in the renderer settings.
+ *
+ * Reference:
+ * - [Bloom in Unreal Engine](https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/Bloom/)
+ *
+ * ```js
+ * const resolution = new THREE.Vector2( window.innerWidth, window.innerHeight );
+ * const bloomPass = new UnrealBloomPass( resolution, 1.5, 0.4, 0.85 );
+ * composer.addPass( bloomPass );
+ * ```
+ *
+ * @augments Pass
+ * @three_import import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
+ */
+class UnrealBloomPass extends Pass {
+
+ /**
+ * Constructs a new Unreal Bloom pass.
+ *
+ * @param {Vector2} [resolution] - The effect's resolution.
+ * @param {number} [strength=1] - The Bloom strength.
+ * @param {number} radius - The Bloom radius.
+ * @param {number} threshold - The luminance threshold limits which bright areas contribute to the Bloom effect.
+ */
+ constructor( resolution, strength = 1, radius, threshold ) {
+
+ super();
+
+ /**
+ * The Bloom strength.
+ *
+ * @type {number}
+ * @default 1
+ */
+ this.strength = strength;
+
+ /**
+ * The Bloom radius. Must be in the range `[0,1]`.
+ *
+ * @type {number}
+ */
+ this.radius = radius;
+
+ /**
+ * The luminance threshold limits which bright areas contribute to the Bloom effect.
+ *
+ * @type {number}
+ */
+ this.threshold = threshold;
+
+ /**
+ * The effect's resolution.
+ *
+ * @type {Vector2}
+ * @default (256,256)
+ */
+ this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 );
+
+ /**
+ * The effect's clear color
+ *
+ * @type {Color}
+ * @default (0,0,0)
+ */
+ this.clearColor = new Color( 0, 0, 0 );
+
+ /**
+ * Overwritten to disable the swap.
+ *
+ * @type {boolean}
+ * @default false
+ */
+ this.needsSwap = false;
+
+ // internals
+
+ // render targets
+ this.renderTargetsHorizontal = [];
+ this.renderTargetsVertical = [];
+ this.nMips = 5;
+ let resx = Math.round( this.resolution.x / 2 );
+ let resy = Math.round( this.resolution.y / 2 );
+
+ this.renderTargetBright = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
+ this.renderTargetBright.texture.name = 'UnrealBloomPass.bright';
+ this.renderTargetBright.texture.generateMipmaps = false;
+
+ for ( let i = 0; i < this.nMips; i ++ ) {
+
+ const renderTargetHorizontal = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
+
+ renderTargetHorizontal.texture.name = 'UnrealBloomPass.h' + i;
+ renderTargetHorizontal.texture.generateMipmaps = false;
+
+ this.renderTargetsHorizontal.push( renderTargetHorizontal );
+
+ const renderTargetVertical = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
+
+ renderTargetVertical.texture.name = 'UnrealBloomPass.v' + i;
+ renderTargetVertical.texture.generateMipmaps = false;
+
+ this.renderTargetsVertical.push( renderTargetVertical );
+
+ resx = Math.round( resx / 2 );
+
+ resy = Math.round( resy / 2 );
+
+ }
+
+ // luminosity high pass material
+
+ const highPassShader = LuminosityHighPassShader;
+ this.highPassUniforms = UniformsUtils.clone( highPassShader.uniforms );
+
+ this.highPassUniforms[ 'luminosityThreshold' ].value = threshold;
+ this.highPassUniforms[ 'smoothWidth' ].value = 0.01;
+
+ this.materialHighPassFilter = new ShaderMaterial( {
+ uniforms: this.highPassUniforms,
+ vertexShader: highPassShader.vertexShader,
+ fragmentShader: highPassShader.fragmentShader
+ } );
+
+ // gaussian blur materials
+
+ this.separableBlurMaterials = [];
+ // These sizes have been changed to account for the altered coefficients-calculation to avoid blockiness,
+ // while retaining the same blur-strength. For details see https://github.com/mrdoob/three.js/pull/31528
+ const kernelSizeArray = [ 6, 10, 14, 18, 22 ];
+ resx = Math.round( this.resolution.x / 2 );
+ resy = Math.round( this.resolution.y / 2 );
+
+ for ( let i = 0; i < this.nMips; i ++ ) {
+
+ this.separableBlurMaterials.push( this._getSeparableBlurMaterial( kernelSizeArray[ i ] ) );
+
+ this.separableBlurMaterials[ i ].uniforms[ 'invSize' ].value = new Vector2( 1 / resx, 1 / resy );
+
+ resx = Math.round( resx / 2 );
+
+ resy = Math.round( resy / 2 );
+
+ }
+
+ // composite material
+
+ 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 = strength;
+ this.compositeMaterial.uniforms[ 'bloomRadius' ].value = 0.1;
+
+ const bloomFactors = [ 1.0, 0.8, 0.6, 0.4, 0.2 ];
+ this.compositeMaterial.uniforms[ 'bloomFactors' ].value = bloomFactors;
+ this.bloomTintColors = [ new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ) ];
+ this.compositeMaterial.uniforms[ 'bloomTintColors' ].value = this.bloomTintColors;
+
+ // blend material
+
+ this.copyUniforms = UniformsUtils.clone( CopyShader.uniforms );
+
+ this.blendMaterial = new ShaderMaterial( {
+ uniforms: this.copyUniforms,
+ vertexShader: CopyShader.vertexShader,
+ fragmentShader: CopyShader.fragmentShader,
+ premultipliedAlpha: true,
+ blending: AdditiveBlending,
+ depthTest: false,
+ depthWrite: false,
+ transparent: true
+ } );
+
+ this._oldClearColor = new Color();
+ this._oldClearAlpha = 1;
+
+ this._basic = new MeshBasicMaterial();
+
+ this._fsQuad = new FullScreenQuad( null );
+
+ }
+
+ /**
+ * Frees the GPU-related resources allocated by this instance. Call this
+ * method whenever the pass is no longer used in your app.
+ */
+ dispose() {
+
+ for ( let i = 0; i < this.renderTargetsHorizontal.length; i ++ ) {
+
+ this.renderTargetsHorizontal[ i ].dispose();
+
+ }
+
+ for ( let i = 0; i < this.renderTargetsVertical.length; i ++ ) {
+
+ this.renderTargetsVertical[ i ].dispose();
+
+ }
+
+ this.renderTargetBright.dispose();
+
+ //
+
+ for ( let i = 0; i < this.separableBlurMaterials.length; i ++ ) {
+
+ this.separableBlurMaterials[ i ].dispose();
+
+ }
+
+ this.compositeMaterial.dispose();
+ this.blendMaterial.dispose();
+ this._basic.dispose();
+
+ //
+
+ this._fsQuad.dispose();
+
+ }
+
+ /**
+ * Sets the size of the pass.
+ *
+ * @param {number} width - The width to set.
+ * @param {number} height - The height to set.
+ */
+ setSize( width, height ) {
+
+ let resx = Math.round( width / 2 );
+ let resy = Math.round( height / 2 );
+
+ this.renderTargetBright.setSize( resx, resy );
+
+ for ( let i = 0; i < this.nMips; i ++ ) {
+
+ this.renderTargetsHorizontal[ i ].setSize( resx, resy );
+ this.renderTargetsVertical[ i ].setSize( resx, resy );
+
+ this.separableBlurMaterials[ i ].uniforms[ 'invSize' ].value = new Vector2( 1 / resx, 1 / resy );
+
+ resx = Math.round( resx / 2 );
+ resy = Math.round( resy / 2 );
+
+ }
+
+ }
+
+ /**
+ * Performs the Bloom pass.
+ *
+ * @param {WebGLRenderer} renderer - The renderer.
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
+ * destination for the pass.
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
+ * previous pass from this buffer.
+ * @param {number} deltaTime - The delta time in seconds.
+ * @param {boolean} maskActive - Whether masking is active or not.
+ */
+ render( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
+
+ renderer.getClearColor( this._oldClearColor );
+ this._oldClearAlpha = renderer.getClearAlpha();
+ const oldAutoClear = renderer.autoClear;
+ renderer.autoClear = false;
+
+ renderer.setClearColor( this.clearColor, 0 );
+
+ if ( maskActive ) renderer.state.buffers.stencil.setTest( false );
+
+ // Render input to screen
+
+ if ( this.renderToScreen ) {
+
+ this._fsQuad.material = this._basic;
+ this._basic.map = readBuffer.texture;
+
+ renderer.setRenderTarget( null );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ }
+
+ // 1. Extract Bright Areas
+
+ this.highPassUniforms[ 'tDiffuse' ].value = readBuffer.texture;
+ this.highPassUniforms[ 'luminosityThreshold' ].value = this.threshold;
+ this._fsQuad.material = this.materialHighPassFilter;
+
+ renderer.setRenderTarget( this.renderTargetBright );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ // 2. Blur All the mips progressively
+
+ let inputRenderTarget = this.renderTargetBright;
+
+ for ( let i = 0; i < this.nMips; i ++ ) {
+
+ this._fsQuad.material = this.separableBlurMaterials[ i ];
+
+ this.separableBlurMaterials[ i ].uniforms[ 'colorTexture' ].value = inputRenderTarget.texture;
+ this.separableBlurMaterials[ i ].uniforms[ 'direction' ].value = UnrealBloomPass.BlurDirectionX;
+ renderer.setRenderTarget( this.renderTargetsHorizontal[ i ] );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ this.separableBlurMaterials[ i ].uniforms[ 'colorTexture' ].value = this.renderTargetsHorizontal[ i ].texture;
+ this.separableBlurMaterials[ i ].uniforms[ 'direction' ].value = UnrealBloomPass.BlurDirectionY;
+ renderer.setRenderTarget( this.renderTargetsVertical[ i ] );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ inputRenderTarget = this.renderTargetsVertical[ i ];
+
+ }
+
+ // Composite All the mips
+
+ 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;
+
+ renderer.setRenderTarget( this.renderTargetsHorizontal[ 0 ] );
+ renderer.clear();
+ this._fsQuad.render( renderer );
+
+ // Blend it additively over the input texture
+
+ this._fsQuad.material = this.blendMaterial;
+ this.copyUniforms[ 'tDiffuse' ].value = this.renderTargetsHorizontal[ 0 ].texture;
+
+ if ( maskActive ) renderer.state.buffers.stencil.setTest( true );
+
+ if ( this.renderToScreen ) {
+
+ renderer.setRenderTarget( null );
+ this._fsQuad.render( renderer );
+
+ } else {
+
+ renderer.setRenderTarget( readBuffer );
+ this._fsQuad.render( renderer );
+
+ }
+
+ // Restore renderer settings
+
+ renderer.setClearColor( this._oldClearColor, this._oldClearAlpha );
+ renderer.autoClear = oldAutoClear;
+
+ }
+
+ // internals
+
+ _getSeparableBlurMaterial( kernelRadius ) {
+
+ const coefficients = [];
+ const sigma = kernelRadius / 3;
+
+ for ( let i = 0; i < kernelRadius; i ++ ) {
+
+ coefficients.push( 0.39894 * Math.exp( - 0.5 * i * i / ( sigma * sigma ) ) / sigma );
+
+ }
+
+ // merge adjacent taps into single bilinear fetches (linear sampling)
+
+ const offsets = [];
+ const weights = [];
+
+ for ( let i = 1; i < kernelRadius; i += 2 ) {
+
+ const wa = coefficients[ i ];
+ const wb = ( i + 1 < kernelRadius ) ? coefficients[ i + 1 ] : 0;
+ const w = wa + wb;
+
+ offsets.push( ( i * wa + ( i + 1 ) * wb ) / w );
+ weights.push( w );
+
+ }
+
+ return new ShaderMaterial( {
+
+ defines: {
+ 'KERNEL_PAIRS': offsets.length
+ },
+
+ uniforms: {
+ 'colorTexture': { value: null },
+ 'invSize': { value: new Vector2( 0.5, 0.5 ) }, // inverse texture size
+ 'direction': { value: new Vector2( 0.5, 0.5 ) },
+ 'centerWeight': { value: coefficients[ 0 ] },
+ 'gaussianOffsets': { value: offsets },
+ 'gaussianWeights': { value: weights }
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ #include
+
+ varying vec2 vUv;
+
+ uniform sampler2D colorTexture;
+ uniform vec2 invSize;
+ uniform vec2 direction;
+ uniform float centerWeight;
+ uniform float gaussianOffsets[KERNEL_PAIRS];
+ uniform float gaussianWeights[KERNEL_PAIRS];
+
+ void main() {
+
+ vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * centerWeight;
+
+ for ( int i = 0; i < KERNEL_PAIRS; i ++ ) {
+
+ vec2 uvOffset = direction * invSize * gaussianOffsets[ i ];
+ vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
+ vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
+ diffuseSum += ( sample1 + sample2 ) * gaussianWeights[ i ];
+
+ }
+
+ gl_FragColor = vec4( diffuseSum, 1.0 );
+
+ }`
+ } );
+
+ }
+
+ _getCompositeMaterial( nMips ) {
+
+ return new ShaderMaterial( {
+
+ defines: {
+ 'NUM_MIPS': nMips
+ },
+
+ uniforms: {
+ 'blurTexture1': { value: null },
+ 'blurTexture2': { value: null },
+ 'blurTexture3': { value: null },
+ 'blurTexture4': { value: null },
+ 'blurTexture5': { value: null },
+ 'bloomStrength': { value: 1.0 },
+ 'bloomFactors': { value: null },
+ 'bloomTintColors': { value: null },
+ 'bloomRadius': { value: 0.0 }
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ uniform sampler2D blurTexture1;
+ uniform sampler2D blurTexture2;
+ uniform sampler2D blurTexture3;
+ uniform sampler2D blurTexture4;
+ uniform sampler2D blurTexture5;
+ uniform float bloomStrength;
+ uniform float bloomRadius;
+ uniform float bloomFactors[NUM_MIPS];
+ uniform vec3 bloomTintColors[NUM_MIPS];
+
+ float lerpBloomFactor( const in float factor ) {
+
+ float mirrorFactor = 1.2 - factor;
+ return mix( factor, mirrorFactor, bloomRadius );
+
+ }
+
+ void main() {
+
+ // 3.0 for backwards compatibility with previous alpha-based intensity
+ vec3 bloom = 3.0 * bloomStrength * (
+ lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +
+ lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +
+ lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +
+ lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +
+ lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb
+ );
+
+ float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );
+ gl_FragColor = vec4( bloom, bloomAlpha );
+
+ }`
+ } );
+
+ }
+
+}
+
+UnrealBloomPass.BlurDirectionX = new Vector2( 1.0, 0.0 );
+UnrealBloomPass.BlurDirectionY = new Vector2( 0.0, 1.0 );
+
+export { UnrealBloomPass };
diff --git a/demo/hero-content/vendor/addons/shaders/ACESFilmicToneMappingShader.js b/demo/hero-content/vendor/addons/shaders/ACESFilmicToneMappingShader.js
new file mode 100644
index 00000000..7529ab24
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/ACESFilmicToneMappingShader.js
@@ -0,0 +1,96 @@
+/**
+ * @module ACESFilmicToneMappingShader
+ * @three_import import { ACESFilmicToneMappingShader } from 'three/addons/shaders/ACESFilmicToneMappingShader.js';
+ */
+
+/**
+ * ACES Filmic Tone Mapping Shader by Stephen Hill.
+ * Reference: [ltc_blit.fs](https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs)
+ *
+ * This implementation of ACES is modified to accommodate a brighter viewing environment.
+ * The scale factor of 1/0.6 is subjective. See discussion in #19621.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const ACESFilmicToneMappingShader = {
+
+ name: 'ACESFilmicToneMappingShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'exposure': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ #define saturate(a) clamp( a, 0.0, 1.0 )
+
+ uniform sampler2D tDiffuse;
+
+ uniform float exposure;
+
+ varying vec2 vUv;
+
+ vec3 RRTAndODTFit( vec3 v ) {
+
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
+ return a / b;
+
+ }
+
+ vec3 ACESFilmicToneMapping( vec3 color ) {
+
+ // sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
+ const mat3 ACESInputMat = mat3(
+ vec3( 0.59719, 0.07600, 0.02840 ), // transposed from source
+ vec3( 0.35458, 0.90834, 0.13383 ),
+ vec3( 0.04823, 0.01566, 0.83777 )
+ );
+
+ // ODT_SAT => XYZ => D60_2_D65 => sRGB
+ const mat3 ACESOutputMat = mat3(
+ vec3( 1.60475, -0.10208, -0.00327 ), // transposed from source
+ vec3( -0.53108, 1.10813, -0.07276 ),
+ vec3( -0.07367, -0.00605, 1.07602 )
+ );
+
+ color = ACESInputMat * color;
+
+ // Apply RRT and ODT
+ color = RRTAndODTFit( color );
+
+ color = ACESOutputMat * color;
+
+ // Clamp to [0, 1]
+ return saturate( color );
+
+ }
+
+ void main() {
+
+ vec4 tex = texture2D( tDiffuse, vUv );
+
+ tex.rgb *= exposure / 0.6; // pre-exposed, outside of the tone mapping function
+
+ gl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );
+
+ }`
+
+};
+
+export { ACESFilmicToneMappingShader };
diff --git a/demo/hero-content/vendor/addons/shaders/AfterimageShader.js b/demo/hero-content/vendor/addons/shaders/AfterimageShader.js
new file mode 100644
index 00000000..feea31b7
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/AfterimageShader.js
@@ -0,0 +1,63 @@
+/**
+ * @module AfterimageShader
+ * @three_import import { AfterimageShader } from 'three/addons/shaders/AfterimageShader.js';
+ */
+
+/**
+ * Inspired by [Three.js FBO motion trails](https://codepen.io/brunoimbrizi/pen/MoRJaN?page=1&).
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const AfterimageShader = {
+
+ name: 'AfterimageShader',
+
+ uniforms: {
+
+ 'damp': { value: 0.96 },
+ 'tOld': { value: null },
+ 'tNew': { value: null }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float damp;
+
+ uniform sampler2D tOld;
+ uniform sampler2D tNew;
+
+ varying vec2 vUv;
+
+ vec4 when_gt( vec4 x, float y ) {
+
+ return max( sign( x - y ), 0.0 );
+
+ }
+
+ void main() {
+
+ vec4 texelOld = texture2D( tOld, vUv );
+ vec4 texelNew = texture2D( tNew, vUv );
+
+ texelOld *= damp * when_gt( texelOld, 0.1 );
+
+ gl_FragColor = max(texelNew, texelOld);
+
+ }`
+
+};
+
+export { AfterimageShader };
diff --git a/demo/hero-content/vendor/addons/shaders/BasicShader.js b/demo/hero-content/vendor/addons/shaders/BasicShader.js
new file mode 100644
index 00000000..2a5da560
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/BasicShader.js
@@ -0,0 +1,36 @@
+/**
+ * @module BasicShader
+ * @three_import import { BasicShader } from 'three/addons/shaders/BasicShader.js';
+ */
+
+/**
+ * Simple shader for testing.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const BasicShader = {
+
+ name: 'BasicShader',
+
+ uniforms: {},
+
+ vertexShader: /* glsl */`
+
+ void main() {
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ void main() {
+
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );
+
+ }`
+
+};
+
+export { BasicShader };
diff --git a/demo/hero-content/vendor/addons/shaders/BleachBypassShader.js b/demo/hero-content/vendor/addons/shaders/BleachBypassShader.js
new file mode 100644
index 00000000..ecb7d73b
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/BleachBypassShader.js
@@ -0,0 +1,68 @@
+
+/**
+ * @module BleachBypassShader
+ * @three_import import { BleachBypassShader } from 'three/addons/shaders/BleachBypassShader.js';
+ */
+
+/**
+ * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass] based on
+ * [Nvidia Shader library](http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass).
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const BleachBypassShader = {
+
+ name: 'BleachBypassShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'opacity': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float opacity;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 base = texture2D( tDiffuse, vUv );
+
+ float lum = luminance( base.rgb );
+ vec3 blend = vec3( lum );
+
+ float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );
+
+ vec3 result1 = 2.0 * base.rgb * blend;
+ vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );
+
+ vec3 newColor = mix( result1, result2, L );
+
+ float A2 = opacity * base.a;
+ vec3 mixRGB = A2 * newColor.rgb;
+ mixRGB += ( ( 1.0 - A2 ) * base.rgb );
+
+ gl_FragColor = vec4( mixRGB, base.a );
+
+ }`
+
+};
+
+export { BleachBypassShader };
diff --git a/demo/hero-content/vendor/addons/shaders/BlendShader.js b/demo/hero-content/vendor/addons/shaders/BlendShader.js
new file mode 100644
index 00000000..8fc45312
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/BlendShader.js
@@ -0,0 +1,56 @@
+/**
+ * @module BlendShader
+ * @three_import import { BlendShader } from 'three/addons/shaders/BlendShader.js';
+ */
+
+/**
+ * Blends two textures.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const BlendShader = {
+
+ name: 'BlendShader',
+
+ uniforms: {
+
+ 'tDiffuse1': { value: null },
+ 'tDiffuse2': { value: null },
+ 'mixRatio': { value: 0.5 },
+ 'opacity': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float opacity;
+ uniform float mixRatio;
+
+ uniform sampler2D tDiffuse1;
+ uniform sampler2D tDiffuse2;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 texel1 = texture2D( tDiffuse1, vUv );
+ vec4 texel2 = texture2D( tDiffuse2, vUv );
+ gl_FragColor = opacity * mix( texel1, texel2, mixRatio );
+
+ }`
+
+};
+
+export { BlendShader };
diff --git a/demo/hero-content/vendor/addons/shaders/BokehShader.js b/demo/hero-content/vendor/addons/shaders/BokehShader.js
new file mode 100644
index 00000000..f8127572
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/BokehShader.js
@@ -0,0 +1,151 @@
+/**
+ * @module BokehShader
+ * @three_import import { BokehShader } from 'three/addons/shaders/BokehShader.js';
+ */
+
+/**
+ * Depth-of-field shader with bokeh ported from
+ * [GLSL shader by Martins Upitis](http://artmartinsh.blogspot.com/2010/02/glsl-lens-blur-filter-with-bokeh.html).
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const BokehShader = {
+
+ name: 'BokehShader',
+
+ defines: {
+ 'DEPTH_PACKING': 1,
+ 'PERSPECTIVE_CAMERA': 1,
+ },
+
+ uniforms: {
+
+ 'tColor': { value: null },
+ 'tDepth': { value: null },
+ 'focus': { value: 1.0 },
+ 'aspect': { value: 1.0 },
+ 'aperture': { value: 0.025 },
+ 'maxblur': { value: 0.01 },
+ 'nearClip': { value: 1.0 },
+ 'farClip': { value: 1000.0 },
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ #include
+
+ varying vec2 vUv;
+
+ uniform sampler2D tColor;
+ uniform sampler2D tDepth;
+
+ uniform float maxblur; // max blur amount
+ uniform float aperture; // aperture - bigger values for shallower depth of field
+
+ uniform float nearClip;
+ uniform float farClip;
+
+ uniform float focus;
+ uniform float aspect;
+
+ #include
+
+ float getDepth( const in vec2 screenPosition ) {
+ #if DEPTH_PACKING == 1
+ return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );
+ #else
+ return texture2D( tDepth, screenPosition ).x;
+ #endif
+ }
+
+ float getViewZ( const in float depth ) {
+ #if PERSPECTIVE_CAMERA == 1
+ return perspectiveDepthToViewZ( depth, nearClip, farClip );
+ #else
+ return orthographicDepthToViewZ( depth, nearClip, farClip );
+ #endif
+ }
+
+
+ void main() {
+
+ vec2 aspectcorrect = vec2( 1.0, aspect );
+
+ float viewZ = getViewZ( getDepth( vUv ) );
+
+ float factor = ( focus + viewZ ); // viewZ is <= 0, so this is a difference equation
+
+ vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );
+
+ vec2 dofblur9 = dofblur * 0.9;
+ vec2 dofblur7 = dofblur * 0.7;
+ vec2 dofblur4 = dofblur * 0.4;
+
+ vec4 col = vec4( 0.0 );
+
+ col += texture2D( tColor, vUv.xy );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );
+
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );
+
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );
+
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );
+ col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );
+ col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );
+
+ gl_FragColor = col / 41.0;
+ gl_FragColor.a = 1.0;
+
+ }`
+
+};
+
+export { BokehShader };
diff --git a/demo/hero-content/vendor/addons/shaders/BokehShader2.js b/demo/hero-content/vendor/addons/shaders/BokehShader2.js
new file mode 100644
index 00000000..7853a867
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/BokehShader2.js
@@ -0,0 +1,404 @@
+import {
+ Vector2
+} from 'three';
+
+/**
+ * @module BokehShader2
+ * @three_import import { BokehShader, BokehDepthShader } from 'three/addons/shaders/BokehShader2.js';
+ */
+
+/**
+ * Depth-of-field shader with bokeh ported from
+ * [GLSL shader by Martins Upitis](http://blenderartists.org/forum/showthread.php?237488-GLSL-depth-of-field-with-bokeh-v2-4-(update)).
+ *
+ * Requires #define RINGS and SAMPLES integers
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const BokehShader = {
+
+ name: 'BokehShader',
+
+ uniforms: {
+
+ 'textureWidth': { value: 1.0 },
+ 'textureHeight': { value: 1.0 },
+
+ 'focalDepth': { value: 1.0 },
+ 'focalLength': { value: 24.0 },
+ 'fstop': { value: 0.9 },
+
+ 'tColor': { value: null },
+ 'tDepth': { value: null },
+
+ 'maxblur': { value: 1.0 },
+
+ 'showFocus': { value: 0 },
+ 'manualdof': { value: 0 },
+ 'vignetting': { value: 0 },
+ 'depthblur': { value: 0 },
+
+ 'threshold': { value: 0.5 },
+ 'gain': { value: 2.0 },
+ 'bias': { value: 0.5 },
+ 'fringe': { value: 0.7 },
+
+ 'znear': { value: 0.1 },
+ 'zfar': { value: 100 },
+
+ 'noise': { value: 1 },
+ 'dithering': { value: 0.0001 },
+ 'pentagon': { value: 0 },
+
+ 'shaderFocus': { value: 1 },
+ 'focusCoords': { value: new Vector2() }
+
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ #include
+
+ varying vec2 vUv;
+
+ uniform sampler2D tColor;
+ uniform sampler2D tDepth;
+ uniform float textureWidth;
+ uniform float textureHeight;
+
+ uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below
+ uniform float focalLength; //focal length in mm
+ uniform float fstop; //f-stop value
+ uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)
+
+ /*
+ make sure that these two values are the same for your camera, otherwise distances will be wrong.
+ */
+
+ uniform float znear; // camera clipping start
+ uniform float zfar; // camera clipping end
+
+ //------------------------------------------
+ //user variables
+
+ const int samples = SAMPLES; //samples on the first ring
+ const int rings = RINGS; //ring count
+
+ const int maxringsamples = rings * samples;
+
+ uniform bool manualdof; // manual dof calculation
+ float ndofstart = 1.0; // near dof blur start
+ float ndofdist = 2.0; // near dof blur falloff distance
+ float fdofstart = 1.0; // far dof blur start
+ float fdofdist = 3.0; // far dof blur falloff distance
+
+ float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)
+
+ uniform bool vignetting; // use optical lens vignetting
+
+ float vignout = 1.3; // vignetting outer border
+ float vignin = 0.0; // vignetting inner border
+ float vignfade = 22.0; // f-stops till vignette fades
+
+ uniform bool shaderFocus;
+ // disable if you use external focalDepth value
+
+ uniform vec2 focusCoords;
+ // autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)
+ // if center of screen use vec2(0.5, 0.5);
+
+ uniform float maxblur;
+ //clamp value of max blur (0.0 = no blur, 1.0 default)
+
+ uniform float threshold; // highlight threshold;
+ uniform float gain; // highlight gain;
+
+ uniform float bias; // bokeh edge bias
+ uniform float fringe; // bokeh chromatic aberration / fringing
+
+ uniform bool noise; //use noise instead of pattern for sample dithering
+
+ uniform float dithering;
+
+ uniform bool depthblur; // blur the depth buffer
+ float dbsize = 1.25; // depth blur size
+
+ /*
+ next part is experimental
+ not looking good with small sample and ring count
+ looks okay starting from samples = 4, rings = 4
+ */
+
+ uniform bool pentagon; //use pentagon as bokeh shape?
+ float feather = 0.4; //pentagon shape feather
+
+ //------------------------------------------
+
+ float penta(vec2 coords) {
+ //pentagonal shape
+ float scale = float(rings) - 1.3;
+ vec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);
+ vec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);
+ vec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);
+ vec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);
+ vec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);
+ vec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);
+
+ vec4 one = vec4( 1.0 );
+
+ vec4 P = vec4((coords),vec2(scale, scale));
+
+ vec4 dist = vec4(0.0);
+ float inorout = -4.0;
+
+ dist.x = dot( P, HS0 );
+ dist.y = dot( P, HS1 );
+ dist.z = dot( P, HS2 );
+ dist.w = dot( P, HS3 );
+
+ dist = smoothstep( -feather, feather, dist );
+
+ inorout += dot( dist, one );
+
+ dist.x = dot( P, HS4 );
+ dist.y = HS5.w - abs( P.z );
+
+ dist = smoothstep( -feather, feather, dist );
+ inorout += dist.x;
+
+ return clamp( inorout, 0.0, 1.0 );
+ }
+
+ float bdepth(vec2 coords) {
+ // Depth buffer blur
+ float d = 0.0;
+ float kernel[9];
+ vec2 offset[9];
+
+ vec2 wh = vec2(1.0/textureWidth,1.0/textureHeight) * dbsize;
+
+ offset[0] = vec2(-wh.x,-wh.y);
+ offset[1] = vec2( 0.0, -wh.y);
+ offset[2] = vec2( wh.x -wh.y);
+
+ offset[3] = vec2(-wh.x, 0.0);
+ offset[4] = vec2( 0.0, 0.0);
+ offset[5] = vec2( wh.x, 0.0);
+
+ offset[6] = vec2(-wh.x, wh.y);
+ offset[7] = vec2( 0.0, wh.y);
+ offset[8] = vec2( wh.x, wh.y);
+
+ kernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;
+ kernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;
+ kernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;
+
+
+ for( int i=0; i<9; i++ ) {
+ float tmp = texture2D(tDepth, coords + offset[i]).r;
+ d += tmp * kernel[i];
+ }
+
+ return d;
+ }
+
+
+ vec3 color(vec2 coords,float blur) {
+ //processing the sample
+
+ vec3 col = vec3(0.0);
+ vec2 texel = vec2(1.0/textureWidth,1.0/textureHeight);
+
+ col.r = texture2D(tColor,coords + vec2(0.0,1.0)*texel*fringe*blur).r;
+ col.g = texture2D(tColor,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;
+ col.b = texture2D(tColor,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;
+
+ vec3 lumcoeff = vec3(0.299,0.587,0.114);
+ float lum = dot(col.rgb, lumcoeff);
+ float thresh = max((lum-threshold)*gain, 0.0);
+ return col+mix(vec3(0.0),col,thresh*blur);
+ }
+
+ vec3 debugFocus(vec3 col, float blur, float depth) {
+ float edge = 0.002*depth; //distance based edge smoothing
+ float m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);
+ float e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);
+
+ col = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);
+ col = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);
+
+ return col;
+ }
+
+ float linearize(float depth) {
+ return -zfar * znear / (depth * (zfar - znear) - zfar);
+ }
+
+ float vignette() {
+ float dist = distance(vUv.xy, vec2(0.5,0.5));
+ dist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);
+ return clamp(dist,0.0,1.0);
+ }
+
+ float gather(float i, float j, int ringsamples, inout vec3 col, float w, float h, float blur) {
+ float rings2 = float(rings);
+ float step = PI*2.0 / float(ringsamples);
+ float pw = cos(j*step)*i;
+ float ph = sin(j*step)*i;
+ float p = 1.0;
+ if (pentagon) {
+ p = penta(vec2(pw,ph));
+ }
+ col += color(vUv.xy + vec2(pw*w,ph*h), blur) * mix(1.0, i/rings2, bias) * p;
+ return 1.0 * mix(1.0, i /rings2, bias) * p;
+ }
+
+ void main() {
+ //scene depth calculation
+
+ float depth = linearize(texture2D(tDepth,vUv.xy).x);
+
+ // Blur depth?
+ if ( depthblur ) {
+ depth = linearize(bdepth(vUv.xy));
+ }
+
+ //focal plane calculation
+
+ float fDepth = focalDepth;
+
+ if (shaderFocus) {
+
+ fDepth = linearize(texture2D(tDepth,focusCoords).x);
+
+ }
+
+ // dof blur factor calculation
+
+ float blur = 0.0;
+
+ if (manualdof) {
+ float a = depth-fDepth; // Focal plane
+ float b = (a-fdofstart)/fdofdist; // Far DoF
+ float c = (-a-ndofstart)/ndofdist; // Near Dof
+ blur = (a>0.0) ? b : c;
+ } else {
+ float f = focalLength; // focal length in mm
+ float d = fDepth*1000.0; // focal plane in mm
+ float o = depth*1000.0; // depth in mm
+
+ float a = (o*f)/(o-f);
+ float b = (d*f)/(d-f);
+ float c = (d-f)/(d*fstop*CoC);
+
+ blur = abs(a-b)*c;
+ }
+
+ blur = clamp(blur,0.0,1.0);
+
+ // calculation of pattern for dithering
+
+ vec2 noise = vec2(rand(vUv.xy), rand( vUv.xy + vec2( 0.4, 0.6 ) ) )*dithering*blur;
+
+ // getting blur x and y step factor
+
+ float w = (1.0/textureWidth)*blur*maxblur+noise.x;
+ float h = (1.0/textureHeight)*blur*maxblur+noise.y;
+
+ // calculation of final color
+
+ vec3 col = vec3(0.0);
+
+ if(blur < 0.05) {
+ //some optimization thingy
+ col = texture2D(tColor, vUv.xy).rgb;
+ } else {
+ col = texture2D(tColor, vUv.xy).rgb;
+ float s = 1.0;
+ int ringsamples;
+
+ for (int i = 1; i <= rings; i++) {
+ /*unboxstart*/
+ ringsamples = i * samples;
+
+ for (int j = 0 ; j < maxringsamples ; j++) {
+ if (j >= ringsamples) break;
+ s += gather(float(i), float(j), ringsamples, col, w, h, blur);
+ }
+ /*unboxend*/
+ }
+
+ col /= s; //divide by sample count
+ }
+
+ if (showFocus) {
+ col = debugFocus(col, blur, depth);
+ }
+
+ if (vignetting) {
+ col *= vignette();
+ }
+
+ gl_FragColor.rgb = col;
+ gl_FragColor.a = 1.0;
+
+ #include
+ #include
+ }`
+
+};
+
+const BokehDepthShader = {
+
+ name: 'BokehDepthShader',
+
+ uniforms: {
+
+ 'mNear': { value: 1.0 },
+ 'mFar': { value: 1000.0 },
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying float vViewZDepth;
+
+ void main() {
+
+ #include
+ #include
+
+ vViewZDepth = - mvPosition.z;
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float mNear;
+ uniform float mFar;
+
+ varying float vViewZDepth;
+
+ void main() {
+
+ float color = 1.0 - smoothstep( mNear, mFar, vViewZDepth );
+ gl_FragColor = vec4( vec3( color ), 1.0 );
+
+ }`
+
+};
+
+export { BokehShader, BokehDepthShader };
diff --git a/demo/hero-content/vendor/addons/shaders/BrightnessContrastShader.js b/demo/hero-content/vendor/addons/shaders/BrightnessContrastShader.js
new file mode 100644
index 00000000..073f07e1
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/BrightnessContrastShader.js
@@ -0,0 +1,62 @@
+/**
+ * @module BrightnessContrastShader
+ * @three_import import { BrightnessContrastShader } from 'three/addons/shaders/BrightnessContrastShader.js';
+ */
+
+/**
+ * Brightness and contrast adjustment {@link https://github.com/evanw/glfx.js}.
+ * Brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white)
+ * Contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const BrightnessContrastShader = {
+
+ name: 'BrightnessContrastShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'brightness': { value: 0 },
+ 'contrast': { value: 0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform float brightness;
+ uniform float contrast;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ gl_FragColor = texture2D( tDiffuse, vUv );
+
+ gl_FragColor.rgb += brightness;
+
+ if (contrast > 0.0) {
+ gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;
+ } else {
+ gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;
+ }
+
+ }`
+
+};
+
+export { BrightnessContrastShader };
diff --git a/demo/hero-content/vendor/addons/shaders/ColorCorrectionShader.js b/demo/hero-content/vendor/addons/shaders/ColorCorrectionShader.js
new file mode 100644
index 00000000..0ae42d99
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/ColorCorrectionShader.js
@@ -0,0 +1,59 @@
+import {
+ Vector3
+} from 'three';
+
+/**
+ * @module ColorCorrectionShader
+ * @three_import import { ColorCorrectionShader } from 'three/addons/shaders/ColorCorrectionShader.js';
+ */
+
+/**
+ * Color correction shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const ColorCorrectionShader = {
+
+ name: 'ColorCorrectionShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'powRGB': { value: new Vector3( 2, 2, 2 ) },
+ 'mulRGB': { value: new Vector3( 1, 1, 1 ) },
+ 'addRGB': { value: new Vector3( 0, 0, 0 ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform vec3 powRGB;
+ uniform vec3 mulRGB;
+ uniform vec3 addRGB;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ gl_FragColor = texture2D( tDiffuse, vUv );
+ gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );
+
+ }`
+
+};
+
+export { ColorCorrectionShader };
diff --git a/demo/hero-content/vendor/addons/shaders/ColorifyShader.js b/demo/hero-content/vendor/addons/shaders/ColorifyShader.js
new file mode 100644
index 00000000..029671ff
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/ColorifyShader.js
@@ -0,0 +1,57 @@
+import {
+ Color
+} from 'three';
+
+/**
+ * @module ColorifyShader
+ * @three_import import { ColorifyShader } from 'three/addons/shaders/ColorifyShader.js';
+ */
+
+/**
+ * Colorify shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const ColorifyShader = {
+
+ name: 'ColorifyShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'color': { value: new Color( 0xffffff ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform vec3 color;
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 texel = texture2D( tDiffuse, vUv );
+
+ float v = luminance( texel.xyz );
+
+ gl_FragColor = vec4( v * color, texel.w );
+
+ }`
+
+};
+
+export { ColorifyShader };
diff --git a/demo/hero-content/vendor/addons/shaders/ConvolutionShader.js b/demo/hero-content/vendor/addons/shaders/ConvolutionShader.js
new file mode 100644
index 00000000..5db1cdf2
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/ConvolutionShader.js
@@ -0,0 +1,74 @@
+import {
+ Vector2
+} from 'three';
+
+/**
+ * @module ConvolutionShader
+ * @three_import import { ConvolutionShader } from 'three/addons/shaders/ConvolutionShader.js';
+ */
+
+/**
+ * Convolution shader ported from o3d sample to WebGL / GLSL.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const ConvolutionShader = {
+
+ name: 'ConvolutionShader',
+
+ defines: {
+
+ 'KERNEL_SIZE_FLOAT': '25.0',
+ 'KERNEL_SIZE_INT': '25'
+
+ },
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'uImageIncrement': { value: new Vector2( 0.001953125, 0.0 ) },
+ 'cKernel': { value: [] }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ uniform vec2 uImageIncrement;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float cKernel[ KERNEL_SIZE_INT ];
+
+ uniform sampler2D tDiffuse;
+ uniform vec2 uImageIncrement;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec2 imageCoord = vUv;
+ vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
+
+ for( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {
+
+ sum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];
+ imageCoord += uImageIncrement;
+
+ }
+
+ gl_FragColor = sum;
+
+ }`
+};
+
+export { ConvolutionShader };
diff --git a/demo/hero-content/vendor/addons/shaders/CopyShader.js b/demo/hero-content/vendor/addons/shaders/CopyShader.js
new file mode 100644
index 00000000..6deb2484
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/CopyShader.js
@@ -0,0 +1,52 @@
+/**
+ * @module CopyShader
+ * @three_import import { CopyShader } from 'three/addons/shaders/CopyShader.js';
+ */
+
+/**
+ * Full-screen copy shader pass.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const CopyShader = {
+
+ name: 'CopyShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'opacity': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float opacity;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 texel = texture2D( tDiffuse, vUv );
+ gl_FragColor = opacity * texel;
+
+
+ }`
+
+};
+
+export { CopyShader };
diff --git a/demo/hero-content/vendor/addons/shaders/DOFMipMapShader.js b/demo/hero-content/vendor/addons/shaders/DOFMipMapShader.js
new file mode 100644
index 00000000..4cddc614
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/DOFMipMapShader.js
@@ -0,0 +1,63 @@
+/**
+ * @module DOFMipMapShader
+ * @three_import import { DOFMipMapShader } from 'three/addons/shaders/DOFMipMapShader.js';
+ */
+
+/**
+ * Depth-of-field shader using mipmaps from Matt Handley @applmak.
+ *
+ * Requires power-of-2 sized render target with enabled mipmaps.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const DOFMipMapShader = {
+
+ name: 'DOFMipMapShader',
+
+ uniforms: {
+
+ 'tColor': { value: null },
+ 'tDepth': { value: null },
+ 'focus': { value: 1.0 },
+ 'maxblur': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float focus;
+ uniform float maxblur;
+
+ uniform sampler2D tColor;
+ uniform sampler2D tDepth;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 depth = texture2D( tDepth, vUv );
+
+ float factor = depth.x - focus;
+
+ vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );
+
+ gl_FragColor = col;
+ gl_FragColor.a = 1.0;
+
+ }`
+
+};
+
+export { DOFMipMapShader };
diff --git a/demo/hero-content/vendor/addons/shaders/DepthLimitedBlurShader.js b/demo/hero-content/vendor/addons/shaders/DepthLimitedBlurShader.js
new file mode 100644
index 00000000..b1aa8c2b
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/DepthLimitedBlurShader.js
@@ -0,0 +1,183 @@
+import {
+ Vector2
+} from 'three';
+
+/**
+ * @module DepthLimitedBlurShader
+ * @three_import import { DepthLimitedBlurShader, BlurShaderUtils } from 'three/addons/shaders/DepthLimitedBlurShader.js';
+ */
+
+/**
+ * A separable Gaussian blur shader that limits blurring across depth
+ * discontinuities, stopping when the view-space depth difference to a
+ * neighboring sample exceeds `depthCutoff`. This preserves edges and
+ * avoids bleeding across them.
+ *
+ * Used by {@link SAOPass}.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const DepthLimitedBlurShader = {
+
+ name: 'DepthLimitedBlurShader',
+
+ defines: {
+ 'KERNEL_RADIUS': 4,
+ 'DEPTH_PACKING': 1,
+ 'PERSPECTIVE_CAMERA': 1
+ },
+
+ uniforms: {
+ 'tDiffuse': { value: null },
+ 'size': { value: new Vector2( 512, 512 ) },
+ 'sampleUvOffsets': { value: [ new Vector2( 0, 0 ) ] },
+ 'sampleWeights': { value: [ 1.0 ] },
+ 'tDepth': { value: null },
+ 'cameraNear': { value: 10 },
+ 'cameraFar': { value: 1000 },
+ 'depthCutoff': { value: 10 },
+ },
+
+ vertexShader: /* glsl */`
+
+ #include
+
+ uniform vec2 size;
+
+ varying vec2 vUv;
+ varying vec2 vInvSize;
+
+ void main() {
+ vUv = uv;
+ vInvSize = 1.0 / size;
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ #include
+ #include
+
+ uniform sampler2D tDiffuse;
+ uniform sampler2D tDepth;
+
+ uniform float cameraNear;
+ uniform float cameraFar;
+ uniform float depthCutoff;
+
+ uniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];
+ uniform float sampleWeights[ KERNEL_RADIUS + 1 ];
+
+ varying vec2 vUv;
+ varying vec2 vInvSize;
+
+ float getDepth( const in vec2 screenPosition ) {
+ #if DEPTH_PACKING == 1
+ return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );
+ #else
+ return texture2D( tDepth, screenPosition ).x;
+ #endif
+ }
+
+ float getViewZ( const in float depth ) {
+ #if PERSPECTIVE_CAMERA == 1
+ return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );
+ #else
+ return orthographicDepthToViewZ( depth, cameraNear, cameraFar );
+ #endif
+ }
+
+ void main() {
+ float depth = getDepth( vUv );
+ if( depth >= ( 1.0 - EPSILON ) ) {
+ discard;
+ }
+
+ float centerViewZ = -getViewZ( depth );
+ bool rBreak = false, lBreak = false;
+
+ float weightSum = sampleWeights[0];
+ vec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;
+
+ for( int i = 1; i <= KERNEL_RADIUS; i ++ ) {
+
+ float sampleWeight = sampleWeights[i];
+ vec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;
+
+ vec2 sampleUv = vUv + sampleUvOffset;
+ float viewZ = -getViewZ( getDepth( sampleUv ) );
+
+ if( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;
+
+ if( ! rBreak ) {
+ diffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;
+ weightSum += sampleWeight;
+ }
+
+ sampleUv = vUv - sampleUvOffset;
+ viewZ = -getViewZ( getDepth( sampleUv ) );
+
+ if( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;
+
+ if( ! lBreak ) {
+ diffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;
+ weightSum += sampleWeight;
+ }
+
+ }
+
+ gl_FragColor = diffuseSum / weightSum;
+ }`
+
+};
+
+const BlurShaderUtils = {
+
+ createSampleWeights: function ( kernelRadius, stdDev ) {
+
+ const weights = [];
+
+ for ( let i = 0; i <= kernelRadius; i ++ ) {
+
+ weights.push( gaussian( i, stdDev ) );
+
+ }
+
+ return weights;
+
+ },
+
+ createSampleOffsets: function ( kernelRadius, uvIncrement ) {
+
+ const offsets = [];
+
+ for ( let i = 0; i <= kernelRadius; i ++ ) {
+
+ offsets.push( uvIncrement.clone().multiplyScalar( i ) );
+
+ }
+
+ return offsets;
+
+ },
+
+ configure: function ( material, kernelRadius, stdDev, uvIncrement ) {
+
+ material.defines[ 'KERNEL_RADIUS' ] = kernelRadius;
+ material.uniforms[ 'sampleUvOffsets' ].value = BlurShaderUtils.createSampleOffsets( kernelRadius, uvIncrement );
+ material.uniforms[ 'sampleWeights' ].value = BlurShaderUtils.createSampleWeights( kernelRadius, stdDev );
+ material.needsUpdate = true;
+
+ }
+
+};
+
+function gaussian( x, stdDev ) {
+
+ return Math.exp( - ( x * x ) / ( 2.0 * ( stdDev * stdDev ) ) ) / ( Math.sqrt( 2.0 * Math.PI ) * stdDev );
+
+}
+
+export { DepthLimitedBlurShader, BlurShaderUtils };
diff --git a/demo/hero-content/vendor/addons/shaders/DigitalGlitch.js b/demo/hero-content/vendor/addons/shaders/DigitalGlitch.js
new file mode 100644
index 00000000..23e873bc
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/DigitalGlitch.js
@@ -0,0 +1,104 @@
+/**
+ * @module DigitalGlitch
+ * @three_import import { DigitalGlitch } from 'three/addons/shaders/DigitalGlitch.js';
+ */
+
+/**
+ * Digital glitch shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const DigitalGlitch = {
+
+ name: 'DigitalGlitch',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null }, //diffuse texture
+ 'tDisp': { value: null }, //displacement texture for digital glitch squares
+ 'byp': { value: 0 }, //apply the glitch ?
+ 'amount': { value: 0.08 },
+ 'angle': { value: 0.02 },
+ 'seed': { value: 0.02 },
+ 'seed_x': { value: 0.02 }, //-1,1
+ 'seed_y': { value: 0.02 }, //-1,1
+ 'distortion_x': { value: 0.5 },
+ 'distortion_y': { value: 0.6 },
+ 'col_s': { value: 0.05 }
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform int byp; //should we apply the glitch ?
+
+ uniform sampler2D tDiffuse;
+ uniform sampler2D tDisp;
+
+ uniform float amount;
+ uniform float angle;
+ uniform float seed;
+ uniform float seed_x;
+ uniform float seed_y;
+ uniform float distortion_x;
+ uniform float distortion_y;
+ uniform float col_s;
+
+ varying vec2 vUv;
+
+
+ float rand(vec2 co){
+ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
+ }
+
+ void main() {
+ if(byp<1) {
+ vec2 p = vUv;
+ float xs = floor(gl_FragCoord.x / 0.5);
+ float ys = floor(gl_FragCoord.y / 0.5);
+ //based on staffantans glitch shader for unity https://github.com/staffantan/unityglitch
+ float disp = texture2D(tDisp, p*seed*seed).r;
+ if(p.ydistortion_x-col_s*seed) {
+ if(seed_x>0.){
+ p.y = 1. - (p.y + distortion_y);
+ }
+ else {
+ p.y = distortion_y;
+ }
+ }
+ if(p.xdistortion_y-col_s*seed) {
+ if(seed_y>0.){
+ p.x=distortion_x;
+ }
+ else {
+ p.x = 1. - (p.x + distortion_x);
+ }
+ }
+ p.x+=disp*seed_x*(seed/5.);
+ p.y+=disp*seed_y*(seed/5.);
+ //base from RGB shift shader
+ vec2 offset = amount * vec2( cos(angle), sin(angle));
+ vec4 cr = texture2D(tDiffuse, p + offset);
+ vec4 cga = texture2D(tDiffuse, p);
+ vec4 cb = texture2D(tDiffuse, p - offset);
+ gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);
+ //add noise
+ vec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);
+ gl_FragColor = gl_FragColor+ snow;
+ }
+ else {
+ gl_FragColor=texture2D (tDiffuse, vUv);
+ }
+ }`
+
+};
+
+export { DigitalGlitch };
diff --git a/demo/hero-content/vendor/addons/shaders/DotScreenShader.js b/demo/hero-content/vendor/addons/shaders/DotScreenShader.js
new file mode 100644
index 00000000..be132eda
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/DotScreenShader.js
@@ -0,0 +1,75 @@
+import {
+ Vector2
+} from 'three';
+
+/**
+ * @module DotScreenShader
+ * @three_import import { DotScreenShader } from 'three/addons/shaders/DotScreenShader.js';
+ */
+
+/**
+ * Dot screen shader based on [glfx.js sepia shader](https://github.com/evanw/glfx.js).
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const DotScreenShader = {
+
+ name: 'DotScreenShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'tSize': { value: new Vector2( 256, 256 ) },
+ 'center': { value: new Vector2( 0.5, 0.5 ) },
+ 'angle': { value: 1.57 },
+ 'scale': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform vec2 center;
+ uniform float angle;
+ uniform float scale;
+ uniform vec2 tSize;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ float pattern() {
+
+ float s = sin( angle ), c = cos( angle );
+
+ vec2 tex = vUv * tSize - center;
+ vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;
+
+ return ( sin( point.x ) * sin( point.y ) ) * 4.0;
+
+ }
+
+ void main() {
+
+ vec4 color = texture2D( tDiffuse, vUv );
+
+ float average = ( color.r + color.g + color.b ) / 3.0;
+
+ gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );
+
+ }`
+
+};
+
+export { DotScreenShader };
diff --git a/demo/hero-content/vendor/addons/shaders/ExposureShader.js b/demo/hero-content/vendor/addons/shaders/ExposureShader.js
new file mode 100644
index 00000000..ca66f7af
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/ExposureShader.js
@@ -0,0 +1,51 @@
+/**
+ * @module ExposureShader
+ * @three_import import { ExposureShader } from 'three/addons/shaders/ExposureShader.js';
+ */
+
+/**
+ * Exposure shader that scales the image color by an exposure factor.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const ExposureShader = {
+
+ name: 'ExposureShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'exposure': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float exposure;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ gl_FragColor = texture2D( tDiffuse, vUv );
+ gl_FragColor.rgb *= exposure;
+
+ }`
+
+};
+
+export { ExposureShader };
diff --git a/demo/hero-content/vendor/addons/shaders/FXAAShader.js b/demo/hero-content/vendor/addons/shaders/FXAAShader.js
new file mode 100644
index 00000000..7181751d
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/FXAAShader.js
@@ -0,0 +1,298 @@
+import {
+ Vector2
+} from 'three';
+
+/**
+ * @module FXAAShader
+ * @three_import import { FXAAShader } from 'three/addons/shaders/FXAAShader.js';
+ */
+
+/**
+ * FXAA algorithm from NVIDIA, C# implementation by Jasper Flick, GLSL port by Dave Hoskins.
+ *
+ * References:
+ * - {@link http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf}.
+ * - {@link https://catlikecoding.com/unity/tutorials/advanced-rendering/fxaa/}.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const FXAAShader = {
+
+ name: 'FXAAShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'resolution': { value: new Vector2( 1 / 1024, 1 / 512 ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform vec2 resolution;
+ varying vec2 vUv;
+
+ #define EDGE_STEP_COUNT 6
+ #define EDGE_GUESS 8.0
+ #define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0
+ const float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );
+
+ float _ContrastThreshold = 0.0312;
+ float _RelativeThreshold = 0.063;
+ float _SubpixelBlending = 1.0;
+
+ vec4 Sample( sampler2D tex2D, vec2 uv ) {
+
+ return texture( tex2D, uv );
+
+ }
+
+ float SampleLuminance( sampler2D tex2D, vec2 uv ) {
+
+ return dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );
+
+ }
+
+ float SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {
+
+ uv += texSize * vec2(uOffset, vOffset);
+ return SampleLuminance(tex2D, uv);
+
+ }
+
+ struct LuminanceData {
+
+ float m, n, e, s, w;
+ float ne, nw, se, sw;
+ float highest, lowest, contrast;
+
+ };
+
+ LuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {
+
+ LuminanceData l;
+ l.m = SampleLuminance( tex2D, uv );
+ l.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );
+ l.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );
+ l.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );
+ l.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );
+
+ l.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );
+ l.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );
+ l.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );
+ l.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );
+
+ l.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );
+ l.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );
+ l.contrast = l.highest - l.lowest;
+ return l;
+
+ }
+
+ bool ShouldSkipPixel( LuminanceData l ) {
+
+ float threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );
+ return l.contrast < threshold;
+
+ }
+
+ float DeterminePixelBlendFactor( LuminanceData l ) {
+
+ float f = 2.0 * ( l.n + l.e + l.s + l.w );
+ f += l.ne + l.nw + l.se + l.sw;
+ f *= 1.0 / 12.0;
+ f = abs( f - l.m );
+ f = clamp( f / l.contrast, 0.0, 1.0 );
+
+ float blendFactor = smoothstep( 0.0, 1.0, f );
+ return blendFactor * blendFactor * _SubpixelBlending;
+
+ }
+
+ struct EdgeData {
+
+ bool isHorizontal;
+ float pixelStep;
+ float oppositeLuminance, gradient;
+
+ };
+
+ EdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {
+
+ EdgeData e;
+ float horizontal =
+ abs( l.n + l.s - 2.0 * l.m ) * 2.0 +
+ abs( l.ne + l.se - 2.0 * l.e ) +
+ abs( l.nw + l.sw - 2.0 * l.w );
+ float vertical =
+ abs( l.e + l.w - 2.0 * l.m ) * 2.0 +
+ abs( l.ne + l.nw - 2.0 * l.n ) +
+ abs( l.se + l.sw - 2.0 * l.s );
+ e.isHorizontal = horizontal >= vertical;
+
+ float pLuminance = e.isHorizontal ? l.n : l.e;
+ float nLuminance = e.isHorizontal ? l.s : l.w;
+ float pGradient = abs( pLuminance - l.m );
+ float nGradient = abs( nLuminance - l.m );
+
+ e.pixelStep = e.isHorizontal ? texSize.y : texSize.x;
+
+ if (pGradient < nGradient) {
+
+ e.pixelStep = -e.pixelStep;
+ e.oppositeLuminance = nLuminance;
+ e.gradient = nGradient;
+
+ } else {
+
+ e.oppositeLuminance = pLuminance;
+ e.gradient = pGradient;
+
+ }
+
+ return e;
+
+ }
+
+ float DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {
+
+ vec2 uvEdge = uv;
+ vec2 edgeStep;
+ if (e.isHorizontal) {
+
+ uvEdge.y += e.pixelStep * 0.5;
+ edgeStep = vec2( texSize.x, 0.0 );
+
+ } else {
+
+ uvEdge.x += e.pixelStep * 0.5;
+ edgeStep = vec2( 0.0, texSize.y );
+
+ }
+
+ float edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;
+ float gradientThreshold = e.gradient * 0.25;
+
+ vec2 puv = uvEdge + edgeStep * edgeSteps[0];
+ float pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
+ bool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
+
+ for ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {
+
+ puv += edgeStep * edgeSteps[i];
+ pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
+ pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
+
+ }
+
+ if ( !pAtEnd ) {
+
+ puv += edgeStep * EDGE_GUESS;
+
+ }
+
+ vec2 nuv = uvEdge - edgeStep * edgeSteps[0];
+ float nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
+ bool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
+
+ for ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {
+
+ nuv -= edgeStep * edgeSteps[i];
+ nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
+ nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
+
+ }
+
+ if ( !nAtEnd ) {
+
+ nuv -= edgeStep * EDGE_GUESS;
+
+ }
+
+ float pDistance, nDistance;
+ if ( e.isHorizontal ) {
+
+ pDistance = puv.x - uv.x;
+ nDistance = uv.x - nuv.x;
+
+ } else {
+
+ pDistance = puv.y - uv.y;
+ nDistance = uv.y - nuv.y;
+
+ }
+
+ float shortestDistance;
+ bool deltaSign;
+ if ( pDistance <= nDistance ) {
+
+ shortestDistance = pDistance;
+ deltaSign = pLuminanceDelta >= 0.0;
+
+ } else {
+
+ shortestDistance = nDistance;
+ deltaSign = nLuminanceDelta >= 0.0;
+
+ }
+
+ if ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {
+
+ return 0.0;
+
+ }
+
+ return 0.5 - shortestDistance / ( pDistance + nDistance );
+
+ }
+
+ vec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {
+
+ LuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );
+ if ( ShouldSkipPixel( luminance ) ) {
+
+ return Sample( tex2D, uv );
+
+ }
+
+ float pixelBlend = DeterminePixelBlendFactor( luminance );
+ EdgeData edge = DetermineEdge( texSize, luminance );
+ float edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );
+ float finalBlend = max( pixelBlend, edgeBlend );
+
+ if (edge.isHorizontal) {
+
+ uv.y += edge.pixelStep * finalBlend;
+
+ } else {
+
+ uv.x += edge.pixelStep * finalBlend;
+
+ }
+
+ return Sample( tex2D, uv );
+
+ }
+
+ void main() {
+
+ gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );
+
+ }`
+
+};
+
+export { FXAAShader };
diff --git a/demo/hero-content/vendor/addons/shaders/FilmShader.js b/demo/hero-content/vendor/addons/shaders/FilmShader.js
new file mode 100644
index 00000000..9f9b7fba
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/FilmShader.js
@@ -0,0 +1,73 @@
+/**
+ * @module FilmShader
+ * @three_import import { FilmShader } from 'three/addons/shaders/FilmShader.js';
+ */
+
+/**
+ * Film grain shader that adds animated noise to the image, with an optional
+ * grayscale conversion.
+ *
+ * Used by {@link FilmPass}.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const FilmShader = {
+
+ name: 'FilmShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'time': { value: 0.0 },
+ 'intensity': { value: 0.5 },
+ 'grayscale': { value: false }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ #include
+
+ uniform float intensity;
+ uniform bool grayscale;
+ uniform float time;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 base = texture2D( tDiffuse, vUv );
+
+ float noise = rand( fract( vUv + time ) );
+
+ vec3 color = base.rgb + base.rgb * clamp( 0.1 + noise, 0.0, 1.0 );
+
+ color = mix( base.rgb, color, intensity );
+
+ if ( grayscale ) {
+
+ color = vec3( luminance( color ) ); // assuming linear-srgb
+
+ }
+
+ gl_FragColor = vec4( color, base.a );
+
+ }`,
+
+};
+
+export { FilmShader };
diff --git a/demo/hero-content/vendor/addons/shaders/FocusShader.js b/demo/hero-content/vendor/addons/shaders/FocusShader.js
new file mode 100644
index 00000000..f68cb2e7
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/FocusShader.js
@@ -0,0 +1,94 @@
+/**
+ * @module FocusShader
+ * @three_import import { FocusShader } from 'three/addons/shaders/FocusShader.js';
+ */
+
+/**
+ * Focus shader based on [PaintEffect postprocess from ro.me](http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js).
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const FocusShader = {
+
+ name: 'FocusShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'screenWidth': { value: 1024 },
+ 'screenHeight': { value: 1024 },
+ 'sampleDistance': { value: 0.94 },
+ 'waveFactor': { value: 0.00125 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float screenWidth;
+ uniform float screenHeight;
+ uniform float sampleDistance;
+ uniform float waveFactor;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 color, org, tmp, add;
+ float sample_dist, f;
+ vec2 vin;
+ vec2 uv = vUv;
+
+ add = color = org = texture2D( tDiffuse, uv );
+
+ vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );
+ sample_dist = dot( vin, vin ) * 2.0;
+
+ f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;
+
+ vec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );
+
+ add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );
+ if( tmp.b < color.b ) color = tmp;
+
+ add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );
+ if( tmp.b < color.b ) color = tmp;
+
+ add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );
+ if( tmp.b < color.b ) color = tmp;
+
+ add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );
+ if( tmp.b < color.b ) color = tmp;
+
+ add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );
+ if( tmp.b < color.b ) color = tmp;
+
+ add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );
+ if( tmp.b < color.b ) color = tmp;
+
+ add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );
+ if( tmp.b < color.b ) color = tmp;
+
+ color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );
+ color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );
+
+ gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );
+
+ }`
+
+};
+
+export { FocusShader };
diff --git a/demo/hero-content/vendor/addons/shaders/FreiChenShader.js b/demo/hero-content/vendor/addons/shaders/FreiChenShader.js
new file mode 100644
index 00000000..9912356c
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/FreiChenShader.js
@@ -0,0 +1,103 @@
+import {
+ Vector2
+} from 'three';
+
+/**
+ * @module FreiChenShader
+ * @three_import import { FreiChenShader } from 'three/addons/shaders/FreiChenShader.js';
+ */
+
+/**
+ * Edge Detection Shader using Frei-Chen filter.
+ * Based on {@link http://rastergrid.com/blog/2011/01/frei-chen-edge-detector}.
+ *
+ * aspect: vec2 of (1/width, 1/height)
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const FreiChenShader = {
+
+ name: 'FreiChenShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'aspect': { value: new Vector2( 512, 512 ) }
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ varying vec2 vUv;
+
+ uniform vec2 aspect;
+
+ vec2 texel = vec2( 1.0 / aspect.x, 1.0 / aspect.y );
+
+
+ mat3 G[9];
+
+ // hard coded matrix values!!!! as suggested in https://github.com/neilmendoza/ofxPostProcessing/blob/master/src/EdgePass.cpp#L45
+
+ const mat3 g0 = mat3( 0.3535533845424652, 0, -0.3535533845424652, 0.5, 0, -0.5, 0.3535533845424652, 0, -0.3535533845424652 );
+ const mat3 g1 = mat3( 0.3535533845424652, 0.5, 0.3535533845424652, 0, 0, 0, -0.3535533845424652, -0.5, -0.3535533845424652 );
+ const mat3 g2 = mat3( 0, 0.3535533845424652, -0.5, -0.3535533845424652, 0, 0.3535533845424652, 0.5, -0.3535533845424652, 0 );
+ const mat3 g3 = mat3( 0.5, -0.3535533845424652, 0, -0.3535533845424652, 0, 0.3535533845424652, 0, 0.3535533845424652, -0.5 );
+ const mat3 g4 = mat3( 0, -0.5, 0, 0.5, 0, 0.5, 0, -0.5, 0 );
+ const mat3 g5 = mat3( -0.5, 0, 0.5, 0, 0, 0, 0.5, 0, -0.5 );
+ const mat3 g6 = mat3( 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.6666666865348816, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204 );
+ const mat3 g7 = mat3( -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, 0.6666666865348816, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408 );
+ const mat3 g8 = mat3( 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408 );
+
+ void main(void)
+ {
+
+ G[0] = g0,
+ G[1] = g1,
+ G[2] = g2,
+ G[3] = g3,
+ G[4] = g4,
+ G[5] = g5,
+ G[6] = g6,
+ G[7] = g7,
+ G[8] = g8;
+
+ mat3 I;
+ float cnv[9];
+ vec3 sample;
+
+ /* fetch the 3x3 neighbourhood and use the RGB vector's length as intensity value */
+ for (float i=0.0; i<3.0; i++) {
+ for (float j=0.0; j<3.0; j++) {
+ sample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;
+ I[int(i)][int(j)] = length(sample);
+ }
+ }
+
+ /* calculate the convolution values for all the masks */
+ for (int i=0; i<9; i++) {
+ float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);
+ cnv[i] = dp3 * dp3;
+ }
+
+ float M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);
+ float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);
+
+ gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);
+ }`
+
+};
+
+export { FreiChenShader };
diff --git a/demo/hero-content/vendor/addons/shaders/GTAOShader.js b/demo/hero-content/vendor/addons/shaders/GTAOShader.js
new file mode 100644
index 00000000..4018f960
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/GTAOShader.js
@@ -0,0 +1,437 @@
+import {
+ DataTexture,
+ Matrix4,
+ RepeatWrapping,
+ Vector2,
+ Vector3,
+} from 'three';
+
+/**
+ * @module GTAOShader
+ * @three_import import { GTAOShader } from 'three/addons/shaders/GTAOShader.js';
+ */
+
+/**
+ * GTAO shader. Use by {@link GTAOPass}.
+ *
+ * References:
+ * - [Practical Realtime Strategies for Accurate Indirect Occlusion](https://iryoku.com/downloads/Practical-Realtime-Strategies-for-Accurate-Indirect-Occlusion.pdf).
+ * - [Horizon-Based Indirect Lighting (HBIL)](https://github.com/Patapom/GodComplex/blob/master/Tests/TestHBIL/2018%20Mayaux%20-%20Horizon-Based%20Indirect%20Lighting%20(HBIL).pdf)
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const GTAOShader = {
+
+ name: 'GTAOShader',
+
+ defines: {
+ PERSPECTIVE_CAMERA: 1,
+ SAMPLES: 16,
+ NORMAL_VECTOR_TYPE: 1,
+ SCREEN_SPACE_RADIUS: 0,
+ SCREEN_SPACE_RADIUS_SCALE: 100.0,
+ SCENE_CLIP_BOX: 0,
+ },
+
+ uniforms: {
+ tNormal: { value: null },
+ tDepth: { value: null },
+ tNoise: { value: null },
+ resolution: { value: new Vector2() },
+ cameraNear: { value: null },
+ cameraFar: { value: null },
+ cameraProjectionMatrix: { value: new Matrix4() },
+ cameraProjectionMatrixInverse: { value: new Matrix4() },
+ cameraWorldMatrix: { value: new Matrix4() },
+ radius: { value: 0.25 },
+ distanceExponent: { value: 1. },
+ thickness: { value: 1. },
+ distanceFallOff: { value: 1. },
+ scale: { value: 1. },
+ sceneBoxMin: { value: new Vector3( - 1, - 1, - 1 ) },
+ sceneBoxMax: { value: new Vector3( 1, 1, 1 ) },
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,
+
+ fragmentShader: /* glsl */`
+ varying vec2 vUv;
+ uniform highp sampler2D tNormal;
+ uniform highp sampler2D tDepth;
+ uniform sampler2D tNoise;
+ uniform vec2 resolution;
+ uniform float cameraNear;
+ uniform float cameraFar;
+ uniform mat4 cameraProjectionMatrix;
+ uniform mat4 cameraProjectionMatrixInverse;
+ uniform mat4 cameraWorldMatrix;
+ uniform float radius;
+ uniform float distanceExponent;
+ uniform float thickness;
+ uniform float distanceFallOff;
+ uniform float scale;
+ #if SCENE_CLIP_BOX == 1
+ uniform vec3 sceneBoxMin;
+ uniform vec3 sceneBoxMax;
+ #endif
+
+ #include
+ #include
+
+ #ifndef FRAGMENT_OUTPUT
+ #define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)
+ #endif
+
+ vec3 getViewPosition( const in vec2 screenPosition, const in float depth ) {
+ #ifdef USE_REVERSED_DEPTH_BUFFER
+ vec4 clipSpacePosition = vec4( vec2( screenPosition ) * 2.0 - 1.0, depth, 1.0 );
+ #else
+ vec4 clipSpacePosition = vec4( vec3( screenPosition, depth ) * 2.0 - 1.0, 1.0 );
+ #endif
+ vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
+ return viewSpacePosition.xyz / viewSpacePosition.w;
+ }
+
+ float getDepth(const vec2 uv) {
+ return textureLod(tDepth, uv.xy, 0.0).r;
+ }
+
+ float fetchDepth(const ivec2 uv) {
+ return texelFetch(tDepth, uv.xy, 0).r;
+ }
+
+ float getViewZ(const in float depth) {
+ #if PERSPECTIVE_CAMERA == 1
+ return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
+ #else
+ return orthographicDepthToViewZ(depth, cameraNear, cameraFar);
+ #endif
+ }
+
+ vec3 computeNormalFromDepth(const vec2 uv) {
+ vec2 size = vec2(textureSize(tDepth, 0));
+ ivec2 p = ivec2(uv * size);
+ float c0 = fetchDepth(p);
+ float l2 = fetchDepth(p - ivec2(2, 0));
+ float l1 = fetchDepth(p - ivec2(1, 0));
+ float r1 = fetchDepth(p + ivec2(1, 0));
+ float r2 = fetchDepth(p + ivec2(2, 0));
+ float b2 = fetchDepth(p - ivec2(0, 2));
+ float b1 = fetchDepth(p - ivec2(0, 1));
+ float t1 = fetchDepth(p + ivec2(0, 1));
+ float t2 = fetchDepth(p + ivec2(0, 2));
+ float dl = abs((2.0 * l1 - l2) - c0);
+ float dr = abs((2.0 * r1 - r2) - c0);
+ float db = abs((2.0 * b1 - b2) - c0);
+ float dt = abs((2.0 * t1 - t2) - c0);
+ vec3 ce = getViewPosition(uv, c0).xyz;
+ vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
+ vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
+ return normalize(cross(dpdx, dpdy));
+ }
+
+ vec3 getViewNormal(const vec2 uv) {
+ #if NORMAL_VECTOR_TYPE == 2
+ return normalize(textureLod(tNormal, uv, 0.).rgb);
+ #elif NORMAL_VECTOR_TYPE == 1
+ return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
+ #else
+ return computeNormalFromDepth(uv);
+ #endif
+ }
+
+ vec3 getSceneUvAndDepth(vec3 sampleViewPos) {
+ vec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);
+ vec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;
+ float sampleSceneDepth = getDepth(sampleUv);
+ return vec3(sampleUv, sampleSceneDepth);
+ }
+
+ void main() {
+ float depth = getDepth(vUv.xy);
+
+ #ifdef USE_REVERSED_DEPTH_BUFFER
+ if (depth <= 0.0) {
+ discard;
+ return;
+ }
+ #else
+ if (depth >= 1.0) {
+ discard;
+ return;
+ }
+ #endif
+
+ vec3 viewPos = getViewPosition(vUv, depth);
+ vec3 viewNormal = getViewNormal(vUv);
+
+ float radiusToUse = radius;
+ float distanceFalloffToUse = thickness;
+ #if SCREEN_SPACE_RADIUS == 1
+ float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;
+ radiusToUse *= radiusScale;
+ distanceFalloffToUse *= radiusScale;
+ #endif
+
+ #if SCENE_CLIP_BOX == 1
+ vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;
+ float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));
+ if (boxDistance > radiusToUse) {
+ discard;
+ return;
+ }
+ #endif
+
+ vec2 noiseResolution = vec2(textureSize(tNoise, 0));
+ vec2 noiseUv = vUv * resolution / noiseResolution;
+ vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
+ vec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;
+ vec3 tangent = normalize(vec3(randomVec.xy, 0.));
+ vec3 bitangent = vec3(-tangent.y, tangent.x, 0.);
+ mat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));
+
+ const int DIRECTIONS = SAMPLES < 30 ? 3 : 5;
+ const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;
+ float ao = 0.0;
+ for (int i = 0; i < DIRECTIONS; ++i) {
+
+ float angle = float(i) / float(DIRECTIONS) * PI;
+ vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w);
+ sampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);
+
+ #if PERSPECTIVE_CAMERA == 1
+ vec3 viewDir = normalize(-viewPos.xyz);
+ #else
+ vec3 viewDir = vec3(0., 0., 1.);
+ #endif
+ vec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));
+ vec3 sliceTangent = cross(sliceBitangent, viewDir);
+ vec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));
+
+ vec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);
+ vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));
+
+ for (int j = 0; j < STEPS; ++j) {
+ vec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);
+
+ vec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);
+ vec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
+ vec3 viewDelta = sampleSceneViewPos - viewPos;
+ if (abs(viewDelta.z) < thickness) {
+ float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
+ cosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));
+ }
+
+ sampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);
+ sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
+ viewDelta = sampleSceneViewPos - viewPos;
+ if (abs(viewDelta.z) < thickness) {
+ float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
+ cosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));
+ }
+ }
+
+ vec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);
+ float nx = dot(normalInSlice, sliceTangent);
+ float ny = dot(normalInSlice, viewDir);
+ float nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);
+ float nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);
+ float occlusion = nx * nxb + ny * nyb;
+ ao += occlusion;
+ }
+
+ ao = clamp(ao / float(DIRECTIONS), 0., 1.);
+ #if SCENE_CLIP_BOX == 1
+ ao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));
+ #endif
+ ao = pow(ao, scale);
+
+ gl_FragColor = FRAGMENT_OUTPUT;
+ }`
+
+};
+
+/**
+ * GTAO depth shader. Use by {@link GTAOPass}.
+ *
+ * @constant
+ * @type {Object}
+ */
+const GTAODepthShader = {
+
+ name: 'GTAODepthShader',
+
+ defines: {
+ PERSPECTIVE_CAMERA: 1
+ },
+
+ uniforms: {
+ tDepth: { value: null },
+ cameraNear: { value: null },
+ cameraFar: { value: null },
+ },
+
+ vertexShader: /* glsl */`
+ varying vec2 vUv;
+
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,
+
+ fragmentShader: /* glsl */`
+ uniform sampler2D tDepth;
+ uniform float cameraNear;
+ uniform float cameraFar;
+ varying vec2 vUv;
+
+ #include
+
+ float getLinearDepth( const in vec2 screenPosition ) {
+ #if PERSPECTIVE_CAMERA == 1
+ float fragCoordZ = texture2D( tDepth, screenPosition ).x;
+ float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
+ return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
+ #else
+ return texture2D( tDepth, screenPosition ).x;
+ #endif
+ }
+
+ void main() {
+ float depth = getLinearDepth( vUv );
+ gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
+
+ }`
+
+};
+
+/**
+ * GTAO blend shader. Use by {@link GTAOPass}.
+ *
+ * @constant
+ * @type {Object}
+ */
+const GTAOBlendShader = {
+
+ name: 'GTAOBlendShader',
+
+ uniforms: {
+ tDiffuse: { value: null },
+ intensity: { value: 1.0 }
+ },
+
+ vertexShader: /* glsl */`
+ varying vec2 vUv;
+
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,
+
+ fragmentShader: /* glsl */`
+ uniform float intensity;
+ uniform sampler2D tDiffuse;
+ varying vec2 vUv;
+
+ void main() {
+ vec4 texel = texture2D( tDiffuse, vUv );
+ gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);
+ }`
+
+};
+
+
+function generateMagicSquareNoise( size = 5 ) {
+
+ const noiseSize = Math.floor( size ) % 2 === 0 ? Math.floor( size ) + 1 : Math.floor( size );
+ const magicSquare = generateMagicSquare( noiseSize );
+ const noiseSquareSize = magicSquare.length;
+ const data = new Uint8Array( noiseSquareSize * 4 );
+
+ for ( let inx = 0; inx < noiseSquareSize; ++ inx ) {
+
+ const iAng = magicSquare[ inx ];
+ const angle = ( 2 * Math.PI * iAng ) / noiseSquareSize;
+ const randomVec = new Vector3(
+ Math.cos( angle ),
+ Math.sin( angle ),
+ 0
+ ).normalize();
+ data[ inx * 4 ] = ( randomVec.x * 0.5 + 0.5 ) * 255;
+ data[ inx * 4 + 1 ] = ( randomVec.y * 0.5 + 0.5 ) * 255;
+ data[ inx * 4 + 2 ] = 127;
+ data[ inx * 4 + 3 ] = 255;
+
+ }
+
+ const noiseTexture = new DataTexture( data, noiseSize, noiseSize );
+ noiseTexture.wrapS = RepeatWrapping;
+ noiseTexture.wrapT = RepeatWrapping;
+ noiseTexture.needsUpdate = true;
+
+ return noiseTexture;
+
+}
+
+function generateMagicSquare( size ) {
+
+ const noiseSize = Math.floor( size ) % 2 === 0 ? Math.floor( size ) + 1 : Math.floor( size );
+ const noiseSquareSize = noiseSize * noiseSize;
+ const magicSquare = Array( noiseSquareSize ).fill( 0 );
+ let i = Math.floor( noiseSize / 2 );
+ let j = noiseSize - 1;
+
+ for ( let num = 1; num <= noiseSquareSize; ) {
+
+ if ( i === - 1 && j === noiseSize ) {
+
+ j = noiseSize - 2;
+ i = 0;
+
+ } else {
+
+ if ( j === noiseSize ) {
+
+ j = 0;
+
+ }
+
+ if ( i < 0 ) {
+
+ i = noiseSize - 1;
+
+ }
+
+ }
+
+ if ( magicSquare[ i * noiseSize + j ] !== 0 ) {
+
+ j -= 2;
+ i ++;
+ continue;
+
+ } else {
+
+ magicSquare[ i * noiseSize + j ] = num ++;
+
+ }
+
+ j ++;
+ i --;
+
+ }
+
+ return magicSquare;
+
+}
+
+
+export { generateMagicSquareNoise, GTAOShader, GTAODepthShader, GTAOBlendShader };
diff --git a/demo/hero-content/vendor/addons/shaders/GammaCorrectionShader.js b/demo/hero-content/vendor/addons/shaders/GammaCorrectionShader.js
new file mode 100644
index 00000000..3f5c8a61
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/GammaCorrectionShader.js
@@ -0,0 +1,52 @@
+/**
+ * @module GammaCorrectionShader
+ * @three_import import { GammaCorrectionShader } from 'three/addons/shaders/GammaCorrectionShader.js';
+ */
+
+/**
+ * Gamma Correction Shader
+ *
+ * References:
+ * - {@link http://en.wikipedia.org/wiki/gamma_correction}.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const GammaCorrectionShader = {
+
+ name: 'GammaCorrectionShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 tex = texture2D( tDiffuse, vUv );
+
+ gl_FragColor = sRGBTransferOETF( tex );
+
+ }`
+
+};
+
+export { GammaCorrectionShader };
diff --git a/demo/hero-content/vendor/addons/shaders/HalftoneShader.js b/demo/hero-content/vendor/addons/shaders/HalftoneShader.js
new file mode 100644
index 00000000..afafea3a
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/HalftoneShader.js
@@ -0,0 +1,332 @@
+/**
+ * @module HalftoneShader
+ * @three_import import { HalftoneShader } from 'three/addons/shaders/HalftoneShader.js';
+ */
+
+/**
+ * RGB Halftone shader.
+ *
+ * Used by {@link HalftonePass}.
+ *
+ * Shape (1 = Dot, 2 = Ellipse, 3 = Line, 4 = Square, 5 = Diamond)
+ * Blending Mode (1 = Linear, 2 = Multiply, 3 = Add, 4 = Lighter, 5 = Darker)
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const HalftoneShader = {
+
+ name: 'HalftoneShader',
+
+ uniforms: {
+ 'tDiffuse': { value: null },
+ 'shape': { value: 1 },
+ 'radius': { value: 4 },
+ 'rotateR': { value: Math.PI / 12 * 1 },
+ 'rotateG': { value: Math.PI / 12 * 2 },
+ 'rotateB': { value: Math.PI / 12 * 3 },
+ 'scatter': { value: 0 },
+ 'width': { value: 1 },
+ 'height': { value: 1 },
+ 'blending': { value: 1 },
+ 'blendingMode': { value: 1 },
+ 'greyscale': { value: false },
+ 'disable': { value: false }
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUV;
+
+ void main() {
+
+ vUV = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ #define SQRT2_MINUS_ONE 0.41421356
+ #define SQRT2_HALF_MINUS_ONE 0.20710678
+ #define PI 3.14159265
+ #define PI2 6.28318531
+ #define SHAPE_DOT 1
+ #define SHAPE_ELLIPSE 2
+ #define SHAPE_LINE 3
+ #define SHAPE_SQUARE 4
+ #define SHAPE_DIAMOND 5
+ #define BLENDING_LINEAR 1
+ #define BLENDING_MULTIPLY 2
+ #define BLENDING_ADD 3
+ #define BLENDING_LIGHTER 4
+ #define BLENDING_DARKER 5
+ uniform sampler2D tDiffuse;
+ uniform float radius;
+ uniform float rotateR;
+ uniform float rotateG;
+ uniform float rotateB;
+ uniform float scatter;
+ uniform float width;
+ uniform float height;
+ uniform int shape;
+ uniform bool disable;
+ uniform float blending;
+ uniform int blendingMode;
+ varying vec2 vUV;
+ uniform bool greyscale;
+ const int samples = 8;
+
+ float blend( float a, float b, float t ) {
+
+ // linear blend
+ return a * ( 1.0 - t ) + b * t;
+
+ }
+
+ float hypot( float x, float y ) {
+
+ // vector magnitude
+ return sqrt( x * x + y * y );
+
+ }
+
+ float rand( vec2 seed ){
+
+ // get pseudo-random number
+ return fract( sin( dot( seed.xy, vec2( 12.9898, 78.233 ) ) ) * 43758.5453 );
+
+ }
+
+ float distanceToDotRadius( float channel, vec2 coord, vec2 normal, vec2 p, float angle, float rad_max ) {
+
+ // apply shape-specific transforms
+ float dist = hypot( coord.x - p.x, coord.y - p.y );
+ float rad = channel;
+
+ if ( shape == SHAPE_DOT ) {
+
+ rad = pow( abs( rad ), 1.125 ) * rad_max;
+
+ } else if ( shape == SHAPE_ELLIPSE ) {
+
+ rad = pow( abs( rad ), 1.125 ) * rad_max;
+
+ if ( dist != 0.0 ) {
+ float dot_p = abs( ( p.x - coord.x ) / dist * normal.x + ( p.y - coord.y ) / dist * normal.y );
+ dist = ( dist * ( 1.0 - SQRT2_HALF_MINUS_ONE ) ) + dot_p * dist * SQRT2_MINUS_ONE;
+ }
+
+ } else if ( shape == SHAPE_LINE ) {
+
+ rad = pow( abs( rad ), 1.5) * rad_max;
+ float dot_p = ( p.x - coord.x ) * normal.x + ( p.y - coord.y ) * normal.y;
+ dist = hypot( normal.x * dot_p, normal.y * dot_p );
+
+ } else if ( shape == SHAPE_SQUARE ) {
+
+ float theta = atan( p.y - coord.y, p.x - coord.x ) - angle;
+ float sin_t = abs( sin( theta ) );
+ float cos_t = abs( cos( theta ) );
+ rad = pow( abs( rad ), 1.4 );
+ rad = rad_max * ( rad + ( ( sin_t > cos_t ) ? rad - sin_t * rad : rad - cos_t * rad ) );
+
+ } else if ( shape == SHAPE_DIAMOND ) {
+
+ float angle45 = PI / 4.0;
+ float theta = atan( p.y - coord.y, p.x - coord.x ) - angle - angle45;
+ float sin_t = abs( sin( theta ) );
+ float cos_t = abs( cos( theta ) );
+ rad = pow( abs( rad ), 1.4 );
+ rad = rad_max * ( rad + ( ( sin_t > cos_t ) ? rad - sin_t * rad : rad - cos_t * rad ) );
+
+ }
+
+ return rad - dist;
+
+ }
+
+ struct Cell {
+
+ // grid sample positions
+ vec2 normal;
+ vec2 p1;
+ vec2 p2;
+ vec2 p3;
+ vec2 p4;
+ float samp2;
+ float samp1;
+ float samp3;
+ float samp4;
+
+ };
+
+ vec4 getSample( vec2 point ) {
+
+ // multi-sampled point
+ vec4 tex = texture2D( tDiffuse, vec2( point.x / width, point.y / height ) );
+ float base = rand( vec2( floor( point.x ), floor( point.y ) ) ) * PI2;
+ float step = PI2 / float( samples );
+ float dist = radius * 0.66;
+
+ for ( int i = 0; i < samples; ++i ) {
+
+ float r = base + step * float( i );
+ vec2 coord = point + vec2( cos( r ) * dist, sin( r ) * dist );
+ tex += texture2D( tDiffuse, vec2( coord.x / width, coord.y / height ) );
+
+ }
+
+ tex /= float( samples ) + 1.0;
+ return tex;
+
+ }
+
+ float getDotColour( Cell c, vec2 p, int channel, float angle, float aa ) {
+
+ // get colour for given point
+ float dist_c_1, dist_c_2, dist_c_3, dist_c_4, res;
+
+ if ( channel == 0 ) {
+
+ c.samp1 = getSample( c.p1 ).r;
+ c.samp2 = getSample( c.p2 ).r;
+ c.samp3 = getSample( c.p3 ).r;
+ c.samp4 = getSample( c.p4 ).r;
+
+ } else if (channel == 1) {
+
+ c.samp1 = getSample( c.p1 ).g;
+ c.samp2 = getSample( c.p2 ).g;
+ c.samp3 = getSample( c.p3 ).g;
+ c.samp4 = getSample( c.p4 ).g;
+
+ } else {
+
+ c.samp1 = getSample( c.p1 ).b;
+ c.samp3 = getSample( c.p3 ).b;
+ c.samp2 = getSample( c.p2 ).b;
+ c.samp4 = getSample( c.p4 ).b;
+
+ }
+
+ dist_c_1 = distanceToDotRadius( c.samp1, c.p1, c.normal, p, angle, radius );
+ dist_c_2 = distanceToDotRadius( c.samp2, c.p2, c.normal, p, angle, radius );
+ dist_c_3 = distanceToDotRadius( c.samp3, c.p3, c.normal, p, angle, radius );
+ dist_c_4 = distanceToDotRadius( c.samp4, c.p4, c.normal, p, angle, radius );
+ res = ( dist_c_1 > 0.0 ) ? clamp( dist_c_1 / aa, 0.0, 1.0 ) : 0.0;
+ res += ( dist_c_2 > 0.0 ) ? clamp( dist_c_2 / aa, 0.0, 1.0 ) : 0.0;
+ res += ( dist_c_3 > 0.0 ) ? clamp( dist_c_3 / aa, 0.0, 1.0 ) : 0.0;
+ res += ( dist_c_4 > 0.0 ) ? clamp( dist_c_4 / aa, 0.0, 1.0 ) : 0.0;
+ res = clamp( res, 0.0, 1.0 );
+
+ return res;
+
+ }
+
+ Cell getReferenceCell( vec2 p, vec2 origin, float grid_angle, float step ) {
+
+ // get containing cell
+ Cell c;
+
+ // calc grid
+ vec2 n = vec2( cos( grid_angle ), sin( grid_angle ) );
+ float threshold = step * 0.5;
+ float dot_normal = n.x * ( p.x - origin.x ) + n.y * ( p.y - origin.y );
+ float dot_line = -n.y * ( p.x - origin.x ) + n.x * ( p.y - origin.y );
+ vec2 offset = vec2( n.x * dot_normal, n.y * dot_normal );
+ float offset_normal = mod( hypot( offset.x, offset.y ), step );
+ float normal_dir = ( dot_normal < 0.0 ) ? 1.0 : -1.0;
+ float normal_scale = ( ( offset_normal < threshold ) ? -offset_normal : step - offset_normal ) * normal_dir;
+ float offset_line = mod( hypot( ( p.x - offset.x ) - origin.x, ( p.y - offset.y ) - origin.y ), step );
+ float line_dir = ( dot_line < 0.0 ) ? 1.0 : -1.0;
+ float line_scale = ( ( offset_line < threshold ) ? -offset_line : step - offset_line ) * line_dir;
+
+ // get closest corner
+ c.normal = n;
+ c.p1.x = p.x - n.x * normal_scale + n.y * line_scale;
+ c.p1.y = p.y - n.y * normal_scale - n.x * line_scale;
+
+ // scatter
+ if ( scatter != 0.0 ) {
+
+ float off_mag = scatter * threshold * 0.5;
+ float off_angle = rand( vec2( floor( c.p1.x ), floor( c.p1.y ) ) ) * PI2;
+ c.p1.x += cos( off_angle ) * off_mag;
+ c.p1.y += sin( off_angle ) * off_mag;
+
+ }
+
+ // find corners
+ float normal_step = normal_dir * ( ( offset_normal < threshold ) ? step : -step );
+ float line_step = line_dir * ( ( offset_line < threshold ) ? step : -step );
+ c.p2.x = c.p1.x - n.x * normal_step;
+ c.p2.y = c.p1.y - n.y * normal_step;
+ c.p3.x = c.p1.x + n.y * line_step;
+ c.p3.y = c.p1.y - n.x * line_step;
+ c.p4.x = c.p1.x - n.x * normal_step + n.y * line_step;
+ c.p4.y = c.p1.y - n.y * normal_step - n.x * line_step;
+
+ return c;
+
+ }
+
+ float blendColour( float a, float b, float t ) {
+
+ // blend colours
+ if ( blendingMode == BLENDING_LINEAR ) {
+ return blend( a, b, 1.0 - t );
+ } else if ( blendingMode == BLENDING_ADD ) {
+ return blend( a, min( 1.0, a + b ), t );
+ } else if ( blendingMode == BLENDING_MULTIPLY ) {
+ return blend( a, max( 0.0, a * b ), t );
+ } else if ( blendingMode == BLENDING_LIGHTER ) {
+ return blend( a, max( a, b ), t );
+ } else if ( blendingMode == BLENDING_DARKER ) {
+ return blend( a, min( a, b ), t );
+ } else {
+ return blend( a, b, 1.0 - t );
+ }
+
+ }
+
+ void main() {
+
+ if ( ! disable ) {
+
+ // setup
+ vec2 p = vec2( vUV.x * width, vUV.y * height );
+ vec2 origin = vec2( 0, 0 );
+ float aa = ( radius < 2.5 ) ? radius * 0.5 : 1.25;
+
+ // get channel samples
+ Cell cell_r = getReferenceCell( p, origin, rotateR, radius );
+ Cell cell_g = getReferenceCell( p, origin, rotateG, radius );
+ Cell cell_b = getReferenceCell( p, origin, rotateB, radius );
+ float r = getDotColour( cell_r, p, 0, rotateR, aa );
+ float g = getDotColour( cell_g, p, 1, rotateG, aa );
+ float b = getDotColour( cell_b, p, 2, rotateB, aa );
+
+ // blend with original
+ vec4 colour = texture2D( tDiffuse, vUV );
+ r = blendColour( r, colour.r, blending );
+ g = blendColour( g, colour.g, blending );
+ b = blendColour( b, colour.b, blending );
+
+ if ( greyscale ) {
+ r = g = b = (r + b + g) / 3.0;
+ }
+
+ gl_FragColor = vec4( r, g, b, 1.0 );
+
+ } else {
+
+ gl_FragColor = texture2D( tDiffuse, vUV );
+
+ }
+
+ }`
+
+};
+
+export { HalftoneShader };
diff --git a/demo/hero-content/vendor/addons/shaders/HorizontalBlurShader.js b/demo/hero-content/vendor/addons/shaders/HorizontalBlurShader.js
new file mode 100644
index 00000000..46c7892a
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/HorizontalBlurShader.js
@@ -0,0 +1,68 @@
+/**
+ * @module HorizontalBlurShader
+ * @three_import import { HorizontalBlurShader } from 'three/addons/shaders/HorizontalBlurShader.js';
+ */
+
+/**
+ * Two pass Gaussian blur filter (horizontal and vertical blur shaders).
+ *
+ * References:
+ * - {@link http://www.cake23.de/traveling-wavefronts-lit-up.html}.
+ *
+ * - 9 samples per pass
+ * - standard deviation 2.7
+ * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const HorizontalBlurShader = {
+
+ name: 'HorizontalBlurShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'h': { value: 1.0 / 512.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform float h;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 sum = vec4( 0.0 );
+
+ sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;
+ sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;
+ sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;
+ sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;
+ sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;
+ sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;
+ sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;
+ sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;
+
+ gl_FragColor = sum;
+
+ }`
+
+};
+
+export { HorizontalBlurShader };
diff --git a/demo/hero-content/vendor/addons/shaders/HorizontalTiltShiftShader.js b/demo/hero-content/vendor/addons/shaders/HorizontalTiltShiftShader.js
new file mode 100644
index 00000000..2d4a9026
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/HorizontalTiltShiftShader.js
@@ -0,0 +1,70 @@
+/**
+ * @module HorizontalTiltShiftShader
+ * @three_import import { HorizontalTiltShiftShader } from 'three/addons/shaders/HorizontalTiltShiftShader.js';
+ */
+
+/**
+ * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position.
+ *
+ * - 9 samples per pass
+ * - standard deviation 2.7
+ * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
+ * - "r" parameter control where "focused" horizontal line lies
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const HorizontalTiltShiftShader = {
+
+ name: 'HorizontalTiltShiftShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'h': { value: 1.0 / 512.0 },
+ 'r': { value: 0.35 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform float h;
+ uniform float r;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 sum = vec4( 0.0 );
+
+ float hh = h * abs( r - vUv.y );
+
+ sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * hh, vUv.y ) ) * 0.051;
+ sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * hh, vUv.y ) ) * 0.0918;
+ sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * hh, vUv.y ) ) * 0.12245;
+ sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * hh, vUv.y ) ) * 0.1531;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;
+ sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * hh, vUv.y ) ) * 0.1531;
+ sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * hh, vUv.y ) ) * 0.12245;
+ sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * hh, vUv.y ) ) * 0.0918;
+ sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * hh, vUv.y ) ) * 0.051;
+
+ gl_FragColor = sum;
+
+ }`
+
+};
+
+export { HorizontalTiltShiftShader };
diff --git a/demo/hero-content/vendor/addons/shaders/HueSaturationShader.js b/demo/hero-content/vendor/addons/shaders/HueSaturationShader.js
new file mode 100644
index 00000000..08bf3cd6
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/HueSaturationShader.js
@@ -0,0 +1,74 @@
+/**
+ * @module HueSaturationShader
+ * @three_import import { HueSaturationShader } from 'three/addons/shaders/HueSaturationShader.js';
+ */
+
+/**
+ * Hue and saturation adjustment, {@link https://github.com/evanw/glfx.js}.
+ *
+ * hue: -1 to 1 (-1 is 180 degrees in the negative direction, 0 is no change, etc.
+ * saturation: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const HueSaturationShader = {
+
+ name: 'HueSaturationShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'hue': { value: 0 },
+ 'saturation': { value: 0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform float hue;
+ uniform float saturation;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ gl_FragColor = texture2D( tDiffuse, vUv );
+
+ // hue
+ float angle = hue * 3.14159265;
+ float s = sin(angle), c = cos(angle);
+ vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;
+ float len = length(gl_FragColor.rgb);
+ gl_FragColor.rgb = vec3(
+ dot(gl_FragColor.rgb, weights.xyz),
+ dot(gl_FragColor.rgb, weights.zxy),
+ dot(gl_FragColor.rgb, weights.yzx)
+ );
+
+ // saturation
+ float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;
+ if (saturation > 0.0) {
+ gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - saturation));
+ } else {
+ gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-saturation);
+ }
+
+ }`
+
+};
+
+export { HueSaturationShader };
diff --git a/demo/hero-content/vendor/addons/shaders/KaleidoShader.js b/demo/hero-content/vendor/addons/shaders/KaleidoShader.js
new file mode 100644
index 00000000..c9e14078
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/KaleidoShader.js
@@ -0,0 +1,65 @@
+/**
+ * @module KaleidoShader
+ * @three_import import { KaleidoShader } from 'three/addons/shaders/KaleidoShader.js';
+ */
+
+/**
+ * Kaleidoscope Shader.
+ * Radial reflection around center point
+ * Ported from: {@link http://pixelshaders.com/editor/}
+ * by [Toby Schachman](http://tobyschachman.com/)
+ *
+ * sides: number of reflections
+ * angle: initial angle in radians
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const KaleidoShader = {
+
+ name: 'KaleidoShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'sides': { value: 6.0 },
+ 'angle': { value: 0.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform float sides;
+ uniform float angle;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec2 p = vUv - 0.5;
+ float r = length(p);
+ float a = atan(p.y, p.x) + angle;
+ float tau = 2. * 3.1416 ;
+ a = mod(a, tau/sides);
+ a = abs(a - tau/sides/2.) ;
+ p = r * vec2(cos(a), sin(a));
+ vec4 color = texture2D(tDiffuse, p + 0.5);
+ gl_FragColor = color;
+
+ }`
+
+};
+
+export { KaleidoShader };
diff --git a/demo/hero-content/vendor/addons/shaders/LuminosityHighPassShader.js b/demo/hero-content/vendor/addons/shaders/LuminosityHighPassShader.js
new file mode 100644
index 00000000..16ff4e69
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/LuminosityHighPassShader.js
@@ -0,0 +1,68 @@
+import {
+ Color
+} from 'three';
+
+/**
+ * @module LuminosityHighPassShader
+ * @three_import import { LuminosityHighPassShader } from 'three/addons/shaders/LuminosityHighPassShader.js';
+ */
+
+/**
+ * Luminosity high pass shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const LuminosityHighPassShader = {
+
+ name: 'LuminosityHighPassShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'luminosityThreshold': { value: 1.0 },
+ 'smoothWidth': { value: 1.0 },
+ 'defaultColor': { value: new Color( 0x000000 ) },
+ 'defaultOpacity': { value: 0.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform vec3 defaultColor;
+ uniform float defaultOpacity;
+ uniform float luminosityThreshold;
+ uniform float smoothWidth;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 texel = texture2D( tDiffuse, vUv );
+
+ float v = luminance( texel.xyz );
+
+ vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
+
+ float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
+
+ gl_FragColor = mix( outputColor, texel, alpha );
+
+ }`
+
+};
+
+export { LuminosityHighPassShader };
diff --git a/demo/hero-content/vendor/addons/shaders/LuminosityShader.js b/demo/hero-content/vendor/addons/shaders/LuminosityShader.js
new file mode 100644
index 00000000..6e2ef610
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/LuminosityShader.js
@@ -0,0 +1,54 @@
+/**
+ * @module LuminosityShader
+ * @three_import import { LuminosityShader } from 'three/addons/shaders/LuminosityShader.js';
+ */
+
+/**
+ * Luminosity shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const LuminosityShader = {
+
+ name: 'LuminosityShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ #include
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 texel = texture2D( tDiffuse, vUv );
+
+ float l = luminance( texel.rgb );
+
+ gl_FragColor = vec4( l, l, l, texel.w );
+
+ }`
+
+};
+
+export { LuminosityShader };
diff --git a/demo/hero-content/vendor/addons/shaders/MirrorShader.js b/demo/hero-content/vendor/addons/shaders/MirrorShader.js
new file mode 100644
index 00000000..7850e0f2
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/MirrorShader.js
@@ -0,0 +1,62 @@
+/**
+ * @module MirrorShader
+ * @three_import import { MirrorShader } from 'three/addons/shaders/MirrorShader.js';
+ */
+
+/**
+ * Copies half the input to the other half.
+ *
+ * side: side of input to mirror (0 = left, 1 = right, 2 = top, 3 = bottom).
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const MirrorShader = {
+
+ name: 'MirrorShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'side': { value: 1 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform int side;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec2 p = vUv;
+ if (side == 0){
+ if (p.x > 0.5) p.x = 1.0 - p.x;
+ }else if (side == 1){
+ if (p.x < 0.5) p.x = 1.0 - p.x;
+ }else if (side == 2){
+ if (p.y < 0.5) p.y = 1.0 - p.y;
+ }else if (side == 3){
+ if (p.y > 0.5) p.y = 1.0 - p.y;
+ }
+ vec4 color = texture2D(tDiffuse, p);
+ gl_FragColor = color;
+
+ }`
+
+};
+
+export { MirrorShader };
diff --git a/demo/hero-content/vendor/addons/shaders/NormalMapShader.js b/demo/hero-content/vendor/addons/shaders/NormalMapShader.js
new file mode 100644
index 00000000..b600c551
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/NormalMapShader.js
@@ -0,0 +1,60 @@
+import {
+ Vector2
+} from 'three';
+
+/**
+ * @module NormalMapShader
+ * @three_import import { NormalMapShader } from 'three/addons/shaders/NormalMapShader.js';
+ */
+
+/**
+ * Normal map shader, compute normals from heightmap.
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const NormalMapShader = {
+
+ name: 'NormalMapShader',
+
+ uniforms: {
+
+ 'heightMap': { value: null },
+ 'resolution': { value: new Vector2( 512, 512 ) },
+ 'scale': { value: new Vector2( 1, 1 ) },
+ 'height': { value: 0.05 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float height;
+ uniform vec2 resolution;
+ uniform sampler2D heightMap;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ float val = texture2D( heightMap, vUv ).x;
+
+ float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;
+ float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;
+
+ gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );
+
+ }`
+
+};
+
+export { NormalMapShader };
diff --git a/demo/hero-content/vendor/addons/shaders/OutputShader.js b/demo/hero-content/vendor/addons/shaders/OutputShader.js
new file mode 100644
index 00000000..5f257829
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/OutputShader.js
@@ -0,0 +1,103 @@
+/**
+ * @module OutputShader
+ * @three_import import { OutputShader } from 'three/addons/shaders/OutputShader.js';
+ */
+
+/**
+ * Performs tone mapping and color space conversion for
+ * FX workflows.
+ *
+ * Used by {@link OutputPass}.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const OutputShader = {
+
+ name: 'OutputShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'toneMappingExposure': { value: 1 }
+
+ },
+
+ vertexShader: /* glsl */`
+ precision highp float;
+
+ uniform mat4 modelViewMatrix;
+ uniform mat4 projectionMatrix;
+
+ attribute vec3 position;
+ attribute vec2 uv;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ precision highp float;
+
+ uniform sampler2D tDiffuse;
+
+ #include
+ #include
+
+ varying vec2 vUv;
+
+ void main() {
+
+ gl_FragColor = texture2D( tDiffuse, vUv );
+
+ // tone mapping
+
+ #ifdef LINEAR_TONE_MAPPING
+
+ gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
+
+ #elif defined( REINHARD_TONE_MAPPING )
+
+ gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
+
+ #elif defined( CINEON_TONE_MAPPING )
+
+ gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
+
+ #elif defined( ACES_FILMIC_TONE_MAPPING )
+
+ gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
+
+ #elif defined( AGX_TONE_MAPPING )
+
+ gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
+
+ #elif defined( NEUTRAL_TONE_MAPPING )
+
+ gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
+
+ #elif defined( CUSTOM_TONE_MAPPING )
+
+ gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
+
+ #endif
+
+ // color space
+
+ #ifdef SRGB_TRANSFER
+
+ gl_FragColor = sRGBTransferOETF( gl_FragColor );
+
+ #endif
+
+ }`
+
+};
+
+export { OutputShader };
diff --git a/demo/hero-content/vendor/addons/shaders/PoissonDenoiseShader.js b/demo/hero-content/vendor/addons/shaders/PoissonDenoiseShader.js
new file mode 100644
index 00000000..210dd8ad
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/PoissonDenoiseShader.js
@@ -0,0 +1,230 @@
+import {
+ Matrix4,
+ Vector2,
+ Vector3,
+} from 'three';
+
+/**
+ * @module PoissonDenoiseShader
+ * @three_import import { PoissonDenoiseShader } from 'three/addons/shaders/PoissonDenoiseShader.js';
+ */
+
+/**
+ * Poisson Denoise Shader.
+ *
+ * References:
+ * - [Self-Supervised Poisson-Gaussian Denoising](https://openaccess.thecvf.com/content/WACV2021/papers/Khademi_Self-Supervised_Poisson-Gaussian_Denoising_WACV_2021_paper.pdf).
+ * - [Poisson2Sparse: Self-Supervised Poisson Denoising From a Single Image](https://arxiv.org/pdf/2206.01856.pdf)
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const PoissonDenoiseShader = {
+
+ name: 'PoissonDenoiseShader',
+
+ defines: {
+ 'SAMPLES': 16,
+ 'SAMPLE_VECTORS': generatePdSamplePointInitializer( 16, 2, 1 ),
+ 'NORMAL_VECTOR_TYPE': 1,
+ },
+
+ uniforms: {
+ 'tDiffuse': { value: null },
+ 'tNormal': { value: null },
+ 'tDepth': { value: null },
+ 'tNoise': { value: null },
+ 'resolution': { value: new Vector2() },
+ 'cameraProjectionMatrixInverse': { value: new Matrix4() },
+ 'lumaPhi': { value: 5. },
+ 'depthPhi': { value: 5. },
+ 'normalPhi': { value: 5. },
+ 'radius': { value: 4. },
+ 'index': { value: 0 }
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ uniform sampler2D tDiffuse;
+ uniform sampler2D tNormal;
+ uniform sampler2D tDepth;
+ uniform sampler2D tNoise;
+ uniform vec2 resolution;
+ uniform mat4 cameraProjectionMatrixInverse;
+ uniform float lumaPhi;
+ uniform float depthPhi;
+ uniform float normalPhi;
+ uniform float radius;
+ uniform int index;
+
+ #include
+ #include
+
+ #ifndef SAMPLE_LUMINANCE
+ #define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)
+ #endif
+
+ #ifndef FRAGMENT_OUTPUT
+ #define FRAGMENT_OUTPUT vec4(denoised, 1.)
+ #endif
+
+ float getLuminance(const in vec3 a) {
+ return SAMPLE_LUMINANCE;
+ }
+
+ const vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;
+
+ vec3 getViewPosition( const in vec2 screenPosition, const in float depth ) {
+ #ifdef USE_REVERSED_DEPTH_BUFFER
+ vec4 clipSpacePosition = vec4( vec2( screenPosition ) * 2.0 - 1.0, depth, 1.0 );
+ #else
+ vec4 clipSpacePosition = vec4( vec3( screenPosition, depth ) * 2.0 - 1.0, 1.0 );
+ #endif
+ vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
+ return viewSpacePosition.xyz / viewSpacePosition.w;
+ }
+
+ float getDepth(const vec2 uv) {
+ return textureLod(tDepth, uv.xy, 0.0).r;
+ }
+
+ float fetchDepth(const ivec2 uv) {
+ return texelFetch(tDepth, uv.xy, 0).r;
+ }
+
+ vec3 computeNormalFromDepth(const vec2 uv) {
+ vec2 size = vec2(textureSize(tDepth, 0));
+ ivec2 p = ivec2(uv * size);
+ float c0 = fetchDepth(p);
+ float l2 = fetchDepth(p - ivec2(2, 0));
+ float l1 = fetchDepth(p - ivec2(1, 0));
+ float r1 = fetchDepth(p + ivec2(1, 0));
+ float r2 = fetchDepth(p + ivec2(2, 0));
+ float b2 = fetchDepth(p - ivec2(0, 2));
+ float b1 = fetchDepth(p - ivec2(0, 1));
+ float t1 = fetchDepth(p + ivec2(0, 1));
+ float t2 = fetchDepth(p + ivec2(0, 2));
+ float dl = abs((2.0 * l1 - l2) - c0);
+ float dr = abs((2.0 * r1 - r2) - c0);
+ float db = abs((2.0 * b1 - b2) - c0);
+ float dt = abs((2.0 * t1 - t2) - c0);
+ vec3 ce = getViewPosition(uv, c0).xyz;
+ vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz
+ : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
+ vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz
+ : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
+ return normalize(cross(dpdx, dpdy));
+ }
+
+ vec3 getViewNormal(const vec2 uv) {
+ #if NORMAL_VECTOR_TYPE == 2
+ return normalize(textureLod(tNormal, uv, 0.).rgb);
+ #elif NORMAL_VECTOR_TYPE == 1
+ return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
+ #else
+ return computeNormalFromDepth(uv);
+ #endif
+ }
+
+ void denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {
+ vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);
+ float sampleDepth = getDepth(sampleUv);
+ vec3 sampleNormal = getViewNormal(sampleUv);
+ vec3 neighborColor = sampleTexel.rgb;
+ vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);
+
+ float normalDiff = dot(viewNormal, sampleNormal);
+ float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);
+ float lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));
+ float lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);
+ float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));
+ float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);
+ float w = lumaSimilarity * depthSimilarity * normalSimilarity;
+
+ denoised += w * neighborColor;
+ totalWeight += w;
+ }
+
+ void main() {
+ float depth = getDepth(vUv.xy);
+ vec3 viewNormal = getViewNormal(vUv);
+ if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {
+ discard;
+ return;
+ }
+ vec4 texel = textureLod(tDiffuse, vUv, 0.0);
+ vec3 center = texel.rgb;
+ vec3 viewPos = getViewPosition(vUv, depth);
+
+ vec2 noiseResolution = vec2(textureSize(tNoise, 0));
+ vec2 noiseUv = vUv * resolution / noiseResolution;
+ vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
+ vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));
+ mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);
+
+ float totalWeight = 1.0;
+ vec3 denoised = texel.rgb;
+ for (int i = 0; i < SAMPLES; i++) {
+ vec3 sampleDir = poissonDisk[i];
+ vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);
+ vec2 sampleUv = vUv + offset;
+ denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);
+ }
+
+ if (totalWeight > 0.) {
+ denoised /= totalWeight;
+ }
+ gl_FragColor = FRAGMENT_OUTPUT;
+ }`
+
+};
+
+function generatePdSamplePointInitializer( samples, rings, radiusExponent ) {
+
+ const poissonDisk = generateDenoiseSamples(
+ samples,
+ rings,
+ radiusExponent,
+ );
+
+ let glslCode = 'vec3[SAMPLES](';
+
+ for ( let i = 0; i < samples; i ++ ) {
+
+ const sample = poissonDisk[ i ];
+ glslCode += `vec3(${sample.x}, ${sample.y}, ${sample.z})${( i < samples - 1 ) ? ',' : ')'}`;
+
+ }
+
+ return glslCode;
+
+}
+
+function generateDenoiseSamples( numSamples, numRings, radiusExponent ) {
+
+ const samples = [];
+
+ for ( let i = 0; i < numSamples; i ++ ) {
+
+ const angle = 2 * Math.PI * numRings * i / numSamples;
+ const radius = Math.pow( i / ( numSamples - 1 ), radiusExponent );
+ samples.push( new Vector3( Math.cos( angle ), Math.sin( angle ), radius ) );
+
+ }
+
+ return samples;
+
+}
+
+export { generatePdSamplePointInitializer, PoissonDenoiseShader };
diff --git a/demo/hero-content/vendor/addons/shaders/RGBShiftShader.js b/demo/hero-content/vendor/addons/shaders/RGBShiftShader.js
new file mode 100644
index 00000000..acbe4413
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/RGBShiftShader.js
@@ -0,0 +1,61 @@
+/**
+ * @module RGBShiftShader
+ * @three_import import { RGBShiftShader } from 'three/addons/shaders/RGBShiftShader.js';
+ */
+
+/**
+ * RGB Shift Shader
+ * Shifts red and blue channels from center in opposite directions
+ * Ported from https://web.archive.org/web/20090820185047/http://kriss.cx/tom/2009/05/rgb-shift/
+ * by Tom Butterworth / https://web.archive.org/web/20090810054752/http://kriss.cx/tom/
+ *
+ * amount: shift distance (1 is width of input)
+ * angle: shift angle in radians
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const RGBShiftShader = {
+
+ name: 'RGBShiftShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'amount': { value: 0.005 },
+ 'angle': { value: 0.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform float amount;
+ uniform float angle;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec2 offset = amount * vec2( cos(angle), sin(angle));
+ vec4 cr = texture2D(tDiffuse, vUv + offset);
+ vec4 cga = texture2D(tDiffuse, vUv);
+ vec4 cb = texture2D(tDiffuse, vUv - offset);
+ gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);
+
+ }`
+
+};
+
+export { RGBShiftShader };
diff --git a/demo/hero-content/vendor/addons/shaders/SAOShader.js b/demo/hero-content/vendor/addons/shaders/SAOShader.js
new file mode 100644
index 00000000..e3e2d942
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/SAOShader.js
@@ -0,0 +1,201 @@
+import {
+ Matrix4,
+ Vector2
+} from 'three';
+
+/**
+ * @module SAOShader
+ * @three_import import { SAOShader } from 'three/addons/shaders/SAOShader.js';
+ */
+
+/**
+ * SAO shader.
+ *
+ * Used by {@link SAOPass}.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SAOShader = {
+
+ name: 'SAOShader',
+
+ defines: {
+ 'NUM_SAMPLES': 7,
+ 'NUM_RINGS': 4,
+ 'DIFFUSE_TEXTURE': 0,
+ 'PERSPECTIVE_CAMERA': 1
+ },
+
+ uniforms: {
+
+ 'tDepth': { value: null },
+ 'tDiffuse': { value: null },
+ 'tNormal': { value: null },
+ 'size': { value: new Vector2( 512, 512 ) },
+
+ 'cameraNear': { value: 1 },
+ 'cameraFar': { value: 100 },
+ 'cameraProjectionMatrix': { value: new Matrix4() },
+ 'cameraInverseProjectionMatrix': { value: new Matrix4() },
+
+ 'scale': { value: 1.0 },
+ 'intensity': { value: 0.1 },
+ 'bias': { value: 0.5 },
+
+ 'minResolution': { value: 0.0 },
+ 'kernelRadius': { value: 100.0 },
+ 'randomSeed': { value: 0.0 }
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }`,
+
+ fragmentShader: /* glsl */`
+ #include
+
+ varying vec2 vUv;
+
+ #if DIFFUSE_TEXTURE == 1
+ uniform sampler2D tDiffuse;
+ #endif
+
+ uniform highp sampler2D tDepth;
+ uniform highp sampler2D tNormal;
+
+ uniform float cameraNear;
+ uniform float cameraFar;
+ uniform mat4 cameraProjectionMatrix;
+ uniform mat4 cameraInverseProjectionMatrix;
+
+ uniform float scale;
+ uniform float intensity;
+ uniform float bias;
+ uniform float kernelRadius;
+ uniform float minResolution;
+ uniform vec2 size;
+ uniform float randomSeed;
+
+ // RGBA depth
+
+ #include
+
+ vec4 getDefaultColor( const in vec2 screenPosition ) {
+ #if DIFFUSE_TEXTURE == 1
+ return texture2D( tDiffuse, vUv );
+ #else
+ return vec4( 1.0 );
+ #endif
+ }
+
+ float getDepth( const in vec2 screenPosition ) {
+ return texture2D( tDepth, screenPosition ).x;
+ }
+
+ float getViewZ( const in float depth ) {
+ #if PERSPECTIVE_CAMERA == 1
+ return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );
+ #else
+ return orthographicDepthToViewZ( depth, cameraNear, cameraFar );
+ #endif
+ }
+
+ vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {
+ float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];
+ vec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );
+ clipPosition *= clipW; // unprojection.
+
+ return ( cameraInverseProjectionMatrix * clipPosition ).xyz;
+ }
+
+ vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {
+ return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );
+ }
+
+ float scaleDividedByCameraFar;
+ float minResolutionMultipliedByCameraFar;
+
+ float getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {
+ vec3 viewDelta = sampleViewPosition - centerViewPosition;
+ float viewDistance = length( viewDelta );
+ float scaledScreenDistance = scaleDividedByCameraFar * viewDistance;
+
+ return max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );
+ }
+
+ // moving costly divides into consts
+ const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );
+ const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );
+
+ float getAmbientOcclusion( const in vec3 centerViewPosition ) {
+ // precompute some variables require in getOcclusion.
+ scaleDividedByCameraFar = scale / cameraFar;
+ minResolutionMultipliedByCameraFar = minResolution * cameraFar;
+ vec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );
+
+ // jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/
+ float angle = rand( vUv + randomSeed ) * PI2;
+ vec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;
+ vec2 radiusStep = radius;
+
+ float occlusionSum = 0.0;
+ float weightSum = 0.0;
+
+ for( int i = 0; i < NUM_SAMPLES; i ++ ) {
+ vec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;
+ radius += radiusStep;
+ angle += ANGLE_STEP;
+
+ float sampleDepth = getDepth( sampleUv );
+ #ifdef USE_REVERSED_DEPTH_BUFFER
+ if( sampleDepth <= 0.0 + EPSILON ) {
+ continue;
+ }
+ #else
+ if( sampleDepth >= 1.0 - EPSILON ) {
+ continue;
+ }
+ #endif
+
+ float sampleViewZ = getViewZ( sampleDepth );
+ vec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );
+ occlusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );
+ weightSum += 1.0;
+ }
+
+ if( weightSum == 0.0 ) discard;
+
+ return occlusionSum * ( intensity / weightSum );
+ }
+
+ void main() {
+ float centerDepth = getDepth( vUv );
+
+ #ifdef USE_REVERSED_DEPTH_BUFFER
+ if( centerDepth <= 0.0 + EPSILON ) {
+ discard;
+ }
+ #else
+ if( centerDepth >= 1.0 - EPSILON ) {
+ discard;
+ }
+ #endif
+
+ float centerViewZ = getViewZ( centerDepth );
+ vec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );
+
+ float ambientOcclusion = getAmbientOcclusion( viewPosition );
+
+ gl_FragColor = getDefaultColor( vUv );
+ gl_FragColor.xyz *= 1.0 - ambientOcclusion;
+ }`
+
+};
+
+export { SAOShader };
diff --git a/demo/hero-content/vendor/addons/shaders/SMAAShader.js b/demo/hero-content/vendor/addons/shaders/SMAAShader.js
new file mode 100644
index 00000000..ce1b47e7
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/SMAAShader.js
@@ -0,0 +1,489 @@
+import {
+ Vector2
+} from 'three';
+
+/**
+ * WebGL port of Subpixel Morphological Antialiasing (SMAA) v2.8
+ * Preset: SMAA 1x Medium (with color edge detection)
+ *
+ * References:
+ * - {@link https://github.com/iryoku/smaa/releases/tag/v2.8}
+ *
+ * @module SMAAShader
+ * @three_import import { SMAAShader } from 'three/addons/shaders/SMAAShader.js';
+ */
+
+/**
+ * SMAA Edges shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SMAAEdgesShader = {
+
+ name: 'SMAAEdgesShader',
+
+ defines: {
+
+ 'SMAA_THRESHOLD': '0.1'
+
+ },
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'resolution': { value: new Vector2( 1 / 1024, 1 / 512 ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ uniform vec2 resolution;
+
+ varying vec2 vUv;
+ varying vec4 vOffset[ 3 ];
+
+ void SMAAEdgeDetectionVS( vec2 texcoord ) {
+ vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component
+ vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component
+ vOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 ); // WebGL port note: Changed sign in W component
+ }
+
+ void main() {
+
+ vUv = uv;
+
+ SMAAEdgeDetectionVS( vUv );
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+ varying vec4 vOffset[ 3 ];
+
+ vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {
+ vec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );
+
+ // Calculate color deltas:
+ vec4 delta;
+ vec3 C = texture2D( colorTex, texcoord ).rgb;
+
+ vec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;
+ vec3 t = abs( C - Cleft );
+ delta.x = max( max( t.r, t.g ), t.b );
+
+ vec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;
+ t = abs( C - Ctop );
+ delta.y = max( max( t.r, t.g ), t.b );
+
+ // We do the usual threshold:
+ vec2 edges = step( threshold, delta.xy );
+
+ // Then discard if there is no edge:
+ if ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )
+ discard;
+
+ // Calculate right and bottom deltas:
+ vec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;
+ t = abs( C - Cright );
+ delta.z = max( max( t.r, t.g ), t.b );
+
+ vec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;
+ t = abs( C - Cbottom );
+ delta.w = max( max( t.r, t.g ), t.b );
+
+ // Calculate the maximum delta in the direct neighborhood:
+ float maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );
+
+ // Calculate left-left and top-top deltas:
+ vec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;
+ t = abs( C - Cleftleft );
+ delta.z = max( max( t.r, t.g ), t.b );
+
+ vec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;
+ t = abs( C - Ctoptop );
+ delta.w = max( max( t.r, t.g ), t.b );
+
+ // Calculate the final maximum delta:
+ maxDelta = max( max( maxDelta, delta.z ), delta.w );
+
+ // Local contrast adaptation in action:
+ edges.xy *= step( 0.5 * maxDelta, delta.xy );
+
+ return vec4( edges, 0.0, 0.0 );
+ }
+
+ void main() {
+
+ gl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );
+
+ }`
+
+};
+
+/**
+ * SMAA Weights shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SMAAWeightsShader = {
+
+ name: 'SMAAWeightsShader',
+
+ defines: {
+
+ 'SMAA_MAX_SEARCH_STEPS': '8',
+ 'SMAA_AREATEX_MAX_DISTANCE': '16',
+ 'SMAA_AREATEX_PIXEL_SIZE': '( 1.0 / vec2( 160.0, 560.0 ) )',
+ 'SMAA_AREATEX_SUBTEX_SIZE': '( 1.0 / 7.0 )'
+
+ },
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'tArea': { value: null },
+ 'tSearch': { value: null },
+ 'resolution': { value: new Vector2( 1 / 1024, 1 / 512 ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ uniform vec2 resolution;
+
+ varying vec2 vUv;
+ varying vec4 vOffset[ 3 ];
+ varying vec2 vPixcoord;
+
+ void SMAABlendingWeightCalculationVS( vec2 texcoord ) {
+ vPixcoord = texcoord / resolution;
+
+ // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
+ vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 ); // WebGL port note: Changed sign in Y and W components
+ vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 ); // WebGL port note: Changed sign in Y and W components
+
+ // And these for the searches, they indicate the ends of the loops:
+ vOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );
+
+ }
+
+ void main() {
+
+ vUv = uv;
+
+ SMAABlendingWeightCalculationVS( vUv );
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ #define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )
+
+ uniform sampler2D tDiffuse;
+ uniform sampler2D tArea;
+ uniform sampler2D tSearch;
+ uniform vec2 resolution;
+
+ varying vec2 vUv;
+ varying vec4 vOffset[3];
+ varying vec2 vPixcoord;
+
+ #if __VERSION__ == 100
+ vec2 round( vec2 x ) {
+ return sign( x ) * floor( abs( x ) + 0.5 );
+ }
+ #endif
+
+ float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {
+ // Not required if searchTex accesses are set to point:
+ // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);
+ // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +
+ // e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;
+ e.r = bias + e.r * scale;
+ return 255.0 * texture2D( searchTex, e, 0.0 ).r;
+ }
+
+ float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
+ /**
+ * @PSEUDO_GATHER4
+ * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to
+ * sample between edge, thus fetching four edges in a row.
+ * Sampling with different offsets in each direction allows to disambiguate
+ * which edges are active from the four fetched ones.
+ */
+ vec2 e = vec2( 0.0, 1.0 );
+
+ for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
+ e = texture2D( edgesTex, texcoord, 0.0 ).rg;
+ texcoord -= vec2( 2.0, 0.0 ) * resolution;
+ if ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;
+ }
+
+ // We correct the previous (-0.25, -0.125) offset we applied:
+ texcoord.x += 0.25 * resolution.x;
+
+ // The searches are bias by 1, so adjust the coords accordingly:
+ texcoord.x += resolution.x;
+
+ // Disambiguate the length added by the last step:
+ texcoord.x += 2.0 * resolution.x; // Undo last step
+ texcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);
+
+ return texcoord.x;
+ }
+
+ float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
+ vec2 e = vec2( 0.0, 1.0 );
+
+ for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
+ e = texture2D( edgesTex, texcoord, 0.0 ).rg;
+ texcoord += vec2( 2.0, 0.0 ) * resolution;
+ if ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;
+ }
+
+ texcoord.x -= 0.25 * resolution.x;
+ texcoord.x -= resolution.x;
+ texcoord.x -= 2.0 * resolution.x;
+ texcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );
+
+ return texcoord.x;
+ }
+
+ float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
+ vec2 e = vec2( 1.0, 0.0 );
+
+ for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
+ e = texture2D( edgesTex, texcoord, 0.0 ).rg;
+ texcoord += vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign
+ if ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;
+ }
+
+ texcoord.y -= 0.25 * resolution.y; // WebGL port note: Changed sign
+ texcoord.y -= resolution.y; // WebGL port note: Changed sign
+ texcoord.y -= 2.0 * resolution.y; // WebGL port note: Changed sign
+ texcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 ); // WebGL port note: Changed sign
+
+ return texcoord.y;
+ }
+
+ float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
+ vec2 e = vec2( 1.0, 0.0 );
+
+ for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
+ e = texture2D( edgesTex, texcoord, 0.0 ).rg;
+ texcoord -= vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign
+ if ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;
+ }
+
+ texcoord.y += 0.25 * resolution.y; // WebGL port note: Changed sign
+ texcoord.y += resolution.y; // WebGL port note: Changed sign
+ texcoord.y += 2.0 * resolution.y; // WebGL port note: Changed sign
+ texcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 ); // WebGL port note: Changed sign
+
+ return texcoord.y;
+ }
+
+ vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {
+ // Rounding prevents precision errors of bilinear filtering:
+ vec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;
+
+ // We do a scale and bias for mapping to texel space:
+ texcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );
+
+ // Move to proper place, according to the subpixel offset:
+ texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;
+
+ return texture2D( areaTex, texcoord, 0.0 ).rg;
+ }
+
+ vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {
+ vec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );
+
+ vec2 e = texture2D( edgesTex, texcoord ).rg;
+
+ if ( e.g > 0.0 ) { // Edge at north
+ vec2 d;
+
+ // Find the distance to the left:
+ vec2 coords;
+ coords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );
+ coords.y = offset[ 1 ].y; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)
+ d.x = coords.x;
+
+ // Now fetch the left crossing edges, two at a time using bilinear
+ // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to
+ // discern what value each edge has:
+ float e1 = texture2D( edgesTex, coords, 0.0 ).r;
+
+ // Find the distance to the right:
+ coords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );
+ d.y = coords.x;
+
+ // We want the distances to be in pixel units (doing this here allow to
+ // better interleave arithmetic and memory accesses):
+ d = d / resolution.x - pixcoord.x;
+
+ // SMAAArea below needs a sqrt, as the areas texture is compressed
+ // quadratically:
+ vec2 sqrt_d = sqrt( abs( d ) );
+
+ // Fetch the right crossing edges:
+ coords.y -= 1.0 * resolution.y; // WebGL port note: Added
+ float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;
+
+ // Ok, we know how this pattern looks like, now it is time for getting
+ // the actual area:
+ weights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );
+ }
+
+ if ( e.r > 0.0 ) { // Edge at west
+ vec2 d;
+
+ // Find the distance to the top:
+ vec2 coords;
+
+ coords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );
+ coords.x = offset[ 0 ].x; // offset[1].x = texcoord.x - 0.25 * resolution.x;
+ d.x = coords.y;
+
+ // Fetch the top crossing edges:
+ float e1 = texture2D( edgesTex, coords, 0.0 ).g;
+
+ // Find the distance to the bottom:
+ coords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );
+ d.y = coords.y;
+
+ // We want the distances to be in pixel units:
+ d = d / resolution.y - pixcoord.y;
+
+ // SMAAArea below needs a sqrt, as the areas texture is compressed
+ // quadratically:
+ vec2 sqrt_d = sqrt( abs( d ) );
+
+ // Fetch the bottom crossing edges:
+ coords.y -= 1.0 * resolution.y; // WebGL port note: Added
+ float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;
+
+ // Get the area for this direction:
+ weights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );
+ }
+
+ return weights;
+ }
+
+ void main() {
+
+ gl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );
+
+ }`
+
+};
+
+/**
+ * SMAA Blend shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SMAABlendShader = {
+
+ name: 'SMAABlendShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'tColor': { value: null },
+ 'resolution': { value: new Vector2( 1 / 1024, 1 / 512 ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ uniform vec2 resolution;
+
+ varying vec2 vUv;
+ varying vec4 vOffset[ 2 ];
+
+ void SMAANeighborhoodBlendingVS( vec2 texcoord ) {
+ vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component
+ vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component
+ }
+
+ void main() {
+
+ vUv = uv;
+
+ SMAANeighborhoodBlendingVS( vUv );
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform sampler2D tColor;
+ uniform vec2 resolution;
+
+ varying vec2 vUv;
+ varying vec4 vOffset[ 2 ];
+
+ vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {
+ // Fetch the blending weights for current pixel:
+ vec4 a;
+ a.xz = texture2D( blendTex, texcoord ).xz;
+ a.y = texture2D( blendTex, offset[ 1 ].zw ).g;
+ a.w = texture2D( blendTex, offset[ 1 ].xy ).a;
+
+ // Is there any blending weight with a value greater than 0.0?
+ if ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {
+ return texture2D( colorTex, texcoord, 0.0 );
+ } else {
+ // Up to 4 lines can be crossing a pixel (one through each edge). We
+ // favor blending by choosing the line with the maximum weight for each
+ // direction:
+ vec2 offset;
+ offset.x = a.a > a.b ? a.a : -a.b; // left vs. right
+ offset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs
+
+ // Then we go in the direction that has the maximum weight:
+ if ( abs( offset.x ) > abs( offset.y )) { // horizontal vs. vertical
+ offset.y = 0.0;
+ } else {
+ offset.x = 0.0;
+ }
+
+ // Fetch the opposite color and lerp by hand:
+ vec4 C = texture2D( colorTex, texcoord, 0.0 );
+ texcoord += sign( offset ) * resolution;
+ vec4 Cop = texture2D( colorTex, texcoord, 0.0 );
+ float s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );
+
+ // WebGL port note: Added gamma correction
+ C.xyz = pow(C.xyz, vec3(2.2));
+ Cop.xyz = pow(Cop.xyz, vec3(2.2));
+ vec4 mixed = mix(C, Cop, s);
+ mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));
+
+ return mixed;
+ }
+ }
+
+ void main() {
+
+ gl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );
+
+ }`
+
+};
+
+export { SMAAEdgesShader, SMAAWeightsShader, SMAABlendShader };
diff --git a/demo/hero-content/vendor/addons/shaders/SSAOShader.js b/demo/hero-content/vendor/addons/shaders/SSAOShader.js
new file mode 100644
index 00000000..c24edfbb
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/SSAOShader.js
@@ -0,0 +1,331 @@
+import {
+ Matrix4,
+ Vector2
+} from 'three';
+
+/**
+ * @module SSAOShader
+ * @three_import import { SSAOShader } from 'three/addons/shaders/SSAOShader.js';
+ */
+
+/**
+ * SSAO shader.
+ *
+ * References:
+ * - {@link http://john-chapman-graphics.blogspot.com/2013/01/ssao-tutorial.html}
+ * - {@link https://learnopengl.com/Advanced-Lighting/SSAO}
+ * - {@link https://github.com/McNopper/OpenGL/blob/master/Example28/shader/ssao.frag.glsl}
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SSAOShader = {
+
+ name: 'SSAOShader',
+
+ defines: {
+ 'PERSPECTIVE_CAMERA': 1,
+ 'KERNEL_SIZE': 32
+ },
+
+ uniforms: {
+
+ 'tNormal': { value: null },
+ 'tDepth': { value: null },
+ 'tNoise': { value: null },
+ 'kernel': { value: null },
+ 'cameraNear': { value: null },
+ 'cameraFar': { value: null },
+ 'resolution': { value: new Vector2() },
+ 'cameraProjectionMatrix': { value: new Matrix4() },
+ 'cameraInverseProjectionMatrix': { value: new Matrix4() },
+ 'kernelRadius': { value: 8 },
+ 'minDistance': { value: 0.005 },
+ 'maxDistance': { value: 0.05 },
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+ uniform highp sampler2D tNormal;
+ uniform highp sampler2D tDepth;
+ uniform sampler2D tNoise;
+
+ uniform vec3 kernel[ KERNEL_SIZE ];
+
+ uniform vec2 resolution;
+
+ uniform float cameraNear;
+ uniform float cameraFar;
+ uniform mat4 cameraProjectionMatrix;
+ uniform mat4 cameraInverseProjectionMatrix;
+
+ uniform float kernelRadius;
+ uniform float minDistance; // avoid artifacts caused by neighbour fragments with minimal depth difference
+ uniform float maxDistance; // avoid the influence of fragments which are too far away
+
+ varying vec2 vUv;
+
+ #include
+
+ #ifdef USE_REVERSED_DEPTH_BUFFER
+
+ const float depthThreshold = 0.0;
+
+ #else
+
+ const float depthThreshold = 1.0;
+
+ #endif
+
+ float getDepth( const in vec2 screenPosition ) {
+
+ return texture2D( tDepth, screenPosition ).x;
+
+ }
+
+ float getLinearDepth( const in vec2 screenPosition ) {
+
+ #if PERSPECTIVE_CAMERA == 1
+
+ float fragCoordZ = texture2D( tDepth, screenPosition ).x;
+ float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
+ return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
+
+ #else
+
+ return texture2D( tDepth, screenPosition ).x;
+
+ #endif
+
+ }
+
+ float getViewZ( const in float depth ) {
+
+ #if PERSPECTIVE_CAMERA == 1
+
+ return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );
+
+ #else
+
+ return orthographicDepthToViewZ( depth, cameraNear, cameraFar );
+
+ #endif
+
+ }
+
+ vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {
+
+ float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];
+
+ vec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );
+
+ clipPosition *= clipW; // unprojection.
+
+ return ( cameraInverseProjectionMatrix * clipPosition ).xyz;
+
+ }
+
+ vec3 getViewNormal( const in vec2 screenPosition ) {
+
+ return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );
+
+ }
+
+ void main() {
+
+ float depth = getDepth( vUv );
+
+ if ( depth == depthThreshold ) {
+
+ gl_FragColor = vec4( 1.0 ); // don't influence background
+
+ } else {
+
+ float viewZ = getViewZ( depth );
+
+ vec3 viewPosition = getViewPosition( vUv, depth, viewZ );
+ vec3 viewNormal = getViewNormal( vUv );
+
+ vec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );
+ vec3 random = vec3( texture2D( tNoise, vUv * noiseScale ).r );
+
+ // compute matrix used to reorient a kernel vector
+
+ vec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );
+ vec3 bitangent = cross( viewNormal, tangent );
+ mat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );
+
+ float occlusion = 0.0;
+
+ for ( int i = 0; i < KERNEL_SIZE; i ++ ) {
+
+ vec3 sampleVector = kernelMatrix * kernel[ i ]; // reorient sample vector in view space
+ vec3 samplePoint = viewPosition + ( sampleVector * kernelRadius ); // calculate sample point
+
+ vec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 ); // project point and calculate NDC
+ samplePointNDC /= samplePointNDC.w;
+
+ vec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates
+
+ float realDepth = getLinearDepth( samplePointUv ); // get linear depth from depth texture
+ float sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar ); // compute linear depth of the sample view Z value
+ float delta = sampleDepth - realDepth;
+
+ if ( delta > minDistance && delta < maxDistance ) { // if fragment is before sample point, increase occlusion
+
+ occlusion += 1.0;
+
+ }
+
+ }
+
+ occlusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );
+
+ gl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );
+
+ }
+
+ }`
+
+};
+
+/**
+ * SSAO depth shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SSAODepthShader = {
+
+ name: 'SSAODepthShader',
+
+ defines: {
+ 'PERSPECTIVE_CAMERA': 1
+ },
+
+ uniforms: {
+
+ 'tDepth': { value: null },
+ 'cameraNear': { value: null },
+ 'cameraFar': { value: null },
+
+ },
+
+ vertexShader:
+
+ `varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader:
+
+ `uniform sampler2D tDepth;
+
+ uniform float cameraNear;
+ uniform float cameraFar;
+
+ varying vec2 vUv;
+
+ #include
+
+ float getLinearDepth( const in vec2 screenPosition ) {
+
+ #if PERSPECTIVE_CAMERA == 1
+
+ float fragCoordZ = texture2D( tDepth, screenPosition ).x;
+ float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
+ return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
+
+ #else
+
+ return texture2D( tDepth, screenPosition ).x;
+
+ #endif
+
+ }
+
+ void main() {
+
+ float depth = getLinearDepth( vUv );
+ gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
+
+ }`
+
+};
+
+/**
+ * SSAO blur shader.
+ *
+ * @constant
+ * @type {Object}
+ */
+const SSAOBlurShader = {
+
+ name: 'SSAOBlurShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'resolution': { value: new Vector2() }
+
+ },
+
+ vertexShader:
+
+ `varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader:
+
+ `uniform sampler2D tDiffuse;
+
+ uniform vec2 resolution;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec2 texelSize = ( 1.0 / resolution );
+ float result = 0.0;
+
+ for ( int i = - 2; i <= 2; i ++ ) {
+
+ for ( int j = - 2; j <= 2; j ++ ) {
+
+ vec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;
+ result += texture2D( tDiffuse, vUv + offset ).r;
+
+ }
+
+ }
+
+ gl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );
+
+ }`
+
+};
+
+export { SSAOShader, SSAODepthShader, SSAOBlurShader };
diff --git a/demo/hero-content/vendor/addons/shaders/SSRShader.js b/demo/hero-content/vendor/addons/shaders/SSRShader.js
new file mode 100644
index 00000000..193bc3ba
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/SSRShader.js
@@ -0,0 +1,396 @@
+import {
+ Matrix4,
+ Vector2
+} from 'three';
+
+
+/**
+ * A collection of shaders used for SSR.
+ *
+ * References:
+ * - [3D Game Shaders For Beginners, Screen Space Reflection (SSR)](https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-reflection.html).
+ *
+ * @module SSRShader
+ * @three_import import * as SSRShader from 'three/addons/shaders/SSRShader.js';
+ */
+
+/**
+ * SSR shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SSRShader = {
+
+ name: 'SSRShader',
+
+ defines: {
+ MAX_STEP: 0,
+ PERSPECTIVE_CAMERA: true,
+ DISTANCE_ATTENUATION: true,
+ FRESNEL: true,
+ INFINITE_THICK: false,
+ SELECTIVE: false,
+ },
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'tNormal': { value: null },
+ 'tMetalness': { value: null },
+ 'tDepth': { value: null },
+ 'cameraNear': { value: null },
+ 'cameraFar': { value: null },
+ 'resolution': { value: new Vector2() },
+ 'cameraProjectionMatrix': { value: new Matrix4() },
+ 'cameraInverseProjectionMatrix': { value: new Matrix4() },
+ 'opacity': { value: .5 },
+ 'maxDistance': { value: 180 },
+ 'cameraRange': { value: 0 },
+ 'thickness': { value: .018 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }
+
+ `,
+
+ fragmentShader: /* glsl */`
+ // precision highp float;
+ precision highp sampler2D;
+ varying vec2 vUv;
+ uniform sampler2D tDepth;
+ uniform sampler2D tNormal;
+ uniform sampler2D tMetalness;
+ uniform sampler2D tDiffuse;
+ uniform float cameraRange;
+ uniform vec2 resolution;
+ uniform float opacity;
+ uniform float cameraNear;
+ uniform float cameraFar;
+ uniform float maxDistance;
+ uniform float thickness;
+ uniform mat4 cameraProjectionMatrix;
+ uniform mat4 cameraInverseProjectionMatrix;
+ #include
+ float pointToLineDistance(vec3 x0, vec3 x1, vec3 x2) {
+ //x0: point, x1: linePointA, x2: linePointB
+ //https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
+ return length(cross(x0-x1,x0-x2))/length(x2-x1);
+ }
+ float pointPlaneDistance(vec3 point,vec3 planePoint,vec3 planeNormal){
+ // https://mathworld.wolfram.com/Point-PlaneDistance.html
+ //// https://en.wikipedia.org/wiki/Plane_(geometry)
+ //// http://paulbourke.net/geometry/pointlineplane/
+ float a=planeNormal.x,b=planeNormal.y,c=planeNormal.z;
+ float x0=point.x,y0=point.y,z0=point.z;
+ float x=planePoint.x,y=planePoint.y,z=planePoint.z;
+ float d=-(a*x+b*y+c*z);
+ float distance=a*x0+b*y0+c*z0+d;
+ return distance;
+ }
+ float getDepth( const in vec2 uv ) {
+ return texture2D( tDepth, uv ).x;
+ }
+ float getViewZ( const in float depth ) {
+ #ifdef PERSPECTIVE_CAMERA
+ return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );
+ #else
+ return orthographicDepthToViewZ( depth, cameraNear, cameraFar );
+ #endif
+ }
+ vec3 getViewPosition( const in vec2 uv, const in float depth/*clip space*/, const in float clipW ) {
+ vec4 clipPosition = vec4( ( vec3( uv, depth ) - 0.5 ) * 2.0, 1.0 );//ndc
+ clipPosition *= clipW; //clip
+ return ( cameraInverseProjectionMatrix * clipPosition ).xyz;//view
+ }
+ vec3 getViewNormal( const in vec2 uv ) {
+ return unpackRGBToNormal( texture2D( tNormal, uv ).xyz );
+ }
+ vec2 viewPositionToXY(vec3 viewPosition){
+ vec2 xy;
+ vec4 clip=cameraProjectionMatrix*vec4(viewPosition,1);
+ xy=clip.xy;//clip
+ float clipW=clip.w;
+ xy/=clipW;//NDC
+ xy=(xy+1.)/2.;//uv
+ xy*=resolution;//screen
+ return xy;
+ }
+ void main(){
+ #ifdef SELECTIVE
+ float metalness=texture2D(tMetalness,vUv).r;
+ if(metalness==0.) return;
+ #endif
+
+ float depth = getDepth( vUv );
+ float viewZ = getViewZ( depth );
+ if(-viewZ>=cameraFar) return;
+
+ float clipW = cameraProjectionMatrix[2][3] * viewZ+cameraProjectionMatrix[3][3];
+ vec3 viewPosition=getViewPosition( vUv, depth, clipW );
+
+ vec2 d0=gl_FragCoord.xy;
+ vec2 d1;
+
+ vec3 viewNormal=getViewNormal( vUv );
+
+ #ifdef PERSPECTIVE_CAMERA
+ vec3 viewIncidentDir=normalize(viewPosition);
+ vec3 viewReflectDir=reflect(viewIncidentDir,viewNormal);
+ #else
+ vec3 viewIncidentDir=vec3(0,0,-1);
+ vec3 viewReflectDir=reflect(viewIncidentDir,viewNormal);
+ #endif
+
+ float maxReflectRayLen=maxDistance/dot(-viewIncidentDir,viewNormal);
+ // dot(a,b)==length(a)*length(b)*cos(theta) // https://www.mathsisfun.com/algebra/vectors-dot-product.html
+ // if(a.isNormalized&&b.isNormalized) dot(a,b)==cos(theta)
+ // maxDistance/maxReflectRayLen=cos(theta)
+ // maxDistance/maxReflectRayLen==dot(a,b)
+ // maxReflectRayLen==maxDistance/dot(a,b)
+
+ vec3 d1viewPosition=viewPosition+viewReflectDir*maxReflectRayLen;
+ #ifdef PERSPECTIVE_CAMERA
+ if(d1viewPosition.z>-cameraNear){
+ //https://tutorial.math.lamar.edu/Classes/CalcIII/EqnsOfLines.aspx
+ float t=(-cameraNear-viewPosition.z)/viewReflectDir.z;
+ d1viewPosition=viewPosition+viewReflectDir*t;
+ }
+ #endif
+ d1=viewPositionToXY(d1viewPosition);
+
+ float xLen=d1.x-d0.x;
+ float yLen=d1.y-d0.y;
+ float totalStep=max(abs(xLen),abs(yLen));
+ float xSpan=xLen/totalStep;
+ float ySpan=yLen/totalStep;
+ float sStep=1./totalStep;
+ float s=sStep; // start at sStep since loop starts at i=1
+ for(float i=1.;i=totalStep) break;
+ vec2 xy=vec2(d0.x+i*xSpan,d0.y+i*ySpan);
+ if(xy.x<0.||xy.x>resolution.x||xy.y<0.||xy.y>resolution.y) break;
+ vec2 uv=xy/resolution;
+
+ float d = getDepth(uv);
+ float vZ = getViewZ( d );
+ if(-vZ>=cameraFar) continue;
+ float cW = cameraProjectionMatrix[2][3] * vZ+cameraProjectionMatrix[3][3];
+ vec3 vP=getViewPosition( uv, d, cW );
+
+ #ifdef PERSPECTIVE_CAMERA
+ // https://comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf
+ float recipVPZ=1./viewPosition.z;
+ float viewReflectRayZ=1./(recipVPZ+s*(1./d1viewPosition.z-recipVPZ));
+ #else
+ float viewReflectRayZ=viewPosition.z+s*(d1viewPosition.z-viewPosition.z);
+ #endif
+
+ // if(viewReflectRayZ>vZ) continue; // will cause "npm run make-screenshot webgl_postprocessing_ssr" high probability hang.
+ // https://github.com/mrdoob/three.js/pull/21539#issuecomment-821061164
+ if(viewReflectRayZ<=vZ){
+
+ bool hit;
+ #ifdef INFINITE_THICK
+ hit=true;
+ #else
+ float away=pointToLineDistance(vP,viewPosition,d1viewPosition);
+
+ float minThickness;
+ vec2 xyNeighbor=xy;
+ xyNeighbor.x+=1.;
+ vec2 uvNeighbor=xyNeighbor/resolution;
+ vec3 vPNeighbor=getViewPosition(uvNeighbor,d,cW);
+ minThickness=vPNeighbor.x-vP.x;
+ minThickness*=3.;
+ float tk=max(minThickness,thickness);
+
+ hit=away<=tk;
+ #endif
+
+ if(hit){
+ vec3 vN=getViewNormal( uv );
+ if(dot(viewReflectDir,vN)>=0.) break; // treat backfaces as opaque
+ float distance=pointPlaneDistance(vP,viewPosition,viewNormal);
+ if(distance>maxDistance) break;
+ float op=opacity;
+ #ifdef DISTANCE_ATTENUATION
+ float ratio=1.-(distance/maxDistance);
+ float attenuation=ratio*ratio;
+ op=opacity*attenuation;
+ #endif
+ #ifdef FRESNEL
+ float fresnelCoe=(dot(viewIncidentDir,viewReflectDir)+1.)/2.;
+ op*=fresnelCoe;
+ #endif
+ vec4 reflectColor=texture2D(tDiffuse,uv);
+ gl_FragColor.xyz=reflectColor.xyz;
+ gl_FragColor.a=op;
+ break;
+ }
+ }
+ s+=sStep;
+ }
+ }
+ `
+
+};
+
+/**
+ * SSR Depth shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SSRDepthShader = {
+
+ name: 'SSRDepthShader',
+
+ defines: {
+ 'PERSPECTIVE_CAMERA': 1
+ },
+
+ uniforms: {
+
+ 'tDepth': { value: null },
+ 'cameraNear': { value: null },
+ 'cameraFar': { value: null },
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }
+
+ `,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDepth;
+
+ uniform float cameraNear;
+ uniform float cameraFar;
+
+ varying vec2 vUv;
+
+ #include
+
+ float getLinearDepth( const in vec2 uv ) {
+
+ #if PERSPECTIVE_CAMERA == 1
+
+ float fragCoordZ = texture2D( tDepth, uv ).x;
+ float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
+ return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
+
+ #else
+
+ return texture2D( tDepth, uv ).x;
+
+ #endif
+
+ }
+
+ void main() {
+
+ float depth = getLinearDepth( vUv );
+ float d = 1.0 - depth;
+ // d=(d-.999)*1000.;
+ gl_FragColor = vec4( vec3( d ), 1.0 );
+
+ }
+
+ `
+
+};
+
+/**
+ * SSR Blur shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SSRBlurShader = {
+
+ name: 'SSRBlurShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'resolution': { value: new Vector2() },
+ 'opacity': { value: .5 },
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }
+
+ `,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform vec2 resolution;
+ varying vec2 vUv;
+ void main() {
+ //reverse engineering from PhotoShop blur filter, then change coefficient
+
+ vec2 texelSize = ( 1.0 / resolution );
+
+ vec4 c=texture2D(tDiffuse,vUv);
+
+ vec2 offset;
+
+ offset=(vec2(-1,0))*texelSize;
+ vec4 cl=texture2D(tDiffuse,vUv+offset);
+
+ offset=(vec2(1,0))*texelSize;
+ vec4 cr=texture2D(tDiffuse,vUv+offset);
+
+ offset=(vec2(0,-1))*texelSize;
+ vec4 cb=texture2D(tDiffuse,vUv+offset);
+
+ offset=(vec2(0,1))*texelSize;
+ vec4 ct=texture2D(tDiffuse,vUv+offset);
+
+ // float coeCenter=.5;
+ // float coeSide=.125;
+ float coeCenter=.2;
+ float coeSide=.2;
+ float a=c.a*coeCenter+cl.a*coeSide+cr.a*coeSide+cb.a*coeSide+ct.a*coeSide;
+ vec3 rgb=(c.rgb*c.a*coeCenter+cl.rgb*cl.a*coeSide+cr.rgb*cr.a*coeSide+cb.rgb*cb.a*coeSide+ct.rgb*ct.a*coeSide)/a;
+ gl_FragColor=vec4(rgb,a);
+
+ }
+ `
+
+
+};
+
+export { SSRShader, SSRDepthShader, SSRBlurShader };
diff --git a/demo/hero-content/vendor/addons/shaders/SepiaShader.js b/demo/hero-content/vendor/addons/shaders/SepiaShader.js
new file mode 100644
index 00000000..970d4af0
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/SepiaShader.js
@@ -0,0 +1,57 @@
+/**
+ * @module SepiaShader
+ * @three_import import { SepiaShader } from 'three/addons/shaders/SepiaShader.js';
+ */
+
+/**
+ * Sepia tone shader based on [glfx.js sepia shader](https://github.com/evanw/glfx.js).
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SepiaShader = {
+
+ name: 'SepiaShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'amount': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float amount;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 color = texture2D( tDiffuse, vUv );
+ vec3 c = color.rgb;
+
+ color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );
+ color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );
+ color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );
+
+ gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );
+
+ }`
+
+};
+
+export { SepiaShader };
diff --git a/demo/hero-content/vendor/addons/shaders/SobelOperatorShader.js b/demo/hero-content/vendor/addons/shaders/SobelOperatorShader.js
new file mode 100644
index 00000000..43d190f9
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/SobelOperatorShader.js
@@ -0,0 +1,98 @@
+import {
+ Vector2
+} from 'three';
+
+/**
+ * @module SobelOperatorShader
+ * @three_import import { SobelOperatorShader } from 'three/addons/shaders/SobelOperatorShader.js';
+ */
+
+/**
+ * Sobel Edge Detection (see {@link https://youtu.be/uihBwtPIBxM}).
+ *
+ * As mentioned in the video the Sobel operator expects a grayscale image as input.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SobelOperatorShader = {
+
+ name: 'SobelOperatorShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'resolution': { value: new Vector2() }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform vec2 resolution;
+ varying vec2 vUv;
+
+ void main() {
+
+ vec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );
+
+ // kernel definition (in glsl matrices are filled in column-major order)
+
+ const mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 ); // x direction kernel
+ const mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 ); // y direction kernel
+
+ // fetch the 3x3 neighbourhood of a fragment
+
+ // first column
+
+ float tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;
+ float tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;
+ float tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;
+
+ // second column
+
+ float tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;
+ float tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;
+ float tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;
+
+ // third column
+
+ float tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;
+ float tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;
+ float tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;
+
+ // gradient value in x direction
+
+ float valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 +
+ Gx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 +
+ Gx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2;
+
+ // gradient value in y direction
+
+ float valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 +
+ Gy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 +
+ Gy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2;
+
+ // magnitude of the total gradient
+
+ float G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );
+
+ gl_FragColor = vec4( vec3( G ), 1 );
+
+ }`
+
+};
+
+export { SobelOperatorShader };
diff --git a/demo/hero-content/vendor/addons/shaders/SubsurfaceScatteringShader.js b/demo/hero-content/vendor/addons/shaders/SubsurfaceScatteringShader.js
new file mode 100644
index 00000000..e4cbf26c
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/SubsurfaceScatteringShader.js
@@ -0,0 +1,95 @@
+import {
+ Color,
+ ShaderChunk,
+ ShaderLib,
+ UniformsUtils
+} from 'three';
+
+function replaceAll( string, find, replace ) {
+
+ return string.split( find ).join( replace );
+
+}
+
+const meshphong_frag_head = ShaderChunk[ 'meshphong_frag' ].slice( 0, ShaderChunk[ 'meshphong_frag' ].indexOf( 'void main() {' ) );
+const meshphong_frag_body = ShaderChunk[ 'meshphong_frag' ].slice( ShaderChunk[ 'meshphong_frag' ].indexOf( 'void main() {' ) );
+
+/**
+ * @module SubsurfaceScatteringShader
+ * @three_import import { SubsurfaceScatteringShader } from 'three/addons/shaders/SubsurfaceScatteringShader.js';
+ */
+
+/**
+ * Subsurface Scattering shader.
+ *
+ * Based on GDC 2011 – [Approximating Translucency for a Fast, Cheap and Convincing Subsurface Scattering Look](https://colinbarrebrisebois.com/2011/03/07/gdc-2011-approximating-translucency-for-a-fast-cheap-and-convincing-subsurface-scattering-look/)
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const SubsurfaceScatteringShader = {
+
+ name: 'SubsurfaceScatteringShader',
+
+ uniforms: UniformsUtils.merge( [
+ ShaderLib[ 'phong' ].uniforms,
+ {
+ 'thicknessMap': { value: null },
+ 'thicknessColor': { value: new Color( 0xffffff ) },
+ 'thicknessDistortion': { value: 0.1 },
+ 'thicknessAmbient': { value: 0.0 },
+ 'thicknessAttenuation': { value: 0.1 },
+ 'thicknessPower': { value: 2.0 },
+ 'thicknessScale': { value: 10.0 }
+ }
+
+ ] ),
+
+ vertexShader: [
+ '#define USE_UV',
+ ShaderChunk[ 'meshphong_vert' ],
+ ].join( '\n' ),
+
+ fragmentShader: [
+ '#define USE_UV',
+ '#define SUBSURFACE',
+
+ meshphong_frag_head,
+
+ 'uniform sampler2D thicknessMap;',
+ 'uniform float thicknessPower;',
+ 'uniform float thicknessScale;',
+ 'uniform float thicknessDistortion;',
+ 'uniform float thicknessAmbient;',
+ 'uniform float thicknessAttenuation;',
+ 'uniform vec3 thicknessColor;',
+
+ 'void RE_Direct_Scattering(const in IncidentLight directLight, const in vec2 uv, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, inout ReflectedLight reflectedLight) {',
+ ' vec3 thickness = thicknessColor * texture2D(thicknessMap, uv).r;',
+ ' vec3 scatteringHalf = normalize(directLight.direction + (geometryNormal * thicknessDistortion));',
+ ' float scatteringDot = pow(saturate(dot(geometryViewDir, -scatteringHalf)), thicknessPower) * thicknessScale;',
+ ' vec3 scatteringIllu = (scatteringDot + thicknessAmbient) * thickness;',
+ ' reflectedLight.directDiffuse += scatteringIllu * thicknessAttenuation * directLight.color;',
+ '}',
+
+ meshphong_frag_body.replace( '#include ',
+
+ replaceAll(
+ ShaderChunk[ 'lights_fragment_begin' ],
+ 'RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );',
+ [
+ 'RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );',
+
+ '#if defined( SUBSURFACE ) && defined( USE_UV )',
+ ' RE_Direct_Scattering(directLight, vUv, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, reflectedLight);',
+ '#endif',
+ ].join( '\n' )
+ ),
+
+ ),
+
+ ].join( '\n' ),
+
+};
+
+export { SubsurfaceScatteringShader };
diff --git a/demo/hero-content/vendor/addons/shaders/TechnicolorShader.js b/demo/hero-content/vendor/addons/shaders/TechnicolorShader.js
new file mode 100644
index 00000000..8752a056
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/TechnicolorShader.js
@@ -0,0 +1,51 @@
+/**
+ * @module TriangleBlurShader
+ * @three_import import { TriangleBlurShader } from 'three/addons/shaders/TriangleBlurShader.js';
+ */
+
+/**
+ * Simulates the look of the two-strip technicolor process popular in early 20th century films.
+ * More historical info here: {@link http://www.widescreenmuseum.com/oldcolor/technicolor1.htm}
+ * Demo here: {@link http://charliehoey.com/technicolor_shader/shader_test.html}
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const TechnicolorShader = {
+
+ name: 'TechnicolorShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );
+ vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);
+
+ gl_FragColor = newTex;
+
+ }`
+
+};
+
+export { TechnicolorShader };
diff --git a/demo/hero-content/vendor/addons/shaders/ToonShader.js b/demo/hero-content/vendor/addons/shaders/ToonShader.js
new file mode 100644
index 00000000..59daae98
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/ToonShader.js
@@ -0,0 +1,349 @@
+import {
+ Color,
+ Vector3
+} from 'three';
+
+/**
+ * Collection of toon shaders.
+ *
+ * @module TriangleBlurShader
+ * @three_import import * as ToonShader from 'three/addons/shaders/ToonShader.js';
+ */
+
+/**
+ * Toon1 shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const ToonShader1 = {
+
+ name: 'ToonShader1',
+
+ uniforms: {
+
+ 'uDirLightPos': { value: new Vector3() },
+ 'uDirLightColor': { value: new Color( 0xeeeeee ) },
+
+ 'uAmbientLightColor': { value: new Color( 0x050505 ) },
+
+ 'uBaseColor': { value: new Color( 0xffffff ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec3 vNormal;
+ varying vec3 vRefract;
+
+ void main() {
+
+ vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
+ vec3 worldNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );
+
+ vNormal = normalize( normalMatrix * normal );
+
+ vec3 I = worldPosition.xyz - cameraPosition;
+ vRefract = refract( normalize( I ), worldNormal, 1.02 );
+
+ gl_Position = projectionMatrix * mvPosition;
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform vec3 uBaseColor;
+
+ uniform vec3 uDirLightPos;
+ uniform vec3 uDirLightColor;
+
+ uniform vec3 uAmbientLightColor;
+
+ varying vec3 vNormal;
+
+ varying vec3 vRefract;
+
+ void main() {
+
+ float directionalLightWeighting = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);
+ vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;
+
+ float intensity = smoothstep( - 0.5, 1.0, pow( length(lightWeighting), 20.0 ) );
+ intensity += length(lightWeighting) * 0.2;
+
+ float cameraWeighting = dot( normalize( vNormal ), vRefract );
+ intensity += pow( 1.0 - length( cameraWeighting ), 6.0 );
+ intensity = intensity * 0.2 + 0.3;
+
+ if ( intensity < 0.50 ) {
+
+ gl_FragColor = vec4( 2.0 * intensity * uBaseColor, 1.0 );
+
+ } else {
+
+ gl_FragColor = vec4( 1.0 - 2.0 * ( 1.0 - intensity ) * ( 1.0 - uBaseColor ), 1.0 );
+
+ }
+
+ #include
+
+ }`
+
+};
+/**
+ * Toon2 shader.
+ *
+ * @constant
+ * @type {Object}
+ */
+const ToonShader2 = {
+
+ uniforms: {
+
+ 'uDirLightPos': { value: new Vector3() },
+ 'uDirLightColor': { value: new Color( 0xeeeeee ) },
+
+ 'uAmbientLightColor': { value: new Color( 0x050505 ) },
+
+ 'uBaseColor': { value: new Color( 0xeeeeee ) },
+ 'uLineColor1': { value: new Color( 0x808080 ) },
+ 'uLineColor2': { value: new Color( 0x000000 ) },
+ 'uLineColor3': { value: new Color( 0x000000 ) },
+ 'uLineColor4': { value: new Color( 0x000000 ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec3 vNormal;
+
+ void main() {
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ vNormal = normalize( normalMatrix * normal );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform vec3 uBaseColor;
+ uniform vec3 uLineColor1;
+ uniform vec3 uLineColor2;
+ uniform vec3 uLineColor3;
+ uniform vec3 uLineColor4;
+
+ uniform vec3 uDirLightPos;
+ uniform vec3 uDirLightColor;
+
+ uniform vec3 uAmbientLightColor;
+
+ varying vec3 vNormal;
+
+ void main() {
+
+ float camera = max( dot( normalize( vNormal ), vec3( 0.0, 0.0, 1.0 ) ), 0.4);
+ float light = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);
+
+ gl_FragColor = vec4( uBaseColor, 1.0 );
+
+ if ( length(uAmbientLightColor + uDirLightColor * light) < 1.00 ) {
+
+ gl_FragColor *= vec4( uLineColor1, 1.0 );
+
+ }
+
+ if ( length(uAmbientLightColor + uDirLightColor * camera) < 0.50 ) {
+
+ gl_FragColor *= vec4( uLineColor2, 1.0 );
+
+ }
+
+ #include
+
+ }`
+
+};
+
+/**
+ * Toon Hatching shader.
+ *
+ * @constant
+ * @type {Object}
+ */
+const ToonShaderHatching = {
+
+ uniforms: {
+
+ 'uDirLightPos': { value: new Vector3() },
+ 'uDirLightColor': { value: new Color( 0xeeeeee ) },
+
+ 'uAmbientLightColor': { value: new Color( 0x050505 ) },
+
+ 'uBaseColor': { value: new Color( 0xffffff ) },
+ 'uLineColor1': { value: new Color( 0x000000 ) },
+ 'uLineColor2': { value: new Color( 0x000000 ) },
+ 'uLineColor3': { value: new Color( 0x000000 ) },
+ 'uLineColor4': { value: new Color( 0x000000 ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec3 vNormal;
+
+ void main() {
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ vNormal = normalize( normalMatrix * normal );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform vec3 uBaseColor;
+ uniform vec3 uLineColor1;
+ uniform vec3 uLineColor2;
+ uniform vec3 uLineColor3;
+ uniform vec3 uLineColor4;
+
+ uniform vec3 uDirLightPos;
+ uniform vec3 uDirLightColor;
+
+ uniform vec3 uAmbientLightColor;
+
+ varying vec3 vNormal;
+
+ void main() {
+
+ float directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);
+ vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;
+
+ gl_FragColor = vec4( uBaseColor, 1.0 );
+
+ if ( length(lightWeighting) < 1.00 ) {
+
+ if ( mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {
+
+ gl_FragColor = vec4( uLineColor1, 1.0 );
+
+ }
+
+ }
+
+ if ( length(lightWeighting) < 0.75 ) {
+
+ if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {
+
+ gl_FragColor = vec4( uLineColor2, 1.0 );
+
+ }
+
+ }
+
+ if ( length(lightWeighting) < 0.50 ) {
+
+ if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {
+
+ gl_FragColor = vec4( uLineColor3, 1.0 );
+
+ }
+
+ }
+
+ if ( length(lightWeighting) < 0.3465 ) {
+
+ if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {
+
+ gl_FragColor = vec4( uLineColor4, 1.0 );
+
+ }
+
+ }
+
+ #include
+
+ }`
+
+};
+
+/**
+ * Toon Dotted shader.
+ *
+ * @constant
+ * @type {Object}
+ */
+const ToonShaderDotted = {
+
+ uniforms: {
+
+ 'uDirLightPos': { value: new Vector3() },
+ 'uDirLightColor': { value: new Color( 0xeeeeee ) },
+
+ 'uAmbientLightColor': { value: new Color( 0x050505 ) },
+
+ 'uBaseColor': { value: new Color( 0xffffff ) },
+ 'uLineColor1': { value: new Color( 0x000000 ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec3 vNormal;
+
+ void main() {
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ vNormal = normalize( normalMatrix * normal );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform vec3 uBaseColor;
+ uniform vec3 uLineColor1;
+ uniform vec3 uLineColor2;
+ uniform vec3 uLineColor3;
+ uniform vec3 uLineColor4;
+
+ uniform vec3 uDirLightPos;
+ uniform vec3 uDirLightColor;
+
+ uniform vec3 uAmbientLightColor;
+
+ varying vec3 vNormal;
+
+ void main() {
+
+ float directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);
+ vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;
+
+ gl_FragColor = vec4( uBaseColor, 1.0 );
+
+ if ( length(lightWeighting) < 1.00 ) {
+
+ if ( ( mod(gl_FragCoord.x, 4.001) + mod(gl_FragCoord.y, 4.0) ) > 6.00 ) {
+
+ gl_FragColor = vec4( uLineColor1, 1.0 );
+
+ }
+
+ }
+
+ if ( length(lightWeighting) < 0.50 ) {
+
+ if ( ( mod(gl_FragCoord.x + 2.0, 4.001) + mod(gl_FragCoord.y + 2.0, 4.0) ) > 6.00 ) {
+
+ gl_FragColor = vec4( uLineColor1, 1.0 );
+
+ }
+
+ }
+
+ #include
+
+ }`
+
+};
+
+export { ToonShader1, ToonShader2, ToonShaderHatching, ToonShaderDotted };
diff --git a/demo/hero-content/vendor/addons/shaders/TriangleBlurShader.js b/demo/hero-content/vendor/addons/shaders/TriangleBlurShader.js
new file mode 100644
index 00000000..2de0f1ca
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/TriangleBlurShader.js
@@ -0,0 +1,79 @@
+import {
+ Vector2
+} from 'three';
+
+/**
+ * @module TriangleBlurShader
+ * @three_import import { TriangleBlurShader } from 'three/addons/shaders/TriangleBlurShader.js';
+ */
+
+/**
+ * Triangle blur shader based on [glfx.js triangle blur shader](https://github.com/evanw/glfx.js).
+ *
+ * A basic blur filter, which convolves the image with a
+ * pyramid filter. The pyramid filter is separable and is applied as two
+ * perpendicular triangle filters.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const TriangleBlurShader = {
+
+ name: 'TriangleBlurShader',
+
+ uniforms: {
+
+ 'texture': { value: null },
+ 'delta': { value: new Vector2( 1, 1 ) }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ #include
+
+ #define ITERATIONS 10.0
+
+ uniform sampler2D texture;
+ uniform vec2 delta;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 color = vec4( 0.0 );
+
+ float total = 0.0;
+
+ // randomize the lookup values to hide the fixed number of samples
+
+ float offset = rand( vUv );
+
+ for ( float t = -ITERATIONS; t <= ITERATIONS; t ++ ) {
+
+ float percent = ( t + offset - 0.5 ) / ITERATIONS;
+ float weight = 1.0 - abs( percent );
+
+ color += texture2D( texture, vUv + delta * percent ) * weight;
+ total += weight;
+
+ }
+
+ gl_FragColor = color / total;
+
+ }`
+
+};
+
+export { TriangleBlurShader };
diff --git a/demo/hero-content/vendor/addons/shaders/UnpackDepthRGBAShader.js b/demo/hero-content/vendor/addons/shaders/UnpackDepthRGBAShader.js
new file mode 100644
index 00000000..4d9fa445
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/UnpackDepthRGBAShader.js
@@ -0,0 +1,60 @@
+/**
+ * @module UnpackDepthRGBAShader
+ * @three_import import { UnpackDepthRGBAShader } from 'three/addons/shaders/UnpackDepthRGBAShader.js';
+ */
+
+/**
+ * Depth visualization shader that shows depth values as monochrome color.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const UnpackDepthRGBAShader = {
+
+ name: 'UnpackDepthRGBAShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'opacity': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float opacity;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ float depth = texture2D( tDiffuse, vUv ).r;
+
+ #ifdef USE_REVERSED_DEPTH_BUFFER
+
+ gl_FragColor = vec4( vec3( depth ), opacity );
+
+ #else
+
+ gl_FragColor = vec4( vec3( 1.0 - depth ), opacity );
+
+ #endif
+
+ }`
+
+};
+
+export { UnpackDepthRGBAShader };
diff --git a/demo/hero-content/vendor/addons/shaders/VelocityShader.js b/demo/hero-content/vendor/addons/shaders/VelocityShader.js
new file mode 100644
index 00000000..9c5ef710
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/VelocityShader.js
@@ -0,0 +1,137 @@
+import {
+ UniformsLib,
+ UniformsUtils,
+ Matrix4
+} from 'three';
+
+/**
+ * @module VelocityShader
+ * @three_import import { VelocityShader } from 'three/addons/shaders/VelocityShader.js';
+ */
+
+/**
+ * Mesh velocity shader by @bhouston.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const VelocityShader = {
+
+ name: 'VelocityShader',
+
+ uniforms: UniformsUtils.merge( [
+ UniformsLib.common,
+ UniformsLib.displacementmap,
+ {
+ modelMatrixPrev: { value: new Matrix4() },
+ currentProjectionViewMatrix: { value: new Matrix4() },
+ previousProjectionViewMatrix: { value: new Matrix4() }
+ }
+ ] ),
+
+ vertexShader: /* glsl */`
+#define NORMAL
+
+#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
+
+ varying vec3 vViewPosition;
+
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+uniform mat4 previousProjectionViewMatrix;
+uniform mat4 currentProjectionViewMatrix;
+
+uniform mat4 modelMatrixPrev;
+
+varying vec4 clipPositionCurrent;
+varying vec4 clipPositionPrevious;
+
+void main() {
+
+
+ #include
+
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ #include
+ #include
+ #include
+ #include
+ #include
+
+#ifdef USE_SKINNING
+
+ vec4 mvPosition = modelViewMatrix * skinned;
+ clipPositionCurrent = currentProjectionViewMatrix * modelMatrix * skinned;
+ clipPositionPrevious = previousProjectionViewMatrix * modelMatrixPrev * skinned;
+
+#else
+
+ vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );
+ clipPositionCurrent = currentProjectionViewMatrix * modelMatrix * vec4( transformed, 1.0 );
+ clipPositionPrevious = previousProjectionViewMatrix * modelMatrixPrev * vec4( transformed, 1.0 );
+
+#endif
+
+ gl_Position = projectionMatrix * mvPosition;
+
+ #include
+ #include
+}
+`,
+ fragmentShader: /* glsl */`
+#define NORMAL
+
+uniform float opacity;
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+varying vec4 clipPositionCurrent;
+varying vec4 clipPositionPrevious;
+
+void main() {
+
+ vec4 diffuseColor = vec4( 1.0 );
+ diffuseColor.a = opacity;
+
+ #include
+ #include
+ #include
+
+ vec2 ndcPositionCurrent = clipPositionCurrent.xy/clipPositionCurrent.w;
+ vec2 ndcPositionPrevious = clipPositionPrevious.xy/clipPositionPrevious.w;
+ vec2 vel = ( ndcPositionCurrent - ndcPositionPrevious ) * 0.5;
+ vel = vel * 0.5 + 0.5;
+ vec2 v1 = packDepthToRG(vel.x);
+ vec2 v2 = packDepthToRG(vel.y);
+ gl_FragColor = vec4(v1.x, v1.y, v2.x, v2.y);
+
+ #include
+
+}
+
+`
+};
+
+export { VelocityShader };
diff --git a/demo/hero-content/vendor/addons/shaders/VerticalBlurShader.js b/demo/hero-content/vendor/addons/shaders/VerticalBlurShader.js
new file mode 100644
index 00000000..e4c953a8
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/VerticalBlurShader.js
@@ -0,0 +1,66 @@
+/**
+ * @module VerticalBlurShader
+ * @three_import import { VerticalBlurShader } from 'three/addons/shaders/VerticalBlurShader.js';
+ */
+
+/**
+ * Two pass Gaussian blur filter (horizontal and vertical blur shaders)
+ * - see {@link http://www.cake23.de/traveling-wavefronts-lit-up.html}
+ *
+ * - 9 samples per pass
+ * - standard deviation 2.7
+ * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const VerticalBlurShader = {
+
+ name: 'VerticalBlurShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'v': { value: 1.0 / 512.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform float v;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 sum = vec4( 0.0 );
+
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;
+
+ gl_FragColor = sum;
+
+ }`
+
+};
+
+export { VerticalBlurShader };
diff --git a/demo/hero-content/vendor/addons/shaders/VerticalTiltShiftShader.js b/demo/hero-content/vendor/addons/shaders/VerticalTiltShiftShader.js
new file mode 100644
index 00000000..f4442b4e
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/VerticalTiltShiftShader.js
@@ -0,0 +1,70 @@
+/**
+ * @module VerticalTiltShiftShader
+ * @three_import import { VerticalTiltShiftShader } from 'three/addons/shaders/VerticalTiltShiftShader.js';
+ */
+
+/**
+ * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position
+ *
+ * - 9 samples per pass
+ * - standard deviation 2.7
+ * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
+ * - "r" parameter control where "focused" horizontal line lies
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const VerticalTiltShiftShader = {
+
+ name: 'VerticalTiltShiftShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'v': { value: 1.0 / 512.0 },
+ 'r': { value: 0.35 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tDiffuse;
+ uniform float v;
+ uniform float r;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vec4 sum = vec4( 0.0 );
+
+ float vv = v * abs( r - vUv.y );
+
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * vv ) ) * 0.051;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * vv ) ) * 0.0918;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * vv ) ) * 0.12245;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * vv ) ) * 0.1531;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * vv ) ) * 0.1531;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * vv ) ) * 0.12245;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * vv ) ) * 0.0918;
+ sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * vv ) ) * 0.051;
+
+ gl_FragColor = sum;
+
+ }`
+
+};
+
+export { VerticalTiltShiftShader };
diff --git a/demo/hero-content/vendor/addons/shaders/VignetteShader.js b/demo/hero-content/vendor/addons/shaders/VignetteShader.js
new file mode 100644
index 00000000..3ac5845a
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/VignetteShader.js
@@ -0,0 +1,56 @@
+/**
+ * @module VignetteShader
+ * @three_import import { VignetteShader } from 'three/addons/shaders/VignetteShader.js';
+ */
+
+/**
+ * Based on [PaintEffect postprocess from ro.me](https://github.com/dataarts/3-dreams-of-black/blob/master/deploy/js/effects/PaintEffect.js).
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const VignetteShader = {
+
+ name: 'VignetteShader',
+
+ uniforms: {
+
+ 'tDiffuse': { value: null },
+ 'offset': { value: 1.0 },
+ 'darkness': { value: 1.0 }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec2 vUv;
+
+ void main() {
+
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform float offset;
+ uniform float darkness;
+
+ uniform sampler2D tDiffuse;
+
+ varying vec2 vUv;
+
+ void main() {
+
+ // Eskil's vignette
+
+ vec4 texel = texture2D( tDiffuse, vUv );
+ vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );
+ gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );
+
+ }`
+
+};
+
+export { VignetteShader };
diff --git a/demo/hero-content/vendor/addons/shaders/VolumeShader.js b/demo/hero-content/vendor/addons/shaders/VolumeShader.js
new file mode 100644
index 00000000..48ae0ac8
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/VolumeShader.js
@@ -0,0 +1,285 @@
+import {
+ Vector2,
+ Vector3
+} from 'three';
+
+/**
+ * @module VolumeShader
+ * @three_import import { VolumeRenderShader1 } from 'three/addons/shaders/VolumeShader.js';
+ */
+
+/**
+ * Shaders to render 3D volumes using raycasting.
+ * The applied techniques are based on similar implementations in the Visvis and Vispy projects.
+ * This is not the only approach, therefore it's marked 1.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const VolumeRenderShader1 = {
+
+ name: 'VolumeRenderShader1',
+
+ uniforms: {
+ 'u_size': { value: new Vector3( 1, 1, 1 ) },
+ 'u_renderstyle': { value: 0 },
+ 'u_renderthreshold': { value: 0.5 },
+ 'u_clim': { value: new Vector2( 1, 1 ) },
+ 'u_data': { value: null },
+ 'u_cmdata': { value: null }
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec3 v_position;
+ varying vec3 v_cameraInObj;
+ varying vec3 v_viewDirInObj;
+
+ void main() {
+ vec4 position4 = vec4(position, 1.0);
+
+ v_position = position;
+
+ // Express the camera position and view direction in the object's local
+ // space so the fragment shader can build the per-fragment view ray.
+ // For perspective cameras, rays converge at v_cameraInObj.
+ // For orthographic cameras, rays travel along v_viewDirInObj.
+ v_cameraInObj = (inverse(modelMatrix) * vec4(cameraPosition, 1.0)).xyz;
+ v_viewDirInObj = (inverse(modelViewMatrix) * vec4(0.0, 0.0, -1.0, 0.0)).xyz;
+
+ gl_Position = projectionMatrix * modelViewMatrix * position4;
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ precision highp float;
+ precision mediump sampler3D;
+
+ uniform vec3 u_size;
+ uniform int u_renderstyle;
+ uniform float u_renderthreshold;
+ uniform vec2 u_clim;
+
+ uniform sampler3D u_data;
+ uniform sampler2D u_cmdata;
+
+ varying vec3 v_position;
+ varying vec3 v_cameraInObj;
+ varying vec3 v_viewDirInObj;
+
+ // The maximum distance through our rendering volume is sqrt(3).
+ const int MAX_STEPS = 887; // 887 for 512^3, 1774 for 1024^3
+ const int REFINEMENT_STEPS = 4;
+ const float relative_step_size = 1.0;
+ const vec4 ambient_color = vec4(0.2, 0.4, 0.2, 1.0);
+ const vec4 diffuse_color = vec4(0.8, 0.2, 0.2, 1.0);
+ const vec4 specular_color = vec4(1.0, 1.0, 1.0, 1.0);
+ const float shininess = 40.0;
+
+ void cast_mip(vec3 start_loc, vec3 step, int nsteps, vec3 view_ray);
+ void cast_iso(vec3 start_loc, vec3 step, int nsteps, vec3 view_ray);
+
+ float sample1(vec3 texcoords);
+ vec4 apply_colormap(float val);
+ vec4 add_lighting(float val, vec3 loc, vec3 step, vec3 view_ray);
+
+
+ void main() {
+ // Per-fragment ray direction in object space, pointing from the back
+ // face toward the camera. For perspective cameras the rays converge
+ // at the camera position; for orthographic cameras they are parallel
+ // to the view direction.
+ vec3 view_ray = isOrthographic
+ ? normalize(-v_viewDirInObj)
+ : normalize(v_cameraInObj - v_position);
+
+ // Slab-based ray/AABB intersection: v_position lies on the back face
+ // of the cuboid, so stepping along view_ray traverses the volume and
+ // exits through the front face at t = distance.
+ vec3 t1 = (vec3(-0.5) - v_position) / view_ray;
+ vec3 t2 = (u_size - vec3(0.5) - v_position) / view_ray;
+ vec3 tmax = max(t1, t2);
+ float distance = min(min(tmax.x, tmax.y), tmax.z);
+
+ // Decide how many steps to take
+ int nsteps = int(distance / relative_step_size + 0.5);
+ if ( nsteps < 1 )
+ discard;
+
+ // Get starting location and step vector in texture coordinates
+ vec3 front = v_position + view_ray * distance;
+ vec3 step = ((v_position - front) / u_size) / float(nsteps);
+ vec3 start_loc = front / u_size;
+
+ // For testing: show the number of steps. This helps to establish
+ // whether the rays are correctly oriented
+ //'gl_FragColor = vec4(0.0, float(nsteps) / 1.0 / u_size.x, 1.0, 1.0);
+ //'return;
+
+ if (u_renderstyle == 0)
+ cast_mip(start_loc, step, nsteps, view_ray);
+ else if (u_renderstyle == 1)
+ cast_iso(start_loc, step, nsteps, view_ray);
+
+ if (gl_FragColor.a < 0.05)
+ discard;
+ }
+
+
+ float sample1(vec3 texcoords) {
+ /* Sample float value from a 3D texture. Assumes intensity data. */
+ return texture(u_data, texcoords.xyz).r;
+ }
+
+
+ vec4 apply_colormap(float val) {
+ val = (val - u_clim[0]) / (u_clim[1] - u_clim[0]);
+ float n = float(textureSize(u_cmdata, 0).x); // see #33842
+ val = (val * (n - 1.0) + 0.5) / n;
+ return texture2D(u_cmdata, vec2(val, 0.5));
+ }
+
+
+ void cast_mip(vec3 start_loc, vec3 step, int nsteps, vec3 view_ray) {
+
+ float max_val = -1e6;
+ int max_i = 100;
+ vec3 loc = start_loc;
+
+ // Enter the raycasting loop. In WebGL 1 the loop index cannot be compared with
+ // non-constant expression. So we use a hard-coded max, and an additional condition
+ // inside the loop.
+ for (int iter=0; iter= nsteps)
+ break;
+ // Sample from the 3D texture
+ float val = sample1(loc);
+ // Apply MIP operation
+ if (val > max_val) {
+ max_val = val;
+ max_i = iter;
+ }
+ // Advance location deeper into the volume
+ loc += step;
+ }
+
+ // Refine location, gives crispier images
+ vec3 iloc = start_loc + step * (float(max_i) - 0.5);
+ vec3 istep = step / float(REFINEMENT_STEPS);
+ for (int i=0; i= nsteps)
+ break;
+
+ // Sample from the 3D texture
+ float val = sample1(loc);
+
+ if (val > low_threshold) {
+ // Take the last interval in smaller steps
+ vec3 iloc = loc - 0.5 * step;
+ vec3 istep = step / float(REFINEMENT_STEPS);
+ for (int i=0; i u_renderthreshold) {
+ gl_FragColor = add_lighting(val, iloc, dstep, view_ray);
+ return;
+ }
+ iloc += istep;
+ }
+ }
+
+ // Advance location deeper into the volume
+ loc += step;
+ }
+ }
+
+
+ vec4 add_lighting(float val, vec3 loc, vec3 step, vec3 view_ray)
+ {
+ // Calculate color by incorporating lighting
+
+ // View direction
+ vec3 V = normalize(view_ray);
+
+ // calculate normal vector from gradient
+ vec3 N;
+ float val1, val2;
+ val1 = sample1(loc + vec3(-step[0], 0.0, 0.0));
+ val2 = sample1(loc + vec3(+step[0], 0.0, 0.0));
+ N[0] = val1 - val2;
+ val = max(max(val1, val2), val);
+ val1 = sample1(loc + vec3(0.0, -step[1], 0.0));
+ val2 = sample1(loc + vec3(0.0, +step[1], 0.0));
+ N[1] = val1 - val2;
+ val = max(max(val1, val2), val);
+ val1 = sample1(loc + vec3(0.0, 0.0, -step[2]));
+ val2 = sample1(loc + vec3(0.0, 0.0, +step[2]));
+ N[2] = val1 - val2;
+ val = max(max(val1, val2), val);
+
+ float gm = length(N); // gradient magnitude
+ N = normalize(N);
+
+ // Flip normal so it points towards viewer
+ float Nselect = float(dot(N, V) > 0.0);
+ N = (2.0 * Nselect - 1.0) * N; // == Nselect * N - (1.0-Nselect)*N;
+
+ // Init colors
+ vec4 ambient_color = vec4(0.0, 0.0, 0.0, 0.0);
+ vec4 diffuse_color = vec4(0.0, 0.0, 0.0, 0.0);
+ vec4 specular_color = vec4(0.0, 0.0, 0.0, 0.0);
+
+ // note: could allow multiple lights
+ for (int i=0; i<1; i++)
+ {
+ // Get light direction (make sure to prevent zero division)
+ vec3 L = normalize(view_ray); //lightDirs[i];
+ float lightEnabled = float( length(L) > 0.0 );
+ L = normalize(L + (1.0 - lightEnabled));
+
+ // Calculate lighting properties
+ float lambertTerm = clamp(dot(N, L), 0.0, 1.0);
+ vec3 H = normalize(L+V); // Halfway vector
+ float specularTerm = pow(max(dot(H, N), 0.0), shininess);
+
+ // Calculate mask
+ float mask1 = lightEnabled;
+
+ // Calculate colors
+ ambient_color += mask1 * ambient_color; // * gl_LightSource[i].ambient;
+ diffuse_color += mask1 * lambertTerm;
+ specular_color += mask1 * specularTerm * specular_color;
+ }
+
+ // Calculate final color by componing different components
+ vec4 final_color;
+ vec4 color = apply_colormap(val);
+ final_color = color * (ambient_color + diffuse_color) + specular_color;
+ final_color.a = color.a;
+ return final_color;
+ }`
+
+};
+
+export { VolumeRenderShader1 };
diff --git a/demo/hero-content/vendor/addons/shaders/WaterRefractionShader.js b/demo/hero-content/vendor/addons/shaders/WaterRefractionShader.js
new file mode 100644
index 00000000..680c4ad5
--- /dev/null
+++ b/demo/hero-content/vendor/addons/shaders/WaterRefractionShader.js
@@ -0,0 +1,106 @@
+/**
+ * @module WaterRefractionShader
+ * @three_import import { WaterRefractionShader } from 'three/addons/shaders/WaterRefractionShader.js';
+ */
+
+/**
+ * Basic water refraction shader.
+ *
+ * @constant
+ * @type {ShaderMaterial~Shader}
+ */
+const WaterRefractionShader = {
+
+ name: 'WaterRefractionShader',
+
+ uniforms: {
+
+ 'color': {
+ value: null
+ },
+
+ 'time': {
+ value: 0
+ },
+
+ 'tDiffuse': {
+ value: null
+ },
+
+ 'tDudv': {
+ value: null
+ },
+
+ 'textureMatrix': {
+ value: null
+ }
+
+ },
+
+ vertexShader: /* glsl */`
+
+ uniform mat4 textureMatrix;
+
+ varying vec2 vUv;
+ varying vec4 vUvRefraction;
+
+ void main() {
+
+ vUv = uv;
+
+ vUvRefraction = textureMatrix * vec4( position, 1.0 );
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ }`,
+
+ fragmentShader: /* glsl */`
+
+ uniform vec3 color;
+ uniform float time;
+ uniform sampler2D tDiffuse;
+ uniform sampler2D tDudv;
+
+ varying vec2 vUv;
+ varying vec4 vUvRefraction;
+
+ float blendOverlay( float base, float blend ) {
+
+ return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );
+
+ }
+
+ vec3 blendOverlay( vec3 base, vec3 blend ) {
+
+ return vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ),blendOverlay( base.b, blend.b ) );
+
+ }
+
+ void main() {
+
+ float waveStrength = 0.5;
+ float waveSpeed = 0.03;
+
+ // simple distortion (ripple) via dudv map (see https://www.youtube.com/watch?v=6B7IF6GOu7s)
+
+ vec2 distortedUv = texture2D( tDudv, vec2( vUv.x + time * waveSpeed, vUv.y ) ).rg * waveStrength;
+ distortedUv = vUv.xy + vec2( distortedUv.x, distortedUv.y + time * waveSpeed );
+ vec2 distortion = ( texture2D( tDudv, distortedUv ).rg * 2.0 - 1.0 ) * waveStrength;
+
+ // new uv coords
+
+ vec4 uv = vec4( vUvRefraction );
+ uv.xy += distortion;
+
+ vec4 base = texture2DProj( tDiffuse, uv );
+
+ gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );
+
+ #include
+ #include
+
+ }`
+
+};
+
+export { WaterRefractionShader };
diff --git a/demo/hero-content/vendor/three.core.js b/demo/hero-content/vendor/three.core.js
new file mode 100644
index 00000000..0ee9b6d5
--- /dev/null
+++ b/demo/hero-content/vendor/three.core.js
@@ -0,0 +1,61162 @@
+/**
+ * @license
+ * Copyright 2010-2026 Three.js Authors
+ * SPDX-License-Identifier: MIT
+ */
+const REVISION = '187';
+
+/**
+ * Represents mouse buttons and interaction types in context of controls.
+ *
+ * @type {ConstantsMouse}
+ * @constant
+ */
+const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
+
+/**
+ * Represents touch interaction types in context of controls.
+ *
+ * @type {ConstantsTouch}
+ * @constant
+ */
+const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
+
+/**
+ * Disables face culling.
+ *
+ * @type {number}
+ * @constant
+ */
+const CullFaceNone = 0;
+
+/**
+ * Culls back faces.
+ *
+ * @type {number}
+ * @constant
+ */
+const CullFaceBack = 1;
+
+/**
+ * Culls front faces.
+ *
+ * @type {number}
+ * @constant
+ */
+const CullFaceFront = 2;
+
+/**
+ * Culls both front and back faces.
+ *
+ * @type {number}
+ * @constant
+ */
+const CullFaceFrontBack = 3;
+
+/**
+ * Gives unfiltered shadow maps - fastest, but lowest quality.
+ *
+ * @type {number}
+ * @constant
+ */
+const BasicShadowMap = 0;
+
+/**
+ * Filters shadow maps using the Percentage-Closer Filtering (PCF) algorithm.
+ *
+ * @type {number}
+ * @constant
+ */
+const PCFShadowMap = 1;
+
+/**
+ * Filters shadow maps using the Percentage-Closer Filtering (PCF) algorithm with
+ * better soft shadows especially when using low-resolution shadow maps.
+ *
+ * @type {number}
+ * @constant
+ * @deprecated since r186. Use `PCFShadowMap` instead.
+ */
+const PCFSoftShadowMap = 2;
+
+/**
+ * Filters shadow maps using the Variance Shadow Map (VSM) algorithm.
+ * When using VSMShadowMap all shadow receivers will also cast shadows.
+ *
+ * @type {number}
+ * @constant
+ */
+const VSMShadowMap = 3;
+
+/**
+ * Only front faces are rendered.
+ *
+ * @type {number}
+ * @constant
+ */
+const FrontSide = 0;
+
+/**
+ * Only back faces are rendered.
+ *
+ * @type {number}
+ * @constant
+ */
+const BackSide = 1;
+
+/**
+ * Both front and back faces are rendered.
+ *
+ * @type {number}
+ * @constant
+ */
+const DoubleSide = 2;
+
+/**
+ * No blending is performed which effectively disables
+ * alpha transparency.
+ *
+ * @type {number}
+ * @constant
+ */
+const NoBlending = 0;
+
+/**
+ * The default blending.
+ *
+ * @type {number}
+ * @constant
+ */
+const NormalBlending = 1;
+
+/**
+ * Represents additive blending.
+ *
+ * @type {number}
+ * @constant
+ */
+const AdditiveBlending = 2;
+
+/**
+ * Represents subtractive blending.
+ *
+ * @type {number}
+ * @constant
+ */
+const SubtractiveBlending = 3;
+
+/**
+ * Represents multiply blending.
+ *
+ * @type {number}
+ * @constant
+ */
+const MultiplyBlending = 4;
+
+/**
+ * Represents custom blending.
+ *
+ * @type {number}
+ * @constant
+ */
+const CustomBlending = 5;
+
+/**
+ * Represents material blending.
+ *
+ * @type {number}
+ * @constant
+ */
+const MaterialBlending = 6;
+
+/**
+ * A `source + destination` blending equation.
+ *
+ * @type {number}
+ * @constant
+ */
+const AddEquation = 100;
+
+/**
+ * A `source - destination` blending equation.
+ *
+ * @type {number}
+ * @constant
+ */
+const SubtractEquation = 101;
+
+/**
+ * A `destination - source` blending equation.
+ *
+ * @type {number}
+ * @constant
+ */
+const ReverseSubtractEquation = 102;
+
+/**
+ * A blend equation that uses the minimum of source and destination.
+ *
+ * @type {number}
+ * @constant
+ */
+const MinEquation = 103;
+
+/**
+ * A blend equation that uses the maximum of source and destination.
+ *
+ * @type {number}
+ * @constant
+ */
+const MaxEquation = 104;
+
+/**
+ * Multiplies all colors by `0`.
+ *
+ * @type {number}
+ * @constant
+ */
+const ZeroFactor = 200;
+
+/**
+ * Multiplies all colors by `1`.
+ *
+ * @type {number}
+ * @constant
+ */
+const OneFactor = 201;
+
+/**
+ * Multiplies all colors by the source colors.
+ *
+ * @type {number}
+ * @constant
+ */
+const SrcColorFactor = 202;
+
+/**
+ * Multiplies all colors by `1` minus each source color.
+ *
+ * @type {number}
+ * @constant
+ */
+const OneMinusSrcColorFactor = 203;
+
+/**
+ * Multiplies all colors by the source alpha value.
+ *
+ * @type {number}
+ * @constant
+ */
+const SrcAlphaFactor = 204;
+
+/**
+ * Multiplies all colors by 1 minus the source alpha value.
+ *
+ * @type {number}
+ * @constant
+ */
+const OneMinusSrcAlphaFactor = 205;
+
+/**
+ * Multiplies all colors by the destination alpha value.
+ *
+ * @type {number}
+ * @constant
+ */
+const DstAlphaFactor = 206;
+
+/**
+ * Multiplies all colors by `1` minus the destination alpha value.
+ *
+ * @type {number}
+ * @constant
+ */
+const OneMinusDstAlphaFactor = 207;
+
+/**
+ * Multiplies all colors by the destination color.
+ *
+ * @type {number}
+ * @constant
+ */
+const DstColorFactor = 208;
+
+/**
+ * Multiplies all colors by `1` minus each destination color.
+ *
+ * @type {number}
+ * @constant
+ */
+const OneMinusDstColorFactor = 209;
+
+/**
+ * Multiplies the RGB colors by the smaller of either the source alpha
+ * value or the value of `1` minus the destination alpha value. The alpha
+ * value is multiplied by `1`.
+ *
+ * @type {number}
+ * @constant
+ */
+const SrcAlphaSaturateFactor = 210;
+
+/**
+ * Multiplies all colors by a constant color.
+ *
+ * @type {number}
+ * @constant
+ */
+const ConstantColorFactor = 211;
+
+/**
+ * Multiplies all colors by `1` minus a constant color.
+ *
+ * @type {number}
+ * @constant
+ */
+const OneMinusConstantColorFactor = 212;
+
+/**
+ * Multiplies all colors by a constant alpha value.
+ *
+ * @type {number}
+ * @constant
+ */
+const ConstantAlphaFactor = 213;
+
+/**
+ * Multiplies all colors by 1 minus a constant alpha value.
+ *
+ * @type {number}
+ * @constant
+ */
+const OneMinusConstantAlphaFactor = 214;
+
+/**
+ * Never pass.
+ *
+ * @type {number}
+ * @constant
+ */
+const NeverDepth = 0;
+
+/**
+ * Always pass.
+ *
+ * @type {number}
+ * @constant
+ */
+const AlwaysDepth = 1;
+
+/**
+ * Pass if the incoming value is less than the depth buffer value.
+ *
+ * @type {number}
+ * @constant
+ */
+const LessDepth = 2;
+
+/**
+ * Pass if the incoming value is less than or equal to the depth buffer value.
+ *
+ * @type {number}
+ * @constant
+ */
+const LessEqualDepth = 3;
+
+/**
+ * Pass if the incoming value equals the depth buffer value.
+ *
+ * @type {number}
+ * @constant
+ */
+const EqualDepth = 4;
+
+/**
+ * Pass if the incoming value is greater than or equal to the depth buffer value.
+ *
+ * @type {number}
+ * @constant
+ */
+const GreaterEqualDepth = 5;
+
+/**
+ * Pass if the incoming value is greater than the depth buffer value.
+ *
+ * @type {number}
+ * @constant
+ */
+const GreaterDepth = 6;
+
+/**
+ * Pass if the incoming value is not equal to the depth buffer value.
+ *
+ * @type {number}
+ * @constant
+ */
+const NotEqualDepth = 7;
+
+/**
+ * Multiplies the environment map color with the surface color.
+ *
+ * @type {number}
+ * @constant
+ */
+const MultiplyOperation = 0;
+
+/**
+ * Uses reflectivity to blend between the two colors.
+ *
+ * @type {number}
+ * @constant
+ */
+const MixOperation = 1;
+
+/**
+ * Adds the two colors.
+ *
+ * @type {number}
+ * @constant
+ */
+const AddOperation = 2;
+
+/**
+ * No tone mapping is applied.
+ *
+ * @type {number}
+ * @constant
+ */
+const NoToneMapping = 0;
+
+/**
+ * Linear tone mapping.
+ *
+ * @type {number}
+ * @constant
+ */
+const LinearToneMapping = 1;
+
+/**
+ * Reinhard tone mapping.
+ *
+ * @type {number}
+ * @constant
+ */
+const ReinhardToneMapping = 2;
+
+/**
+ * Cineon tone mapping.
+ *
+ * @type {number}
+ * @constant
+ */
+const CineonToneMapping = 3;
+
+/**
+ * ACES Filmic tone mapping.
+ *
+ * @type {number}
+ * @constant
+ */
+const ACESFilmicToneMapping = 4;
+
+/**
+ * Custom tone mapping.
+ *
+ * Expects a custom implementation by modifying shader code of the material's fragment shader.
+ *
+ * @type {number}
+ * @constant
+ */
+const CustomToneMapping = 5;
+
+/**
+ * AgX tone mapping.
+ *
+ * @type {number}
+ * @constant
+ */
+const AgXToneMapping = 6;
+
+/**
+ * Neutral tone mapping.
+ *
+ * Implementation based on the Khronos 3D Commerce Group standard tone mapping.
+ *
+ * @type {number}
+ * @constant
+ */
+const NeutralToneMapping = 7;
+
+/**
+ * The skinned mesh shares the same world space as the skeleton.
+ *
+ * @type {string}
+ * @constant
+ */
+const AttachedBindMode = 'attached';
+
+/**
+ * The skinned mesh does not share the same world space as the skeleton.
+ * This is useful when a skeleton is shared across multiple skinned meshes.
+ *
+ * @type {string}
+ * @constant
+ */
+const DetachedBindMode = 'detached';
+
+/**
+ * Maps textures using the geometry's UV coordinates.
+ *
+ * @type {number}
+ * @constant
+ */
+const UVMapping = 300;
+
+/**
+ * Reflection mapping for cube textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const CubeReflectionMapping = 301;
+
+/**
+ * Refraction mapping for cube textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const CubeRefractionMapping = 302;
+
+/**
+ * Reflection mapping for equirectangular textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const EquirectangularReflectionMapping = 303;
+
+/**
+ * Refraction mapping for equirectangular textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const EquirectangularRefractionMapping = 304;
+
+/**
+ * The texture will simply repeat to infinity.
+ *
+ * @type {number}
+ * @constant
+ */
+const RepeatWrapping = 1000;
+
+/**
+ * The last pixel of the texture stretches to the edge of the mesh.
+ *
+ * @type {number}
+ * @constant
+ */
+const ClampToEdgeWrapping = 1001;
+
+/**
+ * The texture will repeats to infinity, mirroring on each repeat.
+ *
+ * @type {number}
+ * @constant
+ */
+const MirroredRepeatWrapping = 1002;
+
+/**
+ * Returns the value of the texture element that is nearest (in Manhattan distance)
+ * to the specified texture coordinates.
+ *
+ * @type {number}
+ * @constant
+ */
+const NearestFilter = 1003;
+
+/**
+ * Chooses the mipmap that most closely matches the size of the pixel being textured
+ * and uses the `NearestFilter` criterion (the texel nearest to the center of the pixel)
+ * to produce a texture value.
+ *
+ * @type {number}
+ * @constant
+ */
+const NearestMipmapNearestFilter = 1004;
+const NearestMipMapNearestFilter = 1004; // legacy
+
+/**
+ * Chooses the two mipmaps that most closely match the size of the pixel being textured and
+ * uses the `NearestFilter` criterion to produce a texture value from each mipmap.
+ * The final texture value is a weighted average of those two values.
+ *
+ * @type {number}
+ * @constant
+ */
+const NearestMipmapLinearFilter = 1005;
+const NearestMipMapLinearFilter = 1005; // legacy
+
+/**
+ * Returns the weighted average of the four texture elements that are closest to the specified
+ * texture coordinates, and can include items wrapped or repeated from other parts of a texture,
+ * depending on the values of `wrapS` and `wrapT`, and on the exact mapping.
+ *
+ * @type {number}
+ * @constant
+ */
+const LinearFilter = 1006;
+
+/**
+ * Chooses the mipmap that most closely matches the size of the pixel being textured and uses
+ * the `LinearFilter` criterion (a weighted average of the four texels that are closest to the
+ * center of the pixel) to produce a texture value.
+ *
+ * @type {number}
+ * @constant
+ */
+const LinearMipmapNearestFilter = 1007;
+const LinearMipMapNearestFilter = 1007; // legacy
+
+/**
+ * Chooses the two mipmaps that most closely match the size of the pixel being textured and uses
+ * the `LinearFilter` criterion to produce a texture value from each mipmap. The final texture value
+ * is a weighted average of those two values.
+ *
+ * @type {number}
+ * @constant
+ */
+const LinearMipmapLinearFilter = 1008;
+const LinearMipMapLinearFilter = 1008; // legacy
+
+/**
+ * An unsigned byte data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const UnsignedByteType = 1009;
+
+/**
+ * A byte data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const ByteType = 1010;
+
+/**
+ * A short data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const ShortType = 1011;
+
+/**
+ * An unsigned short data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const UnsignedShortType = 1012;
+
+/**
+ * An int data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const IntType = 1013;
+
+/**
+ * An unsigned int data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const UnsignedIntType = 1014;
+
+/**
+ * A float data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const FloatType = 1015;
+
+/**
+ * A half float data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const HalfFloatType = 1016;
+
+/**
+ * An unsigned short 4_4_4_4 (packed) data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const UnsignedShort4444Type = 1017;
+
+/**
+ * An unsigned short 5_5_5_1 (packed) data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const UnsignedShort5551Type = 1018;
+
+/**
+ * An unsigned int 24_8 data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const UnsignedInt248Type = 1020;
+
+/**
+ * An unsigned int 5_9_9_9 (packed) data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const UnsignedInt5999Type = 35902;
+
+/**
+ * An unsigned int 10_11_11 (packed) data type for textures.
+ *
+ * @type {number}
+ * @constant
+ */
+const UnsignedInt101111Type = 35899;
+
+/**
+ * Discards the red, green and blue components and reads just the alpha component.
+ *
+ * @type {number}
+ * @constant
+ */
+const AlphaFormat = 1021;
+
+/**
+ * Discards the alpha component and reads the red, green and blue component.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBFormat = 1022;
+
+/**
+ * Reads the red, green, blue and alpha components.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBAFormat = 1023;
+
+/**
+ * Reads each element as a single depth value, converts it to floating point, and clamps to the range `[0,1]`.
+ *
+ * @type {number}
+ * @constant
+ */
+const DepthFormat = 1026;
+
+/**
+ * Reads each element is a pair of depth and stencil values. The depth component of the pair is interpreted as
+ * in `DepthFormat`. The stencil component is interpreted based on the depth + stencil internal format.
+ *
+ * @type {number}
+ * @constant
+ */
+const DepthStencilFormat = 1027;
+
+/**
+ * Discards the green, blue and alpha components and reads just the red component.
+ *
+ * @type {number}
+ * @constant
+ */
+const RedFormat = 1028;
+
+/**
+ * Discards the green, blue and alpha components and reads just the red component. The texels are read as integers instead of floating point.
+ *
+ * @type {number}
+ * @constant
+ */
+const RedIntegerFormat = 1029;
+
+/**
+ * Discards the alpha, and blue components and reads the red, and green components.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGFormat = 1030;
+
+/**
+ * Discards the alpha, and blue components and reads the red, and green components. The texels are read as integers instead of floating point.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGIntegerFormat = 1031;
+
+/**
+ * Discards the alpha component and reads the red, green and blue component. The texels are read as integers instead of floating point.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBIntegerFormat = 1032;
+
+/**
+ * Reads the red, green, blue and alpha components. The texels are read as integers instead of floating point.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBAIntegerFormat = 1033;
+
+/**
+ * A DXT1-compressed image in an RGB image format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGB_S3TC_DXT1_Format = 33776;
+
+/**
+ * A DXT1-compressed image in an RGB image format with a simple on/off alpha value.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_S3TC_DXT1_Format = 33777;
+
+/**
+ * A DXT3-compressed image in an RGBA image format. Compared to a 32-bit RGBA texture, it offers 4:1 compression.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_S3TC_DXT3_Format = 33778;
+
+/**
+ * A DXT5-compressed image in an RGBA image format. It also provides a 4:1 compression, but differs to the DXT3
+ * compression in how the alpha compression is done.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_S3TC_DXT5_Format = 33779;
+
+/**
+ * PVRTC RGB compression in 4-bit mode. One block for each 4×4 pixels.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGB_PVRTC_4BPPV1_Format = 35840;
+
+/**
+ * PVRTC RGB compression in 2-bit mode. One block for each 8×4 pixels.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGB_PVRTC_2BPPV1_Format = 35841;
+
+/**
+ * PVRTC RGBA compression in 4-bit mode. One block for each 4×4 pixels.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_PVRTC_4BPPV1_Format = 35842;
+
+/**
+ * PVRTC RGBA compression in 2-bit mode. One block for each 8×4 pixels.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_PVRTC_2BPPV1_Format = 35843;
+
+/**
+ * ETC1 RGB format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGB_ETC1_Format = 36196;
+
+/**
+ * ETC2 RGB format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGB_ETC2_Format = 37492;
+
+/**
+ * ETC2 RGBA format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ETC2_EAC_Format = 37496;
+
+/**
+ * EAC R11 UNORM format.
+ *
+ * @type {number}
+ * @constant
+ */
+const R11_EAC_Format = 37488; // 0x9270
+
+/**
+ * EAC R11 SNORM format.
+ *
+ * @type {number}
+ * @constant
+ */
+const SIGNED_R11_EAC_Format = 37489; // 0x9271
+
+/**
+ * EAC RG11 UNORM format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RG11_EAC_Format = 37490; // 0x9272
+
+/**
+ * EAC RG11 SNORM format.
+ *
+ * @type {number}
+ * @constant
+ */
+const SIGNED_RG11_EAC_Format = 37491; // 0x9273
+
+/**
+ * ASTC RGBA 4x4 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_4x4_Format = 37808;
+
+/**
+ * ASTC RGBA 5x4 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_5x4_Format = 37809;
+
+/**
+ * ASTC RGBA 5x5 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_5x5_Format = 37810;
+
+/**
+ * ASTC RGBA 6x5 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_6x5_Format = 37811;
+
+/**
+ * ASTC RGBA 6x6 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_6x6_Format = 37812;
+
+/**
+ * ASTC RGBA 8x5 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_8x5_Format = 37813;
+
+/**
+ * ASTC RGBA 8x6 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_8x6_Format = 37814;
+
+/**
+ * ASTC RGBA 8x8 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_8x8_Format = 37815;
+
+/**
+ * ASTC RGBA 10x5 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_10x5_Format = 37816;
+
+/**
+ * ASTC RGBA 10x6 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_10x6_Format = 37817;
+
+/**
+ * ASTC RGBA 10x8 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_10x8_Format = 37818;
+
+/**
+ * ASTC RGBA 10x10 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_10x10_Format = 37819;
+
+/**
+ * ASTC RGBA 12x10 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_12x10_Format = 37820;
+
+/**
+ * ASTC RGBA 12x12 format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_ASTC_12x12_Format = 37821;
+
+/**
+ * BPTC RGBA format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBA_BPTC_Format = 36492;
+
+/**
+ * BPTC Signed RGB format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGB_BPTC_SIGNED_Format = 36494;
+
+/**
+ * BPTC Unsigned RGB format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGB_BPTC_UNSIGNED_Format = 36495;
+
+/**
+ * RGTC1 Red format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RED_RGTC1_Format = 36283;
+
+/**
+ * RGTC1 Signed Red format.
+ *
+ * @type {number}
+ * @constant
+ */
+const SIGNED_RED_RGTC1_Format = 36284;
+
+/**
+ * RGTC2 Red Green format.
+ *
+ * @type {number}
+ * @constant
+ */
+const RED_GREEN_RGTC2_Format = 36285;
+
+/**
+ * RGTC2 Signed Red Green format.
+ *
+ * @type {number}
+ * @constant
+ */
+const SIGNED_RED_GREEN_RGTC2_Format = 36286;
+
+/**
+ * Animations are played once.
+ *
+ * @type {number}
+ * @constant
+ */
+const LoopOnce = 2200;
+
+/**
+ * Animations are played with a chosen number of repetitions, each time jumping from
+ * the end of the clip directly to its beginning.
+ *
+ * @type {number}
+ * @constant
+ */
+const LoopRepeat = 2201;
+
+/**
+ * Animations are played with a chosen number of repetitions, alternately playing forward
+ * and backward.
+ *
+ * @type {number}
+ * @constant
+ */
+const LoopPingPong = 2202;
+
+/**
+ * Discrete interpolation mode for keyframe tracks.
+ *
+ * @type {number}
+ * @constant
+ */
+const InterpolateDiscrete = 2300;
+
+/**
+ * Linear interpolation mode for keyframe tracks.
+ *
+ * @type {number}
+ * @constant
+ */
+const InterpolateLinear = 2301;
+
+/**
+ * Smooth interpolation mode for keyframe tracks.
+ *
+ * @type {number}
+ * @constant
+ */
+const InterpolateSmooth = 2302;
+
+/**
+ * Bezier interpolation mode for keyframe tracks.
+ *
+ * Uses cubic Bezier curves with explicit 2D control points.
+ * Requires tangent data to be set on the track.
+ *
+ * @type {number}
+ * @constant
+ */
+const InterpolateBezier = 2303;
+
+/**
+ * Zero curvature ending for animations.
+ *
+ * @type {number}
+ * @constant
+ */
+const ZeroCurvatureEnding = 2400;
+
+/**
+ * Zero slope ending for animations.
+ *
+ * @type {number}
+ * @constant
+ */
+const ZeroSlopeEnding = 2401;
+
+/**
+ * Wrap around ending for animations.
+ *
+ * @type {number}
+ * @constant
+ */
+const WrapAroundEnding = 2402;
+
+/**
+ * Default animation blend mode.
+ *
+ * @type {number}
+ * @constant
+ */
+const NormalAnimationBlendMode = 2500;
+
+/**
+ * Additive animation blend mode. Can be used to layer motions on top of
+ * each other to build complex performances from smaller re-usable assets.
+ *
+ * @type {number}
+ * @constant
+ */
+const AdditiveAnimationBlendMode = 2501;
+
+/**
+ * For every three vertices draw a single triangle.
+ *
+ * @type {number}
+ * @constant
+ */
+const TrianglesDrawMode = 0;
+
+/**
+ * For each vertex draw a triangle from the last three vertices.
+ *
+ * @type {number}
+ * @constant
+ */
+const TriangleStripDrawMode = 1;
+
+/**
+ * For each vertex draw a triangle from the first vertex and the last two vertices.
+ *
+ * @type {number}
+ * @constant
+ */
+const TriangleFanDrawMode = 2;
+
+/**
+ * The depth value is inverted (1.0 - z) for visualization purposes.
+ *
+ * @type {number}
+ * @constant
+ */
+const BasicDepthPacking = 3200;
+
+/**
+ * The depth value is packed into 32 bit RGBA.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBADepthPacking = 3201;
+
+/**
+ * The depth value is packed into 24 bit RGB.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGBDepthPacking = 3202;
+
+/**
+ * The depth value is packed into 16 bit RG.
+ *
+ * @type {number}
+ * @constant
+ */
+const RGDepthPacking = 3203;
+
+/**
+ * Normal information is relative to the underlying surface.
+ *
+ * @type {number}
+ * @constant
+ */
+const TangentSpaceNormalMap = 0;
+
+/**
+ * Normal information is relative to the object orientation.
+ *
+ * @type {number}
+ * @constant
+ */
+const ObjectSpaceNormalMap = 1;
+
+// Color space string identifiers, matching CSS Color Module Level 4 and WebGPU names where available.
+
+/**
+ * No color space.
+ *
+ * @type {string}
+ * @constant
+ */
+const NoColorSpace = '';
+
+/**
+ * sRGB color space.
+ *
+ * @type {string}
+ * @constant
+ */
+const SRGBColorSpace = 'srgb';
+
+/**
+ * sRGB-linear color space.
+ *
+ * @type {string}
+ * @constant
+ */
+const LinearSRGBColorSpace = 'srgb-linear';
+
+/**
+ * Linear transfer function.
+ *
+ * @type {string}
+ * @constant
+ */
+const LinearTransfer = 'linear';
+
+/**
+ * sRGB transfer function.
+ *
+ * @type {string}
+ * @constant
+ */
+const SRGBTransfer = 'srgb';
+
+/**
+ * No normal map packing.
+ *
+ * @type {string}
+ * @constant
+ */
+const NoNormalPacking = '';
+
+/**
+ * Normal RG packing.
+ *
+ * @type {string}
+ * @constant
+ */
+const NormalRGPacking = 'rg';
+
+/**
+ * Normal GA packing.
+ *
+ * @type {string}
+ * @constant
+ */
+const NormalGAPacking = 'ga';
+
+/**
+ * Sets the stencil buffer value to `0`.
+ *
+ * @type {number}
+ * @constant
+ */
+const ZeroStencilOp = 0;
+
+/**
+ * Keeps the current value.
+ *
+ * @type {number}
+ * @constant
+ */
+const KeepStencilOp = 7680;
+
+/**
+ * Sets the stencil buffer value to the specified reference value.
+ *
+ * @type {number}
+ * @constant
+ */
+const ReplaceStencilOp = 7681;
+
+/**
+ * Increments the current stencil buffer value. Clamps to the maximum representable unsigned value.
+ *
+ * @type {number}
+ * @constant
+ */
+const IncrementStencilOp = 7682;
+
+/**
+ * Decrements the current stencil buffer value. Clamps to `0`.
+ *
+ * @type {number}
+ * @constant
+ */
+const DecrementStencilOp = 7683;
+
+/**
+ * Increments the current stencil buffer value. Wraps stencil buffer value to zero when incrementing
+ * the maximum representable unsigned value.
+ *
+ * @type {number}
+ * @constant
+ */
+const IncrementWrapStencilOp = 34055;
+
+/**
+ * Decrements the current stencil buffer value. Wraps stencil buffer value to the maximum representable
+ * unsigned value when decrementing a stencil buffer value of `0`.
+ *
+ * @type {number}
+ * @constant
+ */
+const DecrementWrapStencilOp = 34056;
+
+/**
+ * Inverts the current stencil buffer value bitwise.
+ *
+ * @type {number}
+ * @constant
+ */
+const InvertStencilOp = 5386;
+
+/**
+ * Will never return true.
+ *
+ * @type {number}
+ * @constant
+ */
+const NeverStencilFunc = 512;
+
+/**
+ * Will return true if the stencil reference value is less than the current stencil value.
+ *
+ * @type {number}
+ * @constant
+ */
+const LessStencilFunc = 513;
+
+/**
+ * Will return true if the stencil reference value is equal to the current stencil value.
+ *
+ * @type {number}
+ * @constant
+ */
+const EqualStencilFunc = 514;
+
+/**
+ * Will return true if the stencil reference value is less than or equal to the current stencil value.
+ *
+ * @type {number}
+ * @constant
+ */
+const LessEqualStencilFunc = 515;
+
+/**
+ * Will return true if the stencil reference value is greater than the current stencil value.
+ *
+ * @type {number}
+ * @constant
+ */
+const GreaterStencilFunc = 516;
+
+/**
+ * Will return true if the stencil reference value is not equal to the current stencil value.
+ *
+ * @type {number}
+ * @constant
+ */
+const NotEqualStencilFunc = 517;
+
+/**
+ * Will return true if the stencil reference value is greater than or equal to the current stencil value.
+ *
+ * @type {number}
+ * @constant
+ */
+const GreaterEqualStencilFunc = 518;
+
+/**
+ * Will always return true.
+ *
+ * @type {number}
+ * @constant
+ */
+const AlwaysStencilFunc = 519;
+
+/**
+ * Never pass.
+ *
+ * @type {number}
+ * @constant
+ */
+const NeverCompare = 512;
+
+/**
+ * Pass if the incoming value is less than the texture value.
+ *
+ * @type {number}
+ * @constant
+ */
+const LessCompare = 513;
+
+/**
+ * Pass if the incoming value equals the texture value.
+ *
+ * @type {number}
+ * @constant
+ */
+const EqualCompare = 514;
+
+/**
+ * Pass if the incoming value is less than or equal to the texture value.
+ *
+ * @type {number}
+ * @constant
+ */
+const LessEqualCompare = 515;
+
+/**
+ * Pass if the incoming value is greater than the texture value.
+ *
+ * @type {number}
+ * @constant
+ */
+const GreaterCompare = 516;
+
+/**
+ * Pass if the incoming value is not equal to the texture value.
+ *
+ * @type {number}
+ * @constant
+ */
+const NotEqualCompare = 517;
+
+/**
+ * Pass if the incoming value is greater than or equal to the texture value.
+ *
+ * @type {number}
+ * @constant
+ */
+const GreaterEqualCompare = 518;
+
+/**
+ * Always pass.
+ *
+ * @type {number}
+ * @constant
+ */
+const AlwaysCompare = 519;
+
+/**
+ * The contents are intended to be specified once by the application, and used many
+ * times as the source for drawing and image specification commands.
+ *
+ * @type {number}
+ * @constant
+ */
+const StaticDrawUsage = 35044;
+
+/**
+ * The contents are intended to be respecified repeatedly by the application, and
+ * used many times as the source for drawing and image specification commands.
+ *
+ * @type {number}
+ * @constant
+ */
+const DynamicDrawUsage = 35048;
+
+/**
+ * The contents are intended to be specified once by the application, and used at most
+ * a few times as the source for drawing and image specification commands.
+ *
+ * @type {number}
+ * @constant
+ */
+const StreamDrawUsage = 35040;
+
+/**
+ * The contents are intended to be specified once by reading data from the 3D API, and queried
+ * many times by the application.
+ *
+ * @type {number}
+ * @constant
+ */
+const StaticReadUsage = 35045;
+
+/**
+ * The contents are intended to be respecified repeatedly by reading data from the 3D API, and queried
+ * many times by the application.
+ *
+ * @type {number}
+ * @constant
+ */
+const DynamicReadUsage = 35049;
+
+/**
+ * The contents are intended to be specified once by reading data from the 3D API, and queried at most
+ * a few times by the application
+ *
+ * @type {number}
+ * @constant
+ */
+const StreamReadUsage = 35041;
+
+/**
+ * The contents are intended to be specified once by reading data from the 3D API, and used many times as
+ * the source for WebGL drawing and image specification commands.
+ *
+ * @type {number}
+ * @constant
+ */
+const StaticCopyUsage = 35046;
+
+/**
+ * The contents are intended to be respecified repeatedly by reading data from the 3D API, and used many times
+ * as the source for WebGL drawing and image specification commands.
+ *
+ * @type {number}
+ * @constant
+ */
+const DynamicCopyUsage = 35050;
+
+/**
+ * The contents are intended to be specified once by reading data from the 3D API, and used at most a few times
+ * as the source for WebGL drawing and image specification commands.
+ *
+ * @type {number}
+ * @constant
+ */
+const StreamCopyUsage = 35042;
+
+/**
+ * GLSL 1 shader code.
+ *
+ * @type {string}
+ * @constant
+ */
+const GLSL1 = '100';
+
+/**
+ * GLSL 3 shader code.
+ *
+ * @type {string}
+ * @constant
+ */
+const GLSL3 = '300 es';
+
+/**
+ * WebGL coordinate system.
+ *
+ * @type {number}
+ * @constant
+ */
+const WebGLCoordinateSystem = 2000;
+
+/**
+ * WebGPU coordinate system.
+ *
+ * @type {number}
+ * @constant
+ */
+const WebGPUCoordinateSystem = 2001;
+
+/**
+ * Represents the different timestamp query types.
+ *
+ * @type {ConstantsTimestampQuery}
+ * @constant
+ */
+const TimestampQuery = {
+ COMPUTE: 'compute',
+ RENDER: 'render'
+};
+
+/**
+ * Represents mouse buttons and interaction types in context of controls.
+ *
+ * @type {ConstantsInterpolationSamplingType}
+ * @constant
+ */
+const InterpolationSamplingType = {
+ PERSPECTIVE: 'perspective',
+ LINEAR: 'linear',
+ FLAT: 'flat'
+};
+
+/**
+ * Represents the different interpolation sampling modes.
+ *
+ * @type {ConstantsInterpolationSamplingMode}
+ * @constant
+ */
+const InterpolationSamplingMode = {
+ NORMAL: 'normal',
+ CENTROID: 'centroid',
+ SAMPLE: 'sample',
+ FIRST: 'first',
+ EITHER: 'either'
+};
+
+/**
+ * Compatibility flags for features that may not be supported across all platforms.
+ *
+ * @type {Object}
+ * @constant
+ */
+const Compatibility = {
+ TEXTURE_COMPARE: 'depthTextureCompare'
+};
+
+/**
+ * Represents the refresh types of render objects.
+ *
+ * @type {ConstantsRenderObjectRefreshType}
+ * @constant
+ */
+const RenderObjectRefreshType = {
+ NONE: 0,
+ SHARED: 1,
+ FULL: 2
+};
+
+/**
+ * This type represents mouse buttons and interaction types in context of controls.
+ *
+ * @typedef {Object} ConstantsMouse
+ * @property {number} MIDDLE - The left mouse button.
+ * @property {number} LEFT - The middle mouse button.
+ * @property {number} RIGHT - The right mouse button.
+ * @property {number} ROTATE - A rotate interaction.
+ * @property {number} DOLLY - A dolly interaction.
+ * @property {number} PAN - A pan interaction.
+ **/
+
+/**
+ * This type represents touch interaction types in context of controls.
+ *
+ * @typedef {Object} ConstantsTouch
+ * @property {number} ROTATE - A rotate interaction.
+ * @property {number} PAN - A pan interaction.
+ * @property {number} DOLLY_PAN - The dolly-pan interaction.
+ * @property {number} DOLLY_ROTATE - A dolly-rotate interaction.
+ **/
+
+/**
+ * This type represents the different timestamp query types.
+ *
+ * @typedef {Object} ConstantsTimestampQuery
+ * @property {string} COMPUTE - A `compute` timestamp query.
+ * @property {string} RENDER - A `render` timestamp query.
+ **/
+
+/**
+ * Represents the different interpolation sampling types.
+ *
+ * @typedef {Object} ConstantsInterpolationSamplingType
+ * @property {string} PERSPECTIVE - Perspective-correct interpolation.
+ * @property {string} LINEAR - Linear interpolation.
+ * @property {string} FLAT - Flat interpolation.
+ */
+
+/**
+ * Represents the different interpolation sampling modes.
+ *
+ * @typedef {Object} ConstantsInterpolationSamplingMode
+ * @property {string} NORMAL - Normal sampling mode.
+ * @property {string} CENTROID - Centroid sampling mode.
+ * @property {string} SAMPLE - Sample-specific sampling mode.
+ * @property {string} FIRST - Flat interpolation using the first vertex.
+ * @property {string} EITHER - Flat interpolation using either vertex.
+ */
+
+/**
+ * Represents the refresh types of render objects.
+ *
+ * @typedef {Object} ConstantsRenderObjectRefreshType
+ * @property {number} NONE - No refresh required.
+ * @property {number} SHARED - Only shared uniform buffers require an update.
+ * @property {number} FULL - The render object requires a full refresh.
+ */
+
+/**
+ * Checks if an array contains values that require Uint32 representation.
+ *
+ * This function determines whether the array contains any values >= 65535,
+ * which would require a Uint32Array rather than a Uint16Array for proper storage.
+ * The function iterates from the end of the array, assuming larger values are
+ * typically located at the end.
+ *
+ * @private
+ * @param {Array} array - The array to check.
+ * @return {boolean} True if the array contains values >= 65535, false otherwise.
+ */
+function arrayNeedsUint32( array ) {
+
+ // assumes larger values usually on last
+
+ for ( let i = array.length - 1; i >= 0; -- i ) {
+
+ if ( array[ i ] >= 65535 ) return true; // account for PRIMITIVE_RESTART_FIXED_INDEX, #24565
+
+ }
+
+ return false;
+
+}
+
+/**
+ * Map of typed array constructor names to their constructors.
+ * This mapping enables dynamic creation of typed arrays based on string type names.
+ *
+ * @private
+ * @constant
+ * @type {Object}
+ */
+const TYPED_ARRAYS = {
+ Int8Array: Int8Array,
+ Uint8Array: Uint8Array,
+ Uint8ClampedArray: Uint8ClampedArray,
+ Int16Array: Int16Array,
+ Uint16Array: Uint16Array,
+ Int32Array: Int32Array,
+ Uint32Array: Uint32Array,
+ Float32Array: Float32Array,
+ Float64Array: Float64Array
+};
+
+/**
+ * Creates a typed array of the specified type from the given buffer.
+ *
+ * @private
+ * @param {string} type - The name of the typed array type (e.g., 'Float32Array', 'Uint16Array').
+ * @param {ArrayBuffer} buffer - The buffer to create the typed array from.
+ * @return {TypedArray} A new typed array of the specified type.
+ */
+function getTypedArray( type, buffer ) {
+
+ return new TYPED_ARRAYS[ type ]( buffer );
+
+}
+
+/**
+ * Returns `true` if the given object is a typed array.
+ *
+ * @param {any} array - The object to check.
+ * @return {boolean} Whether the given object is a typed array.
+ */
+function isTypedArray( array ) {
+
+ return ArrayBuffer.isView( array ) && ! ( array instanceof DataView );
+
+}
+
+/**
+ * Creates an XHTML element with the specified tag name.
+ *
+ * This function uses the XHTML namespace to create DOM elements,
+ * ensuring proper element creation in XML-based contexts.
+ *
+ * @private
+ * @param {string} name - The tag name of the element to create (e.g., 'canvas', 'div').
+ * @return {HTMLElement} The created XHTML element.
+ */
+function createElementNS( name ) {
+
+ return document.createElementNS( 'http://www.w3.org/1999/xhtml', name );
+
+}
+
+/**
+ * Creates a canvas element configured for block display.
+ *
+ * This is a convenience function that creates a canvas element with
+ * display style set to 'block', which is commonly used in three.js
+ * rendering contexts to avoid inline element spacing issues.
+ *
+ * @return {HTMLCanvasElement} A canvas element with display set to 'block'.
+ */
+function createCanvasElement() {
+
+ const canvas = createElementNS( 'canvas' );
+ canvas.style.display = 'block';
+ return canvas;
+
+}
+
+/**
+ * Internal cache for tracking warning messages to prevent duplicate warnings.
+ *
+ * @private
+ * @type {Object}
+ */
+const _cache = {};
+
+/**
+ * Custom console function handler for intercepting log, warn, and error calls.
+ *
+ * @private
+ * @type {Function|null}
+ */
+let _setConsoleFunction = null;
+
+/**
+ * Sets a custom function to handle console output.
+ *
+ * This allows external code to intercept and handle console.log, console.warn,
+ * and console.error calls made by three.js, which is useful for custom logging,
+ * testing, or debugging workflows.
+ *
+ * @param {Function} fn - The function to handle console output. Should accept
+ * (type, message, ...params) where type is 'log', 'warn', or 'error'.
+ */
+function setConsoleFunction( fn ) {
+
+ _setConsoleFunction = fn;
+
+}
+
+/**
+ * Gets the currently set custom console function.
+ *
+ * @return {Function|null} The custom console function, or null if not set.
+ */
+function getConsoleFunction() {
+
+ return _setConsoleFunction;
+
+}
+
+/**
+ * Logs an informational message with the 'THREE.' prefix.
+ *
+ * If a custom console function is set via setConsoleFunction(), it will be used
+ * instead of the native console.log. The first parameter is treated as the
+ * method name and is automatically prefixed with 'THREE.'.
+ *
+ * @param {...any} params - The message components. The first param is used as
+ * the method name and prefixed with 'THREE.'.
+ */
+function log( ...params ) {
+
+ const message = 'THREE.' + params.shift();
+
+ if ( _setConsoleFunction ) {
+
+ _setConsoleFunction( 'log', message, ...params );
+
+ } else {
+
+ console.log( message, ...params );
+
+ }
+
+}
+
+/**
+ * Enhances log/warn/error messages related to TSL.
+ *
+ * @param {Array} params - The original message parameters.
+ * @returns {Array} The filtered and enhanced message parameters.
+ */
+function enhanceLogMessage( params ) {
+
+ const message = params[ 0 ];
+
+ if ( typeof message === 'string' && message.startsWith( 'TSL:' ) ) {
+
+ const stackTrace = params[ 1 ];
+
+ if ( stackTrace && stackTrace.isStackTrace ) {
+
+ params[ 0 ] += ' ' + stackTrace.getLocation();
+
+ } else {
+
+ params[ 1 ] = 'Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.';
+
+ }
+
+ }
+
+ return params;
+
+}
+
+/**
+ * Logs a warning message with the 'THREE.' prefix.
+ *
+ * If a custom console function is set via setConsoleFunction(), it will be used
+ * instead of the native console.warn. The first parameter is treated as the
+ * method name and is automatically prefixed with 'THREE.'.
+ *
+ * @param {...any} params - The message components. The first param is used as
+ * the method name and prefixed with 'THREE.'.
+ */
+function warn( ...params ) {
+
+ params = enhanceLogMessage( params );
+
+ const message = 'THREE.' + params.shift();
+
+ if ( _setConsoleFunction ) {
+
+ _setConsoleFunction( 'warn', message, ...params );
+
+ } else {
+
+ const stackTrace = params[ 0 ];
+
+ if ( stackTrace && stackTrace.isStackTrace ) {
+
+ console.warn( stackTrace.getError( message ) );
+
+ } else {
+
+ console.warn( message, ...params );
+
+ }
+
+ }
+
+}
+
+/**
+ * Logs an error message with the 'THREE.' prefix.
+ *
+ * If a custom console function is set via setConsoleFunction(), it will be used
+ * instead of the native console.error. The first parameter is treated as the
+ * method name and is automatically prefixed with 'THREE.'.
+ *
+ * @param {...any} params - The message components. The first param is used as
+ * the method name and prefixed with 'THREE.'.
+ */
+function error( ...params ) {
+
+ params = enhanceLogMessage( params );
+
+ const message = 'THREE.' + params.shift();
+
+ if ( _setConsoleFunction ) {
+
+ _setConsoleFunction( 'error', message, ...params );
+
+ } else {
+
+ const stackTrace = params[ 0 ];
+
+ if ( stackTrace && stackTrace.isStackTrace ) {
+
+ console.error( stackTrace.getError( message ) );
+
+ } else {
+
+ console.error( message, ...params );
+
+ }
+
+ }
+
+}
+
+/**
+ * Logs a warning message only once, preventing duplicate warnings.
+ *
+ * This function maintains an internal cache of warning messages and will only
+ * output each unique warning message once. Useful for warnings that may be
+ * triggered repeatedly but should only be shown to the user once.
+ *
+ * @param {...any} params - The warning message components.
+ */
+function warnOnce( ...params ) {
+
+ const message = params.join( ' ' );
+
+ if ( message in _cache ) return;
+
+ _cache[ message ] = true;
+
+ warn( ...params );
+
+}
+
+/**
+ * Yields execution to the main thread to allow rendering and other tasks.
+ * Uses scheduler.yield() when available (Chrome 115+), falls back to requestAnimationFrame.
+ *
+ * @return {Promise}
+ */
+function yieldToMain() {
+
+ if ( typeof self !== 'undefined' && typeof self.scheduler !== 'undefined' && typeof self.scheduler.yield !== 'undefined' ) {
+
+ return self.scheduler.yield();
+
+ }
+
+ return new Promise( resolve => {
+
+ requestAnimationFrame( resolve );
+
+ } );
+
+}
+
+/**
+ * Asynchronously probes for WebGL sync object completion.
+ *
+ * This function creates a promise that resolves when the WebGL sync object
+ * signals completion or rejects if the sync operation fails. It uses polling
+ * at the specified interval to check the sync status without blocking the
+ * main thread. This is useful for GPU-CPU synchronization in WebGL contexts.
+ *
+ * @private
+ * @param {WebGL2RenderingContext} gl - The WebGL rendering context.
+ * @param {WebGLSync} sync - The WebGL sync object to wait for.
+ * @param {number} interval - The polling interval in milliseconds.
+ * @return {Promise} A promise that resolves when the sync completes or rejects if it fails.
+ */
+function probeAsync( gl, sync, interval ) {
+
+ return new Promise( function ( resolve, reject ) {
+
+ function probe() {
+
+ switch ( gl.clientWaitSync( sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0 ) ) {
+
+ case gl.WAIT_FAILED:
+ reject();
+ break;
+
+ case gl.TIMEOUT_EXPIRED:
+ setTimeout( probe, interval );
+ break;
+
+ default:
+ resolve();
+
+ }
+
+ }
+
+ setTimeout( probe, interval );
+
+ } );
+
+}
+
+/**
+ * Used to select the correct depth functions
+ * when reversed depth buffer is used.
+ *
+ * @private
+ * @type {Object}
+ */
+const ReversedDepthFuncs = {
+ [ NeverDepth ]: NeverDepth,
+ [ LessDepth ]: GreaterDepth,
+ [ EqualDepth ]: EqualDepth,
+ [ LessEqualDepth ]: GreaterEqualDepth,
+
+ [ AlwaysDepth ]: AlwaysDepth,
+ [ GreaterDepth ]: LessDepth,
+ [ NotEqualDepth ]: NotEqualDepth,
+ [ GreaterEqualDepth ]: LessEqualDepth,
+};
+
+/**
+ * This modules allows to dispatch event objects on custom JavaScript objects.
+ *
+ * Main repository: [eventdispatcher.js](https://github.com/mrdoob/eventdispatcher.js/)
+ *
+ * Code Example:
+ * ```js
+ * class Car extends EventDispatcher {
+ * start() {
+ * this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
+ * }
+ *};
+ *
+ * // Using events with the custom object
+ * const car = new Car();
+ * car.addEventListener( 'start', function ( event ) {
+ * alert( event.message );
+ * } );
+ *
+ * car.start();
+ * ```
+ */
+class EventDispatcher {
+
+ /**
+ * Adds the given event listener to the given event type.
+ *
+ * @param {string} type - The type of event to listen to.
+ * @param {Function} listener - The function that gets called when the event is fired.
+ */
+ addEventListener( type, listener ) {
+
+ if ( this._listeners === undefined ) this._listeners = {};
+
+ const listeners = this._listeners;
+
+ if ( listeners[ type ] === undefined ) {
+
+ listeners[ type ] = [];
+
+ }
+
+ if ( listeners[ type ].indexOf( listener ) === -1 ) {
+
+ listeners[ type ].push( listener );
+
+ }
+
+ }
+
+ /**
+ * Returns `true` if the given event listener has been added to the given event type.
+ *
+ * @param {string} type - The type of event.
+ * @param {Function} listener - The listener to check.
+ * @return {boolean} Whether the given event listener has been added to the given event type.
+ */
+ hasEventListener( type, listener ) {
+
+ const listeners = this._listeners;
+
+ if ( listeners === undefined ) return false;
+
+ return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== -1;
+
+ }
+
+ /**
+ * Removes the given event listener from the given event type.
+ *
+ * @param {string} type - The type of event.
+ * @param {Function} listener - The listener to remove.
+ */
+ removeEventListener( type, listener ) {
+
+ const listeners = this._listeners;
+
+ if ( listeners === undefined ) return;
+
+ const listenerArray = listeners[ type ];
+
+ if ( listenerArray !== undefined ) {
+
+ const index = listenerArray.indexOf( listener );
+
+ if ( index !== -1 ) {
+
+ listenerArray.splice( index, 1 );
+
+ }
+
+ }
+
+ }
+
+ /**
+ * Dispatches an event object.
+ *
+ * @param {Object} event - The event that gets fired.
+ */
+ dispatchEvent( event ) {
+
+ const listeners = this._listeners;
+
+ if ( listeners === undefined ) return;
+
+ const listenerArray = listeners[ event.type ];
+
+ if ( listenerArray !== undefined ) {
+
+ event.target = this;
+
+ // Make a copy, in case listeners are removed while iterating.
+ const array = listenerArray.slice( 0 );
+
+ for ( let i = 0, l = array.length; i < l; i ++ ) {
+
+ array[ i ].call( this, event );
+
+ }
+
+ event.target = null;
+
+ }
+
+ }
+
+}
+
+const _lut = [ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff' ];
+
+let _seed = 1234567;
+
+
+const DEG2RAD = Math.PI / 180;
+const RAD2DEG = 180 / Math.PI;
+
+/**
+ * Generate a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)
+ * (universally unique identifier).
+ *
+ * @return {string} The UUID.
+ */
+function generateUUID() {
+
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
+
+ const d0 = Math.random() * 0xffffffff | 0;
+ const d1 = Math.random() * 0xffffffff | 0;
+ const d2 = Math.random() * 0xffffffff | 0;
+ const d3 = Math.random() * 0xffffffff | 0;
+ const uuid = _lut[ d0 & 0xff ] + _lut[ d0 >> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' +
+ _lut[ d1 & 0xff ] + _lut[ d1 >> 8 & 0xff ] + '-' + _lut[ d1 >> 16 & 0x0f | 0x40 ] + _lut[ d1 >> 24 & 0xff ] + '-' +
+ _lut[ d2 & 0x3f | 0x80 ] + _lut[ d2 >> 8 & 0xff ] + '-' + _lut[ d2 >> 16 & 0xff ] + _lut[ d2 >> 24 & 0xff ] +
+ _lut[ d3 & 0xff ] + _lut[ d3 >> 8 & 0xff ] + _lut[ d3 >> 16 & 0xff ] + _lut[ d3 >> 24 & 0xff ];
+
+ // .toLowerCase() here flattens concatenated strings to save heap memory space.
+ return uuid.toLowerCase();
+
+}
+
+/**
+ * Clamps the given value between min and max.
+ *
+ * @param {number} value - The value to clamp.
+ * @param {number} min - The min value.
+ * @param {number} max - The max value.
+ * @return {number} The clamped value.
+ */
+function clamp( value, min, max ) {
+
+ return Math.max( min, Math.min( max, value ) );
+
+}
+
+/**
+ * Computes the Euclidean modulo of the given parameters that
+ * is `( ( n % m ) + m ) % m`.
+ *
+ * @param {number} n - The first parameter.
+ * @param {number} m - The second parameter.
+ * @return {number} The Euclidean modulo.
+ */
+function euclideanModulo( n, m ) {
+
+ // https://en.wikipedia.org/wiki/Modulo_operation
+
+ return ( ( n % m ) + m ) % m;
+
+}
+
+/**
+ * Performs a linear mapping from range `` to range ``
+ * for the given value. `a2` must be greater than `a1`.
+ *
+ * @param {number} x - The value to be mapped.
+ * @param {number} a1 - Minimum value for range A.
+ * @param {number} a2 - Maximum value for range A.
+ * @param {number} b1 - Minimum value for range B.
+ * @param {number} b2 - Maximum value for range B.
+ * @return {number} The mapped value.
+ */
+function mapLinear( x, a1, a2, b1, b2 ) {
+
+ return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );
+
+}
+
+/**
+ * Returns the percentage in the closed interval `[0, 1]` of the given value
+ * between the start and end point.
+ *
+ * @param {number} x - The start point
+ * @param {number} y - The end point.
+ * @param {number} value - A value between start and end.
+ * @return {number} The interpolation factor.
+ */
+function inverseLerp( x, y, value ) {
+
+ // https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/
+
+ if ( x !== y ) {
+
+ return ( value - x ) / ( y - x );
+
+ } else {
+
+ return 0;
+
+ }
+
+}
+
+/**
+ * Returns a value linearly interpolated from two known points based on the given interval -
+ * `t = 0` will return `x` and `t = 1` will return `y`.
+ *
+ * @param {number} x - The start point
+ * @param {number} y - The end point.
+ * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
+ * @return {number} The interpolated value.
+ */
+function lerp( x, y, t ) {
+
+ return ( 1 - t ) * x + t * y;
+
+}
+
+/**
+ * Smoothly interpolate a number from `x` to `y` in a spring-like manner using a delta
+ * time to maintain frame rate independent movement. For details, see
+ * [Frame rate independent damping using lerp](http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/).
+ *
+ * @param {number} x - The current point.
+ * @param {number} y - The target point.
+ * @param {number} lambda - A higher lambda value will make the movement more sudden,
+ * and a lower value will make the movement more gradual.
+ * @param {number} dt - Delta time in seconds.
+ * @return {number} The interpolated value.
+ */
+function damp( x, y, lambda, dt ) {
+
+ return lerp( x, y, 1 - Math.exp( - lambda * dt ) );
+
+}
+
+/**
+ * Returns a value that alternates between `0` and the given `length` parameter.
+ *
+ * @param {number} x - The value to pingpong.
+ * @param {number} [length=1] - The positive value the function will pingpong to.
+ * @return {number} The alternated value.
+ */
+function pingpong( x, length = 1 ) {
+
+ // https://www.desmos.com/calculator/vcsjnyz7x4
+
+ return length - Math.abs( euclideanModulo( x, length * 2 ) - length );
+
+}
+
+/**
+ * Returns a value in the range `[0,1]` that represents the percentage that `x` has
+ * moved between `min` and `max`, but smoothed or slowed down the closer `x` is to
+ * the `min` and `max`.
+ *
+ * See [Smoothstep](http://en.wikipedia.org/wiki/Smoothstep) for more details.
+ *
+ * @param {number} x - The value to evaluate based on its position between `min` and `max`.
+ * @param {number} min - The min value. Any `x` value below `min` will be `0`. `min` must be lower than `max`.
+ * @param {number} max - The max value. Any `x` value above `max` will be `1`. `max` must be greater than `min`.
+ * @return {number} The alternated value.
+ */
+function smoothstep( x, min, max ) {
+
+ if ( x <= min ) return 0;
+ if ( x >= max ) return 1;
+
+ x = ( x - min ) / ( max - min );
+
+ return x * x * ( 3 - 2 * x );
+
+}
+
+/**
+ * A [variation on smoothstep](https://en.wikipedia.org/wiki/Smoothstep#Variations)
+ * that has zero 1st and 2nd order derivatives at `x=0` and `x=1`.
+ *
+ * @param {number} x - The value to evaluate based on its position between `min` and `max`.
+ * @param {number} min - The min value. Any `x` value below `min` will be `0`. `min` must be lower than `max`.
+ * @param {number} max - The max value. Any `x` value above `max` will be `1`. `max` must be greater than `min`.
+ * @return {number} The alternated value.
+ */
+function smootherstep( x, min, max ) {
+
+ if ( x <= min ) return 0;
+ if ( x >= max ) return 1;
+
+ x = ( x - min ) / ( max - min );
+
+ return x * x * x * ( x * ( x * 6 - 15 ) + 10 );
+
+}
+
+/**
+ * Returns a random integer from `` interval.
+ *
+ * @param {number} low - The lower value boundary.
+ * @param {number} high - The upper value boundary
+ * @return {number} A random integer.
+ */
+function randInt( low, high ) {
+
+ return low + Math.floor( Math.random() * ( high - low + 1 ) );
+
+}
+
+/**
+ * Returns a random float from `` interval.
+ *
+ * @param {number} low - The lower value boundary.
+ * @param {number} high - The upper value boundary
+ * @return {number} A random float.
+ */
+function randFloat( low, high ) {
+
+ return low + Math.random() * ( high - low );
+
+}
+
+/**
+ * Returns a random integer from `<-range/2, range/2>` interval.
+ *
+ * @param {number} range - Defines the value range.
+ * @return {number} A random float.
+ */
+function randFloatSpread( range ) {
+
+ return range * ( 0.5 - Math.random() );
+
+}
+
+/**
+ * Returns a deterministic pseudo-random float in the interval `[0, 1]`.
+ *
+ * @param {number} [s] - The integer seed.
+ * @return {number} A random float.
+ */
+function seededRandom( s ) {
+
+ if ( s !== undefined ) _seed = s;
+
+ // Mulberry32 generator
+
+ let t = _seed += 0x6D2B79F5;
+
+ t = Math.imul( t ^ t >>> 15, t | 1 );
+
+ t ^= t + Math.imul( t ^ t >>> 7, t | 61 );
+
+ return ( ( t ^ t >>> 14 ) >>> 0 ) / 4294967296;
+
+}
+
+/**
+ * Converts degrees to radians.
+ *
+ * @param {number} degrees - A value in degrees.
+ * @return {number} The converted value in radians.
+ */
+function degToRad( degrees ) {
+
+ return degrees * DEG2RAD;
+
+}
+
+/**
+ * Converts radians to degrees.
+ *
+ * @param {number} radians - A value in radians.
+ * @return {number} The converted value in degrees.
+ */
+function radToDeg( radians ) {
+
+ return radians * RAD2DEG;
+
+}
+
+/**
+ * Returns `true` if the given integer is a power of two.
+ *
+ * @param {number} value - The value to check.
+ * @return {boolean} Whether the given integer is a power of two or not.
+ */
+function isPowerOfTwo( value ) {
+
+ return value > 0 && Number.isInteger( value ) && 2 ** Math.round( Math.log2( value ) ) === value;
+
+}
+
+/**
+ * Returns the smallest power of two that is greater than or equal to the given number.
+ *
+ * @param {number} value - The value to find a POT for. Must be greater than `0`.
+ * @return {number} The smallest power of two that is greater than or equal to the given number.
+ */
+function ceilPowerOfTwo( value ) {
+
+ return Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );
+
+}
+
+/**
+ * Returns the largest power of two that is less than or equal to the given number.
+ *
+ * @param {number} value - The value to find a POT for. Must be greater than `0`.
+ * @return {number} The largest power of two that is less than or equal to the given number.
+ */
+function floorPowerOfTwo( value ) {
+
+ return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );
+
+}
+
+/**
+ * Sets the given quaternion from the [Intrinsic Proper Euler Angles](https://en.wikipedia.org/wiki/Euler_angles)
+ * defined by the given angles and order.
+ *
+ * Rotations are applied to the axes in the order specified by order:
+ * rotation by angle `a` is applied first, then by angle `b`, then by angle `c`.
+ *
+ * @param {Quaternion} q - The quaternion to set.
+ * @param {number} a - The rotation applied to the first axis, in radians.
+ * @param {number} b - The rotation applied to the second axis, in radians.
+ * @param {number} c - The rotation applied to the third axis, in radians.
+ * @param {('XYX'|'XZX'|'YXY'|'YZY'|'ZXZ'|'ZYZ')} order - A string specifying the axes order.
+ */
+function setQuaternionFromProperEuler( q, a, b, c, order ) {
+
+ const cos = Math.cos;
+ const sin = Math.sin;
+
+ const c2 = cos( b / 2 );
+ const s2 = sin( b / 2 );
+
+ const c13 = cos( ( a + c ) / 2 );
+ const s13 = sin( ( a + c ) / 2 );
+
+ const c1_3 = cos( ( a - c ) / 2 );
+ const s1_3 = sin( ( a - c ) / 2 );
+
+ const c3_1 = cos( ( c - a ) / 2 );
+ const s3_1 = sin( ( c - a ) / 2 );
+
+ switch ( order ) {
+
+ case 'XYX':
+ q.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 );
+ break;
+
+ case 'YZY':
+ q.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 );
+ break;
+
+ case 'ZXZ':
+ q.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 );
+ break;
+
+ case 'XZX':
+ q.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 );
+ break;
+
+ case 'YXY':
+ q.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 );
+ break;
+
+ case 'ZYZ':
+ q.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 );
+ break;
+
+ default:
+ warn( 'MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );
+
+ }
+
+}
+
+/**
+ * Returns the factor used by {@link normalize} and {@link denormalize} for the given typed array,
+ * or `undefined` if the values are not scaled (float arrays) or the array type is not supported.
+ *
+ * @param {TypedArray} array - The typed array that defines the data type of the value.
+ * @return {number|undefined} The normalization factor.
+ */
+function getNormalizationScale( array ) {
+
+ switch ( array.constructor ) {
+
+ case Uint32Array:
+
+ return 4294967295.0;
+
+ case Uint16Array:
+
+ return 65535.0;
+
+ case Uint8Array:
+ case Uint8ClampedArray:
+
+ return 255.0;
+
+ case Int32Array:
+
+ return 2147483647.0;
+
+ case Int16Array:
+
+ return 32767.0;
+
+ case Int8Array:
+
+ return 127.0;
+
+ default:
+
+ return undefined;
+
+ }
+
+}
+
+/**
+ * Denormalizes the given value according to the given typed array.
+ *
+ * @param {number} value - The value to denormalize.
+ * @param {TypedArray} array - The typed array that defines the data type of the value.
+ * @return {number} The denormalized (float) value in the range `[0,1]` or `[-1,1]`
+ */
+function denormalize( value, array ) {
+
+ if ( array.constructor === Float32Array ) return value;
+
+ const scale = getNormalizationScale( array );
+
+ if ( scale === undefined ) throw new Error( 'THREE.MathUtils: Invalid component type.' );
+
+ return Math.max( value / scale, -1 );
+
+}
+
+/**
+ * Normalizes the given value according to the given typed array.
+ *
+ * @param {number} value - The float value in the range `[0,1]` or `[-1,1]` to normalize.
+ * @param {TypedArray} array - The typed array that defines the data type of the value.
+ * @return {number} The normalized value.
+ */
+function normalize( value, array ) {
+
+ if ( array.constructor === Float32Array ) return value;
+
+ const scale = getNormalizationScale( array );
+
+ if ( scale === undefined ) throw new Error( 'THREE.MathUtils: Invalid component type.' );
+
+ return Math.round( value * scale );
+
+}
+
+/**
+ * @class
+ * @classdesc A collection of math utility functions.
+ * @hideconstructor
+ */
+const MathUtils = {
+ DEG2RAD: DEG2RAD,
+ RAD2DEG: RAD2DEG,
+ /**
+ * Generate a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)
+ * (universally unique identifier).
+ *
+ * @static
+ * @method
+ * @return {string} The UUID.
+ */
+ generateUUID: generateUUID,
+ /**
+ * Clamps the given value between min and max.
+ *
+ * @static
+ * @method
+ * @param {number} value - The value to clamp.
+ * @param {number} min - The min value.
+ * @param {number} max - The max value.
+ * @return {number} The clamped value.
+ */
+ clamp: clamp,
+ /**
+ * Computes the Euclidean modulo of the given parameters that
+ * is `( ( n % m ) + m ) % m`.
+ *
+ * @static
+ * @method
+ * @param {number} n - The first parameter.
+ * @param {number} m - The second parameter.
+ * @return {number} The Euclidean modulo.
+ */
+ euclideanModulo: euclideanModulo,
+ /**
+ * Performs a linear mapping from range `` to range ``
+ * for the given value.
+ *
+ * @static
+ * @method
+ * @param {number} x - The value to be mapped.
+ * @param {number} a1 - Minimum value for range A.
+ * @param {number} a2 - Maximum value for range A.
+ * @param {number} b1 - Minimum value for range B.
+ * @param {number} b2 - Maximum value for range B.
+ * @return {number} The mapped value.
+ */
+ mapLinear: mapLinear,
+ /**
+ * Returns the percentage in the closed interval `[0, 1]` of the given value
+ * between the start and end point.
+ *
+ * @static
+ * @method
+ * @param {number} x - The start point
+ * @param {number} y - The end point.
+ * @param {number} value - A value between start and end.
+ * @return {number} The interpolation factor.
+ */
+ inverseLerp: inverseLerp,
+ /**
+ * Returns a value linearly interpolated from two known points based on the given interval -
+ * `t = 0` will return `x` and `t = 1` will return `y`.
+ *
+ * @static
+ * @method
+ * @param {number} x - The start point
+ * @param {number} y - The end point.
+ * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
+ * @return {number} The interpolated value.
+ */
+ lerp: lerp,
+ /**
+ * Smoothly interpolate a number from `x` to `y` in a spring-like manner using a delta
+ * time to maintain frame rate independent movement. For details, see
+ * [Frame rate independent damping using lerp](http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/).
+ *
+ * @static
+ * @method
+ * @param {number} x - The current point.
+ * @param {number} y - The target point.
+ * @param {number} lambda - A higher lambda value will make the movement more sudden,
+ * and a lower value will make the movement more gradual.
+ * @param {number} dt - Delta time in seconds.
+ * @return {number} The interpolated value.
+ */
+ damp: damp,
+ /**
+ * Returns a value that alternates between `0` and the given `length` parameter.
+ *
+ * @static
+ * @method
+ * @param {number} x - The value to pingpong.
+ * @param {number} [length=1] - The positive value the function will pingpong to.
+ * @return {number} The alternated value.
+ */
+ pingpong: pingpong,
+ /**
+ * Returns a value in the range `[0,1]` that represents the percentage that `x` has
+ * moved between `min` and `max`, but smoothed or slowed down the closer `x` is to
+ * the `min` and `max`.
+ *
+ * See [Smoothstep](http://en.wikipedia.org/wiki/Smoothstep) for more details.
+ *
+ * @static
+ * @method
+ * @param {number} x - The value to evaluate based on its position between min and max.
+ * @param {number} min - The min value. Any x value below min will be `0`.
+ * @param {number} max - The max value. Any x value above max will be `1`.
+ * @return {number} The alternated value.
+ */
+ smoothstep: smoothstep,
+ /**
+ * A [variation on smoothstep](https://en.wikipedia.org/wiki/Smoothstep#Variations)
+ * that has zero 1st and 2nd order derivatives at x=0 and x=1.
+ *
+ * @static
+ * @method
+ * @param {number} x - The value to evaluate based on its position between min and max.
+ * @param {number} min - The min value. Any x value below min will be `0`.
+ * @param {number} max - The max value. Any x value above max will be `1`.
+ * @return {number} The alternated value.
+ */
+ smootherstep: smootherstep,
+ /**
+ * Returns a random integer from `` interval.
+ *
+ * @static
+ * @method
+ * @param {number} low - The lower value boundary.
+ * @param {number} high - The upper value boundary
+ * @return {number} A random integer.
+ */
+ randInt: randInt,
+ /**
+ * Returns a random float from `` interval.
+ *
+ * @static
+ * @method
+ * @param {number} low - The lower value boundary.
+ * @param {number} high - The upper value boundary
+ * @return {number} A random float.
+ */
+ randFloat: randFloat,
+ /**
+ * Returns a random integer from `<-range/2, range/2>` interval.
+ *
+ * @static
+ * @method
+ * @param {number} range - Defines the value range.
+ * @return {number} A random float.
+ */
+ randFloatSpread: randFloatSpread,
+ /**
+ * Returns a deterministic pseudo-random float in the interval `[0, 1]`.
+ *
+ * @static
+ * @method
+ * @param {number} [s] - The integer seed.
+ * @return {number} A random float.
+ */
+ seededRandom: seededRandom,
+ /**
+ * Converts degrees to radians.
+ *
+ * @static
+ * @method
+ * @param {number} degrees - A value in degrees.
+ * @return {number} The converted value in radians.
+ */
+ degToRad: degToRad,
+ /**
+ * Converts radians to degrees.
+ *
+ * @static
+ * @method
+ * @param {number} radians - A value in radians.
+ * @return {number} The converted value in degrees.
+ */
+ radToDeg: radToDeg,
+ /**
+ * Returns `true` if the given number is a power of two.
+ *
+ * @static
+ * @method
+ * @param {number} value - The value to check.
+ * @return {boolean} Whether the given number is a power of two or not.
+ */
+ isPowerOfTwo: isPowerOfTwo,
+ /**
+ * Returns the smallest power of two that is greater than or equal to the given number.
+ *
+ * @static
+ * @method
+ * @param {number} value - The value to find a POT for.
+ * @return {number} The smallest power of two that is greater than or equal to the given number.
+ */
+ ceilPowerOfTwo: ceilPowerOfTwo,
+ /**
+ * Returns the largest power of two that is less than or equal to the given number.
+ *
+ * @static
+ * @method
+ * @param {number} value - The value to find a POT for.
+ * @return {number} The largest power of two that is less than or equal to the given number.
+ */
+ floorPowerOfTwo: floorPowerOfTwo,
+ /**
+ * Sets the given quaternion from the [Intrinsic Proper Euler Angles](https://en.wikipedia.org/wiki/Euler_angles)
+ * defined by the given angles and order.
+ *
+ * Rotations are applied to the axes in the order specified by order:
+ * rotation by angle `a` is applied first, then by angle `b`, then by angle `c`.
+ *
+ * @static
+ * @method
+ * @param {Quaternion} q - The quaternion to set.
+ * @param {number} a - The rotation applied to the first axis, in radians.
+ * @param {number} b - The rotation applied to the second axis, in radians.
+ * @param {number} c - The rotation applied to the third axis, in radians.
+ * @param {('XYX'|'XZX'|'YXY'|'YZY'|'ZXZ'|'ZYZ')} order - A string specifying the axes order.
+ */
+ setQuaternionFromProperEuler: setQuaternionFromProperEuler,
+ /**
+ * Normalizes the given value according to the given typed array.
+ *
+ * @static
+ * @method
+ * @param {number} value - The float value in the range `[0,1]` to normalize.
+ * @param {TypedArray} array - The typed array that defines the data type of the value.
+ * @return {number} The normalize value.
+ */
+ normalize: normalize,
+ /**
+ * Denormalizes the given value according to the given typed array.
+ *
+ * @static
+ * @method
+ * @param {number} value - The value to denormalize.
+ * @param {TypedArray} array - The typed array that defines the data type of the value.
+ * @return {number} The denormalize (float) value in the range `[0,1]`.
+ */
+ denormalize: denormalize
+};
+
+/**
+ * Class representing a 2D vector. A 2D vector is an ordered pair of numbers
+ * (labeled x and y), which can be used to represent a number of things, such as:
+ *
+ * - A point in 2D space (i.e. a position on a plane).
+ * - A direction and length across a plane. In three.js the length will
+ * always be the Euclidean distance(straight-line distance) from `(0, 0)` to `(x, y)`
+ * and the direction is also measured from `(0, 0)` towards `(x, y)`.
+ * - Any arbitrary ordered pair of numbers.
+ *
+ * There are other things a 2D vector can be used to represent, such as
+ * momentum vectors, complex numbers and so on, however these are the most
+ * common uses in three.js.
+ *
+ * Iterating through a vector instance will yield its components `(x, y)` in
+ * the corresponding order.
+ * ```js
+ * const a = new THREE.Vector2( 0, 1 );
+ *
+ * //no arguments; will be initialised to (0, 0)
+ * const b = new THREE.Vector2( );
+ *
+ * const d = a.distanceTo( b );
+ * ```
+ */
+class Vector2 {
+
+ static {
+
+ /**
+ * This flag can be used for type testing.
+ *
+ * @type {boolean}
+ * @readonly
+ * @default true
+ */
+ this.prototype.isVector2 = true;
+
+ }
+
+ /**
+ * Constructs a new 2D vector.
+ *
+ * @param {number} [x=0] - The x value of this vector.
+ * @param {number} [y=0] - The y value of this vector.
+ */
+ constructor( x = 0, y = 0 ) {
+
+ /**
+ * The x value of this vector.
+ *
+ * @type {number}
+ */
+ this.x = x;
+
+ /**
+ * The y value of this vector.
+ *
+ * @type {number}
+ */
+ this.y = y;
+
+ }
+
+ /**
+ * Alias for {@link Vector2#x}.
+ *
+ * @type {number}
+ */
+ get width() {
+
+ return this.x;
+
+ }
+
+ set width( value ) {
+
+ this.x = value;
+
+ }
+
+ /**
+ * Alias for {@link Vector2#y}.
+ *
+ * @type {number}
+ */
+ get height() {
+
+ return this.y;
+
+ }
+
+ set height( value ) {
+
+ this.y = value;
+
+ }
+
+ /**
+ * Sets the vector components.
+ *
+ * @param {number} x - The value of the x component.
+ * @param {number} y - The value of the y component.
+ * @return {Vector2} A reference to this vector.
+ */
+ set( x, y ) {
+
+ this.x = x;
+ this.y = y;
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector components to the same value.
+ *
+ * @param {number} scalar - The value to set for all vector components.
+ * @return {Vector2} A reference to this vector.
+ */
+ setScalar( scalar ) {
+
+ this.x = scalar;
+ this.y = scalar;
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector's x component to the given value
+ *
+ * @param {number} x - The value to set.
+ * @return {Vector2} A reference to this vector.
+ */
+ setX( x ) {
+
+ this.x = x;
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector's y component to the given value
+ *
+ * @param {number} y - The value to set.
+ * @return {Vector2} A reference to this vector.
+ */
+ setY( y ) {
+
+ this.y = y;
+
+ return this;
+
+ }
+
+ /**
+ * Allows to set a vector component with an index.
+ *
+ * @param {number} index - The component index. `0` equals to x, `1` equals to y.
+ * @param {number} value - The value to set.
+ * @return {Vector2} A reference to this vector.
+ */
+ setComponent( index, value ) {
+
+ switch ( index ) {
+
+ case 0: this.x = value; break;
+ case 1: this.y = value; break;
+ default: throw new Error( 'THREE.Vector2: index is out of range: ' + index );
+
+ }
+
+ return this;
+
+ }
+
+ /**
+ * Returns the value of the vector component which matches the given index.
+ *
+ * @param {number} index - The component index. `0` equals to x, `1` equals to y.
+ * @return {number} A vector component value.
+ */
+ getComponent( index ) {
+
+ switch ( index ) {
+
+ case 0: return this.x;
+ case 1: return this.y;
+ default: throw new Error( 'THREE.Vector2: index is out of range: ' + index );
+
+ }
+
+ }
+
+ /**
+ * Returns a new vector with copied values from this instance.
+ *
+ * @return {Vector2} A clone of this instance.
+ */
+ clone() {
+
+ return new this.constructor( this.x, this.y );
+
+ }
+
+ /**
+ * Copies the values of the given vector to this instance.
+ *
+ * @param {Vector2} v - The vector to copy.
+ * @return {Vector2} A reference to this vector.
+ */
+ copy( v ) {
+
+ this.x = v.x;
+ this.y = v.y;
+
+ return this;
+
+ }
+
+ /**
+ * Adds the given vector to this instance.
+ *
+ * @param {Vector2} v - The vector to add.
+ * @return {Vector2} A reference to this vector.
+ */
+ add( v ) {
+
+ this.x += v.x;
+ this.y += v.y;
+
+ return this;
+
+ }
+
+ /**
+ * Adds the given scalar value to all components of this instance.
+ *
+ * @param {number} s - The scalar to add.
+ * @return {Vector2} A reference to this vector.
+ */
+ addScalar( s ) {
+
+ this.x += s;
+ this.y += s;
+
+ return this;
+
+ }
+
+ /**
+ * Adds the given vectors and stores the result in this instance.
+ *
+ * @param {Vector2} a - The first vector.
+ * @param {Vector2} b - The second vector.
+ * @return {Vector2} A reference to this vector.
+ */
+ addVectors( a, b ) {
+
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+
+ return this;
+
+ }
+
+ /**
+ * Adds the given vector scaled by the given factor to this instance.
+ *
+ * @param {Vector2} v - The vector.
+ * @param {number} s - The factor that scales `v`.
+ * @return {Vector2} A reference to this vector.
+ */
+ addScaledVector( v, s ) {
+
+ this.x += v.x * s;
+ this.y += v.y * s;
+
+ return this;
+
+ }
+
+ /**
+ * Subtracts the given vector from this instance.
+ *
+ * @param {Vector2} v - The vector to subtract.
+ * @return {Vector2} A reference to this vector.
+ */
+ sub( v ) {
+
+ this.x -= v.x;
+ this.y -= v.y;
+
+ return this;
+
+ }
+
+ /**
+ * Subtracts the given scalar value from all components of this instance.
+ *
+ * @param {number} s - The scalar to subtract.
+ * @return {Vector2} A reference to this vector.
+ */
+ subScalar( s ) {
+
+ this.x -= s;
+ this.y -= s;
+
+ return this;
+
+ }
+
+ /**
+ * Subtracts the given vectors and stores the result in this instance.
+ *
+ * @param {Vector2} a - The first vector.
+ * @param {Vector2} b - The second vector.
+ * @return {Vector2} A reference to this vector.
+ */
+ subVectors( a, b ) {
+
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+
+ return this;
+
+ }
+
+ /**
+ * Multiplies the given vector with this instance.
+ *
+ * @param {Vector2} v - The vector to multiply.
+ * @return {Vector2} A reference to this vector.
+ */
+ multiply( v ) {
+
+ this.x *= v.x;
+ this.y *= v.y;
+
+ return this;
+
+ }
+
+ /**
+ * Multiplies the given scalar value with all components of this instance.
+ *
+ * @param {number} scalar - The scalar to multiply.
+ * @return {Vector2} A reference to this vector.
+ */
+ multiplyScalar( scalar ) {
+
+ this.x *= scalar;
+ this.y *= scalar;
+
+ return this;
+
+ }
+
+ /**
+ * Divides this instance by the given vector.
+ *
+ * @param {Vector2} v - The vector to divide.
+ * @return {Vector2} A reference to this vector.
+ */
+ divide( v ) {
+
+ this.x /= v.x;
+ this.y /= v.y;
+
+ return this;
+
+ }
+
+ /**
+ * Divides this vector by the given scalar.
+ *
+ * @param {number} scalar - The scalar to divide.
+ * @return {Vector2} A reference to this vector.
+ */
+ divideScalar( scalar ) {
+
+ return this.multiplyScalar( 1 / scalar );
+
+ }
+
+ /**
+ * Multiplies this vector (with an implicit 1 as the 3rd component) by
+ * the given 3x3 matrix.
+ *
+ * @param {Matrix3} m - The matrix to apply.
+ * @return {Vector2} A reference to this vector.
+ */
+ applyMatrix3( m ) {
+
+ const x = this.x, y = this.y;
+ const e = m.elements;
+
+ this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];
+ this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];
+
+ return this;
+
+ }
+
+ /**
+ * If this vector's x or y value is greater than the given vector's x or y
+ * value, replace that value with the corresponding min value.
+ *
+ * @param {Vector2} v - The vector.
+ * @return {Vector2} A reference to this vector.
+ */
+ min( v ) {
+
+ this.x = Math.min( this.x, v.x );
+ this.y = Math.min( this.y, v.y );
+
+ return this;
+
+ }
+
+ /**
+ * If this vector's x or y value is less than the given vector's x or y
+ * value, replace that value with the corresponding max value.
+ *
+ * @param {Vector2} v - The vector.
+ * @return {Vector2} A reference to this vector.
+ */
+ max( v ) {
+
+ this.x = Math.max( this.x, v.x );
+ this.y = Math.max( this.y, v.y );
+
+ return this;
+
+ }
+
+ /**
+ * If this vector's x or y value is greater than the max vector's x or y
+ * value, it is replaced by the corresponding value.
+ * If this vector's x or y value is less than the min vector's x or y value,
+ * it is replaced by the corresponding value.
+ *
+ * @param {Vector2} min - The minimum x and y values.
+ * @param {Vector2} max - The maximum x and y values in the desired range.
+ * @return {Vector2} A reference to this vector.
+ */
+ clamp( min, max ) {
+
+ // assumes min < max, componentwise
+
+ this.x = clamp( this.x, min.x, max.x );
+ this.y = clamp( this.y, min.y, max.y );
+
+ return this;
+
+ }
+
+ /**
+ * If this vector's x or y values are greater than the max value, they are
+ * replaced by the max value.
+ * If this vector's x or y values are less than the min value, they are
+ * replaced by the min value.
+ *
+ * @param {number} minVal - The minimum value the components will be clamped to.
+ * @param {number} maxVal - The maximum value the components will be clamped to.
+ * @return {Vector2} A reference to this vector.
+ */
+ clampScalar( minVal, maxVal ) {
+
+ this.x = clamp( this.x, minVal, maxVal );
+ this.y = clamp( this.y, minVal, maxVal );
+
+ return this;
+
+ }
+
+ /**
+ * If this vector's length is greater than the max value, it is replaced by
+ * the max value.
+ * If this vector's length is less than the min value, it is replaced by the
+ * min value.
+ *
+ * @param {number} min - The minimum value the vector length will be clamped to.
+ * @param {number} max - The maximum value the vector length will be clamped to.
+ * @return {Vector2} A reference to this vector.
+ */
+ clampLength( min, max ) {
+
+ const length = this.length();
+
+ return this.divideScalar( length || 1 ).multiplyScalar( clamp( length, min, max ) );
+
+ }
+
+ /**
+ * The components of this vector are rounded down to the nearest integer value.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ floor() {
+
+ this.x = Math.floor( this.x );
+ this.y = Math.floor( this.y );
+
+ return this;
+
+ }
+
+ /**
+ * The components of this vector are rounded up to the nearest integer value.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ ceil() {
+
+ this.x = Math.ceil( this.x );
+ this.y = Math.ceil( this.y );
+
+ return this;
+
+ }
+
+ /**
+ * The components of this vector are rounded to the nearest integer value
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ round() {
+
+ this.x = Math.round( this.x );
+ this.y = Math.round( this.y );
+
+ return this;
+
+ }
+
+ /**
+ * The components of this vector are rounded towards zero (up if negative,
+ * down if positive) to an integer value.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ roundToZero() {
+
+ this.x = Math.trunc( this.x );
+ this.y = Math.trunc( this.y );
+
+ return this;
+
+ }
+
+ /**
+ * Inverts this vector - i.e. sets x = -x and y = -y.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ negate() {
+
+ this.x = - this.x;
+ this.y = - this.y;
+
+ return this;
+
+ }
+
+ /**
+ * Calculates the dot product of the given vector with this instance.
+ *
+ * @param {Vector2} v - The vector to compute the dot product with.
+ * @return {number} The result of the dot product.
+ */
+ dot( v ) {
+
+ return this.x * v.x + this.y * v.y;
+
+ }
+
+ /**
+ * Calculates the cross product of the given vector with this instance.
+ *
+ * @param {Vector2} v - The vector to compute the cross product with.
+ * @return {number} The result of the cross product.
+ */
+ cross( v ) {
+
+ return this.x * v.y - this.y * v.x;
+
+ }
+
+ /**
+ * Computes the square of the Euclidean length (straight-line length) from
+ * (0, 0) to (x, y). If you are comparing the lengths of vectors, you should
+ * compare the length squared instead as it is slightly more efficient to calculate.
+ *
+ * @return {number} The square length of this vector.
+ */
+ lengthSq() {
+
+ return this.x * this.x + this.y * this.y;
+
+ }
+
+ /**
+ * Computes the Euclidean length (straight-line length) from (0, 0) to (x, y).
+ *
+ * @return {number} The length of this vector.
+ */
+ length() {
+
+ return Math.sqrt( this.x * this.x + this.y * this.y );
+
+ }
+
+ /**
+ * Computes the Manhattan length of this vector.
+ *
+ * @return {number} The length of this vector.
+ */
+ manhattanLength() {
+
+ return Math.abs( this.x ) + Math.abs( this.y );
+
+ }
+
+ /**
+ * Converts this vector to a unit vector - that is, sets it equal to a vector
+ * with the same direction as this one, but with a vector length of `1`.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ normalize() {
+
+ return this.divideScalar( this.length() || 1 );
+
+ }
+
+ /**
+ * Computes the angle in radians of this vector with respect to the positive x-axis.
+ *
+ * @return {number} The angle in radians.
+ */
+ angle() {
+
+ const angle = Math.atan2( - this.y, - this.x ) + Math.PI;
+
+ return angle;
+
+ }
+
+ /**
+ * Returns the angle between the given vector and this instance in radians.
+ *
+ * @param {Vector2} v - The vector to compute the angle with.
+ * @return {number} The angle in radians.
+ */
+ angleTo( v ) {
+
+ const denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
+
+ if ( denominator === 0 ) return Math.PI / 2;
+
+ const theta = this.dot( v ) / denominator;
+
+ // clamp, to handle numerical problems
+
+ return Math.acos( clamp( theta, -1, 1 ) );
+
+ }
+
+ /**
+ * Computes the distance from the given vector to this instance.
+ *
+ * @param {Vector2} v - The vector to compute the distance to.
+ * @return {number} The distance.
+ */
+ distanceTo( v ) {
+
+ return Math.sqrt( this.distanceToSquared( v ) );
+
+ }
+
+ /**
+ * Computes the squared distance from the given vector to this instance.
+ * If you are just comparing the distance with another distance, you should compare
+ * the distance squared instead as it is slightly more efficient to calculate.
+ *
+ * @param {Vector2} v - The vector to compute the squared distance to.
+ * @return {number} The squared distance.
+ */
+ distanceToSquared( v ) {
+
+ const dx = this.x - v.x, dy = this.y - v.y;
+ return dx * dx + dy * dy;
+
+ }
+
+ /**
+ * Computes the Manhattan distance from the given vector to this instance.
+ *
+ * @param {Vector2} v - The vector to compute the Manhattan distance to.
+ * @return {number} The Manhattan distance.
+ */
+ manhattanDistanceTo( v ) {
+
+ return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
+
+ }
+
+ /**
+ * Sets this vector to a vector with the same direction as this one, but
+ * with the specified length.
+ *
+ * @param {number} length - The new length of this vector.
+ * @return {Vector2} A reference to this vector.
+ */
+ setLength( length ) {
+
+ return this.normalize().multiplyScalar( length );
+
+ }
+
+ /**
+ * Linearly interpolates between the given vector and this instance, where
+ * alpha is the percent distance along the line - alpha = 0 will be this
+ * vector, and alpha = 1 will be the given one.
+ *
+ * @param {Vector2} v - The vector to interpolate towards.
+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
+ * @return {Vector2} A reference to this vector.
+ */
+ lerp( v, alpha ) {
+
+ this.x += ( v.x - this.x ) * alpha;
+ this.y += ( v.y - this.y ) * alpha;
+
+ return this;
+
+ }
+
+ /**
+ * Linearly interpolates between the given vectors, where alpha is the percent
+ * distance along the line - alpha = 0 will be first vector, and alpha = 1 will
+ * be the second one. The result is stored in this instance.
+ *
+ * @param {Vector2} v1 - The first vector.
+ * @param {Vector2} v2 - The second vector.
+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
+ * @return {Vector2} A reference to this vector.
+ */
+ lerpVectors( v1, v2, alpha ) {
+
+ this.x = v1.x + ( v2.x - v1.x ) * alpha;
+ this.y = v1.y + ( v2.y - v1.y ) * alpha;
+
+ return this;
+
+ }
+
+ /**
+ * Returns `true` if this vector is equal with the given one.
+ *
+ * @param {Vector2} v - The vector to test for equality.
+ * @return {boolean} Whether this vector is equal with the given one.
+ */
+ equals( v ) {
+
+ return ( ( v.x === this.x ) && ( v.y === this.y ) );
+
+ }
+
+ /**
+ * Sets this vector's x value to be `array[ offset ]` and y
+ * value to be `array[ offset + 1 ]`.
+ *
+ * @param {Array} array - An array holding the vector component values.
+ * @param {number} [offset=0] - The offset into the array.
+ * @return {Vector2} A reference to this vector.
+ */
+ fromArray( array, offset = 0 ) {
+
+ this.x = array[ offset ];
+ this.y = array[ offset + 1 ];
+
+ return this;
+
+ }
+
+ /**
+ * Writes the components of this vector to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the vector components.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The vector components.
+ */
+ toArray( array = [], offset = 0 ) {
+
+ array[ offset ] = this.x;
+ array[ offset + 1 ] = this.y;
+
+ return array;
+
+ }
+
+ /**
+ * Sets the components of this vector from the given buffer attribute.
+ *
+ * @param {BufferAttribute} attribute - The buffer attribute holding vector data.
+ * @param {number} index - The index into the attribute.
+ * @return {Vector2} A reference to this vector.
+ */
+ fromBufferAttribute( attribute, index ) {
+
+ this.x = attribute.getX( index );
+ this.y = attribute.getY( index );
+
+ return this;
+
+ }
+
+ /**
+ * Rotates this vector around the given center by the given angle.
+ *
+ * @param {Vector2} center - The point around which to rotate.
+ * @param {number} angle - The angle to rotate, in radians.
+ * @return {Vector2} A reference to this vector.
+ */
+ rotateAround( center, angle ) {
+
+ const c = Math.cos( angle ), s = Math.sin( angle );
+
+ const x = this.x - center.x;
+ const y = this.y - center.y;
+
+ this.x = x * c - y * s + center.x;
+ this.y = x * s + y * c + center.y;
+
+ return this;
+
+ }
+
+ /**
+ * Sets each component of this vector to a pseudo-random value between `0` and
+ * `1`, excluding `1`.
+ *
+ * @return {Vector2} A reference to this vector.
+ */
+ random() {
+
+ this.x = Math.random();
+ this.y = Math.random();
+
+ return this;
+
+ }
+
+ *[ Symbol.iterator ]() {
+
+ yield this.x;
+ yield this.y;
+
+ }
+
+}
+
+/**
+ * Class for representing a Quaternion. Quaternions are used in three.js to represent rotations.
+ *
+ * Iterating through a vector instance will yield its components `(x, y, z, w)` in
+ * the corresponding order.
+ *
+ * Note that three.js expects Quaternions to be normalized.
+ * ```js
+ * const quaternion = new THREE.Quaternion();
+ * quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
+ *
+ * const vector = new THREE.Vector3( 1, 0, 0 );
+ * vector.applyQuaternion( quaternion );
+ * ```
+ */
+class Quaternion {
+
+ /**
+ * Constructs a new quaternion.
+ *
+ * @param {number} [x=0] - The x value of this quaternion.
+ * @param {number} [y=0] - The y value of this quaternion.
+ * @param {number} [z=0] - The z value of this quaternion.
+ * @param {number} [w=1] - The w value of this quaternion.
+ */
+ constructor( x = 0, y = 0, z = 0, w = 1 ) {
+
+ /**
+ * This flag can be used for type testing.
+ *
+ * @type {boolean}
+ * @readonly
+ * @default true
+ */
+ this.isQuaternion = true;
+
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._w = w;
+
+ }
+
+ /**
+ * Interpolates between two quaternions via SLERP. This implementation assumes the
+ * quaternion data are managed in flat arrays.
+ *
+ * @param {Array} dst - The destination array.
+ * @param {number} dstOffset - An offset into the destination array.
+ * @param {Array} src0 - The source array of the first quaternion.
+ * @param {number} srcOffset0 - An offset into the first source array.
+ * @param {Array} src1 - The source array of the second quaternion.
+ * @param {number} srcOffset1 - An offset into the second source array.
+ * @param {number} t - The interpolation factor. A value in the range `[0,1]` will interpolate. A value outside the range `[0,1]` will extrapolate.
+ * @see {@link Quaternion#slerp}
+ */
+ static slerpFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
+
+ let x0 = src0[ srcOffset0 + 0 ],
+ y0 = src0[ srcOffset0 + 1 ],
+ z0 = src0[ srcOffset0 + 2 ],
+ w0 = src0[ srcOffset0 + 3 ];
+
+ let x1 = src1[ srcOffset1 + 0 ],
+ y1 = src1[ srcOffset1 + 1 ],
+ z1 = src1[ srcOffset1 + 2 ],
+ w1 = src1[ srcOffset1 + 3 ];
+
+ if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {
+
+ let dot = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1;
+
+ if ( dot < 0 ) {
+
+ x1 = - x1;
+ y1 = - y1;
+ z1 = - z1;
+ w1 = - w1;
+
+ dot = - dot;
+
+ }
+
+ let s = 1 - t;
+
+ if ( dot < 0.9995 ) {
+
+ // slerp
+
+ const theta = Math.acos( dot );
+ const sin = Math.sin( theta );
+
+ s = Math.sin( s * theta ) / sin;
+ t = Math.sin( t * theta ) / sin;
+
+ x0 = x0 * s + x1 * t;
+ y0 = y0 * s + y1 * t;
+ z0 = z0 * s + z1 * t;
+ w0 = w0 * s + w1 * t;
+
+ } else {
+
+ // for small angles, lerp then normalize
+
+ x0 = x0 * s + x1 * t;
+ y0 = y0 * s + y1 * t;
+ z0 = z0 * s + z1 * t;
+ w0 = w0 * s + w1 * t;
+
+ const f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );
+
+ x0 *= f;
+ y0 *= f;
+ z0 *= f;
+ w0 *= f;
+
+ }
+
+ }
+
+ dst[ dstOffset ] = x0;
+ dst[ dstOffset + 1 ] = y0;
+ dst[ dstOffset + 2 ] = z0;
+ dst[ dstOffset + 3 ] = w0;
+
+ }
+
+ /**
+ * Multiplies two quaternions. This implementation assumes the quaternion data are managed
+ * in flat arrays.
+ *
+ * @param {Array} dst - The destination array.
+ * @param {number} dstOffset - An offset into the destination array.
+ * @param {Array} src0 - The source array of the first quaternion.
+ * @param {number} srcOffset0 - An offset into the first source array.
+ * @param {Array} src1 - The source array of the second quaternion.
+ * @param {number} srcOffset1 - An offset into the second source array.
+ * @return {Array} The destination array.
+ * @see {@link Quaternion#multiplyQuaternions}.
+ */
+ static multiplyQuaternionsFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) {
+
+ const x0 = src0[ srcOffset0 ];
+ const y0 = src0[ srcOffset0 + 1 ];
+ const z0 = src0[ srcOffset0 + 2 ];
+ const w0 = src0[ srcOffset0 + 3 ];
+
+ const x1 = src1[ srcOffset1 ];
+ const y1 = src1[ srcOffset1 + 1 ];
+ const z1 = src1[ srcOffset1 + 2 ];
+ const w1 = src1[ srcOffset1 + 3 ];
+
+ dst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
+ dst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
+ dst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
+ dst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
+
+ return dst;
+
+ }
+
+ /**
+ * The x value of this quaternion.
+ *
+ * @type {number}
+ * @default 0
+ */
+ get x() {
+
+ return this._x;
+
+ }
+
+ set x( value ) {
+
+ this._x = value;
+ this._onChangeCallback();
+
+ }
+
+ /**
+ * The y value of this quaternion.
+ *
+ * @type {number}
+ * @default 0
+ */
+ get y() {
+
+ return this._y;
+
+ }
+
+ set y( value ) {
+
+ this._y = value;
+ this._onChangeCallback();
+
+ }
+
+ /**
+ * The z value of this quaternion.
+ *
+ * @type {number}
+ * @default 0
+ */
+ get z() {
+
+ return this._z;
+
+ }
+
+ set z( value ) {
+
+ this._z = value;
+ this._onChangeCallback();
+
+ }
+
+ /**
+ * The w value of this quaternion.
+ *
+ * @type {number}
+ * @default 1
+ */
+ get w() {
+
+ return this._w;
+
+ }
+
+ set w( value ) {
+
+ this._w = value;
+ this._onChangeCallback();
+
+ }
+
+ /**
+ * Sets the quaternion components.
+ *
+ * @param {number} x - The x value of this quaternion.
+ * @param {number} y - The y value of this quaternion.
+ * @param {number} z - The z value of this quaternion.
+ * @param {number} w - The w value of this quaternion.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ set( x, y, z, w ) {
+
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._w = w;
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ /**
+ * Returns a new quaternion with copied values from this instance.
+ *
+ * @return {Quaternion} A clone of this instance.
+ */
+ clone() {
+
+ return new this.constructor( this._x, this._y, this._z, this._w );
+
+ }
+
+ /**
+ * Copies the values of the given quaternion to this instance.
+ *
+ * @param {Quaternion} quaternion - The quaternion to copy.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ copy( quaternion ) {
+
+ this._x = quaternion.x;
+ this._y = quaternion.y;
+ this._z = quaternion.z;
+ this._w = quaternion.w;
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ /**
+ * Sets this quaternion from the rotation specified by the given
+ * Euler angles.
+ *
+ * @param {Euler} euler - The Euler angles.
+ * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ setFromEuler( euler, update = true ) {
+
+ const x = euler._x, y = euler._y, z = euler._z, order = euler._order;
+
+ const cos = Math.cos;
+ const sin = Math.sin;
+
+ const c1 = cos( x / 2 );
+ const c2 = cos( y / 2 );
+ const c3 = cos( z / 2 );
+
+ const s1 = sin( x / 2 );
+ const s2 = sin( y / 2 );
+ const s3 = sin( z / 2 );
+
+ switch ( order ) {
+
+ case 'XYZ':
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ break;
+
+ case 'YXZ':
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ break;
+
+ case 'ZXY':
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ break;
+
+ case 'ZYX':
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ break;
+
+ case 'YZX':
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ break;
+
+ case 'XZY':
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ break;
+
+ default:
+ warn( 'Quaternion: .setFromEuler() encountered an unknown order: ' + order );
+
+ }
+
+ if ( update === true ) this._onChangeCallback();
+
+ return this;
+
+ }
+
+ /**
+ * Sets this quaternion from the given axis and angle.
+ *
+ * @param {Vector3} axis - The normalized axis.
+ * @param {number} angle - The angle in radians.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ setFromAxisAngle( axis, angle ) {
+
+ const halfAngle = angle / 2, s = Math.sin( halfAngle );
+
+ this._x = axis.x * s;
+ this._y = axis.y * s;
+ this._z = axis.z * s;
+ this._w = Math.cos( halfAngle );
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ /**
+ * Sets this quaternion from the given rotation matrix.
+ *
+ * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ setFromRotationMatrix( m ) {
+
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
+
+ const te = m.elements,
+
+ m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
+ m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
+ m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],
+
+ trace = m11 + m22 + m33;
+
+ if ( trace > 0 ) {
+
+ const s = 0.5 / Math.sqrt( trace + 1.0 );
+
+ this._w = 0.25 / s;
+ this._x = ( m32 - m23 ) * s;
+ this._y = ( m13 - m31 ) * s;
+ this._z = ( m21 - m12 ) * s;
+
+ } else if ( m11 > m22 && m11 > m33 ) {
+
+ const s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );
+
+ this._w = ( m32 - m23 ) / s;
+ this._x = 0.25 * s;
+ this._y = ( m12 + m21 ) / s;
+ this._z = ( m13 + m31 ) / s;
+
+ } else if ( m22 > m33 ) {
+
+ const s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );
+
+ this._w = ( m13 - m31 ) / s;
+ this._x = ( m12 + m21 ) / s;
+ this._y = 0.25 * s;
+ this._z = ( m23 + m32 ) / s;
+
+ } else {
+
+ const s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );
+
+ this._w = ( m21 - m12 ) / s;
+ this._x = ( m13 + m31 ) / s;
+ this._y = ( m23 + m32 ) / s;
+ this._z = 0.25 * s;
+
+ }
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ /**
+ * Sets this quaternion to the rotation required to rotate the direction vector
+ * `vFrom` to the direction vector `vTo`.
+ *
+ * @param {Vector3} vFrom - The first (normalized) direction vector.
+ * @param {Vector3} vTo - The second (normalized) direction vector.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ setFromUnitVectors( vFrom, vTo ) {
+
+ // assumes direction vectors vFrom and vTo are normalized
+
+ let r = vFrom.dot( vTo ) + 1;
+
+ if ( r < 1e-8 ) { // the epsilon value has been discussed in #31286
+
+ // vFrom and vTo point in opposite directions
+
+ r = 0;
+
+ if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {
+
+ this._x = - vFrom.y;
+ this._y = vFrom.x;
+ this._z = 0;
+ this._w = r;
+
+ } else {
+
+ this._x = 0;
+ this._y = - vFrom.z;
+ this._z = vFrom.y;
+ this._w = r;
+
+ }
+
+ } else {
+
+ // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3
+
+ this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
+ this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
+ this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
+ this._w = r;
+
+ }
+
+ return this.normalize();
+
+ }
+
+ /**
+ * Returns the angle between this quaternion and the given one in radians.
+ *
+ * @param {Quaternion} q - The quaternion to compute the angle with.
+ * @return {number} The angle in radians.
+ */
+ angleTo( q ) {
+
+ return 2 * Math.acos( Math.abs( clamp( this.dot( q ), -1, 1 ) ) );
+
+ }
+
+ /**
+ * Rotates this quaternion by a given angular step to the given quaternion.
+ * The method ensures that the final quaternion will not overshoot `q`.
+ *
+ * @param {Quaternion} q - The target quaternion.
+ * @param {number} step - The angular step in radians.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ rotateTowards( q, step ) {
+
+ const angle = this.angleTo( q );
+
+ if ( angle === 0 ) return this;
+
+ const t = Math.min( 1, step / angle );
+
+ this.slerp( q, t );
+
+ return this;
+
+ }
+
+ /**
+ * Sets this quaternion to the identity quaternion; that is, to the
+ * quaternion that represents "no rotation".
+ *
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ identity() {
+
+ return this.set( 0, 0, 0, 1 );
+
+ }
+
+ /**
+ * Inverts this quaternion via {@link Quaternion#conjugate}. The
+ * quaternion is assumed to have unit length.
+ *
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ invert() {
+
+ return this.conjugate();
+
+ }
+
+ /**
+ * Returns the rotational conjugate of this quaternion. The conjugate of a
+ * quaternion represents the same rotation in the opposite direction about
+ * the rotational axis.
+ *
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ conjugate() {
+
+ this._x *= -1;
+ this._y *= -1;
+ this._z *= -1;
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ /**
+ * Calculates the dot product of this quaternion and the given one.
+ *
+ * @param {Quaternion} v - The quaternion to compute the dot product with.
+ * @return {number} The result of the dot product.
+ */
+ dot( v ) {
+
+ return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
+
+ }
+
+ /**
+ * Computes the squared Euclidean length (straight-line length) of this quaternion,
+ * considered as a 4 dimensional vector. This can be useful if you are comparing the
+ * lengths of two quaternions, as this is a slightly more efficient calculation than
+ * {@link Quaternion#length}.
+ *
+ * @return {number} The squared Euclidean length.
+ */
+ lengthSq() {
+
+ return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
+
+ }
+
+ /**
+ * Computes the Euclidean length (straight-line length) of this quaternion,
+ * considered as a 4 dimensional vector.
+ *
+ * @return {number} The Euclidean length.
+ */
+ length() {
+
+ return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );
+
+ }
+
+ /**
+ * Normalizes this quaternion - that is, calculated the quaternion that performs
+ * the same rotation as this one, but has a length equal to `1`.
+ *
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ normalize() {
+
+ let l = this.length();
+
+ if ( l === 0 ) {
+
+ this._x = 0;
+ this._y = 0;
+ this._z = 0;
+ this._w = 1;
+
+ } else {
+
+ l = 1 / l;
+
+ this._x = this._x * l;
+ this._y = this._y * l;
+ this._z = this._z * l;
+ this._w = this._w * l;
+
+ }
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ /**
+ * Multiplies this quaternion by the given one.
+ *
+ * @param {Quaternion} q - The quaternion.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ multiply( q ) {
+
+ return this.multiplyQuaternions( this, q );
+
+ }
+
+ /**
+ * Pre-multiplies this quaternion by the given one.
+ *
+ * @param {Quaternion} q - The quaternion.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ premultiply( q ) {
+
+ return this.multiplyQuaternions( q, this );
+
+ }
+
+ /**
+ * Multiplies the given quaternions and stores the result in this instance.
+ *
+ * @param {Quaternion} a - The first quaternion.
+ * @param {Quaternion} b - The second quaternion.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ multiplyQuaternions( a, b ) {
+
+ const qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
+ const qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
+
+ this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
+ this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
+ this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
+ this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ /**
+ * Performs a spherical linear interpolation between this quaternion and the target quaternion.
+ *
+ * @param {Quaternion} qb - The target quaternion.
+ * @param {number} t - The interpolation factor. A value in the range `[0,1]` will interpolate. A value outside the range `[0,1]` will extrapolate.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ slerp( qb, t ) {
+
+ let x = qb._x, y = qb._y, z = qb._z, w = qb._w;
+
+ let dot = this.dot( qb );
+
+ if ( dot < 0 ) {
+
+ x = - x;
+ y = - y;
+ z = - z;
+ w = - w;
+
+ dot = - dot;
+
+ }
+
+ let s = 1 - t;
+
+ if ( dot < 0.9995 ) {
+
+ // slerp
+
+ const theta = Math.acos( dot );
+ const sin = Math.sin( theta );
+
+ s = Math.sin( s * theta ) / sin;
+ t = Math.sin( t * theta ) / sin;
+
+ this._x = this._x * s + x * t;
+ this._y = this._y * s + y * t;
+ this._z = this._z * s + z * t;
+ this._w = this._w * s + w * t;
+
+ this._onChangeCallback();
+
+ } else {
+
+ // for small angles, lerp then normalize
+
+ this._x = this._x * s + x * t;
+ this._y = this._y * s + y * t;
+ this._z = this._z * s + z * t;
+ this._w = this._w * s + w * t;
+
+ this.normalize(); // normalize calls _onChangeCallback()
+
+ }
+
+ return this;
+
+ }
+
+ /**
+ * Performs a spherical linear interpolation between the given quaternions
+ * and stores the result in this quaternion.
+ *
+ * @param {Quaternion} qa - The source quaternion.
+ * @param {Quaternion} qb - The target quaternion.
+ * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ slerpQuaternions( qa, qb, t ) {
+
+ return this.copy( qa ).slerp( qb, t );
+
+ }
+
+ /**
+ * Sets this quaternion to a uniformly random, normalized quaternion.
+ *
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ random() {
+
+ // Ken Shoemake
+ // Uniform random rotations
+ // D. Kirk, editor, Graphics Gems III, pages 124-132. Academic Press, New York, 1992.
+
+ const theta1 = 2 * Math.PI * Math.random();
+ const theta2 = 2 * Math.PI * Math.random();
+
+ const x0 = Math.random();
+ const r1 = Math.sqrt( 1 - x0 );
+ const r2 = Math.sqrt( x0 );
+
+ return this.set(
+ r1 * Math.sin( theta1 ),
+ r1 * Math.cos( theta1 ),
+ r2 * Math.sin( theta2 ),
+ r2 * Math.cos( theta2 ),
+ );
+
+ }
+
+ /**
+ * Returns `true` if this quaternion is equal with the given one.
+ *
+ * @param {Quaternion} quaternion - The quaternion to test for equality.
+ * @return {boolean} Whether this quaternion is equal with the given one.
+ */
+ equals( quaternion ) {
+
+ return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );
+
+ }
+
+ /**
+ * Sets this quaternion's components from the given array.
+ *
+ * @param {Array} array - An array holding the quaternion component values.
+ * @param {number} [offset=0] - The offset into the array.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ fromArray( array, offset = 0 ) {
+
+ this._x = array[ offset ];
+ this._y = array[ offset + 1 ];
+ this._z = array[ offset + 2 ];
+ this._w = array[ offset + 3 ];
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ /**
+ * Writes the components of this quaternion to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the quaternion components.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The quaternion components.
+ */
+ toArray( array = [], offset = 0 ) {
+
+ array[ offset ] = this._x;
+ array[ offset + 1 ] = this._y;
+ array[ offset + 2 ] = this._z;
+ array[ offset + 3 ] = this._w;
+
+ return array;
+
+ }
+
+ /**
+ * Sets the components of this quaternion from the given buffer attribute.
+ *
+ * @param {BufferAttribute} attribute - The buffer attribute holding quaternion data.
+ * @param {number} index - The index into the attribute.
+ * @return {Quaternion} A reference to this quaternion.
+ */
+ fromBufferAttribute( attribute, index ) {
+
+ this._x = attribute.getX( index );
+ this._y = attribute.getY( index );
+ this._z = attribute.getZ( index );
+ this._w = attribute.getW( index );
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ /**
+ * This methods defines the serialization result of this class. Returns the
+ * numerical elements of this quaternion in an array of format `[x, y, z, w]`.
+ *
+ * @return {Array} The serialized quaternion.
+ */
+ toJSON() {
+
+ return this.toArray();
+
+ }
+
+ _onChange( callback ) {
+
+ this._onChangeCallback = callback;
+
+ return this;
+
+ }
+
+ _onChangeCallback() {}
+
+ *[ Symbol.iterator ]() {
+
+ yield this._x;
+ yield this._y;
+ yield this._z;
+ yield this._w;
+
+ }
+
+}
+
+/**
+ * Class representing a 3D vector. A 3D vector is an ordered triplet of numbers
+ * (labeled x, y and z), which can be used to represent a number of things, such as:
+ *
+ * - A point in 3D space.
+ * - A direction and length in 3D space. In three.js the length will
+ * always be the Euclidean distance(straight-line distance) from `(0, 0, 0)` to `(x, y, z)`
+ * and the direction is also measured from `(0, 0, 0)` towards `(x, y, z)`.
+ * - Any arbitrary ordered triplet of numbers.
+ *
+ * There are other things a 3D vector can be used to represent, such as
+ * momentum vectors and so on, however these are the most
+ * common uses in three.js.
+ *
+ * Iterating through a vector instance will yield its components `(x, y, z)` in
+ * the corresponding order.
+ * ```js
+ * const a = new THREE.Vector3( 0, 1, 0 );
+ *
+ * //no arguments; will be initialised to (0, 0, 0)
+ * const b = new THREE.Vector3( );
+ *
+ * const d = a.distanceTo( b );
+ * ```
+ */
+class Vector3 {
+
+ static {
+
+ /**
+ * This flag can be used for type testing.
+ *
+ * @type {boolean}
+ * @readonly
+ * @default true
+ */
+ this.prototype.isVector3 = true;
+
+ }
+
+ /**
+ * Constructs a new 3D vector.
+ *
+ * @param {number} [x=0] - The x value of this vector.
+ * @param {number} [y=0] - The y value of this vector.
+ * @param {number} [z=0] - The z value of this vector.
+ */
+ constructor( x = 0, y = 0, z = 0 ) {
+
+ /**
+ * The x value of this vector.
+ *
+ * @type {number}
+ */
+ this.x = x;
+
+ /**
+ * The y value of this vector.
+ *
+ * @type {number}
+ */
+ this.y = y;
+
+ /**
+ * The z value of this vector.
+ *
+ * @type {number}
+ */
+ this.z = z;
+
+ }
+
+ /**
+ * Sets the vector components.
+ *
+ * @param {number} x - The value of the x component.
+ * @param {number} y - The value of the y component.
+ * @param {number} z - The value of the z component.
+ * @return {Vector3} A reference to this vector.
+ */
+ set( x, y, z ) {
+
+ if ( z === undefined ) z = this.z; // sprite.scale.set(x,y)
+
+ this.x = x;
+ this.y = y;
+ this.z = z;
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector components to the same value.
+ *
+ * @param {number} scalar - The value to set for all vector components.
+ * @return {Vector3} A reference to this vector.
+ */
+ setScalar( scalar ) {
+
+ this.x = scalar;
+ this.y = scalar;
+ this.z = scalar;
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector's x component to the given value.
+ *
+ * @param {number} x - The value to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setX( x ) {
+
+ this.x = x;
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector's y component to the given value.
+ *
+ * @param {number} y - The value to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setY( y ) {
+
+ this.y = y;
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector's z component to the given value.
+ *
+ * @param {number} z - The value to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setZ( z ) {
+
+ this.z = z;
+
+ return this;
+
+ }
+
+ /**
+ * Allows to set a vector component with an index.
+ *
+ * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.
+ * @param {number} value - The value to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setComponent( index, value ) {
+
+ switch ( index ) {
+
+ case 0: this.x = value; break;
+ case 1: this.y = value; break;
+ case 2: this.z = value; break;
+ default: throw new Error( 'THREE.Vector3: index is out of range: ' + index );
+
+ }
+
+ return this;
+
+ }
+
+ /**
+ * Returns the value of the vector component which matches the given index.
+ *
+ * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.
+ * @return {number} A vector component value.
+ */
+ getComponent( index ) {
+
+ switch ( index ) {
+
+ case 0: return this.x;
+ case 1: return this.y;
+ case 2: return this.z;
+ default: throw new Error( 'THREE.Vector3: index is out of range: ' + index );
+
+ }
+
+ }
+
+ /**
+ * Returns a new vector with copied values from this instance.
+ *
+ * @return {Vector3} A clone of this instance.
+ */
+ clone() {
+
+ return new this.constructor( this.x, this.y, this.z );
+
+ }
+
+ /**
+ * Copies the values of the given vector to this instance.
+ *
+ * @param {Vector3} v - The vector to copy.
+ * @return {Vector3} A reference to this vector.
+ */
+ copy( v ) {
+
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+
+ return this;
+
+ }
+
+ /**
+ * Adds the given vector to this instance.
+ *
+ * @param {Vector3} v - The vector to add.
+ * @return {Vector3} A reference to this vector.
+ */
+ add( v ) {
+
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+
+ return this;
+
+ }
+
+ /**
+ * Adds the given scalar value to all components of this instance.
+ *
+ * @param {number} s - The scalar to add.
+ * @return {Vector3} A reference to this vector.
+ */
+ addScalar( s ) {
+
+ this.x += s;
+ this.y += s;
+ this.z += s;
+
+ return this;
+
+ }
+
+ /**
+ * Adds the given vectors and stores the result in this instance.
+ *
+ * @param {Vector3} a - The first vector.
+ * @param {Vector3} b - The second vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ addVectors( a, b ) {
+
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+ this.z = a.z + b.z;
+
+ return this;
+
+ }
+
+ /**
+ * Adds the given vector scaled by the given factor to this instance.
+ *
+ * @param {Vector3|Vector4} v - The vector.
+ * @param {number} s - The factor that scales `v`.
+ * @return {Vector3} A reference to this vector.
+ */
+ addScaledVector( v, s ) {
+
+ this.x += v.x * s;
+ this.y += v.y * s;
+ this.z += v.z * s;
+
+ return this;
+
+ }
+
+ /**
+ * Subtracts the given vector from this instance.
+ *
+ * @param {Vector3} v - The vector to subtract.
+ * @return {Vector3} A reference to this vector.
+ */
+ sub( v ) {
+
+ this.x -= v.x;
+ this.y -= v.y;
+ this.z -= v.z;
+
+ return this;
+
+ }
+
+ /**
+ * Subtracts the given scalar value from all components of this instance.
+ *
+ * @param {number} s - The scalar to subtract.
+ * @return {Vector3} A reference to this vector.
+ */
+ subScalar( s ) {
+
+ this.x -= s;
+ this.y -= s;
+ this.z -= s;
+
+ return this;
+
+ }
+
+ /**
+ * Subtracts the given vectors and stores the result in this instance.
+ *
+ * @param {Vector3} a - The first vector.
+ * @param {Vector3} b - The second vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ subVectors( a, b ) {
+
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+ this.z = a.z - b.z;
+
+ return this;
+
+ }
+
+ /**
+ * Multiplies the given vector with this instance.
+ *
+ * @param {Vector3} v - The vector to multiply.
+ * @return {Vector3} A reference to this vector.
+ */
+ multiply( v ) {
+
+ this.x *= v.x;
+ this.y *= v.y;
+ this.z *= v.z;
+
+ return this;
+
+ }
+
+ /**
+ * Multiplies the given scalar value with all components of this instance.
+ *
+ * @param {number} scalar - The scalar to multiply.
+ * @return {Vector3} A reference to this vector.
+ */
+ multiplyScalar( scalar ) {
+
+ this.x *= scalar;
+ this.y *= scalar;
+ this.z *= scalar;
+
+ return this;
+
+ }
+
+ /**
+ * Multiplies the given vectors and stores the result in this instance.
+ *
+ * @param {Vector3} a - The first vector.
+ * @param {Vector3} b - The second vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ multiplyVectors( a, b ) {
+
+ this.x = a.x * b.x;
+ this.y = a.y * b.y;
+ this.z = a.z * b.z;
+
+ return this;
+
+ }
+
+ /**
+ * Applies the given Euler rotation to this vector.
+ *
+ * @param {Euler} euler - The Euler angles.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyEuler( euler ) {
+
+ return this.applyQuaternion( _quaternion$5.setFromEuler( euler ) );
+
+ }
+
+ /**
+ * Applies a rotation specified by an axis and an angle to this vector.
+ *
+ * @param {Vector3} axis - A normalized vector representing the rotation axis.
+ * @param {number} angle - The angle in radians.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyAxisAngle( axis, angle ) {
+
+ return this.applyQuaternion( _quaternion$5.setFromAxisAngle( axis, angle ) );
+
+ }
+
+ /**
+ * Multiplies this vector with the given 3x3 matrix.
+ *
+ * @param {Matrix3} m - The 3x3 matrix.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyMatrix3( m ) {
+
+ const x = this.x, y = this.y, z = this.z;
+ const e = m.elements;
+
+ this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;
+ this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;
+ this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;
+
+ return this;
+
+ }
+
+ /**
+ * Multiplies this vector by the given normal matrix and normalizes
+ * the result.
+ *
+ * @param {Matrix3} m - The normal matrix.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyNormalMatrix( m ) {
+
+ return this.applyMatrix3( m ).normalize();
+
+ }
+
+ /**
+ * Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and
+ * divides by perspective.
+ *
+ * @param {Matrix4} m - The matrix to apply.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyMatrix4( m ) {
+
+ const x = this.x, y = this.y, z = this.z;
+ const e = m.elements;
+
+ const w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );
+
+ this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;
+ this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;
+ this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;
+
+ return this;
+
+ }
+
+ /**
+ * Applies the given Quaternion to this vector.
+ *
+ * @param {Quaternion} q - The Quaternion.
+ * @return {Vector3} A reference to this vector.
+ */
+ applyQuaternion( q ) {
+
+ // quaternion q is assumed to have unit length
+
+ const vx = this.x, vy = this.y, vz = this.z;
+ const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
+
+ // t = 2 * cross( q.xyz, v );
+ const tx = 2 * ( qy * vz - qz * vy );
+ const ty = 2 * ( qz * vx - qx * vz );
+ const tz = 2 * ( qx * vy - qy * vx );
+
+ // v + q.w * t + cross( q.xyz, t );
+ this.x = vx + qw * tx + qy * tz - qz * ty;
+ this.y = vy + qw * ty + qz * tx - qx * tz;
+ this.z = vz + qw * tz + qx * ty - qy * tx;
+
+ return this;
+
+ }
+
+ /**
+ * Projects this vector from world space into the camera's normalized
+ * device coordinate (NDC) space.
+ *
+ * @param {Camera} camera - The camera.
+ * @return {Vector3} A reference to this vector.
+ */
+ project( camera ) {
+
+ return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );
+
+ }
+
+ /**
+ * Unprojects this vector from the camera's normalized device coordinate (NDC)
+ * space into world space.
+ *
+ * @param {Camera} camera - The camera.
+ * @return {Vector3} A reference to this vector.
+ */
+ unproject( camera ) {
+
+ return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );
+
+ }
+
+ /**
+ * Transforms this vector by the upper left 3x3 sub-matrix of the given 4x4 matrix,
+ * and normalizes the result.
+ *
+ * @param {Matrix4} m - The matrix.
+ * @return {Vector3} A reference to this vector.
+ */
+ transformDirection( m ) {
+
+ // input: THREE.Matrix4 affine matrix
+ // vector interpreted as a direction
+
+ const x = this.x, y = this.y, z = this.z;
+ const e = m.elements;
+
+ this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;
+ this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;
+ this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;
+
+ return this.normalize();
+
+ }
+
+ /**
+ * Divides this instance by the given vector.
+ *
+ * @param {Vector3} v - The vector to divide.
+ * @return {Vector3} A reference to this vector.
+ */
+ divide( v ) {
+
+ this.x /= v.x;
+ this.y /= v.y;
+ this.z /= v.z;
+
+ return this;
+
+ }
+
+ /**
+ * Divides this vector by the given scalar.
+ *
+ * @param {number} scalar - The scalar to divide.
+ * @return {Vector3} A reference to this vector.
+ */
+ divideScalar( scalar ) {
+
+ return this.multiplyScalar( 1 / scalar );
+
+ }
+
+ /**
+ * If this vector's x, y or z value is greater than the given vector's x, y or z
+ * value, replace that value with the corresponding min value.
+ *
+ * @param {Vector3} v - The vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ min( v ) {
+
+ this.x = Math.min( this.x, v.x );
+ this.y = Math.min( this.y, v.y );
+ this.z = Math.min( this.z, v.z );
+
+ return this;
+
+ }
+
+ /**
+ * If this vector's x, y or z value is less than the given vector's x, y or z
+ * value, replace that value with the corresponding max value.
+ *
+ * @param {Vector3} v - The vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ max( v ) {
+
+ this.x = Math.max( this.x, v.x );
+ this.y = Math.max( this.y, v.y );
+ this.z = Math.max( this.z, v.z );
+
+ return this;
+
+ }
+
+ /**
+ * If this vector's x, y or z value is greater than the max vector's x, y or z
+ * value, it is replaced by the corresponding value.
+ * If this vector's x, y or z value is less than the min vector's x, y or z value,
+ * it is replaced by the corresponding value.
+ *
+ * @param {Vector3} min - The minimum x, y and z values.
+ * @param {Vector3} max - The maximum x, y and z values in the desired range.
+ * @return {Vector3} A reference to this vector.
+ */
+ clamp( min, max ) {
+
+ // assumes min < max, componentwise
+
+ this.x = clamp( this.x, min.x, max.x );
+ this.y = clamp( this.y, min.y, max.y );
+ this.z = clamp( this.z, min.z, max.z );
+
+ return this;
+
+ }
+
+ /**
+ * If this vector's x, y or z values are greater than the max value, they are
+ * replaced by the max value.
+ * If this vector's x, y or z values are less than the min value, they are
+ * replaced by the min value.
+ *
+ * @param {number} minVal - The minimum value the components will be clamped to.
+ * @param {number} maxVal - The maximum value the components will be clamped to.
+ * @return {Vector3} A reference to this vector.
+ */
+ clampScalar( minVal, maxVal ) {
+
+ this.x = clamp( this.x, minVal, maxVal );
+ this.y = clamp( this.y, minVal, maxVal );
+ this.z = clamp( this.z, minVal, maxVal );
+
+ return this;
+
+ }
+
+ /**
+ * If this vector's length is greater than the max value, it is replaced by
+ * the max value.
+ * If this vector's length is less than the min value, it is replaced by the
+ * min value.
+ *
+ * @param {number} min - The minimum value the vector length will be clamped to.
+ * @param {number} max - The maximum value the vector length will be clamped to.
+ * @return {Vector3} A reference to this vector.
+ */
+ clampLength( min, max ) {
+
+ const length = this.length();
+
+ return this.divideScalar( length || 1 ).multiplyScalar( clamp( length, min, max ) );
+
+ }
+
+ /**
+ * The components of this vector are rounded down to the nearest integer value.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ floor() {
+
+ this.x = Math.floor( this.x );
+ this.y = Math.floor( this.y );
+ this.z = Math.floor( this.z );
+
+ return this;
+
+ }
+
+ /**
+ * The components of this vector are rounded up to the nearest integer value.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ ceil() {
+
+ this.x = Math.ceil( this.x );
+ this.y = Math.ceil( this.y );
+ this.z = Math.ceil( this.z );
+
+ return this;
+
+ }
+
+ /**
+ * The components of this vector are rounded to the nearest integer value
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ round() {
+
+ this.x = Math.round( this.x );
+ this.y = Math.round( this.y );
+ this.z = Math.round( this.z );
+
+ return this;
+
+ }
+
+ /**
+ * The components of this vector are rounded towards zero (up if negative,
+ * down if positive) to an integer value.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ roundToZero() {
+
+ this.x = Math.trunc( this.x );
+ this.y = Math.trunc( this.y );
+ this.z = Math.trunc( this.z );
+
+ return this;
+
+ }
+
+ /**
+ * Inverts this vector - i.e. sets x = -x, y = -y and z = -z.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ negate() {
+
+ this.x = - this.x;
+ this.y = - this.y;
+ this.z = - this.z;
+
+ return this;
+
+ }
+
+ /**
+ * Calculates the dot product of the given vector with this instance.
+ *
+ * @param {Vector3} v - The vector to compute the dot product with.
+ * @return {number} The result of the dot product.
+ */
+ dot( v ) {
+
+ return this.x * v.x + this.y * v.y + this.z * v.z;
+
+ }
+
+ /**
+ * Computes the square of the Euclidean length (straight-line length) from
+ * (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should
+ * compare the length squared instead as it is slightly more efficient to calculate.
+ *
+ * @return {number} The square length of this vector.
+ */
+ lengthSq() {
+
+ return this.x * this.x + this.y * this.y + this.z * this.z;
+
+ }
+
+ /**
+ * Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).
+ *
+ * @return {number} The length of this vector.
+ */
+ length() {
+
+ return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
+
+ }
+
+ /**
+ * Computes the Manhattan length of this vector.
+ *
+ * @return {number} The length of this vector.
+ */
+ manhattanLength() {
+
+ return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
+
+ }
+
+ /**
+ * Converts this vector to a unit vector - that is, sets it equal to a vector
+ * with the same direction as this one, but with a vector length of `1`.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ normalize() {
+
+ return this.divideScalar( this.length() || 1 );
+
+ }
+
+ /**
+ * Sets this vector to a vector with the same direction as this one, but
+ * with the specified length.
+ *
+ * @param {number} length - The new length of this vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ setLength( length ) {
+
+ return this.normalize().multiplyScalar( length );
+
+ }
+
+ /**
+ * Linearly interpolates between the given vector and this instance, where
+ * alpha is the percent distance along the line - alpha = 0 will be this
+ * vector, and alpha = 1 will be the given one.
+ *
+ * @param {Vector3} v - The vector to interpolate towards.
+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
+ * @return {Vector3} A reference to this vector.
+ */
+ lerp( v, alpha ) {
+
+ this.x += ( v.x - this.x ) * alpha;
+ this.y += ( v.y - this.y ) * alpha;
+ this.z += ( v.z - this.z ) * alpha;
+
+ return this;
+
+ }
+
+ /**
+ * Linearly interpolates between the given vectors, where alpha is the percent
+ * distance along the line - alpha = 0 will be first vector, and alpha = 1 will
+ * be the second one. The result is stored in this instance.
+ *
+ * @param {Vector3} v1 - The first vector.
+ * @param {Vector3} v2 - The second vector.
+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
+ * @return {Vector3} A reference to this vector.
+ */
+ lerpVectors( v1, v2, alpha ) {
+
+ this.x = v1.x + ( v2.x - v1.x ) * alpha;
+ this.y = v1.y + ( v2.y - v1.y ) * alpha;
+ this.z = v1.z + ( v2.z - v1.z ) * alpha;
+
+ return this;
+
+ }
+
+ /**
+ * Calculates the cross product of the given vector with this instance.
+ *
+ * @param {Vector3} v - The vector to compute the cross product with.
+ * @return {Vector3} The result of the cross product.
+ */
+ cross( v ) {
+
+ return this.crossVectors( this, v );
+
+ }
+
+ /**
+ * Calculates the cross product of the given vectors and stores the result
+ * in this instance.
+ *
+ * @param {Vector3} a - The first vector.
+ * @param {Vector3} b - The second vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ crossVectors( a, b ) {
+
+ const ax = a.x, ay = a.y, az = a.z;
+ const bx = b.x, by = b.y, bz = b.z;
+
+ this.x = ay * bz - az * by;
+ this.y = az * bx - ax * bz;
+ this.z = ax * by - ay * bx;
+
+ return this;
+
+ }
+
+ /**
+ * Projects this vector onto the given one.
+ *
+ * @param {Vector3} v - The vector to project to.
+ * @return {Vector3} A reference to this vector.
+ */
+ projectOnVector( v ) {
+
+ const denominator = v.lengthSq();
+
+ if ( denominator === 0 ) return this.set( 0, 0, 0 );
+
+ const scalar = v.dot( this ) / denominator;
+
+ return this.copy( v ).multiplyScalar( scalar );
+
+ }
+
+ /**
+ * Projects this vector onto a plane by subtracting this
+ * vector projected onto the plane's normal from this vector.
+ *
+ * @param {Vector3} planeNormal - The plane normal.
+ * @return {Vector3} A reference to this vector.
+ */
+ projectOnPlane( planeNormal ) {
+
+ _vector$c.copy( this ).projectOnVector( planeNormal );
+
+ return this.sub( _vector$c );
+
+ }
+
+ /**
+ * Reflects this vector off a plane orthogonal to the given normal vector.
+ *
+ * @param {Vector3} normal - The (normalized) normal vector.
+ * @return {Vector3} A reference to this vector.
+ */
+ reflect( normal ) {
+
+ return this.sub( _vector$c.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
+
+ }
+ /**
+ * Returns the angle between the given vector and this instance in radians.
+ *
+ * @param {Vector3} v - The vector to compute the angle with.
+ * @return {number} The angle in radians.
+ */
+ angleTo( v ) {
+
+ const denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
+
+ if ( denominator === 0 ) return Math.PI / 2;
+
+ const theta = this.dot( v ) / denominator;
+
+ // clamp, to handle numerical problems
+
+ return Math.acos( clamp( theta, -1, 1 ) );
+
+ }
+
+ /**
+ * Computes the distance from the given vector to this instance.
+ *
+ * @param {Vector3} v - The vector to compute the distance to.
+ * @return {number} The distance.
+ */
+ distanceTo( v ) {
+
+ return Math.sqrt( this.distanceToSquared( v ) );
+
+ }
+
+ /**
+ * Computes the squared distance from the given vector to this instance.
+ * If you are just comparing the distance with another distance, you should compare
+ * the distance squared instead as it is slightly more efficient to calculate.
+ *
+ * @param {Vector3} v - The vector to compute the squared distance to.
+ * @return {number} The squared distance.
+ */
+ distanceToSquared( v ) {
+
+ const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
+
+ return dx * dx + dy * dy + dz * dz;
+
+ }
+
+ /**
+ * Computes the Manhattan distance from the given vector to this instance.
+ *
+ * @param {Vector3} v - The vector to compute the Manhattan distance to.
+ * @return {number} The Manhattan distance.
+ */
+ manhattanDistanceTo( v ) {
+
+ return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
+
+ }
+
+ /**
+ * Sets the vector components from the given spherical coordinates.
+ *
+ * @param {Spherical} s - The spherical coordinates.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromSpherical( s ) {
+
+ return this.setFromSphericalCoords( s.radius, s.phi, s.theta );
+
+ }
+
+ /**
+ * Sets the vector components from the given spherical coordinates.
+ *
+ * @param {number} radius - The radius.
+ * @param {number} phi - The phi angle in radians.
+ * @param {number} theta - The theta angle in radians.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromSphericalCoords( radius, phi, theta ) {
+
+ const sinPhiRadius = Math.sin( phi ) * radius;
+
+ this.x = sinPhiRadius * Math.sin( theta );
+ this.y = Math.cos( phi ) * radius;
+ this.z = sinPhiRadius * Math.cos( theta );
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector components from the given cylindrical coordinates.
+ *
+ * @param {Cylindrical} c - The cylindrical coordinates.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromCylindrical( c ) {
+
+ return this.setFromCylindricalCoords( c.radius, c.theta, c.y );
+
+ }
+
+ /**
+ * Sets the vector components from the given cylindrical coordinates.
+ *
+ * @param {number} radius - The radius.
+ * @param {number} theta - The theta angle in radians.
+ * @param {number} y - The y value.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromCylindricalCoords( radius, theta, y ) {
+
+ this.x = radius * Math.sin( theta );
+ this.y = y;
+ this.z = radius * Math.cos( theta );
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector components to the position elements of the
+ * given transformation matrix.
+ *
+ * @param {Matrix4} m - The 4x4 matrix.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromMatrixPosition( m ) {
+
+ const e = m.elements;
+
+ this.x = e[ 12 ];
+ this.y = e[ 13 ];
+ this.z = e[ 14 ];
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector components to the scale elements of the
+ * given transformation matrix.
+ *
+ * @param {Matrix4} m - The 4x4 matrix.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromMatrixScale( m ) {
+
+ const sx = this.setFromMatrixColumn( m, 0 ).length();
+ const sy = this.setFromMatrixColumn( m, 1 ).length();
+ const sz = this.setFromMatrixColumn( m, 2 ).length();
+
+ this.x = sx;
+ this.y = sy;
+ this.z = sz;
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector components from the specified matrix column.
+ *
+ * @param {Matrix4} m - The 4x4 matrix.
+ * @param {number} index - The column index.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromMatrixColumn( m, index ) {
+
+ return this.fromArray( m.elements, index * 4 );
+
+ }
+
+ /**
+ * Sets the vector components from the specified matrix column.
+ *
+ * @param {Matrix3} m - The 3x3 matrix.
+ * @param {number} index - The column index.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromMatrix3Column( m, index ) {
+
+ return this.fromArray( m.elements, index * 3 );
+
+ }
+
+ /**
+ * Sets the vector components from the given Euler angles.
+ *
+ * @param {Euler} e - The Euler angles to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromEuler( e ) {
+
+ this.x = e._x;
+ this.y = e._y;
+ this.z = e._z;
+
+ return this;
+
+ }
+
+ /**
+ * Sets the vector components from the RGB components of the
+ * given color.
+ *
+ * @param {Color} c - The color to set.
+ * @return {Vector3} A reference to this vector.
+ */
+ setFromColor( c ) {
+
+ this.x = c.r;
+ this.y = c.g;
+ this.z = c.b;
+
+ return this;
+
+ }
+
+ /**
+ * Returns `true` if this vector is equal with the given one.
+ *
+ * @param {Vector3} v - The vector to test for equality.
+ * @return {boolean} Whether this vector is equal with the given one.
+ */
+ equals( v ) {
+
+ return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
+
+ }
+
+ /**
+ * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`
+ * and z value to be `array[ offset + 2 ]`.
+ *
+ * @param {Array} array - An array holding the vector component values.
+ * @param {number} [offset=0] - The offset into the array.
+ * @return {Vector3} A reference to this vector.
+ */
+ fromArray( array, offset = 0 ) {
+
+ this.x = array[ offset ];
+ this.y = array[ offset + 1 ];
+ this.z = array[ offset + 2 ];
+
+ return this;
+
+ }
+
+ /**
+ * Writes the components of this vector to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the vector components.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The vector components.
+ */
+ toArray( array = [], offset = 0 ) {
+
+ array[ offset ] = this.x;
+ array[ offset + 1 ] = this.y;
+ array[ offset + 2 ] = this.z;
+
+ return array;
+
+ }
+
+ /**
+ * Sets the components of this vector from the given buffer attribute.
+ *
+ * @param {BufferAttribute} attribute - The buffer attribute holding vector data.
+ * @param {number} index - The index into the attribute.
+ * @return {Vector3} A reference to this vector.
+ */
+ fromBufferAttribute( attribute, index ) {
+
+ this.x = attribute.getX( index );
+ this.y = attribute.getY( index );
+ this.z = attribute.getZ( index );
+
+ return this;
+
+ }
+
+ /**
+ * Sets each component of this vector to a pseudo-random value between `0` and
+ * `1`, excluding `1`.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ random() {
+
+ this.x = Math.random();
+ this.y = Math.random();
+ this.z = Math.random();
+
+ return this;
+
+ }
+
+ /**
+ * Sets this vector to a uniformly random point on a unit sphere.
+ *
+ * @return {Vector3} A reference to this vector.
+ */
+ randomDirection() {
+
+ // https://mathworld.wolfram.com/SpherePointPicking.html
+
+ const theta = Math.random() * Math.PI * 2;
+ const u = Math.random() * 2 - 1;
+ const c = Math.sqrt( 1 - u * u );
+
+ this.x = c * Math.cos( theta );
+ this.y = u;
+ this.z = c * Math.sin( theta );
+
+ return this;
+
+ }
+
+ *[ Symbol.iterator ]() {
+
+ yield this.x;
+ yield this.y;
+ yield this.z;
+
+ }
+
+}
+
+const _vector$c = /*@__PURE__*/ new Vector3();
+const _quaternion$5 = /*@__PURE__*/ new Quaternion();
+
+/**
+ * Represents a 3x3 matrix.
+ *
+ * A Note on Row-Major and Column-Major Ordering:
+ *
+ * The constructor and {@link Matrix3#set} method take arguments in
+ * [row-major](https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order)
+ * order, while internally they are stored in the {@link Matrix3#elements} array in column-major order.
+ * This means that calling:
+ * ```js
+ * const m = new THREE.Matrix();
+ * m.set( 11, 12, 13,
+ * 21, 22, 23,
+ * 31, 32, 33 );
+ * ```
+ * will result in the elements array containing:
+ * ```js
+ * m.elements = [ 11, 21, 31,
+ * 12, 22, 32,
+ * 13, 23, 33 ];
+ * ```
+ * and internally all calculations are performed using column-major ordering.
+ * However, as the actual ordering makes no difference mathematically and
+ * most people are used to thinking about matrices in row-major order, the
+ * three.js documentation shows matrices in row-major order. Just bear in
+ * mind that if you are reading the source code, you'll have to take the
+ * transpose of any matrices outlined here to make sense of the calculations.
+ */
+class Matrix3 {
+
+ static {
+
+ /**
+ * This flag can be used for type testing.
+ *
+ * @type {boolean}
+ * @readonly
+ * @default true
+ */
+ this.prototype.isMatrix3 = true;
+
+ }
+
+ /**
+ * Constructs a new 3x3 matrix. The arguments are supposed to be
+ * in row-major order. If no arguments are provided, the constructor
+ * initializes the matrix as an identity matrix.
+ *
+ * @param {number} [n11] - 1-1 matrix element.
+ * @param {number} [n12] - 1-2 matrix element.
+ * @param {number} [n13] - 1-3 matrix element.
+ * @param {number} [n21] - 2-1 matrix element.
+ * @param {number} [n22] - 2-2 matrix element.
+ * @param {number} [n23] - 2-3 matrix element.
+ * @param {number} [n31] - 3-1 matrix element.
+ * @param {number} [n32] - 3-2 matrix element.
+ * @param {number} [n33] - 3-3 matrix element.
+ */
+ constructor( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {
+
+ /**
+ * A column-major list of matrix values.
+ *
+ * @type {Array}
+ */
+ this.elements = [
+
+ 1, 0, 0,
+ 0, 1, 0,
+ 0, 0, 1
+
+ ];
+
+ if ( n11 !== undefined ) {
+
+ this.set( n11, n12, n13, n21, n22, n23, n31, n32, n33 );
+
+ }
+
+ }
+
+ /**
+ * Sets the elements of the matrix.The arguments are supposed to be
+ * in row-major order.
+ *
+ * @param {number} [n11] - 1-1 matrix element.
+ * @param {number} [n12] - 1-2 matrix element.
+ * @param {number} [n13] - 1-3 matrix element.
+ * @param {number} [n21] - 2-1 matrix element.
+ * @param {number} [n22] - 2-2 matrix element.
+ * @param {number} [n23] - 2-3 matrix element.
+ * @param {number} [n31] - 3-1 matrix element.
+ * @param {number} [n32] - 3-2 matrix element.
+ * @param {number} [n33] - 3-3 matrix element.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ set( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {
+
+ const te = this.elements;
+
+ te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;
+ te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;
+ te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;
+
+ return this;
+
+ }
+
+ /**
+ * Sets this matrix to the 3x3 identity matrix.
+ *
+ * @return {Matrix3} A reference to this matrix.
+ */
+ identity() {
+
+ this.set(
+
+ 1, 0, 0,
+ 0, 1, 0,
+ 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ /**
+ * Copies the values of the given matrix to this instance.
+ *
+ * @param {Matrix3} m - The matrix to copy.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ copy( m ) {
+
+ const te = this.elements;
+ const me = m.elements;
+
+ te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];
+ te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];
+ te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];
+
+ return this;
+
+ }
+
+ /**
+ * Extracts the basis of this matrix into the three axis vectors provided.
+ *
+ * @param {Vector3} xAxis - The basis's x axis.
+ * @param {Vector3} yAxis - The basis's y axis.
+ * @param {Vector3} zAxis - The basis's z axis.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ extractBasis( xAxis, yAxis, zAxis ) {
+
+ xAxis.setFromMatrix3Column( this, 0 );
+ yAxis.setFromMatrix3Column( this, 1 );
+ zAxis.setFromMatrix3Column( this, 2 );
+
+ return this;
+
+ }
+
+ /**
+ * Set this matrix to the upper 3x3 matrix of the given 4x4 matrix.
+ *
+ * @param {Matrix4} m - The 4x4 matrix.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ setFromMatrix4( m ) {
+
+ const me = m.elements;
+
+ this.set(
+
+ me[ 0 ], me[ 4 ], me[ 8 ],
+ me[ 1 ], me[ 5 ], me[ 9 ],
+ me[ 2 ], me[ 6 ], me[ 10 ]
+
+ );
+
+ return this;
+
+ }
+
+ /**
+ * Post-multiplies this matrix by the given 3x3 matrix.
+ *
+ * @param {Matrix3} m - The matrix to multiply with.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ multiply( m ) {
+
+ return this.multiplyMatrices( this, m );
+
+ }
+
+ /**
+ * Pre-multiplies this matrix by the given 3x3 matrix.
+ *
+ * @param {Matrix3} m - The matrix to multiply with.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ premultiply( m ) {
+
+ return this.multiplyMatrices( m, this );
+
+ }
+
+ /**
+ * Multiples the given 3x3 matrices and stores the result
+ * in this matrix.
+ *
+ * @param {Matrix3} a - The first matrix.
+ * @param {Matrix3} b - The second matrix.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ multiplyMatrices( a, b ) {
+
+ const ae = a.elements;
+ const be = b.elements;
+ const te = this.elements;
+
+ const a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];
+ const a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];
+ const a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];
+
+ const b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];
+ const b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];
+ const b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];
+
+ te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;
+ te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;
+ te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;
+
+ te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;
+ te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;
+ te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;
+
+ te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;
+ te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;
+ te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;
+
+ return this;
+
+ }
+
+ /**
+ * Multiplies every component of the matrix by the given scalar.
+ *
+ * @param {number} s - The scalar.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ multiplyScalar( s ) {
+
+ const te = this.elements;
+
+ te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;
+ te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;
+ te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;
+
+ return this;
+
+ }
+
+ /**
+ * Computes and returns the determinant of this matrix.
+ *
+ * @return {number} The determinant.
+ */
+ determinant() {
+
+ const te = this.elements;
+
+ const a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],
+ d = te[ 3 ], e = te[ 4 ], f = te[ 5 ],
+ g = te[ 6 ], h = te[ 7 ], i = te[ 8 ];
+
+ return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
+
+ }
+
+ /**
+ * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).
+ * You can not invert with a determinant of zero. If you attempt this, the method produces
+ * a zero matrix instead.
+ *
+ * @return {Matrix3} A reference to this matrix.
+ */
+ invert() {
+
+ const te = this.elements,
+
+ n11 = te[ 0 ], n21 = te[ 1 ], n31 = te[ 2 ],
+ n12 = te[ 3 ], n22 = te[ 4 ], n32 = te[ 5 ],
+ n13 = te[ 6 ], n23 = te[ 7 ], n33 = te[ 8 ],
+
+ t11 = n33 * n22 - n32 * n23,
+ t12 = n32 * n13 - n33 * n12,
+ t13 = n23 * n12 - n22 * n13,
+
+ det = n11 * t11 + n21 * t12 + n31 * t13;
+
+ if ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+
+ const detInv = 1 / det;
+
+ te[ 0 ] = t11 * detInv;
+ te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;
+ te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;
+
+ te[ 3 ] = t12 * detInv;
+ te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;
+ te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;
+
+ te[ 6 ] = t13 * detInv;
+ te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;
+ te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;
+
+ return this;
+
+ }
+
+ /**
+ * Transposes this matrix in place.
+ *
+ * @return {Matrix3} A reference to this matrix.
+ */
+ transpose() {
+
+ let tmp;
+ const m = this.elements;
+
+ tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;
+ tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;
+ tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;
+
+ return this;
+
+ }
+
+ /**
+ * Computes the normal matrix which is the inverse transpose of the upper
+ * left 3x3 portion of the given 4x4 matrix.
+ *
+ * @param {Matrix4} matrix4 - The 4x4 matrix.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ getNormalMatrix( matrix4 ) {
+
+ return this.setFromMatrix4( matrix4 ).invert().transpose();
+
+ }
+
+ /**
+ * Transposes this matrix into the supplied array, and returns itself unchanged.
+ *
+ * @param {Array} r - An array to store the transposed matrix elements.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ transposeIntoArray( r ) {
+
+ const m = this.elements;
+
+ r[ 0 ] = m[ 0 ];
+ r[ 1 ] = m[ 3 ];
+ r[ 2 ] = m[ 6 ];
+ r[ 3 ] = m[ 1 ];
+ r[ 4 ] = m[ 4 ];
+ r[ 5 ] = m[ 7 ];
+ r[ 6 ] = m[ 2 ];
+ r[ 7 ] = m[ 5 ];
+ r[ 8 ] = m[ 8 ];
+
+ return this;
+
+ }
+
+ /**
+ * Sets the UV transform matrix from offset, repeat, rotation, and center.
+ *
+ * @param {number} tx - Offset x.
+ * @param {number} ty - Offset y.
+ * @param {number} sx - Repeat x.
+ * @param {number} sy - Repeat y.
+ * @param {number} rotation - Rotation, in radians. Positive values rotate counterclockwise.
+ * @param {number} cx - Center x of rotation.
+ * @param {number} cy - Center y of rotation
+ * @return {Matrix3} A reference to this matrix.
+ */
+ setUvTransform( tx, ty, sx, sy, rotation, cx, cy ) {
+
+ const c = Math.cos( rotation );
+ const s = Math.sin( rotation );
+
+ this.set(
+ sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,
+ - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,
+ 0, 0, 1
+ );
+
+ return this;
+
+ }
+
+ /**
+ * Scales this matrix with the given scalar values.
+ *
+ * @deprecated
+ * @param {number} sx - The amount to scale in the X axis.
+ * @param {number} sy - The amount to scale in the Y axis.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ scale( sx, sy ) {
+
+ warnOnce( 'Matrix3: .scale() is deprecated. Use .makeScale() instead.' ); // @deprecated r185
+
+ this.premultiply( _m3.makeScale( sx, sy ) );
+
+ return this;
+
+ }
+
+ /**
+ * Rotates this matrix by the given angle.
+ *
+ * @deprecated
+ * @param {number} theta - The rotation in radians.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ rotate( theta ) {
+
+ warnOnce( 'Matrix3: .rotate() is deprecated. Use .makeRotation() instead.' ); // @deprecated r185
+
+ this.premultiply( _m3.makeRotation( - theta ) );
+
+ return this;
+
+ }
+
+ /**
+ * Translates this matrix by the given scalar values.
+ *
+ * @deprecated
+ * @param {number} tx - The amount to translate in the X axis.
+ * @param {number} ty - The amount to translate in the Y axis.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ translate( tx, ty ) {
+
+ warnOnce( 'Matrix3: .translate() is deprecated. Use .makeTranslation() instead.' ); // @deprecated r185
+
+ this.premultiply( _m3.makeTranslation( tx, ty ) );
+
+ return this;
+
+ }
+
+ // for 2D Transforms
+
+ /**
+ * Sets this matrix as a 2D translation transform.
+ *
+ * @param {number|Vector2} x - The amount to translate in the X axis or alternatively a translation vector.
+ * @param {number} y - The amount to translate in the Y axis.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ makeTranslation( x, y ) {
+
+ if ( x.isVector2 ) {
+
+ this.set(
+
+ 1, 0, x.x,
+ 0, 1, x.y,
+ 0, 0, 1
+
+ );
+
+ } else {
+
+ this.set(
+
+ 1, 0, x,
+ 0, 1, y,
+ 0, 0, 1
+
+ );
+
+ }
+
+ return this;
+
+ }
+
+ /**
+ * Sets this matrix as a 2D rotational transformation.
+ *
+ * @param {number} theta - The rotation in radians.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ makeRotation( theta ) {
+
+ // counterclockwise
+
+ const c = Math.cos( theta );
+ const s = Math.sin( theta );
+
+ this.set(
+
+ c, - s, 0,
+ s, c, 0,
+ 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ /**
+ * Sets this matrix as a 2D scale transform.
+ *
+ * @param {number} x - The amount to scale in the X axis.
+ * @param {number} y - The amount to scale in the Y axis.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ makeScale( x, y ) {
+
+ this.set(
+
+ x, 0, 0,
+ 0, y, 0,
+ 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ /**
+ * Returns `true` if this matrix is equal with the given one.
+ *
+ * @param {Matrix3} matrix - The matrix to test for equality.
+ * @return {boolean} Whether this matrix is equal with the given one.
+ */
+ equals( matrix ) {
+
+ const te = this.elements;
+ const me = matrix.elements;
+
+ for ( let i = 0; i < 9; i ++ ) {
+
+ if ( te[ i ] !== me[ i ] ) return false;
+
+ }
+
+ return true;
+
+ }
+
+ /**
+ * Sets the elements of the matrix from the given array.
+ *
+ * @param {Array} array - The matrix elements in column-major order.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Matrix3} A reference to this matrix.
+ */
+ fromArray( array, offset = 0 ) {
+
+ for ( let i = 0; i < 9; i ++ ) {
+
+ this.elements[ i ] = array[ i + offset ];
+
+ }
+
+ return this;
+
+ }
+
+ /**
+ * Writes the elements of this matrix to the given array. If no array is provided,
+ * the method returns a new instance.
+ *
+ * @param {Array} [array=[]] - The target array holding the matrix elements in column-major order.
+ * @param {number} [offset=0] - Index of the first element in the array.
+ * @return {Array} The matrix elements in column-major order.
+ */
+ toArray( array = [], offset = 0 ) {
+
+ const te = this.elements;
+
+ array[ offset ] = te[ 0 ];
+ array[ offset + 1 ] = te[ 1 ];
+ array[ offset + 2 ] = te[ 2 ];
+
+ array[ offset + 3 ] = te[ 3 ];
+ array[ offset + 4 ] = te[ 4 ];
+ array[ offset + 5 ] = te[ 5 ];
+
+ array[ offset + 6 ] = te[ 6 ];
+ array[ offset + 7 ] = te[ 7 ];
+ array[ offset + 8 ] = te[ 8 ];
+
+ return array;
+
+ }
+
+ /**
+ * Returns a matrix with copied values from this instance.
+ *
+ * @return {Matrix3} A clone of this instance.
+ */
+ clone() {
+
+ return new this.constructor().fromArray( this.elements );
+
+ }
+
+}
+
+const _m3 = /*@__PURE__*/ new Matrix3();
+
+const LINEAR_REC709_TO_XYZ = /*@__PURE__*/ new Matrix3().set(
+ 0.4123908, 0.3575843, 0.1804808,
+ 0.2126390, 0.7151687, 0.0721923,
+ 0.0193308, 0.1191948, 0.9505322
+);
+
+const XYZ_TO_LINEAR_REC709 = /*@__PURE__*/ new Matrix3().set(
+ 3.2409699, -1.5373832, -0.4986108,
+ -0.9692436, 1.8759675, 0.0415551,
+ 0.0556301, -0.203977, 1.0569715
+);
+
+function createColorManagement() {
+
+ const ColorManagement = {
+
+ enabled: true,
+
+ workingColorSpace: LinearSRGBColorSpace,
+
+ /**
+ * Implementations of supported color spaces.
+ *
+ * Required:
+ * - primaries: chromaticity coordinates [ rx ry gx gy bx by ]
+ * - whitePoint: reference white [ x y ]
+ * - transfer: transfer function (pre-defined)
+ * - toXYZ: Matrix3 RGB to XYZ transform
+ * - fromXYZ: Matrix3 XYZ to RGB transform
+ * - luminanceCoefficients: RGB luminance coefficients
+ *
+ * Optional:
+ * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace, toneMappingMode: 'extended' | 'standard' }
+ * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
+ *
+ * Reference:
+ * - https://www.russellcottrell.com/photo/matrixCalculator.htm
+ */
+ spaces: {},
+
+ convert: function ( color, sourceColorSpace, targetColorSpace ) {
+
+ if ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
+
+ return color;
+
+ }
+
+ if ( this.spaces[ sourceColorSpace ].transfer === SRGBTransfer ) {
+
+ color.r = SRGBToLinear( color.r );
+ color.g = SRGBToLinear( color.g );
+ color.b = SRGBToLinear( color.b );
+
+ }
+
+ if ( this.spaces[ sourceColorSpace ].primaries !== this.spaces[ targetColorSpace ].primaries ) {
+
+ color.applyMatrix3( this.spaces[ sourceColorSpace ].toXYZ );
+ color.applyMatrix3( this.spaces[ targetColorSpace ].fromXYZ );
+
+ }
+
+ if ( this.spaces[ targetColorSpace ].transfer === SRGBTransfer ) {
+
+ color.r = LinearToSRGB( color.r );
+ color.g = LinearToSRGB( color.g );
+ color.b = LinearToSRGB( color.b );
+
+ }
+
+ return color;
+
+ },
+
+ workingToColorSpace: function ( color, targetColorSpace ) {
+
+ return this.convert( color, this.workingColorSpace, targetColorSpace );
+
+ },
+
+ colorSpaceToWorking: function ( color, sourceColorSpace ) {
+
+ return this.convert( color, sourceColorSpace, this.workingColorSpace );
+
+ },
+
+ getPrimaries: function ( colorSpace ) {
+
+ return this.spaces[ colorSpace ].primaries;
+
+ },
+
+ getTransfer: function ( colorSpace ) {
+
+ if ( colorSpace === NoColorSpace ) return LinearTransfer;
+
+ return this.spaces[ colorSpace ].transfer;
+
+ },
+
+ getToneMappingMode: function ( colorSpace ) {
+
+ return this.spaces[ colorSpace ].outputColorSpaceConfig.toneMappingMode || 'standard';
+
+ },
+
+ getLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {
+
+ return target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );
+
+ },
+
+ define: function ( colorSpaces ) {
+
+ Object.assign( this.spaces, colorSpaces );
+
+ },
+
+ // Internal APIs
+
+ _getMatrix: function ( targetMatrix, sourceColorSpace, targetColorSpace ) {
+
+ return targetMatrix
+ .copy( this.spaces[ targetColorSpace ].fromXYZ )
+ .multiply( this.spaces[ sourceColorSpace ].toXYZ );
+
+ },
+
+ _getDrawingBufferColorSpace: function ( colorSpace ) {
+
+ return this.spaces[ colorSpace ].outputColorSpaceConfig.drawingBufferColorSpace;
+
+ },
+
+ _getUnpackColorSpace: function ( colorSpace = this.workingColorSpace ) {
+
+ return this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;
+
+ },
+
+ };
+
+ /******************************************************************************
+ * sRGB definitions
+ */
+
+ const REC709_PRIMARIES = [ 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 ];
+ const REC709_LUMINANCE_COEFFICIENTS = [ 0.2126, 0.7152, 0.0722 ];
+ const D65 = [ 0.3127, 0.3290 ];
+
+ ColorManagement.define( {
+
+ [ LinearSRGBColorSpace ]: {
+ primaries: REC709_PRIMARIES,
+ whitePoint: D65,
+ transfer: LinearTransfer,
+ toXYZ: LINEAR_REC709_TO_XYZ,
+ fromXYZ: XYZ_TO_LINEAR_REC709,
+ luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
+ workingColorSpaceConfig: { unpackColorSpace: SRGBColorSpace },
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
+ },
+
+ [ SRGBColorSpace ]: {
+ primaries: REC709_PRIMARIES,
+ whitePoint: D65,
+ transfer: SRGBTransfer,
+ toXYZ: LINEAR_REC709_TO_XYZ,
+ fromXYZ: XYZ_TO_LINEAR_REC709,
+ luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
+ },
+
+ } );
+
+ return ColorManagement;
+
+}
+
+const ColorManagement = /*@__PURE__*/ createColorManagement();
+
+function SRGBToLinear( c ) {
+
+ return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
+
+}
+
+function LinearToSRGB( c ) {
+
+ return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
+
+}
+
+let _canvas;
+
+/**
+ * A class containing utility functions for images.
+ *
+ * @hideconstructor
+ */
+class ImageUtils {
+
+ /**
+ * Returns a data URI containing a representation of the given image.
+ *
+ * @param {(HTMLImageElement|HTMLCanvasElement)} image - The image object.
+ * @param {string} [type='image/png'] - Indicates the image format.
+ * @return {string} The data URI.
+ */
+ static getDataURL( image, type = 'image/png' ) {
+
+ if ( /^data:/i.test( image.src ) ) {
+
+ return image.src;
+
+ }
+
+ if ( typeof HTMLCanvasElement === 'undefined' ) {
+
+ return image.src;
+
+ }
+
+ let canvas;
+
+ if ( image instanceof HTMLCanvasElement ) {
+
+ canvas = image;
+
+ } else {
+
+ if ( _canvas === undefined ) _canvas = createElementNS( 'canvas' );
+
+ _canvas.width = image.width;
+ _canvas.height = image.height;
+
+ const context = _canvas.getContext( '2d' );
+
+ if ( image instanceof ImageData ) {
+
+ context.putImageData( image, 0, 0 );
+
+ } else {
+
+ context.drawImage( image, 0, 0, image.width, image.height );
+
+ }
+
+ canvas = _canvas;
+
+ }
+
+ return canvas.toDataURL( type );
+
+ }
+
+ /**
+ * Converts the given sRGB image data to linear color space.
+ *
+ * @param {(HTMLImageElement|HTMLCanvasElement|ImageBitmap|Object)} image - The image object.
+ * @return {HTMLCanvasElement|Object} The converted image.
+ */
+ static sRGBToLinear( image ) {
+
+ if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
+ ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
+ ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
+
+ const canvas = createElementNS( 'canvas' );
+
+ canvas.width = image.width;
+ canvas.height = image.height;
+
+ const context = canvas.getContext( '2d' );
+ context.drawImage( image, 0, 0, image.width, image.height );
+
+ const imageData = context.getImageData( 0, 0, image.width, image.height );
+ const data = imageData.data;
+
+ for ( let i = 0; i < data.length; i ++ ) {
+
+ data[ i ] = SRGBToLinear( data[ i ] / 255 ) * 255;
+
+ }
+
+ context.putImageData( imageData, 0, 0 );
+
+ return canvas;
+
+ } else if ( image.data ) {
+
+ const data = image.data.slice( 0 );
+
+ for ( let i = 0; i < data.length; i ++ ) {
+
+ if ( data instanceof Uint8Array || data instanceof Uint8ClampedArray ) {
+
+ data[ i ] = Math.floor( SRGBToLinear( data[ i ] / 255 ) * 255 );
+
+ } else {
+
+ // assuming float
+
+ data[ i ] = SRGBToLinear( data[ i ] );
+
+ }
+
+ }
+
+ return {
+ data: data,
+ width: image.width,
+ height: image.height
+ };
+
+ } else {
+
+ warn( 'ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.' );
+ return image;
+
+ }
+
+ }
+
+}
+
+let _sourceId = 0;
+
+/**
+ * Represents the data source of a texture.
+ *
+ * The main purpose of this class is to decouple the data definition from the texture
+ * definition so the same data can be used with multiple texture instances.
+ */
+class TextureSource {
+
+ /**
+ * Constructs a new texture source.
+ *
+ * @param {any} [data=null] - The data definition of a texture.
+ */
+ constructor( data = null ) {
+
+ /**
+ * This flag can be used for type testing.
+ *
+ * @type {boolean}
+ * @readonly
+ * @default true
+ */
+ this.isTextureSource = true;
+
+ /**
+ * The ID of the source.
+ *
+ * @name TextureSource#id
+ * @type {number}
+ * @readonly
+ */
+ Object.defineProperty( this, 'id', { value: _sourceId ++ } );
+
+ /**
+ * The UUID of the source.
+ *
+ * @type {string}
+ * @readonly
+ */
+ this.uuid = generateUUID();
+
+ /**
+ * The data definition of a texture.
+ *
+ * @type {any}
+ */
+ this.data = data;
+
+ /**
+ * This property is only relevant when {@link TextureSource#needsUpdate} is set to `true` and
+ * provides more control on how texture data should be processed. When `dataReady` is set
+ * to `false`, the engine performs the memory allocation (if necessary) but does not transfer
+ * the data into the GPU memory.
+ *
+ * @type {boolean}
+ * @default true
+ */
+ this.dataReady = true;
+
+ /**
+ * This starts at `0` and counts how many times {@link TextureSource#needsUpdate} is set to `true`.
+ *
+ * @type {number}
+ * @readonly
+ * @default 0
+ */
+ this.version = 0;
+
+ }
+
+ /**
+ * Returns the dimensions of the source into the given target vector.
+ *
+ * @param {(Vector2|Vector3)} target - The target object the result is written into.
+ * @return {(Vector2|Vector3)} The dimensions of the source.
+ */
+ getSize( target ) {
+
+ const data = this.data;
+
+ if ( ( typeof HTMLVideoElement !== 'undefined' ) && ( data instanceof HTMLVideoElement ) ) {
+
+ target.set( data.videoWidth, data.videoHeight, 0 );
+
+ } else if ( ( typeof VideoFrame !== 'undefined' ) && ( data instanceof VideoFrame ) ) {
+
+ target.set( data.displayWidth, data.displayHeight, 0 );
+
+ } else if ( data !== null ) {
+
+ target.set( data.width || 0, data.height || 0, data.depth || 0 );
+
+ } else {
+
+ target.set( 0, 0, 0 );
+
+ }
+
+ return target;
+
+ }
+
+ /**
+ * When the property is set to `true`, the engine allocates the memory
+ * for the texture (if necessary) and triggers the actual texture upload
+ * to the GPU next time the source is used.
+ *
+ * @type {boolean}
+ * @default false
+ * @param {boolean} value
+ */
+ set needsUpdate( value ) {
+
+ if ( value === true ) this.version ++;
+
+ }
+
+ /**
+ * Serializes the source into JSON.
+ *
+ * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
+ * @return {Object} A JSON object representing the serialized source.
+ * @see {@link ObjectLoader#parse}
+ */
+ toJSON( meta ) {
+
+ const isRootObject = ( meta === undefined || typeof meta === 'string' );
+
+ if ( ! isRootObject && meta.images[ this.uuid ] !== undefined ) {
+
+ return meta.images[ this.uuid ];
+
+ }
+
+ const output = {
+ uuid: this.uuid,
+ url: ''
+ };
+
+ const data = this.data;
+
+ if ( data !== null ) {
+
+ let url;
+
+ if ( Array.isArray( data ) ) {
+
+ // cube texture
+
+ url = [];
+
+ for ( let i = 0, l = data.length; i < l; i ++ ) {
+
+ if ( data[ i ].isDataTexture ) {
+
+ url.push( serializeImage( data[ i ].image ) );
+
+ } else {
+
+ url.push( serializeImage( data[ i ] ) );
+
+ }
+
+ }
+
+ } else {
+
+ // texture
+
+ url = serializeImage( data );
+
+ }
+
+ output.url = url;
+
+ }
+
+ if ( ! isRootObject ) {
+
+ meta.images[ this.uuid ] = output;
+
+ }
+
+ return output;
+
+ }
+
+}
+
+function serializeImage( image ) {
+
+ if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
+ ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
+ ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
+
+ // default images
+
+ return ImageUtils.getDataURL( image );
+
+ } else {
+
+ if ( image.data ) {
+
+ // images of DataTexture
+
+ return {
+ data: Array.from( image.data ),
+ width: image.width,
+ height: image.height,
+ type: image.data.constructor.name
+ };
+
+ } else {
+
+ warn( 'Texture: Unable to serialize Texture.' );
+ return {};
+
+ }
+
+ }
+
+}
+
+/**
+ * @deprecated since r186. Use {@link TextureSource} instead. `Source` has been renamed to `TextureSource`.
+ */
+class Source extends TextureSource {
+
+ /**
+ * Constructs a new texture source.
+ *
+ * @param {any} [data=null] - The data definition of a texture.
+ * @deprecated since r186. Use {@link TextureSource} instead.
+ */
+ constructor( data = null ) {
+
+ warnOnce( 'Source: "Source" has been renamed to "TextureSource". Please update your code to use "THREE.TextureSource" instead.' ); // @deprecated, r186
+
+ super( data );
+
+ /**
+ * This flag can be used for type testing.
+ *
+ * @deprecated since r186. Use {@link TextureSource#isTextureSource} instead.
+ * @type {boolean}
+ * @readonly
+ * @default true
+ */
+ this.isSource = true;
+
+ }
+
+}
+
+let _textureId = 0;
+
+const _tempVec3 = /*@__PURE__*/ new Vector3();
+
+/**
+ * Base class for all textures.
+ *
+ * Note: After the initial use of a texture, its dimensions, format, and type
+ * cannot be changed. Instead, call {@link Texture#dispose} on the texture and instantiate a new one.
+ *
+ * @augments EventDispatcher
+ */
+class Texture extends EventDispatcher {
+
+ /**
+ * Constructs a new texture.
+ *
+ * @param {?Object} [image=Texture.DEFAULT_IMAGE] - The image holding the texture data.
+ * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.
+ * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.
+ * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.
+ * @param {number} [magFilter=LinearFilter] - The mag filter value.
+ * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.
+ * @param {number} [format=RGBAFormat] - The texture format.
+ * @param {number} [type=UnsignedByteType] - The texture type.
+ * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
+ * @param {string} [colorSpace=NoColorSpace] - The color space.
+ */
+ constructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = Texture.DEFAULT_ANISOTROPY, colorSpace = NoColorSpace ) {
+
+ super();
+
+ /**
+ * This flag can be used for type testing.
+ *
+ * @type {boolean}
+ * @readonly
+ * @default true
+ */
+ this.isTexture = true;
+
+ /**
+ * The ID of the texture.
+ *
+ * @name Texture#id
+ * @type {number}
+ * @readonly
+ */
+ Object.defineProperty( this, 'id', { value: _textureId ++ } );
+
+ /**
+ * The UUID of the texture.
+ *
+ * @type {string}
+ * @readonly
+ */
+ this.uuid = generateUUID();
+
+ /**
+ * The name of the texture.
+ *
+ * @type {string}
+ */
+ this.name = '';
+
+ /**
+ * The data definition of a texture. A reference to the data source can be
+ * shared across textures. This is often useful in context of spritesheets
+ * where multiple textures render the same data but with different texture
+ * transformations.
+ *
+ * @type {TextureSource}
+ */
+ this.source = new TextureSource( image );
+
+ /**
+ * An array holding user-defined mipmaps.
+ *
+ * @type {Array