diff --git a/docs/api/en/core/BufferAttribute.html b/docs/api/en/core/BufferAttribute.html index fc0ded08ba4c8218a2c43bf469ef99ce2351fc30..4be6c0525392716c4e74dec5a9eaa261f5ac4b57 100644 --- a/docs/api/en/core/BufferAttribute.html +++ b/docs/api/en/core/BufferAttribute.html @@ -58,16 +58,6 @@ then this will count the number of such vectors stored.
-
- Whether the buffer is dynamic or not. Default is *false*.
-
- 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.
- 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.
-
Used to check whether this or derived classes are BufferAttributes. Default is *true*.
@@ -111,10 +101,16 @@
related to color).
+ 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*. +
+A version number, incremented every time the [page:BufferAttribute.needsUpdate needsUpdate] property is set to true.
-Set [page:BufferAttribute.dynamic dynamic] to value.
+Set [page:BufferAttribute.usage usage] to value.
Sets the x component of the vector at the given index.
diff --git a/docs/api/en/core/InterleavedBuffer.html b/docs/api/en/core/InterleavedBuffer.html index a657be0b47e535792f5a9f757aa834521bf2d700..5f00e5f05f4af1107d9c7f96a28f99f5f856478a 100644 --- a/docs/api/en/core/InterleavedBuffer.html +++ b/docs/api/en/core/InterleavedBuffer.html @@ -44,11 +44,6 @@ Gives the total number of elements in the array. -- Default is *false*. -
-Object containing offset and count. @@ -79,13 +74,14 @@ Default is *false*. Setting this to true increments [page:InterleavedBuffer.version version].
-- Set [page:InterleavedBuffer.dynamic dynamic] to value. + 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]().
+Copies another [name] to this [name]. @@ -107,6 +103,9 @@ Creates a clone of this [name].
+Set [page:BufferAttribute.usage usage] to value.
+diff --git a/docs/api/zh/core/BufferAttribute.html b/docs/api/zh/core/BufferAttribute.html index b6ee6e7aad7a930f455a1fa4880479eb03447ee1..ca5486bfe0e75e2fd1faa94b573533f1c5192aa7 100644 --- a/docs/api/zh/core/BufferAttribute.html +++ b/docs/api/zh/core/BufferAttribute.html @@ -52,16 +52,6 @@ 若缓存存储三元组(例如顶点位置、法向量、颜色值),则该值应等于队列中三元组的个数。
-
- 不论缓存是否是动态的,默认值都将是 *false*
-
- 如果该值为 false,即告知 GPU 缓存中的数据会经常使用但不经常变化。
- 该值与 [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData gl.STATIC_DRAW] 标志位相一致。
- 如果该值为 true,即告知 GPU 缓存中的数据会经常使用且经常变化。
- 该值与 [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData gl.DYNAMIC_DRAW] 标志位相一致。
-
指示当前类或派生类是 BufferAttributes. 默认值为 *true*.
@@ -101,6 +91,13 @@
该值只可以被用于更新某些矢量数据(例如,颜色相关数据)。
+ 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*. +
+版本号,当 [page:BufferAttribute.needsUpdate needsUpdate] 被设置为 true 时,该值会自增。
@@ -158,8 +155,8 @@ 特别的, 对将 [page:Array value] 转为 [page:TypedArray] 的要求详见上述链接。 -将 [page:BufferAttribute.dynamic dynamic] 设置为 value.
+Set [page:BufferAttribute.usage usage] to value.
设置给定索引的矢量的第一维数据(设置 X 值)。
diff --git a/docs/api/zh/core/InterleavedBuffer.html b/docs/api/zh/core/InterleavedBuffer.html index 7e6c1a2e8b45431a26cb4a74b858f34fcba0e5c4..16a16904f4deafb5679d841598a495db53c87add 100644 --- a/docs/api/zh/core/InterleavedBuffer.html +++ b/docs/api/zh/core/InterleavedBuffer.html @@ -44,11 +44,6 @@ 类型化队列中,所有元素的数目。 -- 默认值为 *false*。 -
-对象存储着需要更新的数据的偏移量和数量。 @@ -79,13 +74,14 @@ 默认值为 *false*。该值被设置为 true 时,会导致 [page:InterleavedBuffer.version version] 增加。
-- 根据输入参数设置 [page:InterleavedBuffer.dynamic dynamic] 的值。 + 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]().
+将参数指定的 [name] 拷贝到当前 [name]。 @@ -107,6 +103,9 @@ 克隆当前 [name]。
+Set [page:BufferAttribute.usage usage] to value.
+
diff --git a/examples/js/geometries/LightningStrike.js b/examples/js/geometries/LightningStrike.js
index 3a05b34013326e4a18d1fa383cd3894e15187cce..73862e6a1d0819fd12e0c46a5e0bc036ed23cf74 100644
--- a/examples/js/geometries/LightningStrike.js
+++ b/examples/js/geometries/LightningStrike.js
@@ -430,11 +430,11 @@ THREE.LightningStrike.prototype.createMesh = function () {
if ( ! this.isStatic ) {
- this.index.dynamic = true;
- this.positionAttribute.dynamic = true;
+ this.index.usage = THREE.DynamicDrawUsage;
+ this.positionAttribute.usage = THREE.DynamicDrawUsage;
if ( this.generateUVs ) {
- this.uvsAttribute.dynamic = true;
+ this.uvsAttribute.usage = THREE.DynamicDrawUsage;
}
diff --git a/examples/jsm/geometries/LightningStrike.js b/examples/jsm/geometries/LightningStrike.js
index 0f5e75dd8d651dc43281a8e25564bc260e9a1f93..b971cd37b0e6dc0c7e99d06b5455c45d36ec2917 100644
--- a/examples/jsm/geometries/LightningStrike.js
+++ b/examples/jsm/geometries/LightningStrike.js
@@ -103,6 +103,7 @@
import {
BufferGeometry,
+ DynamicDrawUsage,
Float32BufferAttribute,
Math as _Math,
Uint32BufferAttribute,
@@ -439,11 +440,11 @@ LightningStrike.prototype.createMesh = function () {
if ( ! this.isStatic ) {
- this.index.dynamic = true;
- this.positionAttribute.dynamic = true;
+ this.index.usage = DynamicDrawUsage;
+ this.positionAttribute.usage = DynamicDrawUsage;
if ( this.generateUVs ) {
- this.uvsAttribute.dynamic = true;
+ this.uvsAttribute.usage = DynamicDrawUsage;
}
diff --git a/examples/webgl_buffergeometry_custom_attributes_particles.html b/examples/webgl_buffergeometry_custom_attributes_particles.html
index 3a5e7a3efca7794d6a777eb16239240288e77585..8a2a7fd47f9e8104bc00aa3b358448290d8ef850 100644
--- a/examples/webgl_buffergeometry_custom_attributes_particles.html
+++ b/examples/webgl_buffergeometry_custom_attributes_particles.html
@@ -114,7 +114,7 @@
geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 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 );
diff --git a/examples/webgl_buffergeometry_drawrange.html b/examples/webgl_buffergeometry_drawrange.html
index 50c4f6162fbf9716659cbe43e0ca7bc64378e935..834eaf2d1e4a6b603d7405c64219afd3f9e18008 100644
--- a/examples/webgl_buffergeometry_drawrange.html
+++ b/examples/webgl_buffergeometry_drawrange.html
@@ -139,7 +139,7 @@
}
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
pointCloud = new THREE.Points( particles, pMaterial );
@@ -147,8 +147,8 @@
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();
diff --git a/examples/webgl_buffergeometry_instancing_dynamic.html b/examples/webgl_buffergeometry_instancing_dynamic.html
index 6940e6729b09f456298685bedc39108e2d4aeef1..64cab48af4fd0755f51c4d271b8e101bd9f10895 100644
--- a/examples/webgl_buffergeometry_instancing_dynamic.html
+++ b/examples/webgl_buffergeometry_instancing_dynamic.html
@@ -147,7 +147,7 @@
}
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( 'orientation', orientationAttribute );
diff --git a/examples/webgl_buffergeometry_instancing_interleaved_dynamic.html b/examples/webgl_buffergeometry_instancing_interleaved_dynamic.html
index fad7112279982fc05457e8b035c644e570e565d8..6fc4e129762bfc77168852964e93f0283e678b32 100644
--- a/examples/webgl_buffergeometry_instancing_interleaved_dynamic.html
+++ b/examples/webgl_buffergeometry_instancing_interleaved_dynamic.html
@@ -162,7 +162,7 @@
geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
// 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 vector = new THREE.Vector4();
diff --git a/examples/webgl_geometry_dynamic.html b/examples/webgl_geometry_dynamic.html
index 5f73fb0e28523c1c8deecd530ffcb73340eb73a4..1de8d067d0f7d551010b34f96f60d193d66b762e 100644
--- a/examples/webgl_geometry_dynamic.html
+++ b/examples/webgl_geometry_dynamic.html
@@ -58,7 +58,7 @@
geometry.rotateX( - Math.PI / 2 );
var position = geometry.attributes.position;
- position.dynamic = true;
+ position.usage = THREE.DynamicDrawUsage;
for ( var i = 0; i < position.count; i ++ ) {
diff --git a/examples/webgl_points_dynamic.html b/examples/webgl_points_dynamic.html
index 29db8030ce91f9f82546876cc9bb19729b9cea1e..f54d3243a84cbd529555ab83d12b87d7b652794c 100644
--- a/examples/webgl_points_dynamic.html
+++ b/examples/webgl_points_dynamic.html
@@ -180,7 +180,7 @@
geometry.addAttribute( 'position', positions.clone() );
geometry.addAttribute( 'initialPosition', positions.clone() );
- geometry.attributes.position.setDynamic( true );
+ geometry.attributes.position.setUsage( THREE.DynamicDrawUsage );
var clones = [
diff --git a/examples/webgl_simple_gi.html b/examples/webgl_simple_gi.html
index c139d8a23e4e3791e079df8d40c9f3327f589ecc..fbeb534735fd24e009de71211456d6b6bdf0df6d 100644
--- a/examples/webgl_simple_gi.html
+++ b/examples/webgl_simple_gi.html
@@ -73,7 +73,7 @@
if ( attributes.color === undefined ) {
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 ) );
}
diff --git a/examples/webvr_paint.html b/examples/webvr_paint.html
index 21e48ec66974ede3d61766b1daf06af541223c65..69f83e4b73dc37474148fcc9b02e9f824cbf93ed 100644
--- a/examples/webvr_paint.html
+++ b/examples/webvr_paint.html
@@ -146,15 +146,15 @@
var geometry = new THREE.BufferGeometry();
var positions = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
- positions.dynamic = true;
+ positions.usage = THREE.DynamicDrawUsage;
geometry.addAttribute( 'position', positions );
var normals = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
- normals.dynamic = true;
+ normals.usage = THREE.DynamicDrawUsage;
geometry.addAttribute( 'normal', normals );
var colors = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
- colors.dynamic = true;
+ colors.usage = THREE.DynamicDrawUsage;
geometry.addAttribute( 'color', colors );
geometry.drawRange.count = 0;
diff --git a/examples/webvr_vive_paint.html b/examples/webvr_vive_paint.html
index 2b3bb0ff759f8db263eb1bfec285b0b947683fc5..1fbc7e978b842ca0154825ce763624c9c1586d2c 100644
--- a/examples/webvr_vive_paint.html
+++ b/examples/webvr_vive_paint.html
@@ -169,15 +169,15 @@
var geometry = new THREE.BufferGeometry();
var positions = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
- positions.dynamic = true;
+ positions.usage = THREE.DynamicDrawUsage;
geometry.addAttribute( 'position', positions );
var normals = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
- normals.dynamic = true;
+ normals.usage = THREE.DynamicDrawUsage;
geometry.addAttribute( 'normal', normals );
var colors = new THREE.BufferAttribute( new Float32Array( 1000000 * 3 ), 3 );
- colors.dynamic = true;
+ colors.usage = THREE.DynamicDrawUsage;
geometry.addAttribute( 'color', colors );
geometry.drawRange.count = 0;
diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js
index 08557138b288f7ac99e6d41072d092e916a4d9f2..6980b98bbf32d7550083412c8ec757272521fc69 100644
--- a/src/Three.Legacy.js
+++ b/src/Three.Legacy.js
@@ -5,7 +5,11 @@
import { Audio } from './audio/Audio.js';
import { AudioAnalyser } from './audio/AudioAnalyser.js';
import { PerspectiveCamera } from './cameras/PerspectiveCamera.js';
-import { FlatShading } from './constants.js';
+import {
+ FlatShading,
+ StaticDrawUsage,
+ DynamicDrawUsage
+} from './constants.js';
import {
Float64BufferAttribute,
Float32BufferAttribute,
@@ -1163,13 +1167,33 @@ Object.defineProperties( BufferAttribute.prototype, {
console.warn( 'THREE.BufferAttribute: .length has been deprecated. Use .count instead.' );
return this.array.length;
+ }
+ },
+ 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 */ ) {
console.error( 'THREE.BufferAttribute: .copyIndicesArray() has been removed.' );
@@ -1185,7 +1209,6 @@ Object.assign( BufferAttribute.prototype, {
return this;
}
-
} );
Object.assign( BufferGeometry.prototype, {
@@ -1247,8 +1270,33 @@ 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;
+
+ },
setArray: function ( array ) {
console.warn( 'THREE.InterleavedBuffer: .setArray has been deprecated. Use BufferGeometry .setAttribute to replace/resize attribute buffers' );
@@ -1259,7 +1307,6 @@ Object.assign( InterleavedBuffer.prototype, {
return this;
}
-
} );
//
diff --git a/src/constants.d.ts b/src/constants.d.ts
index 8d200621acbfbd3f8a0146422bd43d081404ae80..fe5f5a623fb15bc73a65503d0b8e15084fa47d58 100644
--- a/src/constants.d.ts
+++ b/src/constants.d.ts
@@ -275,3 +275,15 @@ export const GreaterStencilFunc: StencilFunc;
export const NotEqualStencilFunc: StencilFunc;
export const GreaterEqualStencilFunc: 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;
diff --git a/src/constants.js b/src/constants.js
index 8e398a8a2937d450e23f91fedf005686dabffe74..7b3cb214cec56c139e26f7dc698ace1e9c9de977 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -166,3 +166,13 @@ export var GreaterStencilFunc = 516;
export var NotEqualStencilFunc = 517;
export var GreaterEqualStencilFunc = 518;
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;
diff --git a/src/core/BufferAttribute.d.ts b/src/core/BufferAttribute.d.ts
index 00843fe96b534ebc144846010262c20f0b438507..aa4980470909f6df22d498b42ab54bff45ac3e14 100644
--- a/src/core/BufferAttribute.d.ts
+++ b/src/core/BufferAttribute.d.ts
@@ -1,3 +1,7 @@
+import {
+ Usage
+} from '../constants';
+
/**
* @see src/core/BufferAttribute.js
*/
@@ -8,7 +12,7 @@ export class BufferAttribute {
name: string;
array: ArrayLike