Unverified Commit d69c9f45 authored by Raoul v. R's avatar Raoul v. R Committed by GitHub
Browse files

Merge pull request #149 from vanruesc/dev

Version 6.8.0
parents 11ae0b82 7eeb87b2
Showing with 33996 additions and 29477 deletions
+33996 -29477
/**
* postprocessing v6.7.0 build Mon Sep 09 2019
* postprocessing v6.8.0 build Tue Oct 01 2019
* https://github.com/vanruesc/postprocessing
* Copyright 2019 Raoul van Rüschen, Zlib
*/
......@@ -3057,6 +3057,15 @@ class EffectPass extends Pass {
this.effects = effects.sort((a, b) => (b.attributes - a.attributes));
/**
* The current render size.
*
* @type {Vector2}
* @private
*/
this.size = new Vector2();
/**
* Indicates whether this pass should skip rendering.
*
......@@ -3115,8 +3124,6 @@ class EffectPass extends Pass {
this.maxTime = 1e3;
this.setFullscreenMaterial(this.createMaterial());
}
/**
......@@ -3296,14 +3303,11 @@ class EffectPass extends Pass {
recompile() {
let material = this.getFullscreenMaterial();
let width = 0, height = 0;
let depthTexture = null;
let depthPacking = 0;
if(material !== null) {
const resolution = material.uniforms.resolution.value;
width = resolution.x; height = resolution.y;
depthTexture = material.uniforms.depthBuffer.value;
depthPacking = material.depthPacking;
material.dispose();
......@@ -3314,7 +3318,7 @@ class EffectPass extends Pass {
}
material = this.createMaterial();
material.setSize(width, height);
material.setSize(this.size.x, this.size.y);
this.setFullscreenMaterial(material);
this.setDepthTexture(depthTexture, depthPacking);
......@@ -3398,7 +3402,15 @@ class EffectPass extends Pass {
setSize(width, height) {
this.getFullscreenMaterial().setSize(width, height);
const material = this.getFullscreenMaterial();
if(material !== null) {
material.setSize(width, height);
}
this.size.set(width, height);
for(const effect of this.effects) {
......@@ -3417,8 +3429,19 @@ class EffectPass extends Pass {
initialize(renderer, alpha) {
const capabilities = renderer.capabilities;
// Initialize effects before building the final shader.
for(const effect of this.effects) {
effect.initialize(renderer, alpha);
}
// Generate the fullscreen material.
this.setFullscreenMaterial(this.createMaterial());
this.getFullscreenMaterial().setSize(this.size.x, this.size.y);
// Compare required resources with capabilities.
const capabilities = renderer.capabilities;
let max = Math.min(capabilities.maxFragmentUniforms, capabilities.maxVertexUniforms);
if(this.uniforms > max) {
......@@ -3435,12 +3458,6 @@ class EffectPass extends Pass {
}
for(const effect of this.effects) {
effect.initialize(renderer, alpha);
}
}
/**
......@@ -4470,14 +4487,22 @@ class Selection extends Set {
/**
* Sets the render layer of selected objects.
*
* The current selection will be cleared beforehand.
* The current selection will be updated accordingly.
*
* @type {Number}
*/
set layer(value) {
this.clear();
const currentLayer = this.currentLayer;
for(const object of this) {
object.layers.disable(currentLayer);
object.layers.enable(value);
}
this.currentLayer = value;
}
......@@ -5115,7 +5140,7 @@ class ColorDepthEffect extends Effect {
}
var fragmentShader$f = "varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 color=inputColor;color.r=texture2D(inputBuffer,vUvR).r;color.b=texture2D(inputBuffer,vUvB).b;outputColor=color;}";
var fragmentShader$f = "varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 color=inputColor;\n#ifdef ALPHA\nvec2 ra=texture2D(inputBuffer,vUvR).ra;vec2 ba=texture2D(inputBuffer,vUvB).ba;color.r=ra.x;color.b=ba.x;color.a=max(max(ra.y,ba.y),inputColor.a);\n#else\ncolor.r=texture2D(inputBuffer,vUvR).r;color.b=texture2D(inputBuffer,vUvB).b;\n#endif\noutputColor=color;}";
var vertexShader$6 = "uniform vec2 offset;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vUvR=uv+offset;vUvB=uv-offset;}";
......@@ -5171,6 +5196,27 @@ class ChromaticAberrationEffect extends Effect {
}
/**
* Performs initialization tasks.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {Boolean} alpha - Whether the renderer uses the alpha channel or not.
*/
initialize(renderer, alpha) {
if(alpha) {
this.defines.set("ALPHA", "1");
} else {
this.defines.delete("ALPHA");
}
}
}
var fragmentShader$g = "void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){\n#ifdef INVERTED\nvec3 color=vec3(1.0-depth);\n#else\nvec3 color=vec3(depth);\n#endif\noutputColor=vec4(color,inputColor.a);}";
......
/**
* postprocessing v6.7.0 build Mon Sep 09 2019
* postprocessing v6.8.0 build Tue Oct 01 2019
* https://github.com/vanruesc/postprocessing
* Copyright 2019 Raoul van Rüschen, Zlib
*/
......@@ -1634,15 +1634,13 @@
_this11.effects = effects.sort(function (a, b) {
return b.attributes - a.attributes;
});
_this11.size = new three.Vector2();
_this11.skipRendering = false;
_this11.quantize = false;
_this11.uniforms = 0;
_this11.varyings = 0;
_this11.minTime = 1.0;
_this11.maxTime = 1e3;
_this11.setFullscreenMaterial(_this11.createMaterial());
return _this11;
}
......@@ -1802,15 +1800,10 @@
key: "recompile",
value: function recompile() {
var material = this.getFullscreenMaterial();
var width = 0,
height = 0;
var depthTexture = null;
var depthPacking = 0;
if (material !== null) {
var resolution = material.uniforms.resolution.value;
width = resolution.x;
height = resolution.y;
depthTexture = material.uniforms.depthBuffer.value;
depthPacking = material.depthPacking;
material.dispose();
......@@ -1819,7 +1812,7 @@
}
material = this.createMaterial();
material.setSize(width, height);
material.setSize(this.size.x, this.size.y);
this.setFullscreenMaterial(material);
this.setDepthTexture(depthTexture, depthPacking);
}
......@@ -1900,7 +1893,13 @@
}, {
key: "setSize",
value: function setSize(width, height) {
this.getFullscreenMaterial().setSize(width, height);
var material = this.getFullscreenMaterial();
if (material !== null) {
material.setSize(width, height);
}
this.size.set(width, height);
var _iteratorNormalCompletion11 = true;
var _didIteratorError11 = false;
var _iteratorError11 = undefined;
......@@ -1928,19 +1927,6 @@
}, {
key: "initialize",
value: function initialize(renderer, alpha) {
var capabilities = renderer.capabilities;
var max = Math.min(capabilities.maxFragmentUniforms, capabilities.maxVertexUniforms);
if (this.uniforms > max) {
console.warn("The current rendering context doesn't support more than " + max + " uniforms, but " + this.uniforms + " were defined");
}
max = capabilities.maxVaryings;
if (this.varyings > max) {
console.warn("The current rendering context doesn't support more than " + max + " varyings, but " + this.varyings + " were defined");
}
var _iteratorNormalCompletion12 = true;
var _didIteratorError12 = false;
var _iteratorError12 = undefined;
......@@ -1964,6 +1950,21 @@
}
}
}
this.setFullscreenMaterial(this.createMaterial());
this.getFullscreenMaterial().setSize(this.size.x, this.size.y);
var capabilities = renderer.capabilities;
var max = Math.min(capabilities.maxFragmentUniforms, capabilities.maxVertexUniforms);
if (this.uniforms > max) {
console.warn("The current rendering context doesn't support more than " + max + " uniforms, but " + this.uniforms + " were defined");
}
max = capabilities.maxVaryings;
if (this.varyings > max) {
console.warn("The current rendering context doesn't support more than " + max + " varyings, but " + this.varyings + " were defined");
}
}
}, {
key: "dispose",
......@@ -2748,7 +2749,32 @@
return this.currentLayer;
},
set: function set(value) {
this.clear();
var currentLayer = this.currentLayer;
var _iteratorNormalCompletion22 = true;
var _didIteratorError22 = false;
var _iteratorError22 = undefined;
try {
for (var _iterator22 = this[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
var object = _step22.value;
object.layers.disable(currentLayer);
object.layers.enable(value);
}
} catch (err) {
_didIteratorError22 = true;
_iteratorError22 = err;
} finally {
try {
if (!_iteratorNormalCompletion22 && _iterator22["return"] != null) {
_iterator22["return"]();
}
} finally {
if (_didIteratorError22) {
throw _iteratorError22;
}
}
}
this.currentLayer = value;
}
}]);
......@@ -3023,7 +3049,7 @@
return ColorDepthEffect;
}(Effect);
var fragmentShader$f = "varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 color=inputColor;color.r=texture2D(inputBuffer,vUvR).r;color.b=texture2D(inputBuffer,vUvB).b;outputColor=color;}";
var fragmentShader$f = "varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 color=inputColor;\n#ifdef ALPHA\nvec2 ra=texture2D(inputBuffer,vUvR).ra;vec2 ba=texture2D(inputBuffer,vUvB).ba;color.r=ra.x;color.b=ba.x;color.a=max(max(ra.y,ba.y),inputColor.a);\n#else\ncolor.r=texture2D(inputBuffer,vUvR).r;color.b=texture2D(inputBuffer,vUvB).b;\n#endif\noutputColor=color;}";
var vertexShader$6 = "uniform vec2 offset;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vUvR=uv+offset;vUvB=uv-offset;}";
var ChromaticAberrationEffect = function (_Effect6) {
......@@ -3047,6 +3073,15 @@
}
_createClass(ChromaticAberrationEffect, [{
key: "initialize",
value: function initialize(renderer, alpha) {
if (alpha) {
this.defines.set("ALPHA", "1");
} else {
this.defines["delete"]("ALPHA");
}
}
}, {
key: "offset",
get: function get() {
return this.uniforms.get("offset").value;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -334,7 +334,7 @@ export class SSAODemo extends PostProcessingDemo {
rings: 4,
distanceThreshold: 0.6,
distanceFalloff: 0.1,
rangeThreshold: 0.0015,
rangeThreshold: 0.005,
rangeFalloff: 0.01,
luminanceInfluence: 0.7,
radius: 18.25,
......
{
"name": "postprocessing",
"version": "6.7.0",
"version": "6.8.0",
"description": "A post processing library that provides the means to implement image filter effects for three.js.",
"homepage": "https://github.com/vanruesc/postprocessing",
"main": "build/postprocessing.js",
......@@ -61,13 +61,13 @@
"extends": "delta"
},
"peerDependencies": {
"three": ">= 0.102.0 < 0.109.0"
"three": ">= 0.102.0 < 0.110.0"
},
"devDependencies": {
"@babel/core": "7.x.x",
"@babel/preset-env": "7.x.x",
"ava": "2.x.x",
"cross-env": "5.x.x",
"cross-env": "6.x.x",
"dat.gui": "0.x.x",
"delta-controls": "2.x.x",
"esdoc": "1.x.x",
......@@ -83,7 +83,7 @@
"rollup-plugin-glsl": "1.x.x",
"rollup-plugin-node-resolve": "5.x.x",
"synthetic-event": "1.x.x",
"three": "0.108.x",
"three": "0.109.x",
"three-demo": "3.x.x",
"three-gltf-loader": "1.108.x"
}
......
......@@ -7,7 +7,7 @@
<link rel="stylesheet" href="styles.css">
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,es5,es6"></script>
<script src="https://cdn.jsdelivr.net/npm/proxy-polyfill@latest/proxy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.108.x/build/three.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.109.x/build/three.js"></script>
<script src="index.js"></script>
</head>
<body>
......
......@@ -7,7 +7,7 @@
<link rel="stylesheet" href="styles.css">
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,es5,es6"></script>
<script src="https://cdn.jsdelivr.net/npm/proxy-polyfill@latest/proxy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.108.x/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.109.x/build/three.min.js"></script>
<script src="index.min.js"></script>
</head>
<body>
......
......@@ -4838,15 +4838,13 @@
_this17.effects = effects.sort(function (a, b) {
return b.attributes - a.attributes;
});
_this17.size = new three.Vector2();
_this17.skipRendering = false;
_this17.quantize = false;
_this17.uniforms = 0;
_this17.varyings = 0;
_this17.minTime = 1.0;
_this17.maxTime = 1e3;
_this17.setFullscreenMaterial(_this17.createMaterial());
return _this17;
}
 
......@@ -5006,15 +5004,10 @@
key: "recompile",
value: function recompile() {
var material = this.getFullscreenMaterial();
var width = 0,
height = 0;
var depthTexture = null;
var depthPacking = 0;
 
if (material !== null) {
var resolution = material.uniforms.resolution.value;
width = resolution.x;
height = resolution.y;
depthTexture = material.uniforms.depthBuffer.value;
depthPacking = material.depthPacking;
material.dispose();
......@@ -5023,7 +5016,7 @@
}
 
material = this.createMaterial();
material.setSize(width, height);
material.setSize(this.size.x, this.size.y);
this.setFullscreenMaterial(material);
this.setDepthTexture(depthTexture, depthPacking);
}
......@@ -5104,7 +5097,13 @@
}, {
key: "setSize",
value: function setSize(width, height) {
this.getFullscreenMaterial().setSize(width, height);
var material = this.getFullscreenMaterial();
if (material !== null) {
material.setSize(width, height);
}
this.size.set(width, height);
var _iteratorNormalCompletion13 = true;
var _didIteratorError13 = false;
var _iteratorError13 = undefined;
......@@ -5132,19 +5131,6 @@
}, {
key: "initialize",
value: function initialize(renderer, alpha) {
var capabilities = renderer.capabilities;
var max = Math.min(capabilities.maxFragmentUniforms, capabilities.maxVertexUniforms);
if (this.uniforms > max) {
console.warn("The current rendering context doesn't support more than " + max + " uniforms, but " + this.uniforms + " were defined");
}
max = capabilities.maxVaryings;
if (this.varyings > max) {
console.warn("The current rendering context doesn't support more than " + max + " varyings, but " + this.varyings + " were defined");
}
var _iteratorNormalCompletion14 = true;
var _didIteratorError14 = false;
var _iteratorError14 = undefined;
......@@ -5168,6 +5154,21 @@
}
}
}
this.setFullscreenMaterial(this.createMaterial());
this.getFullscreenMaterial().setSize(this.size.x, this.size.y);
var capabilities = renderer.capabilities;
var max = Math.min(capabilities.maxFragmentUniforms, capabilities.maxVertexUniforms);
if (this.uniforms > max) {
console.warn("The current rendering context doesn't support more than " + max + " uniforms, but " + this.uniforms + " were defined");
}
max = capabilities.maxVaryings;
if (this.varyings > max) {
console.warn("The current rendering context doesn't support more than " + max + " varyings, but " + this.varyings + " were defined");
}
}
}, {
key: "dispose",
......@@ -5939,7 +5940,32 @@
return this.currentLayer;
},
set: function set(value) {
this.clear();
var currentLayer = this.currentLayer;
var _iteratorNormalCompletion24 = true;
var _didIteratorError24 = false;
var _iteratorError24 = undefined;
try {
for (var _iterator24 = this[Symbol.iterator](), _step24; !(_iteratorNormalCompletion24 = (_step24 = _iterator24.next()).done); _iteratorNormalCompletion24 = true) {
var object = _step24.value;
object.layers.disable(currentLayer);
object.layers.enable(value);
}
} catch (err) {
_didIteratorError24 = true;
_iteratorError24 = err;
} finally {
try {
if (!_iteratorNormalCompletion24 && _iterator24["return"] != null) {
_iterator24["return"]();
}
} finally {
if (_didIteratorError24) {
throw _iteratorError24;
}
}
}
this.currentLayer = value;
}
}]);
......@@ -6214,7 +6240,7 @@
return ColorDepthEffect;
}(Effect);
 
var fragmentShader$f = "varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 color=inputColor;color.r=texture2D(inputBuffer,vUvR).r;color.b=texture2D(inputBuffer,vUvB).b;outputColor=color;}";
var fragmentShader$f = "varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 color=inputColor;\n#ifdef ALPHA\nvec2 ra=texture2D(inputBuffer,vUvR).ra;vec2 ba=texture2D(inputBuffer,vUvB).ba;color.r=ra.x;color.b=ba.x;color.a=max(max(ra.y,ba.y),inputColor.a);\n#else\ncolor.r=texture2D(inputBuffer,vUvR).r;color.b=texture2D(inputBuffer,vUvB).b;\n#endif\noutputColor=color;}";
var vertexShader$6 = "uniform vec2 offset;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vUvR=uv+offset;vUvB=uv-offset;}";
 
var ChromaticAberrationEffect = function (_Effect6) {
......@@ -6238,6 +6264,15 @@
}
 
_createClass(ChromaticAberrationEffect, [{
key: "initialize",
value: function initialize(renderer, alpha) {
if (alpha) {
this.defines.set("ALPHA", "1");
} else {
this.defines["delete"]("ALPHA");
}
}
}, {
key: "offset",
get: function get() {
return this.uniforms.get("offset").value;
......@@ -15424,7 +15459,7 @@
rings: 4,
distanceThreshold: 0.6,
distanceFalloff: 0.1,
rangeThreshold: 0.0015,
rangeThreshold: 0.005,
rangeFalloff: 0.01,
luminanceInfluence: 0.7,
radius: 18.25,
......@@ -16150,27 +16185,27 @@
return new EffectPass(camera, effect);
});
passes[passes.length - 1].renderToScreen = true;
var _iteratorNormalCompletion24 = true;
var _didIteratorError24 = false;
var _iteratorError24 = undefined;
var _iteratorNormalCompletion25 = true;
var _didIteratorError25 = false;
var _iteratorError25 = undefined;
 
try {
for (var _iterator24 = passes[Symbol.iterator](), _step24; !(_iteratorNormalCompletion24 = (_step24 = _iterator24.next()).done); _iteratorNormalCompletion24 = true) {
var pass = _step24.value;
for (var _iterator25 = passes[Symbol.iterator](), _step25; !(_iteratorNormalCompletion25 = (_step25 = _iterator25.next()).done); _iteratorNormalCompletion25 = true) {
var pass = _step25.value;
pass.enabled = false;
composer.addPass(pass);
}
} catch (err) {
_didIteratorError24 = true;
_iteratorError24 = err;
_didIteratorError25 = true;
_iteratorError25 = err;
} finally {
try {
if (!_iteratorNormalCompletion24 && _iterator24["return"] != null) {
_iterator24["return"]();
if (!_iteratorNormalCompletion25 && _iterator25["return"] != null) {
_iterator25["return"]();
}
} finally {
if (_didIteratorError24) {
throw _iteratorError24;
if (_didIteratorError25) {
throw _iteratorError25;
}
}
}
......
This diff is collapsed.
......@@ -567,7 +567,7 @@ layers, please change it to a free layer before rendering!</p>
<div data-ice="description"><p>Sets the render layer of selected objects.</p>
<p>The current selection will be cleared beforehand.</p>
<p>The current selection will be updated accordingly.</p>
</div>
......@@ -607,7 +607,7 @@ layers, please change it to a free layer before rendering!</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber127">source</a></span></span>
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber135">source</a></span></span>
</span>
</h3>
......@@ -681,7 +681,7 @@ layers, please change it to a free layer before rendering!</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber71">source</a></span></span>
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber79">source</a></span></span>
</span>
</h3>
......@@ -738,7 +738,7 @@ layers, please change it to a free layer before rendering!</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber143">source</a></span></span>
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber151">source</a></span></span>
</span>
</h3>
......@@ -812,7 +812,7 @@ layers, please change it to a free layer before rendering!</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber114">source</a></span></span>
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber122">source</a></span></span>
</span>
</h3>
......@@ -886,7 +886,7 @@ layers, please change it to a free layer before rendering!</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber92">source</a></span></span>
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber100">source</a></span></span>
</span>
</h3>
......@@ -960,7 +960,7 @@ layers, please change it to a free layer before rendering!</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber164">source</a></span></span>
<span data-ice="source"><span><a href="file/src/core/Selection.js.html#lineNumber172">source</a></span></span>
</span>
</h3>
......
......@@ -240,7 +240,42 @@
</tbody>
</table>
</div>
<div data-ice="methodSummary"><h2>Method Summary</h2><table class="summary" data-ice="summary">
<thead><tr><td data-ice="title" colspan="3">Public Methods</td></tr></thead>
<tbody>
<tr data-ice="target">
<td>
<span class="access" data-ice="access">public</span>
<span class="override" data-ice="override"></span>
</td>
<td>
<div>
<p>
<span class="code" data-ice="name"><span><a href="class/src/effects/ChromaticAberrationEffect.js~ChromaticAberrationEffect.html#instance-method-initialize">initialize</a></span></span><span class="code" data-ice="signature">(renderer: <span>WebGLRenderer</span>, alpha: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></span>)</span>
</p>
</div>
<div>
<div data-ice="description"><p>Performs initialization tasks.</p>
</div>
</div>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</div>
<div class="inherited-summary" data-ice="inheritedSummary"><h2>Inherited Summary</h2><table class="summary" data-ice="summary">
<thead><tr><td data-ice="title" colspan="3"><span class="toggle closed"></span> From class <span><a href="class/src/effects/Effect.js~Effect.html">Effect</a></span></td></tr></thead>
......@@ -799,7 +834,77 @@ deletes them.</p>
</div>
</div>
<div data-ice="methodDetails"><h2 data-ice="title">Public Methods</h2>
<div class="detail" data-ice="detail">
<h3 data-ice="anchor" id="instance-method-initialize">
<span class="access" data-ice="access">public</span>
<span class="code" data-ice="name">initialize</span><span class="code" data-ice="signature">(renderer: <span>WebGLRenderer</span>, alpha: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></span>)</span>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/effects/ChromaticAberrationEffect.js.html#lineNumber67">source</a></span></span>
</span>
</h3>
<div data-ice="description"><p>Performs initialization tasks.</p>
</div>
<div data-ice="override"><h4>Override:</h4><span><a href="class/src/effects/Effect.js~Effect.html#instance-method-initialize">Effect#initialize</a></span></div>
<div data-ice="properties"><div data-ice="properties">
<h4 data-ice="title">Params:</h4>
<table class="params">
<thead>
<tr><td>Name</td><td>Type</td><td>Attribute</td><td>Description</td></tr>
</thead>
<tbody>
<tr data-ice="property" data-depth="0">
<td data-ice="name" class="code" data-depth="0">renderer</td>
<td data-ice="type" class="code"><span>WebGLRenderer</span></td>
<td data-ice="appendix"></td>
<td data-ice="description"><p>The renderer.</p>
</td>
</tr>
<tr data-ice="property" data-depth="0">
<td data-ice="name" class="code" data-depth="0">alpha</td>
<td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></span></td>
<td data-ice="appendix"></td>
<td data-ice="description"><p>Whether the renderer uses the alpha channel or not.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
......
......@@ -99,13 +99,13 @@
</nav>
<div class="content" data-ice="content"><div class="header-notice">
<div data-ice="importPath" class="import-path"><pre class="prettyprint"><code data-ice="importPathCode">import {EffectPass} from &apos;<span><a href="file/src/passes/EffectPass.js.html#lineNumber209">postprocessing/src/passes/EffectPass.js</a></span>&apos;</code></pre></div>
<div data-ice="importPath" class="import-path"><pre class="prettyprint"><code data-ice="importPathCode">import {EffectPass} from &apos;<span><a href="file/src/passes/EffectPass.js.html#lineNumber210">postprocessing/src/passes/EffectPass.js</a></span>&apos;</code></pre></div>
<span data-ice="access">public</span>
<span data-ice="kind">class</span>
<span data-ice="source">| <span><a href="file/src/passes/EffectPass.js.html#lineNumber209">source</a></span></span>
<span data-ice="source">| <span><a href="file/src/passes/EffectPass.js.html#lineNumber210">source</a></span></span>
</div>
<div class="self-detail detail">
......@@ -1030,7 +1030,7 @@ initialized and every time its own size is updated.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber220">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber221">source</a></span></span>
</span>
</h3>
......@@ -1102,7 +1102,7 @@ initialized and every time its own size is updated.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber312">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber320">source</a></span></span>
</span>
</h3>
......@@ -1147,7 +1147,7 @@ initialized and every time its own size is updated.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber326">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber334">source</a></span></span>
</span>
</h3>
......@@ -1192,7 +1192,7 @@ initialized and every time its own size is updated.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber298">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber308">source</a></span></span>
</span>
</h3>
......@@ -1237,7 +1237,7 @@ initialized and every time its own size is updated.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber288">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber298">source</a></span></span>
</span>
</h3>
......@@ -1282,7 +1282,7 @@ initialized and every time its own size is updated.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber429">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber437">source</a></span></span>
</span>
</h3>
......@@ -1330,7 +1330,7 @@ preceding <span><a href="class/src/passes/RenderPass.js~RenderPass.html">RenderP
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber453">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber461">source</a></span></span>
</span>
</h3>
......@@ -1381,7 +1381,7 @@ the screen. Otherwise, the contents of the input buffer will be lost.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber634">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber652">source</a></span></span>
</span>
</h3>
......@@ -1426,7 +1426,7 @@ the screen. Otherwise, the contents of the input buffer will be lost.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber511">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber516">source</a></span></span>
</span>
</h3>
......@@ -1483,7 +1483,7 @@ the screen. Otherwise, the contents of the input buffer will be lost.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber600">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber613">source</a></span></span>
</span>
</h3>
......@@ -1551,7 +1551,7 @@ the screen. Otherwise, the contents of the input buffer will be lost.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber478">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber486">source</a></span></span>
</span>
</h3>
......@@ -1596,7 +1596,7 @@ the screen. Otherwise, the contents of the input buffer will be lost.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber552">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber557">source</a></span></span>
</span>
</h3>
......@@ -1685,7 +1685,7 @@ the screen. Otherwise, the contents of the input buffer will be lost.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber526">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber531">source</a></span></span>
</span>
</h3>
......@@ -1754,7 +1754,7 @@ the screen. Otherwise, the contents of the input buffer will be lost.</p>
<span class="right-info">
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber581">source</a></span></span>
<span data-ice="source"><span><a href="file/src/passes/EffectPass.js.html#lineNumber586">source</a></span></span>
</span>
</h3>
......
{
"coverage": "97.23%",
"expectCount": 578,
"actualCount": 562,
"coverage": "97.24%",
"expectCount": 580,
"actualCount": 564,
"files": {
"src/core/Disposable.js": {
"expectCount": 2,
......@@ -54,8 +54,8 @@
"undocumentLines": []
},
"src/effects/ChromaticAberrationEffect.js": {
"expectCount": 4,
"actualCount": 4,
"expectCount": 5,
"actualCount": 5,
"undocumentLines": []
},
"src/effects/ColorAverageEffect.js": {
......@@ -283,11 +283,11 @@
]
},
"src/passes/EffectPass.js": {
"expectCount": 25,
"actualCount": 23,
"expectCount": 26,
"actualCount": 24,
"undocumentLines": [
429,
453
437,
461
]
},
"src/passes/MaskPass.js": {
......
......@@ -151,14 +151,22 @@ export class Selection extends Set {
/**
* Sets the render layer of selected objects.
*
* The current selection will be cleared beforehand.
* The current selection will be updated accordingly.
*
* @type {Number}
*/
set layer(value) {
this.clear();
const currentLayer = this.currentLayer;
for(const object of this) {
object.layers.disable(currentLayer);
object.layers.enable(value);
}
this.currentLayer = value;
}
......
......@@ -158,6 +158,27 @@ export class ChromaticAberrationEffect extends Effect {
}
/**
* Performs initialization tasks.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {Boolean} alpha - Whether the renderer uses the alpha channel or not.
*/
initialize(renderer, alpha) {
if(alpha) {
this.defines.set(&quot;ALPHA&quot;, &quot;1&quot;);
} else {
this.defines.delete(&quot;ALPHA&quot;);
}
}
}
</code></pre>
......
......@@ -99,7 +99,8 @@
</nav>
<div class="content" data-ice="content"><h1 data-ice="title">src/passes/EffectPass.js</h1>
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import { BlendFunction } from &quot;../effects/blending&quot;;
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import { Vector2 } from &quot;three&quot;;
import { BlendFunction } from &quot;../effects/blending&quot;;
import { EffectAttribute } from &quot;../effects/Effect.js&quot;;
import { EffectMaterial, Section } from &quot;../materials&quot;;
import { Pass } from &quot;./Pass.js&quot;;
......@@ -340,6 +341,15 @@ export class EffectPass extends Pass {
this.effects = effects.sort((a, b) =&gt; (b.attributes - a.attributes));
/**
* The current render size.
*
* @type {Vector2}
* @private
*/
this.size = new Vector2();
/**
* Indicates whether this pass should skip rendering.
*
......@@ -398,8 +408,6 @@ export class EffectPass extends Pass {
this.maxTime = 1e3;
this.setFullscreenMaterial(this.createMaterial());
}
/**
......@@ -579,14 +587,11 @@ export class EffectPass extends Pass {
recompile() {
let material = this.getFullscreenMaterial();
let width = 0, height = 0;
let depthTexture = null;
let depthPacking = 0;
if(material !== null) {
const resolution = material.uniforms.resolution.value;
width = resolution.x; height = resolution.y;
depthTexture = material.uniforms.depthBuffer.value;
depthPacking = material.depthPacking;
material.dispose();
......@@ -597,7 +602,7 @@ export class EffectPass extends Pass {
}
material = this.createMaterial();
material.setSize(width, height);
material.setSize(this.size.x, this.size.y);
this.setFullscreenMaterial(material);
this.setDepthTexture(depthTexture, depthPacking);
......@@ -681,7 +686,15 @@ export class EffectPass extends Pass {
setSize(width, height) {
this.getFullscreenMaterial().setSize(width, height);
const material = this.getFullscreenMaterial();
if(material !== null) {
material.setSize(width, height);
}
this.size.set(width, height);
for(const effect of this.effects) {
......@@ -700,8 +713,19 @@ export class EffectPass extends Pass {
initialize(renderer, alpha) {
const capabilities = renderer.capabilities;
// Initialize effects before building the final shader.
for(const effect of this.effects) {
effect.initialize(renderer, alpha);
}
// Generate the fullscreen material.
this.setFullscreenMaterial(this.createMaterial());
this.getFullscreenMaterial().setSize(this.size.x, this.size.y);
// Compare required resources with capabilities.
const capabilities = renderer.capabilities;
let max = Math.min(capabilities.maxFragmentUniforms, capabilities.maxVertexUniforms);
if(this.uniforms &gt; max) {
......@@ -718,12 +742,6 @@ export class EffectPass extends Pass {
}
for(const effect of this.effects) {
effect.initialize(renderer, alpha);
}
}
/**
......
......@@ -103,7 +103,7 @@
<a href="https://david-dm.org/vanruesc/postprocessing?type=peer"><img src="https://david-dm.org/vanruesc/postprocessing/peer-status.svg" alt="Peer dependencies"></a>
<a href="https://www.jsdelivr.com/package/npm/postprocessing"><img src="https://badgen.net/jsdelivr/hits/npm/postprocessing" alt="CDN"></a></p>
<p>A post processing library that provides the means to implement image filter effects for <a href="https://threejs.org/">three.js</a>.</p>
<p><em><a href="https://vanruesc.github.io/postprocessing/public/demo">Extensive Demo</a>&#x2002;&#xB7;&#x2002;<a href="https://jsfiddle.net/vcjL62en/">Sandbox</a>&#x2002;&#xB7;&#x2002;<a href="https://vanruesc.github.io/postprocessing/public/docs">API Reference</a>&#x2002;&#xB7;&#x2002;<a href="https://github.com/vanruesc/postprocessing/wiki">Wiki</a></em></p>
<p><em><a href="https://vanruesc.github.io/postprocessing/public/demo">Extensive Demo</a>&#x2002;&#xB7;&#x2002;<a href="https://codesandbox.io/s/postprocessing-25rts">Sandbox</a>&#x2002;&#xB7;&#x2002;<a href="https://vanruesc.github.io/postprocessing/public/docs">API Reference</a>&#x2002;&#xB7;&#x2002;<a href="https://github.com/vanruesc/postprocessing/wiki">Wiki</a></em></p>
<h2 id="installation">Installation</h2><p>This library requires the peer dependency <a href="https://github.com/mrdoob/three.js/">three</a>.</p>
<pre><code class="lang-sh"><code class="source-code prettyprint">npm install three postprocessing</code>
</code></pre>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment