修改更新

This commit is contained in:
xief
2025-05-29 15:53:01 +08:00
parent 16fac2ab19
commit 26f1c60a43
4 changed files with 69 additions and 61 deletions

View File

@@ -38,26 +38,26 @@
<label>金属度</label>
<CfFlex gap="1em">
<input v-model="model.metallic" type="range" min="0" max="1" step="0.01" />
<span>{{ model.metallic }}</span>
<input v-model="Material.matalness" @change="UpdateMaterial" type="range" min="0" max="1" step="0.01" />
<span>{{ Material.matalness }}</span>
</CfFlex>
<label>粗糙度</label>
<CfFlex gap="1em">
<input v-model="model.roughness" type="range" min="0" max="1" step="0.01" />
<span>{{ model.roughness }}</span>
<input v-model="Material.roughness" @change="UpdateMaterial" type="range" min="0" max="1" step="0.01" />
<span>{{ Material.roughness }}</span>
</CfFlex>
<label>法线强度</label>
<CfFlex gap="1em">
<input v-model="model.normalScale" type="range" min="0" max="1" step="0.01" />
<span>{{ model.normalScale }}</span>
<input v-model="Material.bumpScale" @change="UpdateMaterial" type="range" min="0" max="1" step="0.01" />
<span>{{ Material.bumpScale }}</span>
</CfFlex>
<label>高光</label>
<CfFlex gap="1em">
<input v-model="model.emissiveIntensity" type="range" min="0" max="1" step="0.01" />
<span>{{ model.emissiveIntensity }}</span>
<input v-model="Material.specular" @change="UpdateMaterial" type="range" min="0" max="1" step="0.01" />
<span>{{ Material.specular }}</span>
</CfFlex>
</div>
@@ -66,7 +66,7 @@
<label>启用纹理</label>
<input type="checkbox" v-model="enableTexture" />
<label>平铺U</label>
<!-- <label>平铺U</label>
<select v-model="textureAdjustment.wrapS">
<option value="0">镜像平铺</option>
<option value="1">平铺</option>
@@ -78,7 +78,7 @@
<option value="0">镜像平铺</option>
<option value="1">平铺</option>
<option value="2">展开</option>
</select>
</select> -->
<label>旋转</label>
<input v-model="textureAdjustment.rotation" type="number" step="0.01" min="0" max="359" />
@@ -115,7 +115,6 @@ import CfFlex from "./CfFlex.vue";
import { DirectoryId } from "../api/Request";
import { IsNullOrWhitespace } from "../helpers/helper.string";
import { FromDeflateBase64, ToDeflatedBase64 } from "../helpers/helper.material";
import { MaterialIn } from "../common/MaterialSerializer";
export interface MaterialRequest {
/** 材质名 */
@@ -150,12 +149,12 @@ const textureAdjustment = ref<TextureAdjustment>({
moveY: 0
});
const uploading = ref(false);
const model = reactive({
metallic: Material.value.matalness,
roughness: Material.value.roughness,
normalScale: Material.value.bumpScale,
emissiveIntensity: Material.value.specular
});
// const model = reactive({
// metallic: Material.value.matalness,
// roughness: Material.value.roughness,
// normalScale: Material.value.bumpScale,
// emissiveIntensity: Material.value.specular
// });
const materialInfo = reactive({
dirId: DirectoryId.MaterialDir, // 正常来说是2
materialName: '材质1',
@@ -171,9 +170,6 @@ watch(() => props.textureSrc, async (val) => {
await scene.ChangeTextureFromUrlAsync(_textureSrc.value);
});
watch(model, async (val) => {
await UpdateMaterial();
});
watch(enableTexture, async (val) => {
await EnableTexture(val);
@@ -185,6 +181,7 @@ watch(textureAdjustment, async (val) => {
// 监听纹理更新
watch(() => scene.CurrTexture, (val) => {
console.log('watch-CurrTexture')
textureAdjustment.value = {
wrapS: val.wrapS,
wrapT: val.wrapT,
@@ -197,15 +194,17 @@ watch(() => scene.CurrTexture, (val) => {
})
async function UpdateMaterial() {
Material.value.matalness = model.metallic;
Material.value.roughness = model.roughness;
Material.value.bumpScale = model.normalScale;
Material.value.specular = model.emissiveIntensity;
console.log(scene.CurrentShowObject)
// Material.value.matalness = model.metallic;
// Material.value.roughness = model.roughness;
// Material.value.bumpScale = model.normalScale;
// Material.value.specular = model.emissiveIntensity;
// Material.value.side = DoubleSide;
await scene.UpdateMaterialAsync();
}
function UpdateTexture() {
console.log('UpdateTexture')
const texture = scene.CurrTexture;
const val = textureAdjustment.value;
texture.wrapS = val.wrapS;
@@ -228,8 +227,7 @@ async function loadData() {
if(!materialInfo.inputText) return;
const json = JSON.parse(materialInfo.inputText);
const cadFile = FromDeflateBase64(json.file);
MaterialIn(JSON.parse(cadFile));
scene.ImportMaterialAsync(cadFile)
}
async function HandleUpload() {