Browse Source

Added @serialize to lights

David Catuhe 9 years ago
parent
commit
8360975db1

+ 1 - 1
Tools/Gulp/config.json

@@ -186,7 +186,7 @@
       "../../src/tools/hdr/babylon.tools.cubemaptosphericalpolynomial.js",
       "../../src/tools/hdr/babylon.tools.panoramatocubemap.js",
       "../../src/tools/hdr/babylon.tools.hdr.js",
-      "../../src/tools/hdr/babylon.tools.pmremgenerator.js",
+      "../../src/tools/hdr/babylon.tools.pmremGenerator.js",
       "../../src/materials/textures/babylon.hdrcubetexture.js"
     ]
   }

File diff suppressed because it is too large
+ 22 - 26
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 1225 - 1223
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 26 - 30
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 3484 - 3479
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 26 - 30
dist/preview release/babylon.noworker.js


+ 21 - 7
src/Lights/babylon.directionalLight.js

@@ -3,13 +3,18 @@ var __extends = (this && this.__extends) || function (d, b) {
     function __() { this.constructor = d; }
     d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
 };
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
 var BABYLON;
 (function (BABYLON) {
     var DirectionalLight = (function (_super) {
         __extends(DirectionalLight, _super);
         function DirectionalLight(name, direction, scene) {
             _super.call(this, name, scene);
-            this.direction = direction;
             this.shadowOrthoScale = 0.5;
             this.autoUpdateExtends = true;
             // Cache
@@ -18,6 +23,7 @@ var BABYLON;
             this._orthoTop = Number.MIN_VALUE;
             this._orthoBottom = Number.MAX_VALUE;
             this.position = direction.scale(-1);
+            this.direction = direction;
         }
         DirectionalLight.prototype.getAbsolutePosition = function () {
             return this.transformedPosition ? this.transformedPosition : this.position;
@@ -102,13 +108,21 @@ var BABYLON;
             BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
             return this._worldMatrix;
         };
-        DirectionalLight.prototype.serialize = function () {
-            var serializationObject = _super.prototype.serialize.call(this);
-            serializationObject.type = 1;
-            serializationObject.position = this.position.asArray();
-            serializationObject.direction = this.direction.asArray();
-            return serializationObject;
+        DirectionalLight.prototype.getTypeID = function () {
+            return 1;
         };
+        __decorate([
+            BABYLON.serializeAsVector3()
+        ], DirectionalLight.prototype, "position", void 0);
+        __decorate([
+            BABYLON.serializeAsVector3()
+        ], DirectionalLight.prototype, "direction", void 0);
+        __decorate([
+            BABYLON.serialize()
+        ], DirectionalLight.prototype, "shadowOrthoScale", void 0);
+        __decorate([
+            BABYLON.serialize()
+        ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
         return DirectionalLight;
     })(BABYLON.Light);
     BABYLON.DirectionalLight = DirectionalLight;

+ 10 - 8
src/Lights/babylon.directionalLight.ts

@@ -1,13 +1,19 @@
 module BABYLON {
     export class DirectionalLight extends Light implements IShadowLight {
+        @serializeAsVector3()
         public position: Vector3;
 
+        @serializeAsVector3()
+        public direction: Vector3
+
         private _transformedDirection: Vector3;
         public transformedPosition: Vector3;
         private _worldMatrix: Matrix;
 
+        @serialize()
         public shadowOrthoScale = 0.5;
 
+        @serialize()
         public autoUpdateExtends = true;
 
         // Cache
@@ -16,10 +22,11 @@
         private _orthoTop = Number.MIN_VALUE;
         private _orthoBottom = Number.MAX_VALUE;
 
-        constructor(name: string, public direction: Vector3, scene: Scene) {
+        constructor(name: string, direction: Vector3, scene: Scene) {
             super(name, scene);
 
             this.position = direction.scale(-1);
+            this.direction = direction;
         }
 
         public getAbsolutePosition(): Vector3 {
@@ -136,13 +143,8 @@
             return this._worldMatrix;
         }
 
-        public serialize(): any {
-            var serializationObject = super.serialize();
-            serializationObject.type = 1;
-            serializationObject.position = this.position.asArray();
-            serializationObject.direction = this.direction.asArray();
-
-            return serializationObject;
+        public getTypeID(): number {
+            return 1;
         }
     }
 }  

+ 15 - 7
src/Lights/babylon.hemisphericLight.js

@@ -3,14 +3,20 @@ var __extends = (this && this.__extends) || function (d, b) {
     function __() { this.constructor = d; }
     d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
 };
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
 var BABYLON;
 (function (BABYLON) {
     var HemisphericLight = (function (_super) {
         __extends(HemisphericLight, _super);
         function HemisphericLight(name, direction, scene) {
             _super.call(this, name, scene);
-            this.direction = direction;
             this.groundColor = new BABYLON.Color3(0.0, 0.0, 0.0);
+            this.direction = direction;
         }
         HemisphericLight.prototype.setDirectionToTarget = function (target) {
             this.direction = BABYLON.Vector3.Normalize(target.subtract(BABYLON.Vector3.Zero()));
@@ -30,13 +36,15 @@ var BABYLON;
             }
             return this._worldMatrix;
         };
-        HemisphericLight.prototype.serialize = function () {
-            var serializationObject = _super.prototype.serialize.call(this);
-            serializationObject.type = 3;
-            serializationObject.direction = this.direction.asArray();
-            serializationObject.groundColor = this.groundColor.asArray();
-            return serializationObject;
+        HemisphericLight.prototype.getTypeID = function () {
+            return 3;
         };
+        __decorate([
+            BABYLON.serializeAsColor3()
+        ], HemisphericLight.prototype, "groundColor", void 0);
+        __decorate([
+            BABYLON.serializeAsVector3()
+        ], HemisphericLight.prototype, "direction", void 0);
         return HemisphericLight;
     })(BABYLON.Light);
     BABYLON.HemisphericLight = HemisphericLight;

+ 9 - 8
src/Lights/babylon.hemisphericLight.ts

@@ -1,11 +1,17 @@
 module BABYLON {
     export class HemisphericLight extends Light {
+        @serializeAsColor3()
         public groundColor = new Color3(0.0, 0.0, 0.0);
 
+        @serializeAsVector3()
+        public direction: Vector3
+
         private _worldMatrix: Matrix;
 
-        constructor(name: string, public direction: Vector3, scene: Scene) {
+        constructor(name: string, direction: Vector3, scene: Scene) {
             super(name, scene);
+
+            this.direction = direction;
         }
 
         public setDirectionToTarget(target: Vector3): Vector3 {
@@ -31,13 +37,8 @@
             return this._worldMatrix;
         }
 
-        public serialize(): any {
-            var serializationObject = super.serialize();
-            serializationObject.type = 3;
-            serializationObject.direction = this.direction.asArray();
-            serializationObject.groundColor = this.groundColor.asArray();
-
-            return serializationObject;
+        public getTypeID(): number {
+            return 3;
         }
     }
 } 

+ 46 - 40
src/Lights/babylon.light.js

@@ -3,6 +3,12 @@ var __extends = (this && this.__extends) || function (d, b) {
     function __() { this.constructor = d; }
     d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
 };
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
 var BABYLON;
 (function (BABYLON) {
     var Light = (function (_super) {
@@ -75,65 +81,47 @@ var BABYLON;
             // Remove from scene
             this.getScene().removeLight(this);
         };
+        Light.prototype.getTypeID = function () {
+            return 0;
+        };
+        Light.prototype.clone = function (name) {
+            return BABYLON.SerializationHelper.Clone(Light.GetConstructorFromName(this.getTypeID(), name, this.getScene()), this);
+        };
         Light.prototype.serialize = function () {
-            var serializationObject = {};
-            serializationObject.name = this.name;
-            serializationObject.id = this.id;
-            serializationObject.tags = BABYLON.Tags.GetTags(this);
-            if (this.intensity) {
-                serializationObject.intensity = this.intensity;
-            }
+            var serializationObject = BABYLON.SerializationHelper.Serialize(this);
+            // Type
+            serializationObject.type = this.getTypeID();
             // Parent
             if (this.parent) {
                 serializationObject.parentId = this.parent.id;
             }
-            serializationObject.range = this.range;
-            serializationObject.radius = this.radius;
-            serializationObject.diffuse = this.diffuse.asArray();
-            serializationObject.specular = this.specular.asArray();
             return serializationObject;
         };
-        Light.Parse = function (parsedLight, scene) {
-            var light;
-            switch (parsedLight.type) {
+        Light.GetConstructorFromName = function (type, name, scene) {
+            switch (type) {
                 case 0:
-                    light = new BABYLON.PointLight(parsedLight.name, BABYLON.Vector3.FromArray(parsedLight.position), scene);
-                    break;
+                    return function () { return new BABYLON.PointLight(name, BABYLON.Vector3.Zero(), scene); };
                 case 1:
-                    light = new BABYLON.DirectionalLight(parsedLight.name, BABYLON.Vector3.FromArray(parsedLight.direction), scene);
-                    light.position = BABYLON.Vector3.FromArray(parsedLight.position);
-                    break;
+                    return function () { return new BABYLON.DirectionalLight(name, BABYLON.Vector3.Zero(), scene); };
                 case 2:
-                    light = new BABYLON.SpotLight(parsedLight.name, BABYLON.Vector3.FromArray(parsedLight.position), BABYLON.Vector3.FromArray(parsedLight.direction), parsedLight.angle, parsedLight.exponent, scene);
-                    break;
+                    return function () { return new BABYLON.SpotLight(name, BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), 0, 0, scene); };
                 case 3:
-                    light = new BABYLON.HemisphericLight(parsedLight.name, BABYLON.Vector3.FromArray(parsedLight.direction), scene);
-                    light.groundColor = BABYLON.Color3.FromArray(parsedLight.groundColor);
-                    break;
-            }
-            light.id = parsedLight.id;
-            BABYLON.Tags.AddTagsTo(light, parsedLight.tags);
-            if (parsedLight.intensity !== undefined) {
-                light.intensity = parsedLight.intensity;
-            }
-            if (parsedLight.range) {
-                light.range = parsedLight.range;
-            }
-            if (parsedLight.radius) {
-                light.radius = parsedLight.radius;
+                    return function () { return new BABYLON.HemisphericLight(name, BABYLON.Vector3.Zero(), scene); };
             }
-            light.diffuse = BABYLON.Color3.FromArray(parsedLight.diffuse);
-            light.specular = BABYLON.Color3.FromArray(parsedLight.specular);
+        };
+        Light.Parse = function (parsedLight, scene) {
+            var light = BABYLON.SerializationHelper.Parse(Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene), parsedLight, scene);
+            // Inclusion / exclusions
             if (parsedLight.excludedMeshesIds) {
                 light._excludedMeshesIds = parsedLight.excludedMeshesIds;
             }
+            if (parsedLight.includedOnlyMeshesIds) {
+                light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
+            }
             // Parent
             if (parsedLight.parentId) {
                 light._waitingParentId = parsedLight.parentId;
             }
-            if (parsedLight.includedOnlyMeshesIds) {
-                light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
-            }
             // Animations
             if (parsedLight.animations) {
                 for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
@@ -147,6 +135,24 @@ var BABYLON;
             }
             return light;
         };
+        __decorate([
+            BABYLON.serializeAsColor3()
+        ], Light.prototype, "diffuse", void 0);
+        __decorate([
+            BABYLON.serializeAsColor3()
+        ], Light.prototype, "specular", void 0);
+        __decorate([
+            BABYLON.serialize()
+        ], Light.prototype, "intensity", void 0);
+        __decorate([
+            BABYLON.serialize()
+        ], Light.prototype, "range", void 0);
+        __decorate([
+            BABYLON.serialize()
+        ], Light.prototype, "includeOnlyWithLayerMask", void 0);
+        __decorate([
+            BABYLON.serialize()
+        ], Light.prototype, "radius", void 0);
         return Light;
     })(BABYLON.Node);
     BABYLON.Light = Light;

+ 37 - 50
src/Lights/babylon.light.ts

@@ -21,16 +21,27 @@
     }
 
     export class Light extends Node {
+        @serializeAsColor3()
         public diffuse = new Color3(1.0, 1.0, 1.0);
+
+        @serializeAsColor3()
         public specular = new Color3(1.0, 1.0, 1.0);
+
+        @serialize()
         public intensity = 1.0;
+
+        @serialize()
         public range = Number.MAX_VALUE;
+
+        @serialize()
         public includeOnlyWithLayerMask = 0;
+
         public includedOnlyMeshes = new Array<AbstractMesh>();
         public excludedMeshes = new Array<AbstractMesh>();
         public excludeWithLayerMask = 0;
 
         // PBR Properties.
+        @serialize()
         public radius = 0.00001;
 
         public _shadowGenerator: ShadowGenerator;
@@ -116,82 +127,58 @@
             this.getScene().removeLight(this);
         }
 
+        public getTypeID(): number {
+            return 0;
+        }
+
+        public clone(name: string): Light {
+            return SerializationHelper.Clone(Light.GetConstructorFromName(this.getTypeID(), name, this.getScene()), this);
+        }
+
         public serialize(): any {
-            var serializationObject: any = {};
-            serializationObject.name = this.name;
-            serializationObject.id = this.id;
-            serializationObject.tags = Tags.GetTags(this);
+            var serializationObject = SerializationHelper.Serialize(this);
+
+            // Type
+            serializationObject.type = this.getTypeID();
 
-            if (this.intensity) {
-                serializationObject.intensity = this.intensity;
-            }
-            
             // Parent
             if (this.parent) {
                 serializationObject.parentId = this.parent.id;
             }
 
-            serializationObject.range = this.range;
-            serializationObject.radius = this.radius;
-
-            serializationObject.diffuse = this.diffuse.asArray();
-            serializationObject.specular = this.specular.asArray();
-
             return serializationObject;
         }
 
-        public static Parse(parsedLight: any, scene: Scene): Light {
-            var light;
-
-            switch (parsedLight.type) {
+        static GetConstructorFromName(type: number, name: string, scene: Scene): () => Light {
+            switch (type) {
                 case 0:
-                    light = new PointLight(parsedLight.name, Vector3.FromArray(parsedLight.position), scene);
-                    break;
+                    return () => new PointLight(name, Vector3.Zero(), scene);
                 case 1:
-                    light = new DirectionalLight(parsedLight.name, Vector3.FromArray(parsedLight.direction), scene);
-                    light.position = Vector3.FromArray(parsedLight.position);
-                    break;
+                    return () => new DirectionalLight(name, Vector3.Zero(), scene);
                 case 2:
-                    light = new SpotLight(parsedLight.name, Vector3.FromArray(parsedLight.position), Vector3.FromArray(parsedLight.direction), parsedLight.angle, parsedLight.exponent, scene);
-                    break;
+                    return () => new SpotLight(name, Vector3.Zero(), Vector3.Zero(), 0, 0, scene);
                 case 3:
-                    light = new HemisphericLight(parsedLight.name, Vector3.FromArray(parsedLight.direction), scene);
-                    light.groundColor = Color3.FromArray(parsedLight.groundColor);
-                    break;
-            }
-
-            light.id = parsedLight.id;
-
-            Tags.AddTagsTo(light, parsedLight.tags);
-
-            if (parsedLight.intensity !== undefined) {
-                light.intensity = parsedLight.intensity;
-            }
-
-            if (parsedLight.range) {
-                light.range = parsedLight.range;
-            }
-
-            if (parsedLight.radius) {
-                light.radius = parsedLight.radius;
+                    return () => new HemisphericLight(name, Vector3.Zero(), scene);
             }
+        }
 
-            light.diffuse = Color3.FromArray(parsedLight.diffuse);
-            light.specular = Color3.FromArray(parsedLight.specular);
+        public static Parse(parsedLight: any, scene: Scene): Light {            
+            var light = SerializationHelper.Parse(Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene), parsedLight, scene);
 
+            // Inclusion / exclusions
             if (parsedLight.excludedMeshesIds) {
                 light._excludedMeshesIds = parsedLight.excludedMeshesIds;
             }
 
+            if (parsedLight.includedOnlyMeshesIds) {
+                light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
+            }
+
             // Parent
             if (parsedLight.parentId) {
                 light._waitingParentId = parsedLight.parentId;
             }
 
-            if (parsedLight.includedOnlyMeshesIds) {
-                light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
-            }
-
             // Animations
             if (parsedLight.animations) {
                 for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {

+ 11 - 5
src/Lights/babylon.pointLight.js

@@ -3,6 +3,12 @@ var __extends = (this && this.__extends) || function (d, b) {
     function __() { this.constructor = d; }
     d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
 };
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
 var BABYLON;
 (function (BABYLON) {
     var PointLight = (function (_super) {
@@ -69,12 +75,12 @@ var BABYLON;
             BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
             return this._worldMatrix;
         };
-        PointLight.prototype.serialize = function () {
-            var serializationObject = _super.prototype.serialize.call(this);
-            serializationObject.type = 0;
-            serializationObject.position = this.position.asArray();
-            return serializationObject;
+        PointLight.prototype.getTypeID = function () {
+            return 0;
         };
+        __decorate([
+            BABYLON.serializeAsVector3()
+        ], PointLight.prototype, "position", void 0);
         return PointLight;
     })(BABYLON.Light);
     BABYLON.PointLight = PointLight;

+ 8 - 8
src/Lights/babylon.pointLight.ts

@@ -3,8 +3,13 @@
         private _worldMatrix: Matrix;
         public transformedPosition: Vector3;
 
-        constructor(name: string, public position: Vector3, scene: Scene) {
+        @serializeAsVector3()
+        public position: Vector3;
+
+        constructor(name: string, position: Vector3, scene: Scene) {
             super(name, scene);
+
+            this.position = position;
         }
 
         public getAbsolutePosition(): Vector3 {
@@ -83,13 +88,8 @@
             return this._worldMatrix;
         }
 
-        public serialize(): any {
-            var serializationObject = super.serialize();
-
-            serializationObject.type = 0;
-            serializationObject.position = this.position.asArray();
-
-            return serializationObject;
+        public getTypeID(): number {
+            return 0;
         }
     }
 } 

+ 20 - 8
src/Lights/babylon.spotLight.js

@@ -3,6 +3,12 @@ var __extends = (this && this.__extends) || function (d, b) {
     function __() { this.constructor = d; }
     d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
 };
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
 var BABYLON;
 (function (BABYLON) {
     var SpotLight = (function (_super) {
@@ -71,15 +77,21 @@ var BABYLON;
             BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
             return this._worldMatrix;
         };
-        SpotLight.prototype.serialize = function () {
-            var serializationObject = _super.prototype.serialize.call(this);
-            serializationObject.type = 2;
-            serializationObject.position = this.position.asArray();
-            serializationObject.direction = this.position.asArray();
-            serializationObject.angle = this.angle;
-            serializationObject.exponent = this.exponent;
-            return serializationObject;
+        SpotLight.prototype.getTypeID = function () {
+            return 2;
         };
+        __decorate([
+            BABYLON.serializeAsVector3()
+        ], SpotLight.prototype, "position", void 0);
+        __decorate([
+            BABYLON.serializeAsVector3()
+        ], SpotLight.prototype, "direction", void 0);
+        __decorate([
+            BABYLON.serialize()
+        ], SpotLight.prototype, "angle", void 0);
+        __decorate([
+            BABYLON.serialize()
+        ], SpotLight.prototype, "exponent", void 0);
         return SpotLight;
     })(BABYLON.Light);
     BABYLON.SpotLight = SpotLight;

+ 19 - 11
src/Lights/babylon.spotLight.ts

@@ -1,13 +1,29 @@
 module BABYLON {
     export class SpotLight extends Light implements IShadowLight {
+        @serializeAsVector3()
+        public position: Vector3;
+
+        @serializeAsVector3()
+        public direction: Vector3;
+
+        @serialize()
+        public angle: number;
+
+        @serialize()
+        public exponent: number
 
         public transformedPosition: Vector3;
 
         private _transformedDirection: Vector3;
         private _worldMatrix: Matrix;
 
-        constructor(name: string, public position: Vector3, public direction: Vector3, public angle: number, public exponent: number, scene: Scene) {
+        constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene) {
             super(name, scene);
+
+            this.position = position;
+            this.direction = direction;
+            this.angle = angle;
+            this.exponent = exponent;
         }
 
         public getAbsolutePosition(): Vector3 {
@@ -85,16 +101,8 @@
             return this._worldMatrix;
         }
 
-        public serialize(): any {
-            var serializationObject = super.serialize();
-
-            serializationObject.type = 2;
-            serializationObject.position = this.position.asArray();
-            serializationObject.direction = this.position.asArray();
-            serializationObject.angle = this.angle;
-            serializationObject.exponent = this.exponent;
-
-            return serializationObject;
+        public getTypeID(): number {
+            return 2;
         }
     }
 }

+ 5 - 16
src/Tools/babylon.decorators.js

@@ -24,16 +24,12 @@ var BABYLON;
         return generateSerializableMember(3, sourceName); // fresnel parameters member
     }
     BABYLON.serializeAsFresnelParameters = serializeAsFresnelParameters;
-    function serializeAsVector2(sourceName) {
-        return generateSerializableMember(4, sourceName); // vector2 member
-    }
-    BABYLON.serializeAsVector2 = serializeAsVector2;
     function serializeAsVector3(sourceName) {
-        return generateSerializableMember(5, sourceName); // vector3 member
+        return generateSerializableMember(4, sourceName); // vector3 member
     }
     BABYLON.serializeAsVector3 = serializeAsVector3;
     function serializeAsMeshReference(sourceName) {
-        return generateSerializableMember(6, sourceName); // mesh reference member
+        return generateSerializableMember(5, sourceName); // mesh reference member
     }
     BABYLON.serializeAsMeshReference = serializeAsMeshReference;
     var SerializationHelper = (function () {
@@ -69,9 +65,6 @@ var BABYLON;
                             serializationObject[targetPropertyName] = sourceProperty.asArray();
                             break;
                         case 5:
-                            serializationObject[targetPropertyName] = sourceProperty.asArray();
-                            break;
-                        case 6:
                             serializationObject[targetPropertyName] = sourceProperty.id;
                             break;
                     }
@@ -103,12 +96,9 @@ var BABYLON;
                             destination[property] = BABYLON.FresnelParameters.Parse(sourceProperty);
                             break;
                         case 4:
-                            destination[property] = BABYLON.Vector2.FromArray(sourceProperty);
-                            break;
-                        case 5:
                             destination[property] = BABYLON.Vector3.FromArray(sourceProperty);
                             break;
-                        case 6:
+                        case 5:
                             destination[property] = scene.getLastMeshByID(sourceProperty);
                             break;
                     }
@@ -128,14 +118,13 @@ var BABYLON;
                 if (sourceProperty !== undefined && sourceProperty !== null) {
                     switch (propertyType) {
                         case 0: // Value
-                        case 6:
+                        case 5:
                             destination[property] = sourceProperty;
                             break;
                         case 1: // Texture
                         case 2: // Color3
                         case 3: // FresnelParameters
-                        case 4: // Vector2
-                        case 5:
+                        case 4:
                             destination[property] = sourceProperty.clone();
                             break;
                     }

+ 8 - 19
src/Tools/babylon.decorators.ts

@@ -24,17 +24,13 @@
     export function serializeAsFresnelParameters(sourceName?: string) {
         return generateSerializableMember(3, sourceName); // fresnel parameters member
     }
-    
-    export function serializeAsVector2(sourceName?: string) {
-        return generateSerializableMember(4, sourceName); // vector2 member
-    }
 
     export function serializeAsVector3(sourceName?: string) {
-        return generateSerializableMember(5, sourceName); // vector3 member
+        return generateSerializableMember(4, sourceName); // vector3 member
     }
 
     export function serializeAsMeshReference(sourceName?: string) {
-        return generateSerializableMember(6, sourceName); // mesh reference member
+        return generateSerializableMember(5, sourceName); // mesh reference member
     }
 
     export class SerializationHelper {
@@ -68,13 +64,10 @@
                         case 3:     // FresnelParameters
                             serializationObject[targetPropertyName] = sourceProperty.serialize();
                             break;
-                        case 4:     // Vector2
-                            serializationObject[targetPropertyName] = sourceProperty.asArray();
-                            break;
-                        case 5:     // Vector3
+                        case 4:     // Vector3
                             serializationObject[targetPropertyName] = sourceProperty.asArray();
                             break;
-                        case 6:     // Mesh reference
+                        case 5:     // Mesh reference
                             serializationObject[targetPropertyName] = sourceProperty.id;
                             break;
                     }
@@ -110,13 +103,10 @@
                         case 3:     // FresnelParameters
                             destination[property] = FresnelParameters.Parse(sourceProperty);
                             break;
-                        case 4:     // Vector2
-                            destination[property] = Vector2.FromArray(sourceProperty);
-                            break;
-                        case 5:     // Vector3
+                        case 4:     // Vector3
                             destination[property] = Vector3.FromArray(sourceProperty);
                             break;
-                        case 6:     // Mesh reference
+                        case 5:     // Mesh reference
                             destination[property] = scene.getLastMeshByID(sourceProperty);
                             break;
                     }
@@ -141,14 +131,13 @@
                 if (sourceProperty !== undefined && sourceProperty !== null) {
                     switch (propertyType) {
                         case 0:     // Value
-                        case 6:     // Mesh reference
+                        case 5:     // Mesh reference
                             destination[property] = sourceProperty;
                             break;
                         case 1:     // Texture
                         case 2:     // Color3
                         case 3:     // FresnelParameters
-                        case 4:     // Vector2
-                        case 5:     // Vector3
+                        case 4:     // Vector3
                             destination[property] = sourceProperty.clone();
                             break;
                     }