David Catuhe 11 years ago
parent
commit
fa64e35da4
32 changed files with 905 additions and 44 deletions
  1. 56 0
      Babylon/Actions/babylon.action.js
  2. 59 0
      Babylon/Actions/babylon.action.ts
  3. 79 0
      Babylon/Actions/babylon.actionManager.js
  4. 81 0
      Babylon/Actions/babylon.actionManager.ts
  5. 89 0
      Babylon/Actions/babylon.condition.js
  6. 83 0
      Babylon/Actions/babylon.condition.ts
  7. 136 0
      Babylon/Actions/babylon.directActions.js
  8. 110 0
      Babylon/Actions/babylon.directActions.ts
  9. 60 0
      Babylon/Actions/babylon.interpolateValueAction.js
  10. 47 0
      Babylon/Actions/babylon.interpolateValueAction.ts
  11. 3 2
      Babylon/Animations/babylon.animatable.js
  12. 4 2
      Babylon/Animations/babylon.animatable.ts
  13. 1 0
      Babylon/Lights/babylon.light.js
  14. 1 0
      Babylon/Lights/babylon.light.ts
  15. 9 0
      Babylon/Loading/Plugins/babylon.babylonFileLoader.js
  16. 1 0
      Babylon/Materials/babylon.effect.js
  17. 1 0
      Babylon/Materials/babylon.effect.ts
  18. 0 1
      Babylon/Materials/babylon.material.js
  19. 1 1
      Babylon/Materials/babylon.material.ts
  20. 2 1
      Babylon/Materials/babylon.shaderMaterial.js
  21. 2 1
      Babylon/Materials/babylon.shaderMaterial.ts
  22. 1 1
      Babylon/Materials/babylon.standardMaterial.js
  23. 1 1
      Babylon/Materials/babylon.standardMaterial.ts
  24. 0 16
      Babylon/Math/babylon.axis.js
  25. 1 1
      Babylon/Mesh/babylon.mesh.js
  26. 2 1
      Babylon/Mesh/babylon.mesh.ts
  27. 22 16
      Babylon/Shaders/default.fragment.fx
  28. 4 0
      Babylon/Tools/babylon.sceneSerializer.js
  29. 4 0
      Babylon/Tools/babylon.sceneSerializer.ts
  30. 20 0
      Babylon/babylon.scene.js
  31. 20 0
      Babylon/babylon.scene.ts
  32. 5 0
      Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJS/babylonJS.xml

+ 56 - 0
Babylon/Actions/babylon.action.js

@@ -0,0 +1,56 @@
+var BABYLON;
+(function (BABYLON) {
+    var Action = (function () {
+        function Action(trigger, condition) {
+            this.trigger = trigger;
+            this._nextActiveAction = this;
+            this._condition = condition;
+        }
+        // Methods
+        Action.prototype._prepare = function () {
+        };
+
+        Action.prototype._executeCurrent = function () {
+            if (this._condition) {
+                if (!this._condition.isValid()) {
+                    return;
+                }
+            }
+
+            this._nextActiveAction.execute();
+
+            if (this._nextActiveAction._child) {
+                this._nextActiveAction = this._nextActiveAction._child;
+            } else {
+                this._nextActiveAction = this;
+            }
+        };
+
+        Action.prototype.execute = function () {
+        };
+
+        Action.prototype.then = function (action) {
+            this._child = action;
+
+            action._actionManager = this._actionManager;
+            action._prepare();
+
+            return action;
+        };
+
+        Action.prototype._getTarget = function (targetType, targetName) {
+            return this._actionManager._getTarget(targetType, targetName);
+        };
+
+        Action.prototype._getProperty = function (propertyPath) {
+            return this._actionManager._getProperty(propertyPath);
+        };
+
+        Action.prototype._getEffectiveTarget = function (target, propertyPath) {
+            return this._actionManager._getEffectiveTarget(target, propertyPath);
+        };
+        return Action;
+    })();
+    BABYLON.Action = Action;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.action.js.map

+ 59 - 0
Babylon/Actions/babylon.action.ts

@@ -0,0 +1,59 @@
+module BABYLON {
+    export class Action {
+        public _actionManager: ActionManager;
+
+        private _nextActiveAction;
+        private _child;
+        private _condition: Condition;
+
+        constructor(public trigger: number, condition?: Condition) {
+            this._nextActiveAction = this;
+            this._condition = condition;
+        }
+
+        // Methods
+        public _prepare(): void {
+        }
+
+        public _executeCurrent(): void {
+            if (this._condition) {
+                if (!this._condition.isValid()) {
+                    return;
+                }
+            }
+
+            this._nextActiveAction.execute();
+
+            if (this._nextActiveAction._child) {
+                this._nextActiveAction = this._nextActiveAction._child;
+            } else {
+                this._nextActiveAction = this;
+            }
+        }
+
+        public execute(): void {
+
+        }
+
+        public then(action: Action): Action {
+            this._child = action;
+
+            action._actionManager = this._actionManager;
+            action._prepare();
+
+            return action;
+        }
+
+        public _getTarget(targetType: number, targetName: string): any {
+            return this._actionManager._getTarget(targetType, targetName);
+        }
+
+        public _getProperty(propertyPath: string): string {
+            return this._actionManager._getProperty(propertyPath);
+        }
+
+        public _getEffectiveTarget(target: any, propertyPath: string): any {
+            return this._actionManager._getEffectiveTarget(target, propertyPath);
+        }
+    }
+}

+ 79 - 0
Babylon/Actions/babylon.actionManager.js

@@ -0,0 +1,79 @@
+var BABYLON;
+(function (BABYLON) {
+    var ActionManager = (function () {
+        function ActionManager(scene) {
+            // Members
+            this.actions = new Array();
+            this._scene = scene;
+        }
+        // Methods
+        ActionManager.prototype.getScene = function () {
+            return this._scene;
+        };
+
+        ActionManager.prototype.registerAction = function (action) {
+            this.actions.push(action);
+
+            action._actionManager = this;
+            action._prepare();
+
+            return action;
+        };
+
+        ActionManager.prototype.processTrigger = function (trigger) {
+            for (var index = 0; index < this.actions.length; index++) {
+                var action = this.actions[index];
+
+                if (action.trigger === trigger) {
+                    action._executeCurrent();
+                }
+            }
+        };
+
+        ActionManager.prototype._getTarget = function (targetType, targetName) {
+            var scene = this._scene;
+
+            switch (targetType) {
+                case ActionManager.SceneTarget:
+                    return scene;
+                case ActionManager.MeshTarget:
+                    return scene.getMeshByName(targetName);
+                case ActionManager.LightTarget:
+                    return scene.getLightByName(targetName);
+                case ActionManager.CameraTarget:
+                    return scene.getCameraByName(targetName);
+                case ActionManager.MaterialTarget:
+                    return scene.getMaterialByName(targetName);
+            }
+
+            return null;
+        };
+
+        ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
+            var properties = propertyPath.split(".");
+
+            for (var index = 0; index < properties.length - 1; index++) {
+                target = target[properties[index]];
+            }
+
+            return target;
+        };
+
+        ActionManager.prototype._getProperty = function (propertyPath) {
+            var properties = propertyPath.split(".");
+
+            return properties[properties.length - 1];
+        };
+        ActionManager.AlwaysTrigger = 0;
+        ActionManager.OnPickTrigger = 1;
+
+        ActionManager.SceneTarget = 0;
+        ActionManager.MeshTarget = 1;
+        ActionManager.LightTarget = 2;
+        ActionManager.CameraTarget = 3;
+        ActionManager.MaterialTarget = 4;
+        return ActionManager;
+    })();
+    BABYLON.ActionManager = ActionManager;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.actionManager.js.map

+ 81 - 0
Babylon/Actions/babylon.actionManager.ts

@@ -0,0 +1,81 @@
+module BABYLON {
+    export class ActionManager {
+        // Statics
+        public static AlwaysTrigger = 0;
+        public static OnPickTrigger = 1;
+
+        public static SceneTarget = 0;
+        public static MeshTarget = 1;
+        public static LightTarget = 2;
+        public static CameraTarget = 3;
+        public static MaterialTarget = 4;
+
+        // Members
+        public actions = new Array<Action>();
+
+        private _scene: Scene;
+
+        constructor(scene: Scene) {
+            this._scene = scene;
+        }
+
+        // Methods
+        public getScene(): Scene {
+            return this._scene;
+        }
+
+        public registerAction(action: Action): Action {
+            this.actions.push(action);
+
+            action._actionManager = this;
+            action._prepare();
+
+            return action;
+        }
+
+        public processTrigger(trigger: number): void {
+            for (var index = 0; index < this.actions.length; index++) {
+                var action = this.actions[index];
+
+                if (action.trigger === trigger) {
+                    action._executeCurrent();
+                }
+            }
+        }
+
+        public _getTarget(targetType: number, targetName: string): any {
+            var scene = this._scene;
+
+            switch (targetType) {
+                case ActionManager.SceneTarget:
+                    return scene;
+                case ActionManager.MeshTarget:
+                    return scene.getMeshByName(targetName);
+                case ActionManager.LightTarget:
+                    return scene.getLightByName(targetName);
+                case ActionManager.CameraTarget:
+                    return scene.getCameraByName(targetName);
+                case ActionManager.MaterialTarget:
+                    return scene.getMaterialByName(targetName);
+            }
+
+            return null;
+        }
+
+        public _getEffectiveTarget(target: any, propertyPath: string): any {
+            var properties = propertyPath.split(".");
+
+            for (var index = 0; index < properties.length - 1; index++) {
+                target = target[properties[index]];
+            }
+
+            return target;
+        }
+
+        public _getProperty(propertyPath: string): string {
+            var properties = propertyPath.split(".");
+
+            return properties[properties.length - 1];
+        }
+    }
+} 

+ 89 - 0
Babylon/Actions/babylon.condition.js

@@ -0,0 +1,89 @@
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var Condition = (function () {
+        function Condition(actionManager) {
+            this._actionManager = actionManager;
+        }
+        Condition.prototype.isValid = function () {
+            return true;
+        };
+
+        Condition.prototype._getTarget = function (targetType, targetName) {
+            return this._actionManager._getTarget(targetType, targetName);
+        };
+
+        Condition.prototype._getProperty = function (propertyPath) {
+            return this._actionManager._getProperty(propertyPath);
+        };
+
+        Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
+            return this._actionManager._getEffectiveTarget(target, propertyPath);
+        };
+        return Condition;
+    })();
+    BABYLON.Condition = Condition;
+
+    var StateCondition = (function (_super) {
+        __extends(StateCondition, _super);
+        function StateCondition(actionManager, targetType, targetName, propertyPath, value, operator) {
+            if (typeof operator === "undefined") { operator = StateCondition.IsEqual; }
+            _super.call(this, actionManager);
+            this.targetType = targetType;
+            this.targetName = targetName;
+            this.propertyPath = propertyPath;
+            this.value = value;
+            this.operator = operator;
+
+            this._target = this._getTarget(this.targetType, this.targetName);
+            this._target = this._getEffectiveTarget(this._target, this.propertyPath);
+            this._property = this._getProperty(this.propertyPath);
+        }
+        // Methods
+        StateCondition.prototype.isValid = function () {
+            switch (this.operator) {
+                case StateCondition.IsGreater:
+                    return this._target[this._property] > this.value;
+                case StateCondition.IsLesser:
+                    return this._target[this._property] < this.value;
+                case StateCondition.IsEqual:
+                case StateCondition.IsDifferent:
+                    var check;
+
+                    if (this.value.equals) {
+                        check = this.value.equals(this._target[this._property]);
+                    } else {
+                        check = this.value === this._target[this._property];
+                    }
+                    return this.operator === StateCondition.IsEqual ? check : !check;
+            }
+
+            return false;
+        };
+        StateCondition.IsEqual = 0;
+        StateCondition.IsDifferent = 1;
+        StateCondition.IsGreater = 2;
+        StateCondition.IsLesser = 3;
+        return StateCondition;
+    })(Condition);
+    BABYLON.StateCondition = StateCondition;
+
+    var PredicateCondition = (function (_super) {
+        __extends(PredicateCondition, _super);
+        function PredicateCondition(actionManager, predicate) {
+            _super.call(this, actionManager);
+            this.predicate = predicate;
+        }
+        PredicateCondition.prototype.isValid = function () {
+            return this.predicate();
+        };
+        return PredicateCondition;
+    })(Condition);
+    BABYLON.PredicateCondition = PredicateCondition;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.condition.js.map

+ 83 - 0
Babylon/Actions/babylon.condition.ts

@@ -0,0 +1,83 @@
+module BABYLON {
+    export class Condition {
+        public _actionManager: ActionManager;
+
+        constructor(actionManager: ActionManager) {
+            this._actionManager = actionManager;
+        }
+
+        public isValid(): boolean {
+            return true;
+        }
+
+        public _getTarget(targetType: number, targetName: string): any {
+            return this._actionManager._getTarget(targetType, targetName);
+        }
+
+        public _getProperty(propertyPath: string): string {
+            return this._actionManager._getProperty(propertyPath);
+        }
+
+        public _getEffectiveTarget(target: any, propertyPath: string): any {
+            return this._actionManager._getEffectiveTarget(target, propertyPath);
+        }
+    }
+
+    export class StateCondition extends Condition {
+        // Statics
+        public static IsEqual = 0;
+        public static IsDifferent = 1;
+        public static IsGreater= 2;
+        public static IsLesser = 3;
+
+        // Members
+        public _actionManager: ActionManager;
+
+        private _target: any;
+        private _property: string;
+
+        constructor(actionManager: ActionManager, public targetType: number, public targetName: string, public propertyPath: string, public value: any, public operator: number = StateCondition.IsEqual) {
+            super(actionManager);
+
+            this._target = this._getTarget(this.targetType, this.targetName);
+            this._target = this._getEffectiveTarget(this._target, this.propertyPath);
+            this._property = this._getProperty(this.propertyPath);
+        }
+
+        // Methods
+        public isValid(): boolean {
+            switch (this.operator) {
+                case StateCondition.IsGreater:
+                    return this._target[this._property] > this.value;
+                case StateCondition.IsLesser:
+                    return this._target[this._property] < this.value;
+                case StateCondition.IsEqual:
+                case StateCondition.IsDifferent:
+                    var check: boolean;
+
+                    if (this.value.equals) {
+                        check = this.value.equals(this._target[this._property]);
+                    } else {
+                        check = this.value === this._target[this._property];
+                    }
+                    return this.operator === StateCondition.IsEqual ? check: !check;
+            }
+
+            return false;
+        }
+    }
+
+    export class PredicateCondition extends Condition {
+        // Members
+        public _actionManager: ActionManager;
+
+
+        constructor(actionManager: ActionManager, public predicate: () => boolean) {
+            super(actionManager);
+        }
+
+        public isValid(): boolean {
+            return this.predicate();
+        }
+    }
+}

+ 136 - 0
Babylon/Actions/babylon.directActions.js

@@ -0,0 +1,136 @@
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var SwitchBooleanAction = (function (_super) {
+        __extends(SwitchBooleanAction, _super);
+        function SwitchBooleanAction(trigger, targetType, targetName, propertyPath, condition) {
+            _super.call(this, trigger, condition);
+            this.targetType = targetType;
+            this.targetName = targetName;
+            this.propertyPath = propertyPath;
+        }
+        SwitchBooleanAction.prototype._prepare = function () {
+            this._target = this._getTarget(this.targetType, this.targetName);
+            this._target = this._getEffectiveTarget(this._target, this.propertyPath);
+            this._property = this._getProperty(this.propertyPath);
+        };
+
+        SwitchBooleanAction.prototype.execute = function () {
+            this._target[this._property] = !this._target[this._property];
+        };
+        return SwitchBooleanAction;
+    })(BABYLON.Action);
+    BABYLON.SwitchBooleanAction = SwitchBooleanAction;
+
+    var SetValueAction = (function (_super) {
+        __extends(SetValueAction, _super);
+        function SetValueAction(trigger, targetType, targetName, propertyPath, value, condition) {
+            _super.call(this, trigger, condition);
+            this.targetType = targetType;
+            this.targetName = targetName;
+            this.propertyPath = propertyPath;
+            this.value = value;
+        }
+        SetValueAction.prototype._prepare = function () {
+            this._target = this._getTarget(this.targetType, this.targetName);
+            this._target = this._getEffectiveTarget(this._target, this.propertyPath);
+            this._property = this._getProperty(this.propertyPath);
+        };
+
+        SetValueAction.prototype.execute = function () {
+            this._target[this._property] = this.value;
+        };
+        return SetValueAction;
+    })(BABYLON.Action);
+    BABYLON.SetValueAction = SetValueAction;
+
+    var PlayAnimationAction = (function (_super) {
+        __extends(PlayAnimationAction, _super);
+        function PlayAnimationAction(trigger, targetType, targetName, from, to, loop, condition) {
+            _super.call(this, trigger, condition);
+            this.targetType = targetType;
+            this.targetName = targetName;
+            this.from = from;
+            this.to = to;
+            this.loop = loop;
+        }
+        PlayAnimationAction.prototype._prepare = function () {
+            this._target = this._getTarget(this.targetType, this.targetName);
+        };
+
+        PlayAnimationAction.prototype.execute = function () {
+            var scene = this._actionManager.getScene();
+            scene.beginAnimation(this._target, this.from, this.to, this.loop);
+        };
+        return PlayAnimationAction;
+    })(BABYLON.Action);
+    BABYLON.PlayAnimationAction = PlayAnimationAction;
+
+    var StopAnimationAction = (function (_super) {
+        __extends(StopAnimationAction, _super);
+        function StopAnimationAction(trigger, targetType, targetName, condition) {
+            _super.call(this, trigger, condition);
+            this.targetType = targetType;
+            this.targetName = targetName;
+        }
+        StopAnimationAction.prototype._prepare = function () {
+            this._target = this._getTarget(this.targetType, this.targetName);
+        };
+
+        StopAnimationAction.prototype.execute = function () {
+            var scene = this._actionManager.getScene();
+            scene.stopAnimation(this._target);
+        };
+        return StopAnimationAction;
+    })(BABYLON.Action);
+    BABYLON.StopAnimationAction = StopAnimationAction;
+
+    var ExecuteCodeAction = (function (_super) {
+        __extends(ExecuteCodeAction, _super);
+        function ExecuteCodeAction(trigger, func, condition) {
+            _super.call(this, trigger, condition);
+            this.func = func;
+        }
+        ExecuteCodeAction.prototype.execute = function () {
+            this.func();
+        };
+        return ExecuteCodeAction;
+    })(BABYLON.Action);
+    BABYLON.ExecuteCodeAction = ExecuteCodeAction;
+
+    var SetParentAction = (function (_super) {
+        __extends(SetParentAction, _super);
+        function SetParentAction(trigger, targetType, targetName, parentType, parentName, condition) {
+            _super.call(this, trigger, condition);
+            this.targetType = targetType;
+            this.targetName = targetName;
+            this.parentType = parentType;
+            this.parentName = parentName;
+        }
+        SetParentAction.prototype._prepare = function () {
+            this._target = this._getTarget(this.targetType, this.targetName);
+            this._parent = this._getTarget(this.parentType, this.parentName);
+        };
+
+        SetParentAction.prototype.execute = function () {
+            if (this._target.parent === this._parent) {
+                return;
+            }
+
+            var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
+            invertParentWorldMatrix.invert();
+
+            this._target.position = BABYLON.Vector3.TransformCoordinates(this._target.position, invertParentWorldMatrix);
+
+            this._target.parent = this._parent;
+        };
+        return SetParentAction;
+    })(BABYLON.Action);
+    BABYLON.SetParentAction = SetParentAction;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.directActions.js.map

+ 110 - 0
Babylon/Actions/babylon.directActions.ts

@@ -0,0 +1,110 @@
+module BABYLON {
+    export class SwitchBooleanAction extends Action {
+        private _target: any;
+        private _property: string;
+
+        constructor(trigger: number, public targetType: number, public targetName: string, public propertyPath: string, condition?: Condition) {
+            super(trigger, condition);
+        }
+
+        public _prepare(): void {
+            this._target = this._getTarget(this.targetType, this.targetName);
+            this._target = this._getEffectiveTarget(this._target, this.propertyPath);
+            this._property = this._getProperty(this.propertyPath);
+        }
+
+        public execute(): void {
+            this._target[this._property] = !this._target[this._property];
+        }
+    }
+
+    export class SetValueAction extends Action {
+        private _target: any;
+        private _property: string;
+
+        constructor(trigger: number, public targetType: number, public targetName: string, public propertyPath: string, public value: any, condition?: Condition) {
+            super(trigger, condition);
+        }
+
+        public _prepare(): void {
+            this._target = this._getTarget(this.targetType, this.targetName);
+            this._target = this._getEffectiveTarget(this._target, this.propertyPath);
+            this._property = this._getProperty(this.propertyPath);
+        }
+
+        public execute(): void {
+            this._target[this._property] = this.value;
+        }
+    }
+
+    export class PlayAnimationAction extends Action {
+        private _target: any;
+
+        constructor(trigger: number, public targetType: number, public targetName: string, public from: number, public to: number, public loop?: boolean, condition?: Condition) {
+            super(trigger, condition);
+        }
+
+        public _prepare(): void {
+            this._target = this._getTarget(this.targetType, this.targetName);
+        }
+
+        public execute(): void {
+            var scene = this._actionManager.getScene();
+            scene.beginAnimation(this._target, this.from, this.to, this.loop);
+        }
+    }
+
+    export class StopAnimationAction extends Action {
+        private _target: any;
+
+        constructor(trigger: number, public targetType: number, public targetName: string, condition?: Condition) {
+            super(trigger, condition);
+        }
+
+        public _prepare(): void {
+            this._target = this._getTarget(this.targetType, this.targetName);
+        }
+
+        public execute(): void {
+            var scene = this._actionManager.getScene();
+            scene.stopAnimation(this._target);
+        }
+    }
+
+    export class ExecuteCodeAction extends Action {
+        constructor(trigger: number, public func: () => void, condition?: Condition) {
+            super(trigger, condition);
+        }
+
+        public execute(): void {
+            this.func();
+        }
+    }
+
+    export class SetParentAction extends Action {
+        private _parent: any;
+        private _target: any;
+
+        constructor(trigger: number, public targetType: number, public targetName: string, public parentType: number, public parentName: string, condition?: Condition) {
+            super(trigger, condition);
+        }
+
+        public _prepare(): void {
+            this._target = this._getTarget(this.targetType, this.targetName);
+            this._parent = this._getTarget(this.parentType, this.parentName);
+        }
+
+        public execute(): void {
+            if (this._target.parent === this._parent) {
+                return;
+            }
+
+            var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
+            invertParentWorldMatrix.invert();
+
+            this._target.position = BABYLON.Vector3.TransformCoordinates(this._target.position, invertParentWorldMatrix);
+
+            this._target.parent = this._parent;
+        }
+    }
+} 

+ 60 - 0
Babylon/Actions/babylon.interpolateValueAction.js

@@ -0,0 +1,60 @@
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var InterpolateValueAction = (function (_super) {
+        __extends(InterpolateValueAction, _super);
+        function InterpolateValueAction(trigger, targetType, targetName, propertyPath, value, duration, condition) {
+            if (typeof duration === "undefined") { duration = 1000; }
+            _super.call(this, trigger, condition);
+            this.targetType = targetType;
+            this.targetName = targetName;
+            this.propertyPath = propertyPath;
+            this.value = value;
+            this.duration = duration;
+        }
+        InterpolateValueAction.prototype._prepare = function () {
+            this._target = this._getTarget(this.targetType, this.targetName);
+            this._target = this._getEffectiveTarget(this._target, this.propertyPath);
+            this._property = this._getProperty(this.propertyPath);
+        };
+
+        InterpolateValueAction.prototype.execute = function () {
+            var scene = this._actionManager.getScene();
+            var keys = [
+                {
+                    frame: 0,
+                    value: this._target[this._property]
+                }, {
+                    frame: 100,
+                    value: this.value
+                }
+            ];
+
+            var dataType = BABYLON.Animation.ANIMATIONTYPE_FLOAT;
+
+            if (this.value instanceof BABYLON.Color3) {
+                dataType = BABYLON.Animation.ANIMATIONTYPE_COLOR3;
+            } else if (this.value instanceof BABYLON.Vector3) {
+                dataType = BABYLON.Animation.ANIMATIONTYPE_VECTOR3;
+            } else if (this.value instanceof BABYLON.Matrix) {
+                dataType = BABYLON.Animation.ANIMATIONTYPE_MATRIX;
+            } else if (this.value instanceof BABYLON.Quaternion) {
+                dataType = BABYLON.Animation.ANIMATIONTYPE_QUATERNION;
+            }
+
+            var animation = new BABYLON.Animation("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
+
+            animation.setKeys(keys);
+
+            scene.beginDirectAnimation(this._target, [animation], 0, 100);
+        };
+        return InterpolateValueAction;
+    })(BABYLON.Action);
+    BABYLON.InterpolateValueAction = InterpolateValueAction;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.interpolateValueAction.js.map

+ 47 - 0
Babylon/Actions/babylon.interpolateValueAction.ts

@@ -0,0 +1,47 @@
+module BABYLON {
+    export class InterpolateValueAction extends Action {
+        private _target: any;
+        private _property: string;
+
+        constructor(trigger: number, public targetType: number, public targetName: string, public propertyPath: string, public value: any, public duration: number = 1000, condition?: Condition) {
+            super(trigger, condition);
+        }
+
+        public _prepare(): void {
+            this._target = this._getTarget(this.targetType, this.targetName);
+            this._target = this._getEffectiveTarget(this._target, this.propertyPath);
+            this._property = this._getProperty(this.propertyPath);
+        }
+
+        public execute(): void {
+            var scene = this._actionManager.getScene();
+            var keys = [
+                {
+                    frame: 0,
+                    value: this._target[this._property]
+                }, {
+                    frame: 100,
+                    value: this.value
+                }
+            ];
+
+            var dataType: number = Animation.ANIMATIONTYPE_FLOAT;
+
+            if (this.value instanceof Color3) {
+                dataType = Animation.ANIMATIONTYPE_COLOR3;
+            } else if (this.value instanceof Vector3) {
+                dataType = Animation.ANIMATIONTYPE_VECTOR3;
+            } else if (this.value instanceof Matrix) {
+                dataType = Animation.ANIMATIONTYPE_MATRIX;
+            } else if (this.value instanceof Quaternion) {
+                dataType = Animation.ANIMATIONTYPE_QUATERNION;
+            } 
+
+            var animation = new BABYLON.Animation("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, Animation.ANIMATIONLOOPMODE_CONSTANT);
+
+            animation.setKeys(keys);
+
+            scene.beginDirectAnimation(this._target, [animation], 0, 100);
+        }
+    }
+} 

+ 3 - 2
Babylon/Animations/babylon.animatable.js

@@ -2,7 +2,7 @@
 (function (BABYLON) {
     (function (Internals) {
         var Animatable = (function () {
-            function Animatable(target, fromFrame, toFrame, loopAnimation, speedRatio, onAnimationEnd) {
+            function Animatable(target, fromFrame, toFrame, loopAnimation, speedRatio, onAnimationEnd, animations) {
                 if (typeof fromFrame === "undefined") { fromFrame = 0; }
                 if (typeof toFrame === "undefined") { toFrame = 100; }
                 if (typeof loopAnimation === "undefined") { loopAnimation = false; }
@@ -14,6 +14,7 @@
                 this.speedRatio = speedRatio;
                 this.onAnimationEnd = onAnimationEnd;
                 this.animationStarted = false;
+                this._animations = animations;
             }
             // Methods
             Animatable.prototype._animate = function (delay) {
@@ -23,7 +24,7 @@
 
                 // Animating
                 var running = false;
-                var animations = this.target.animations;
+                var animations = this._animations || this.target.animations;
                 for (var index = 0; index < animations.length; index++) {
                     var isRunning = animations[index].animate(this.target, delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this.speedRatio);
                     running = running || isRunning;

+ 4 - 2
Babylon/Animations/babylon.animatable.ts

@@ -1,10 +1,12 @@
 module BABYLON.Internals {
     export class Animatable {
         private _localDelayOffset: number;
+        private _animations: any;
 
         public animationStarted = false;
 
-        constructor(public target, public fromFrame: number = 0, public toFrame: number = 100, public loopAnimation: boolean = false, public speedRatio: number = 1.0, public onAnimationEnd?) {
+        constructor(public target, public fromFrame: number = 0, public toFrame: number = 100, public loopAnimation: boolean = false, public speedRatio: number = 1.0, public onAnimationEnd?, animations?: any) {
+            this._animations = animations;
         }
 
         // Methods
@@ -15,7 +17,7 @@
 
             // Animating
             var running = false;
-            var animations = this.target.animations;
+            var animations = this._animations || this.target.animations;
             for (var index = 0; index < animations.length; index++) {
                 var isRunning = animations[index].animate(this.target, delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this.speedRatio);
                 running = running || isRunning;

+ 1 - 0
Babylon/Lights/babylon.light.js

@@ -13,6 +13,7 @@ var BABYLON;
             this.diffuse = new BABYLON.Color3(1.0, 1.0, 1.0);
             this.specular = new BABYLON.Color3(1.0, 1.0, 1.0);
             this.intensity = 1.0;
+            this.range = Number.MAX_VALUE;
             this.excludedMeshes = new Array();
 
             scene.lights.push(this);

+ 1 - 0
Babylon/Lights/babylon.light.ts

@@ -3,6 +3,7 @@
         public diffuse = new Color3(1.0, 1.0, 1.0);
         public specular = new Color3(1.0, 1.0, 1.0);
         public intensity = 1.0;
+        public range = Number.MAX_VALUE;
         public excludedMeshes = new Array<Mesh>();
 
         public _shadowGenerator: ShadowGenerator;

+ 9 - 0
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -291,6 +291,11 @@ var BABYLON = BABYLON || {};
         if (parsedLight.intensity) {
             light.intensity = parsedLight.intensity;
         }
+
+        if (parsedLight.range) {
+            light.range = parsedLight.range;
+        }
+
         light.diffuse = BABYLON.Color3.FromArray(parsedLight.diffuse);
         light.specular = BABYLON.Color3.FromArray(parsedLight.specular);
     };
@@ -369,6 +374,10 @@ var BABYLON = BABYLON || {};
         mesh.isVisible = parsedMesh.isVisible;
         mesh.infiniteDistance = parsedMesh.infiniteDistance;
 
+        if (parsedMesh.pickable !== undefined) {
+            mesh.isPickable = parsedMesh.pickable;
+        }
+
         mesh.receiveShadows = parsedMesh.receiveShadows;
 
         mesh.billboardMode = parsedMesh.billboardMode;

+ 1 - 0
Babylon/Materials/babylon.effect.js

@@ -156,6 +156,7 @@
                     console.error("Unable to compile effect: " + this.name);
                     console.error("Defines: " + defines);
                     console.error("Optional defines: " + optionalDefines);
+                    console.error("Error: " + e.message);
                     this._compilationError = e.message;
 
                     if (this.onError) {

+ 1 - 0
Babylon/Materials/babylon.effect.ts

@@ -170,6 +170,7 @@
                     console.error("Unable to compile effect: " + this.name);
                     console.error("Defines: " + defines);
                     console.error("Optional defines: " + optionalDefines);
+                    console.error("Error: " + e.message);
                     this._compilationError = e.message;
 
                     if (this.onError) {

+ 0 - 1
Babylon/Materials/babylon.material.js

@@ -8,7 +8,6 @@
             this.alpha = 1.0;
             this.wireframe = false;
             this.backFaceCulling = true;
-            this._effect = null;
             this._wasPreviouslyReady = false;
             this.id = name;
 

+ 1 - 1
Babylon/Materials/babylon.material.ts

@@ -11,7 +11,7 @@
         public onDispose: () => void;
         public getRenderTargetTextures: () => SmartArray;
 
-        public _effect = null;
+        public _effect: Effect;
         public _wasPreviouslyReady = false;
         private _scene: Scene;
 

+ 2 - 1
Babylon/Materials/babylon.shaderMaterial.js

@@ -153,7 +153,8 @@ var BABYLON;
             }
 
             for (name in this._colors4) {
-                this._effect.setColor4(name, this._colors4[name]);
+                var color = this._colors4[name];
+                this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
             }
 
             for (name in this._vectors2) {

+ 2 - 1
Babylon/Materials/babylon.shaderMaterial.ts

@@ -158,7 +158,8 @@
 
             // Color4      
             for (name in this._colors4) {
-                this._effect.setColor4(name, this._colors4[name]);
+                var color = this._colors4[name];
+                this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
             }
 
             // Vector2        

+ 1 - 1
Babylon/Materials/babylon.standardMaterial.js

@@ -373,7 +373,7 @@ var BABYLON;
 
                     light.diffuse.scaleToRef(light.intensity, this._scaledDiffuse);
                     light.specular.scaleToRef(light.intensity, this._scaledSpecular);
-                    this._effect.setColor3("vLightDiffuse" + lightIndex, this._scaledDiffuse);
+                    this._effect.setColor4("vLightDiffuse" + lightIndex, this._scaledDiffuse, light.range);
                     this._effect.setColor3("vLightSpecular" + lightIndex, this._scaledSpecular);
 
                     // Shadows

+ 1 - 1
Babylon/Materials/babylon.standardMaterial.ts

@@ -379,7 +379,7 @@
 
                     light.diffuse.scaleToRef(light.intensity, this._scaledDiffuse);
                     light.specular.scaleToRef(light.intensity, this._scaledSpecular);
-                    this._effect.setColor3("vLightDiffuse" + lightIndex, this._scaledDiffuse);
+                    this._effect.setColor4("vLightDiffuse" + lightIndex, this._scaledDiffuse, light.range);
                     this._effect.setColor3("vLightSpecular" + lightIndex, this._scaledSpecular);
 
                     // Shadows

+ 0 - 16
Babylon/Math/babylon.axis.js

@@ -1,16 +0,0 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-    BABYLON.Space = {
-        LOCAL: 0,
-        WORLD: 1
-    };
-
-    BABYLON.Axis =  {
-        X: new BABYLON.Vector3(1, 0, 0),
-        Y: new BABYLON.Vector3(0, 1, 0),
-        Z: new BABYLON.Vector3(0, 0, 1)
-    };
-})();

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

@@ -253,7 +253,7 @@ var BABYLON;
             if (property === "rotation") {
                 this.rotationQuaternion = null;
             }
-            this._currentRenderId = -1;
+            this._currentRenderId = Number.MAX_VALUE;
         };
 
         Mesh.prototype.refreshBoundingInfo = function () {

+ 2 - 1
Babylon/Mesh/babylon.mesh.ts

@@ -28,6 +28,7 @@
         public showBoundingBox = false;
         public subMeshes: SubMesh[];
         public delayLoadingFile: string;
+        public actionManager: ActionManager;
 
         // Cache
         private _positions = null;
@@ -271,7 +272,7 @@
             if (property === "rotation") {
                 this.rotationQuaternion = null;
             }
-            this._currentRenderId = -1;
+            this._currentRenderId = Number.MAX_VALUE;
         }
 
         public refreshBoundingInfo(): void {

+ 22 - 16
Babylon/Shaders/default.fragment.fx

@@ -27,7 +27,7 @@ varying vec3 vColor;
 // Lights
 #ifdef LIGHT0
 uniform vec4 vLightData0;
-uniform vec3 vLightDiffuse0;
+uniform vec4 vLightDiffuse0;
 uniform vec3 vLightSpecular0;
 #ifdef SHADOW0
 varying vec4 vPositionFromLight0;
@@ -44,7 +44,7 @@ uniform vec3 vLightGround0;
 
 #ifdef LIGHT1
 uniform vec4 vLightData1;
-uniform vec3 vLightDiffuse1;
+uniform vec4 vLightDiffuse1;
 uniform vec3 vLightSpecular1;
 #ifdef SHADOW1
 varying vec4 vPositionFromLight1;
@@ -61,7 +61,7 @@ uniform vec3 vLightGround1;
 
 #ifdef LIGHT2
 uniform vec4 vLightData2;
-uniform vec3 vLightDiffuse2;
+uniform vec4 vLightDiffuse2;
 uniform vec3 vLightSpecular2;
 #ifdef SHADOW2
 varying vec4 vPositionFromLight2;
@@ -78,7 +78,7 @@ uniform vec3 vLightGround2;
 
 #ifdef LIGHT3
 uniform vec4 vLightData3;
-uniform vec3 vLightDiffuse3;
+uniform vec4 vLightDiffuse3;
 uniform vec3 vLightSpecular3;
 #ifdef SHADOW3
 varying vec4 vPositionFromLight3;
@@ -317,13 +317,17 @@ struct lightingInfo
 	vec3 specular;
 };
 
-lightingInfo computeLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor) {
+lightingInfo computeLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor, float range) {
 	lightingInfo result;
 
 	vec3 lightVectorW;
+	float attenuation = 1.0;
 	if (lightData.w == 0.)
 	{
-		lightVectorW = normalize(lightData.xyz - vPositionW);
+		vec3 direction = lightData.xyz - vPositionW;
+
+		attenuation =  max(0., 1.0 - length(direction) / range);
+		lightVectorW = normalize(direction);
 	}
 	else
 	{
@@ -338,16 +342,18 @@ lightingInfo computeLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData,
 	float specComp = max(0., dot(vNormal, angleW));
 	specComp = pow(specComp, max(1., vSpecularColor.a));
 
-	result.diffuse = ndl * diffuseColor;
-	result.specular = specComp * specularColor;
+	result.diffuse = ndl * diffuseColor * attenuation;
+	result.specular = specComp * specularColor * attenuation;
 
 	return result;
 }
 
-lightingInfo computeSpotLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 lightDirection, vec3 diffuseColor, vec3 specularColor) {
+lightingInfo computeSpotLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 lightDirection, vec3 diffuseColor, vec3 specularColor, float range) {
 	lightingInfo result;
 
-	vec3 lightVectorW = normalize(lightData.xyz - vPositionW);
+	vec3 direction = lightData.xyz - vPositionW;
+	vec3 lightVectorW = normalize(direction);
+	float attenuation = max(0., 1.0 - length(direction) / range);
 
 	// diffuse
 	float cosAngle = max(0., dot(-lightDirection.xyz, lightVectorW));
@@ -366,8 +372,8 @@ lightingInfo computeSpotLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightDa
 		float specComp = max(0., dot(vNormal, angleW));
 		specComp = pow(specComp, vSpecularColor.a);
 
-		result.diffuse = ndl * spotAtten * diffuseColor;
-		result.specular = specComp * specularColor * spotAtten;
+		result.diffuse = ndl * spotAtten * diffuseColor * attenuation;
+		result.specular = specComp * specularColor * spotAtten * attenuation;
 
 		return result;
 	}
@@ -450,7 +456,7 @@ void main(void) {
 	lightingInfo info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0, vLightSpecular0, vLightGround0);
 #endif
 #ifdef POINTDIRLIGHT0
-	lightingInfo info = computeLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0, vLightSpecular0);
+	lightingInfo info = computeLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a);
 #endif
 #ifdef SHADOW0
 #ifdef SHADOWVSM0
@@ -473,7 +479,7 @@ void main(void) {
 	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1, vLightSpecular1, vLightGround1);
 #endif
 #ifdef POINTDIRLIGHT1
-	info = computeLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1, vLightSpecular1);
+	info = computeLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a);
 #endif
 #ifdef SHADOW1
 #ifdef SHADOWVSM1
@@ -496,7 +502,7 @@ void main(void) {
 	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2, vLightSpecular2, vLightGround2);
 #endif
 #ifdef POINTDIRLIGHT2
-	info = computeLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2, vLightSpecular2);
+	info = computeLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a);
 #endif
 #ifdef SHADOW2
 #ifdef SHADOWVSM2
@@ -519,7 +525,7 @@ void main(void) {
 	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3, vLightSpecular3, vLightGround3);
 #endif
 #ifdef POINTDIRLIGHT3
-	info = computeLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3, vLightSpecular3);
+	info = computeLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a);
 #endif
 #ifdef SHADOW3
 #ifdef SHADOWVSM3

+ 4 - 0
Babylon/Tools/babylon.sceneSerializer.js

@@ -29,6 +29,9 @@
         if (light.intensity) {
             serializationObject.intensity = light.intensity;
         }
+
+        serializationObject.range = light.range;
+
         serializationObject.diffuse = light.diffuse.asArray();
         serializationObject.specular = light.specular.asArray();
 
@@ -369,6 +372,7 @@
         serializationObject.isEnabled = mesh.isEnabled();
         serializationObject.isVisible = mesh.isVisible;
         serializationObject.infiniteDistance = mesh.infiniteDistance;
+        serializationObject.pickable = mesh.isPickable;
 
         serializationObject.receiveShadows = mesh.receiveShadows;
 

+ 4 - 0
Babylon/Tools/babylon.sceneSerializer.ts

@@ -29,6 +29,9 @@
         if (light.intensity) {
             serializationObject.intensity = light.intensity;
         }
+
+        serializationObject.range = light.range;
+
         serializationObject.diffuse = light.diffuse.asArray();
         serializationObject.specular = light.specular.asArray();
 
@@ -370,6 +373,7 @@
         serializationObject.isEnabled = mesh.isEnabled();
         serializationObject.isVisible = mesh.isVisible;
         serializationObject.infiniteDistance = mesh.infiniteDistance;
+        serializationObject.pickable = mesh.isPickable;
 
         serializationObject.receiveShadows = mesh.receiveShadows;
 

+ 20 - 0
Babylon/babylon.scene.js

@@ -262,6 +262,16 @@
             }
         };
 
+        Scene.prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd) {
+            if (speedRatio === undefined) {
+                speedRatio = 1.0;
+            }
+
+            var animatable = new BABYLON.Internals.Animatable(target, from, to, loop, speedRatio, onAnimationEnd, animations);
+
+            this._activeAnimatables.push(animatable);
+        };
+
         Scene.prototype.stopAnimation = function (target) {
             // Local animations
             if (target.animations) {
@@ -382,6 +392,16 @@
             return null;
         };
 
+        Scene.prototype.getLightByName = function (name) {
+            for (var index = 0; index < this.lights.length; index++) {
+                if (this.lights[index].name === name) {
+                    return this.lights[index];
+                }
+            }
+
+            return null;
+        };
+
         Scene.prototype.getLightByID = function (id) {
             for (var index = 0; index < this.lights.length; index++) {
                 if (this.lights[index].id === id) {

+ 20 - 0
Babylon/babylon.scene.ts

@@ -316,6 +316,16 @@
             }
         }
 
+        public beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): void {
+            if (speedRatio === undefined) {
+                speedRatio = 1.0;
+            }
+
+            var animatable = new BABYLON.Internals.Animatable(target, from, to, loop, speedRatio, onAnimationEnd, animations);
+
+            this._activeAnimatables.push(animatable);
+        }
+
         public stopAnimation(target: any): void {
             // Local animations
             if (target.animations) {
@@ -435,6 +445,16 @@
             return null;
         }
 
+        public getLightByName(name: string): Light {
+            for (var index = 0; index < this.lights.length; index++) {
+                if (this.lights[index].name === name) {
+                    return this.lights[index];
+                }
+            }
+
+            return null;
+        }
+
         public getLightByID(id: string): Light {
             for (var index = 0; index < this.lights.length; index++) {
                 if (this.lights[index].id === id) {

+ 5 - 0
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJS/babylonJS.xml

@@ -1,5 +1,10 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <files xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="babylonJS.xsd">
+  <script src="Babylon/Actions/babylon.condition.js"></script>
+  <script src="Babylon/Actions/babylon.action.js"></script>
+  <script src="Babylon/Actions/babylon.actionManager.js"></script>
+  <script src="Babylon/Actions/babylon.interpolateValueAction.js"></script>
+  <script src="Babylon/Actions/babylon.directActions.js"></script>
   <script src="Babylon/Rendering/babylon.boundingBoxRenderer.js"></script>
   <script src="Babylon/Materials/babylon.shaderMaterial.js"></script>
   <script src="Babylon/Cameras/babylon.virtualJoysticksCamera.js"></script>