vue 使用 xbim/viewer进行BIM模型3D预览
作者:互联网
施工行业BIM模型使用XBIM进行预览
安装XBIM
使用 npm install @xbim/viewer --save 进行安装
创建vue组件
<canvas id="viewer" style="height: calc(50vh + 10px); width: 100%; z-index: 999; border-radius: 3px">
import { Viewer, NavigationCube, Grid, ViewType } from '@xbim/viewer'
created() {
this.initViewer()
},
initViewer() {
var check = Viewer.check()
if (check.noErrors) {
this.$nextTick(() => {
var viewer = new Viewer('viewer')
viewer.background = [216, 226, 236, 255]
const cube = new NavigationCube()
const grid = new Grid()
viewer.addPlugin(grid)
cube.ratio = 0.05
cube.passiveAlpha = cube.activeAlpha = 0.85
viewer.addPlugin(cube)
viewer.on('loaded', function () {
viewer.show(ViewType.DEFAULT, undefined, undefined, false)
viewer.start()
})
viewer.load('/data/100200.wexbim')
})
} else {
var msg = document.getElementById('msg')
msg.innerHTML = ''
for (var i in check.errors) {
var error = check.errors[i]
msg.innerHTML += "<div style='color: red;'>" + error + '</div>'
}
}
},
标签:cube,viewer,xbim,msg,BIM,var,check 来源: https://blog.csdn.net/weixin_36766709/article/details/113866556