浏览代码

lazy load the local engine to avoid issues with unit tests

Kacey Coley 7 年之前
父节点
当前提交
f72e1b0f8d

+ 21 - 7
serializers/src/glTF/2.0/babylon.glTFExporter.ts

@@ -113,7 +113,7 @@ module BABYLON.GLTF2 {
          */
         private _shouldExportTransformNode: ((babylonTransformNode: TransformNode) => boolean);
 
-        public _localEngine: Engine;
+        private _localEngine: Engine;
 
         private _glTFMaterialExporter: _GLTFMaterialExporter;
 
@@ -142,15 +142,26 @@ module BABYLON.GLTF2 {
             this._shouldExportTransformNode = _options.shouldExportTransformNode ? _options.shouldExportTransformNode : (babylonTransformNode: TransformNode) => true;
             this._animationSampleRate = _options.animationSampleRate ? _options.animationSampleRate : 1 / 60;
 
-            const localCanvas = document.createElement('canvas');
-            localCanvas.id = "WriteCanvas";
-            localCanvas.width = 2048;
-            localCanvas.height = 2048;
-            this._localEngine = new Engine(localCanvas, true, { premultipliedAlpha: false, preserveDrawingBuffer: true });
-            this._localEngine.setViewport(new Viewport(0,0,1,1));
+
             this._glTFMaterialExporter = new _GLTFMaterialExporter(this);
         }
 
+        /**
+         * Lazy load a local engine with premultiplied alpha set to false
+         */
+        public _getLocalEngine(): Engine {
+            if (!this._localEngine) {
+                const localCanvas = document.createElement('canvas');
+                localCanvas.id = "WriteCanvas";
+                localCanvas.width = 2048;
+                localCanvas.height = 2048;
+                this._localEngine = new Engine(localCanvas, true, { premultipliedAlpha: false, preserveDrawingBuffer: true });
+                this._localEngine.setViewport(new Viewport(0, 0, 1, 1));
+            }
+
+            return this._localEngine;
+        }
+
         private reorderIndicesBasedOnPrimitiveMode(submesh: SubMesh, primitiveMode: number, babylonIndices: IndicesArray, byteOffset: number, binaryWriter: _BinaryWriter) {
             switch (primitiveMode) {
                 case Material.TriangleFillMode: {
@@ -636,6 +647,9 @@ module BABYLON.GLTF2 {
         private _generateBinaryAsync(): Promise<ArrayBuffer> {
             let binaryWriter = new _BinaryWriter(4);
             return this.createSceneAsync(this._babylonScene, binaryWriter).then(() => {
+                if (this._localEngine) {
+                    this._localEngine.dispose();
+                }
                 return binaryWriter.getArrayBuffer();
             });
         }

+ 1 - 1
serializers/src/glTF/2.0/babylon.glTFMaterialExporter.ts

@@ -483,7 +483,7 @@ module BABYLON.GLTF2 {
                     let hostingScene: Scene;
 
                     let textureType = Engine.TEXTURETYPE_UNSIGNED_INT;
-                    const engine = this._exporter._localEngine;
+                    const engine = this._exporter._getLocalEngine();
 
                     hostingScene = new Scene(engine);
 

+ 304 - 304
tests/unit/babylon/serializers/babylon.glTFSerializer.tests.ts

@@ -35,335 +35,335 @@ describe('Babylon glTF Serializer', () => {
      * This tests the glTF serializer help functions 
      */
     describe('#GLTF', () => {
-        // it('should convert Babylon standard material to metallic roughness', () => {
-        //     const scene = new BABYLON.Scene(subject);
-        //     const babylonStandardMaterial = new BABYLON.StandardMaterial("specGloss", scene);
-        //     babylonStandardMaterial.diffuseColor = BABYLON.Color3.White();
-        //     babylonStandardMaterial.specularColor = BABYLON.Color3.Black();
-        //     babylonStandardMaterial.specularPower = 64;
-        //     babylonStandardMaterial.alpha = 1;
-        //     const materialExporter = new BABYLON.GLTF2._GLTFMaterialExporter(new BABYLON.GLTF2._Exporter(scene));
+        it('should convert Babylon standard material to metallic roughness', () => {
+            const scene = new BABYLON.Scene(subject);
+            const babylonStandardMaterial = new BABYLON.StandardMaterial("specGloss", scene);
+            babylonStandardMaterial.diffuseColor = BABYLON.Color3.White();
+            babylonStandardMaterial.specularColor = BABYLON.Color3.Black();
+            babylonStandardMaterial.specularPower = 64;
+            babylonStandardMaterial.alpha = 1;
+            const materialExporter = new BABYLON.GLTF2._GLTFMaterialExporter(new BABYLON.GLTF2._Exporter(scene));
 
-        //     const metalRough = materialExporter._convertToGLTFPBRMetallicRoughness(babylonStandardMaterial);
+            const metalRough = materialExporter._convertToGLTFPBRMetallicRoughness(babylonStandardMaterial);
 
-        //     metalRough.baseColorFactor.should.deep.equal([0.5, 0.5, 0.5, 1]);
+            metalRough.baseColorFactor.should.deep.equal([0.5, 0.5, 0.5, 1]);
 
-        //     metalRough.metallicFactor.should.be.equal(0);
+            metalRough.metallicFactor.should.be.equal(0);
 
-        //     metalRough.roughnessFactor.should.be.approximately(0.328809, 1e-6);
-        // });
+            metalRough.roughnessFactor.should.be.approximately(0.328809, 1e-6);
+        });
         it('should solve for metallic', () => {
             BABYLON.GLTF2._GLTFMaterialExporter._SolveMetallic(1.0, 0.0, 1.0).should.be.equal(0);
             BABYLON.GLTF2._GLTFMaterialExporter._SolveMetallic(0.0, 1.0, 1.0).should.be.approximately(1, 1e-6);
         });
-        // it('should serialize empty Babylon scene to glTF with only asset property', () => {
-        //     const scene = new BABYLON.Scene(subject);
+        it('should serialize empty Babylon scene to glTF with only asset property', () => {
+            const scene = new BABYLON.Scene(subject);
 
-        //     return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
-        //         const jsonString = glTFData.glTFFiles['test.gltf'] as string;
-        //         const jsonData = JSON.parse(jsonString);
+            return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
+                const jsonString = glTFData.glTFFiles['test.gltf'] as string;
+                const jsonData = JSON.parse(jsonString);
 
-        //         Object.keys(jsonData).length.should.be.equal(1);
-        //         jsonData.asset.version.should.be.equal("2.0");
-        //         jsonData.asset.generator.should.be.equal("BabylonJS");
-        //     });
-        // });
-        // it('should serialize sphere geometry in scene to glTF', () => {
-        //     const scene = new BABYLON.Scene(subject);
-        //     BABYLON.Mesh.CreateSphere('sphere', 16, 2, scene);
+                Object.keys(jsonData).length.should.be.equal(1);
+                jsonData.asset.version.should.be.equal("2.0");
+                jsonData.asset.generator.should.be.equal("BabylonJS");
+            });
+        });
+        it('should serialize sphere geometry in scene to glTF', () => {
+            const scene = new BABYLON.Scene(subject);
+            BABYLON.Mesh.CreateSphere('sphere', 16, 2, scene);
 
-        //     return BABYLON.GLTF2Export.GLTFAsync(scene, 'test')
-        //         .then(glTFData => {
-        //             const jsonString = glTFData.glTFFiles['test.gltf'] as string;
-        //             const jsonData = JSON.parse(jsonString);
+            return BABYLON.GLTF2Export.GLTFAsync(scene, 'test')
+                .then(glTFData => {
+                    const jsonString = glTFData.glTFFiles['test.gltf'] as string;
+                    const jsonData = JSON.parse(jsonString);
 
-        //             // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials
-        //             Object.keys(jsonData).length.should.be.equal(9);
+                    // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials
+                    Object.keys(jsonData).length.should.be.equal(9);
 
-        //             // positions, normals, indices
-        //             jsonData.accessors.length.should.be.equal(3);
+                    // positions, normals, indices
+                    jsonData.accessors.length.should.be.equal(3);
 
-        //             // generator, version
-        //             Object.keys(jsonData.asset).length.should.be.equal(2);
+                    // generator, version
+                    Object.keys(jsonData.asset).length.should.be.equal(2);
 
-        //             jsonData.buffers.length.should.be.equal(1);
+                    jsonData.buffers.length.should.be.equal(1);
 
-        //             // positions, normals, texture coords, indices
-        //             jsonData.bufferViews.length.should.be.equal(4);
+                    // positions, normals, texture coords, indices
+                    jsonData.bufferViews.length.should.be.equal(4);
 
-        //             jsonData.meshes.length.should.be.equal(1);
+                    jsonData.meshes.length.should.be.equal(1);
 
-        //             jsonData.nodes.length.should.be.equal(1);
+                    jsonData.nodes.length.should.be.equal(1);
 
-        //             jsonData.scenes.length.should.be.equal(1);
+                    jsonData.scenes.length.should.be.equal(1);
 
-        //             jsonData.scene.should.be.equal(0);
-        //         });
-        // });
-        // it('should serialize single component translation animation to glTF', () => {
-        //     const scene = new BABYLON.Scene(subject);
-        //     const box = BABYLON.Mesh.CreateBox('box', 1, scene);
-        //     let keys: BABYLON.IAnimationKey[] = [];
-        //     keys.push({
-        //         frame: 0,
-        //         value: 1
-        //     });
-        //     keys.push({
-        //         frame: 20,
-        //         value: 0.2
-        //     });
-        //     keys.push({
-        //         frame: 40,
-        //         value: 1
-        //     });
-        //     let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'position.y', 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
-        //     animationBoxT.setKeys(keys);
-        //     box.animations.push(animationBoxT);
+                    jsonData.scene.should.be.equal(0);
+                });
+        });
+        it('should serialize single component translation animation to glTF', () => {
+            const scene = new BABYLON.Scene(subject);
+            const box = BABYLON.Mesh.CreateBox('box', 1, scene);
+            let keys: BABYLON.IAnimationKey[] = [];
+            keys.push({
+                frame: 0,
+                value: 1
+            });
+            keys.push({
+                frame: 20,
+                value: 0.2
+            });
+            keys.push({
+                frame: 40,
+                value: 1
+            });
+            let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'position.y', 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
+            animationBoxT.setKeys(keys);
+            box.animations.push(animationBoxT);
 
-        //     return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
-        //         const jsonString = glTFData.glTFFiles['test.gltf'] as string;
-        //         const jsonData = JSON.parse(jsonString);
-        //         jsonData.animations.length.should.be.equal(1);
-        //         const animation = jsonData.animations[0];
-        //         animation.channels.length.should.be.equal(1);
-        //         animation.channels[0].sampler.should.be.equal(0);
-        //         animation.channels[0].target.node.should.be.equal(0);
-        //         animation.channels[0].target.path.should.be.equal('translation');
-        //         jsonData.animations[0].samplers.length.should.be.equal(1);
-        //         // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
-        //         Object.keys(jsonData).length.should.be.equal(10);
-        //         // positions, normals, indices, animation keyframe data, animation data
-        //         jsonData.accessors.length.should.be.equal(5);
-        //         // generator, version
-        //         Object.keys(jsonData.asset).length.should.be.equal(2);
-        //         jsonData.buffers.length.should.be.equal(1);
-        //         // positions, normals, texture coords, indices, animation keyframe data, animation data
-        //         jsonData.bufferViews.length.should.be.equal(6);
-        //         jsonData.meshes.length.should.be.equal(1);
-        //         jsonData.nodes.length.should.be.equal(1);
-        //         jsonData.scenes.length.should.be.equal(1);
-        //         jsonData.scene.should.be.equal(0);
-        //     });
-        // });
-        // it('should serialize translation animation to glTF', () => {
-        //     const scene = new BABYLON.Scene(subject);
-        //     const box = BABYLON.Mesh.CreateBox('box', 1, scene);
-        //     let keys: BABYLON.IAnimationKey[] = [];
-        //     keys.push({
-        //         frame: 0,
-        //         value: new BABYLON.Vector3(0.1, 0.1, 0.1)
-        //     });
-        //     keys.push({
-        //         frame: 20,
-        //         value: BABYLON.Vector3.One()
-        //     });
-        //     keys.push({
-        //         frame: 40,
-        //         value: new BABYLON.Vector3(0.1, 0.1, 0.1)
-        //     });
-        //     let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'position', 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
-        //     animationBoxT.setKeys(keys);
-        //     box.animations.push(animationBoxT);
+            return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
+                const jsonString = glTFData.glTFFiles['test.gltf'] as string;
+                const jsonData = JSON.parse(jsonString);
+                jsonData.animations.length.should.be.equal(1);
+                const animation = jsonData.animations[0];
+                animation.channels.length.should.be.equal(1);
+                animation.channels[0].sampler.should.be.equal(0);
+                animation.channels[0].target.node.should.be.equal(0);
+                animation.channels[0].target.path.should.be.equal('translation');
+                jsonData.animations[0].samplers.length.should.be.equal(1);
+                // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
+                Object.keys(jsonData).length.should.be.equal(10);
+                // positions, normals, indices, animation keyframe data, animation data
+                jsonData.accessors.length.should.be.equal(5);
+                // generator, version
+                Object.keys(jsonData.asset).length.should.be.equal(2);
+                jsonData.buffers.length.should.be.equal(1);
+                // positions, normals, texture coords, indices, animation keyframe data, animation data
+                jsonData.bufferViews.length.should.be.equal(6);
+                jsonData.meshes.length.should.be.equal(1);
+                jsonData.nodes.length.should.be.equal(1);
+                jsonData.scenes.length.should.be.equal(1);
+                jsonData.scene.should.be.equal(0);
+            });
+        });
+        it('should serialize translation animation to glTF', () => {
+            const scene = new BABYLON.Scene(subject);
+            const box = BABYLON.Mesh.CreateBox('box', 1, scene);
+            let keys: BABYLON.IAnimationKey[] = [];
+            keys.push({
+                frame: 0,
+                value: new BABYLON.Vector3(0.1, 0.1, 0.1)
+            });
+            keys.push({
+                frame: 20,
+                value: BABYLON.Vector3.One()
+            });
+            keys.push({
+                frame: 40,
+                value: new BABYLON.Vector3(0.1, 0.1, 0.1)
+            });
+            let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'position', 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
+            animationBoxT.setKeys(keys);
+            box.animations.push(animationBoxT);
 
-        //     return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
-        //         const jsonString = glTFData.glTFFiles['test.gltf'] as string;
-        //         const jsonData = JSON.parse(jsonString);
-        //         jsonData.animations.length.should.be.equal(1);
-        //         const animation = jsonData.animations[0];
-        //         animation.channels.length.should.be.equal(1);
-        //         animation.channels[0].sampler.should.be.equal(0);
-        //         animation.channels[0].target.node.should.be.equal(0);
-        //         animation.channels[0].target.path.should.be.equal('translation');
-        //         animation.samplers.length.should.be.equal(1);
-        //         animation.samplers[0].interpolation.should.be.equal('LINEAR');
-        //         animation.samplers[0].input.should.be.equal(3);
-        //         animation.samplers[0].output.should.be.equal(4);
-        //         jsonData.animations[0].samplers.length.should.be.equal(1);
-        //         // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
-        //         Object.keys(jsonData).length.should.be.equal(10);
-        //         // positions, normals, indices, animation keyframe data, animation data
-        //         jsonData.accessors.length.should.be.equal(5);
-        //         // generator, version
-        //         Object.keys(jsonData.asset).length.should.be.equal(2);
-        //         jsonData.buffers.length.should.be.equal(1);
-        //         // positions, normals, texture coords, indices, animation keyframe data, animation data
-        //         jsonData.bufferViews.length.should.be.equal(6);
-        //         jsonData.meshes.length.should.be.equal(1);
-        //         jsonData.nodes.length.should.be.equal(1);
-        //         jsonData.scenes.length.should.be.equal(1);
-        //         jsonData.scene.should.be.equal(0);
-        //     });
-        // });
-        // it('should serialize scale animation to glTF', () => {
-        //     const scene = new BABYLON.Scene(subject);
-        //     const box = BABYLON.Mesh.CreateBox('box', 1, scene);
-        //     let keys: BABYLON.IAnimationKey[] = [];
-        //     keys.push({
-        //         frame: 0,
-        //         value: new BABYLON.Vector3(0.1, 0.1, 0.1)
-        //     });
-        //     keys.push({
-        //         frame: 20,
-        //         value: BABYLON.Vector3.One()
-        //     });
-        //     keys.push({
-        //         frame: 40,
-        //         value: new BABYLON.Vector3(0.1, 0.1, 0.1)
-        //     });
-        //     let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'scaling', 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
-        //     animationBoxT.setKeys(keys);
-        //     box.animations.push(animationBoxT);
+            return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
+                const jsonString = glTFData.glTFFiles['test.gltf'] as string;
+                const jsonData = JSON.parse(jsonString);
+                jsonData.animations.length.should.be.equal(1);
+                const animation = jsonData.animations[0];
+                animation.channels.length.should.be.equal(1);
+                animation.channels[0].sampler.should.be.equal(0);
+                animation.channels[0].target.node.should.be.equal(0);
+                animation.channels[0].target.path.should.be.equal('translation');
+                animation.samplers.length.should.be.equal(1);
+                animation.samplers[0].interpolation.should.be.equal('LINEAR');
+                animation.samplers[0].input.should.be.equal(3);
+                animation.samplers[0].output.should.be.equal(4);
+                jsonData.animations[0].samplers.length.should.be.equal(1);
+                // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
+                Object.keys(jsonData).length.should.be.equal(10);
+                // positions, normals, indices, animation keyframe data, animation data
+                jsonData.accessors.length.should.be.equal(5);
+                // generator, version
+                Object.keys(jsonData.asset).length.should.be.equal(2);
+                jsonData.buffers.length.should.be.equal(1);
+                // positions, normals, texture coords, indices, animation keyframe data, animation data
+                jsonData.bufferViews.length.should.be.equal(6);
+                jsonData.meshes.length.should.be.equal(1);
+                jsonData.nodes.length.should.be.equal(1);
+                jsonData.scenes.length.should.be.equal(1);
+                jsonData.scene.should.be.equal(0);
+            });
+        });
+        it('should serialize scale animation to glTF', () => {
+            const scene = new BABYLON.Scene(subject);
+            const box = BABYLON.Mesh.CreateBox('box', 1, scene);
+            let keys: BABYLON.IAnimationKey[] = [];
+            keys.push({
+                frame: 0,
+                value: new BABYLON.Vector3(0.1, 0.1, 0.1)
+            });
+            keys.push({
+                frame: 20,
+                value: BABYLON.Vector3.One()
+            });
+            keys.push({
+                frame: 40,
+                value: new BABYLON.Vector3(0.1, 0.1, 0.1)
+            });
+            let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'scaling', 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
+            animationBoxT.setKeys(keys);
+            box.animations.push(animationBoxT);
 
-        //     return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
-        //         const jsonString = glTFData.glTFFiles['test.gltf'] as string;
-        //         const jsonData = JSON.parse(jsonString);
-        //         jsonData.animations.length.should.be.equal(1);
-        //         const animation = jsonData.animations[0];
-        //         animation.channels.length.should.be.equal(1);
-        //         animation.channels[0].sampler.should.be.equal(0);
-        //         animation.channels[0].target.node.should.be.equal(0);
-        //         animation.channels[0].target.path.should.be.equal('scale');
-        //         animation.samplers.length.should.be.equal(1);
-        //         animation.samplers[0].interpolation.should.be.equal('LINEAR');
-        //         animation.samplers[0].input.should.be.equal(3);
-        //         animation.samplers[0].output.should.be.equal(4);
-        //         jsonData.animations[0].samplers.length.should.be.equal(1);
-        //         // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
-        //         Object.keys(jsonData).length.should.be.equal(10);
-        //         // positions, normals, indices, animation keyframe data, animation data
-        //         jsonData.accessors.length.should.be.equal(5);
-        //         // generator, version
-        //         Object.keys(jsonData.asset).length.should.be.equal(2);
-        //         jsonData.buffers.length.should.be.equal(1);
-        //         // positions, normals, texture coords, indices, animation keyframe data, animation data
-        //         jsonData.bufferViews.length.should.be.equal(6);
-        //         jsonData.meshes.length.should.be.equal(1);
-        //         jsonData.nodes.length.should.be.equal(1);
-        //         jsonData.scenes.length.should.be.equal(1);
-        //         jsonData.scene.should.be.equal(0);
-        //     });
-        // });
-        // it('should serialize rotation quaternion animation to glTF', () => {
-        //     const scene = new BABYLON.Scene(subject);
-        //     const box = BABYLON.Mesh.CreateBox('box', 1, scene);
-        //     let keys: BABYLON.IAnimationKey[] = [];
-        //     keys.push({
-        //         frame: 0,
-        //         value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
-        //     });
-        //     keys.push({
-        //         frame: 20,
-        //         value: BABYLON.Quaternion.Identity()
-        //     });
-        //     keys.push({
-        //         frame: 40,
-        //         value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
-        //     });
-        //     let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'rotationQuaternion', 30, BABYLON.Animation.ANIMATIONTYPE_QUATERNION, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
-        //     animationBoxT.setKeys(keys);
-        //     box.animations.push(animationBoxT);
+            return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
+                const jsonString = glTFData.glTFFiles['test.gltf'] as string;
+                const jsonData = JSON.parse(jsonString);
+                jsonData.animations.length.should.be.equal(1);
+                const animation = jsonData.animations[0];
+                animation.channels.length.should.be.equal(1);
+                animation.channels[0].sampler.should.be.equal(0);
+                animation.channels[0].target.node.should.be.equal(0);
+                animation.channels[0].target.path.should.be.equal('scale');
+                animation.samplers.length.should.be.equal(1);
+                animation.samplers[0].interpolation.should.be.equal('LINEAR');
+                animation.samplers[0].input.should.be.equal(3);
+                animation.samplers[0].output.should.be.equal(4);
+                jsonData.animations[0].samplers.length.should.be.equal(1);
+                // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
+                Object.keys(jsonData).length.should.be.equal(10);
+                // positions, normals, indices, animation keyframe data, animation data
+                jsonData.accessors.length.should.be.equal(5);
+                // generator, version
+                Object.keys(jsonData.asset).length.should.be.equal(2);
+                jsonData.buffers.length.should.be.equal(1);
+                // positions, normals, texture coords, indices, animation keyframe data, animation data
+                jsonData.bufferViews.length.should.be.equal(6);
+                jsonData.meshes.length.should.be.equal(1);
+                jsonData.nodes.length.should.be.equal(1);
+                jsonData.scenes.length.should.be.equal(1);
+                jsonData.scene.should.be.equal(0);
+            });
+        });
+        it('should serialize rotation quaternion animation to glTF', () => {
+            const scene = new BABYLON.Scene(subject);
+            const box = BABYLON.Mesh.CreateBox('box', 1, scene);
+            let keys: BABYLON.IAnimationKey[] = [];
+            keys.push({
+                frame: 0,
+                value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
+            });
+            keys.push({
+                frame: 20,
+                value: BABYLON.Quaternion.Identity()
+            });
+            keys.push({
+                frame: 40,
+                value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
+            });
+            let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'rotationQuaternion', 30, BABYLON.Animation.ANIMATIONTYPE_QUATERNION, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
+            animationBoxT.setKeys(keys);
+            box.animations.push(animationBoxT);
 
-        //     return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
-        //         const jsonString = glTFData.glTFFiles['test.gltf'] as string;
-        //         const jsonData = JSON.parse(jsonString);
-        //         jsonData.animations.length.should.be.equal(1);
-        //         const animation = jsonData.animations[0];
-        //         animation.channels.length.should.be.equal(1);
-        //         animation.channels[0].sampler.should.be.equal(0);
-        //         animation.channels[0].target.node.should.be.equal(0);
-        //         animation.channels[0].target.path.should.be.equal('rotation');
-        //         animation.samplers.length.should.be.equal(1);
-        //         animation.samplers[0].interpolation.should.be.equal('LINEAR');
-        //         animation.samplers[0].input.should.be.equal(3);
-        //         animation.samplers[0].output.should.be.equal(4);
-        //         jsonData.animations[0].samplers.length.should.be.equal(1);
-        //         // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
-        //         Object.keys(jsonData).length.should.be.equal(10);
-        //         // positions, normals, indices, animation keyframe data, animation data
-        //         jsonData.accessors.length.should.be.equal(5);
-        //         // generator, version
-        //         Object.keys(jsonData.asset).length.should.be.equal(2);
-        //         jsonData.buffers.length.should.be.equal(1);
-        //         // positions, normals, texture coords, indices, animation keyframe data, animation data
-        //         jsonData.bufferViews.length.should.be.equal(6);
-        //         jsonData.meshes.length.should.be.equal(1);
-        //         jsonData.nodes.length.should.be.equal(1);
-        //         jsonData.scenes.length.should.be.equal(1);
-        //         jsonData.scene.should.be.equal(0);
-        //     });
-        // });
-        // it('should serialize combined animations to glTF', () => {
-        //     const scene = new BABYLON.Scene(subject);
-        //     const box = BABYLON.Mesh.CreateBox('box', 1, scene);
-        //     const rotationKeyFrames: BABYLON.IAnimationKey[] = [];
-        //     rotationKeyFrames.push({
-        //         frame: 0,
-        //         value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
-        //     });
-        //     rotationKeyFrames.push({
-        //         frame: 20,
-        //         value: BABYLON.Quaternion.Identity()
-        //     });
-        //     rotationKeyFrames.push({
-        //         frame: 40,
-        //         value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
-        //     });
-        //     const scaleKeyFrames: BABYLON.IAnimationKey[] = [];
-        //     scaleKeyFrames.push({
-        //         frame: 0,
-        //         value: new BABYLON.Vector3(0.1, 0.1, 0.1)
-        //     });
-        //     scaleKeyFrames.push({
-        //         frame: 20,
-        //         value: BABYLON.Vector3.One()
-        //     });
-        //     scaleKeyFrames.push({
-        //         frame: 40,
-        //         value: new BABYLON.Vector3(0.1, 0.1, 0.1)
-        //     });
-        //     let rotationAnimationBox = new BABYLON.Animation('boxAnimation_rotation', 'rotationQuaternion', 30, BABYLON.Animation.ANIMATIONTYPE_QUATERNION, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
-        //     rotationAnimationBox.setKeys(rotationKeyFrames);
-        //     box.animations.push(rotationAnimationBox);
-        //     let scaleAnimationBox = new BABYLON.Animation('boxAnimation_scale', 'scaling', 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
-        //     scaleAnimationBox.setKeys(scaleKeyFrames);
-        //     box.animations.push(scaleAnimationBox);
+            return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
+                const jsonString = glTFData.glTFFiles['test.gltf'] as string;
+                const jsonData = JSON.parse(jsonString);
+                jsonData.animations.length.should.be.equal(1);
+                const animation = jsonData.animations[0];
+                animation.channels.length.should.be.equal(1);
+                animation.channels[0].sampler.should.be.equal(0);
+                animation.channels[0].target.node.should.be.equal(0);
+                animation.channels[0].target.path.should.be.equal('rotation');
+                animation.samplers.length.should.be.equal(1);
+                animation.samplers[0].interpolation.should.be.equal('LINEAR');
+                animation.samplers[0].input.should.be.equal(3);
+                animation.samplers[0].output.should.be.equal(4);
+                jsonData.animations[0].samplers.length.should.be.equal(1);
+                // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
+                Object.keys(jsonData).length.should.be.equal(10);
+                // positions, normals, indices, animation keyframe data, animation data
+                jsonData.accessors.length.should.be.equal(5);
+                // generator, version
+                Object.keys(jsonData.asset).length.should.be.equal(2);
+                jsonData.buffers.length.should.be.equal(1);
+                // positions, normals, texture coords, indices, animation keyframe data, animation data
+                jsonData.bufferViews.length.should.be.equal(6);
+                jsonData.meshes.length.should.be.equal(1);
+                jsonData.nodes.length.should.be.equal(1);
+                jsonData.scenes.length.should.be.equal(1);
+                jsonData.scene.should.be.equal(0);
+            });
+        });
+        it('should serialize combined animations to glTF', () => {
+            const scene = new BABYLON.Scene(subject);
+            const box = BABYLON.Mesh.CreateBox('box', 1, scene);
+            const rotationKeyFrames: BABYLON.IAnimationKey[] = [];
+            rotationKeyFrames.push({
+                frame: 0,
+                value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
+            });
+            rotationKeyFrames.push({
+                frame: 20,
+                value: BABYLON.Quaternion.Identity()
+            });
+            rotationKeyFrames.push({
+                frame: 40,
+                value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
+            });
+            const scaleKeyFrames: BABYLON.IAnimationKey[] = [];
+            scaleKeyFrames.push({
+                frame: 0,
+                value: new BABYLON.Vector3(0.1, 0.1, 0.1)
+            });
+            scaleKeyFrames.push({
+                frame: 20,
+                value: BABYLON.Vector3.One()
+            });
+            scaleKeyFrames.push({
+                frame: 40,
+                value: new BABYLON.Vector3(0.1, 0.1, 0.1)
+            });
+            let rotationAnimationBox = new BABYLON.Animation('boxAnimation_rotation', 'rotationQuaternion', 30, BABYLON.Animation.ANIMATIONTYPE_QUATERNION, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
+            rotationAnimationBox.setKeys(rotationKeyFrames);
+            box.animations.push(rotationAnimationBox);
+            let scaleAnimationBox = new BABYLON.Animation('boxAnimation_scale', 'scaling', 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
+            scaleAnimationBox.setKeys(scaleKeyFrames);
+            box.animations.push(scaleAnimationBox);
 
-        //     return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
-        //         const jsonString = glTFData.glTFFiles['test.gltf'] as string;
-        //         const jsonData = JSON.parse(jsonString);
-        //         jsonData.animations.length.should.be.equal(2);
+            return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
+                const jsonString = glTFData.glTFFiles['test.gltf'] as string;
+                const jsonData = JSON.parse(jsonString);
+                jsonData.animations.length.should.be.equal(2);
 
-        //         let animation = jsonData.animations[0];
-        //         animation.channels.length.should.be.equal(1);
-        //         animation.channels[0].sampler.should.be.equal(0);
-        //         animation.channels[0].target.node.should.be.equal(0);
-        //         animation.channels[0].target.path.should.be.equal('rotation');
-        //         animation.samplers.length.should.be.equal(1);
-        //         animation.samplers[0].interpolation.should.be.equal('LINEAR');
-        //         animation.samplers[0].input.should.be.equal(3);
-        //         animation.samplers[0].output.should.be.equal(4);
-        //         animation = jsonData.animations[1];
-        //         animation.channels[0].sampler.should.be.equal(0);
-        //         animation.channels[0].target.node.should.be.equal(0);
-        //         animation.channels[0].target.path.should.be.equal('scale');
-        //         animation.samplers.length.should.be.equal(1);
-        //         animation.samplers[0].interpolation.should.be.equal('LINEAR');
-        //         animation.samplers[0].input.should.be.equal(5);
-        //         animation.samplers[0].output.should.be.equal(6);
-        //         // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
-        //         Object.keys(jsonData).length.should.be.equal(10);
-        //         // positions, normals, indices, rotation animation keyframe data, rotation animation data, scale animation keyframe data, scale animation data
-        //         jsonData.accessors.length.should.be.equal(7);
-        //         // generator, version
-        //         Object.keys(jsonData.asset).length.should.be.equal(2);
-        //         jsonData.buffers.length.should.be.equal(1);
-        //         // positions, normals, texture coords, indices, rotation animation keyframe data, rotation animation data, scale animation keyframe data, scale animation data 
-        //         jsonData.bufferViews.length.should.be.equal(8);
-        //         jsonData.meshes.length.should.be.equal(1);
-        //         jsonData.nodes.length.should.be.equal(1);
-        //         jsonData.scenes.length.should.be.equal(1);
-        //         jsonData.scene.should.be.equal(0);
-        //     });
-        // });
+                let animation = jsonData.animations[0];
+                animation.channels.length.should.be.equal(1);
+                animation.channels[0].sampler.should.be.equal(0);
+                animation.channels[0].target.node.should.be.equal(0);
+                animation.channels[0].target.path.should.be.equal('rotation');
+                animation.samplers.length.should.be.equal(1);
+                animation.samplers[0].interpolation.should.be.equal('LINEAR');
+                animation.samplers[0].input.should.be.equal(3);
+                animation.samplers[0].output.should.be.equal(4);
+                animation = jsonData.animations[1];
+                animation.channels[0].sampler.should.be.equal(0);
+                animation.channels[0].target.node.should.be.equal(0);
+                animation.channels[0].target.path.should.be.equal('scale');
+                animation.samplers.length.should.be.equal(1);
+                animation.samplers[0].interpolation.should.be.equal('LINEAR');
+                animation.samplers[0].input.should.be.equal(5);
+                animation.samplers[0].output.should.be.equal(6);
+                // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
+                Object.keys(jsonData).length.should.be.equal(10);
+                // positions, normals, indices, rotation animation keyframe data, rotation animation data, scale animation keyframe data, scale animation data
+                jsonData.accessors.length.should.be.equal(7);
+                // generator, version
+                Object.keys(jsonData.asset).length.should.be.equal(2);
+                jsonData.buffers.length.should.be.equal(1);
+                // positions, normals, texture coords, indices, rotation animation keyframe data, rotation animation data, scale animation keyframe data, scale animation data 
+                jsonData.bufferViews.length.should.be.equal(8);
+                jsonData.meshes.length.should.be.equal(1);
+                jsonData.nodes.length.should.be.equal(1);
+                jsonData.scenes.length.should.be.equal(1);
+                jsonData.scene.should.be.equal(0);
+            });
+        });
     });
 });