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,7 +5,7 @@ import cloneDeep from 'lodash/cloneDeep' | ||
| 5 | import { chartInitConfig } from '@/settings/designSetting' | 5 | import { chartInitConfig } from '@/settings/designSetting' |
| 6 | 6 | ||
| 7 | export const option = { | 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 | backgroundColor: '', //场景背景色 | 9 | backgroundColor: '', //场景背景色 |
| 10 | backgroundAlpha: 0, //场景透明度 | 10 | backgroundAlpha: 0, //场景透明度 |
| 11 | enableDamping: false, //是否启用阻尼 | 11 | enableDamping: false, //是否启用阻尼 |
| @@ -18,7 +18,9 @@ export const option = { | @@ -18,7 +18,9 @@ export const option = { | ||
| 18 | */ | 18 | */ |
| 19 | outputEncoding: 'liner', | 19 | outputEncoding: 'liner', |
| 20 | clearScene: false, //是否清空场景内容 | 20 | clearScene: false, //是否清空场景内容 |
| 21 | - lights: [//灯光为数组,type 为 环境光(AmbientLight) | 方向光(DirectionalLight) | 点光(PointLight) | 半球光(HemisphereLight) | 21 | + lightInput: 1, |
| 22 | + lights: [ | ||
| 23 | + //灯光为数组,type 为 环境光(AmbientLight) | 方向光(DirectionalLight) | 点光(PointLight) | 半球光(HemisphereLight) | ||
| 22 | { | 24 | { |
| 23 | type: 'AmbientLight', | 25 | type: 'AmbientLight', |
| 24 | label: '环境光(只有颜色)', | 26 | label: '环境光(只有颜色)', |
| @@ -54,38 +56,41 @@ export const option = { | @@ -54,38 +56,41 @@ export const option = { | ||
| 54 | size: 1, | 56 | size: 1, |
| 55 | show: false | 57 | show: false |
| 56 | }, | 58 | }, |
| 57 | - position: [//模型位置 | 59 | + position: [ |
| 60 | + //模型位置 | ||
| 58 | { | 61 | { |
| 59 | x: 0, | 62 | x: 0, |
| 60 | y: 0, | 63 | y: 0, |
| 61 | z: 0 | 64 | z: 0 |
| 62 | } | 65 | } |
| 63 | ], | 66 | ], |
| 64 | - rotation: [//模型旋转 | 67 | + rotation: [ |
| 68 | + //模型旋转 | ||
| 65 | { | 69 | { |
| 66 | x: 0, | 70 | x: 0, |
| 67 | y: 0, | 71 | y: 0, |
| 68 | z: 0 | 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 | textStyle: { | 81 | textStyle: { |
| 77 | - fontFamily: "Arial", | 82 | + fontFamily: 'Arial', |
| 78 | fontSize: 18, | 83 | fontSize: 18, |
| 79 | - fontWeight: "normal", | 84 | + fontWeight: 'normal', |
| 80 | lineHeight: 1, | 85 | lineHeight: 1, |
| 81 | - color: "#ffffff", | 86 | + color: '#ffffff', |
| 82 | borderWidth: 8, | 87 | borderWidth: 8, |
| 83 | borderRadius: 4, | 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 | sid: null | 94 | sid: null |
| 90 | } | 95 | } |
| 91 | ] | 96 | ] |
| @@ -11,15 +11,15 @@ | @@ -11,15 +11,15 @@ | ||
| 11 | <n-input-number :min="0" v-model:value="optionData.borderConfig.size" size="small" /> | 11 | <n-input-number :min="0" v-model:value="optionData.borderConfig.size" size="small" /> |
| 12 | </setting-item> | 12 | </setting-item> |
| 13 | </setting-item-box> | 13 | </setting-item-box> |
| 14 | - <setting-item-box name="上传文件"> | 14 | + <setting-item-box name="上传文件"> |
| 15 | <setting-item> | 15 | <setting-item> |
| 16 | <FileUpload | 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 | </setting-item> | 23 | </setting-item> |
| 24 | </setting-item-box> | 24 | </setting-item-box> |
| 25 | <setting-item-box :alone="true"> | 25 | <setting-item-box :alone="true"> |
| @@ -78,8 +78,13 @@ | @@ -78,8 +78,13 @@ | ||
| 78 | </template> | 78 | </template> |
| 79 | </setting-item> | 79 | </setting-item> |
| 80 | </setting-item-box> | 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 | <setting-item-box name="灯光配置"> | 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 | <n-color-picker | 88 | <n-color-picker |
| 84 | v-if="!includeHemisphereLight.includes(item.type)" | 89 | v-if="!includeHemisphereLight.includes(item.type)" |
| 85 | size="small" | 90 | size="small" |
| 1 | <template> | 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 | <div v-if="useDetectWebGLContext()"> | 3 | <div v-if="useDetectWebGLContext()"> |
| 4 | <vue3dLoader | 4 | <vue3dLoader |
| 5 | ref="vue3dLoaderRef" | 5 | ref="vue3dLoaderRef" |
| @@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
| 20 | @load="onLoad" | 20 | @load="onLoad" |
| 21 | :position="position" | 21 | :position="position" |
| 22 | :rotation="rotation" | 22 | :rotation="rotation" |
| 23 | - :lights="lights" | 23 | + :lights="[lights[lightInput]]" |
| 24 | :showFps="showFps" | 24 | :showFps="showFps" |
| 25 | :labels="labels" | 25 | :labels="labels" |
| 26 | /> | 26 | /> |
| @@ -96,12 +96,13 @@ const { | @@ -96,12 +96,13 @@ const { | ||
| 96 | rotation, | 96 | rotation, |
| 97 | lights, | 97 | lights, |
| 98 | showFps, | 98 | showFps, |
| 99 | - labels | 99 | + labels, |
| 100 | + lightInput | ||
| 100 | } = toRefs(props.chartConfig.option) as any | 101 | } = toRefs(props.chartConfig.option) as any |
| 101 | 102 | ||
| 102 | watch(dataset, (newData: string) => { | 103 | watch(dataset, (newData: string) => { |
| 103 | //dateset为空则清除场景 | 104 | //dateset为空则清除场景 |
| 104 | - if(!newData) clearScene.value=true | 105 | + if (!newData) clearScene.value = true |
| 105 | }) | 106 | }) |
| 106 | </script> | 107 | </script> |
| 107 | 108 |