progressView.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>施工进度展示</title>
  6. <style type="text/css">
  7. * {
  8. margin: 0;
  9. padding: 0;
  10. }
  11. html,
  12. body {
  13. height: 100%;
  14. }
  15. .buttons {
  16. font-size: 0;
  17. }
  18. .button {
  19. margin: 5px 0 5px 5px;
  20. width: 100px;
  21. height: 30px;
  22. border-radius: 3px;
  23. border: none;
  24. background: #11DAB7;
  25. color: #FFFFFF;
  26. outline: none;
  27. }
  28. .main {
  29. display: flex;
  30. flex-direction: column;
  31. overflow: hidden;
  32. height: 100%;
  33. }
  34. #domId {
  35. flex: 1;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div class='main'>
  41. <div class='buttons'>
  42. <button class="button" id="btnSctPlaneAnimation" onclick="sectionPlaneAnimation()">施工进度展示</button>
  43. </div>
  44. <div id="domId"></div>
  45. </div>
  46. <script src="https://static.bimface.com/api/BimfaceSDKLoader/BimfaceSDKLoader@latest-release.js"></script>
  47. <script>
  48. var viewToken = '0a5b447abd0e451787ed4f82d5a7da30';
  49. // 声明Viewer及App
  50. var viewer3D;
  51. var app;
  52. var viewAdded = false;
  53. // 配置JSSDK加载项
  54. window.onload = function () {
  55. var loaderConfig = new BimfaceSDKLoaderConfig();
  56. loaderConfig.viewToken = viewToken;
  57. BimfaceSDKLoader.load(loaderConfig, successCallback, failureCallback);
  58. }
  59. // 加载成功回调函数
  60. function successCallback(viewMetaData) {
  61. var dom4Show = document.getElementById('domId');
  62. // 设置WebApplication3D的配置项
  63. var webAppConfig = new Glodon.Bimface.Application.WebApplication3DConfig();
  64. webAppConfig.domElement = dom4Show;
  65. // 创建WebApplication3D,用以显示模型
  66. app = new Glodon.Bimface.Application.WebApplication3D(webAppConfig);
  67. app.addView(viewToken);
  68. viewer3D = app.getViewer();
  69. // 增加加载完成监听事件
  70. viewer3D.addEventListener(Glodon.Bimface.Viewer.Viewer3DEvent.ViewAdded, function () {
  71. viewAdded = true;
  72. //自适应屏幕大小
  73. window.onresize = function () {
  74. viewer3D.resize(document.documentElement.clientWidth, document.documentElement.clientHeight - 40);
  75. }
  76. viewer3D.setCameraStatus({
  77. "name": "persp",
  78. "position": { "x": -30219.946765163415, "y": -45491.65416486451, "z": 29660.465140231066 },
  79. "target": { "x": 207832.38340026487, "y": 170233.69288006236, "z": -126343.72635548069 },
  80. "up": { "x": 0.3236896665312058, "y": 0.2933266544203183, "z": 0.8995468156730366 },
  81. "fov": 45,
  82. "zoom": 1,
  83. "version": 1,
  84. "coordinateSystem": "world"
  85. });
  86. viewer3D.hideComponentsByObjectData([
  87. {
  88. levelName: "Roof"
  89. },
  90. {
  91. levelName: "Parapet"
  92. },
  93. {
  94. levelName: "03 - Floor",
  95. categoryId: "-2000038"
  96. },
  97. {
  98. categoryId: "-2000023"
  99. }
  100. ]);
  101. createSectionPlane();
  102. // 渲染场景
  103. viewer3D.render();
  104. });
  105. }
  106. // 加载失败回调函数
  107. function failureCallback(error) {
  108. console.log(error);
  109. }
  110. // 构造剖切面并设置初始状态
  111. var sectionPlane = null;
  112. var originPt = { x: 0, y: 0, z: 7600 };
  113. var planeDirection = { x: 0, y: 0, z: 1 };
  114. var sectionPlaneOffset = 500;
  115. function createSectionPlane() {
  116. if (!viewAdded || sectionPlane) {
  117. return;
  118. }
  119. var sectionPlaneConfig = new Glodon.Bimface.Plugins.Section.SectionPlaneConfig();
  120. sectionPlaneConfig.viewer = viewer3D;
  121. sectionPlane = new Glodon.Bimface.Plugins.Section.SectionPlane(sectionPlaneConfig);
  122. sectionPlane.setPlane(Glodon.Bimface.Plugins.Section.SectionPlanePlane.Z);
  123. sectionPlane.setDirection(Glodon.Bimface.Plugins.Section.SectionPlaneDirection.Forward);
  124. sectionPlane.setPositionByPlane(originPt, planeDirection, sectionPlaneOffset);
  125. sectionPlane.setObjectsByObjectData([
  126. {
  127. categoryId: "-2000011",
  128. family: "基本墙"
  129. },
  130. {
  131. categoryId: "-2001330"
  132. }
  133. ]);
  134. sectionPlane.hidePlane();
  135. }
  136. function animate() {
  137. animationId = requestAnimationFrame(animate);
  138. sectionPlaneOffset += 50;
  139. if (sectionPlaneOffset > 3500) {
  140. sectionPlaneOffset = 500;
  141. }
  142. sectionPlane.setPositionByPlane(originPt, planeDirection, sectionPlaneOffset);
  143. viewer3D.render();
  144. }
  145. // 剖切面移动动画
  146. var isSectionPlaneAnimationActivated = false;
  147. var animationId = null;
  148. function sectionPlaneAnimation() {
  149. if (!viewAdded || !sectionPlane) {
  150. return;
  151. }
  152. if (!isSectionPlaneAnimationActivated) {
  153. animate();
  154. setButtonText('btnSctPlaneAnimation', '暂停进度展示');
  155. } else {
  156. cancelAnimationFrame(animationId);
  157. sectionPlaneOffset = 500;
  158. sectionPlane.setPositionByPlane(originPt, planeDirection, sectionPlaneOffset);
  159. viewer3D.render();
  160. setButtonText('btnSctPlaneAnimation', '施工进度展示');
  161. }
  162. isSectionPlaneAnimationActivated = !isSectionPlaneAnimationActivated;
  163. }
  164. // ************************** 按钮文字 **************************
  165. function setButtonText(btnId, text) {
  166. var dom = document.getElementById(btnId);
  167. if (dom != null && dom.nodeName == "BUTTON") {
  168. dom.innerText = text;
  169. }
  170. }
  171. </script>
  172. </body>
  173. </html>