Browse Source

feat: add

rindy 2 năm trước cách đây
mục cha
commit
6860dedf20
5 tập tin đã thay đổi với 98 bổ sung1 xóa
  1. 3 0
      .prettierignore
  2. 14 0
      .prettierrc
  3. 18 1
      public/smart-bim.html
  4. 59 0
      src/pages/Bim.vue
  5. 4 0
      src/pages/bim.js

+ 3 - 0
.prettierignore

@@ -0,0 +1,3 @@
+packages/kankan-sdk-deps/lib/*.js
+packages/kankan-sdk/dist/*.js
+packages/**/public/**/*.js

+ 14 - 0
.prettierrc

@@ -0,0 +1,14 @@
+{
+    "printWidth": 200,
+    "tabWidth": 4,
+    "useTabs": false,
+    "semi": false,
+    "singleQuote": true,
+    "arrowParens": "avoid",
+    "bracketSpacing": true,
+    "disableLanguages": [],
+    "eslintIntegration": false,
+    "stylelintIntegration": false,
+    "tslintIntegration": false,
+    "proseWrap": "preserve"
+}

+ 18 - 1
public/smart-bim.html

@@ -4,7 +4,23 @@
         <meta charset="utf-8" />
         <meta http-equiv="X-UA-Compatible" content="IE=edge" />
         <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
-        <title></title>
+        <title>BIM</title>
+        <style type="text/css">
+            * {
+              margin: 0;
+              padding: 0;
+            }
+      
+            html,
+            body {
+              height: 100%;
+            }
+      
+            #app {
+              width: 100%;
+              height: 100%;
+            }
+          </style>
     </head>
 
     <body>
@@ -12,5 +28,6 @@
             <strong>We're sorry but doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
         </noscript>
         <div id="app"></div>
+        <script src="https://static.bimface.com/api/BimfaceSDKLoader/BimfaceSDKLoader@latest-release.js"></script>
     </body>
 </html>

+ 59 - 0
src/pages/Bim.vue

@@ -0,0 +1,59 @@
+<template>
+    <div id="domId"></div>
+</template>
+<script setup>
+import { onMounted } from 'vue'
+
+let viewToken = 'fe69c34c232047989b3619489027d9df'
+// 声明Viewer及App
+let app
+let viewer3D
+let viewAdded = false
+
+// 加载成功回调函数
+const successCallback = viewMetaData => {
+    let dom4Show = document.getElementById('domId')
+    // 设置WebApplication3D的配置项
+    let webAppConfig = new Glodon.Bimface.Application.WebApplicationRfaConfig()
+    webAppConfig.domElement = dom4Show
+    webAppConfig.EnableFamilyList = false
+    // 设置模型爆炸配置项
+    webAppConfig.enableExplosion = true
+    // 创建WebApplication3D,用以显示模型
+    app = new Glodon.Bimface.Application.WebApplicationRfa(webAppConfig)
+    app.addView(viewToken)
+    viewer3D = app.getViewer()
+    // 监听添加view完成的事件
+    viewer3D.addEventListener(Glodon.Bimface.Viewer.Viewer3DEvent.ViewAdded, function () {
+        //自适应屏幕大小
+        window.onresize = function () {
+            viewer3D.resize(document.documentElement.clientWidth, document.documentElement.clientHeight - 40)
+        }
+        viewAdded = true
+        // 渲染3D模型
+        viewer3D.render()
+    })
+
+    // viewer3D.addEventListener(Glodon.Bimface.Viewer.ViewerDrawingEvent.MouseClicked, function (objectdata) {
+    //     // 调用viewerDrawing对象的Method,可以继续扩展功能
+    //     alert('objectId : ' + JSON.stringify(objectdata.objectId) + '\n' + 'worldPosition : ' + JSON.stringify(objectdata.worldPosition))
+    // })
+}
+
+// 加载失败回调函数
+const failureCallback = error => {
+    console.log(error)
+}
+
+onMounted(() => {
+    let loaderConfig = new BimfaceSDKLoaderConfig()
+    loaderConfig.viewToken = viewToken
+    BimfaceSDKLoader.load(loaderConfig, successCallback, failureCallback)
+})
+</script>
+<style lang="scss" scoped>
+#domId {
+    width: 100%;
+    height: 100%;
+}
+</style>

+ 4 - 0
src/pages/bim.js

@@ -0,0 +1,4 @@
+import { createApp } from 'vue'
+import App from './Bim.vue'
+const app = (window.__app = createApp(App))
+app.mount('#app')