|
|
@@ -85,8 +85,15 @@ class NodeMaterialObserver {
|
|
|
|
|
|
if ( data === undefined ) {
|
|
|
|
|
|
+ const { geometry, material } = renderObject;
|
|
|
+
|
|
|
data = {
|
|
|
- material: this.getMaterialData( renderObject.material ),
|
|
|
+ material: this.getMaterialData( material ),
|
|
|
+ geometry: {
|
|
|
+ attributes: this.getAttributesData( geometry.attributes ),
|
|
|
+ indexVersion: geometry.index ? geometry.index.version : null,
|
|
|
+ drawRange: { start: geometry.drawRange.start, count: geometry.drawRange.count }
|
|
|
+ },
|
|
|
worldMatrix: renderObject.object.matrixWorld.clone()
|
|
|
};
|
|
|
|
|
|
@@ -116,6 +123,24 @@ class NodeMaterialObserver {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ getAttributesData( attributes ) {
|
|
|
+
|
|
|
+ const attributesData = {};
|
|
|
+
|
|
|
+ for ( const name in attributes ) {
|
|
|
+
|
|
|
+ const attribute = attributes[ name ];
|
|
|
+
|
|
|
+ attributesData[ name ] = {
|
|
|
+ version: attribute.version
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return attributesData;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
containsNode( builder ) {
|
|
|
|
|
|
const material = builder.material;
|
|
|
@@ -170,7 +195,7 @@ class NodeMaterialObserver {
|
|
|
|
|
|
equals( renderObject ) {
|
|
|
|
|
|
- const { object, material } = renderObject;
|
|
|
+ const { object, material, geometry } = renderObject;
|
|
|
|
|
|
const renderObjectData = this.getRenderObjectData( renderObject );
|
|
|
|
|
|
@@ -224,6 +249,66 @@ class NodeMaterialObserver {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // geometry
|
|
|
+
|
|
|
+ const storedGeometryData = renderObjectData.geometry;
|
|
|
+ const attributes = geometry.attributes;
|
|
|
+ const storedAttributes = storedGeometryData.attributes;
|
|
|
+
|
|
|
+ const storedAttributeNames = Object.keys( storedAttributes );
|
|
|
+ const currentAttributeNames = Object.keys( attributes );
|
|
|
+
|
|
|
+ if ( storedAttributeNames.length !== currentAttributeNames.length ) {
|
|
|
+
|
|
|
+ renderObjectData.geometry.attributes = this.getAttributesData( attributes );
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // Compare each attribute
|
|
|
+ for ( const name of storedAttributeNames ) {
|
|
|
+
|
|
|
+ const storedAttributeData = storedAttributes[ name ];
|
|
|
+ const attribute = attributes[ name ];
|
|
|
+
|
|
|
+ if ( attribute === undefined ) {
|
|
|
+
|
|
|
+ // Attribute was removed
|
|
|
+ delete storedAttributes[ name ];
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( storedAttributeData.version !== attribute.version ) {
|
|
|
+
|
|
|
+ storedAttributeData.version = attribute.version;
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // Check index
|
|
|
+ const index = geometry.index;
|
|
|
+ const storedIndexVersion = storedGeometryData.indexVersion;
|
|
|
+ const currentIndexVersion = index ? index.version : null;
|
|
|
+
|
|
|
+ if ( storedIndexVersion !== currentIndexVersion ) {
|
|
|
+
|
|
|
+ storedGeometryData.indexVersion = currentIndexVersion;
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // Check drawRange
|
|
|
+ if ( storedGeometryData.drawRange.start !== geometry.drawRange.start || storedGeometryData.drawRange.count !== geometry.drawRange.count ) {
|
|
|
+
|
|
|
+ storedGeometryData.drawRange.start = geometry.drawRange.start;
|
|
|
+ storedGeometryData.drawRange.count = geometry.drawRange.count;
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// morph targets
|
|
|
|
|
|
if ( renderObjectData.morphTargetInfluences ) {
|