瀏覽代碼

Examples: Refactor webgl_simple_gi.

Mugen87 4 年之前
父節點
當前提交
68cb92fbbb
共有 1 個文件被更改,包括 12 次插入12 次删除
  1. 12 12
      examples/webgl_simple_gi.html

+ 12 - 12
examples/webgl_simple_gi.html

@@ -18,15 +18,19 @@
 
 
 			import { OrbitControls } from './jsm/controls/OrbitControls.js';
 			import { OrbitControls } from './jsm/controls/OrbitControls.js';
 
 
-			// HACK:
+			class GIMesh extends THREE.Mesh {
 
 
-			THREE.Mesh.prototype.clone = function () {
+				copy( source ) {
 
 
-				const newMaterial = ( this.material.isMaterial ) ? this.material.clone() : this.material.slice();
+					super.copy( source );
 
 
-				return new this.constructor( this.geometry.clone(), newMaterial ).copy( this );
+					this.geometry = source.geometry.clone();
 
 
-			};
+					return this;
+
+				}
+
+			}
 
 
 			//
 			//
 
 
@@ -41,11 +45,7 @@
 				let clone = scene.clone();
 				let clone = scene.clone();
 				clone.autoUpdate = false;
 				clone.autoUpdate = false;
 
 
-				const rt = new THREE.WebGLRenderTarget( SIZE, SIZE, {
-					wrapS: THREE.ClampToEdgeWrapping,
-					wrapT: THREE.ClampToEdgeWrapping,
-					depthBuffer: true
-				} );
+				const rt = new THREE.WebGLRenderTarget( SIZE, SIZE );
 
 
 				const normalMatrix = new THREE.Matrix3();
 				const normalMatrix = new THREE.Matrix3();
 
 
@@ -62,7 +62,7 @@
 
 
 					if ( bounces === 3 ) return;
 					if ( bounces === 3 ) return;
 
 
-					const object = scene.children[ 0 ];
+					const object = scene.children[ 0 ]; // torusKnot
 					const geometry = object.geometry;
 					const geometry = object.geometry;
 
 
 					const attributes = geometry.attributes;
 					const attributes = geometry.attributes;
@@ -160,7 +160,7 @@
 				const torusGeometry = new THREE.TorusKnotBufferGeometry( 0.75, 0.3, 128, 32, 1 );
 				const torusGeometry = new THREE.TorusKnotBufferGeometry( 0.75, 0.3, 128, 32, 1 );
 				const material = new THREE.MeshBasicMaterial( { vertexColors: true } );
 				const material = new THREE.MeshBasicMaterial( { vertexColors: true } );
 
 
-				const torusKnot = new THREE.Mesh( torusGeometry, material );
+				const torusKnot = new GIMesh( torusGeometry, material );
 				scene.add( torusKnot );
 				scene.add( torusKnot );
 
 
 				// room
 				// room