提交 45d63985 编写于 作者: B Ben Adams

Reset attribute divisor when changing from non-instanced

上级 c6c305a3
......@@ -910,8 +910,6 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( geometryAttribute !== undefined ) {
state.enableAttribute( programAttribute );
var size = geometryAttribute.itemSize;
var buffer = objects.getAttributeBuffer( geometryAttribute );
......@@ -921,18 +919,13 @@ THREE.WebGLRenderer = function ( parameters ) {
var stride = data.stride;
var offset = geometryAttribute.offset;
state.enableAttribute( programAttribute, data.meshPerAttribute, extension );
_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer );
_gl.vertexAttribPointer( programAttribute, size, _gl.FLOAT, false, stride * data.array.BYTES_PER_ELEMENT, ( startIndex * stride + offset ) * data.array.BYTES_PER_ELEMENT );
if ( data instanceof THREE.InstancedInterleavedBuffer ) {
if ( extension === null ) {
console.error( 'THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferAttribute but hardware does not support extension ANGLE_instanced_arrays.' );
return;
}
extension.vertexAttribDivisorANGLE( programAttribute, data.meshPerAttribute );
if ( geometry.maxInstancedCount === undefined ) {
......@@ -945,18 +938,13 @@ THREE.WebGLRenderer = function ( parameters ) {
} else {
state.enableAttribute( programAttribute, geometryAttribute.meshPerAttribute, extension );
_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer );
_gl.vertexAttribPointer( programAttribute, size, _gl.FLOAT, false, 0, startIndex * size * 4 ); // 4 bytes per Float32
if ( geometryAttribute instanceof THREE.InstancedBufferAttribute ) {
if ( extension === null ) {
console.error( 'THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferAttribute but hardware does not support extension ANGLE_instanced_arrays.' );
return;
}
extension.vertexAttribDivisorANGLE( programAttribute, geometryAttribute.meshPerAttribute );
if ( geometry.maxInstancedCount === undefined ) {
......
......@@ -68,7 +68,7 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
};
this.enableAttribute = function ( attribute ) {
this.enableAttribute = function ( attribute, meshPerAttribute, extension ) {
newAttributes[ attribute ] = 1;
......@@ -79,6 +79,15 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
}
meshPerAttribute = meshPerAttribute || 0;
if ( attributeDivisors[ attribute ] !== meshPerAttribute ) {
extension.vertexAttribDivisorANGLE( attribute, meshPerAttribute );
attributeDivisors[ attribute ] !== meshPerAttribute;
}
};
this.disableUnusedAttributes = function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册