|
@@ -3669,7 +3669,7 @@ var BABYLON;
|
|
|
*/
|
|
|
AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
|
|
|
if (typeof timeout === "undefined") { timeout = 0; }
|
|
|
- var asyncLoop = new AsyncLoop(Math.ceil(iterations / syncedIterations), function (loop) {
|
|
|
+ AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
|
|
|
if (breakFunction && breakFunction())
|
|
|
loop.breakLoop();
|
|
|
else {
|
|
@@ -9448,6 +9448,22 @@ var BABYLON;
|
|
|
return null;
|
|
|
};
|
|
|
|
|
|
+ Scene.prototype.getNodeByName = function (name) {
|
|
|
+ var mesh = this.getMeshByName(name);
|
|
|
+
|
|
|
+ if (mesh) {
|
|
|
+ return mesh;
|
|
|
+ }
|
|
|
+
|
|
|
+ var light = this.getLightByName(name);
|
|
|
+
|
|
|
+ if (light) {
|
|
|
+ return light;
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.getCameraByName(name);
|
|
|
+ };
|
|
|
+
|
|
|
Scene.prototype.getMeshByName = function (name) {
|
|
|
for (var index = 0; index < this.meshes.length; index++) {
|
|
|
if (this.meshes[index].name === name) {
|
|
@@ -12415,7 +12431,7 @@ var BABYLON;
|
|
|
|
|
|
/**
|
|
|
* Simplify the mesh according to the given array of settings.
|
|
|
- * Function will return immediately and will simplify asnyc.
|
|
|
+ * Function will return immediately and will simplify async.
|
|
|
* @param settings a collection of simplification settings.
|
|
|
* @param parallelProcessing should all levels calculate parallel or one after the other.
|
|
|
* @param type the type of simplification to run.
|
|
@@ -12460,7 +12476,7 @@ var BABYLON;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- var asyncLoop = new BABYLON.AsyncLoop(settings.length, function (loop) {
|
|
|
+ BABYLON.AsyncLoop.Run(settings.length, function (loop) {
|
|
|
runDecimation(settings[loop.index], function () {
|
|
|
loop.executeNext();
|
|
|
});
|
|
@@ -19766,7 +19782,7 @@ var BABYLON;
|
|
|
|
|
|
var center = mesh.getBoundingInfo().boundingBox.center;
|
|
|
body.setPosition(center.x, center.y, center.z);
|
|
|
- body.setOrientation(mesh.rotation.x, mesh.rotation.y, mesh.rotation.z);
|
|
|
+ body.setRotation(mesh.rotation.x, mesh.rotation.y, mesh.rotation.z);
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -19780,7 +19796,7 @@ var BABYLON;
|
|
|
|
|
|
body = registeredMesh.body.body;
|
|
|
body.setPosition(absolutePosition.x, absolutePosition.y, absolutePosition.z);
|
|
|
- body.setOrientation(absoluteRotation.x, absoluteRotation.y, absoluteRotation.z);
|
|
|
+ body.setRotation(absoluteRotation.x, absoluteRotation.y, absoluteRotation.z);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -21552,7 +21568,7 @@ var BABYLON;
|
|
|
camera = new BABYLON.ArcRotateCamera(parsedCamera.name, alpha, beta, radius, lockedTargetMesh, scene);
|
|
|
}
|
|
|
} else if (parsedCamera.type === "AnaglyphFreeCamera") {
|
|
|
- var eye_space = parsedCamera.eye_space;
|
|
|
+ eye_space = parsedCamera.eye_space;
|
|
|
camera = new BABYLON.AnaglyphFreeCamera(parsedCamera.name, position, eye_space, scene);
|
|
|
} else if (parsedCamera.type === "DeviceOrientationCamera") {
|
|
|
camera = new BABYLON.DeviceOrientationCamera(parsedCamera.name, position, scene);
|
|
@@ -21837,6 +21853,11 @@ var BABYLON;
|
|
|
mesh._waitingParentId = parsedMesh.parentId;
|
|
|
}
|
|
|
|
|
|
+ // Actions
|
|
|
+ if (parsedMesh.actions !== undefined) {
|
|
|
+ mesh._waitingActions = parsedMesh.actions;
|
|
|
+ }
|
|
|
+
|
|
|
// Geometry
|
|
|
mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
|
|
|
|
|
@@ -21953,6 +21974,92 @@ var BABYLON;
|
|
|
return mesh;
|
|
|
};
|
|
|
|
|
|
+ var parseActions = function (parsedActions, object, scene) {
|
|
|
+ var Types = { TRIGGER: 0, ACTION: 1, FLOW_CONTROL: 2, OBJECT: 3, SCENE: 4 };
|
|
|
+ object.actionManager = new BABYLON.ActionManager(scene);
|
|
|
+
|
|
|
+ var instanciate = function (name, params) {
|
|
|
+ var newInstance = Object.create(BABYLON[name].prototype);
|
|
|
+ newInstance.constructor.apply(newInstance, params);
|
|
|
+ return newInstance;
|
|
|
+ };
|
|
|
+
|
|
|
+ var getObjectByName = function (name) {
|
|
|
+ var object = scene.getMeshByName(name);
|
|
|
+
|
|
|
+ if (!object)
|
|
|
+ object = scene.getLightByName(name);
|
|
|
+
|
|
|
+ if (!object)
|
|
|
+ object = scene.getCameraByName(name);
|
|
|
+
|
|
|
+ return object;
|
|
|
+ };
|
|
|
+
|
|
|
+ // traverse graph per trigger
|
|
|
+ var traverse = function (parsedAction, trigger, condition, action, actionManager) {
|
|
|
+ var parameters = new Array();
|
|
|
+
|
|
|
+ // Parameters
|
|
|
+ if (parsedAction.type == Types.FLOW_CONTROL)
|
|
|
+ parameters.push(actionManager);
|
|
|
+ else
|
|
|
+ parameters.push(trigger);
|
|
|
+
|
|
|
+ for (var i = 0; i < parsedAction.properties.length; i++) {
|
|
|
+ var value = parsedAction.properties[i].value;
|
|
|
+ if (parsedAction.properties[i].name == "target") {
|
|
|
+ value = getObjectByName(value);
|
|
|
+ } else if (parsedAction.properties[i].name != "propertyPath") {
|
|
|
+ if (value == "false" || value == "true")
|
|
|
+ value = value == "true";
|
|
|
+ else if (parsedAction.type == Types.FLOW_CONTROL && parsedAction.properties[i].name == "operator")
|
|
|
+ value = BABYLON.ValueCondition[value];
|
|
|
+ else
|
|
|
+ value = parseFloat(value);
|
|
|
+ }
|
|
|
+ parameters.push(value);
|
|
|
+ }
|
|
|
+ parameters.push(condition);
|
|
|
+
|
|
|
+ // If interpolate value action
|
|
|
+ if (parsedAction.name == "InterpolateValueAction") {
|
|
|
+ var param = parameters[parameters.length - 2];
|
|
|
+ parameters[parameters.length - 1] = param;
|
|
|
+ parameters[parameters.length - 2] = condition;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Action or condition
|
|
|
+ var newAction = instanciate(parsedAction.name, parameters);
|
|
|
+ if (newAction instanceof BABYLON.Condition) {
|
|
|
+ condition = newAction;
|
|
|
+ newAction = action;
|
|
|
+ } else {
|
|
|
+ condition = null;
|
|
|
+ if (action)
|
|
|
+ action.then(newAction);
|
|
|
+ else
|
|
|
+ actionManager.registerAction(newAction);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (var i = 0; i < parsedAction.children.length; i++)
|
|
|
+ traverse(parsedAction.children[i], trigger, condition, newAction, actionManager);
|
|
|
+ };
|
|
|
+
|
|
|
+ for (var i = 0; i < parsedActions.children.length; i++) {
|
|
|
+ var triggerParams;
|
|
|
+ var trigger = parsedActions.children[i];
|
|
|
+
|
|
|
+ if (trigger.properties.length > 0) {
|
|
|
+ triggerParams = { trigger: BABYLON.ActionManager[trigger.name], parameter: scene.getMeshByName(trigger.properties[0].value) };
|
|
|
+ } else
|
|
|
+ triggerParams = BABYLON.ActionManager[trigger.name];
|
|
|
+
|
|
|
+ for (var j = 0; j < trigger.children.length; j++)
|
|
|
+ traverse(trigger.children[j], triggerParams, null, null, object.actionManager);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
var isDescendantOf = function (mesh, names, hierarchyIds) {
|
|
|
names = (names instanceof Array) ? names : [names];
|
|
|
for (var i in names) {
|
|
@@ -22405,6 +22512,10 @@ var BABYLON;
|
|
|
mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
|
|
|
mesh._waitingParentId = undefined;
|
|
|
}
|
|
|
+ if (mesh._waitingActions) {
|
|
|
+ parseActions(mesh._waitingActions, mesh, scene);
|
|
|
+ mesh._waitingActions = undefined;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Particles Systems
|
|
@@ -22432,6 +22543,11 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Actions (scene)
|
|
|
+ if (parsedData.actions) {
|
|
|
+ parseActions(parsedData.actions, scene, scene);
|
|
|
+ }
|
|
|
+
|
|
|
// Finish
|
|
|
return true;
|
|
|
}
|
|
@@ -31066,7 +31182,7 @@ var BABYLON;
|
|
|
this._mesh = _mesh;
|
|
|
this.initialised = false;
|
|
|
this.syncIterations = 5000;
|
|
|
- this.agressiveness = 7;
|
|
|
+ this.aggressiveness = 7;
|
|
|
this.decimationIterations = 100;
|
|
|
}
|
|
|
QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
|
|
@@ -31093,7 +31209,7 @@ var BABYLON;
|
|
|
_this.triangles[i].isDirty = false;
|
|
|
}
|
|
|
|
|
|
- var threshold = 0.000000001 * Math.pow((iteration + 3), _this.agressiveness);
|
|
|
+ var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
|
|
|
|
|
|
var trianglesIterator = function (i) {
|
|
|
var t = _this.triangles[i];
|