فهرست منبع

add unit test

Trevor Baron 7 سال پیش
والد
کامیت
489913922e

+ 2 - 2
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
-  "errors": 10526,
+  "errors": 10505,
   "babylon.typedoc.json": {
-    "errors": 10526,
+    "errors": 10505,
     "AnimationKeyInterpolation": {
       "Enumeration": {
         "Comments": {

+ 2 - 2
tests/unit/babylon/babylonReference.ts

@@ -1,5 +1,5 @@
-/// <reference path="../../../dist/babylon.d.ts" />
-/// <reference path="../../../dist/loaders/babylon.glTF2FileLoader.d.ts" />
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+/// <reference path="../../../dist/preview release/loaders/babylon.glTF2FileLoader.d.ts" />
 /// <reference path="../../../dist/preview release/serializers/babylon.glTF2Serializer.d.ts" />
 
 /// <reference path="../node_modules/@types/chai/index.d.ts" />

+ 41 - 1
tests/unit/babylon/loading/babylon.sceneloader.tests.ts

@@ -1,7 +1,7 @@
 /**
  * Describes the test suite.
  */
-describe('Babylon Tools', () => {
+describe('Babylon SceneLoader', () => {
     var subject : BABYLON.Engine;
 
     /**
@@ -48,4 +48,44 @@ describe('Babylon Tools', () => {
             });
         });
     });
+
+    describe('#AssetContainer', () => {
+        it('should be loaded from BoomBox GLTF', (done) => {
+            var scene = new BABYLON.Scene(subject);
+            BABYLON.SceneLoader.LoadAssetContainer("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene, function (container) {
+                expect(container.meshes.length).to.eq(2);
+                done();
+            });
+        });
+        it('should be adding and removing objects from scene', () => {
+            // Create a scene with some assets
+            var scene = new BABYLON.Scene(subject);
+            var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);
+            var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
+            var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);
+            var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);
+
+            // Move all the assets from the scene into a container
+            var container = new BABYLON.AssetContainer(scene);
+            var keepAssets = new BABYLON.KeepAssets();
+            keepAssets.cameras.push(camera)
+            container.moveAllFromScene(keepAssets)
+            expect(scene.cameras.length).to.eq(1)
+            expect(scene.meshes.length).to.eq(0)
+            expect(scene.lights.length).to.eq(0)
+            expect(container.cameras.length).to.eq(0)
+            expect(container.meshes.length).to.eq(2)
+            expect(container.lights.length).to.eq(1)
+
+            // Add them back and then remove again
+            container.addAllToScene();
+            expect(scene.cameras.length).to.eq(1)
+            expect(scene.meshes.length).to.eq(2)
+            expect(scene.lights.length).to.eq(1)
+            container.removeAllFromScene();
+            expect(scene.cameras.length).to.eq(1)
+            expect(scene.meshes.length).to.eq(0)
+            expect(scene.lights.length).to.eq(0)
+        });
+    });
 });