- Added move on camera with effect
This commit is contained in:
Kum1ta
2024-08-24 02:56:55 +02:00
parent 7c9a646e50
commit ccee8a207b
28 changed files with 2301 additions and 71 deletions

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/22 23:13:53 by edbernar #+# #+# */
/* Updated: 2024/08/23 02:24:09 by edbernar ### ########.fr */
/* Updated: 2024/08/24 02:36:42 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,6 +19,8 @@ class Screen
{
screen = null;
tv = null;
pointLightIntensity = 1;
screenMaterial = null;
constructor(scene)
{
@ -31,7 +33,9 @@ class Screen
tv.geometry.center();
this.tv = tv;
tv.position.set(0, 0.99, 2);
// tv.material = new THREE.MeshPhysicalMaterial({color: 0x222222});
tv.material = new THREE.MeshPhysicalMaterial({color: 0xaaaaaa});
tv.material.roughness = 10;
tv.material.metalness = 1;
tv.scale.set(0.05, 0.05, 0.05);
tv.castShadow = true;
tv.receiveShadow = true;
@ -50,7 +54,7 @@ class Screen
const vertices = positionAttribute.array;
const material = new THREE.MeshStandardMaterial({color: 0xbbbbbb});
const mesh = new THREE.Mesh(geometry, material);
const pointLight = new THREE.PointLight( 0xffffff, 5, 0, 2);
const pointLight = new THREE.PointLight( 0xffffff, 10 * this.pointLightIntensity, 0, 2);
for (let i = 0; i < vertices.length; i += 3)
{
@ -62,20 +66,20 @@ class Screen
}
positionAttribute.needsUpdate = true;
mesh.scale.set(0.4, 0.4);
mesh.position.set(-0.155, 1.2, 1.3);
mesh.position.set(-0.155, 1.2, 1.15);
mesh.rotation.x = Math.PI + 0.05;
mesh.rotation.z = Math.PI;
scene.add(mesh);
pointLight.position.set(-0.155, 1.2, 0.8);
pointLight.position.set(-0.05, 1.2, 0.95);
pointLight.castShadow = true;
pointLight.shadow.mapSize.width = 2048;
pointLight.shadow.mapSize.height = 2048;
pointLight.shadow.radius = 20;
console.log(pointLight.shadow)
scene.add(pointLight);
setInterval(() => {
const intensity = Math.random() * 2 + 5;
const intensity = Math.random() * 2 + 10;
pointLight.intensity = intensity < 5 ? 5 : (intensity > 7 ? 7 : intensity);
pointLight.intensity = intensity * this.pointLightIntensity > 13 * this.pointLightIntensity ? 13 * this.pointLightIntensity : intensity * this.pointLightIntensity;
}, 100);
return (mesh);
}
@ -86,7 +90,7 @@ class Screen
const context = canvas.getContext('2d', { willReadFrequently: true });
const video = document.createElement('video');
const texture = new THREE.CanvasTexture(canvas);
const material = new THREE.MeshBasicMaterial({ map: texture,color: 0xffffff });
const material = new THREE.MeshBasicMaterial({ map: texture,color: 0xffffff, transparent: true, opacity: 1 });
canvas.width = 534;
canvas.height = 360;
@ -102,7 +106,7 @@ class Screen
updateCanvas();
}).catch(err => console.error("Error playing video: ", err));
});
function addNoiseOnImage(context)
{
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
@ -113,7 +117,7 @@ class Screen
const g = data[i + 1];
const b = data[i + 2];
const brightness = (3 * r + 4 * g + b) >>> 3;
const noise = Math.random() * 32 - 16;
const noise = Math.random() * 128 - 32;
data[i] = data[i + 1] = data[i + 2] = brightness + noise;
}
context.putImageData(imageData, 0, 0);
@ -127,10 +131,9 @@ class Screen
context.drawImage(video, 0, 0, canvas.width, canvas.height);
addNoiseOnImage(context);
texture.needsUpdate = true;
requestAnimationFrame(updateCanvas);
}
requestAnimationFrame(updateCanvas);
}
texture.offset.set(0.02, 0);
this.screen.material = material;
video.load();

View File

@ -6,29 +6,86 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/22 17:19:17 by edbernar #+# #+# */
/* Updated: 2024/08/23 02:23:55 by edbernar ### ########.fr */
/* Updated: 2024/08/24 02:46:49 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import * as THREE from 'three'
import { Screen } from './Screen.js'
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js';
import { BokehPass } from 'three/examples/jsm/postprocessing/BokehPass.js';
const scene = new THREE.Scene();
const renderer = new THREE.WebGLRenderer({antialias: true});
const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight);
const ambiantLight = new THREE.AmbientLight(0xffffff, 0.16);
const ambiantLight = new THREE.AmbientLight(0xffffff, 3);
const screen = new Screen(scene);
const cube = createCube();
renderer.toneMapping = THREE.LinearToneMapping;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.getElementsByClassName('homeSection')[0].appendChild(renderer.domElement);
scene.background = new THREE.Color(0x020202)
camera.position.set(0, 2.5, -5);
console.log(camera.rotation);
camera.position.set(6, 1, -5.5);
camera.rotation.set(Math.PI + 0.2, 0, Math.PI);
scene.add(ambiantLight);
let globalSpeed = 0.75;
const composer = new EffectComposer(renderer);
composer.addPass(new RenderPass(scene, camera));
const dofPass = new BokehPass(scene, camera, {
focus: 10.0,
aperture: 0.020,
maxblur: 0.01,
});
composer.addPass(dofPass);
setTimeout(() => {
let interval = setInterval(() => {
camera.position.x -= (0.01 * globalSpeed);
camera.lookAt(screen.tv.position);
if (camera.position.x < 3.3)
fadeInOut();
if (dofPass.materialBokeh.uniforms.aperture.value > 0)
dofPass.materialBokeh.uniforms.aperture.value -= 0.0001;
if (camera.position.x < 3)
{
clearInterval(interval);
camera.position.set(-2, 4, -6);
interval = setInterval(() => {
camera.lookAt(screen.tv.position);
camera.position.x += (0.01 * globalSpeed);
camera.position.y -= (0.005 * globalSpeed);
if (camera.position.x > 1.7)
fadeInOut();
if (camera.position.x > 2)
{
camera.position.set(0, 1.2, 0);
clearInterval(interval);
interval = setInterval(() => {
camera.lookAt(screen.tv.position);
camera.position.y += (0.005 * globalSpeed);
camera.position.z -= (0.01 * globalSpeed);
if (camera.position.x < -2.3)
fadeInOut();
if (camera.position.z < -2)
{
globalSpeed -= 0.001;
if (globalSpeed < 0)
clearInterval(interval);
}
}, 10);
}
}, 10);
}
}, 10);
}, 500)
document.addEventListener('resize', () => {
renderer.setSize(window.innerWidth, window.innerHeight);
@ -36,38 +93,44 @@ document.addEventListener('resize', () => {
camera.updateProjectionMatrix();
});
/***** FOR DEBUGGING PURPOSES *****/
let isInFade = false;
document.addEventListener('keydown', (e) => {
if (e.key === 'w')
camera.position.z += 0.1;
if (e.key === 's')
camera.position.z -= 0.1;
if (e.key === 'a')
camera.position.x -= 0.1;
if (e.key === 'd')
camera.position.x += 0.1;
if (e.key === 'q')
camera.position.y += 0.1;
if (e.key === 'e')
camera.position.y -= 0.1;
if (e.key === 'ArrowUp')
camera.rotation.x += 0.1;
if (e.key === 'ArrowDown')
camera.rotation.x -= 0.1;
if (e.key === 'ArrowLeft')
camera.rotation.y += 0.1;
if (e.key === 'ArrowRight')
camera.rotation.y -= 0.1;
if (e.key === 'p')
{
console.log(camera.position);
console.log(camera.rotation);
}
function fadeInOut()
{
if (isInFade)
return;
let interval = null;
isInFade = true;
interval = setInterval(() => {
screen.pointLightIntensity -= 0.2;
screen.screen.material.opacity -= 0.05;
if (screen.screen.material.opacity <= 0)
{
clearInterval(interval);
setTimeout(() => {
interval = setInterval(() => {
screen.pointLightIntensity += 0.2;
screen.screen.material.opacity += 0.05;
if (screen.screen.material.opacity >= 1)
{
clearInterval(interval);
isInFade = false;
}
}, 20);
}, 500);
}
}, 20);
}
});
function createCube()
{
const geometry = new THREE.BoxGeometry(5, 5, 0.1);
const material = new THREE.MeshStandardMaterial({color: 0x020202});
const mesh = new THREE.Mesh(geometry, material);
/**********************************/
mesh.position.set(8, 1, -5);
scene.add(mesh);
}
function home3D()
@ -91,7 +154,8 @@ function createPlane()
function loop()
{
renderer.render(scene, camera);
composer.render();
// renderer.render(scene, camera);
}

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* main.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madegryc <madegryc@student.42.fr> +#+ +:+ +#+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/30 13:50:35 by edbernar #+# #+# */
/* Updated: 2024/08/23 17:47:37 by madegryc ### ########.fr */
/* Updated: 2024/08/23 23:36:33 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,9 +25,9 @@ window.addEventListener('scroll', () => {
parallaxElement2.style.transform = `translateX(50%) translateY(${-parallaxSpeed}px) rotate(${rotationAngle}deg)`;
});
document.getElementById('closePopupBtn').addEventListener('click', function() {
document.getElementById('loginPopup').style.display = 'none';
});
// document.getElementById('closePopupBtn').addEventListener('click', function() {
// document.getElementById('loginPopup').style.display = 'none';
// });
document.addEventListener('DOMContentLoaded', () => {
liveChat();

View File

@ -1,23 +1,80 @@
{
"hash": "c14d87d3",
"configHash": "5e1f4c84",
"hash": "86ff4072",
"configHash": "2420ea4a",
"lockfileHash": "7685a2f8",
"browserHash": "80c73e8e",
"browserHash": "aad3db38",
"optimized": {
"three": {
"src": "../../three/build/three.module.js",
"file": "three.js",
"fileHash": "7ba8d136",
"fileHash": "f6b8584f",
"needsInterop": false
},
"three/addons/loaders/GLTFLoader.js": {
"src": "../../three/examples/jsm/loaders/GLTFLoader.js",
"file": "three_addons_loaders_GLTFLoader__js.js",
"fileHash": "38fc56e7",
"fileHash": "35494c7f",
"needsInterop": false
},
"three/examples/jsm/postprocessing/EffectComposer.js": {
"src": "../../three/examples/jsm/postprocessing/EffectComposer.js",
"file": "three_examples_jsm_postprocessing_EffectComposer__js.js",
"fileHash": "7753c0a1",
"needsInterop": false
},
"three/examples/jsm/postprocessing/RenderPass.js": {
"src": "../../three/examples/jsm/postprocessing/RenderPass.js",
"file": "three_examples_jsm_postprocessing_RenderPass__js.js",
"fileHash": "1a306bae",
"needsInterop": false
},
"three/examples/jsm/postprocessing/ShaderPass.js": {
"src": "../../three/examples/jsm/postprocessing/ShaderPass.js",
"file": "three_examples_jsm_postprocessing_ShaderPass__js.js",
"fileHash": "22bec74b",
"needsInterop": false
},
"three/examples/jsm/postprocessing/UnrealBloomPass.js": {
"src": "../../three/examples/jsm/postprocessing/UnrealBloomPass.js",
"file": "three_examples_jsm_postprocessing_UnrealBloomPass__js.js",
"fileHash": "7a96d06c",
"needsInterop": false
},
"three/examples/jsm/shaders/HorizontalBlurShader.js": {
"src": "../../three/examples/jsm/shaders/HorizontalBlurShader.js",
"file": "three_examples_jsm_shaders_HorizontalBlurShader__js.js",
"fileHash": "d8a23bdf",
"needsInterop": false
},
"three/examples/jsm/shaders/VerticalBlurShader.js": {
"src": "../../three/examples/jsm/shaders/VerticalBlurShader.js",
"file": "three_examples_jsm_shaders_VerticalBlurShader__js.js",
"fileHash": "fdb8cde0",
"needsInterop": false
},
"three/examples/jsm/postprocessing/BokehPass.js": {
"src": "../../three/examples/jsm/postprocessing/BokehPass.js",
"file": "three_examples_jsm_postprocessing_BokehPass__js.js",
"fileHash": "915505f2",
"needsInterop": false
},
"three/examples/jsm/postprocessing/SSAOPass.js": {
"src": "../../three/examples/jsm/postprocessing/SSAOPass.js",
"file": "three_examples_jsm_postprocessing_SSAOPass__js.js",
"fileHash": "3f06867f",
"needsInterop": false
}
},
"chunks": {
"chunk-D6CDVL7U": {
"file": "chunk-D6CDVL7U.js"
},
"chunk-OLTXGRDG": {
"file": "chunk-OLTXGRDG.js"
},
"chunk-JHQAMVLY": {
"file": "chunk-JHQAMVLY.js"
},
"chunk-IS2ZBFBB": {
"file": "chunk-IS2ZBFBB.js"
}

View File

@ -0,0 +1,53 @@
import {
FullScreenQuad,
Pass
} from "./chunk-JHQAMVLY.js";
import {
ShaderMaterial,
UniformsUtils
} from "./chunk-IS2ZBFBB.js";
// node_modules/three/examples/jsm/postprocessing/ShaderPass.js
var ShaderPass = class extends Pass {
constructor(shader, textureID) {
super();
this.textureID = textureID !== void 0 ? textureID : "tDiffuse";
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 !== void 0 ? shader.name : "unspecified",
defines: Object.assign({}, shader.defines),
uniforms: this.uniforms,
vertexShader: shader.vertexShader,
fragmentShader: shader.fragmentShader
});
}
this.fsQuad = new FullScreenQuad(this.material);
}
render(renderer, writeBuffer, readBuffer) {
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);
if (this.clear) renderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil);
this.fsQuad.render(renderer);
}
}
dispose() {
this.material.dispose();
this.fsQuad.dispose();
}
};
export {
ShaderPass
};
//# sourceMappingURL=chunk-D6CDVL7U.js.map

View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../three/examples/jsm/postprocessing/ShaderPass.js"],
"sourcesContent": ["import {\n\tShaderMaterial,\n\tUniformsUtils\n} from 'three';\nimport { Pass, FullScreenQuad } from './Pass.js';\n\nclass ShaderPass extends Pass {\n\n\tconstructor( shader, textureID ) {\n\n\t\tsuper();\n\n\t\tthis.textureID = ( textureID !== undefined ) ? textureID : 'tDiffuse';\n\n\t\tif ( shader instanceof ShaderMaterial ) {\n\n\t\t\tthis.uniforms = shader.uniforms;\n\n\t\t\tthis.material = shader;\n\n\t\t} else if ( shader ) {\n\n\t\t\tthis.uniforms = UniformsUtils.clone( shader.uniforms );\n\n\t\t\tthis.material = new ShaderMaterial( {\n\n\t\t\t\tname: ( shader.name !== undefined ) ? shader.name : 'unspecified',\n\t\t\t\tdefines: Object.assign( {}, shader.defines ),\n\t\t\t\tuniforms: this.uniforms,\n\t\t\t\tvertexShader: shader.vertexShader,\n\t\t\t\tfragmentShader: shader.fragmentShader\n\n\t\t\t} );\n\n\t\t}\n\n\t\tthis.fsQuad = new FullScreenQuad( this.material );\n\n\t}\n\n\trender( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {\n\n\t\tif ( this.uniforms[ this.textureID ] ) {\n\n\t\t\tthis.uniforms[ this.textureID ].value = readBuffer.texture;\n\n\t\t}\n\n\t\tthis.fsQuad.material = this.material;\n\n\t\tif ( this.renderToScreen ) {\n\n\t\t\trenderer.setRenderTarget( null );\n\t\t\tthis.fsQuad.render( renderer );\n\n\t\t} else {\n\n\t\t\trenderer.setRenderTarget( writeBuffer );\n\t\t\t// TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600\n\t\t\tif ( this.clear ) renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );\n\t\t\tthis.fsQuad.render( renderer );\n\n\t\t}\n\n\t}\n\n\tdispose() {\n\n\t\tthis.material.dispose();\n\n\t\tthis.fsQuad.dispose();\n\n\t}\n\n}\n\nexport { ShaderPass };\n"],
"mappings": ";;;;;;;;;;AAMA,IAAM,aAAN,cAAyB,KAAK;AAAA,EAE7B,YAAa,QAAQ,WAAY;AAEhC,UAAM;AAEN,SAAK,YAAc,cAAc,SAAc,YAAY;AAE3D,QAAK,kBAAkB,gBAAiB;AAEvC,WAAK,WAAW,OAAO;AAEvB,WAAK,WAAW;AAAA,IAEjB,WAAY,QAAS;AAEpB,WAAK,WAAW,cAAc,MAAO,OAAO,QAAS;AAErD,WAAK,WAAW,IAAI,eAAgB;AAAA,QAEnC,MAAQ,OAAO,SAAS,SAAc,OAAO,OAAO;AAAA,QACpD,SAAS,OAAO,OAAQ,CAAC,GAAG,OAAO,OAAQ;AAAA,QAC3C,UAAU,KAAK;AAAA,QACf,cAAc,OAAO;AAAA,QACrB,gBAAgB,OAAO;AAAA,MAExB,CAAE;AAAA,IAEH;AAEA,SAAK,SAAS,IAAI,eAAgB,KAAK,QAAS;AAAA,EAEjD;AAAA,EAEA,OAAQ,UAAU,aAAa,YAA0C;AAExE,QAAK,KAAK,SAAU,KAAK,SAAU,GAAI;AAEtC,WAAK,SAAU,KAAK,SAAU,EAAE,QAAQ,WAAW;AAAA,IAEpD;AAEA,SAAK,OAAO,WAAW,KAAK;AAE5B,QAAK,KAAK,gBAAiB;AAE1B,eAAS,gBAAiB,IAAK;AAC/B,WAAK,OAAO,OAAQ,QAAS;AAAA,IAE9B,OAAO;AAEN,eAAS,gBAAiB,WAAY;AAEtC,UAAK,KAAK,MAAQ,UAAS,MAAO,SAAS,gBAAgB,SAAS,gBAAgB,SAAS,gBAAiB;AAC9G,WAAK,OAAO,OAAQ,QAAS;AAAA,IAE9B;AAAA,EAED;AAAA,EAEA,UAAU;AAET,SAAK,SAAS,QAAQ;AAEtB,SAAK,OAAO,QAAQ;AAAA,EAErB;AAED;",
"names": []
}

View File

@ -0,0 +1,56 @@
import {
BufferGeometry,
Float32BufferAttribute,
Mesh,
OrthographicCamera
} from "./chunk-IS2ZBFBB.js";
// node_modules/three/examples/jsm/postprocessing/Pass.js
var Pass = class {
constructor() {
this.isPass = true;
this.enabled = true;
this.needsSwap = true;
this.clear = false;
this.renderToScreen = false;
}
setSize() {
}
render() {
console.error("THREE.Pass: .render() must be implemented in derived pass.");
}
dispose() {
}
};
var _camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
var FullscreenTriangleGeometry = class 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));
}
};
var _geometry = new FullscreenTriangleGeometry();
var FullScreenQuad = class {
constructor(material) {
this._mesh = new Mesh(_geometry, material);
}
dispose() {
this._mesh.geometry.dispose();
}
render(renderer) {
renderer.render(this._mesh, _camera);
}
get material() {
return this._mesh.material;
}
set material(value) {
this._mesh.material = value;
}
};
export {
Pass,
FullScreenQuad
};
//# sourceMappingURL=chunk-JHQAMVLY.js.map

View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../three/examples/jsm/postprocessing/Pass.js"],
"sourcesContent": ["import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\nclass Pass {\n\n\tconstructor() {\n\n\t\tthis.isPass = true;\n\n\t\t// if set to true, the pass is processed by the composer\n\t\tthis.enabled = true;\n\n\t\t// if set to true, the pass indicates to swap read and write buffer after rendering\n\t\tthis.needsSwap = true;\n\n\t\t// if set to true, the pass clears its buffer before rendering\n\t\tthis.clear = false;\n\n\t\t// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\tsetSize( /* width, height */ ) {}\n\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\nclass FullScreenQuad {\n\n\tconstructor( material ) {\n\n\t\tthis._mesh = new Mesh( _geometry, material );\n\n\t}\n\n\tdispose() {\n\n\t\tthis._mesh.geometry.dispose();\n\n\t}\n\n\trender( renderer ) {\n\n\t\trenderer.render( this._mesh, _camera );\n\n\t}\n\n\tget material() {\n\n\t\treturn this._mesh.material;\n\n\t}\n\n\tset material( value ) {\n\n\t\tthis._mesh.material = value;\n\n\t}\n\n}\n\nexport { Pass, FullScreenQuad };\n"],
"mappings": ";;;;;;;;AAOA,IAAM,OAAN,MAAW;AAAA,EAEV,cAAc;AAEb,SAAK,SAAS;AAGd,SAAK,UAAU;AAGf,SAAK,YAAY;AAGjB,SAAK,QAAQ;AAGb,SAAK,iBAAiB;AAAA,EAEvB;AAAA,EAEA,UAA+B;AAAA,EAAC;AAAA,EAEhC,SAAyE;AAExE,YAAQ,MAAO,4DAA6D;AAAA,EAE7E;AAAA,EAEA,UAAU;AAAA,EAAC;AAEZ;AAIA,IAAM,UAAU,IAAI,mBAAoB,IAAK,GAAG,GAAG,IAAK,GAAG,CAAE;AAI7D,IAAM,6BAAN,cAAyC,eAAe;AAAA,EAEvD,cAAc;AAEb,UAAM;AAEN,SAAK,aAAc,YAAY,IAAI,uBAAwB,CAAE,IAAK,GAAG,GAAG,IAAK,IAAK,GAAG,GAAG,IAAK,CAAE,GAAG,CAAE,CAAE;AACtG,SAAK,aAAc,MAAM,IAAI,uBAAwB,CAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAE,GAAG,CAAE,CAAE;AAAA,EAEhF;AAED;AAEA,IAAM,YAAY,IAAI,2BAA2B;AAEjD,IAAM,iBAAN,MAAqB;AAAA,EAEpB,YAAa,UAAW;AAEvB,SAAK,QAAQ,IAAI,KAAM,WAAW,QAAS;AAAA,EAE5C;AAAA,EAEA,UAAU;AAET,SAAK,MAAM,SAAS,QAAQ;AAAA,EAE7B;AAAA,EAEA,OAAQ,UAAW;AAElB,aAAS,OAAQ,KAAK,OAAO,OAAQ;AAAA,EAEtC;AAAA,EAEA,IAAI,WAAW;AAEd,WAAO,KAAK,MAAM;AAAA,EAEnB;AAAA,EAEA,IAAI,SAAU,OAAQ;AAErB,SAAK,MAAM,WAAW;AAAA,EAEvB;AAED;",
"names": []
}

View File

@ -0,0 +1,44 @@
// node_modules/three/examples/jsm/shaders/CopyShader.js
var CopyShader = {
name: "CopyShader",
uniforms: {
"tDiffuse": { value: null },
"opacity": { value: 1 }
},
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
};
//# sourceMappingURL=chunk-OLTXGRDG.js.map

View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../three/examples/jsm/shaders/CopyShader.js"],
"sourcesContent": ["/**\n * Full-screen textured quad shader\n */\n\nconst CopyShader = {\n\n\tname: 'CopyShader',\n\n\tuniforms: {\n\n\t\t'tDiffuse': { value: null },\n\t\t'opacity': { value: 1.0 }\n\n\t},\n\n\tvertexShader: /* glsl */`\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}`,\n\n\tfragmentShader: /* glsl */`\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}`\n\n};\n\nexport { CopyShader };\n"],
"mappings": ";AAIA,IAAM,aAAa;AAAA,EAElB,MAAM;AAAA,EAEN,UAAU;AAAA,IAET,YAAY,EAAE,OAAO,KAAK;AAAA,IAC1B,WAAW,EAAE,OAAO,EAAI;AAAA,EAEzB;AAAA,EAEA;AAAA;AAAA,IAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWxB;AAAA;AAAA,IAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgB3B;",
"names": []
}

View File

@ -0,0 +1,233 @@
import {
FullScreenQuad,
Pass
} from "./chunk-JHQAMVLY.js";
import {
Color,
HalfFloatType,
MeshDepthMaterial,
NearestFilter,
NoBlending,
RGBADepthPacking,
ShaderMaterial,
UniformsUtils,
WebGLRenderTarget
} from "./chunk-IS2ZBFBB.js";
// node_modules/three/examples/jsm/shaders/BokehShader.js
var BokehShader = {
name: "BokehShader",
defines: {
"DEPTH_PACKING": 1,
"PERSPECTIVE_CAMERA": 1
},
uniforms: {
"tColor": { value: null },
"tDepth": { value: null },
"focus": { value: 1 },
"aspect": { value: 1 },
"aperture": { value: 0.025 },
"maxblur": { value: 0.01 },
"nearClip": { value: 1 },
"farClip": { value: 1e3 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`
),
fragmentShader: (
/* glsl */
`
#include <common>
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 <packing>
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;
}`
)
};
// node_modules/three/examples/jsm/postprocessing/BokehPass.js
var BokehPass = class extends Pass {
constructor(scene, camera, params) {
super();
this.scene = scene;
this.camera = camera;
const focus = params.focus !== void 0 ? params.focus : 1;
const aperture = params.aperture !== void 0 ? params.aperture : 0.025;
const maxblur = params.maxblur !== void 0 ? params.maxblur : 1;
this.renderTargetDepth = new WebGLRenderTarget(1, 1, {
// will be resized later
minFilter: NearestFilter,
magFilter: NearestFilter,
type: HalfFloatType
});
this.renderTargetDepth.texture.name = "BokehPass.depth";
this.materialDepth = new MeshDepthMaterial();
this.materialDepth.depthPacking = RGBADepthPacking;
this.materialDepth.blending = NoBlending;
const bokehShader = BokehShader;
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;
this.materialBokeh = new ShaderMaterial({
defines: Object.assign({}, bokehShader.defines),
uniforms: bokehUniforms,
vertexShader: bokehShader.vertexShader,
fragmentShader: bokehShader.fragmentShader
});
this.uniforms = bokehUniforms;
this.fsQuad = new FullScreenQuad(this.materialBokeh);
this._oldClearColor = new Color();
}
render(renderer, writeBuffer, readBuffer) {
this.scene.overrideMaterial = this.materialDepth;
renderer.getClearColor(this._oldClearColor);
const oldClearAlpha = renderer.getClearAlpha();
const oldAutoClear = renderer.autoClear;
renderer.autoClear = false;
renderer.setClearColor(16777215);
renderer.setClearAlpha(1);
renderer.setRenderTarget(this.renderTargetDepth);
renderer.clear();
renderer.render(this.scene, this.camera);
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;
}
setSize(width, height) {
this.materialBokeh.uniforms["aspect"].value = width / height;
this.renderTargetDepth.setSize(width, height);
}
dispose() {
this.renderTargetDepth.dispose();
this.materialDepth.dispose();
this.materialBokeh.dispose();
this.fsQuad.dispose();
}
};
export {
BokehPass
};
//# sourceMappingURL=three_examples_jsm_postprocessing_BokehPass__js.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,199 @@
import {
ShaderPass
} from "./chunk-D6CDVL7U.js";
import {
CopyShader
} from "./chunk-OLTXGRDG.js";
import {
Pass
} from "./chunk-JHQAMVLY.js";
import {
Clock,
HalfFloatType,
NoBlending,
Vector2,
WebGLRenderTarget
} from "./chunk-IS2ZBFBB.js";
// node_modules/three/examples/jsm/postprocessing/MaskPass.js
var MaskPass = class extends Pass {
constructor(scene, camera) {
super();
this.scene = scene;
this.camera = camera;
this.clear = true;
this.needsSwap = false;
this.inverse = false;
}
render(renderer, writeBuffer, readBuffer) {
const context = renderer.getContext();
const state = renderer.state;
state.buffers.color.setMask(false);
state.buffers.depth.setMask(false);
state.buffers.color.setLocked(true);
state.buffers.depth.setLocked(true);
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, 4294967295);
state.buffers.stencil.setClear(clearValue);
state.buffers.stencil.setLocked(true);
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);
state.buffers.color.setLocked(false);
state.buffers.depth.setLocked(false);
state.buffers.color.setMask(true);
state.buffers.depth.setMask(true);
state.buffers.stencil.setLocked(false);
state.buffers.stencil.setFunc(context.EQUAL, 1, 4294967295);
state.buffers.stencil.setOp(context.KEEP, context.KEEP, context.KEEP);
state.buffers.stencil.setLocked(true);
}
};
var ClearMaskPass = class extends Pass {
constructor() {
super();
this.needsSwap = false;
}
render(renderer) {
renderer.state.buffers.stencil.setLocked(false);
renderer.state.buffers.stencil.setTest(false);
}
};
// node_modules/three/examples/jsm/postprocessing/EffectComposer.js
var EffectComposer = class {
constructor(renderer, renderTarget) {
this.renderer = renderer;
this._pixelRatio = renderer.getPixelRatio();
if (renderTarget === void 0) {
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";
this.writeBuffer = this.renderTarget1;
this.readBuffer = this.renderTarget2;
this.renderToScreen = true;
this.passes = [];
this.copyPass = new ShaderPass(CopyShader);
this.copyPass.material.blending = NoBlending;
this.clock = new Clock();
}
swapBuffers() {
const tmp = this.readBuffer;
this.readBuffer = this.writeBuffer;
this.writeBuffer = tmp;
}
addPass(pass) {
this.passes.push(pass);
pass.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
}
insertPass(pass, index) {
this.passes.splice(index, 0, pass);
pass.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
}
removePass(pass) {
const index = this.passes.indexOf(pass);
if (index !== -1) {
this.passes.splice(index, 1);
}
}
isLastEnabledPass(passIndex) {
for (let i = passIndex + 1; i < this.passes.length; i++) {
if (this.passes[i].enabled) {
return false;
}
}
return true;
}
render(deltaTime) {
if (deltaTime === void 0) {
deltaTime = this.clock.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;
stencil.setFunc(context.NOTEQUAL, 1, 4294967295);
this.copyPass.render(this.renderer, this.writeBuffer, this.readBuffer, deltaTime);
stencil.setFunc(context.EQUAL, 1, 4294967295);
}
this.swapBuffers();
}
if (MaskPass !== void 0) {
if (pass instanceof MaskPass) {
maskActive = true;
} else if (pass instanceof ClearMaskPass) {
maskActive = false;
}
}
}
this.renderer.setRenderTarget(currentRenderTarget);
}
reset(renderTarget) {
if (renderTarget === void 0) {
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;
}
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);
}
}
setPixelRatio(pixelRatio) {
this._pixelRatio = pixelRatio;
this.setSize(this._width, this._height);
}
dispose() {
this.renderTarget1.dispose();
this.renderTarget2.dispose();
this.copyPass.dispose();
}
};
export {
EffectComposer
};
//# sourceMappingURL=three_examples_jsm_postprocessing_EffectComposer__js.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,61 @@
import {
Pass
} from "./chunk-JHQAMVLY.js";
import {
Color
} from "./chunk-IS2ZBFBB.js";
// node_modules/three/examples/jsm/postprocessing/RenderPass.js
var RenderPass = class extends Pass {
constructor(scene, camera, overrideMaterial = null, clearColor = null, clearAlpha = null) {
super();
this.scene = scene;
this.camera = camera;
this.overrideMaterial = overrideMaterial;
this.clearColor = clearColor;
this.clearAlpha = clearAlpha;
this.clear = true;
this.clearDepth = false;
this.needsSwap = false;
this._oldClearColor = new Color();
}
render(renderer, writeBuffer, readBuffer) {
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) {
renderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil);
}
renderer.render(this.scene, this.camera);
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
};
//# sourceMappingURL=three_examples_jsm_postprocessing_RenderPass__js.js.map

View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../three/examples/jsm/postprocessing/RenderPass.js"],
"sourcesContent": ["import {\n\tColor\n} from 'three';\nimport { Pass } from './Pass.js';\n\nclass RenderPass extends Pass {\n\n\tconstructor( scene, camera, overrideMaterial = null, clearColor = null, clearAlpha = null ) {\n\n\t\tsuper();\n\n\t\tthis.scene = scene;\n\t\tthis.camera = camera;\n\n\t\tthis.overrideMaterial = overrideMaterial;\n\n\t\tthis.clearColor = clearColor;\n\t\tthis.clearAlpha = clearAlpha;\n\n\t\tthis.clear = true;\n\t\tthis.clearDepth = false;\n\t\tthis.needsSwap = false;\n\t\tthis._oldClearColor = new Color();\n\n\t}\n\n\trender( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {\n\n\t\tconst oldAutoClear = renderer.autoClear;\n\t\trenderer.autoClear = false;\n\n\t\tlet oldClearAlpha, oldOverrideMaterial;\n\n\t\tif ( this.overrideMaterial !== null ) {\n\n\t\t\toldOverrideMaterial = this.scene.overrideMaterial;\n\n\t\t\tthis.scene.overrideMaterial = this.overrideMaterial;\n\n\t\t}\n\n\t\tif ( this.clearColor !== null ) {\n\n\t\t\trenderer.getClearColor( this._oldClearColor );\n\t\t\trenderer.setClearColor( this.clearColor, renderer.getClearAlpha() );\n\n\t\t}\n\n\t\tif ( this.clearAlpha !== null ) {\n\n\t\t\toldClearAlpha = renderer.getClearAlpha();\n\t\t\trenderer.setClearAlpha( this.clearAlpha );\n\n\t\t}\n\n\t\tif ( this.clearDepth == true ) {\n\n\t\t\trenderer.clearDepth();\n\n\t\t}\n\n\t\trenderer.setRenderTarget( this.renderToScreen ? null : readBuffer );\n\n\t\tif ( this.clear === true ) {\n\n\t\t\t// TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600\n\t\t\trenderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );\n\n\t\t}\n\n\t\trenderer.render( this.scene, this.camera );\n\n\t\t// restore\n\n\t\tif ( this.clearColor !== null ) {\n\n\t\t\trenderer.setClearColor( this._oldClearColor );\n\n\t\t}\n\n\t\tif ( this.clearAlpha !== null ) {\n\n\t\t\trenderer.setClearAlpha( oldClearAlpha );\n\n\t\t}\n\n\t\tif ( this.overrideMaterial !== null ) {\n\n\t\t\tthis.scene.overrideMaterial = oldOverrideMaterial;\n\n\t\t}\n\n\t\trenderer.autoClear = oldAutoClear;\n\n\t}\n\n}\n\nexport { RenderPass };\n"],
"mappings": ";;;;;;;;AAKA,IAAM,aAAN,cAAyB,KAAK;AAAA,EAE7B,YAAa,OAAO,QAAQ,mBAAmB,MAAM,aAAa,MAAM,aAAa,MAAO;AAE3F,UAAM;AAEN,SAAK,QAAQ;AACb,SAAK,SAAS;AAEd,SAAK,mBAAmB;AAExB,SAAK,aAAa;AAClB,SAAK,aAAa;AAElB,SAAK,QAAQ;AACb,SAAK,aAAa;AAClB,SAAK,YAAY;AACjB,SAAK,iBAAiB,IAAI,MAAM;AAAA,EAEjC;AAAA,EAEA,OAAQ,UAAU,aAAa,YAA0C;AAExE,UAAM,eAAe,SAAS;AAC9B,aAAS,YAAY;AAErB,QAAI,eAAe;AAEnB,QAAK,KAAK,qBAAqB,MAAO;AAErC,4BAAsB,KAAK,MAAM;AAEjC,WAAK,MAAM,mBAAmB,KAAK;AAAA,IAEpC;AAEA,QAAK,KAAK,eAAe,MAAO;AAE/B,eAAS,cAAe,KAAK,cAAe;AAC5C,eAAS,cAAe,KAAK,YAAY,SAAS,cAAc,CAAE;AAAA,IAEnE;AAEA,QAAK,KAAK,eAAe,MAAO;AAE/B,sBAAgB,SAAS,cAAc;AACvC,eAAS,cAAe,KAAK,UAAW;AAAA,IAEzC;AAEA,QAAK,KAAK,cAAc,MAAO;AAE9B,eAAS,WAAW;AAAA,IAErB;AAEA,aAAS,gBAAiB,KAAK,iBAAiB,OAAO,UAAW;AAElE,QAAK,KAAK,UAAU,MAAO;AAG1B,eAAS,MAAO,SAAS,gBAAgB,SAAS,gBAAgB,SAAS,gBAAiB;AAAA,IAE7F;AAEA,aAAS,OAAQ,KAAK,OAAO,KAAK,MAAO;AAIzC,QAAK,KAAK,eAAe,MAAO;AAE/B,eAAS,cAAe,KAAK,cAAe;AAAA,IAE7C;AAEA,QAAK,KAAK,eAAe,MAAO;AAE/B,eAAS,cAAe,aAAc;AAAA,IAEvC;AAEA,QAAK,KAAK,qBAAqB,MAAO;AAErC,WAAK,MAAM,mBAAmB;AAAA,IAE/B;AAEA,aAAS,YAAY;AAAA,EAEtB;AAED;",
"names": []
}

View File

@ -0,0 +1,938 @@
import {
CopyShader
} from "./chunk-OLTXGRDG.js";
import {
FullScreenQuad,
Pass
} from "./chunk-JHQAMVLY.js";
import {
AddEquation,
Color,
CustomBlending,
DataTexture,
DepthStencilFormat,
DepthTexture,
DstAlphaFactor,
DstColorFactor,
FloatType,
HalfFloatType,
MathUtils,
Matrix4,
MeshNormalMaterial,
NearestFilter,
NoBlending,
RedFormat,
RepeatWrapping,
ShaderMaterial,
UniformsUtils,
UnsignedInt248Type,
Vector2,
Vector3,
WebGLRenderTarget,
ZeroFactor
} from "./chunk-IS2ZBFBB.js";
// node_modules/three/examples/jsm/math/SimplexNoise.js
var SimplexNoise = class {
constructor(r = Math) {
this.grad3 = [
[1, 1, 0],
[-1, 1, 0],
[1, -1, 0],
[-1, -1, 0],
[1, 0, 1],
[-1, 0, 1],
[1, 0, -1],
[-1, 0, -1],
[0, 1, 1],
[0, -1, 1],
[0, 1, -1],
[0, -1, -1]
];
this.grad4 = [
[0, 1, 1, 1],
[0, 1, 1, -1],
[0, 1, -1, 1],
[0, 1, -1, -1],
[0, -1, 1, 1],
[0, -1, 1, -1],
[0, -1, -1, 1],
[0, -1, -1, -1],
[1, 0, 1, 1],
[1, 0, 1, -1],
[1, 0, -1, 1],
[1, 0, -1, -1],
[-1, 0, 1, 1],
[-1, 0, 1, -1],
[-1, 0, -1, 1],
[-1, 0, -1, -1],
[1, 1, 0, 1],
[1, 1, 0, -1],
[1, -1, 0, 1],
[1, -1, 0, -1],
[-1, 1, 0, 1],
[-1, 1, 0, -1],
[-1, -1, 0, 1],
[-1, -1, 0, -1],
[1, 1, 1, 0],
[1, 1, -1, 0],
[1, -1, 1, 0],
[1, -1, -1, 0],
[-1, 1, 1, 0],
[-1, 1, -1, 0],
[-1, -1, 1, 0],
[-1, -1, -1, 0]
];
this.p = [];
for (let i = 0; i < 256; i++) {
this.p[i] = Math.floor(r.random() * 256);
}
this.perm = [];
for (let i = 0; i < 512; i++) {
this.perm[i] = this.p[i & 255];
}
this.simplex = [
[0, 1, 2, 3],
[0, 1, 3, 2],
[0, 0, 0, 0],
[0, 2, 3, 1],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[1, 2, 3, 0],
[0, 2, 1, 3],
[0, 0, 0, 0],
[0, 3, 1, 2],
[0, 3, 2, 1],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[1, 3, 2, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[1, 2, 0, 3],
[0, 0, 0, 0],
[1, 3, 0, 2],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[2, 3, 0, 1],
[2, 3, 1, 0],
[1, 0, 2, 3],
[1, 0, 3, 2],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[2, 0, 3, 1],
[0, 0, 0, 0],
[2, 1, 3, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[2, 0, 1, 3],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[3, 0, 1, 2],
[3, 0, 2, 1],
[0, 0, 0, 0],
[3, 1, 2, 0],
[2, 1, 0, 3],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[3, 1, 0, 2],
[0, 0, 0, 0],
[3, 2, 0, 1],
[3, 2, 1, 0]
];
}
dot(g, x, y) {
return g[0] * x + g[1] * y;
}
dot3(g, x, y, z) {
return g[0] * x + g[1] * y + g[2] * z;
}
dot4(g, x, y, z, w) {
return g[0] * x + g[1] * y + g[2] * z + g[3] * w;
}
noise(xin, yin) {
let n0;
let n1;
let n2;
const F2 = 0.5 * (Math.sqrt(3) - 1);
const s = (xin + yin) * F2;
const i = Math.floor(xin + s);
const j = Math.floor(yin + s);
const G2 = (3 - Math.sqrt(3)) / 6;
const t = (i + j) * G2;
const X0 = i - t;
const Y0 = j - t;
const x0 = xin - X0;
const y0 = yin - Y0;
let i1;
let j1;
if (x0 > y0) {
i1 = 1;
j1 = 0;
} else {
i1 = 0;
j1 = 1;
}
const x1 = x0 - i1 + G2;
const y1 = y0 - j1 + G2;
const x2 = x0 - 1 + 2 * G2;
const y2 = y0 - 1 + 2 * G2;
const ii = i & 255;
const jj = j & 255;
const gi0 = this.perm[ii + this.perm[jj]] % 12;
const gi1 = this.perm[ii + i1 + this.perm[jj + j1]] % 12;
const gi2 = this.perm[ii + 1 + this.perm[jj + 1]] % 12;
let t0 = 0.5 - x0 * x0 - y0 * y0;
if (t0 < 0) n0 = 0;
else {
t0 *= t0;
n0 = t0 * t0 * this.dot(this.grad3[gi0], x0, y0);
}
let t1 = 0.5 - x1 * x1 - y1 * y1;
if (t1 < 0) n1 = 0;
else {
t1 *= t1;
n1 = t1 * t1 * this.dot(this.grad3[gi1], x1, y1);
}
let t2 = 0.5 - x2 * x2 - y2 * y2;
if (t2 < 0) n2 = 0;
else {
t2 *= t2;
n2 = t2 * t2 * this.dot(this.grad3[gi2], x2, y2);
}
return 70 * (n0 + n1 + n2);
}
// 3D simplex noise
noise3d(xin, yin, zin) {
let n0;
let n1;
let n2;
let n3;
const F3 = 1 / 3;
const s = (xin + yin + zin) * F3;
const i = Math.floor(xin + s);
const j = Math.floor(yin + s);
const k = Math.floor(zin + s);
const G3 = 1 / 6;
const t = (i + j + k) * G3;
const X0 = i - t;
const Y0 = j - t;
const Z0 = k - t;
const x0 = xin - X0;
const y0 = yin - Y0;
const z0 = zin - Z0;
let i1;
let j1;
let k1;
let i2;
let j2;
let k2;
if (x0 >= y0) {
if (y0 >= z0) {
i1 = 1;
j1 = 0;
k1 = 0;
i2 = 1;
j2 = 1;
k2 = 0;
} else if (x0 >= z0) {
i1 = 1;
j1 = 0;
k1 = 0;
i2 = 1;
j2 = 0;
k2 = 1;
} else {
i1 = 0;
j1 = 0;
k1 = 1;
i2 = 1;
j2 = 0;
k2 = 1;
}
} else {
if (y0 < z0) {
i1 = 0;
j1 = 0;
k1 = 1;
i2 = 0;
j2 = 1;
k2 = 1;
} else if (x0 < z0) {
i1 = 0;
j1 = 1;
k1 = 0;
i2 = 0;
j2 = 1;
k2 = 1;
} else {
i1 = 0;
j1 = 1;
k1 = 0;
i2 = 1;
j2 = 1;
k2 = 0;
}
}
const x1 = x0 - i1 + G3;
const y1 = y0 - j1 + G3;
const z1 = z0 - k1 + G3;
const x2 = x0 - i2 + 2 * G3;
const y2 = y0 - j2 + 2 * G3;
const z2 = z0 - k2 + 2 * G3;
const x3 = x0 - 1 + 3 * G3;
const y3 = y0 - 1 + 3 * G3;
const z3 = z0 - 1 + 3 * G3;
const ii = i & 255;
const jj = j & 255;
const kk = k & 255;
const gi0 = this.perm[ii + this.perm[jj + this.perm[kk]]] % 12;
const gi1 = this.perm[ii + i1 + this.perm[jj + j1 + this.perm[kk + k1]]] % 12;
const gi2 = this.perm[ii + i2 + this.perm[jj + j2 + this.perm[kk + k2]]] % 12;
const gi3 = this.perm[ii + 1 + this.perm[jj + 1 + this.perm[kk + 1]]] % 12;
let t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
if (t0 < 0) n0 = 0;
else {
t0 *= t0;
n0 = t0 * t0 * this.dot3(this.grad3[gi0], x0, y0, z0);
}
let t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1;
if (t1 < 0) n1 = 0;
else {
t1 *= t1;
n1 = t1 * t1 * this.dot3(this.grad3[gi1], x1, y1, z1);
}
let t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2;
if (t2 < 0) n2 = 0;
else {
t2 *= t2;
n2 = t2 * t2 * this.dot3(this.grad3[gi2], x2, y2, z2);
}
let t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3;
if (t3 < 0) n3 = 0;
else {
t3 *= t3;
n3 = t3 * t3 * this.dot3(this.grad3[gi3], x3, y3, z3);
}
return 32 * (n0 + n1 + n2 + n3);
}
// 4D simplex noise
noise4d(x, y, z, w) {
const grad4 = this.grad4;
const simplex = this.simplex;
const perm = this.perm;
const F4 = (Math.sqrt(5) - 1) / 4;
const G4 = (5 - Math.sqrt(5)) / 20;
let n0;
let n1;
let n2;
let n3;
let n4;
const s = (x + y + z + w) * F4;
const i = Math.floor(x + s);
const j = Math.floor(y + s);
const k = Math.floor(z + s);
const l = Math.floor(w + s);
const t = (i + j + k + l) * G4;
const X0 = i - t;
const Y0 = j - t;
const Z0 = k - t;
const W0 = l - t;
const x0 = x - X0;
const y0 = y - Y0;
const z0 = z - Z0;
const w0 = w - W0;
const c1 = x0 > y0 ? 32 : 0;
const c2 = x0 > z0 ? 16 : 0;
const c3 = y0 > z0 ? 8 : 0;
const c4 = x0 > w0 ? 4 : 0;
const c5 = y0 > w0 ? 2 : 0;
const c6 = z0 > w0 ? 1 : 0;
const c = c1 + c2 + c3 + c4 + c5 + c6;
const i1 = simplex[c][0] >= 3 ? 1 : 0;
const j1 = simplex[c][1] >= 3 ? 1 : 0;
const k1 = simplex[c][2] >= 3 ? 1 : 0;
const l1 = simplex[c][3] >= 3 ? 1 : 0;
const i2 = simplex[c][0] >= 2 ? 1 : 0;
const j2 = simplex[c][1] >= 2 ? 1 : 0;
const k2 = simplex[c][2] >= 2 ? 1 : 0;
const l2 = simplex[c][3] >= 2 ? 1 : 0;
const i3 = simplex[c][0] >= 1 ? 1 : 0;
const j3 = simplex[c][1] >= 1 ? 1 : 0;
const k3 = simplex[c][2] >= 1 ? 1 : 0;
const l3 = simplex[c][3] >= 1 ? 1 : 0;
const x1 = x0 - i1 + G4;
const y1 = y0 - j1 + G4;
const z1 = z0 - k1 + G4;
const w1 = w0 - l1 + G4;
const x2 = x0 - i2 + 2 * G4;
const y2 = y0 - j2 + 2 * G4;
const z2 = z0 - k2 + 2 * G4;
const w2 = w0 - l2 + 2 * G4;
const x3 = x0 - i3 + 3 * G4;
const y3 = y0 - j3 + 3 * G4;
const z3 = z0 - k3 + 3 * G4;
const w3 = w0 - l3 + 3 * G4;
const x4 = x0 - 1 + 4 * G4;
const y4 = y0 - 1 + 4 * G4;
const z4 = z0 - 1 + 4 * G4;
const w4 = w0 - 1 + 4 * G4;
const ii = i & 255;
const jj = j & 255;
const kk = k & 255;
const ll = l & 255;
const gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32;
const gi1 = perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32;
const gi2 = perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32;
const gi3 = perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32;
const gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32;
let t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0;
if (t0 < 0) n0 = 0;
else {
t0 *= t0;
n0 = t0 * t0 * this.dot4(grad4[gi0], x0, y0, z0, w0);
}
let t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1;
if (t1 < 0) n1 = 0;
else {
t1 *= t1;
n1 = t1 * t1 * this.dot4(grad4[gi1], x1, y1, z1, w1);
}
let t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2;
if (t2 < 0) n2 = 0;
else {
t2 *= t2;
n2 = t2 * t2 * this.dot4(grad4[gi2], x2, y2, z2, w2);
}
let t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3;
if (t3 < 0) n3 = 0;
else {
t3 *= t3;
n3 = t3 * t3 * this.dot4(grad4[gi3], x3, y3, z3, w3);
}
let t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4;
if (t4 < 0) n4 = 0;
else {
t4 *= t4;
n4 = t4 * t4 * this.dot4(grad4[gi4], x4, y4, z4, w4);
}
return 27 * (n0 + n1 + n2 + n3 + n4);
}
};
// node_modules/three/examples/jsm/shaders/SSAOShader.js
var 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: 5e-3 },
"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 <packing>
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 == 1.0 ) {
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 );
}
}`
)
};
var 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 <packing>
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 );
}`
};
var 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 );
}`
};
// node_modules/three/examples/jsm/postprocessing/SSAOPass.js
var SSAOPass = class _SSAOPass extends Pass {
constructor(scene, camera, width, height, kernelSize = 32) {
super();
this.width = width !== void 0 ? width : 512;
this.height = height !== void 0 ? height : 512;
this.clear = true;
this.needsSwap = false;
this.camera = camera;
this.scene = scene;
this.kernelRadius = 8;
this.kernel = [];
this.noiseTexture = null;
this.output = 0;
this.minDistance = 5e-3;
this.maxDistance = 0.1;
this._visibilityCache = /* @__PURE__ */ new Map();
this.generateSampleKernel(kernelSize);
this.generateRandomKernelRotations();
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
});
this.ssaoRenderTarget = new WebGLRenderTarget(this.width, this.height, { type: HalfFloatType });
this.blurRenderTarget = this.ssaoRenderTarget.clone();
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);
this.normalMaterial = new MeshNormalMaterial();
this.normalMaterial.blending = NoBlending;
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);
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;
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.fsQuad = new FullScreenQuad(null);
this.originalClearColor = new Color();
}
dispose() {
this.normalRenderTarget.dispose();
this.ssaoRenderTarget.dispose();
this.blurRenderTarget.dispose();
this.normalMaterial.dispose();
this.blurMaterial.dispose();
this.copyMaterial.dispose();
this.depthRenderMaterial.dispose();
this.fsQuad.dispose();
}
render(renderer, writeBuffer, readBuffer) {
this.overrideVisibility();
this.renderOverride(renderer, this.normalMaterial, this.normalRenderTarget, 7829503, 1);
this.restoreVisibility();
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);
this.renderPass(renderer, this.blurMaterial, this.blurRenderTarget);
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.");
}
}
renderPass(renderer, passMaterial, renderTarget, clearColor, clearAlpha) {
renderer.getClearColor(this.originalClearColor);
const originalClearAlpha = renderer.getClearAlpha();
const originalAutoClear = renderer.autoClear;
renderer.setRenderTarget(renderTarget);
renderer.autoClear = false;
if (clearColor !== void 0 && clearColor !== null) {
renderer.setClearColor(clearColor);
renderer.setClearAlpha(clearAlpha || 0);
renderer.clear();
}
this.fsQuad.material = passMaterial;
this.fsQuad.render(renderer);
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 !== void 0 && clearColor !== null) {
renderer.setClearColor(clearColor);
renderer.setClearAlpha(clearAlpha || 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);
}
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);
}
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) {
cache.set(object, object.visible);
if (object.isPoints || object.isLine) object.visible = false;
});
}
restoreVisibility() {
const scene = this.scene;
const cache = this._visibilityCache;
scene.traverse(function(object) {
const visible = cache.get(object);
object.visible = visible;
});
cache.clear();
}
};
SSAOPass.OUTPUT = {
"Default": 0,
"SSAO": 1,
"Blur": 2,
"Depth": 3,
"Normal": 4
};
export {
SSAOPass
};
//# sourceMappingURL=three_examples_jsm_postprocessing_SSAOPass__js.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
import {
ShaderPass
} from "./chunk-D6CDVL7U.js";
import "./chunk-JHQAMVLY.js";
import "./chunk-IS2ZBFBB.js";
export {
ShaderPass
};
//# sourceMappingURL=three_examples_jsm_postprocessing_ShaderPass__js.js.map

View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}

View File

@ -0,0 +1,331 @@
import {
CopyShader
} from "./chunk-OLTXGRDG.js";
import {
FullScreenQuad,
Pass
} from "./chunk-JHQAMVLY.js";
import {
AdditiveBlending,
Color,
HalfFloatType,
MeshBasicMaterial,
ShaderMaterial,
UniformsUtils,
Vector2,
Vector3,
WebGLRenderTarget
} from "./chunk-IS2ZBFBB.js";
// node_modules/three/examples/jsm/shaders/LuminosityHighPassShader.js
var LuminosityHighPassShader = {
name: "LuminosityHighPassShader",
shaderID: "luminosityHighPass",
uniforms: {
"tDiffuse": { value: null },
"luminosityThreshold": { value: 1 },
"smoothWidth": { value: 1 },
"defaultColor": { value: new Color(0) },
"defaultOpacity": { 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 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 );
}`
)
};
// node_modules/three/examples/jsm/postprocessing/UnrealBloomPass.js
var UnrealBloomPass = class _UnrealBloomPass extends Pass {
constructor(resolution, strength, radius, threshold) {
super();
this.strength = strength !== void 0 ? strength : 1;
this.radius = radius;
this.threshold = threshold;
this.resolution = resolution !== void 0 ? new Vector2(resolution.x, resolution.y) : new Vector2(256, 256);
this.clearColor = new Color(0, 0, 0);
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 });
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 });
renderTargetHorizontal.texture.name = "UnrealBloomPass.h" + i;
renderTargetHorizontal.texture.generateMipmaps = false;
this.renderTargetsHorizontal.push(renderTargetHorizontal);
const renderTargetVertical = new WebGLRenderTarget(resx, resy, { type: HalfFloatType });
renderTargetVertical.texture.name = "UnrealBloomPass.v" + i;
renderTargetVertical.texture.generateMipmaps = false;
this.renderTargetsVertical.push(renderTargetVertical);
resx = Math.round(resx / 2);
resy = Math.round(resy / 2);
}
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
});
this.separableBlurMaterials = [];
const kernelSizeArray = [3, 5, 7, 9, 11];
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.getSeperableBlurMaterial(kernelSizeArray[i]));
this.separableBlurMaterials[i].uniforms["invSize"].value = new Vector2(1 / resx, 1 / resy);
resx = Math.round(resx / 2);
resy = Math.round(resy / 2);
}
this.compositeMaterial = this.getCompositeMaterial(this.nMips);
this.compositeMaterial.uniforms["blurTexture1"].value = this.renderTargetsVertical[0].texture;
this.compositeMaterial.uniforms["blurTexture2"].value = this.renderTargetsVertical[1].texture;
this.compositeMaterial.uniforms["blurTexture3"].value = this.renderTargetsVertical[2].texture;
this.compositeMaterial.uniforms["blurTexture4"].value = this.renderTargetsVertical[3].texture;
this.compositeMaterial.uniforms["blurTexture5"].value = this.renderTargetsVertical[4].texture;
this.compositeMaterial.uniforms["bloomStrength"].value = strength;
this.compositeMaterial.uniforms["bloomRadius"].value = 0.1;
const bloomFactors = [1, 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;
const copyShader = CopyShader;
this.copyUniforms = UniformsUtils.clone(copyShader.uniforms);
this.blendMaterial = new ShaderMaterial({
uniforms: this.copyUniforms,
vertexShader: copyShader.vertexShader,
fragmentShader: copyShader.fragmentShader,
blending: AdditiveBlending,
depthTest: false,
depthWrite: false,
transparent: true
});
this.enabled = true;
this.needsSwap = false;
this._oldClearColor = new Color();
this.oldClearAlpha = 1;
this.basic = new MeshBasicMaterial();
this.fsQuad = new FullScreenQuad(null);
}
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();
}
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);
}
}
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);
if (this.renderToScreen) {
this.fsQuad.material = this.basic;
this.basic.map = readBuffer.texture;
renderer.setRenderTarget(null);
renderer.clear();
this.fsQuad.render(renderer);
}
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);
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];
}
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);
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);
}
renderer.setClearColor(this._oldClearColor, this.oldClearAlpha);
renderer.autoClear = oldAutoClear;
}
getSeperableBlurMaterial(kernelRadius) {
const coefficients = [];
for (let i = 0; i < kernelRadius; i++) {
coefficients.push(0.39894 * Math.exp(-0.5 * i * i / (kernelRadius * kernelRadius)) / kernelRadius);
}
return new ShaderMaterial({
defines: {
"KERNEL_RADIUS": kernelRadius
},
uniforms: {
"colorTexture": { value: null },
"invSize": { value: new Vector2(0.5, 0.5) },
// inverse texture size
"direction": { value: new Vector2(0.5, 0.5) },
"gaussianCoefficients": { value: coefficients }
// precomputed Gaussian coefficients
},
vertexShader: `varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,
fragmentShader: `#include <common>
varying vec2 vUv;
uniform sampler2D colorTexture;
uniform vec2 invSize;
uniform vec2 direction;
uniform float gaussianCoefficients[KERNEL_RADIUS];
void main() {
float weightSum = gaussianCoefficients[0];
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
float x = float(i);
float w = gaussianCoefficients[i];
vec2 uvOffset = direction * invSize * x;
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
diffuseSum += (sample1 + sample2) * w;
weightSum += 2.0 * w;
}
gl_FragColor = vec4(diffuseSum/weightSum, 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 },
"bloomFactors": { value: null },
"bloomTintColors": { value: null },
"bloomRadius": { value: 0 }
},
vertexShader: `varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,
fragmentShader: `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() {
gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
}`
});
}
};
UnrealBloomPass.BlurDirectionX = new Vector2(1, 0);
UnrealBloomPass.BlurDirectionY = new Vector2(0, 1);
export {
UnrealBloomPass
};
//# sourceMappingURL=three_examples_jsm_postprocessing_UnrealBloomPass__js.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,52 @@
// node_modules/three/examples/jsm/shaders/HorizontalBlurShader.js
var HorizontalBlurShader = {
name: "HorizontalBlurShader",
uniforms: {
"tDiffuse": { value: null },
"h": { value: 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 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
};
//# sourceMappingURL=three_examples_jsm_shaders_HorizontalBlurShader__js.js.map

View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../three/examples/jsm/shaders/HorizontalBlurShader.js"],
"sourcesContent": ["/**\n * Two pass Gaussian blur filter (horizontal and vertical blur shaders)\n * - see http://www.cake23.de/traveling-wavefronts-lit-up.html\n *\n * - 9 samples per pass\n * - standard deviation 2.7\n * - \"h\" and \"v\" parameters should be set to \"1 / width\" and \"1 / height\"\n */\n\nconst HorizontalBlurShader = {\n\n\tname: 'HorizontalBlurShader',\n\n\tuniforms: {\n\n\t\t'tDiffuse': { value: null },\n\t\t'h': { value: 1.0 / 512.0 }\n\n\t},\n\n\tvertexShader: /* glsl */`\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}`,\n\n\tfragmentShader: /* glsl */`\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float h;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 sum = vec4( 0.0 );\n\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}`\n\n};\n\nexport { HorizontalBlurShader };\n"],
"mappings": ";AASA,IAAM,uBAAuB;AAAA,EAE5B,MAAM;AAAA,EAEN,UAAU;AAAA,IAET,YAAY,EAAE,OAAO,KAAK;AAAA,IAC1B,KAAK,EAAE,OAAO,IAAM,IAAM;AAAA,EAE3B;AAAA,EAEA;AAAA;AAAA,IAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWxB;AAAA;AAAA,IAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyB3B;",
"names": []
}

View File

@ -0,0 +1,52 @@
// node_modules/three/examples/jsm/shaders/VerticalBlurShader.js
var VerticalBlurShader = {
name: "VerticalBlurShader",
uniforms: {
"tDiffuse": { value: null },
"v": { value: 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 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
};
//# sourceMappingURL=three_examples_jsm_shaders_VerticalBlurShader__js.js.map

View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../three/examples/jsm/shaders/VerticalBlurShader.js"],
"sourcesContent": ["/**\n * Two pass Gaussian blur filter (horizontal and vertical blur shaders)\n * - see http://www.cake23.de/traveling-wavefronts-lit-up.html\n *\n * - 9 samples per pass\n * - standard deviation 2.7\n * - \"h\" and \"v\" parameters should be set to \"1 / width\" and \"1 / height\"\n */\n\nconst VerticalBlurShader = {\n\n\tname: 'VerticalBlurShader',\n\n\tuniforms: {\n\n\t\t'tDiffuse': { value: null },\n\t\t'v': { value: 1.0 / 512.0 }\n\n\t},\n\n\tvertexShader: /* glsl */`\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}`,\n\n\tfragmentShader: /* glsl */`\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float v;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 sum = vec4( 0.0 );\n\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}`\n\n};\n\nexport { VerticalBlurShader };\n"],
"mappings": ";AASA,IAAM,qBAAqB;AAAA,EAE1B,MAAM;AAAA,EAEN,UAAU;AAAA,IAET,YAAY,EAAE,OAAO,KAAK;AAAA,IAC1B,KAAK,EAAE,OAAO,IAAM,IAAM;AAAA,EAE3B;AAAA,EAEA;AAAA;AAAA,IAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWxB;AAAA;AAAA,IAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyB3B;",
"names": []
}

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* home.css :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madegryc <madegryc@student.42.fr> +#+ +:+ +#+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/07 12:00:55 by edbernar #+# #+# */
/* Updated: 2024/08/23 18:32:53 by madegryc ### ########.fr */
/* Updated: 2024/08/24 02:10:59 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -65,6 +65,7 @@ body {
position: absolute;
inset-inline: 0;
top: 0;
z-index: 999;
}
#topButton{

View File

@ -1,32 +1,32 @@
{
"hash": "fba7eca6",
"configHash": "345fb419",
"hash": "aeb97021",
"configHash": "0b4c6e74",
"lockfileHash": "cd36b699",
"browserHash": "f41bc951",
"browserHash": "7e895c56",
"optimized": {
"stats.js": {
"src": "../../stats.js/build/stats.min.js",
"file": "stats__js.js",
"fileHash": "8ddcd2c8",
"needsInterop": true
},
"three": {
"src": "../../three/build/three.module.js",
"file": "three.js",
"fileHash": "bafac1ea",
"fileHash": "f7b14752",
"needsInterop": false
},
"three/addons/loaders/GLTFLoader.js": {
"src": "../../three/examples/jsm/loaders/GLTFLoader.js",
"file": "three_addons_loaders_GLTFLoader__js.js",
"fileHash": "31ea0df1",
"fileHash": "529e8aba",
"needsInterop": false
},
"three/examples/jsm/Addons.js": {
"src": "../../three/examples/jsm/Addons.js",
"file": "three_examples_jsm_Addons__js.js",
"fileHash": "43d0b53e",
"fileHash": "834ab11f",
"needsInterop": false
},
"stats.js": {
"src": "../../stats.js/build/stats.min.js",
"file": "stats__js.js",
"fileHash": "fb9a7c1e",
"needsInterop": true
}
},
"chunks": {