Skip to content

Commit

Permalink
implemenet destroyAttribute()
Browse files Browse the repository at this point in the history
  • Loading branch information
aardgoose committed Dec 15, 2023
1 parent 2b8971b commit 379db47
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/jsm/renderers/webgl/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import WebGLTextureUtils from './utils/WebGLTextureUtils.js';
import WebGLExtensions from './utils/WebGLExtensions.js';
import WebGLCapabilities from './utils/WebGLCapabilities.js';
import { DepthFormat } from '../../../../src/constants.js';
import { attribute } from '../../nodes/Nodes.js';

//

Expand Down Expand Up @@ -893,9 +894,9 @@ class WebGLBackend extends Backend {

}

destroyAttribute( /*attribute*/ ) {
destroyAttribute( attribute ) {

console.warn( 'Abstract class.' );
this.attributeUtils.destroyAttribute( attribute );

}

Expand Down
19 changes: 19 additions & 0 deletions examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,25 @@ class WebGLAttributeUtils {

}

destroyAttribute( attribute ) {

const backend = this.backend;
const { gl } = backend;

if ( attribute.isInterleavedBufferAttribute ) {

backend.delete( attribute.data );

}

const attributeData = backend.get( attribute );

gl.deleteBuffer( attributeData.bufferGPU );

backend.delete( attribute );

}

async getArrayBufferAsync( attribute ) {

const backend = this.backend;
Expand Down

0 comments on commit 379db47

Please sign in to comment.