diff --git a/docs/api/en/core/BufferAttribute.html b/docs/api/en/core/BufferAttribute.html index 764273483a8aaf..c3cef46dd6e61e 100644 --- a/docs/api/en/core/BufferAttribute.html +++ b/docs/api/en/core/BufferAttribute.html @@ -70,6 +70,9 @@
Read-only flag to check if a given object is of type [name].
+Unique number for this attribute instance.
+The length of vectors that are being stored in the diff --git a/src/core/BufferAttribute.js b/src/core/BufferAttribute.js index 747bb1efe34499..652a2a2d32616c 100644 --- a/src/core/BufferAttribute.js +++ b/src/core/BufferAttribute.js @@ -7,6 +7,8 @@ import { fromHalfFloat, toHalfFloat } from '../extras/DataUtils.js'; const _vector = /*@__PURE__*/ new Vector3(); const _vector2 = /*@__PURE__*/ new Vector2(); +let _id = 0; + class BufferAttribute { constructor( array, itemSize, normalized = false ) { @@ -19,6 +21,8 @@ class BufferAttribute { this.isBufferAttribute = true; + Object.defineProperty( this, 'id', { value: _id ++ } ); + this.name = ''; this.array = array; diff --git a/src/renderers/common/RenderObject.js b/src/renderers/common/RenderObject.js index a95347e88335da..0a670f8e57192a 100644 --- a/src/renderers/common/RenderObject.js +++ b/src/renderers/common/RenderObject.js @@ -558,6 +558,26 @@ class RenderObject { } + // structural equality isn't sufficient for morph targets since the + // data are maintained in textures. only if the targets are all equal + // the texture and thus the instance of `MorphNode` can be shared. + + for ( const name of Object.keys( geometry.morphAttributes ).sort() ) { + + const targets = geometry.morphAttributes[ name ]; + + cacheKey += 'morph-' + name + ','; + + for ( let i = 0, l = targets.length; i < l; i ++ ) { + + const attribute = targets[ i ]; + + cacheKey += attribute.id + ','; + + } + + } + if ( geometry.index ) { cacheKey += 'index,'; @@ -641,12 +661,6 @@ class RenderObject { } - if ( object.morphTargetInfluences ) { - - cacheKey += object.morphTargetInfluences.length + ','; - - } - if ( object.isBatchedMesh ) { cacheKey += object._matricesTexture.uuid + ',';