threepipe
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

script.ts 1.9KB

před 1 rokem
před 1 rokem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {_testFinish, _testStart, LoadingScreenPlugin, ThreeViewer} from 'threepipe'
  2. import {
  3. GlobeControls2,
  4. GlobeControlsPlugin,
  5. TileCompressionPlugin,
  6. TilesRendererPlugin,
  7. UnloadTilesPlugin,
  8. } from '@threepipe/plugin-3d-tiles-renderer'
  9. import {CESIUM_ION_API_TOKEN} from '../globals.js'
  10. async function init() {
  11. const viewer = new ThreeViewer({
  12. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  13. msaa: false,
  14. debug: true,
  15. renderScale: 'auto',
  16. zPrepass: false,
  17. rgbm: false,
  18. // modelRootScale: 0.01,
  19. plugins: [LoadingScreenPlugin, GlobeControlsPlugin],
  20. })
  21. viewer.scene.mainCamera.position.set(4800000, 2570000, 14720000)
  22. // viewer.scene.mainCamera.position.set(300, 300, 300)
  23. viewer.scene.mainCamera.lookAt(0, 0, 0)
  24. viewer.scene.mainCamera.autoNearFar = false
  25. // viewer.scene.mainCamera.minNearPlane = 1
  26. viewer.scene.mainCamera.maxFarPlane = 160000000
  27. viewer.scene.mainCamera.fov = 60
  28. viewer.scene.mainCamera.controlsMode = 'globe'
  29. const controls = viewer.scene.mainCamera.controls as GlobeControls2
  30. // controls.minDistance = 6.379e6
  31. controls.maxDistance = 160000000
  32. controls.enableDamping = true
  33. const tiles = viewer.addPluginSync(TilesRendererPlugin)
  34. const result = await tiles.loadCesiumIon({
  35. assetId: '2275207',
  36. apiToken: CESIUM_ION_API_TOKEN,
  37. autoRefreshToken: true,
  38. }, {
  39. autoCenter: false,
  40. autoScale: false,
  41. tiles: {
  42. TilesFadePlugin: true,
  43. plugins: [
  44. ()=>new UnloadTilesPlugin(),
  45. ()=>new TileCompressionPlugin(),
  46. ],
  47. },
  48. })
  49. if (result) {
  50. result.rotateX(-Math.PI / 2)
  51. result.tilesRenderer.errorTarget = 40
  52. controls.setTilesRenderer(result.tilesRenderer)
  53. }
  54. }
  55. _testStart()
  56. init().finally(_testFinish)