threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {_testFinish, LoadingScreenPlugin, MathUtils, OrbitControls3, ThreeViewer} from 'threepipe'
  2. import {TilesRendererPlugin, UnloadTilesPlugin, TileCompressionPlugin} from '@threepipe/plugin-3d-tiles-renderer'
  3. async function init() {
  4. const viewer = new ThreeViewer({
  5. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  6. msaa: false,
  7. debug: true,
  8. renderScale: 'auto',
  9. })
  10. // viewer.scene.mainCamera.position.set(4800000, 2570000, 14720000 )
  11. viewer.scene.mainCamera.position.set(500, 500, 500)
  12. viewer.scene.mainCamera.autoNearFar = false
  13. viewer.scene.mainCamera.minNearPlane = 1
  14. viewer.scene.mainCamera.maxFarPlane = 1600000
  15. viewer.scene.mainCamera.fov = 60
  16. const controls = viewer.scene.mainCamera.controls as OrbitControls3
  17. controls.minDistance = 1
  18. controls.maxDistance = 1e4 * 2
  19. controls.minPolarAngle = 0
  20. controls.maxPolarAngle = 3 * Math.PI / 8
  21. controls.enableDamping = true
  22. controls.autoRotate = true
  23. controls.autoRotateSpeed = 0.5
  24. controls.enablePan = false
  25. const tiles = viewer.addPluginSync(TilesRendererPlugin)
  26. viewer.addPluginSync(LoadingScreenPlugin)
  27. const result = await tiles.loadCesiumIon({
  28. assetId: '2275207',
  29. apiToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0M2VkOWIxYy00NGEyLTQ1N2QtOWYxYy01ZDNlYjdkN2U4N2MiLCJpZCI6Mjk5NTY5LCJpYXQiOjE3NDY0MzE1NTl9.iOdIsjY4zSnTfIXBx0Pl-yfsG24OuHTt2CQnIP5JRrQ',
  30. autoRefreshToken: true,
  31. }, {
  32. autoCenter: false,
  33. tiles: {
  34. TilesFadePlugin: true,
  35. plugins: [
  36. ()=>new TileCompressionPlugin(),
  37. ()=>new UnloadTilesPlugin(),
  38. ],
  39. },
  40. })
  41. if (result) {
  42. result.rotateX(-Math.PI / 2)
  43. // @ts-expect-error deprecated?
  44. result.tilesRenderer.setLatLonToYUp(35.6586 * MathUtils.DEG2RAD, 139.7454 * MathUtils.DEG2RAD) // Tokyo Tower
  45. result.tilesRenderer.errorTarget = 1
  46. }
  47. console.log(result)
  48. }
  49. init().finally(_testFinish)