babylon.glTFSerializer.tests.ts 25 KB

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