threepipe
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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