threepipe
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

index.html 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Slippy Map Tiles (3D Tiles Renderer)</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <!-- Import maps polyfill -->
  8. <!-- Remove this when import maps will be widely supported -->
  9. <script async src="https://unpkg.com/es-module-shims@1.6.3/dist/es-module-shims.js"></script>
  10. <script type="importmap">
  11. {
  12. "imports": {
  13. "threepipe": "./../../dist/index.mjs",
  14. "@threepipe/plugin-3d-tiles-renderer": "./../../plugins/3d-tiles-renderer/dist/index.mjs"
  15. }
  16. }
  17. </script>
  18. <style id="example-style">
  19. html, body, #canvas-container, #mcanvas {
  20. width: 100%;
  21. height: 100%;
  22. margin: 0;
  23. overflow: hidden;
  24. }
  25. </style>
  26. <script type="module" src="../examples-utils/global-loading.mjs"></script>
  27. <script type="module" src="../examples-utils/simple-code-preview.mjs"></script>
  28. <script id="example-script" type="module" lang="ts">
  29. import {_testFinish, _testStart, LoadingScreenPlugin, ThreeViewer, SSAAPlugin} from 'threepipe'
  30. import {SlippyMapTilesLoadPlugin, EnvironmentControlsPlugin} from '@threepipe/plugin-3d-tiles-renderer'
  31. const viewer = new ThreeViewer({
  32. canvas: document.getElementById('mcanvas'),
  33. msaa: true, renderScale: window.devicePixelRatio,
  34. tonemap: false,
  35. })
  36. viewer.addPluginsSync([EnvironmentControlsPlugin, SlippyMapTilesLoadPlugin, LoadingScreenPlugin, SSAAPlugin])
  37. // todo once loaded small tiles, its not loading back the bigger ones on zoom out
  38. // also getting weird behaviour sometimes
  39. async function init() {
  40. viewer.scene.mainCamera.position.set(0,0, 20)
  41. viewer.scene.mainCamera.lookAt(0,0, 0)
  42. viewer.scene.mainCamera.minNearPlane = 0.1
  43. viewer.scene.mainCamera.setDirty()
  44. viewer.scene.mainCamera.controlsMode = 'environment'
  45. viewer.scene.mainCamera.controls.minDistance = 0.3
  46. viewer.scene.mainCamera.controls.maxDistance = 30
  47. // https://github.com/CesiumGS/3d-tiles-samples
  48. // from https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/master/example/data/root.b3dm
  49. const result = await viewer.load('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
  50. autoCenter: true,
  51. autoScale: true,
  52. autoScaleRadius: 30,
  53. fileExtension: SlippyMapTilesLoadPlugin.DUMMY_EXT,
  54. tiles: {
  55. errorTarget: 1,
  56. XYZTilesPlugin: {
  57. projection: 'planar',
  58. center: true
  59. },
  60. }
  61. })
  62. // result.rotation.x = - Math.PI / 2;
  63. }
  64. _testStart()
  65. init().finally(_testFinish)
  66. </script>
  67. </head>
  68. <body>
  69. <div id="canvas-container">
  70. <canvas id="mcanvas"></canvas>
  71. </div>
  72. </body>