提交 9af4f0b1 编写于 作者: D dubejf

Implement and use update counter

上级 55c5baf6
......@@ -9,7 +9,8 @@ THREE.BufferAttribute = function ( array, itemSize ) {
this.array = array;
this.itemSize = itemSize;
this.needsUpdate = false;
this._needsUpdate = false;
this.updateCounter = 0;
};
......@@ -30,6 +31,20 @@ THREE.BufferAttribute.prototype = {
},
get needsUpdate() {
return this._needsUpdate;
},
set needsUpdate( value ) {
if ( value === true ) this.updateCounter ++;
this._needsUpdate = value;
},
copyAt: function ( index1, attribute, index2 ) {
index1 *= this.itemSize;
......
......@@ -9,7 +9,8 @@ THREE.InterleavedBuffer = function ( array, stride, dynamic ) {
this.array = array;
this.stride = stride;
this.needsUpdate = false;
this._needsUpdate = false;
this.updateCounter = 0;
this.dynamic = dynamic || false;
this.updateRange = { offset: 0, count: -1 };
......@@ -32,6 +33,20 @@ THREE.InterleavedBuffer.prototype = {
},
get needsUpdate() {
return this._needsUpdate;
},
set needsUpdate( value ) {
if ( value === true ) this.updateCounter ++;
this._needsUpdate = value;
},
copyAt: function ( index1, attribute, index2 ) {
index1 *= this.stride;
......
......@@ -185,7 +185,7 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
createBuffer( attributeProperties, data, bufferType );
} else if ( data.needsUpdate === true ) {
} else if ( attributeProperties.updateCounter !== data.updateCounter ) {
updateBuffer( attributeProperties, data, bufferType );
......@@ -210,11 +210,12 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
gl.bufferData( bufferType, data.array, usage );
attributeProperties.updateCounter = data.updateCounter;
data.needsUpdate = false;
}
function updateBuffer( attributeProperties, data, bufferType ) {
function updateBuffer ( attributeProperties, data, bufferType ) {
gl.bindBuffer( bufferType, attributeProperties.__webglBuffer );
......@@ -235,6 +236,7 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
}
attributeProperties.updateCounter = data.updateCounter;
data.needsUpdate = false;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册