babylon.sceneLoader.tests.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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 rootMesh.isEnabled check', () => {
  140. const scene = new BABYLON.Scene(subject);
  141. let rootMesh: BABYLON.AbstractMesh;
  142. subject.runRenderLoop(() => {
  143. if (!rootMesh) {
  144. for (const mesh of scene.meshes) {
  145. if (!mesh.parent) {
  146. rootMesh = mesh;
  147. break;
  148. }
  149. }
  150. }
  151. if (rootMesh) {
  152. expect(rootMesh.isEnabled(), "rootMesh.isEnabled").to.be.false;
  153. }
  154. });
  155. return BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(scene => {
  156. expect(rootMesh.isEnabled(), "rootMesh.isEnabled").to.be.true;
  157. subject.stopRenderLoop();
  158. });
  159. });
  160. it('Load CompileMaterials', () => {
  161. const scene = new BABYLON.Scene(subject);
  162. const promises = new Array<Promise<void>>();
  163. let createShaderProgramSpy: sinon.SinonSpy;
  164. subject.runRenderLoop(() => {
  165. for (const mesh of scene.meshes) {
  166. if (mesh.material && mesh.isEnabled()) {
  167. expect(mesh.material.isReady(mesh), "mesh material is ready").to.be.true;
  168. }
  169. }
  170. });
  171. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  172. loader.compileMaterials = true;
  173. promises.push(loader.whenCompleteAsync().then(() => {
  174. const called = createShaderProgramSpy.called;
  175. createShaderProgramSpy.restore();
  176. expect(called, "createShaderProgramCalled").to.be.false;
  177. }));
  178. });
  179. promises.push(BABYLON.SceneLoader.AppendAsync("http://models.babylonjs.com/Tests/CompileMaterials/", "Test.gltf", scene).then(() => {
  180. createShaderProgramSpy = sinon.spy(subject, "createShaderProgram");
  181. }));
  182. return Promise.all(promises);
  183. });
  184. it('Load BrainStem with compileMaterials', () => {
  185. const scene = new BABYLON.Scene(subject);
  186. const promises = new Array<Promise<void>>();
  187. let createShaderProgramSpy: sinon.SinonSpy;
  188. subject.runRenderLoop(() => {
  189. for (const mesh of scene.meshes) {
  190. if (mesh.material && mesh.isEnabled()) {
  191. expect(mesh.material.isReady(mesh), "mesh material is ready").to.be.true;
  192. }
  193. }
  194. });
  195. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  196. loader.compileMaterials = true;
  197. promises.push(loader.whenCompleteAsync().then(() => {
  198. const called = createShaderProgramSpy.called;
  199. createShaderProgramSpy.restore();
  200. expect(called, "createShaderProgramCalled").to.be.false;
  201. }));
  202. });
  203. promises.push(BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BrainStem/", "BrainStem.gltf", scene).then(() => {
  204. createShaderProgramSpy = sinon.spy(subject, "createShaderProgram");
  205. }));
  206. return Promise.all(promises);
  207. });
  208. it('Load Alien', () => {
  209. const scene = new BABYLON.Scene(subject);
  210. return BABYLON.SceneLoader.ImportMeshAsync(null, "/Playground/scenes/Alien/", "Alien.gltf", scene).then(result => {
  211. const skeletonsMapping = {
  212. "AlienHead": "skeleton0",
  213. "Collar": "skeleton1",
  214. "LeftEye": "skeleton2",
  215. "RightEye": "skeleton3",
  216. "CollarClasp": "skeleton1",
  217. "Shirt": "skeleton1",
  218. "ShirtPlate": "skeleton1",
  219. "Teeth": "skeleton1",
  220. };
  221. expect(scene.skeletons, "scene.skeletons").to.have.lengthOf(4);
  222. expect(result.skeletons, "skeletons").to.have.lengthOf(4);
  223. for (const meshName in skeletonsMapping) {
  224. const skeletonName = skeletonsMapping[meshName];
  225. expect(scene.getMeshByName(meshName).skeleton.name, `skeleton name of mesh '${meshName}'`).to.equal(skeletonName);
  226. }
  227. const alienHeadMesh = scene.getMeshByName("AlienHead") as BABYLON.Mesh;
  228. expect(alienHeadMesh.morphTargetManager.numTargets, "alienHeadMesh.morphTargetManager.numTargets").to.equal(2);
  229. expect(scene.animationGroups, "scene.animationGroups").to.have.lengthOf(1);
  230. expect(result.animationGroups, "animationGroups").to.have.lengthOf(1);
  231. const animationGroup = result.animationGroups[0];
  232. expect(animationGroup.name, "animationGroup.name").to.equal("TwoTargetBlend");
  233. expect(animationGroup.targetedAnimations, "animationGroup.targetedAnimations").to.have.lengthOf(7);
  234. const influenceAnimations = animationGroup.targetedAnimations.filter(_ => _.animation.targetProperty === "influence");
  235. expect(influenceAnimations, "influenceAnimations").to.have.lengthOf(2);
  236. const rotationAnimations = animationGroup.targetedAnimations.filter(_ => _.animation.targetProperty === "rotationQuaternion");
  237. expect(rotationAnimations, "rotationAnimations").to.have.lengthOf(4);
  238. const positionAnimations = animationGroup.targetedAnimations.filter(_ => _.animation.targetProperty === "position");
  239. expect(positionAnimations, "positionAnimations").to.have.lengthOf(1);
  240. });
  241. });
  242. it('Load TwoQuads with LODs', () => {
  243. const scene = new BABYLON.Scene(subject);
  244. const promises = new Array<Promise<void>>();
  245. subject.runRenderLoop(() => {
  246. for (const mesh of scene.meshes) {
  247. if (mesh.material && mesh.isEnabled()) {
  248. expect(mesh.material.isReady(mesh), "mesh material is ready").to.be.true;
  249. }
  250. }
  251. });
  252. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  253. loader.compileMaterials = true;
  254. promises.push(loader.whenCompleteAsync().then(() => {
  255. const meshes = [
  256. scene.getMeshByName("node0"),
  257. scene.getMeshByName("node1")
  258. ];
  259. expect(meshes[0].material.name, "Material for node 0").to.equal("LOD0");
  260. expect(meshes[1].material.name, "Material for node 1").to.equal("LOD0");
  261. expect(scene.materials, "scene.materials").to.have.lengthOf(1);
  262. const materials = [
  263. scene.getMaterialByName("LOD0")
  264. ];
  265. expect(materials[0].isReady(meshes[0]), "Material of LOD 0 is ready for node 0").to.be.true;
  266. expect(materials[0].isReady(meshes[1]), "Material of LOD 0 is ready for node 1").to.be.true;
  267. }));
  268. });
  269. promises.push(BABYLON.SceneLoader.AppendAsync("http://models.babylonjs.com/Tests/TwoQuads/", "TwoQuads.gltf", scene).then(() => {
  270. const meshes = [
  271. scene.getMeshByName("node0"),
  272. scene.getMeshByName("node1")
  273. ];
  274. expect(meshes[0].material.name, "Material for node 0").to.equal("LOD2");
  275. expect(meshes[1].material.name, "Material for node 1").to.equal("LOD2");
  276. expect(scene.materials, "scene.materials").to.have.lengthOf(3);
  277. const materials = [
  278. scene.getMaterialByName("LOD0"),
  279. scene.getMaterialByName("LOD1"),
  280. scene.getMaterialByName("LOD2")
  281. ];
  282. expect(materials[0].isReady(meshes[0]), "Material of LOD 0 is ready for node 0").to.be.false;
  283. expect(materials[0].isReady(meshes[1]), "Material of LOD 0 is ready for node 1").to.be.false;
  284. expect(materials[1].isReady(meshes[0]), "Material of LOD 1 is ready for node 0").to.be.false;
  285. expect(materials[1].isReady(meshes[1]), "Material of LOD 1 is ready for node 1").to.be.false;
  286. expect(materials[2].isReady(meshes[0]), "Material of LOD 2 is ready for node 0").to.be.true;
  287. expect(materials[2].isReady(meshes[1]), "Material of LOD 2 is ready for node 1").to.be.true;
  288. }));
  289. return Promise.all(promises);
  290. });
  291. it('Load TwoQuads with LODs and onMaterialLODsLoadedObservable', () => {
  292. const scene = new BABYLON.Scene(subject);
  293. const promises = new Array<Promise<void>>();
  294. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  295. loader.onExtensionLoadedObservable.addOnce(extension => {
  296. if (extension instanceof BABYLON.GLTF2.Extensions.MSFT_lod) {
  297. extension.onMaterialLODsLoadedObservable.add(indexLOD => {
  298. const expectedMaterialName = `LOD${2 - indexLOD}`;
  299. expect(scene.getMeshByName("node0").material.name, "Material for node 0").to.equal(expectedMaterialName);
  300. expect(scene.getMeshByName("node1").material.name, "Material for node 1").to.equal(expectedMaterialName);
  301. });
  302. }
  303. });
  304. promises.push(loader.whenCompleteAsync());
  305. });
  306. promises.push(BABYLON.SceneLoader.AppendAsync("http://models.babylonjs.com/Tests/TwoQuads/", "TwoQuads.gltf", scene).then(() => {
  307. // do nothing
  308. }));
  309. return Promise.all(promises);
  310. });
  311. it('Load TwoQuads with LODs and dispose when onMaterialLODsLoadedObservable', () => {
  312. const scene = new BABYLON.Scene(subject);
  313. const promises = new Array<Promise<void>>();
  314. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  315. loader.onExtensionLoadedObservable.addOnce(extension => {
  316. if (extension instanceof BABYLON.GLTF2.Extensions.MSFT_lod) {
  317. extension.onMaterialLODsLoadedObservable.add(indexLOD => {
  318. expect(indexLOD, "indexLOD").to.equal(0);
  319. loader.dispose();
  320. });
  321. }
  322. });
  323. promises.push(new Promise(resolve => {
  324. loader.onDisposeObservable.addOnce(() => {
  325. resolve();
  326. });
  327. }));
  328. });
  329. promises.push(BABYLON.SceneLoader.AppendAsync("http://models.babylonjs.com/Tests/TwoQuads/", "TwoQuads.gltf", scene).then(() => {
  330. // do nothing
  331. }));
  332. return Promise.all(promises);
  333. });
  334. it('Load MultiPrimitive', () => {
  335. const scene = new BABYLON.Scene(subject);
  336. return BABYLON.SceneLoader.ImportMeshAsync(null, "http://models.babylonjs.com/Tests/MultiPrimitive/", "MultiPrimitive.gltf", scene).then(result => {
  337. expect(result.meshes, "meshes").to.have.lengthOf(4);
  338. const node = scene.getMeshByName("node");
  339. expect(node, "node").to.exist;
  340. expect(node, "node").to.be.an.instanceof(BABYLON.Mesh);
  341. const mesh = node as BABYLON.Mesh;
  342. expect(mesh.geometry).to.not.exist;
  343. expect(mesh.material).to.not.exist;
  344. expect(mesh.getChildren(), "mesh children").to.have.lengthOf(2);
  345. for (const childNode of mesh.getChildren()) {
  346. expect(childNode, "child node").to.be.an.instanceof(BABYLON.Mesh);
  347. const childMesh = childNode as BABYLON.Mesh;
  348. expect(childMesh.geometry).to.exist;
  349. expect(childMesh.material).to.exist;
  350. }
  351. });
  352. });
  353. it('Load BrainStem', () => {
  354. const scene = new BABYLON.Scene(subject);
  355. return BABYLON.SceneLoader.ImportMeshAsync(null, "/Playground/scenes/BrainStem/", "BrainStem.gltf", scene).then(result => {
  356. expect(result.skeletons, "skeletons").to.have.lengthOf(1);
  357. const node1 = scene.getMeshByName("node1");
  358. for (const childMesh of node1.getChildMeshes()) {
  359. expect(childMesh.skeleton, "mesh skeleton").to.exist;
  360. expect(childMesh.skeleton.name, "mesh skeleton name").to.equal(result.skeletons[0].name);
  361. }
  362. });
  363. });
  364. it('Load BoomBox with transparencyAsCoverage', () => {
  365. const scene = new BABYLON.Scene(subject);
  366. const promises = new Array<Promise<any>>();
  367. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  368. var specularOverAlpha = false;
  369. var radianceOverAlpha = false;
  370. loader.transparencyAsCoverage = true;
  371. loader.onMaterialLoaded = material => {
  372. specularOverAlpha = specularOverAlpha || (material as BABYLON.PBRMaterial).useSpecularOverAlpha;
  373. radianceOverAlpha = radianceOverAlpha || (material as BABYLON.PBRMaterial).useRadianceOverAlpha;
  374. };
  375. promises.push(loader.whenCompleteAsync().then(() => {
  376. expect(specularOverAlpha, "specularOverAlpha").to.be.false;
  377. expect(radianceOverAlpha, "radianceOverAlpha").to.be.false;
  378. }));
  379. });
  380. promises.push(BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene));
  381. return Promise.all(promises);
  382. });
  383. it('Load BoomBox without transparencyAsCoverage', () => {
  384. const scene = new BABYLON.Scene(subject);
  385. const promises = new Array<Promise<any>>();
  386. BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce((loader: BABYLON.GLTFFileLoader) => {
  387. var specularOverAlpha = true;
  388. var radianceOverAlpha = true;
  389. loader.transparencyAsCoverage = false;
  390. loader.onMaterialLoaded = material => {
  391. specularOverAlpha = specularOverAlpha && (material as BABYLON.PBRMaterial).useSpecularOverAlpha;
  392. radianceOverAlpha = radianceOverAlpha && (material as BABYLON.PBRMaterial).useRadianceOverAlpha;
  393. };
  394. promises.push(loader.whenCompleteAsync().then(() => {
  395. expect(specularOverAlpha, "specularOverAlpha").to.be.true;
  396. expect(radianceOverAlpha, "radianceOverAlpha").to.be.true;
  397. }));
  398. });
  399. promises.push(BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene));
  400. return Promise.all(promises);
  401. });
  402. it('Load BoomBox twice and check texture instancing', () => {
  403. const scene = new BABYLON.Scene(subject);
  404. return BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(() => {
  405. const createTextureSpy = sinon.spy(subject, "createTexture");
  406. return BABYLON.SceneLoader.AppendAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(() => {
  407. const called = createTextureSpy.called;
  408. createTextureSpy.restore();
  409. expect(called, "createTextureSpyCalled").to.be.false;
  410. });
  411. });
  412. });
  413. // TODO: test animation group callback
  414. // TODO: test material instancing
  415. // TODO: test KHR_materials_pbrSpecularGlossiness
  416. // TODO: test KHR_lights
  417. });
  418. describe('#AssetContainer', () => {
  419. it('should be loaded from BoomBox GLTF', () => {
  420. var scene = new BABYLON.Scene(subject);
  421. return BABYLON.SceneLoader.LoadAssetContainerAsync("/Playground/scenes/BoomBox/", "BoomBox.gltf", scene).then(container => {
  422. expect(container.meshes.length).to.eq(2);
  423. });
  424. });
  425. it('should be adding and removing objects from scene', () => {
  426. // Create a scene with some assets
  427. var scene = new BABYLON.Scene(subject);
  428. var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);
  429. var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
  430. var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);
  431. var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);
  432. // Move all the assets from the scene into a container
  433. var container = new BABYLON.AssetContainer(scene);
  434. var keepAssets = new BABYLON.KeepAssets();
  435. keepAssets.cameras.push(camera);
  436. container.moveAllFromScene(keepAssets);
  437. expect(scene.cameras.length).to.eq(1);
  438. expect(scene.meshes.length).to.eq(0);
  439. expect(scene.lights.length).to.eq(0);
  440. expect(container.cameras.length).to.eq(0);
  441. expect(container.meshes.length).to.eq(2);
  442. expect(container.lights.length).to.eq(1);
  443. // Add them back and then remove again
  444. container.addAllToScene();
  445. expect(scene.cameras.length).to.eq(1);
  446. expect(scene.meshes.length).to.eq(2);
  447. expect(scene.lights.length).to.eq(1);
  448. container.removeAllFromScene();
  449. expect(scene.cameras.length).to.eq(1);
  450. expect(scene.meshes.length).to.eq(0);
  451. expect(scene.lights.length).to.eq(0);
  452. });
  453. });
  454. });