فهرست منبع

Morph target serialization support - step 1

David Catuhe 8 سال پیش
والد
کامیت
745e6870bc
5فایلهای تغییر یافته به همراه6833 افزوده شده و 6759 حذف شده
  1. 3391 3378
      dist/preview release/babylon.d.ts
  2. 3391 3378
      dist/preview release/babylon.module.d.ts
  3. 18 0
      src/Morph/babylon.morphTarget.ts
  4. 24 0
      src/Morph/babylon.morphTargetManager.ts
  5. 9 3
      src/babylon.scene.ts

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3391 - 3378
dist/preview release/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3391 - 3378
dist/preview release/babylon.module.d.ts


+ 18 - 0
src/Morph/babylon.morphTarget.ts

@@ -47,6 +47,24 @@ module BABYLON {
             return this._normals;
             return this._normals;
         }
         }
 
 
+        /**
+         * Serializes the current target into a Serialization object.  
+         * Returns the serialized object.  
+         */
+        public serialize(): any {
+            var serializationObject:any = {};
+
+            serializationObject.name = this.name;
+            serializationObject.influence = this.influence;
+
+            serializationObject.positions = this.getPositions();
+            if (this.hasNormals) {
+                serializationObject.normals = this.getNormals();
+            }
+
+            return serializationObject;
+        }
+
         // Statics
         // Statics
         public static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget {
         public static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget {
             if (!name) {
             if (!name) {

+ 24 - 0
src/Morph/babylon.morphTargetManager.ts

@@ -7,6 +7,7 @@ module BABYLON {
         private _influences: Float32Array;
         private _influences: Float32Array;
         private _supportsNormals = false;
         private _supportsNormals = false;
         private _vertexCount = 0;
         private _vertexCount = 0;
+        private _uniqueId = 0;
 
 
         public constructor(scene?: Scene) {
         public constructor(scene?: Scene) {
             if (!scene) {
             if (!scene) {
@@ -14,6 +15,12 @@ module BABYLON {
             }
             }
 
 
             this._scene = scene;
             this._scene = scene;
+
+            this._uniqueId = scene.getUniqueId();
+        }
+
+        public get uniqueId(): number {
+            return this._uniqueId;
         }
         }
 
 
         public get vertexCount(): number {
         public get vertexCount(): number {
@@ -62,6 +69,23 @@ module BABYLON {
             }
             }
         }
         }
 
 
+        /**
+         * Serializes the current manager into a Serialization object.  
+         * Returns the serialized object.  
+         */
+        public serialize(): any {
+            var serializationObject:any = {};
+
+            serializationObject.id = this.uniqueId;
+
+            serializationObject.targets = [];
+            for (var target of this._targets) {
+                serializationObject.targets.push(target.serialize());
+            }
+
+            return serializationObject;
+        }
+
         private _onInfluenceChanged(needUpdate: boolean): void {
         private _onInfluenceChanged(needUpdate: boolean): void {
             this._syncActiveTargets(needUpdate);
             this._syncActiveTargets(needUpdate);
         }
         }

+ 9 - 3
src/babylon.scene.ts

@@ -1670,8 +1670,14 @@
 
 
         // Methods
         // Methods
 
 
+        public getUniqueId() {
+            var result = this._uniqueIdCounter;
+            this._uniqueIdCounter++;
+            return result;
+        }
+
         public addMesh(newMesh: AbstractMesh) {
         public addMesh(newMesh: AbstractMesh) {
-            newMesh.uniqueId = this._uniqueIdCounter++;
+            newMesh.uniqueId = this.getUniqueId();
             var position = this.meshes.push(newMesh);
             var position = this.meshes.push(newMesh);
 
 
             //notify the collision coordinator
             //notify the collision coordinator
@@ -1739,13 +1745,13 @@
         }
         }
 
 
         public addLight(newLight: Light) {
         public addLight(newLight: Light) {
-            newLight.uniqueId = this._uniqueIdCounter++;
+            newLight.uniqueId = this.getUniqueId();
             var position = this.lights.push(newLight);
             var position = this.lights.push(newLight);
             this.onNewLightAddedObservable.notifyObservers(newLight);
             this.onNewLightAddedObservable.notifyObservers(newLight);
         }
         }
 
 
         public addCamera(newCamera: Camera) {
         public addCamera(newCamera: Camera) {
-            newCamera.uniqueId = this._uniqueIdCounter++;
+            newCamera.uniqueId = this.getUniqueId();
             var position = this.cameras.push(newCamera);
             var position = this.cameras.push(newCamera);
             this.onNewCameraAddedObservable.notifyObservers(newCamera);
             this.onNewCameraAddedObservable.notifyObservers(newCamera);
         }
         }