Pārlūkot izejas kodu

Merge pull request #18688 from OndrejSpanel/pull/18239

WebGLObjects: Introduce usage of WeakMap.
Mr.doob 5 gadi atpakaļ
vecāks
revīzija
1cd04af118
1 mainītis faili ar 4 papildinājumiem un 4 dzēšanām
  1. 4 4
      src/renderers/webgl/WebGLObjects.js

+ 4 - 4
src/renderers/webgl/WebGLObjects.js

@@ -4,7 +4,7 @@
 
 function WebGLObjects( gl, geometries, attributes, info ) {
 
-	var updateList = {};
+	var updateMap = new WeakMap();
 
 	function update( object ) {
 
@@ -15,7 +15,7 @@ function WebGLObjects( gl, geometries, attributes, info ) {
 
 		// Update once per frame
 
-		if ( updateList[ buffergeometry.id ] !== frame ) {
+		if ( updateMap.get( buffergeometry ) !== frame ) {
 
 			if ( geometry.isGeometry ) {
 
@@ -25,7 +25,7 @@ function WebGLObjects( gl, geometries, attributes, info ) {
 
 			geometries.update( buffergeometry );
 
-			updateList[ buffergeometry.id ] = frame;
+			updateMap.set( buffergeometry, frame );
 
 		}
 
@@ -41,7 +41,7 @@ function WebGLObjects( gl, geometries, attributes, info ) {
 
 	function dispose() {
 
-		updateList = {};
+		updateMap = new WeakMap();
 
 	}