Ver Fonte

renamed to GLBufferAttribute, fixed lint errors

raub há 7 anos atrás
pai
commit
6e26560bf7

+ 2 - 2
examples/webgl_buffergeometry_points_externalbufferattribute.html → examples/webgl_buffergeometry_points_glbufferattribute.html

@@ -122,7 +122,7 @@
 				gl.bindBuffer(gl.ARRAY_BUFFER, rgb);
 				gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW);
 
-				var posAttr = new THREE.ExternalBufferAttribute( gl, pos, gl.FLOAT, 3, particles );
+				var posAttr = new THREE.GLBufferAttribute( gl, pos, gl.FLOAT, 3, particles );
 				geometry.addAttribute( 'position', posAttr );
 
 				setInterval(function () {
@@ -136,7 +136,7 @@
 					geometry.setDrawRange(0, drawCount);
 				}, 20);
 
-				geometry.addAttribute( 'color', new THREE.ExternalBufferAttribute( gl, rgb, gl.FLOAT, 3, particles ) );
+				geometry.addAttribute( 'color', new THREE.GLBufferAttribute( gl, rgb, gl.FLOAT, 3, particles ) );
 
 				geometry.computeBoundingSphere();
 

+ 1 - 1
src/Three.js

@@ -90,7 +90,7 @@ export { InterleavedBufferAttribute } from './core/InterleavedBufferAttribute.js
 export { InstancedInterleavedBuffer } from './core/InstancedInterleavedBuffer.js';
 export { InterleavedBuffer } from './core/InterleavedBuffer.js';
 export { InstancedBufferAttribute } from './core/InstancedBufferAttribute.js';
-export { ExternalBufferAttribute } from './core/ExternalBufferAttribute.js';
+export { GLBufferAttribute } from './core/GLBufferAttribute.js';
 export * from './core/BufferAttribute.js';
 export { Face3 } from './core/Face3.js';
 export { Object3D } from './core/Object3D.js';

+ 5 - 5
src/core/BufferGeometry.js

@@ -68,7 +68,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 
 	addAttribute: function ( name, attribute ) {
 
-		if ( ! (attribute && (attribute.isBufferAttribute || attribute.isInterleavedBufferAttribute || attribute.isExternalBufferAttribute) ) ) {
+		if ( ! (attribute && (attribute.isBufferAttribute || attribute.isInterleavedBufferAttribute || attribute.isGLBufferAttribute) ) ) {
 
 			console.warn( 'THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).' );
 
@@ -596,12 +596,12 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 
 		var position = this.attributes.position;
 
-		if ( position && position.isExternalBufferAttribute ) {
+		if ( position && position.isGLBufferAttribute ) {
 
 			this.boundingBox.set(
 				new Vector3( - Infinity, - Infinity, - Infinity ),
 				new Vector3( + Infinity, + Infinity, + Infinity )
-			)
+			);
 
 			return;
 
@@ -640,9 +640,9 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 
 			var position = this.attributes.position;
 
-			if ( position && position.isExternalBufferAttribute ) {
+			if ( position && position.isGLBufferAttribute ) {
 
-				this.boundingSphere.set(new Vector3(), Infinity)
+				this.boundingSphere.set( new Vector3(), Infinity );
 
 				return;
 

+ 0 - 93
src/core/ExternalBufferAttribute.js

@@ -1,93 +0,0 @@
-import { _Math } from '../math/Math.js';
-
-/**
- * @author raub / https://github.com/raub
- */
-
-
-function ExternalBufferAttribute( gl, buffer, type, itemSize, count ) {
-
-	this.sizes = [
-		[gl.FLOAT, 4],
-		[gl.UNSIGNED_SHORT, 2],
-		[gl.SHORT, 2],
-		[gl.UNSIGNED_INT, 4],
-		[gl.INT, 4],
-		[gl.BYTE, 1],
-		[gl.UNSIGNED_BYTE, 1],
-	].reduce(function (accum, current) {
-		accum[current[0]] = current[1];
-		return accum;
-	}, {});
-
-	if ( ! this.sizes[type] ) {
-		throw new TypeError( 'THREE.ExternalBufferAttribute: unsupported GL data type.' );
-	}
-
-	this.uuid = _Math.generateUUID();
-
-	this.buffer = buffer;
-	this.type = type;
-	this.itemSize = itemSize;
-	this.elementSize = this.sizes[type];
-	this.count = count;
-
-	this.version = 0;
-
-}
-
-Object.defineProperty( ExternalBufferAttribute.prototype, 'needsUpdate', {
-
-	set: function ( value ) {
-
-		if ( value === true ) this.version ++;
-
-	}
-
-} );
-
-Object.assign( ExternalBufferAttribute.prototype, {
-
-	isExternalBufferAttribute: true,
-
-	setBuffer: function ( buffer ) {
-
-		this.buffer = buffer;
-
-		return this;
-
-	},
-
-	setType: function ( type ) {
-
-		if ( ! sizes[type] ) {
-			throw new TypeError( 'THREE.ExternalBufferAttribute: unsupported GL data type.' );
-		}
-
-		this.type = type;
-		this.elementSize = this.sizes[type];
-
-		return this;
-
-	},
-
-	setItemSize: function ( itemSize ) {
-
-		this.itemSize = itemSize;
-
-		return this;
-
-	},
-
-	setCount: function ( count ) {
-
-		this.count = count;
-
-		return this;
-
-	},
-
-} );
-
-
-export { ExternalBufferAttribute };

+ 99 - 0
src/core/GLBufferAttribute.js

@@ -0,0 +1,99 @@
+import { _Math } from '../math/Math.js';
+
+/**
+ * @author raub / https://github.com/raub
+ */
+
+
+function GLBufferAttribute( gl, buffer, type, itemSize, count ) {
+
+	this.sizes = [
+		[ gl.FLOAT, 4 ],
+		[ gl.UNSIGNED_SHORT, 2 ],
+		[ gl.SHORT, 2 ],
+		[ gl.UNSIGNED_INT, 4 ],
+		[ gl.INT, 4 ],
+		[ gl.BYTE, 1 ],
+		[ gl.UNSIGNED_BYTE, 1 ],
+	].reduce( function ( accum, current ) {
+
+		accum[ current[ 0 ] ] = current[ 1 ];
+		return accum;
+
+	}, {} );
+
+	if ( ! this.sizes[ type ] ) {
+
+		throw new TypeError( 'THREE.GLBufferAttribute: unsupported GL data type.' );
+
+	}
+
+	this.uuid = _Math.generateUUID();
+
+	this.buffer = buffer;
+	this.type = type;
+	this.itemSize = itemSize;
+	this.elementSize = this.sizes[ type ];
+	this.count = count;
+
+	this.version = 0;
+
+}
+
+Object.defineProperty( GLBufferAttribute.prototype, 'needsUpdate', {
+
+	set: function ( value ) {
+
+		if ( value === true ) this.version ++;
+
+	}
+
+} );
+
+Object.assign( GLBufferAttribute.prototype, {
+
+	isGLBufferAttribute: true,
+
+	setBuffer: function ( buffer ) {
+
+		this.buffer = buffer;
+
+		return this;
+
+	},
+
+	setType: function ( type ) {
+
+		if ( ! this.sizes[ type ] ) {
+
+			throw new TypeError( 'THREE.GLBufferAttribute: unsupported GL data type.' );
+
+		}
+
+		this.type = type;
+		this.elementSize = this.sizes[ type ];
+
+		return this;
+
+	},
+
+	setItemSize: function ( itemSize ) {
+
+		this.itemSize = itemSize;
+
+		return this;
+
+	},
+
+	setCount: function ( count ) {
+
+		this.count = count;
+
+		return this;
+
+	},
+
+} );
+
+
+export { GLBufferAttribute };

+ 4 - 2
src/renderers/webgl/WebGLAttributes.js

@@ -123,12 +123,14 @@ function WebGLAttributes( gl ) {
 
 	function update( attribute, bufferType ) {
 
-		if (attribute.isExternalBufferAttribute) {
+		if ( attribute.isGLBufferAttribute ) {
 
 			var cached = buffers[ attribute.uuid ];
 
-			if (cached && cached.version >= attribute.version) {
+			if ( cached && cached.version >= attribute.version ) {
+
 				return;
+
 			}
 
 			buffers[ attribute.uuid ] = {