227 lines
628 KiB
JavaScript
227 lines
628 KiB
JavaScript
|
|
/**
|
||
|
|
* @license
|
||
|
|
* Copyright 2010-2021 Three.js Authors
|
||
|
|
* SPDX-License-Identifier: MIT
|
||
|
|
*/
|
||
|
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).THREE={})}(this,(function(t){"use strict";const e="127",n=100,i=300,r=301,s=302,a=303,o=304,l=306,c=307,h=1e3,u=1001,d=1002,p=1003,f=1004,m=1005,g=1006,v=1007,y=1008,x=1009,_=1012,b=1014,w=1015,M=1016,S=1020,T=1022,E=1023,A=1026,L=1027,R=33776,C=33777,P=33778,D=33779,I=35840,N=35841,B=35842,O=35843,z=37492,F=37496,H=2300,U=2301,G=2302,k=2400,V=2401,W=2402,j=2500,q=2501,X=3e3,Y=3001,Z=3007,J=3002,Q=3004,K=3005,$=3006,tt=7680,et=35044,nt=35048,it="300 es";function rt(){}Object.assign(rt.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)},removeEventListener:function(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}},dispatchEvent:function(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e<i;e++)n[e].call(this,t);t.target=null}}});const st=[];for(let t=0;t<256;t++)st[t]=(t<16?"0":"")+t.toString(16);let at=1234567;const ot={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(st[255&t]+st[t>>8&255]+st[t>>16&255]+st[t>>24&255]+"-"+st[255&e]+st[e>>8&255]+"-"+st[e>>16&15|64]+st[e>>24&255]+"-"+st[63&n|128]+st[n>>8&255]+"-"+st[n>>16&255]+st[n>>24&255]+st[255&i]+st[i>>8&255]+st[i>>16&255]+st[i>>24&255]).toUpperCase()},clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:function(t,e,n){return(1-n)*t+n*e},damp:function(t,e,n,i){return ot.lerp(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(ot.euclideanModulo(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(at=t%2147483647),at=16807*at%2147483647,(at-1)/2147483646},degToRad:function(t){return t*ot.DEG2RAD},radToDeg:function(t){return t*ot.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((e+i)/2),h=a((e+i)/2),u=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),f=a((i-e)/2);switch(r){case"XYX":t.set(o*h,l*u,l*d,o*c);break;case"YZY":t.set(l*d,o*h,l*u,o*c);break;case"ZXZ":t.set(l*u,l*d,o*h,o*c);break;case"XZX":t.set(o*h,l*f,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*f,o*c);break;case"ZYZ":t.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class lt{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/* BASICS FOR POST PROCESSING */
|
||
|
|
THREE.CopyShader={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\n\tvUv = uv;\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#if __VERSION__ < 130\n#define TEXTURE2D texture2D\n#else\n#define TEXTURE2D texture\n#endif\nuniform float opacity;\nuniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texel = TEXTURE2D( tDiffuse, vUv );\n\tgl_FragColor = opacity * texel;\n}"};
|
||
|
|
THREE.EffectComposer=function(a,b){if(this.renderer=a,void 0===b){var c={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat},d=a.getSize(new THREE.Vector2);this._pixelRatio=a.getPixelRatio(),this._width=d.width,this._height=d.height,b=new THREE.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,c),b.texture.name="EffectComposer.rt1"}else this._pixelRatio=1,this._width=b.width,this._height=b.height;this.renderTarget1=b,this.renderTarget2=b.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===THREE.CopyShader&&console.error("THREE.EffectComposer relies on THREE.CopyShader"),void 0===THREE.ShaderPass&&console.error("THREE.EffectComposer relies on THREE.ShaderPass"),this.copyPass=new THREE.ShaderPass(THREE.CopyShader),this.clock=new THREE.Clock},Object.assign(THREE.EffectComposer.prototype,{swapBuffers:function(){var a=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=a},addPass:function(a){this.passes.push(a),a.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)},insertPass:function(a,b){this.passes.splice(b,0,a),a.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)},removePass:function(a){const b=this.passes.indexOf(a);-1!==b&&this.passes.splice(b,1)},isLastEnabledPass:function(a){for(var b=a+1;b<this.passes.length;b++)if(this.passes[b].enabled)return!1;return!0},render:function(a){a===void 0&&(a=this.clock.getDelta());var b,c,d=this.renderer.getRenderTarget(),e=!1,f=this.passes.length;for(c=0;c<f;c++)if(b=this.passes[c],!1!==b.enabled){if(b.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(c),b.render(this.renderer,this.writeBuffer,this.readBuffer,a,e),b.needsSwap){if(e){var g=this.renderer.getContext(),h=this.renderer.state.buffers.stencil;h.setFunc(g.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,a),h.setFunc(g.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==THREE.MaskPass&&(b instanceof THREE.MaskPass?e=!0:b instanceof THREE.ClearMaskPass&&(e=!1))}this.renderer.setRenderTarget(d)},reset:function(a){if(a===void 0){var b=this.renderer.getSize(new THREE.Vector2);this._pixelRatio=this.renderer.getPixelRatio(),this._width=b.width,this._height=b.height,a=this.renderTarget1.clone(),a.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=a,this.renderTarget2=a.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2},setSize:function(a,b){this._width=a,this._height=b;var c=this._width*this._pixelRatio,d=this._height*this._pixelRatio;this.renderTarget1.setSize(c,d),this.renderTarget2.setSize(c,d);for(var e=0;e<this.passes.length;e++)this.passes[e].setSize(c,d)},setPixelRatio:function(a){this._pixelRatio=a,this.setSize(this._width,this._height)}}),THREE.Pass=function(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1},Object.assign(THREE.Pass.prototype,{setSize:function(){},render:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}),THREE.Pass.FullScreenQuad=function(){var a=new THREE.OrthographicCamera(-1,1,1,-1,0,1),b=new THREE.BufferGeometry;b.setAttribute("position",new THREE.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),b.setAttribute("uv",new THREE.Float32BufferAttribute([0,2,0,0,2,0],2));var c=function(a){this._mesh=new THREE.Mesh(b,a)};return Object.defineProperty(c.prototype,"material",{get:function(){return this._mesh.material},set:function(a){this._mesh.material=a}}),Object.assign(c.prototype,{dispose:function(){this._mesh.geometry.dispose()},render:function(b){b.render(this._mesh,a)}}),c}();
|
||
|
|
THREE.RenderPass=function(a,b,c,d,e){THREE.Pass.call(this),this.scene=a,this.camera=b,this.overrideMaterial=c,this.clearColor=d,this.clearAlpha=e===void 0?0:e,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new THREE.Color},THREE.RenderPass.prototype=Object.assign(Object.create(THREE.Pass.prototype),{constructor:THREE.RenderPass,render:function(a,b,c){var d=a.autoClear;a.autoClear=!1;var e,f;this.overrideMaterial!==void 0&&(f=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(a.getClearColor(this._oldClearColor),e=a.getClearAlpha(),a.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&a.clearDepth(),a.setRenderTarget(this.renderToScreen?null:c),this.clear&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil),a.render(this.scene,this.camera),this.clearColor&&a.setClearColor(this._oldClearColor,e),this.overrideMaterial!==void 0&&(this.scene.overrideMaterial=f),a.autoClear=d}});
|
||
|
|
THREE.ShaderPass=function(a,b){THREE.Pass.call(this),this.textureID=b===void 0?"tDiffuse":b,a instanceof THREE.ShaderMaterial?(this.uniforms=a.uniforms,this.material=a):a&&(this.uniforms=THREE.UniformsUtils.clone(a.uniforms),this.material=new THREE.ShaderMaterial({defines:Object.assign({},a.defines),uniforms:this.uniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader})),this.fsQuad=new THREE.Pass.FullScreenQuad(this.material)},THREE.ShaderPass.prototype=Object.assign(Object.create(THREE.Pass.prototype),{constructor:THREE.ShaderPass,render:function(a,b,c){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=c.texture),this.fsQuad.material=this.material,this.renderToScreen?(a.setRenderTarget(null),this.fsQuad.render(a)):(a.setRenderTarget(b),this.clear&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil),this.fsQuad.render(a))}});
|
||
|
|
|
||
|
|
/* 3D BLUR */
|
||
|
|
THREE.BokehShader={defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:.01},nearClip:{value:1},farClip:{value:1e3}},vertexShader:"varying vec2 vUv;\nvoid main() {\n\tvUv = uv;\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#if __VERSION__ < 130\n#define TEXTURE2D texture2D\n#else\n#define TEXTURE2D texture\n#endif\n#include <common>\nvarying vec2 vUv;\nuniform sampler2D tColor;\nuniform sampler2D tDepth;\nuniform float maxblur;\nuniform float aperture;\nuniform float nearClip;\nuniform float farClip;\nuniform float focus;\nuniform float aspect;\n#include <packing>\nfloat getDepth( const in vec2 screenPosition ) {\n\t#if DEPTH_PACKING == 1\n\treturn unpackRGBAToDepth( TEXTURE2D( tDepth, screenPosition ) );\n\t#else\n\treturn TEXTURE2D( tDepth, screenPosition ).x;\n\t#endif\n}\nfloat getViewZ( const in float depth ) {\n\t#if PERSPECTIVE_CAMERA == 1\n\treturn perspectiveDepthToViewZ( depth, nearClip, farClip );\n\t#else\n\treturn orthographicDepthToViewZ( depth, nearClip, farClip );\n\t#endif\n}\nvoid main() {\n\tvec2 aspectcorrect = vec2( 1.0, aspect );\n\tfloat viewZ = getViewZ( getDepth( vUv ) );\n\tfloat factor = ( focus + viewZ );\n\tvec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );\n\tvec2 dofblur9 = dofblur * 0.9;\n\tvec2 dofblur7 = dofblur * 0.7;\n\tvec2 dofblur4 = dofblur * 0.4;\n\tvec4 col = vec4( 0.0 );\n\tcol += TEXTURE2D( tColor, vUv.xy );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );\n\tcol += TEXTURE2D( tColor, vUv.xy + ( ve
|
||
|
|
THREE.BokehPass = function(a, b, c) {
|
||
|
|
|
||
|
|
THREE.Pass.call(this), this.scene = a, this.camera = b;
|
||
|
|
var d = c.focus === void 0 ? 1 : c.focus,
|
||
|
|
e = c.aspect === void 0 ? b.aspect : c.aspect,
|
||
|
|
f = c.aperture === void 0 ? .025 : c.aperture,
|
||
|
|
g = c.maxblur === void 0 ? 1 : c.maxblur,
|
||
|
|
h = c.width || window.innerWidth || 1,
|
||
|
|
i = c.height || window.innerHeight || 1;
|
||
|
|
this.renderTargetDepth = new THREE.WebGLRenderTarget(h, i, {
|
||
|
|
minFilter: THREE.NearestFilter,
|
||
|
|
magFilter: THREE.NearestFilter
|
||
|
|
}),
|
||
|
|
this.renderTargetDepth.texture.name = "BokehPass.depth",
|
||
|
|
this.materialDepth = new THREE.MeshDepthMaterial,
|
||
|
|
this.materialDepth.depthPacking = THREE.RGBADepthPacking,
|
||
|
|
this.materialDepth.blending = THREE.NoBlending,
|
||
|
|
THREE.BokehShader === void 0 && console.error("THREE.BokehPass relies on THREE.BokehShader");
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
var j = THREE.BokehShader,
|
||
|
|
k = THREE.UniformsUtils.clone(j.uniforms);
|
||
|
|
k.tDepth.value = this.renderTargetDepth.texture,
|
||
|
|
k.focus.value = d,
|
||
|
|
k.aspect.value = e,
|
||
|
|
k.aperture.value = f,
|
||
|
|
k.maxblur.value = g,
|
||
|
|
k.nearClip.value = b.near,
|
||
|
|
k.farClip.value = b.far;
|
||
|
|
|
||
|
|
|
||
|
|
if (c.transparent) j.fragmentShader = j.fragmentShader.replace('#transparent', '');
|
||
|
|
else j.fragmentShader = j.fragmentShader.replace('#transparent', 'gl_FragColor.a = 1.0;');
|
||
|
|
|
||
|
|
this.materialBokeh = new THREE.ShaderMaterial({
|
||
|
|
defines: Object.assign({}, j.defines),
|
||
|
|
uniforms: k,
|
||
|
|
vertexShader: j.vertexShader,
|
||
|
|
fragmentShader: j.fragmentShader
|
||
|
|
}),
|
||
|
|
this.uniforms = k,
|
||
|
|
this.needsSwap = !1,
|
||
|
|
this.fsQuad = new THREE.Pass.FullScreenQuad(this.materialBokeh),
|
||
|
|
this._oldClearColor = new THREE.Color
|
||
|
|
}, THREE.BokehPass.prototype = Object.assign(Object.create(THREE.Pass.prototype), {
|
||
|
|
constructor: THREE.BokehPass,
|
||
|
|
render: function(a, b, c) {
|
||
|
|
this.scene.overrideMaterial = this.materialDepth, a.getClearColor(this._oldClearColor);
|
||
|
|
var d = a.getClearAlpha(),
|
||
|
|
e = a.autoClear;
|
||
|
|
a.autoClear = !1,
|
||
|
|
a.setClearColor(16777215),
|
||
|
|
a.setClearAlpha(1), a.setRenderTarget(this.renderTargetDepth),
|
||
|
|
a.clear(),
|
||
|
|
a.render(this.scene, this.camera),
|
||
|
|
this.uniforms.tColor.value = c.texture,
|
||
|
|
this.uniforms.nearClip.value = this.camera.near,
|
||
|
|
this.uniforms.farClip.value = this.camera.far,
|
||
|
|
this.renderToScreen ? (
|
||
|
|
a.setRenderTarget(null),
|
||
|
|
this.fsQuad.render(a))
|
||
|
|
:
|
||
|
|
(a.setRenderTarget(b), a.clear(), this.fsQuad.render(a)),
|
||
|
|
this.scene.overrideMaterial = null,
|
||
|
|
a.setClearColor(this._oldClearColor),
|
||
|
|
a.setClearAlpha(d), a.autoClear = e
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
/* FILM SHADER */
|
||
|
|
THREE.FilmShader={uniforms:{tDiffuse:{value:null},time:{value:0},nIntensity:{value:.5},sIntensity:{value:.05},sCount:{value:4096},grayscale:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#if __VERSION__ < 130\n#define TEXTURE2D texture2D\n#else\n#define TEXTURE2D texture\n#endif\n#include <common>","uniform float time;","uniform bool grayscale;","uniform float nIntensity;","uniform float sIntensity;","uniform float sCount;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","\tvec4 cTextureScreen = TEXTURE2D( tDiffuse, vUv );","\tfloat dx = rand( vUv + time );","\tvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );","\tvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );","\tcResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;","\tcResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );","\tif( grayscale ) {","\t\tcResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );","\t}","\tgl_FragColor = vec4( cResult, cTextureScreen.a );","}"].join("\n")},THREE.FilmPass=function(e,t,r,s){THREE.Pass.call(this),void 0===THREE.FilmShader&&console.error("THREE.FilmPass relies on THREE.FilmShader");var i=THREE.FilmShader;this.uniforms=THREE.UniformsUtils.clone(i.uniforms),this.material=new THREE.ShaderMaterial({uniforms:this.uniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader}),void 0!==s&&(this.uniforms.grayscale.value=s),void 0!==e&&(this.uniforms.nIntensity.value=e),void 0!==t&&(this.uniforms.sIntensity.value=t),void 0!==r&&(this.uniforms.sCount.value=r),this.fsQuad=new THREE.Pass.FullScreenQuad(this.material)},THREE.FilmPass.prototype=Object.assign(Object.create(THREE.Pass.prototype),{constructor:THREE.FilmPass,render:function(e,t,r,s){this.uniforms.tDiffuse.value=r.texture,this.uniforms.time.value+=s,this.renderToScreen?e.setRenderTarget(null):(e.setRenderTarget(t),this.clear&&e.clear()),this.fsQuad.render(e)}});
|
||
|
|
|
||
|
|
/* GLITCH */
|
||
|
|
THREE.DigitalGlitch={uniforms:{tDiffuse:{value:null},tDisp:{value:null},byp:{value:0},amount:{value:.08},angle:{value:.02},seed:{value:.02},seed_x:{value:.02},seed_y:{value:.02},distortion_x:{value:.5},distortion_y:{value:.6},col_s:{value:.05}},vertexShader:"varying vec2 vUv;\nvoid main() {\n\tvUv = uv;\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#if __VERSION__ < 130\n#define TEXTURE2D texture2D\n#else\n#define TEXTURE2D texture\n#endif\nuniform int byp;\nuniform sampler2D tDiffuse;\nuniform sampler2D tDisp;\nuniform float amount;\nuniform float angle;\nuniform float seed;\nuniform float seed_x;\nuniform float seed_y;\nuniform float distortion_x;\nuniform float distortion_y;\nuniform float col_s;\nvarying vec2 vUv;\nfloat rand(vec2 co){\n\treturn fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\nvoid main() {\n\tif(byp<1) {\n\t\tvec2 p = vUv;\n\t\tfloat xs = floor(gl_FragCoord.x / 0.5);\n\t\tfloat ys = floor(gl_FragCoord.y / 0.5);\n\t\tvec4 normal = texture2D (tDisp, p*seed*seed);\n\t\tif(p.y<distortion_x+col_s && p.y>distortion_x-col_s*seed) {\n\t\t\tif(seed_x>0.){\n\t\t\t\tp.y = 1. - (p.y + distortion_y);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tp.y = distortion_y;\n\t\t\t}\n\t\t}\n\t\tif(p.x<distortion_y+col_s && p.x>distortion_y-col_s*seed) {\n\t\t\tif(seed_y>0.){\n\t\t\t\tp.x=distortion_x;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tp.x = 1. - (p.x + distortion_x);\n\t\t\t}\n\t\t}\n\t\tp.x+=normal.x*seed_x*(seed/5.);\n\t\tp.y+=normal.y*seed_y*(seed/5.);\n\t\tvec2 offset = amount * vec2( cos(angle), sin(angle));\n\t\tvec4 cr = TEXTURE2D(tDiffuse, p + offset);\n\t\tvec4 cga = TEXTURE2D(tDiffuse, p);\n\t\tvec4 cb = TEXTURE2D(tDiffuse, p - offset);\n\t\tgl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);\n\t\tvec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);\n\t\tgl_FragColor = gl_FragColor+ snow;\n\t}\n\telse {\n\t\tgl_FragColor=texture2D (tDiffuse, vUv);\n\t}\n}"};
|
||
|
|
THREE.GlitchPass=function(t,e){THREE.Pass.call(this),void 0===THREE.DigitalGlitch&&console.error("THREE.GlitchPass relies on THREE.DigitalGlitch");var s=THREE.DigitalGlitch;this.uniforms=THREE.UniformsUtils.clone(s.uniforms),"object"==typeof t&&(e={...t},t=64),"object"!=typeof t&&null!=t||(t=64),this.uniforms.tDisp.value=this.generateHeightmap(t),this.uniforms.damount=90,this.uniforms.dseed=.3,this.uniforms.drepeat=5,this.uniforms.dlen=120,e&&(e.damount&&(this.uniforms.damount=e.damount),e.dseed&&(this.uniforms.dseed=e.dseed),e.drepeat&&(this.uniforms.drepeat=e.drepeat),e.drepeat&&(this.uniforms.dlen=e.dlen)),this.material=new THREE.ShaderMaterial({uniforms:this.uniforms,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader}),this.fsQuad=new THREE.Pass.FullScreenQuad(this.material),this.goWild=!1,this.curF=0,this.generateTrigger(this.uniforms.dlen)},THREE.GlitchPass.prototype=Object.assign(Object.create(THREE.Pass.prototype),{constructor:THREE.GlitchPass,render:function(t,e,s){this.uniforms.tDiffuse.value=s.texture,this.uniforms.seed.value=Math.random(),this.uniforms.byp.value=0,this.curF%this.randX<this.randX/this.uniforms.drepeat?(this.uniforms.amount.value=Math.random()/this.uniforms.damount,this.uniforms.angle.value=THREE.MathUtils.randFloat(-Math.PI,Math.PI),this.uniforms.distortion_x.value=THREE.MathUtils.randFloat(0,1),this.uniforms.distortion_y.value=THREE.MathUtils.randFloat(0,1),this.uniforms.seed_x.value=THREE.MathUtils.randFloat(-this.uniforms.dseed,this.uniforms.dseed),this.uniforms.seed_y.value=THREE.MathUtils.randFloat(-this.uniforms.dseed,this.uniforms.dseed)):0==this.goWild&&(this.uniforms.byp.value=1),this.curF++,this.renderToScreen?t.setRenderTarget(null):(t.setRenderTarget(e),this.clear&&t.clear()),this.fsQuad.render(t)},generateTrigger:function(t){this.randX=THREE.MathUtils.randInt(t,2*t)},generateHeightmap:function(t){for(var e=new Float32Array(t*t*3),s=t*t,i=0;i<s;i++){var r=THREE.MathUtils.randFloat(0,1);e[3*i+0]=r,e[3*i+1]=r,e[3*i+2]=r}return new THREE.DataTexture(e,t,t,THREE.RGBFormat,THREE.FloatType)}});
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Copyright 2010-2021 ThemePunch Author
|
||
|
|
* License only for Usage within Slider Revolution
|
||
|
|
*/
|
||
|
|
/* GLITCH2*/
|
||
|
|
THREE.glitch2Shader = { uniforms: { 'tColor': { value: null }, 'progress': { value: 0. }, 'duration': { value: 1.0 }, 'width': { value: 0. }, 'height': { value: 0. } }, vertexShader: `varying vec2 vUv;void main() {vUv = uv;gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );}`, fragmentShader: `#if __VERSION__ < 130\n #define TEXTURE2D texture2D \n #else \n #define TEXTURE2D texture \n #endif \n varying vec2 vUv; uniform sampler2D tColor; uniform float progress; uniform float duration; uniform vec4 resolution; uniform float width; uniform float height; float random(vec2 c) { return fract(sin(dot(c.xy, vec2(12.9898, 78.233))) * 43758.5453); } vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 permute(vec4 x) { return mod289(((x * 34.0) + 1.0) * x); } vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; } float snoise3(vec3 v) { const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0); const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); vec3 i = floor(v + dot(v, C.yyy)); vec3 x0 = v - i + dot(i, C.xxx); vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1.0 - g; vec3 i1 = min(g.xyz, l.zxy); vec3 i2 = max(g.xyz, l.zxy); vec3 x1 = x0 - i1 + C.xxx; vec3 x2 = x0 - i2 + C.yyy; vec3 x3 = x0 - D.yyy; i = mod289(i); vec4 p = permute(permute(permute(i.z + vec4(0.0, i1.z, i2.z, 1.0)) + i.y + vec4(0.0, i1.y, i2.y, 1.0)) + i.x + vec4(0.0, i1.x, i2.x, 1.0)); float n_ = 0.142857142857; vec3 ns = n_ * D.wyz - D.xzx; vec4 j = p - 49.0 * floor(p * ns.z * ns.z); vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7.0 * x_); vec4 x = x_ * ns.x + ns.yyyy; vec4 y = y_ * ns.x + ns.yyyy; vec4 h = 1.0 - abs(x) - abs(y); vec4 b0 = vec4(x.xy, y.xy); vec4 b1 = vec4(x.zw, y.zw); vec4 s0 = floor(b0) * 2.0 + 1.0; vec4 s1 = floor(b1) * 2.0 + 1.0; vec4 sh = -step(h, vec4(0.0)); vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww; vec3 p0 = vec3(a0.xy, h.x); vec3 p1 = vec3(a0.zw, h.y); vec3 p2 = vec3(a1.xy, h.z); vec3 p3 = vec3(a1.zw, h.w); vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0); m = m * m; return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); } float CircularIn(float t) { return sqrt((2.0 - t) * t); } vec4 makeNoise(vec2 vUv, float progress, in sampler2D Texture, float interval, vec2 resolution) { precision highp float; float oProgress = progress; float strength = smoothstep(interval * 0.5, interval, interval - mod(progress, interval)); vec2 shake = vec2(strength * 8.0 + 0.5) * vec2(random(vec2(progress)) * 2.0 - 1.0, random(vec2(progress * 2.0)) * 2.0 - 1.0) / resolution.y; float y = vUv.y * resolution.y; float rgbWave = (snoise3(vec3(0.0, y * 0.01, progress * 400.0)) * (2.0 + strength * 32.0) * snoise3(vec3(0.0, y * 0.02, progress * 200.0)) * (1.0 + strength * 4.0) + step(0.9995, sin(y * 0.005 + progress * 1.6)) * 12.0 + step(0.9999, sin(y * 0.005 + progress * 2.0)) * -18.0) / resolution.x; float rgbDiff = (6.0 + sin(progress * 500.0 + vUv.y * 40.0) * (20.0 * strength + 1.0)) / resolution.x; float rgbUvX = vUv.x + rgbWave; float r = TEXTURE2D(Texture, vec2(rgbUvX + rgbDiff, vUv.y) + shake).r; float g = TEXTURE2D(Texture, vec2(rgbUvX, vUv.y) + shake).g; float b = TEXTURE2D(Texture, vec2(rgbUvX - rgbDiff, vUv.y) + shake).b; float whiteNoise = (random(vUv + mod(progress, 10.0)) * 2.0 - 1.0) * (0.15 + strength * 0.15); float bnTime = floor(progress * 20.0) * 200.0; float noiseX = step((snoise3(vec3(0.0, vUv.x * 3.0, bnTime)) + 1.0) / 2.0, 0.12 + .1); float noiseY = step((snoise3(vec3(0.0, vUv.y * 3.0, bnTime)) + 1.0) / 2.0, 0.12 + .1); float bnMask = noiseX * noiseY; float bnUvX = vUv.x + sin(bnTime) * 0.2 + rgbWave; float bnR = TEXTURE2D(Texture, vec2(bnUvX + rgbDiff, vUv.y)).r * bnMask; float bnG = TEXTURE2D(Texture, vec2(bnUvX, vUv.y)).g * bnMask; float bnB = TEXTURE2D(Texture, vec2(bnUvX - rgbDiff, vUv.y)).b * bnMask; vec4
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Copyright 2010-2021 ThemePunch Author
|
||
|
|
* License only for Usage within Slider Revolution
|
||
|
|
*/
|
||
|
|
/* 2D BLUR */
|
||
|
|
THREE.Blur2dShader = {uniforms: {'tColor': { value: null },'intensity': { value: 0 },'progress': { value: 0 },'left': {value: 1.0},'top': {value: 0.0}},vertexShader:`varying vec2 vUv;void main() {vUv = uv;gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );}`,fragmentShader: `#if __VERSION__ < 130\n#define TEXTURE2D texture2D\n#else\n#define TEXTURE2D texture\n#endif\nvarying vec2 vUv;uniform sampler2D tColor;uniform float progress;uniform float intensity;uniform float left;uniform float top;const int Samples = 64;vec4 DirectionalBlur(in vec2 UV, in vec2 Direction, in float Intensity, in sampler2D Texture) {vec4 Color = vec4(0.0); for (int i=1; i<=Samples/2; i++){Color += TEXTURE2D(Texture,UV+float(i)*Intensity/float(Samples/2)*Direction);Color += TEXTURE2D(Texture,UV-float(i)*Intensity/float(Samples/2)*Direction);}return Color/float(Samples);}void main() {vec2 uv = vUv;vec2 Direction = vec2(left, top);float Intensity = intensity;float m = progress;m = smoothstep(0.1,0.9,m);float mult = (m -0.5)*2.;Intensity *= (-(mult * mult) + 1.);Intensity *= 1.0 - step(1.0,m);vec4 Color = DirectionalBlur(uv,normalize(Direction), Intensity, tColor);gl_FragColor = Color;}`};
|
||
|
|
THREE.Blur2D = function (e, r, t, inlineEase) { THREE.Pass.call(this), this.scene = e, this.camera = r; var a = void 0 === t.left ? 0 : t.left, e = void 0 === t.top ? 0 : t.top; 0 === a && 0 === e && (a = 1); r = t.width || window.innerWidth || 1, t = t.height || window.innerHeight || 1; this.renderTargetDepth = new THREE.WebGLRenderTarget(r, t, { minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter }), this.renderTargetDepth.texture.name = "Blur2D.depth", void 0 === THREE.Blur2dShader && console.error("THREE.Blur2D relies on THREE.Blur2dShader"); r = THREE.Blur2dShader, t = THREE.UniformsUtils.clone(r.uniforms); if(inlineEase.name !== undefined && inlineEase.function !== undefined) { r.fragmentShader = r.fragmentShader.replace('/*easeName*/', inlineEase.name); r.fragmentShader = r.fragmentShader.replace('/*easeFunction*/', inlineEase.function); } t.intensity.value = .1, t.progress.value = 0, t.left.value = a, t.top.value = e, this.materialBlur2d = new THREE.ShaderMaterial({ uniforms: t, vertexShader: r.vertexShader, fragmentShader: r.fragmentShader }), this.uniforms = t, this.needsSwap = !1, this.fsQuad = new THREE.Pass.FullScreenQuad(this.materialBlur2d), this._oldClearColor = new THREE.Color }, THREE.Blur2D.prototype = Object.assign(Object.create(THREE.Pass.prototype), { constructor: THREE.Blur2D, render: function (e, r, t) { e.getClearColor(this._oldClearColor); var a = e.getClearAlpha(), l = e.autoClear; e.autoClear = !1, e.setClearColor(16777215), e.setClearAlpha(1), e.setRenderTarget(this.renderTargetDepth), e.clear(), e.render(this.scene, this.camera), this.uniforms.tColor.value = t.texture, this.renderToScreen ? e.setRenderTarget(null) : (e.setRenderTarget(r), e.clear()), this.fsQuad.render(e), this.scene.overrideMaterial = null, e.setClearColor(this._oldClearColor), e.setClearAlpha(a), e.autoClear = l } });
|
||
|
|
|
||
|
|
|
||
|
|
/*
|
||
|
|
UDATE POST PROCESSING LIBRARY IN RS
|
||
|
|
*/
|
||
|
|
(function(jQuery) {
|
||
|
|
|
||
|
|
jQuery.fn.revolution = jQuery.fn.revolution || {};
|
||
|
|
var _R = window._R_is_Editor ? RVS._R : jQuery.fn.revolution;
|
||
|
|
_R.postProcessing = _R.postProcessing || {};
|
||
|
|
|
||
|
|
|
||
|
|
/*3D BLUR*/
|
||
|
|
_R.postProcessing.d3 = {
|
||
|
|
init: function(renderer, scene, camera, opt) {
|
||
|
|
let PP = {};
|
||
|
|
PP.type = "d3";
|
||
|
|
PP.renderPass = new THREE.RenderPass( scene, camera );
|
||
|
|
PP.effectPass = new THREE.BokehPass( scene, camera, {
|
||
|
|
focus: opt.focus,
|
||
|
|
aperture: opt.aperture,
|
||
|
|
maxblur: opt.maxblur,
|
||
|
|
width: opt.width,
|
||
|
|
height: opt.height,
|
||
|
|
transparent: opt.transparent
|
||
|
|
});
|
||
|
|
PP.composer = new THREE.EffectComposer( renderer);
|
||
|
|
PP.composer.addPass( PP.renderPass );
|
||
|
|
PP.composer.addPass( PP.effectPass );
|
||
|
|
return PP;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/* FILM*/
|
||
|
|
_R.postProcessing.film = {
|
||
|
|
init: function(renderer, scene, camera, opt) {
|
||
|
|
let PP = {};
|
||
|
|
PP.type = "film";
|
||
|
|
PP.renderPass = new THREE.RenderPass( scene, camera );
|
||
|
|
PP.effectPass = new THREE.FilmPass( opt.noise , opt.scale , opt.size , opt.grayscale );
|
||
|
|
PP.effectPass.renderToScreen = true;
|
||
|
|
PP.composer = new THREE.EffectComposer( renderer);
|
||
|
|
PP.composer.addPass( PP.renderPass );
|
||
|
|
PP.composer.addPass( PP.effectPass );
|
||
|
|
return PP;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/* GLITCH */
|
||
|
|
_R.postProcessing.glitches = {
|
||
|
|
init: function(renderer, scene, camera,obj) {
|
||
|
|
let PP = {};
|
||
|
|
PP.type = "glitches";
|
||
|
|
PP.composer = new THREE.EffectComposer( renderer);
|
||
|
|
PP.renderPass = new THREE.RenderPass( scene, camera );
|
||
|
|
PP.effectPass = new THREE.GlitchPass({
|
||
|
|
damount:parseInt(obj.amount) || 90,
|
||
|
|
dseed:parseFloat(obj.seed) || 0.3,
|
||
|
|
drepeat:parseFloat(obj.repeat) || 5,
|
||
|
|
dlen:parseInt(obj.len) || 120
|
||
|
|
});
|
||
|
|
|
||
|
|
PP.composer.addPass( PP.renderPass );
|
||
|
|
PP.composer.addPass( PP.effectPass );
|
||
|
|
return PP;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/* GLITCH 2 */
|
||
|
|
_R.postProcessing.glitch2 = {
|
||
|
|
init: function(renderer, scene, camera, opt) {
|
||
|
|
let PP = {};
|
||
|
|
PP.type = "glitch2";
|
||
|
|
PP.renderPass = new THREE.RenderPass( scene, camera );
|
||
|
|
PP.effectPass = new THREE.glitch2( scene, camera, {
|
||
|
|
progress: opt.progress,
|
||
|
|
duration:opt.duration,
|
||
|
|
transparent: opt.transparent,
|
||
|
|
width: opt.width,
|
||
|
|
height: opt.height
|
||
|
|
});
|
||
|
|
PP.composer = new THREE.EffectComposer( renderer);
|
||
|
|
PP.composer.addPass( PP.renderPass );
|
||
|
|
PP.composer.addPass( PP.effectPass );
|
||
|
|
return PP;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/*2D BLUR */
|
||
|
|
_R.postProcessing.motion = {
|
||
|
|
init: function(renderer, scene, camera, opt, inlineEase) {
|
||
|
|
let PP = {};
|
||
|
|
PP.type = "motion";
|
||
|
|
PP.renderPass = new THREE.RenderPass( scene, camera );
|
||
|
|
PP.effectPass = new THREE.Blur2D( scene, camera, {
|
||
|
|
progress: opt.progress,
|
||
|
|
intensity: opt.intensity,
|
||
|
|
left: opt.left,
|
||
|
|
top: opt.top,
|
||
|
|
width: opt.width,
|
||
|
|
height: opt.height
|
||
|
|
}, inlineEase);
|
||
|
|
PP.composer = new THREE.EffectComposer( renderer);
|
||
|
|
PP.composer.addPass( PP.renderPass );
|
||
|
|
PP.composer.addPass( PP.effectPass );
|
||
|
|
|
||
|
|
return PP;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
})(jQuery);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
//Support Defer and Async and Footer Loads
|
||
|
|
window.RS_MODULES = window.RS_MODULES || {};
|
||
|
|
window.RS_MODULES.threejs = {loaded:true, version:'R128'};
|
||
|
|
if (window.RS_MODULES.checkMinimal) window.RS_MODULES.checkMinimal();
|