|
@@ -27,6 +27,12 @@ function WebGLObjects( gl, geometries, attributes, info ) {
|
|
|
|
|
|
if ( object.isInstancedMesh ) {
|
|
if ( object.isInstancedMesh ) {
|
|
|
|
|
|
|
|
+ if ( object.hasEventListener( 'dispose', onInstancedMeshDispose ) === false ) {
|
|
|
|
+
|
|
|
|
+ object.addEventListener( 'dispose', onInstancedMeshDispose );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
attributes.update( object.instanceMatrix, gl.ARRAY_BUFFER );
|
|
attributes.update( object.instanceMatrix, gl.ARRAY_BUFFER );
|
|
|
|
|
|
if ( object.instanceColor !== null ) {
|
|
if ( object.instanceColor !== null ) {
|
|
@@ -47,6 +53,18 @@ function WebGLObjects( gl, geometries, attributes, info ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function onInstancedMeshDispose( event ) {
|
|
|
|
+
|
|
|
|
+ const instancedMesh = event.target;
|
|
|
|
+
|
|
|
|
+ instancedMesh.removeEventListener( 'dispose', onInstancedMeshDispose );
|
|
|
|
+
|
|
|
|
+ attributes.remove( instancedMesh.instanceMatrix );
|
|
|
|
+
|
|
|
|
+ if ( instancedMesh.instanceColor !== null ) attributes.remove( instancedMesh.instanceColor );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
return {
|
|
return {
|
|
|
|
|
|
update: update,
|
|
update: update,
|