Browse Source

WebGLObjects: Robustness.

Mr.doob 10 năm trước cách đây
mục cha
commit
50a327d1a4
1 tập tin đã thay đổi với 23 bổ sung11 xóa
  1. 23 11
      src/renderers/webgl/WebGLObjects.js

+ 23 - 11
src/renderers/webgl/WebGLObjects.js

@@ -178,25 +178,37 @@ THREE.WebGLObjects = function ( gl, info ) {
 
 			var bufferGeometry = geometries[ geometry.id ];
 
-			if ( geometry.verticesNeedUpdate === true ) {
+			if ( object instanceof THREE.PointCloud || object instanceof THREE.Line ) {
 
-				var attribute = bufferGeometry.attributes.position;
+				if ( geometry.verticesNeedUpdate === true ) {
 
-				attribute.copyVector3sArray( geometry.vertices );
-				attribute.needsUpdate = true;
+					var attribute = bufferGeometry.attributes.position;
 
-				geometry.verticesNeedUpdate = false;
+					if ( attribute !== undefined ) {
 
-			}
+						attribute.copyVector3sArray( geometry.vertices );
+						attribute.needsUpdate = true;
+
+					}
+
+					geometry.verticesNeedUpdate = false;
+
+				}
 
-			if ( geometry.colorsNeedUpdate === true ) {
+				if ( geometry.colorsNeedUpdate === true ) {
 
-				var attribute = bufferGeometry.attributes.color;
+					var attribute = bufferGeometry.attributes.color;
 
-				attribute.copyColorsArray( geometry.colors );
-				attribute.needsUpdate = true;
+					if ( attribute !== undefined ) {
 
-				geometry.colorsNeedUpdate = false;
+						attribute.copyColorsArray( geometry.colors );
+						attribute.needsUpdate = true;
+
+					}
+
+					geometry.colorsNeedUpdate = false;
+
+				}
 
 			}