suitbim_addModelByProject.html 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  6. <meta
  7. name="viewport"
  8. content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
  9. />
  10. <meta
  11. name="description"
  12. content="Demonstrates use cases for a batch table hierarchy."
  13. />
  14. <meta name="cesium-sandcastle-labels" content="3D Tiles, SuitBIM" />
  15. <title>模型加载示例</title>
  16. <script type="text/javascript" src="../Build/Cesium/Cesium.js"></script>
  17. <script type="text/javascript" src="../Build/Cesium/Sandcastle-header.js"></script>
  18. </head>
  19. <body
  20. class="sandcastle-loading"
  21. data-sandcastle-bucket="bucket-requirejs.html"
  22. >
  23. <style>
  24. @import url(./templates/bucket.css);
  25. #toolbar button {
  26. display: block;
  27. }
  28. </style>
  29. <div id="cesiumContainer" class="fullSize"></div>
  30. <div id="loadingOverlay"><h1>Loading...</h1></div>
  31. <div id="toolbar"></div>
  32. <script id="cesium_sandcastle_script">
  33. window.startup = async function (Cesium) {
  34. "use strict";
  35. //Sandcastle_Begin
  36. const viewer = new Cesium.Viewer("cesiumContainer", {
  37. suitBaseSettings: true, // 基础设置按钮,例如透明度、抗锯齿等
  38. suitMeasure: true, // 测量工具
  39. suitClippings: false
  40. });
  41. viewer.scene.debugShowFramesPerSecond = true;
  42. viewer.scene.globe.depthTestAgainstTerrain = true; // 地形深度与普通的图形深度进行测试
  43. // 模型加载初始化
  44. const collection = viewer.addSuitcimTilesetCollection({
  45. // enableIndexedDB : false, // 默认值true,是否开启本地缓存,来存储已经请求过的模型数据
  46. // enablePackDownload : false, // 默认值:true, 启用该技术将有效地减少几何体数据的网络请求次数
  47. // enableOcclusion : false, // 默认值:true,是否启用遮挡剔除
  48. serverHost: "https://bimrun.com/bim/",
  49. });
  50. // 根据项目id加载模型
  51. collection.displayProjects([357554579]);
  52. // 拉进到模型
  53. collection.readyPromise.then(() => {
  54. viewer.zoomTo(collection);
  55. });
  56. // 模型构建信息获取
  57. const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
  58. handler.setInputAction(function (movement) {
  59. const pickedFeature = viewer.scene.pick(movement.position);
  60. pickedFeature.getPropertyIds().forEach((item) => {
  61. console.log(item + ": " + pickedFeature.getProperty(item));
  62. });
  63. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  64. //Sandcastle_End
  65. Sandcastle.finishedLoading();
  66. };
  67. if (typeof Cesium !== "undefined") {
  68. window.startupCalled = true;
  69. window.startup(Cesium);
  70. }
  71. </script>
  72. </body>
  73. </html>