Преглед изворни кода

Move .vertexColors assignment to apply to lines scope, as well.

Don McCurdy пре 8 година
родитељ
комит
b1afd19724
1 измењених фајлова са 11 додато и 8 уклоњено
  1. 11 8
      examples/js/loaders/GLTF2Loader.js

+ 11 - 8
examples/js/loaders/GLTF2Loader.js

@@ -1696,11 +1696,13 @@ THREE.GLTF2Loader = ( function () {
 
 					var material = primitive.material !== undefined ? dependencies.materials[ primitive.material ] : createDefaultMaterial();
 
+					var geometry;
+
 					var meshNode;
 
 					if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === undefined ) {
 
-						var geometry = new THREE.BufferGeometry();
+						geometry = new THREE.BufferGeometry();
 
 						var attributes = primitive.attributes;
 
@@ -1750,12 +1752,6 @@ THREE.GLTF2Loader = ( function () {
 
 						}
 
-						if ( geometry.attributes.color !== undefined ) {
-
-							material.vertexColors = THREE.VertexColors;
-
-						}
-
 						if ( primitive.indices !== undefined ) {
 
 							geometry.setIndex( dependencies.accessors[ primitive.indices ] );
@@ -1767,7 +1763,7 @@ THREE.GLTF2Loader = ( function () {
 
 					} else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) {
 
-						var geometry = new THREE.BufferGeometry();
+						geometry = new THREE.BufferGeometry();
 
 						var attributes = primitive.attributes;
 
@@ -1813,6 +1809,13 @@ THREE.GLTF2Loader = ( function () {
 
 					}
 
+					if ( geometry.attributes.color !== undefined ) {
+
+						material.vertexColors = THREE.VertexColors;
+						material.needsUpdate = true;
+
+					}
+
 					meshNode.name = ( name === "0" ? group.name : group.name + name );
 
 					if ( primitive.extras ) meshNode.userData = primitive.extras;