babylon.sceneLoader.tests.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. /**
  2. * Describes the test suite.
  3. */
  4. describe('Babylon Scene Loader', function () {
  5. let subject: BABYLON.Engine;
  6. this.timeout(10000);
  7. /**
  8. * Loads the dependencies.
  9. */
  10. before(function (done) {
  11. this.timeout(180000);
  12. (BABYLONDEVTOOLS).Loader
  13. .useDist()
  14. .load(function () {
  15. // Force apply promise polyfill for consistent behavior between PhantomJS, IE11, and other browsers.
  16. BABYLON.PromisePolyfill.Apply(true);
  17. done();
  18. });
  19. });
  20. /**
  21. * Create a new engine subject before each test.
  22. */
  23. beforeEach(function () {
  24. subject = new BABYLON.NullEngine({
  25. renderHeight: 256,
  26. renderWidth: 256,
  27. textureSize: 256,
  28. deterministicLockstep: false,
  29. lockstepMaxSteps: 1
  30. });
  31. // Avoid creating normals in PBR materials.
  32. subject.getCaps().standardDerivatives = true;
  33. });
  34. /**
  35. * Integration tests for loading glTF assets.
  36. */
  37. describe('#glTF', () => {
  38. it('Load BoomBox', () => {
  39. const scene = new BABYLON.Scene(subject);
  40. return BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(scene => {
  41. expect(scene.meshes.length, "scene.meshes.length").to.equal(2);
  42. expect(scene.materials.length, "scene.materials.length").to.equal(1);
  43. });
  44. });
  45. it('Load BoomBox GLB', () => {
  46. const scene = new BABYLON.Scene(subject);
  47. return BABYLON.SceneLoader.AppendAsync("/Playground/scenes/", "BoomBox.glb", scene).then(scene => {
  48. expect(scene.meshes.length, "scene.meshes.length").to.equal(2);
  49. expect(scene.materials.length, "scene.materials.length").to.equal(1);
  50. });
  51. });
  52. it('Load BoomBox with ImportMesh', () => {
  53. const scene = new BABYLON.Scene(subject);
  54. return BABYLON.SceneLoader.ImportMeshAsync(null, "/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(result => {
  55. expect(result.meshes.length, "meshes.length").to.equal(scene.meshes.length);
  56. expect(result.particleSystems.length, "particleSystems.length").to.equal(0);
  57. expect(result.skeletons.length, "skeletons.length").to.equal(0);
  58. expect(result.animationGroups.length, "animationGroups.length").to.equal(0);
  59. });
  60. });
  61. it('Load TwoQuads with ImportMesh and one node name', () => {
  62. const scene = new BABYLON.Scene(subject);
  63. return BABYLON.SceneLoader.ImportMeshAsync("node0", "http://models.babylonjs.com/Tests/TwoQuads/", "TwoQuads.gltf", scene).then(() => {
  64. expect(scene.getMeshByName("node0"), "node0").to.exist;
  65. expect(scene.getMeshByName("node1"), "node1").to.not.exist;
  66. });
  67. });
  68. it('Load TwoQuads with ImporMesh and two node names', () => {
  69. const scene = new BABYLON.Scene(subject);
  70. return BABYLON.SceneLoader.ImportMeshAsync(["node0", "node1"], "http://models.babylonjs.com/Tests/TwoQuads/", "TwoQuads.gltf", scene).then(() => {
  71. expect(scene.getMeshByName("node0"), "node0").to.exist;
  72. expect(scene.getMeshByName("node1"), "node1").to.exist;
  73. });
  74. });
  75. it('Load BoomBox with callbacks', () => {
  76. let parsedCount = 0;
  77. let meshCount = 0;
  78. let materialCount = 0;
  79. let textureCounts: { [name: string]: number } = {};
  80. let ready = false;
  81. const promises = new Array<Promise<void>>();
  82. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  83. loader.onParsed = data => {
  84. parsedCount++;
  85. };
  86. loader.onMeshLoaded = mesh => {
  87. meshCount++;
  88. };
  89. loader.onMaterialLoaded = material => {
  90. materialCount++;
  91. };
  92. loader.onTextureLoaded = texture => {
  93. textureCounts[texture.name] = textureCounts[texture.name] || 0;
  94. textureCounts[texture.name]++;
  95. };
  96. promises.push(loader.whenCompleteAsync().then(() => {
  97. expect(ready, "ready").to.be.true;
  98. }));
  99. });
  100. const scene = new BABYLON.Scene(subject);
  101. promises.push(BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(() => {
  102. ready = true;
  103. expect(parsedCount, "parsedCount").to.equal(1);
  104. expect(meshCount, "meshCount").to.equal(scene.meshes.length);
  105. expect(materialCount, "materialCount").to.equal(scene.materials.length);
  106. const expectedTextureLoadCounts = {
  107. "baseColor": 1,
  108. "occlusionRoughnessMetallic": 2,
  109. "normal": 1,
  110. "emissive": 1
  111. };
  112. expect(Object.keys(textureCounts), "Object.keys(textureCounts)").to.have.lengthOf(Object.keys(expectedTextureLoadCounts).length);
  113. for (const textureName in expectedTextureLoadCounts) {
  114. expect(textureCounts, "textureCounts").to.have.property(textureName, expectedTextureLoadCounts[textureName]);
  115. }
  116. }));
  117. return Promise.all(promises);
  118. });
  119. it('Load BoomBox with dispose', () => {
  120. let ready = false;
  121. let disposed = false;
  122. const promises = new Array<Promise<void>>();
  123. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  124. loader.onDispose = () => {
  125. disposed = true;
  126. };
  127. promises.push(BABYLON.Tools.DelayAsync(50).then(() => {
  128. loader.dispose();
  129. expect(ready, "ready").to.be.false;
  130. expect(disposed, "disposed").to.be.true;
  131. }));
  132. });
  133. const scene = new BABYLON.Scene(subject);
  134. promises.push(BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox2.gltf", scene).then(() => {
  135. ready = true;
  136. }));
  137. return Promise.race(promises);
  138. });
  139. it('Load BoomBox with mesh.isEnabled check', () => {
  140. const scene = new BABYLON.Scene(subject);
  141. subject.runRenderLoop(() => {
  142. for (const mesh of scene.meshes) {
  143. if (mesh.getTotalVertices() !== 0) {
  144. expect(mesh.isEnabled(), "mesh.isEnabled").to.be.false;
  145. }
  146. }
  147. });
  148. return BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(scene => {
  149. subject.stopRenderLoop();
  150. for (const mesh of scene.meshes) {
  151. if (mesh.getTotalVertices() !== 0) {
  152. expect(mesh.isEnabled(), "mesh.isEnabled").to.be.true;
  153. }
  154. }
  155. });
  156. });
  157. it('Load CompileMaterials', () => {
  158. const scene = new BABYLON.Scene(subject);
  159. const promises = new Array<Promise<void>>();
  160. let createShaderProgramSpy: sinon.SinonSpy;
  161. subject.runRenderLoop(() => {
  162. for (const mesh of scene.meshes) {
  163. if (mesh.material && mesh.isEnabled()) {
  164. expect(mesh.material.isReady(mesh), "mesh material is ready").to.be.true;
  165. }
  166. }
  167. });
  168. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  169. loader.compileMaterials = true;
  170. promises.push(loader.whenCompleteAsync().then(() => {
  171. const called = createShaderProgramSpy.called;
  172. createShaderProgramSpy.restore();
  173. expect(called, "createShaderProgramCalled").to.be.false;
  174. }));
  175. });
  176. promises.push(BABYLON.SceneLoader.AppendAsync("http://models.babylonjs.com/Tests/CompileMaterials/", "Test.gltf", scene).then(() => {
  177. createShaderProgramSpy = sinon.spy(subject, "createShaderProgram");
  178. }));
  179. return Promise.all(promises);
  180. });
  181. it('Load BrainStem with compileMaterials', () => {
  182. const scene = new BABYLON.Scene(subject);
  183. const promises = new Array<Promise<void>>();
  184. let createShaderProgramSpy: sinon.SinonSpy;
  185. subject.runRenderLoop(() => {
  186. for (const mesh of scene.meshes) {
  187. if (mesh.material && mesh.isEnabled()) {
  188. expect(mesh.material.isReady(mesh), "mesh material is ready").to.be.true;
  189. }
  190. }
  191. });
  192. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  193. loader.compileMaterials = true;
  194. promises.push(loader.whenCompleteAsync().then(() => {
  195. const called = createShaderProgramSpy.called;
  196. createShaderProgramSpy.restore();
  197. expect(called, "createShaderProgramCalled").to.be.false;
  198. }));
  199. });
  200. promises.push(BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BrainStem/", "BrainStem.gltf", scene).then(() => {
  201. createShaderProgramSpy = sinon.spy(subject, "createShaderProgram");
  202. }));
  203. return Promise.all(promises);
  204. });
  205. it('Load Alien', () => {
  206. const scene = new BABYLON.Scene(subject);
  207. return BABYLON.SceneLoader.ImportMeshAsync(null, "/Playground/scenes/Alien/", "Alien.gltf", scene).then(result => {
  208. const skeletonsMapping = {
  209. "AlienHead": "skeleton0",
  210. "Collar": "skeleton1",
  211. "LeftEye": "skeleton2",
  212. "RightEye": "skeleton3",
  213. "CollarClasp": "skeleton1",
  214. "Shirt": "skeleton1",
  215. "ShirtPlate": "skeleton1",
  216. "Teeth": "skeleton1",
  217. };
  218. expect(scene.skeletons, "scene.skeletons").to.have.lengthOf(4);
  219. expect(result.skeletons, "skeletons").to.have.lengthOf(4);
  220. for (const meshName in skeletonsMapping) {
  221. const skeletonName = skeletonsMapping[meshName];
  222. expect(scene.getMeshByName(meshName).skeleton.name, `skeleton name of mesh '${meshName}'`).to.equal(skeletonName);
  223. }
  224. const alienHeadMesh = scene.getMeshByName("AlienHead") as BABYLON.Mesh;
  225. expect(alienHeadMesh.morphTargetManager.numTargets, "alienHeadMesh.morphTargetManager.numTargets").to.equal(2);
  226. expect(scene.animationGroups, "scene.animationGroups").to.have.lengthOf(1);
  227. expect(result.animationGroups, "animationGroups").to.have.lengthOf(1);
  228. const animationGroup = result.animationGroups[0];
  229. expect(animationGroup.name, "animationGroup.name").to.equal("TwoTargetBlend");
  230. expect(animationGroup.targetedAnimations, "animationGroup.targetedAnimations").to.have.lengthOf(7);
  231. const influenceAnimations = animationGroup.targetedAnimations.filter(_ => _.animation.targetProperty === "influence");
  232. expect(influenceAnimations, "influenceAnimations").to.have.lengthOf(2);
  233. const rotationAnimations = animationGroup.targetedAnimations.filter(_ => _.animation.targetProperty === "rotationQuaternion");
  234. expect(rotationAnimations, "rotationAnimations").to.have.lengthOf(4);
  235. const positionAnimations = animationGroup.targetedAnimations.filter(_ => _.animation.targetProperty === "position");
  236. expect(positionAnimations, "positionAnimations").to.have.lengthOf(1);
  237. });
  238. });
  239. it('Load TwoQuads with LODs', () => {
  240. const scene = new BABYLON.Scene(subject);
  241. const promises = new Array<Promise<void>>();
  242. subject.runRenderLoop(() => {
  243. for (const mesh of scene.meshes) {
  244. if (mesh.material && mesh.isEnabled()) {
  245. expect(mesh.material.isReady(mesh), "mesh material is ready").to.be.true;
  246. }
  247. }
  248. });
  249. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  250. loader.compileMaterials = true;
  251. promises.push(loader.whenCompleteAsync().then(() => {
  252. const meshes = [
  253. scene.getMeshByName("node0"),
  254. scene.getMeshByName("node1")
  255. ];
  256. expect(meshes[0].material.name, "Material for node 0").to.equal("LOD0");
  257. expect(meshes[1].material.name, "Material for node 1").to.equal("LOD0");
  258. expect(scene.materials, "scene.materials").to.have.lengthOf(1);
  259. const materials = [
  260. scene.getMaterialByName("LOD0")
  261. ];
  262. expect(materials[0].isReady(meshes[0]), "Material of LOD 0 is ready for node 0").to.be.true;
  263. expect(materials[0].isReady(meshes[1]), "Material of LOD 0 is ready for node 1").to.be.true;
  264. }));
  265. });
  266. promises.push(BABYLON.SceneLoader.AppendAsync("http://models.babylonjs.com/Tests/TwoQuads/", "TwoQuads.gltf", scene).then(() => {
  267. const meshes = [
  268. scene.getMeshByName("node0"),
  269. scene.getMeshByName("node1")
  270. ];
  271. expect(meshes[0].material.name, "Material for node 0").to.equal("LOD2");
  272. expect(meshes[1].material.name, "Material for node 1").to.equal("LOD2");
  273. expect(scene.materials, "scene.materials").to.have.lengthOf(3);
  274. const materials = [
  275. scene.getMaterialByName("LOD0"),
  276. scene.getMaterialByName("LOD1"),
  277. scene.getMaterialByName("LOD2")
  278. ];
  279. expect(materials[0].isReady(meshes[0]), "Material of LOD 0 is ready for node 0").to.be.false;
  280. expect(materials[0].isReady(meshes[1]), "Material of LOD 0 is ready for node 1").to.be.false;
  281. expect(materials[1].isReady(meshes[0]), "Material of LOD 1 is ready for node 0").to.be.false;
  282. expect(materials[1].isReady(meshes[1]), "Material of LOD 1 is ready for node 1").to.be.false;
  283. expect(materials[2].isReady(meshes[0]), "Material of LOD 2 is ready for node 0").to.be.true;
  284. expect(materials[2].isReady(meshes[1]), "Material of LOD 2 is ready for node 1").to.be.true;
  285. }));
  286. return Promise.all(promises);
  287. });
  288. it('Load TwoQuads with LODs and onMaterialLODsLoadedObservable', () => {
  289. const scene = new BABYLON.Scene(subject);
  290. const promises = new Array<Promise<void>>();
  291. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  292. loader.onExtensionLoadedObservable.addOnce(extension => {
  293. if (extension instanceof BABYLON.GLTF2.Extensions.MSFT_lod) {
  294. extension.onMaterialLODsLoadedObservable.add(indexLOD => {
  295. const expectedMaterialName = `LOD${2 - indexLOD}`;
  296. expect(scene.getMeshByName("node0").material.name, "Material for node 0").to.equal(expectedMaterialName);
  297. expect(scene.getMeshByName("node1").material.name, "Material for node 1").to.equal(expectedMaterialName);
  298. });
  299. }
  300. });
  301. promises.push(loader.whenCompleteAsync());
  302. });
  303. promises.push(BABYLON.SceneLoader.AppendAsync("http://models.babylonjs.com/Tests/TwoQuads/", "TwoQuads.gltf", scene).then(() => {
  304. // do nothing
  305. }));
  306. return Promise.all(promises);
  307. });
  308. it('Load TwoQuads with LODs and dispose when onMaterialLODsLoadedObservable', () => {
  309. const scene = new BABYLON.Scene(subject);
  310. const promises = new Array<Promise<void>>();
  311. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  312. loader.onExtensionLoadedObservable.addOnce(extension => {
  313. if (extension instanceof BABYLON.GLTF2.Extensions.MSFT_lod) {
  314. extension.onMaterialLODsLoadedObservable.add(indexLOD => {
  315. expect(indexLOD, "indexLOD").to.equal(0);
  316. loader.dispose();
  317. });
  318. }
  319. });
  320. promises.push(new Promise(resolve => {
  321. loader.onDisposeObservable.addOnce(() => {
  322. resolve();
  323. });
  324. }));
  325. });
  326. promises.push(BABYLON.SceneLoader.AppendAsync("http://models.babylonjs.com/Tests/TwoQuads/", "TwoQuads.gltf", scene).then(() => {
  327. // do nothing
  328. }));
  329. return Promise.all(promises);
  330. });
  331. it('Load MultiPrimitive', () => {
  332. const scene = new BABYLON.Scene(subject);
  333. return BABYLON.SceneLoader.ImportMeshAsync(null, "http://models.babylonjs.com/Tests/MultiPrimitive/", "MultiPrimitive.gltf", scene).then(result => {
  334. expect(result.meshes, "meshes").to.have.lengthOf(4);
  335. const node = scene.getMeshByName("node");
  336. expect(node, "node").to.exist;
  337. expect(node, "node").to.be.an.instanceof(BABYLON.Mesh);
  338. const mesh = node as BABYLON.Mesh;
  339. expect(mesh.geometry).to.not.exist;
  340. expect(mesh.material).to.not.exist;
  341. expect(mesh.getChildren(), "mesh children").to.have.lengthOf(2);
  342. for (const childNode of mesh.getChildren()) {
  343. expect(childNode, "child node").to.be.an.instanceof(BABYLON.Mesh);
  344. const childMesh = childNode as BABYLON.Mesh;
  345. expect(childMesh.geometry).to.exist;
  346. expect(childMesh.material).to.exist;
  347. }
  348. });
  349. });
  350. it('Load BrainStem', () => {
  351. const scene = new BABYLON.Scene(subject);
  352. return BABYLON.SceneLoader.ImportMeshAsync(null, "/Playground/scenes/BrainStem/", "BrainStem.gltf", scene).then(result => {
  353. expect(result.skeletons, "skeletons").to.have.lengthOf(1);
  354. const node1 = scene.getMeshByName("node1");
  355. for (const childMesh of node1.getChildMeshes()) {
  356. expect(childMesh.skeleton, "mesh skeleton").to.exist;
  357. expect(childMesh.skeleton.name, "mesh skeleton name").to.equal(result.skeletons[0].name);
  358. }
  359. });
  360. });
  361. it('Load BoomBox with transparencyAsCoverage', () => {
  362. const scene = new BABYLON.Scene(subject);
  363. const promises = new Array<Promise<any>>();
  364. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  365. var specularOverAlpha = false;
  366. var radianceOverAlpha = false;
  367. loader.transparencyAsCoverage = true;
  368. loader.onMaterialLoaded = material => {
  369. specularOverAlpha = specularOverAlpha || (material as BABYLON.PBRMaterial).useSpecularOverAlpha;
  370. radianceOverAlpha = radianceOverAlpha || (material as BABYLON.PBRMaterial).useRadianceOverAlpha;
  371. };
  372. promises.push(loader.whenCompleteAsync().then(() => {
  373. expect(specularOverAlpha, "specularOverAlpha").to.be.false;
  374. expect(radianceOverAlpha, "radianceOverAlpha").to.be.false;
  375. }));
  376. });
  377. promises.push(BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene));
  378. return Promise.all(promises);
  379. });
  380. it('Load BoomBox without transparencyAsCoverage', () => {
  381. const scene = new BABYLON.Scene(subject);
  382. const promises = new Array<Promise<any>>();
  383. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  384. var specularOverAlpha = true;
  385. var radianceOverAlpha = true;
  386. loader.transparencyAsCoverage = false;
  387. loader.onMaterialLoaded = material => {
  388. specularOverAlpha = specularOverAlpha && (material as BABYLON.PBRMaterial).useSpecularOverAlpha;
  389. radianceOverAlpha = radianceOverAlpha && (material as BABYLON.PBRMaterial).useRadianceOverAlpha;
  390. };
  391. promises.push(loader.whenCompleteAsync().then(() => {
  392. expect(specularOverAlpha, "specularOverAlpha").to.be.true;
  393. expect(radianceOverAlpha, "radianceOverAlpha").to.be.true;
  394. }));
  395. });
  396. promises.push(BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene));
  397. return Promise.all(promises);
  398. });
  399. it('Load BoomBox twice and check texture instancing', () => {
  400. const scene = new BABYLON.Scene(subject);
  401. return BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(() => {
  402. const createTextureSpy = sinon.spy(subject, "createTexture");
  403. return BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(() => {
  404. const called = createTextureSpy.called;
  405. createTextureSpy.restore();
  406. expect(called, "createTextureSpyCalled").to.be.false;
  407. });
  408. });
  409. });
  410. // TODO: test animation group callback
  411. // TODO: test material instancing
  412. // TODO: test KHR_materials_pbrSpecularGlossiness
  413. // TODO: test KHR_lights
  414. });
  415. describe('#AssetContainer', () => {
  416. it('should be loaded from BoomBox GLTF', () => {
  417. var scene = new BABYLON.Scene(subject);
  418. return BABYLON.SceneLoader.LoadAssetContainerAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(container => {
  419. expect(container.meshes.length).to.eq(2);
  420. });
  421. });
  422. it('should be adding and removing objects from scene', () => {
  423. // Create a scene with some assets
  424. var scene = new BABYLON.Scene(subject);
  425. var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);
  426. var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
  427. var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);
  428. var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);
  429. // Move all the assets from the scene into a container
  430. var container = new BABYLON.AssetContainer(scene);
  431. var keepAssets = new BABYLON.KeepAssets();
  432. keepAssets.cameras.push(camera);
  433. container.moveAllFromScene(keepAssets);
  434. expect(scene.cameras.length).to.eq(1);
  435. expect(scene.meshes.length).to.eq(0);
  436. expect(scene.lights.length).to.eq(0);
  437. expect(container.cameras.length).to.eq(0);
  438. expect(container.meshes.length).to.eq(2);
  439. expect(container.lights.length).to.eq(1);
  440. // Add them back and then remove again
  441. container.addAllToScene();
  442. expect(scene.cameras.length).to.eq(1);
  443. expect(scene.meshes.length).to.eq(2);
  444. expect(scene.lights.length).to.eq(1);
  445. container.removeAllFromScene();
  446. expect(scene.cameras.length).to.eq(1);
  447. expect(scene.meshes.length).to.eq(0);
  448. expect(scene.lights.length).to.eq(0);
  449. });
  450. });
  451. });