From f3fc055174f638a1253c30456ac033d77837184d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Tran?= Date: Tue, 30 Mar 2021 23:04:57 +0200 Subject: [PATCH] Examples: Postprocessing fullscreen triangle optimization (#21358) * Examples: Postprocessing fullscreen triangle * Examples: Postprocessing fullscreen triangle indent --- examples/js/postprocessing/EffectComposer.js | 6 +++++- examples/jsm/postprocessing/EffectComposer.js | 9 +++++++-- examples/jsm/postprocessing/Pass.js | 9 +++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/examples/js/postprocessing/EffectComposer.js b/examples/js/postprocessing/EffectComposer.js index d958c68bbc..5c87f8f47a 100644 --- a/examples/js/postprocessing/EffectComposer.js +++ b/examples/js/postprocessing/EffectComposer.js @@ -261,7 +261,11 @@ Object.assign( THREE.Pass.prototype, { THREE.Pass.FullScreenQuad = ( function () { var camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); - var geometry = new THREE.PlaneGeometry( 2, 2 ); + var geometry = new THREE.BufferGeometry(); + const vertices = new Float32Array([-1, 3, 0, -1, -1, 0, 3, -1, 0]); + geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3)); + const uv = new Float32Array([0, 2, 0, 0, 2, 0]); + geometry.setAttribute("uv", new THREE.BufferAttribute(uv, 2)); var FullScreenQuad = function ( material ) { diff --git a/examples/jsm/postprocessing/EffectComposer.js b/examples/jsm/postprocessing/EffectComposer.js index 91f5067f94..d6e99814b9 100644 --- a/examples/jsm/postprocessing/EffectComposer.js +++ b/examples/jsm/postprocessing/EffectComposer.js @@ -3,7 +3,8 @@ import { LinearFilter, Mesh, OrthographicCamera, - PlaneGeometry, + BufferGeometry, + BufferAttribute, RGBAFormat, Vector2, WebGLRenderTarget @@ -276,7 +277,11 @@ Object.assign( Pass.prototype, { Pass.FullScreenQuad = ( function () { var camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); - var geometry = new PlaneGeometry( 2, 2 ); + var geometry = new BufferGeometry(); + const vertices = new Float32Array([-1, 3, 0, -1, -1, 0, 3, -1, 0]); + geometry.setAttribute("position", new BufferAttribute(vertices, 3)); + const uv = new Float32Array([0, 2, 0, 0, 2, 0]); + geometry.setAttribute("uv", new BufferAttribute(uv, 2)); var FullScreenQuad = function ( material ) { diff --git a/examples/jsm/postprocessing/Pass.js b/examples/jsm/postprocessing/Pass.js index af22741bec..0788da9092 100644 --- a/examples/jsm/postprocessing/Pass.js +++ b/examples/jsm/postprocessing/Pass.js @@ -1,6 +1,7 @@ import { OrthographicCamera, - PlaneGeometry, + BufferGeometry, + BufferAttribute, Mesh } from '../../../build/three.module.js'; @@ -41,7 +42,11 @@ Object.assign( Pass.prototype, { Pass.FullScreenQuad = ( function () { var camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); - var geometry = new PlaneGeometry( 2, 2 ); + var geometry = new BufferGeometry(); + const vertices = new Float32Array([-1, 3, 0, -1, -1, 0, 3, -1, 0]); + geometry.setAttribute("position", new BufferAttribute(vertices, 3)); + const uv = new Float32Array([0, 2, 0, 0, 2, 0]); + geometry.setAttribute("uv", new BufferAttribute(uv, 2)); var FullScreenQuad = function ( material ) { -- GitLab