2
0
Эх сурвалжийг харах

BufferAttribute: Deprecate .dynamic,introduce .usage

Mugen87 5 жил өмнө
parent
commit
de6472aa78

+ 9 - 13
docs/api/en/core/BufferAttribute.html

@@ -58,16 +58,6 @@
 		then this will count the number of such vectors stored.
 		then this will count the number of such vectors stored.
 		</p>
 		</p>
 
 
-		<h3>[property:Boolean dynamic]</h3>
-		<p>
-			Whether the buffer is dynamic or not. Default is *false*.<br />
-
-			If false, the GPU is informed that contents of the buffer are likely to be used often and not change often.
-			This corresponds to the  [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData gl.STATIC_DRAW] flag.<br />
-			if true, the GPU is informed that contents of the buffer are likely to be used often and change often.
-			This corresponds to the  [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData gl.DYNAMIC_DRAW] flag.
-		</p>
-
 		<h3>[property:Boolean isBufferAttribute]</h3>
 		<h3>[property:Boolean isBufferAttribute]</h3>
 		<p>
 		<p>
 			Used to check whether this or derived classes are BufferAttributes. Default is *true*.<br /><br />
 			Used to check whether this or derived classes are BufferAttributes. Default is *true*.<br /><br />
@@ -111,10 +101,16 @@
 			related to color).
 			related to color).
 		</p>
 		</p>
 
 
+		<h3>[property:Usage usage]</h3>
+		<p>
+			Defines the intended usage pattern of the data store for optimization purposes. Corresponds to the *usage* parameter of
+			[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData WebGLRenderingContext.bufferData]().
+			Default is *THREE.StaticDrawUsage*.
+		</p>
+
 		<h3>[property:Integer version]</h3>
 		<h3>[property:Integer version]</h3>
 		<p>A version number, incremented every time the [page:BufferAttribute.needsUpdate needsUpdate] property is set to true.</p>
 		<p>A version number, incremented every time the [page:BufferAttribute.needsUpdate needsUpdate] property is set to true.</p>
 
 
-
 		<h2>Methods</h2>
 		<h2>Methods</h2>
 
 
 		<h3>[method:BufferAttribute clone]() </h3>
 		<h3>[method:BufferAttribute clone]() </h3>
@@ -185,8 +181,8 @@
 		After setting the array, [page:BufferAttribute.needsUpdate needsUpdate] should be set to true.
 		After setting the array, [page:BufferAttribute.needsUpdate needsUpdate] should be set to true.
 		</p>
 		</p>
 
 
-		<h3>[method:BufferAttribute setDynamic] ( [param:Boolean value] ) </h3>
-		<p>Set [page:BufferAttribute.dynamic dynamic] to value.</p>
+		<h3>[method:BufferAttribute setUsage] ( [param:Usage value] ) </h3>
+		<p>Set [page:BufferAttribute.usage usage] to value.</p>
 
 
 		<h3>[method:BufferAttribute setX]( [param:Integer index], [param:Float x] ) </h3>
 		<h3>[method:BufferAttribute setX]( [param:Integer index], [param:Float x] ) </h3>
 		<p>Sets the x component of the vector at the given index.</p>
 		<p>Sets the x component of the vector at the given index.</p>

+ 12 - 13
docs/api/en/core/InterleavedBuffer.html

@@ -44,11 +44,6 @@
 		Gives the total number of elements in the array.
 		Gives the total number of elements in the array.
 		</p>
 		</p>
 
 
-		<h3>[property:Boolean dynamic]</h3>
-		<p>
-		Default is *false*.
-		</p>
-
 		<h3>[property:Object updateRange]</h3>
 		<h3>[property:Object updateRange]</h3>
 		<p>
 		<p>
 		Object containing offset and count.
 		Object containing offset and count.
@@ -79,17 +74,13 @@
 		Default is *false*. Setting this to true increments [page:InterleavedBuffer.version version].
 		Default is *false*. Setting this to true increments [page:InterleavedBuffer.version version].
 		</p>
 		</p>
 
 
-		<h2>Methods</h2>
-
-		<h3>[method:InterleavedBuffer setArray] ( [param:TypedArray array] ) </h3>
+		<h3>[property:Usage usage]</h3>
 		<p>
 		<p>
-		 array - must be  a Typed Array.
+			Defines the intended usage pattern of the data store for optimization purposes. Corresponds to the *usage* parameter of
+			[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData WebGLRenderingContext.bufferData]().
 		</p>
 		</p>
 
 
-		<h3>[method:InterleavedBuffer setDynamic] ( [param:Boolean value] ) </h3>
-		<p>
-			Set [page:InterleavedBuffer.dynamic dynamic] to value.
-		</p>
+		<h2>Methods</h2>
 
 
 		<h3>[method:InterleavedBuffer copy]( [param:InterleavedBuffer source] ) </h3>
 		<h3>[method:InterleavedBuffer copy]( [param:InterleavedBuffer source] ) </h3>
 		<p>
 		<p>
@@ -112,6 +103,14 @@
 			Creates a clone of this [name].
 			Creates a clone of this [name].
 		</p>
 		</p>
 
 
+		<h3>[method:InterleavedBuffer setArray] ( [param:TypedArray array] ) </h3>
+		<p>
+		 array - must be  a Typed Array.
+		</p>
+
+		<h3>[method:BufferAttribute setUsage] ( [param:Usage value] ) </h3>
+		<p>Set [page:BufferAttribute.usage usage] to value.</p>
+
 		<h2>Source</h2>
 		<h2>Source</h2>
 
 
 		<p>
 		<p>

+ 9 - 12
docs/api/zh/core/BufferAttribute.html

@@ -52,16 +52,6 @@
 			若缓存存储三元组(例如顶点位置、法向量、颜色值),则该值应等于队列中三元组的个数。
 			若缓存存储三元组(例如顶点位置、法向量、颜色值),则该值应等于队列中三元组的个数。
 		</p>
 		</p>
 
 
-		<h3>[property:Boolean dynamic]</h3>
-		<p>
-			不论缓存是否是动态的,默认值都将是 *false*<br />
-
-			如果该值为 false,即告知 GPU 缓存中的数据会经常使用但不经常变化。
-			该值与 [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData gl.STATIC_DRAW] 标志位相一致。<br />
-			如果该值为 true,即告知 GPU 缓存中的数据会经常使用且经常变化。
-			该值与 [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData gl.DYNAMIC_DRAW] 标志位相一致。
-		</p>
-
 		<h3>[property:Boolean isBufferAttribute]</h3>
 		<h3>[property:Boolean isBufferAttribute]</h3>
 		<p>
 		<p>
 			指示当前类或派生类是 BufferAttributes. 默认值为 *true*.<br /><br />
 			指示当前类或派生类是 BufferAttributes. 默认值为 *true*.<br /><br />
@@ -101,6 +91,13 @@
 			该值只可以被用于更新某些矢量数据(例如,颜色相关数据)。
 			该值只可以被用于更新某些矢量数据(例如,颜色相关数据)。
 		</p>
 		</p>
 
 
+		<h3>[property:Usage usage]</h3>
+		<p>
+			Defines the intended usage pattern of the data store for optimization purposes. Corresponds to the *usage* parameter of
+			[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData WebGLRenderingContext.bufferData]().
+			Default is *THREE.StaticDrawUsage*.
+		</p>
+
 		<h3>[property:Integer version]</h3>
 		<h3>[property:Integer version]</h3>
 		<p>版本号,当 [page:BufferAttribute.needsUpdate needsUpdate] 被设置为 true 时,该值会自增。</p>
 		<p>版本号,当 [page:BufferAttribute.needsUpdate needsUpdate] 被设置为 true 时,该值会自增。</p>
 
 
@@ -165,8 +162,8 @@
 		队列被复制后,[page:BufferAttribute.needsUpdate needsUpdate] 应当被设置为 true。
 		队列被复制后,[page:BufferAttribute.needsUpdate needsUpdate] 应当被设置为 true。
 		</p>
 		</p>
 
 
-		<h3>[method:BufferAttribute setDynamic] ( [param:Boolean value] ) </h3>
-		<p>将 [page:BufferAttribute.dynamic dynamic] 设置为 value.</p>
+		<h3>[method:BufferAttribute setUsage] ( [param:Usage value] ) </h3>
+		<p>Set [page:BufferAttribute.usage usage] to value.</p>
 
 
 		<h3>[method:BufferAttribute setX]( [param:Integer index], [param:Float x] ) </h3>
 		<h3>[method:BufferAttribute setX]( [param:Integer index], [param:Float x] ) </h3>
 		<p>设置给定索引的矢量的第一维数据(设置 X 值)。</p>
 		<p>设置给定索引的矢量的第一维数据(设置 X 值)。</p>

+ 12 - 13
docs/api/zh/core/InterleavedBuffer.html

@@ -44,11 +44,6 @@
 			类型化队列中,所有元素的数目。
 			类型化队列中,所有元素的数目。
 		</p>
 		</p>
 
 
-		<h3>[property:Boolean dynamic]</h3>
-		<p>
-			默认值为 *false*。
-		</p>
-
 		<h3>[property:Object updateRange]</h3>
 		<h3>[property:Object updateRange]</h3>
 		<p>
 		<p>
 			对象存储着需要更新的数据的偏移量和数量。
 			对象存储着需要更新的数据的偏移量和数量。
@@ -79,17 +74,13 @@
 			默认值为 *false*。该值被设置为 true 时,会导致 [page:InterleavedBuffer.version version] 增加。
 			默认值为 *false*。该值被设置为 true 时,会导致 [page:InterleavedBuffer.version version] 增加。
 		</p>
 		</p>
 
 
-		<h2>方法</h2>
-
-		<h3>[method:InterleavedBuffer setArray] ( [param:TypedArray array] ) </h3>
+		<h3>[property:Usage usage]</h3>
 		<p>
 		<p>
-		 array - 必须是一个类型化的队列。
+			Defines the intended usage pattern of the data store for optimization purposes. Corresponds to the *usage* parameter of
+			[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData WebGLRenderingContext.bufferData]().
 		</p>
 		</p>
 
 
-		<h3>[method:InterleavedBuffer setDynamic] ( [param:Boolean value] ) </h3>
-		<p>
-			根据输入参数设置 [page:InterleavedBuffer.dynamic dynamic] 的值。
-		</p>
+		<h2>方法</h2>
 
 
 		<h3>[method:InterleavedBuffer copy]( [param:InterleavedBuffer source] ) </h3>
 		<h3>[method:InterleavedBuffer copy]( [param:InterleavedBuffer source] ) </h3>
 		<p>
 		<p>
@@ -112,6 +103,14 @@
 			克隆当前 [name]。
 			克隆当前 [name]。
 		</p>
 		</p>
 
 
+		<h3>[method:InterleavedBuffer setArray] ( [param:TypedArray array] ) </h3>
+		<p>
+		 array - 必须是一个类型化的队列。
+		</p>
+
+		<h3>[method:BufferAttribute setUsage] ( [param:Usage value] ) </h3>
+		<p>Set [page:BufferAttribute.usage usage] to value.</p>
+
 		<h2>源代码</h2>
 		<h2>源代码</h2>
 
 
 		<p>
 		<p>

+ 3 - 3
examples/js/geometries/LightningStrike.js

@@ -430,11 +430,11 @@ THREE.LightningStrike.prototype.createMesh = function () {
 
 
 	if ( ! this.isStatic ) {
 	if ( ! this.isStatic ) {
 
 
-		this.index.dynamic = true;
-		this.positionAttribute.dynamic = true;
+		this.index.usage = THREE.DynamicDrawUsage;
+		this.positionAttribute.usage = THREE.DynamicDrawUsage;
 		if ( this.generateUVs ) {
 		if ( this.generateUVs ) {
 
 
-			this.uvsAttribute.dynamic = true;
+			this.uvsAttribute.usage = THREE.DynamicDrawUsage;
 
 
 		}
 		}
 
 

+ 4 - 3
examples/jsm/geometries/LightningStrike.js

@@ -103,6 +103,7 @@
 
 
 import {
 import {
 	BufferGeometry,
 	BufferGeometry,
+	DynamicDrawUsage,
 	Float32BufferAttribute,
 	Float32BufferAttribute,
 	Math as _Math,
 	Math as _Math,
 	Uint32BufferAttribute,
 	Uint32BufferAttribute,
@@ -439,11 +440,11 @@ LightningStrike.prototype.createMesh = function () {
 
 
 	if ( ! this.isStatic ) {
 	if ( ! this.isStatic ) {
 
 
-		this.index.dynamic = true;
-		this.positionAttribute.dynamic = true;
+		this.index.usage = DynamicDrawUsage;
+		this.positionAttribute.usage = DynamicDrawUsage;
 		if ( this.generateUVs ) {
 		if ( this.generateUVs ) {
 
 
-			this.uvsAttribute.dynamic = true;
+			this.uvsAttribute.usage = DynamicDrawUsage;
 
 
 		}
 		}
 
 

+ 1 - 1
examples/webgl_buffergeometry_custom_attributes_particles.html

@@ -114,7 +114,7 @@
 
 
 				geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
 				geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
 				geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) );
 				geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) );
-				geometry.addAttribute( 'size', new THREE.Float32BufferAttribute( sizes, 1 ).setDynamic( true ) );
+				geometry.addAttribute( 'size', new THREE.Float32BufferAttribute( sizes, 1 ).setUsage( THREE.DynamicDrawUsage ) );
 
 
 				particleSystem = new THREE.Points( geometry, shaderMaterial );
 				particleSystem = new THREE.Points( geometry, shaderMaterial );
 
 

+ 3 - 3
examples/webgl_buffergeometry_drawrange.html

@@ -139,7 +139,7 @@
 				}
 				}
 
 
 				particles.setDrawRange( 0, particleCount );
 				particles.setDrawRange( 0, particleCount );
-				particles.addAttribute( 'position', new THREE.BufferAttribute( particlePositions, 3 ).setDynamic( true ) );
+				particles.addAttribute( 'position', new THREE.BufferAttribute( particlePositions, 3 ).setUsage( THREE.DynamicDrawUsage ) );
 
 
 				// create the particle system
 				// create the particle system
 				pointCloud = new THREE.Points( particles, pMaterial );
 				pointCloud = new THREE.Points( particles, pMaterial );
@@ -147,8 +147,8 @@
 
 
 				var geometry = new THREE.BufferGeometry();
 				var geometry = new THREE.BufferGeometry();
 
 
-				geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ).setDynamic( true ) );
-				geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ).setDynamic( true ) );
+				geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ).setUsage( THREE.DynamicDrawUsage ) );
+				geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ).setUsage( THREE.DynamicDrawUsage ) );
 
 
 				geometry.computeBoundingSphere();
 				geometry.computeBoundingSphere();
 
 

+ 1 - 1
examples/webgl_buffergeometry_instancing_dynamic.html

@@ -147,7 +147,7 @@
 			}
 			}
 
 
 			offsetAttribute = new THREE.InstancedBufferAttribute( new Float32Array( offsets ), 3 );
 			offsetAttribute = new THREE.InstancedBufferAttribute( new Float32Array( offsets ), 3 );
-			orientationAttribute = new THREE.InstancedBufferAttribute( new Float32Array( orientations ), 4 ).setDynamic( true );
+			orientationAttribute = new THREE.InstancedBufferAttribute( new Float32Array( orientations ), 4 ).setUsage( THREE.DynamicDrawUsage );
 
 
 			geometry.addAttribute( 'offset', offsetAttribute );
 			geometry.addAttribute( 'offset', offsetAttribute );
 			geometry.addAttribute( 'orientation', orientationAttribute );
 			geometry.addAttribute( 'orientation', orientationAttribute );

+ 1 - 1
examples/webgl_buffergeometry_instancing_interleaved_dynamic.html

@@ -162,7 +162,7 @@
 			geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
 			geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
 
 
 			// per instance data
 			// per instance data
-			instanceBuffer = new THREE.InstancedInterleavedBuffer( new Float32Array( instances * 8 ), 8, 1 ).setDynamic( true );
+			instanceBuffer = new THREE.InstancedInterleavedBuffer( new Float32Array( instances * 8 ), 8, 1 ).setUsage( THREE.DynamicDrawUsage );
 			var offsets = new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 0 );
 			var offsets = new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 0 );
 
 
 			var vector = new THREE.Vector4();
 			var vector = new THREE.Vector4();

+ 1 - 1
examples/webgl_geometry_dynamic.html

@@ -58,7 +58,7 @@
 				geometry.rotateX( - Math.PI / 2 );
 				geometry.rotateX( - Math.PI / 2 );
 
 
 				var position = geometry.attributes.position;
 				var position = geometry.attributes.position;
-				position.dynamic = true;
+				position.usage = THREE.DynamicDrawUsage;
 
 
 				for ( var i = 0; i < position.count; i ++ ) {
 				for ( var i = 0; i < position.count; i ++ ) {
 
 

+ 1 - 1
examples/webgl_points_dynamic.html

@@ -180,7 +180,7 @@
 				geometry.addAttribute( 'position', positions.clone() );
 				geometry.addAttribute( 'position', positions.clone() );
 				geometry.addAttribute( 'initialPosition', positions.clone() );
 				geometry.addAttribute( 'initialPosition', positions.clone() );
 
 
-				geometry.attributes.position.setDynamic( true );
+				geometry.attributes.position.setUsage( THREE.DynamicDrawUsage );
 
 
 				var clones = [
 				var clones = [
 
 

+ 1 - 1
examples/webgl_simple_gi.html

@@ -73,7 +73,7 @@
 					if ( attributes.color === undefined ) {
 					if ( attributes.color === undefined ) {
 
 
 						var colors = new Float32Array( positions.length );
 						var colors = new Float32Array( positions.length );
-						geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ).setDynamic( true ) );
+						geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ).setUsage( THREE.DynamicDrawUsage ) );
 
 
 					}
 					}
 
 

+ 3 - 3
examples/webvr_paint.html

@@ -146,15 +146,15 @@
 				var geometry = new THREE.BufferGeometry();
 				var geometry = new THREE.BufferGeometry();
 
 
 				var positions = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
 				var positions = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
-				positions.dynamic = true;
+				positions.usage = THREE.DynamicDrawUsage;
 				geometry.addAttribute( 'position', positions );
 				geometry.addAttribute( 'position', positions );
 
 
 				var normals = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
 				var normals = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
-				normals.dynamic = true;
+				normals.usage = THREE.DynamicDrawUsage;
 				geometry.addAttribute( 'normal', normals );
 				geometry.addAttribute( 'normal', normals );
 
 
 				var colors = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
 				var colors = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
-				colors.dynamic = true;
+				colors.usage = THREE.DynamicDrawUsage;
 				geometry.addAttribute( 'color', colors );
 				geometry.addAttribute( 'color', colors );
 
 
 				geometry.drawRange.count = 0;
 				geometry.drawRange.count = 0;

+ 3 - 3
examples/webvr_vive_paint.html

@@ -169,15 +169,15 @@
 				var geometry = new THREE.BufferGeometry();
 				var geometry = new THREE.BufferGeometry();
 
 
 				var positions = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
 				var positions = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
-				positions.dynamic = true;
+				positions.usage = THREE.DynamicDrawUsage;
 				geometry.addAttribute( 'position', positions );
 				geometry.addAttribute( 'position', positions );
 
 
 				var normals = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
 				var normals = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
-				normals.dynamic = true;
+				normals.usage = THREE.DynamicDrawUsage;
 				geometry.addAttribute( 'normal', normals );
 				geometry.addAttribute( 'normal', normals );
 
 
 				var colors = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
 				var colors = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
-				colors.dynamic = true;
+				colors.usage = THREE.DynamicDrawUsage;
 				geometry.addAttribute( 'color', colors );
 				geometry.addAttribute( 'color', colors );
 
 
 				geometry.drawRange.count = 0;
 				geometry.drawRange.count = 0;

+ 60 - 2
src/Three.Legacy.js

@@ -5,7 +5,11 @@
 import { Audio } from './audio/Audio.js';
 import { Audio } from './audio/Audio.js';
 import { AudioAnalyser } from './audio/AudioAnalyser.js';
 import { AudioAnalyser } from './audio/AudioAnalyser.js';
 import { PerspectiveCamera } from './cameras/PerspectiveCamera.js';
 import { PerspectiveCamera } from './cameras/PerspectiveCamera.js';
-import { FlatShading } from './constants.js';
+import {
+	FlatShading,
+	StaticDrawUsage,
+	DynamicDrawUsage
+} from './constants.js';
 import {
 import {
 	Float64BufferAttribute,
 	Float64BufferAttribute,
 	Float32BufferAttribute,
 	Float32BufferAttribute,
@@ -19,6 +23,7 @@ import {
 	BufferAttribute
 	BufferAttribute
 } from './core/BufferAttribute.js';
 } from './core/BufferAttribute.js';
 import { BufferGeometry } from './core/BufferGeometry.js';
 import { BufferGeometry } from './core/BufferGeometry.js';
+import { InterleavedBuffer } from './core/InterleavedBuffer.js';
 import { Face3 } from './core/Face3.js';
 import { Face3 } from './core/Face3.js';
 import { Geometry } from './core/Geometry.js';
 import { Geometry } from './core/Geometry.js';
 import { Object3D } from './core/Object3D.js';
 import { Object3D } from './core/Object3D.js';
@@ -1164,12 +1169,36 @@ Object.defineProperties( BufferAttribute.prototype, {
 
 
 		}
 		}
 	},
 	},
+	dynamic: {
+		get: function () {
+
+			console.warn( 'THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.' );
+			return this.usage === DynamicDrawUsage;
+
+		},
+		set: function ( value ) {
+
+			console.warn( 'THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.' );
+			this.setUsage( value );
+
+		}
+	}
+
+} );
+
+Object.assign( BufferAttribute.prototype, {
+	setDynamic: function ( value ) {
+
+		console.warn( 'THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead.' );
+		this.setUsage( value === true ? DynamicDrawUsage : StaticDrawUsage );
+		return this;
+
+	},
 	copyIndicesArray: function ( /* indices */ ) {
 	copyIndicesArray: function ( /* indices */ ) {
 
 
 		console.error( 'THREE.BufferAttribute: .copyIndicesArray() has been removed.' );
 		console.error( 'THREE.BufferAttribute: .copyIndicesArray() has been removed.' );
 
 
 	}
 	}
-
 } );
 } );
 
 
 Object.assign( BufferGeometry.prototype, {
 Object.assign( BufferGeometry.prototype, {
@@ -1231,6 +1260,35 @@ Object.defineProperties( BufferGeometry.prototype, {
 
 
 } );
 } );
 
 
+Object.defineProperties( InterleavedBuffer.prototype, {
+
+	dynamic: {
+		get: function () {
+
+			console.warn( 'THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.' );
+			return this.usage === DynamicDrawUsage;
+
+		},
+		set: function ( value ) {
+
+			console.warn( 'THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.' );
+			this.setUsage( value );
+
+		}
+	}
+
+} );
+
+Object.assign( InterleavedBuffer.prototype, {
+	setDynamic: function ( value ) {
+
+		console.warn( 'THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead.' );
+		this.setUsage( value === true ? DynamicDrawUsage : StaticDrawUsage );
+		return this;
+
+	}
+} );
+
 //
 //
 
 
 Object.assign( ExtrudeBufferGeometry.prototype, {
 Object.assign( ExtrudeBufferGeometry.prototype, {

+ 12 - 0
src/constants.d.ts

@@ -275,3 +275,15 @@ export const GreaterStencilFunc: StencilFunc;
 export const NotEqualStencilFunc: StencilFunc;
 export const NotEqualStencilFunc: StencilFunc;
 export const GreaterEqualStencilFunc: StencilFunc;
 export const GreaterEqualStencilFunc: StencilFunc;
 export const AlwaysStencilFunc: StencilFunc;
 export const AlwaysStencilFunc: StencilFunc;
+
+// usage types
+export enum Usage {}
+export const StaticDrawUsage: Usage;
+export const DynamicDrawUsage: Usage;
+export const StreamDrawUsage: Usage;
+export const StaticReadUsage: Usage;
+export const DynamicReadUsage: Usage;
+export const StreamReadUsage: Usage;
+export const StaticCopyUsage: Usage;
+export const DynamicCopyUsage: Usage;
+export const StreamCopyUsage: Usage;

+ 10 - 0
src/constants.js

@@ -166,3 +166,13 @@ export var GreaterStencilFunc = 516;
 export var NotEqualStencilFunc = 517;
 export var NotEqualStencilFunc = 517;
 export var GreaterEqualStencilFunc = 518;
 export var GreaterEqualStencilFunc = 518;
 export var AlwaysStencilFunc = 519;
 export var AlwaysStencilFunc = 519;
+
+export var StaticDrawUsage = 35044;
+export var DynamicDrawUsage = 35048;
+export var StreamDrawUsage = 35040;
+export var StaticReadUsage = 35045;
+export var DynamicReadUsage = 35049;
+export var StreamReadUsage = 35041;
+export var StaticCopyUsage = 35046;
+export var DynamicCopyUsage = 35050;
+export var StreamCopyUsage = 35042;

+ 6 - 2
src/core/BufferAttribute.d.ts

@@ -1,3 +1,7 @@
+import {
+	Usage
+} from '../constants';
+
 /**
 /**
  * @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js">src/core/BufferAttribute.js</a>
  * @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js">src/core/BufferAttribute.js</a>
  */
  */
@@ -8,7 +12,7 @@ export class BufferAttribute {
 	name: string;
 	name: string;
 	array: ArrayLike<number>;
 	array: ArrayLike<number>;
 	itemSize: number;
 	itemSize: number;
-	dynamic: boolean;
+	usage: Usage;
 	updateRange: { offset: number; count: number };
 	updateRange: { offset: number; count: number };
 	version: number;
 	version: number;
 	normalized: boolean;
 	normalized: boolean;
@@ -17,7 +21,7 @@ export class BufferAttribute {
 	onUpload: Function;
 	onUpload: Function;
 
 
 	setArray( array?: ArrayBufferView ): void;
 	setArray( array?: ArrayBufferView ): void;
-	setDynamic( dynamic: boolean ): BufferAttribute;
+	setUsage( usage: Usage ): BufferAttribute;
 	clone(): this;
 	clone(): this;
 	copy( source: BufferAttribute ): this;
 	copy( source: BufferAttribute ): this;
 	copyAt(
 	copyAt(

+ 5 - 4
src/core/BufferAttribute.js

@@ -2,6 +2,7 @@ import { Vector4 } from '../math/Vector4.js';
 import { Vector3 } from '../math/Vector3.js';
 import { Vector3 } from '../math/Vector3.js';
 import { Vector2 } from '../math/Vector2.js';
 import { Vector2 } from '../math/Vector2.js';
 import { Color } from '../math/Color.js';
 import { Color } from '../math/Color.js';
+import { StaticDrawUsage } from '../constants.js';
 
 
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
@@ -22,7 +23,7 @@ function BufferAttribute( array, itemSize, normalized ) {
 	this.count = array !== undefined ? array.length / itemSize : 0;
 	this.count = array !== undefined ? array.length / itemSize : 0;
 	this.normalized = normalized === true;
 	this.normalized = normalized === true;
 
 
-	this.dynamic = false;
+	this.usage = StaticDrawUsage;
 	this.updateRange = { offset: 0, count: - 1 };
 	this.updateRange = { offset: 0, count: - 1 };
 
 
 	this.version = 0;
 	this.version = 0;
@@ -60,9 +61,9 @@ Object.assign( BufferAttribute.prototype, {
 
 
 	},
 	},
 
 
-	setDynamic: function ( value ) {
+	setUsage: function ( value ) {
 
 
-		this.dynamic = value;
+		this.usage = value;
 
 
 		return this;
 		return this;
 
 
@@ -76,7 +77,7 @@ Object.assign( BufferAttribute.prototype, {
 		this.count = source.count;
 		this.count = source.count;
 		this.normalized = source.normalized;
 		this.normalized = source.normalized;
 
 
-		this.dynamic = source.dynamic;
+		this.usage = source.usage;
 
 
 		return this;
 		return this;
 
 

+ 3 - 2
src/core/InterleavedBuffer.d.ts

@@ -1,4 +1,5 @@
 import { InterleavedBufferAttribute } from './InterleavedBufferAttribute';
 import { InterleavedBufferAttribute } from './InterleavedBufferAttribute';
+import { Usage } from '../constants';
 
 
 /**
 /**
  * @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBuffer.js">src/core/InterleavedBuffer.js</a>
  * @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBuffer.js">src/core/InterleavedBuffer.js</a>
@@ -9,7 +10,7 @@ export class InterleavedBuffer {
 
 
 	array: ArrayLike<number>;
 	array: ArrayLike<number>;
 	stride: number;
 	stride: number;
-	dynamic: boolean;
+	usage: Usage;
 	updateRange: { offset: number; count: number };
 	updateRange: { offset: number; count: number };
 	version: number;
 	version: number;
 	length: number;
 	length: number;
@@ -17,7 +18,7 @@ export class InterleavedBuffer {
 	needsUpdate: boolean;
 	needsUpdate: boolean;
 
 
 	setArray( array?: ArrayBufferView ): void;
 	setArray( array?: ArrayBufferView ): void;
-	setDynamic( dynamic: boolean ): InterleavedBuffer;
+	setUsage( usage: Usage ): InterleavedBuffer;
 	clone(): this;
 	clone(): this;
 	copy( source: InterleavedBuffer ): this;
 	copy( source: InterleavedBuffer ): this;
 	copyAt(
 	copyAt(

+ 5 - 4
src/core/InterleavedBuffer.js

@@ -1,3 +1,4 @@
+import { StaticDrawUsage } from '../constants.js';
 
 
 /**
 /**
  * @author benaadams / https://twitter.com/ben_a_adams
  * @author benaadams / https://twitter.com/ben_a_adams
@@ -9,7 +10,7 @@ function InterleavedBuffer( array, stride ) {
 	this.stride = stride;
 	this.stride = stride;
 	this.count = array !== undefined ? array.length / stride : 0;
 	this.count = array !== undefined ? array.length / stride : 0;
 
 
-	this.dynamic = false;
+	this.usage = StaticDrawUsage;
 	this.updateRange = { offset: 0, count: - 1 };
 	this.updateRange = { offset: 0, count: - 1 };
 
 
 	this.version = 0;
 	this.version = 0;
@@ -47,9 +48,9 @@ Object.assign( InterleavedBuffer.prototype, {
 
 
 	},
 	},
 
 
-	setDynamic: function ( value ) {
+	setUsage: function ( value ) {
 
 
-		this.dynamic = value;
+		this.usage = value;
 
 
 		return this;
 		return this;
 
 
@@ -60,7 +61,7 @@ Object.assign( InterleavedBuffer.prototype, {
 		this.array = new source.array.constructor( source.array );
 		this.array = new source.array.constructor( source.array );
 		this.count = source.count;
 		this.count = source.count;
 		this.stride = source.stride;
 		this.stride = source.stride;
-		this.dynamic = source.dynamic;
+		this.usage = source.usage;
 
 
 		return this;
 		return this;
 
 

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

@@ -9,7 +9,7 @@ function WebGLAttributes( gl ) {
 	function createBuffer( attribute, bufferType ) {
 	function createBuffer( attribute, bufferType ) {
 
 
 		var array = attribute.array;
 		var array = attribute.array;
-		var usage = attribute.dynamic ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW;
+		var usage = attribute.usage;
 
 
 		var buffer = gl.createBuffer();
 		var buffer = gl.createBuffer();
 
 
@@ -70,20 +70,12 @@ function WebGLAttributes( gl ) {
 
 
 		gl.bindBuffer( bufferType, buffer );
 		gl.bindBuffer( bufferType, buffer );
 
 
-		if ( attribute.dynamic === false ) {
-
-			gl.bufferData( bufferType, array, gl.STATIC_DRAW );
-
-		} else if ( updateRange.count === - 1 ) {
+		if ( updateRange.count === - 1 ) {
 
 
 			// Not using update ranges
 			// Not using update ranges
 
 
 			gl.bufferSubData( bufferType, 0, array );
 			gl.bufferSubData( bufferType, 0, array );
 
 
-		} else if ( updateRange.count === 0 ) {
-
-			console.error( 'THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually.' );
-
 		} else {
 		} else {
 
 
 			gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
 			gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,

+ 8 - 4
test/unit/src/core/BufferAttribute.tests.js

@@ -8,6 +8,7 @@ import { Color } from '../../../../src/math/Color';
 import { Vector2 } from '../../../../src/math/Vector2';
 import { Vector2 } from '../../../../src/math/Vector2';
 import { Vector3 } from '../../../../src/math/Vector3';
 import { Vector3 } from '../../../../src/math/Vector3';
 import { Vector4 } from '../../../../src/math/Vector4';
 import { Vector4 } from '../../../../src/math/Vector4';
+import { DynamicDrawUsage } from '../../../../src/constants';
 
 
 export default QUnit.module( 'Core', () => {
 export default QUnit.module( 'Core', () => {
 
 
@@ -64,23 +65,26 @@ export default QUnit.module( 'Core', () => {
 
 
 		} );
 		} );
 
 
-		QUnit.todo( "setDynamic", ( assert ) => {
+		QUnit.test( "setUsage", ( assert ) => {
 
 
-			assert.ok( false, "everything's gonna be alright" );
+			var attr = new BufferAttribute();
+			attr.setUsage( DynamicDrawUsage );
+
+			assert.strictEqual( attr.usage, DynamicDrawUsage, "Usage was set" );
 
 
 		} );
 		} );
 
 
 		QUnit.test( "copy", ( assert ) => {
 		QUnit.test( "copy", ( assert ) => {
 
 
 			var attr = new BufferAttribute( new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ), 3 );
 			var attr = new BufferAttribute( new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ), 3 );
-			attr.setDynamic( true );
+			attr.setUsage( DynamicDrawUsage );
 			attr.needsUpdate = true;
 			attr.needsUpdate = true;
 
 
 			var attrCopy = new BufferAttribute().copy( attr );
 			var attrCopy = new BufferAttribute().copy( attr );
 
 
 			assert.ok( attr.count === attrCopy.count, 'count is equal' );
 			assert.ok( attr.count === attrCopy.count, 'count is equal' );
 			assert.ok( attr.itemSize === attrCopy.itemSize, 'itemSize is equal' );
 			assert.ok( attr.itemSize === attrCopy.itemSize, 'itemSize is equal' );
-			assert.ok( attr.dynamic === attrCopy.dynamic, 'dynamic is equal' );
+			assert.ok( attr.usage === attrCopy.usage, 'usage is equal' );
 			assert.ok( attr.array.length === attrCopy.array.length, 'array length is equal' );
 			assert.ok( attr.array.length === attrCopy.array.length, 'array length is equal' );
 			assert.ok( attr.version === 1 && attrCopy.version === 0, 'version is not copied which is good' );
 			assert.ok( attr.version === 1 && attrCopy.version === 0, 'version is not copied which is good' );
 
 

+ 9 - 5
test/unit/src/core/InterleavedBuffer.tests.js

@@ -4,6 +4,7 @@
 /* global QUnit */
 /* global QUnit */
 
 
 import { InterleavedBuffer } from '../../../../src/core/InterleavedBuffer';
 import { InterleavedBuffer } from '../../../../src/core/InterleavedBuffer';
+import { DynamicDrawUsage } from '../../../../src/constants';
 
 
 export default QUnit.module( 'Core', () => {
 export default QUnit.module( 'Core', () => {
 
 
@@ -20,7 +21,7 @@ export default QUnit.module( 'Core', () => {
 			}
 			}
 
 
 			assert.ok( copiedInstance.stride === instance.stride, "stride was copied" );
 			assert.ok( copiedInstance.stride === instance.stride, "stride was copied" );
-			assert.ok( copiedInstance.dynamic === true, "dynamic was copied" );
+			assert.ok( copiedInstance.usage === DynamicDrawUsage, "usage was copied" );
 
 
 		}
 		}
 
 
@@ -77,9 +78,12 @@ export default QUnit.module( 'Core', () => {
 
 
 		} );
 		} );
 
 
-		QUnit.todo( "setDynamic", ( assert ) => {
+		QUnit.test( "setUsage", ( assert ) => {
 
 
-			assert.ok( false, "everything's gonna be alright" );
+			var instance = new InterleavedBuffer();
+			instance.setUsage( DynamicDrawUsage );
+
+			assert.strictEqual( instance.usage, DynamicDrawUsage, "Usage was set" );
 
 
 		} );
 		} );
 
 
@@ -87,7 +91,7 @@ export default QUnit.module( 'Core', () => {
 
 
 			var array = new Float32Array( [ 1, 2, 3, 7, 8, 9 ] );
 			var array = new Float32Array( [ 1, 2, 3, 7, 8, 9 ] );
 			var instance = new InterleavedBuffer( array, 3 );
 			var instance = new InterleavedBuffer( array, 3 );
-			instance.setDynamic( true );
+			instance.setUsage( DynamicDrawUsage );
 
 
 			checkInstanceAgainstCopy( instance, instance.copy( instance ), assert );
 			checkInstanceAgainstCopy( instance, instance.copy( instance ), assert );
 
 
@@ -120,7 +124,7 @@ export default QUnit.module( 'Core', () => {
 
 
 			var array = new Float32Array( [ 1, 2, 3, 7, 8, 9 ] );
 			var array = new Float32Array( [ 1, 2, 3, 7, 8, 9 ] );
 			var instance = new InterleavedBuffer( array, 3 );
 			var instance = new InterleavedBuffer( array, 3 );
-			instance.setDynamic( true );
+			instance.setUsage( DynamicDrawUsage );
 
 
 			checkInstanceAgainstCopy( instance, instance.clone(), assert );
 			checkInstanceAgainstCopy( instance, instance.clone(), assert );