瀏覽代碼

JSONLoader: Fixed breakage. See #10657

Mr.doob 8 年之前
父節點
當前提交
2e898a1325
共有 2 個文件被更改,包括 14 次插入5 次删除
  1. 7 5
      src/core/Geometry.js
  2. 7 0
      src/loaders/JSONLoader.js

+ 7 - 5
src/core/Geometry.js

@@ -1142,11 +1142,13 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
 
 
 		}
 		}
 
 
-		data.vertices = vertices;
-		data.normals = normals;
-		if ( colors.length > 0 ) data.colors = colors;
-		if ( uvs.length > 0 ) data.uvs = [ uvs ]; // temporal backward compatibility
-		data.faces = faces;
+		data.data = {};
+
+		data.data.vertices = vertices;
+		data.data.normals = normals;
+		if ( colors.length > 0 ) data.data.colors = colors;
+		if ( uvs.length > 0 ) data.data.uvs = [ uvs ]; // temporal backward compatibility
+		data.data.faces = faces;
 
 
 		return data;
 		return data;
 
 

+ 7 - 0
src/loaders/JSONLoader.js

@@ -83,6 +83,13 @@ Object.assign( JSONLoader.prototype, {
 
 
 	parse: function ( json, texturePath ) {
 	parse: function ( json, texturePath ) {
 
 
+		if ( json.data !== undefined ) {
+
+			// Geometry 4.0 spec
+			json = json.data;
+
+		}
+
 		var geometry = new Geometry(),
 		var geometry = new Geometry(),
 		scale = ( json.scale !== undefined ) ? 1.0 / json.scale : 1.0;
 		scale = ( json.scale !== undefined ) ? 1.0 / json.scale : 1.0;