|
@@ -10939,8 +10939,8 @@ function WebGLBindingStates(gl, extensions, attributes, capabilities) {
|
|
bindVertexArrayObject(currentState.object);
|
|
bindVertexArrayObject(currentState.object);
|
|
}
|
|
}
|
|
|
|
|
|
- updateBuffers = needsUpdate(geometry, index);
|
|
|
|
- if (updateBuffers) saveCache(geometry, index);
|
|
|
|
|
|
+ updateBuffers = needsUpdate(object, geometry, program, index);
|
|
|
|
+ if (updateBuffers) saveCache(object, geometry, program, index);
|
|
} else {
|
|
} else {
|
|
const wireframe = material.wireframe === true;
|
|
const wireframe = material.wireframe === true;
|
|
|
|
|
|
@@ -10952,10 +10952,6 @@ function WebGLBindingStates(gl, extensions, attributes, capabilities) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (object.isInstancedMesh === true) {
|
|
|
|
- updateBuffers = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (index !== null) {
|
|
if (index !== null) {
|
|
attributes.update(index, gl.ELEMENT_ARRAY_BUFFER);
|
|
attributes.update(index, gl.ELEMENT_ARRAY_BUFFER);
|
|
}
|
|
}
|
|
@@ -11036,18 +11032,29 @@ function WebGLBindingStates(gl, extensions, attributes, capabilities) {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
- function needsUpdate(geometry, index) {
|
|
|
|
|
|
+ function needsUpdate(object, geometry, program, index) {
|
|
const cachedAttributes = currentState.attributes;
|
|
const cachedAttributes = currentState.attributes;
|
|
const geometryAttributes = geometry.attributes;
|
|
const geometryAttributes = geometry.attributes;
|
|
let attributesNum = 0;
|
|
let attributesNum = 0;
|
|
|
|
+ const programAttributes = program.getAttributes();
|
|
|
|
+
|
|
|
|
+ for (const name in programAttributes) {
|
|
|
|
+ const programAttribute = programAttributes[name];
|
|
|
|
+
|
|
|
|
+ if (programAttribute.location >= 0) {
|
|
|
|
+ const cachedAttribute = cachedAttributes[name];
|
|
|
|
+ let geometryAttribute = geometryAttributes[name];
|
|
|
|
+
|
|
|
|
+ if (geometryAttribute === undefined) {
|
|
|
|
+ if (name === 'instanceMatrix' && object.instanceMatrix) geometryAttribute = object.instanceMatrix;
|
|
|
|
+ if (name === 'instanceColor' && object.instanceColor) geometryAttribute = object.instanceColor;
|
|
|
|
+ }
|
|
|
|
|
|
- for (const key in geometryAttributes) {
|
|
|
|
- const cachedAttribute = cachedAttributes[key];
|
|
|
|
- const geometryAttribute = geometryAttributes[key];
|
|
|
|
- if (cachedAttribute === undefined) return true;
|
|
|
|
- if (cachedAttribute.attribute !== geometryAttribute) return true;
|
|
|
|
- if (cachedAttribute.data !== geometryAttribute.data) return true;
|
|
|
|
- attributesNum++;
|
|
|
|
|
|
+ if (cachedAttribute === undefined) return true;
|
|
|
|
+ if (cachedAttribute.attribute !== geometryAttribute) return true;
|
|
|
|
+ if (geometryAttribute && cachedAttribute.data !== geometryAttribute.data) return true;
|
|
|
|
+ attributesNum++;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (currentState.attributesNum !== attributesNum) return true;
|
|
if (currentState.attributesNum !== attributesNum) return true;
|
|
@@ -11055,22 +11062,33 @@ function WebGLBindingStates(gl, extensions, attributes, capabilities) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- function saveCache(geometry, index) {
|
|
|
|
|
|
+ function saveCache(object, geometry, program, index) {
|
|
const cache = {};
|
|
const cache = {};
|
|
const attributes = geometry.attributes;
|
|
const attributes = geometry.attributes;
|
|
let attributesNum = 0;
|
|
let attributesNum = 0;
|
|
|
|
+ const programAttributes = program.getAttributes();
|
|
|
|
|
|
- for (const key in attributes) {
|
|
|
|
- const attribute = attributes[key];
|
|
|
|
- const data = {};
|
|
|
|
- data.attribute = attribute;
|
|
|
|
|
|
+ for (const name in programAttributes) {
|
|
|
|
+ const programAttribute = programAttributes[name];
|
|
|
|
|
|
- if (attribute.data) {
|
|
|
|
- data.data = attribute.data;
|
|
|
|
- }
|
|
|
|
|
|
+ if (programAttribute.location >= 0) {
|
|
|
|
+ let attribute = attributes[name];
|
|
|
|
+
|
|
|
|
+ if (attribute === undefined) {
|
|
|
|
+ if (name === 'instanceMatrix' && object.instanceMatrix) attribute = object.instanceMatrix;
|
|
|
|
+ if (name === 'instanceColor' && object.instanceColor) attribute = object.instanceColor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const data = {};
|
|
|
|
+ data.attribute = attribute;
|
|
|
|
|
|
- cache[key] = data;
|
|
|
|
- attributesNum++;
|
|
|
|
|
|
+ if (attribute && attribute.data) {
|
|
|
|
+ data.data = attribute.data;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cache[name] = data;
|
|
|
|
+ attributesNum++;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
currentState.attributes = cache;
|
|
currentState.attributes = cache;
|