loader-3d-tiles.spec.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import { Loader3DTiles, Runtime } from '../src'
  2. import { expect, use } from 'chai'
  3. import { Object3D } from 'three'
  4. import chaiAsPromised from 'chai-as-promised'
  5. import { installFilePolyfills } from '@loaders.gl/polyfills'
  6. import path from 'path'
  7. import { fileURLToPath } from 'url';
  8. import { dirname } from 'path';
  9. use(chaiAsPromised)
  10. installFilePolyfills()
  11. const __filename = fileURLToPath(import.meta.url);
  12. const __dirname = dirname(__filename);
  13. describe('Loader3DTiles', () => {
  14. it('handles successful loading of a tileset', async () => {
  15. const { model, runtime } = <{ model: Object3D; runtime: Runtime }>await Loader3DTiles.load(
  16. {
  17. url: path.resolve(__dirname,'./redrocks-tileset.json'),
  18. },
  19. )
  20. expect(model.type).to.equal('Group')
  21. expect(runtime.getTileset().root.type).to.equal('pointcloud')
  22. })
  23. it('throws an exception when loading failes', async () => {
  24. expect(
  25. Loader3DTiles.load({
  26. url: path.resolve(__dirname, './non-existing.json'),
  27. }),
  28. ).to.be.rejectedWith(Error)
  29. })
  30. })