Browse Source

Examples: Postprocessing fullscreen triangle optimization (#21358)

* Examples: Postprocessing fullscreen triangle

* Examples: Postprocessing fullscreen triangle indent
Rémi Tran 4 years ago
parent
commit
f3fc055174

+ 5 - 1
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 ) {
 

+ 7 - 2
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 ) {
 

+ 7 - 2
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 ) {