babylon.glTFSerializer.tests.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. /**
  2. * Describes the test suite
  3. */
  4. describe('Babylon glTF Serializer', () => {
  5. let subject: BABYLON.Engine;
  6. /**
  7. * Loads the dependencies
  8. */
  9. before(function(done) {
  10. this.timeout(180000);
  11. (BABYLONDEVTOOLS).Loader
  12. .useDist()
  13. .testMode()
  14. .load(function() {
  15. // Force apply promise polyfill for consistent behavior between chrome headless, IE11, and other browsers.
  16. BABYLON.PromisePolyfill.Apply(true);
  17. done();
  18. });
  19. });
  20. /**
  21. * Create a null 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. });
  32. /**
  33. * This tests the glTF serializer help functions
  34. */
  35. describe('#GLTF', () => {
  36. it('should convert Babylon standard material to metallic roughness', () => {
  37. const scene = new BABYLON.Scene(subject);
  38. const babylonStandardMaterial = new BABYLON.StandardMaterial("specGloss", scene);
  39. babylonStandardMaterial.diffuseColor = BABYLON.Color3.White();
  40. babylonStandardMaterial.specularColor = BABYLON.Color3.Black();
  41. babylonStandardMaterial.specularPower = 64;
  42. babylonStandardMaterial.alpha = 1;
  43. const materialExporter = new BABYLON.GLTF2.Exporter._GLTFMaterialExporter(new BABYLON.GLTF2.Exporter._Exporter(scene));
  44. const metalRough = materialExporter._convertToGLTFPBRMetallicRoughness(babylonStandardMaterial);
  45. metalRough.baseColorFactor.should.deep.equal([0.5, 0.5, 0.5, 1]);
  46. metalRough.metallicFactor.should.be.equal(0);
  47. metalRough.roughnessFactor.should.be.approximately(0.328809, 1e-6);
  48. });
  49. it('should solve for metallic', () => {
  50. BABYLON.GLTF2.Exporter._GLTFMaterialExporter._SolveMetallic(1.0, 0.0, 1.0).should.be.equal(0);
  51. BABYLON.GLTF2.Exporter._GLTFMaterialExporter._SolveMetallic(0.0, 1.0, 1.0).should.be.approximately(1, 1e-6);
  52. });
  53. it('should serialize empty Babylon scene to glTF with only asset property', () => {
  54. const scene = new BABYLON.Scene(subject);
  55. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
  56. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  57. const jsonData = JSON.parse(jsonString);
  58. console.error(jsonData);
  59. Object.keys(jsonData).length.should.be.equal(1);
  60. jsonData.asset.version.should.be.equal("2.0");
  61. jsonData.asset.generator.should.be.equal("BabylonJS");
  62. });
  63. });
  64. it('should serialize sphere geometry in scene to glTF', () => {
  65. const scene = new BABYLON.Scene(subject);
  66. BABYLON.Mesh.CreateSphere('sphere', 16, 2, scene);
  67. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test')
  68. .then(glTFData => {
  69. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  70. const jsonData = JSON.parse(jsonString);
  71. // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials
  72. Object.keys(jsonData).length.should.be.equal(9);
  73. // positions, normals, indices
  74. jsonData.accessors.length.should.be.equal(3);
  75. // generator, version
  76. Object.keys(jsonData.asset).length.should.be.equal(2);
  77. jsonData.buffers.length.should.be.equal(1);
  78. // positions, normals, texture coords, indices
  79. jsonData.bufferViews.length.should.be.equal(4);
  80. jsonData.meshes.length.should.be.equal(1);
  81. jsonData.nodes.length.should.be.equal(1);
  82. jsonData.scenes.length.should.be.equal(1);
  83. jsonData.scene.should.be.equal(0);
  84. });
  85. });
  86. it('should serialize single component translation animation to glTF', () => {
  87. const scene = new BABYLON.Scene(subject);
  88. const box = BABYLON.Mesh.CreateBox('box', 1, scene);
  89. let keys: BABYLON.IAnimationKey[] = [];
  90. keys.push({
  91. frame: 0,
  92. value: 1
  93. });
  94. keys.push({
  95. frame: 20,
  96. value: 0.2
  97. });
  98. keys.push({
  99. frame: 40,
  100. value: 1
  101. });
  102. let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'position.y', 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
  103. animationBoxT.setKeys(keys);
  104. box.animations.push(animationBoxT);
  105. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
  106. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  107. const jsonData = JSON.parse(jsonString);
  108. jsonData.animations.length.should.be.equal(1);
  109. const animation = jsonData.animations[0];
  110. animation.channels.length.should.be.equal(1);
  111. animation.channels[0].sampler.should.be.equal(0);
  112. animation.channels[0].target.node.should.be.equal(0);
  113. animation.channels[0].target.path.should.be.equal('translation');
  114. jsonData.animations[0].samplers.length.should.be.equal(1);
  115. // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
  116. Object.keys(jsonData).length.should.be.equal(10);
  117. // positions, normals, indices, animation keyframe data, animation data
  118. jsonData.accessors.length.should.be.equal(5);
  119. // generator, version
  120. Object.keys(jsonData.asset).length.should.be.equal(2);
  121. jsonData.buffers.length.should.be.equal(1);
  122. // positions, normals, texture coords, indices, animation keyframe data, animation data
  123. jsonData.bufferViews.length.should.be.equal(6);
  124. jsonData.meshes.length.should.be.equal(1);
  125. jsonData.nodes.length.should.be.equal(1);
  126. jsonData.scenes.length.should.be.equal(1);
  127. jsonData.scene.should.be.equal(0);
  128. });
  129. });
  130. it('should serialize translation animation to glTF', () => {
  131. const scene = new BABYLON.Scene(subject);
  132. const box = BABYLON.Mesh.CreateBox('box', 1, scene);
  133. let keys: BABYLON.IAnimationKey[] = [];
  134. keys.push({
  135. frame: 0,
  136. value: new BABYLON.Vector3(0.1, 0.1, 0.1)
  137. });
  138. keys.push({
  139. frame: 20,
  140. value: BABYLON.Vector3.One()
  141. });
  142. keys.push({
  143. frame: 40,
  144. value: new BABYLON.Vector3(0.1, 0.1, 0.1)
  145. });
  146. let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'position', 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
  147. animationBoxT.setKeys(keys);
  148. box.animations.push(animationBoxT);
  149. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
  150. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  151. const jsonData = JSON.parse(jsonString);
  152. jsonData.animations.length.should.be.equal(1);
  153. const animation = jsonData.animations[0];
  154. animation.channels.length.should.be.equal(1);
  155. animation.channels[0].sampler.should.be.equal(0);
  156. animation.channels[0].target.node.should.be.equal(0);
  157. animation.channels[0].target.path.should.be.equal('translation');
  158. animation.samplers.length.should.be.equal(1);
  159. animation.samplers[0].interpolation.should.be.equal('LINEAR');
  160. animation.samplers[0].input.should.be.equal(3);
  161. animation.samplers[0].output.should.be.equal(4);
  162. jsonData.animations[0].samplers.length.should.be.equal(1);
  163. // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
  164. Object.keys(jsonData).length.should.be.equal(10);
  165. // positions, normals, indices, animation keyframe data, animation data
  166. jsonData.accessors.length.should.be.equal(5);
  167. // generator, version
  168. Object.keys(jsonData.asset).length.should.be.equal(2);
  169. jsonData.buffers.length.should.be.equal(1);
  170. // positions, normals, texture coords, indices, animation keyframe data, animation data
  171. jsonData.bufferViews.length.should.be.equal(6);
  172. jsonData.meshes.length.should.be.equal(1);
  173. jsonData.nodes.length.should.be.equal(1);
  174. jsonData.scenes.length.should.be.equal(1);
  175. jsonData.scene.should.be.equal(0);
  176. });
  177. });
  178. it('should serialize scale animation to glTF', () => {
  179. const scene = new BABYLON.Scene(subject);
  180. const box = BABYLON.Mesh.CreateBox('box', 1, scene);
  181. let keys: BABYLON.IAnimationKey[] = [];
  182. keys.push({
  183. frame: 0,
  184. value: new BABYLON.Vector3(0.1, 0.1, 0.1)
  185. });
  186. keys.push({
  187. frame: 20,
  188. value: BABYLON.Vector3.One()
  189. });
  190. keys.push({
  191. frame: 40,
  192. value: new BABYLON.Vector3(0.1, 0.1, 0.1)
  193. });
  194. let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'scaling', 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
  195. animationBoxT.setKeys(keys);
  196. box.animations.push(animationBoxT);
  197. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
  198. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  199. const jsonData = JSON.parse(jsonString);
  200. jsonData.animations.length.should.be.equal(1);
  201. const animation = jsonData.animations[0];
  202. animation.channels.length.should.be.equal(1);
  203. animation.channels[0].sampler.should.be.equal(0);
  204. animation.channels[0].target.node.should.be.equal(0);
  205. animation.channels[0].target.path.should.be.equal('scale');
  206. animation.samplers.length.should.be.equal(1);
  207. animation.samplers[0].interpolation.should.be.equal('LINEAR');
  208. animation.samplers[0].input.should.be.equal(3);
  209. animation.samplers[0].output.should.be.equal(4);
  210. jsonData.animations[0].samplers.length.should.be.equal(1);
  211. // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
  212. Object.keys(jsonData).length.should.be.equal(10);
  213. // positions, normals, indices, animation keyframe data, animation data
  214. jsonData.accessors.length.should.be.equal(5);
  215. // generator, version
  216. Object.keys(jsonData.asset).length.should.be.equal(2);
  217. jsonData.buffers.length.should.be.equal(1);
  218. // positions, normals, texture coords, indices, animation keyframe data, animation data
  219. jsonData.bufferViews.length.should.be.equal(6);
  220. jsonData.meshes.length.should.be.equal(1);
  221. jsonData.nodes.length.should.be.equal(1);
  222. jsonData.scenes.length.should.be.equal(1);
  223. jsonData.scene.should.be.equal(0);
  224. });
  225. });
  226. it('should serialize rotation quaternion animation to glTF', () => {
  227. const scene = new BABYLON.Scene(subject);
  228. const box = BABYLON.Mesh.CreateBox('box', 1, scene);
  229. let keys: BABYLON.IAnimationKey[] = [];
  230. keys.push({
  231. frame: 0,
  232. value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
  233. });
  234. keys.push({
  235. frame: 20,
  236. value: BABYLON.Quaternion.Identity()
  237. });
  238. keys.push({
  239. frame: 40,
  240. value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
  241. });
  242. let animationBoxT = new BABYLON.Animation('boxAnimation_translation', 'rotationQuaternion', 30, BABYLON.Animation.ANIMATIONTYPE_QUATERNION, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
  243. animationBoxT.setKeys(keys);
  244. box.animations.push(animationBoxT);
  245. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
  246. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  247. const jsonData = JSON.parse(jsonString);
  248. jsonData.animations.length.should.be.equal(1);
  249. const animation = jsonData.animations[0];
  250. animation.channels.length.should.be.equal(1);
  251. animation.channels[0].sampler.should.be.equal(0);
  252. animation.channels[0].target.node.should.be.equal(0);
  253. animation.channels[0].target.path.should.be.equal('rotation');
  254. animation.samplers.length.should.be.equal(1);
  255. animation.samplers[0].interpolation.should.be.equal('LINEAR');
  256. animation.samplers[0].input.should.be.equal(3);
  257. animation.samplers[0].output.should.be.equal(4);
  258. jsonData.animations[0].samplers.length.should.be.equal(1);
  259. // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
  260. Object.keys(jsonData).length.should.be.equal(10);
  261. // positions, normals, indices, animation keyframe data, animation data
  262. jsonData.accessors.length.should.be.equal(5);
  263. // generator, version
  264. Object.keys(jsonData.asset).length.should.be.equal(2);
  265. jsonData.buffers.length.should.be.equal(1);
  266. // positions, normals, texture coords, indices, animation keyframe data, animation data
  267. jsonData.bufferViews.length.should.be.equal(6);
  268. jsonData.meshes.length.should.be.equal(1);
  269. jsonData.nodes.length.should.be.equal(1);
  270. jsonData.scenes.length.should.be.equal(1);
  271. jsonData.scene.should.be.equal(0);
  272. });
  273. });
  274. it('should serialize combined animations to glTF', () => {
  275. const scene = new BABYLON.Scene(subject);
  276. const box = BABYLON.Mesh.CreateBox('box', 1, scene);
  277. const rotationKeyFrames: BABYLON.IAnimationKey[] = [];
  278. rotationKeyFrames.push({
  279. frame: 0,
  280. value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
  281. });
  282. rotationKeyFrames.push({
  283. frame: 20,
  284. value: BABYLON.Quaternion.Identity()
  285. });
  286. rotationKeyFrames.push({
  287. frame: 40,
  288. value: new BABYLON.Quaternion(0.707, 0.0, 0.0, 0.707)
  289. });
  290. const scaleKeyFrames: BABYLON.IAnimationKey[] = [];
  291. scaleKeyFrames.push({
  292. frame: 0,
  293. value: new BABYLON.Vector3(0.1, 0.1, 0.1)
  294. });
  295. scaleKeyFrames.push({
  296. frame: 20,
  297. value: BABYLON.Vector3.One()
  298. });
  299. scaleKeyFrames.push({
  300. frame: 40,
  301. value: new BABYLON.Vector3(0.1, 0.1, 0.1)
  302. });
  303. let rotationAnimationBox = new BABYLON.Animation('boxAnimation_rotation', 'rotationQuaternion', 30, BABYLON.Animation.ANIMATIONTYPE_QUATERNION, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
  304. rotationAnimationBox.setKeys(rotationKeyFrames);
  305. box.animations.push(rotationAnimationBox);
  306. let scaleAnimationBox = new BABYLON.Animation('boxAnimation_scale', 'scaling', 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
  307. scaleAnimationBox.setKeys(scaleKeyFrames);
  308. box.animations.push(scaleAnimationBox);
  309. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
  310. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  311. const jsonData = JSON.parse(jsonString);
  312. jsonData.animations.length.should.be.equal(2);
  313. let animation = jsonData.animations[0];
  314. animation.channels.length.should.be.equal(1);
  315. animation.channels[0].sampler.should.be.equal(0);
  316. animation.channels[0].target.node.should.be.equal(0);
  317. animation.channels[0].target.path.should.be.equal('rotation');
  318. animation.samplers.length.should.be.equal(1);
  319. animation.samplers[0].interpolation.should.be.equal('LINEAR');
  320. animation.samplers[0].input.should.be.equal(3);
  321. animation.samplers[0].output.should.be.equal(4);
  322. animation = jsonData.animations[1];
  323. animation.channels[0].sampler.should.be.equal(0);
  324. animation.channels[0].target.node.should.be.equal(0);
  325. animation.channels[0].target.path.should.be.equal('scale');
  326. animation.samplers.length.should.be.equal(1);
  327. animation.samplers[0].interpolation.should.be.equal('LINEAR');
  328. animation.samplers[0].input.should.be.equal(5);
  329. animation.samplers[0].output.should.be.equal(6);
  330. // accessors, asset, buffers, bufferViews, meshes, nodes, scene, scenes, materials, animations
  331. Object.keys(jsonData).length.should.be.equal(10);
  332. // positions, normals, indices, rotation animation keyframe data, rotation animation data, scale animation keyframe data, scale animation data
  333. jsonData.accessors.length.should.be.equal(7);
  334. // generator, version
  335. Object.keys(jsonData.asset).length.should.be.equal(2);
  336. jsonData.buffers.length.should.be.equal(1);
  337. // positions, normals, texture coords, indices, rotation animation keyframe data, rotation animation data, scale animation keyframe data, scale animation data
  338. jsonData.bufferViews.length.should.be.equal(8);
  339. jsonData.meshes.length.should.be.equal(1);
  340. jsonData.nodes.length.should.be.equal(1);
  341. jsonData.scenes.length.should.be.equal(1);
  342. jsonData.scene.should.be.equal(0);
  343. });
  344. });
  345. it('should serialize point light to glTF', () => {
  346. const scene = new BABYLON.Scene(subject);
  347. const pointLight = new BABYLON.PointLight("pointLight", new BABYLON.Vector3(4, 4, 0), scene);
  348. const intensity = 0.2;
  349. pointLight.intensity = intensity;
  350. const diffuseColor = BABYLON.Color3.Red();
  351. pointLight.diffuse = diffuseColor;
  352. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
  353. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  354. const jsonData = JSON.parse(jsonString);
  355. // assets, extensionsUsed, extensions, nodes, scenes, scene
  356. Object.keys(jsonData).length.should.be.equal(6);
  357. jsonData.extensions['KHR_lights_punctual'].lights.length.should.be.equal(1);
  358. jsonData.extensions['KHR_lights_punctual'].lights[0].intensity.should.be.equal(intensity);
  359. expect(jsonData.extensions['KHR_lights_punctual'].lights[0].color).to.deep.equal(diffuseColor.asArray());
  360. jsonData.nodes.length.should.be.equal(1);
  361. jsonData.nodes[0].extensions['KHR_lights_punctual']['light'].should.be.equal(0);
  362. });
  363. });
  364. it('should serialize spot light to glTF', () => {
  365. const scene = new BABYLON.Scene(subject);
  366. const spotLight = new BABYLON.SpotLight("spotLight", new BABYLON.Vector3(-4, 4, 0), new BABYLON.Vector3(0, Math.PI/4, 0), Math.PI/4, 2, scene);
  367. const intensity = 0.2;
  368. spotLight.intensity = intensity;
  369. spotLight.innerAngle = Math.PI/8;
  370. const diffuseColor = BABYLON.Color3.Red();
  371. spotLight.diffuse = diffuseColor;
  372. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
  373. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  374. const jsonData = JSON.parse(jsonString);
  375. // assets, extensionsUsed, extensions, nodes, scenes, scene
  376. Object.keys(jsonData).length.should.be.equal(6);
  377. jsonData.extensions['KHR_lights_punctual'].lights.length.should.be.equal(1);
  378. jsonData.extensions['KHR_lights_punctual'].lights[0].intensity.should.be.equal(intensity);
  379. jsonData.extensions['KHR_lights_punctual'].lights[0].spot.outerConeAngle.should.be.equal(spotLight.angle/2);
  380. jsonData.extensions['KHR_lights_punctual'].lights[0].spot.innerConeAngle.should.be.equal(spotLight.innerAngle/2);
  381. expect(jsonData.extensions['KHR_lights_punctual'].lights[0].color).to.deep.equal(diffuseColor.asArray());
  382. jsonData.nodes.length.should.be.equal(1);
  383. jsonData.nodes[0].extensions['KHR_lights_punctual']['light'].should.be.equal(0);
  384. });
  385. });
  386. it('should serialize directional light to glTF', () => {
  387. const scene = new BABYLON.Scene(subject);
  388. const directionalLight = new BABYLON.DirectionalLight("directionalLight", BABYLON.Vector3.Forward(), scene);
  389. const diffuseColor = BABYLON.Color3.Red();
  390. directionalLight.diffuse = diffuseColor;
  391. const intensity = 0.2;
  392. directionalLight.intensity = intensity;
  393. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
  394. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  395. const jsonData = JSON.parse(jsonString);
  396. // assets, extensionsUsed, extensions, nodes, scenes, scene
  397. Object.keys(jsonData).length.should.be.equal(6);
  398. jsonData.extensions['KHR_lights_punctual'].lights.length.should.be.equal(1);
  399. jsonData.extensions['KHR_lights_punctual'].lights[0].intensity.should.be.equal(intensity);
  400. expect(jsonData.extensions['KHR_lights_punctual'].lights[0].color).to.deep.equal(diffuseColor.asArray());
  401. jsonData.nodes.length.should.be.equal(1);
  402. jsonData.nodes[0].extensions['KHR_lights_punctual']['light'].should.be.equal(0);
  403. });
  404. });
  405. it('should serialize multiple lights to glTF', () => {
  406. const scene = new BABYLON.Scene(subject);
  407. const pointLight = new BABYLON.PointLight("pointLight", new BABYLON.Vector3(4, 4, 0), scene);
  408. const spotLight = new BABYLON.SpotLight("spotLight", new BABYLON.Vector3(-4, 4, 0), new BABYLON.Vector3(0, Math.PI/4, 0), Math.PI/4, 2, scene);
  409. const directionalLight = new BABYLON.DirectionalLight("directionalLight", BABYLON.Vector3.Forward(), scene);
  410. return BABYLON.GLTF2Export.GLTFAsync(scene, 'test').then(glTFData => {
  411. const jsonString = glTFData.glTFFiles['test.gltf'] as string;
  412. const jsonData = JSON.parse(jsonString);
  413. // assets, extensionsUsed, extensions, nodes, scenes, scene
  414. Object.keys(jsonData).length.should.be.equal(6);
  415. jsonData.extensions['KHR_lights_punctual'].lights.length.should.be.equal(3);
  416. jsonData.nodes.length.should.be.equal(3);
  417. });
  418. });
  419. });
  420. });