Commit 0d4c0edfa14a22c8cdb738f1d9a384d3dba577c9

Authored by fengwotao
1 parent 95d6ff52

perf(external/Composes): 引入Threejs插件和部分静态文件,新增部分三维可配置属性

... ... @@ -119,37 +119,37 @@ watch(
119 119 //TODO:三维静态路径地址,无法通过import.meta.globEager来引入,要报错,待优化
120 120 const pathList = [
121 121 {
122   - label: '3D厂房',
123   - value: 'src/assets/external/models/fbx/厂房.fbx',
  122 + label: '猫模型',
  123 + value: 'src/assets/external/models/fbx/cat.fbx',
124 124 type: 'fbx'
125 125 },
126 126 {
127   - label: '树',
128   - value: 'src/assets/external/models/obj/tree.obj',
129   - type: 'obj'
  127 + label: '枪拖把模型',
  128 + value: 'src/assets/external/models/gltf/Sniper_Stand.glb',
  129 + type: 'gltf'
130 130 },
131 131 {
132   - label: 'gltf类型',
133   - value: 'src/assets/external/models/gltf/DamagedHelmet.gltf',
134   - type: 'gltf'
  132 + label: '飞机模型',
  133 + value: 'src/assets/external/models/obj/11803_Airplane_v1_l1.obj',
  134 + type: 'obj'
135 135 },
136 136 {
137   - label: '白色物体',
138   - value: 'src/assets/external/models/stl/colored.stl',
  137 + label: '踏月桥模型',
  138 + value: 'src/assets/external/models/stl/踏月桥.stl',
139 139 type: 'stl'
140 140 },
141 141 {
142   - label: '舞动的机器人',
143   - value: 'src/assets/external/models/collada/stormtrooper.dae',
  142 + label: '龙模型',
  143 + value: 'src/assets/external/models/collada/Dragon 2.5_dae.dae',
144 144 type: 'dae'
145 145 },
146 146 {
147   - label: '雕像',
148   - value: 'src/assets/external/models/ply/Lucy100k.ply',
  147 + label: '战斗机模型',
  148 + value: 'src/assets/external/models/ply/Intergalactic_Spaceship-(Ply).ply',
149 149 type: 'ply'
150 150 },
151 151 {
152   - label: '正方体',
  152 + label: '正方体模型',
153 153 value: 'src/assets/external/models/json/lightmap.json',
154 154 type: 'json'
155 155 }
... ... @@ -157,8 +157,6 @@ const pathList = [
157 157
158 158 /**
159 159 * 三维文件格式,vue-3d-loader是这个插件支持的格式,其他格式待解决
160   - * glb是gltf文件的二进制形式
161   - * 有些格式需要联合使用,需要贴纹理或者图片等,搭配使用比如(obj,mtl) (fbx,jpg)
162 160 */
163 161 const threeSupportFileFormat = ['fbx', 'obj', 'gltf', 'stl', 'dae', 'glb', 'ply', 'json']
164 162
... ...
... ... @@ -21,17 +21,20 @@
21 21 @click="onClick"
22 22 />
23 23 <div v-show="show" class="process">
24   - <span>拼命加载中...</span>
25   - <n-progress status="success" type="line" :percentage="process" :indicator-placement="'inside'" processing />
  24 + <span> 拼命加载中... </span>
  25 + <n-progress type="line" :color="themeColor" :percentage="process" :indicator-placement="'inside'" processing />
26 26 </div>
27 27 </div>
28 28 <div v-else>您的浏览器不支持WebGL!</div>
29 29 </div>
30 30 </template>
31 31 <script setup lang="ts">
32   -import { PropType, toRefs, ref, onMounted, nextTick } from 'vue'
  32 +import { PropType, toRefs, ref, onMounted, nextTick, computed } from 'vue'
33 33 import { CreateComponentType } from '@/packages/index.d'
34 34 import { vue3dLoader } from 'vue-3d-loader'
  35 +import { useDesignStore } from '@/store/modules/designStore/designStore'
  36 +
  37 +const designStore = useDesignStore()
35 38
36 39 const props = defineProps({
37 40 chartConfig: {
... ... @@ -40,6 +43,11 @@ const props = defineProps({
40 43 }
41 44 })
42 45
  46 +// 颜色
  47 +const themeColor = computed(() => {
  48 + return designStore.getAppTheme
  49 +})
  50 +
43 51 const vue3dLoaderRef = ref(null)
44 52
45 53 //threejs配置
... ... @@ -49,10 +57,9 @@ const webGLRendererOptions = {
49 57 preserveDrawingBuffer: true //缩略图生效需开启
50 58 }
51 59
52   -//标注示例
  60 +//标注示例可以多个支持图片和文字
53 61 const labels = ref()
54 62 labels.value = [
55   - // text label
56 63 {
57 64 text: 'co2浓度:44',
58 65 position: { x: 0, y: 18, z: 0 },
... ... @@ -69,6 +76,23 @@ labels.value = [
69 76 backgroundColor: 'rgba(0,0,0,1)'
70 77 },
71 78 sid: 3 // 自定义标识,可有可无
  79 + },
  80 + {
  81 + text: '氧气浓度:100',
  82 + position: { x: 10, y: 18, z: 0 },
  83 + scale: { x: 11.5, y: 10.8, z: 30.5 },
  84 + textStyle: {
  85 + fontFamily: 'Arial',
  86 + fontSize: 12,
  87 + fontWeight: 600,
  88 + lineHeight: 1,
  89 + color: '#ffffff',
  90 + borderWidth: 8,
  91 + borderRadius: 0,
  92 + borderColor: '#000000',
  93 + backgroundColor: 'rgba(0,0,0,1)'
  94 + },
  95 + sid: 4 // 自定义标识,可有可无
72 96 }
73 97 ]
74 98
... ... @@ -85,8 +109,7 @@ const onLoad = async () => {
85 109 const process = ref(0)
86 110
87 111 const onProcess = (event: any) => {
88   - // 拼命加载中,加载进度
89   - process.value = Math.floor(event.loaded / event.total) * 100
  112 + process.value= Math.floor((event.loaded / event.total) * 100)
90 113 }
91 114
92 115 const onClick = (event: any) => {
... ... @@ -120,7 +143,7 @@ const {
120 143 dataset,
121 144 outputEncoding,
122 145 clearScene,
123   - dampingFactor,
  146 + dampingFactor
124 147 } = toRefs(props.chartConfig.option) as any
125 148 </script>
126 149
... ... @@ -132,6 +155,7 @@ const {
132 155 position: absolute;
133 156 top: 50%;
134 157 left: 50%;
  158 + width: 50%;
135 159 transform: translate(-50%, -50%);
136 160 }
137 161 }
... ...