浏览代码

GLBufferAttribute: Fix buffer attribute update.

Mugen87 5 年之前
父节点
当前提交
9cbc221db7
共有 2 个文件被更改,包括 7 次插入7 次删除
  1. 7 5
      examples/webgl_buffergeometry_glbufferattribute.html
  2. 0 2
      src/renderers/webgl/WebGLBindingStates.js

+ 7 - 5
examples/webgl_buffergeometry_glbufferattribute.html

@@ -16,7 +16,7 @@
 			import * as THREE from '../build/three.module.js';
 			import * as THREE from '../build/three.module.js';
 
 
 			import Stats from './jsm/libs/stats.module.js';
 			import Stats from './jsm/libs/stats.module.js';
-			
+
 			var container, stats;
 			var container, stats;
 
 
 			var camera, scene, renderer;
 			var camera, scene, renderer;
@@ -98,13 +98,15 @@
 				gl.bindBuffer( gl.ARRAY_BUFFER, rgb );
 				gl.bindBuffer( gl.ARRAY_BUFFER, rgb );
 				gl.bufferData( gl.ARRAY_BUFFER, new Float32Array( colors ), gl.STATIC_DRAW );
 				gl.bufferData( gl.ARRAY_BUFFER, new Float32Array( colors ), gl.STATIC_DRAW );
 
 
-				var posAttr = new THREE.GLBufferAttribute( pos, gl.FLOAT, 3, 4, particles );
-				geometry.setAttribute( 'position', posAttr );
+				var posAttr1 = new THREE.GLBufferAttribute( pos, gl.FLOAT, 3, 4, particles );
+				var posAttr2 = new THREE.GLBufferAttribute( pos2, gl.FLOAT, 3, 4, particles );
+				geometry.setAttribute( 'position', posAttr1 );
 
 
 				setInterval( function () {
 				setInterval( function () {
 
 
-					posAttr.buffer = ( posAttr.buffer === pos ) ? pos2 : pos;
-					posAttr.needsUpdate = true;
+					var attr = geometry.getAttribute( 'position' );
+
+					geometry.setAttribute( 'position', ( attr === posAttr1 ) ? posAttr2 : posAttr1 );
 
 
 				}, 2000 );
 				}, 2000 );
 
 

+ 0 - 2
src/renderers/webgl/WebGLBindingStates.js

@@ -176,8 +176,6 @@
 			const cachedAttribute = cachedAttributes[ key ];
 			const cachedAttribute = cachedAttributes[ key ];
 			const geometryAttribute = geometryAttributes[ key ];
 			const geometryAttribute = geometryAttributes[ key ];
 
 
-			if ( geometryAttribute.isGLBufferAttribute ) return true;
-
 			if ( cachedAttribute === undefined ) return true;
 			if ( cachedAttribute === undefined ) return true;
 
 
 			if ( cachedAttribute.attribute !== geometryAttribute ) return true;
 			if ( cachedAttribute.attribute !== geometryAttribute ) return true;