How to clear the array (this.array) of the bufferAttribute which is shared with different geometries

can anyone help me out, how to clear the array (this.array) of the bufferAttribute which is shared with different geometries. i tried with “onUploadCallback” but it throwing error for this case.

getBufferAttrib(accessor)
{
let key ='bufferView : ' + accessor.bufferView;
let bufferAttribute = this.BufferAttributeCache.get(key);

if(bufferAttribute === undefined){

   let itemSize = WebglConstants.WEBGL_TYPE_SIZES[accessor.type];

   let arrayType = WebglConstants.WEBGL_COMPONENT_TYPES[accessor.componentType];
   let data = new arrayType(accessor.bufferViewData,accessor.bufferOffset, accessor.count * itemSize );
   bufferAttribute = new THREE.BufferAttribute( data, itemSize );    
   bufferAttribute.name = accessor.name;
   bufferAttribute.refCount = 1;
   bufferAttribute.onUploadCallback = function() {
       this.refCount = this.refCount - 1;
       if(this.refCount === 0){
           this.array = null;
       }             
   };      
   this.BufferAttributeCache.add(key, bufferAttribute);

}
else{
   bufferAttribute.refCount = bufferAttribute.refCount + 1;
}

Please reformat your code–it did not format correctly for this forum. Also, as I mentioned on Stack Overflow, if you’re receiving an error, please include the full text of the error in your question (or on this forum you can post it below as a reply).

1 Like