Browse Source

Simplification of loader plugin system

David Catuhe 11 years ago
parent
commit
c968322be9

+ 4 - 12
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -542,13 +542,9 @@ var BABYLON = BABYLON || {};
 
     BABYLON.SceneLoader.RegisterPlugin({
         extensions: ".babylon",
-        importMesh: function (meshesNames, scene, data, rootUrl, then) {
+        importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons) {
             var parsedData = JSON.parse(data);
 
-            // Meshes
-            var meshes = [];
-            var particleSystems = [];
-            var skeletons = [];
             var loadedSkeletonsIds = [];
             var loadedMaterialsIds = [];
             var hierarchyIds = [];
@@ -621,11 +617,9 @@ var BABYLON = BABYLON || {};
                 }
             }
 
-            if (then) {
-                then(meshes, particleSystems, skeletons);
-            }
+            return true;
         },
-        load: function (scene, data, rootUrl, then) {
+        load: function (scene, data, rootUrl) {
             var parsedData = JSON.parse(data);
 
             // Scene
@@ -729,9 +723,7 @@ var BABYLON = BABYLON || {};
             }
 
             // Finish
-            if (then) {
-                then(scene);
-            }
+            return true;
         }
     });
 

+ 14 - 2
Babylon/Loading/babylon.sceneLoader.js

@@ -35,7 +35,15 @@ var BABYLON = BABYLON || {};
             var plugin = this._getPluginForFilename(sceneFilename);
 
             BABYLON.Tools.LoadFile(rootUrl + sceneFilename, function (data) {
-                plugin.importMesh(meshesNames, scene, data, rootUrl, then);
+                var meshes = [];
+                var particleSystems = [];
+                var skeletons = [];
+
+                plugin.importMesh(meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons);
+
+                if (then) {
+                    then(meshes, particleSystems, skeletons);
+                }
             }, progressCallBack, database);
         },
 
@@ -47,7 +55,11 @@ var BABYLON = BABYLON || {};
             var loadSceneFromData = function (data) {
                 var scene = new BABYLON.Scene(engine);
                 scene.database = database;
-                plugin.load(scene, data, rootUrl, then);
+                plugin.load(scene, data, rootUrl);
+
+                if (then) {
+                    then(scene);
+                }
             };
 
             if (rootUrl.indexOf("file:") === -1) {

+ 4 - 3
Babylon/Math/babylon.math.js

@@ -1039,11 +1039,12 @@ var BABYLON = BABYLON || {};
     // Statics
     BABYLON.Quaternion.RotationAxis = function (axis, angle) {
         var result = new BABYLON.Quaternion();
+        var sin = Math.sin(angle / 2);
 
         result.w = Math.cos(angle / 2);
-        result.x = axis.x * Math.sin(angle / 2);
-        result.y = axis.y * Math.sin(angle / 2);
-        result.z = axis.z * Math.sin(angle / 2);
+        result.x = axis.x * sin;
+        result.y = axis.y * sin;
+        result.z = axis.z * sin;
 
         return result;
     };

+ 2 - 2
Babylon/Mesh/babylon.mesh.js

@@ -102,7 +102,7 @@ var BABYLON = BABYLON || {};
             this.rotation = BABYLON.Vector3.Zero();
         }
 
-        if (space == BABYLON.Space.LOCAL) {
+        if (!space || space == BABYLON.Space.LOCAL) {
             var rotationQuaternion = BABYLON.Quaternion.RotationAxis(axis, amount);
             this.rotationQuaternion = this.rotationQuaternion.multiply(rotationQuaternion);
         }
@@ -121,7 +121,7 @@ var BABYLON = BABYLON || {};
     BABYLON.Mesh.prototype.translate = function (axis, distance, space) {
         var displacementVector = axis.scale(distance);
 
-        if (space == BABYLON.Space.LOCAL) {
+        if (!space || space == BABYLON.Space.LOCAL) {
             var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
             this.setPositionWithLocalVector(tempV3);
         }

File diff suppressed because it is too large
+ 2 - 2
babylon.1.9.0.js