Kaynağa Gözat

Merge remote-tracking branch 'origin/dev' into dev

Mr.doob 10 yıl önce
ebeveyn
işleme
70ad75899f

+ 1 - 1
examples/js/loaders/AssimpJSONLoader.js

@@ -53,7 +53,7 @@ THREE.AssimpJSONLoader.prototype = {
 
 			scene = scope.parse( json );
 			onLoad( scene );
-		} );
+		}, onProgress, onError );
 	},
 
 	setCrossOrigin: function ( value ) {

+ 1 - 1
examples/js/loaders/BabylonLoader.js

@@ -22,7 +22,7 @@ THREE.BabylonLoader.prototype = {
 
 			onLoad( scope.parse( JSON.parse( text ) ) );
 
-		} );
+		}, onProgress, onError );
 
 	},
 

+ 1 - 1
examples/js/loaders/MTLLoader.js

@@ -26,7 +26,7 @@ THREE.MTLLoader.prototype = {
 
 			onLoad( scope.parse( text ) );
 
-		} );
+		}, onProgress, onError );
 
 	},
 

+ 1 - 1
examples/js/loaders/OBJLoader.js

@@ -22,7 +22,7 @@ THREE.OBJLoader.prototype = {
 
 			onLoad( scope.parse( text ) );
 
-		} );
+		}, onProgress, onError );
 
 	},
 

+ 2 - 2
examples/js/loaders/OBJMTLLoader.js

@@ -45,9 +45,9 @@ THREE.OBJMTLLoader.prototype = {
 
 				onLoad( object );
 
-			} );
+			}, onProgress, onError );
 
-		} );
+		}, onProgress, onError );
 
 	},
 

+ 2 - 2
examples/js/loaders/PDBLoader.js

@@ -12,7 +12,7 @@ THREE.PDBLoader.prototype = {
 
 	constructor: THREE.PDBLoader,
 
-	load: function ( url, onLoad ) {
+	load: function ( url, onLoad, onProgress, onError ) {
 
 		var scope = this;
 
@@ -23,7 +23,7 @@ THREE.PDBLoader.prototype = {
 			var json = scope.parsePDB( text );
 			scope.createModel( json, onLoad );
 
-		} );
+		}, onProgress, onError );
 
 	},
 

+ 2 - 2
examples/js/loaders/SVGLoader.js

@@ -25,7 +25,7 @@ THREE.SVGLoader.prototype = {
 
 			onLoad( doc.firstChild );
 
-		} );
+		}, onProgress, onError );
 
 	}
-};
+};

+ 1 - 1
examples/js/loaders/SceneLoader.js

@@ -32,7 +32,7 @@ THREE.SceneLoader.prototype = {
 
 			scope.parse( JSON.parse( text ), onLoad, url );
 
-		} );
+		}, onProgress, onError );
 
 	},
 

+ 2 - 2
examples/js/loaders/TGALoader.js

@@ -9,7 +9,7 @@ THREE.TGALoader.prototype = {
 
 	constructor: THREE.TGALoader,
 
-	load: function ( url, onLoad, onError ) {
+	load: function ( url, onLoad, onProgress, onError ) {
 		
 		var scope = this;
 		
@@ -24,7 +24,7 @@ THREE.TGALoader.prototype = {
 
 			if ( onLoad ) onLoad( texture );
 
-		} );
+		}, onProgress, onError );
 
 		return texture;
 

+ 12 - 3
examples/webgl_loader_assimp2json.html

@@ -80,6 +80,16 @@
 			// init scene
 			init();
 
+			var onProgress = function ( xhr ) {
+				if ( xhr.lengthComputable ) {
+					var percentComplete = xhr.loaded / xhr.total * 100;
+					console.log( Math.round(percentComplete, 2) + '% downloaded' );
+				}
+			};
+
+			var onError = function ( xhr ) {
+			};
+
 			// Load jeep model using the AssimpJSONLoader
 			var loader1 = new THREE.AssimpJSONLoader();
 			loader1.load( 'models/assimp/jeep/jeep.assimp.json', function ( assimpjson ) {
@@ -88,8 +98,7 @@
 				assimpjson.updateMatrix();
 
 				scene.add(assimpjson);
-			} );
-
+			}, onProgress, onError );
 
 			// load interior model
 			var loader2 = new THREE.AssimpJSONLoader();
@@ -100,7 +109,7 @@
 
 				scene.add( assimpjson );
 
-			} );
+			}, onProgress, onError );
 
 			animate();
 

+ 12 - 1
examples/webgl_loader_obj.html

@@ -79,6 +79,17 @@
 
 				var texture = new THREE.Texture();
 
+				var onProgress = function ( xhr ) {
+					if ( xhr.lengthComputable ) {
+						var percentComplete = xhr.loaded / xhr.total * 100;
+						console.log( Math.round(percentComplete, 2) + '% downloaded' );
+					}
+				};
+
+				var onError = function ( xhr ) {
+				};
+
+
 				var loader = new THREE.ImageLoader( manager );
 				loader.load( 'textures/UV_Grid_Sm.jpg', function ( image ) {
 
@@ -105,7 +116,7 @@
 					object.position.y = - 80;
 					scene.add( object );
 
-				} );
+				}, onProgress, onError );
 
 				//
 

+ 12 - 1
examples/webgl_loader_obj_mtl.html

@@ -76,6 +76,17 @@
 
 				// model
 
+				var onProgress = function ( xhr ) {
+					if ( xhr.lengthComputable ) {
+						var percentComplete = xhr.loaded / xhr.total * 100;
+						console.log( Math.round(percentComplete, 2) + '% downloaded' );
+					}
+				};
+
+				var onError = function ( xhr ) {
+				};
+
+
 				THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
 
 				var loader = new THREE.OBJMTLLoader();
@@ -84,7 +95,7 @@
 					object.position.y = - 80;
 					scene.add( object );
 
-				} );
+				}, onProgress, onError );
 
 				//
 

+ 11 - 1
examples/webgl_loader_pdb.html

@@ -181,6 +181,16 @@
 
 			//
 
+			var onProgress = function ( xhr ) {
+				if ( xhr.lengthComputable ) {
+					var percentComplete = xhr.loaded / xhr.total * 100;
+					console.log( Math.round(percentComplete, 2) + '% downloaded' );
+				}
+			};
+
+			var onError = function ( xhr ) {
+			};
+
 			function loadMolecule( url ) {
 
 				while( root.children.length > 0 ) {
@@ -244,7 +254,7 @@
 
 					render();
 
-				} );
+				}, onProgress, onError );
 
 
 			}

+ 6 - 6
utils/exporters/blender/2.65/scripts/addons/io_mesh_threejs/__init__.py

@@ -139,8 +139,8 @@ class ImportTHREEJS(bpy.types.Operator, ImportHelper):
     bl_idname = "import.threejs"
     bl_label = "Import Three.js"
 
-    filename_ext = ".js"
-    filter_glob = StringProperty(default="*.js", options={'HIDDEN'})
+    filename_ext = ".json"
+    filter_glob = StringProperty(default="*.json", options={'HIDDEN'})
 
     option_flip_yz = BoolProperty(name="Flip YZ", description="Flip YZ", default=True)
     recalculate_normals = BoolProperty(name="Recalculate normals", description="Recalculate vertex normals", default=True)
@@ -283,7 +283,7 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
     bl_idname = "export.threejs"
     bl_label = "Export Three.js"
 
-    filename_ext = ".js"
+    filename_ext = ".json"
 
     option_vertices = BoolProperty(name = "Vertices", description = "Export vertices", default = True)
     option_vertices_deltas = BoolProperty(name = "Deltas", description = "Delta vertices", default = False)
@@ -442,11 +442,11 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
 # ################################################################
 
 def menu_func_export(self, context):
-    default_path = bpy.data.filepath.replace(".blend", ".js")
-    self.layout.operator(ExportTHREEJS.bl_idname, text="Three.js (.js)").filepath = default_path
+    default_path = bpy.data.filepath.replace(".blend", ".json")
+    self.layout.operator(ExportTHREEJS.bl_idname, text="Three.js (.json)").filepath = default_path
 
 def menu_func_import(self, context):
-    self.layout.operator(ImportTHREEJS.bl_idname, text="Three.js (.js)")
+    self.layout.operator(ImportTHREEJS.bl_idname, text="Three.js (.json)")
 
 def register():
     bpy.utils.register_module(__name__)

+ 2 - 2
utils/exporters/blender/2.65/scripts/addons/io_mesh_threejs/export_threejs.py

@@ -1802,7 +1802,7 @@ def generate_section(label, content):
 
 def get_mesh_filename(mesh):
     object_id = mesh["data"]["name"]
-    filename = "%s.js" % sanitize(object_id)
+    filename = "%s.json" % sanitize(object_id)
     return filename
 
 def generate_material_id_list(materials):
@@ -2563,7 +2563,7 @@ def save(operator, context, filepath = "",
 
     #print("URL TYPE", option_url_base_html)
 
-    filepath = ensure_extension(filepath, '.js')
+    filepath = ensure_extension(filepath, '.json')
 
     scene = context.scene