Commit fef8ee5f448223016452e5d939e423e53044f7d0
1 parent
c845c5b2
feat(src/packages): 优化三维模型灯光选择对应灯光进行配置
Showing
3 changed files
with
38 additions
and
27 deletions
... | ... | @@ -5,7 +5,7 @@ import cloneDeep from 'lodash/cloneDeep' |
5 | 5 | import { chartInitConfig } from '@/settings/designSetting' |
6 | 6 | |
7 | 7 | export const option = { |
8 | - dataset: [new URL('/src/assets/external/three/test.obj', import.meta.url).href],//三维数据源 | |
8 | + dataset: [new URL('/src/assets/external/three/test.obj', import.meta.url).href], //三维数据源 | |
9 | 9 | backgroundColor: '', //场景背景色 |
10 | 10 | backgroundAlpha: 0, //场景透明度 |
11 | 11 | enableDamping: false, //是否启用阻尼 |
... | ... | @@ -18,7 +18,9 @@ export const option = { |
18 | 18 | */ |
19 | 19 | outputEncoding: 'liner', |
20 | 20 | clearScene: false, //是否清空场景内容 |
21 | - lights: [//灯光为数组,type 为 环境光(AmbientLight) | 方向光(DirectionalLight) | 点光(PointLight) | 半球光(HemisphereLight) | |
21 | + lightInput: 1, | |
22 | + lights: [ | |
23 | + //灯光为数组,type 为 环境光(AmbientLight) | 方向光(DirectionalLight) | 点光(PointLight) | 半球光(HemisphereLight) | |
22 | 24 | { |
23 | 25 | type: 'AmbientLight', |
24 | 26 | label: '环境光(只有颜色)', |
... | ... | @@ -54,38 +56,41 @@ export const option = { |
54 | 56 | size: 1, |
55 | 57 | show: false |
56 | 58 | }, |
57 | - position: [//模型位置 | |
59 | + position: [ | |
60 | + //模型位置 | |
58 | 61 | { |
59 | 62 | x: 0, |
60 | 63 | y: 0, |
61 | 64 | z: 0 |
62 | 65 | } |
63 | 66 | ], |
64 | - rotation: [//模型旋转 | |
67 | + rotation: [ | |
68 | + //模型旋转 | |
65 | 69 | { |
66 | 70 | x: 0, |
67 | 71 | y: 0, |
68 | 72 | z: 0 |
69 | 73 | } |
70 | 74 | ], |
71 | - showFps:false,//是否显示fps | |
72 | - labels:[ //添加图片/文字标签,暂且支持文字 | |
75 | + showFps: false, //是否显示fps | |
76 | + labels: [ | |
77 | + //添加图片/文字标签,暂且支持文字 | |
73 | 78 | { |
74 | - image: "", | |
75 | - text: "", | |
79 | + image: '', | |
80 | + text: '', | |
76 | 81 | textStyle: { |
77 | - fontFamily: "Arial", | |
82 | + fontFamily: 'Arial', | |
78 | 83 | fontSize: 18, |
79 | - fontWeight: "normal", | |
84 | + fontWeight: 'normal', | |
80 | 85 | lineHeight: 1, |
81 | - color: "#ffffff", | |
86 | + color: '#ffffff', | |
82 | 87 | borderWidth: 8, |
83 | 88 | borderRadius: 4, |
84 | - borderColor: "rgba(0,0,0,1)", | |
85 | - backgroundColor: "rgba(0, 0, 0, 1)" | |
89 | + borderColor: 'rgba(0,0,0,1)', | |
90 | + backgroundColor: 'rgba(0, 0, 0, 1)' | |
86 | 91 | }, |
87 | - position: {x:0, y:0, z:0}, | |
88 | - scale:{x:1, y:1, z:0}, | |
92 | + position: { x: 0, y: 0, z: 0 }, | |
93 | + scale: { x: 1, y: 1, z: 0 }, | |
89 | 94 | sid: null |
90 | 95 | } |
91 | 96 | ] | ... | ... |
... | ... | @@ -11,15 +11,15 @@ |
11 | 11 | <n-input-number :min="0" v-model:value="optionData.borderConfig.size" size="small" /> |
12 | 12 | </setting-item> |
13 | 13 | </setting-item-box> |
14 | - <setting-item-box name="上传文件"> | |
14 | + <setting-item-box name="上传文件"> | |
15 | 15 | <setting-item> |
16 | 16 | <FileUpload |
17 | - :max="100" | |
18 | - :fileList="optionData.dataset" | |
19 | - :threeSupportFileFormat="threeSupportFileFormat" | |
20 | - :singleFileType="singleFileTypeNotMtl" | |
21 | - @fileStaticUri="handleFileStaticUri" | |
22 | - /> | |
17 | + :max="100" | |
18 | + :fileList="optionData.dataset" | |
19 | + :threeSupportFileFormat="threeSupportFileFormat" | |
20 | + :singleFileType="singleFileTypeNotMtl" | |
21 | + @fileStaticUri="handleFileStaticUri" | |
22 | + /> | |
23 | 23 | </setting-item> |
24 | 24 | </setting-item-box> |
25 | 25 | <setting-item-box :alone="true"> |
... | ... | @@ -78,8 +78,13 @@ |
78 | 78 | </template> |
79 | 79 | </setting-item> |
80 | 80 | </setting-item-box> |
81 | + <setting-item-box name="灯光选择"> | |
82 | + <setting-item name="灯光选择((0,环境光),(1,方向光),(2,点光),(3,半球光))"> | |
83 | + <n-input-number :min="0" :max="3" v-model:value="optionData.lightInput" size="small" /> | |
84 | + </setting-item> | |
85 | + </setting-item-box> | |
81 | 86 | <setting-item-box name="灯光配置"> |
82 | - <setting-item v-for="(item, index) in optionData.lights" :name="item.label" :key="index"> | |
87 | + <setting-item v-for="(item, index) in [optionData.lights[optionData.lightInput]]" :name="item.label" :key="index"> | |
83 | 88 | <n-color-picker |
84 | 89 | v-if="!includeHemisphereLight.includes(item.type)" |
85 | 90 | size="small" | ... | ... |
1 | 1 | <template> |
2 | - <div class="go-content-box" :style="{ border: !borderConfig.show ? 'none' : ''}"> | |
2 | + <div class="go-content-box" :style="{ border: !borderConfig.show ? 'none' : '' }"> | |
3 | 3 | <div v-if="useDetectWebGLContext()"> |
4 | 4 | <vue3dLoader |
5 | 5 | ref="vue3dLoaderRef" |
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | @load="onLoad" |
21 | 21 | :position="position" |
22 | 22 | :rotation="rotation" |
23 | - :lights="lights" | |
23 | + :lights="[lights[lightInput]]" | |
24 | 24 | :showFps="showFps" |
25 | 25 | :labels="labels" |
26 | 26 | /> |
... | ... | @@ -96,12 +96,13 @@ const { |
96 | 96 | rotation, |
97 | 97 | lights, |
98 | 98 | showFps, |
99 | - labels | |
99 | + labels, | |
100 | + lightInput | |
100 | 101 | } = toRefs(props.chartConfig.option) as any |
101 | 102 | |
102 | 103 | watch(dataset, (newData: string) => { |
103 | 104 | //dateset为空则清除场景 |
104 | - if(!newData) clearScene.value=true | |
105 | + if (!newData) clearScene.value = true | |
105 | 106 | }) |
106 | 107 | </script> |
107 | 108 | ... | ... |