更新编辑模型,添加材质名支持
This commit is contained in:
parent
074ad202a9
commit
696e8b294e
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "material-editor",
|
"name": "material-editor",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.11",
|
"version": "1.0.12",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
@ -168,14 +168,7 @@ export class MaterialEditor
|
|||||||
setMaterial(mat: PhysicalMaterialRecord)
|
setMaterial(mat: PhysicalMaterialRecord)
|
||||||
{
|
{
|
||||||
this.Material = mat;
|
this.Material = mat;
|
||||||
// for (const child of this.ShowObject.children) {
|
|
||||||
// if (child instanceof Mesh) {
|
|
||||||
// child.material = mat.Material;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
console.log(mat.Material);
|
|
||||||
|
|
||||||
this._MeshMaterial.copy(mat.Material);
|
this._MeshMaterial.copy(mat.Material);
|
||||||
let mtl = this._MeshMaterial;
|
let mtl = this._MeshMaterial;
|
||||||
if (mtl.metalness > 0.8)
|
if (mtl.metalness > 0.8)
|
||||||
@ -216,7 +209,6 @@ export class MaterialEditor
|
|||||||
|
|
||||||
async Update()
|
async Update()
|
||||||
{
|
{
|
||||||
console.log("copy:", this.Material.Material.metalness);
|
|
||||||
let mat = this.ShowMesh.material as MeshPhysicalMaterial;
|
let mat = this.ShowMesh.material as MeshPhysicalMaterial;
|
||||||
mat.needsUpdate = true;
|
mat.needsUpdate = true;
|
||||||
|
|
||||||
|
@ -127,7 +127,8 @@ export interface MaterialRequest {
|
|||||||
const scene = useScene();
|
const scene = useScene();
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
readonly textureSrcList?: string[];
|
name?: string;
|
||||||
|
textureSrcList?: string[];
|
||||||
}>();
|
}>();
|
||||||
const emits = defineEmits<{
|
const emits = defineEmits<{
|
||||||
(e: 'cancel'): void;
|
(e: 'cancel'): void;
|
||||||
@ -138,7 +139,7 @@ const Material = computed(() => scene.Material);
|
|||||||
const CurrGeometry = computed(() => scene.CurrGeometry);
|
const CurrGeometry = computed(() => scene.CurrGeometry);
|
||||||
const Geometries = computed(() => scene.Geometries);
|
const Geometries = computed(() => scene.Geometries);
|
||||||
|
|
||||||
const debugMode = ref(false);
|
const debugMode = ref(true);
|
||||||
const _textureSrc = ref(props.textureSrcList);
|
const _textureSrc = ref(props.textureSrcList);
|
||||||
const debugTextureSrc = ref("");
|
const debugTextureSrc = ref("");
|
||||||
const textureAdjustment = ref<TextureAdjustment>({
|
const textureAdjustment = ref<TextureAdjustment>({
|
||||||
@ -159,7 +160,7 @@ const uploading = ref(false);
|
|||||||
// });
|
// });
|
||||||
const materialInfo = reactive({
|
const materialInfo = reactive({
|
||||||
dirId: DirectoryId.MaterialDir, // 正常来说是2
|
dirId: DirectoryId.MaterialDir, // 正常来说是2
|
||||||
materialName: '材质',
|
materialName: props.name || '材质',
|
||||||
inputText:'',
|
inputText:'',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -178,7 +179,6 @@ watch(textureAdjustment, async (val) => {
|
|||||||
|
|
||||||
// 监听纹理更新
|
// 监听纹理更新
|
||||||
watch(() => scene.CurrTexture, (val) => {
|
watch(() => scene.CurrTexture, (val) => {
|
||||||
console.log('watch-CurrTexture')
|
|
||||||
textureAdjustment.value = {
|
textureAdjustment.value = {
|
||||||
wrapS: val.wrapS,
|
wrapS: val.wrapS,
|
||||||
wrapT: val.wrapT,
|
wrapT: val.wrapT,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<CfFlex class="material-view">
|
<CfFlex class="material-view">
|
||||||
<div ref="container" class="material-view-container" />
|
<div ref="container" class="material-view-container" />
|
||||||
<MaterialAdjuster ref="adjuster" class="material-view-sider" :textureSrcList="textureSrc" @cancel="config.cancelCallback" @submit="config.submitCallback" />
|
<MaterialAdjuster ref="adjuster" class="material-view-sider" :name="matName" :textureSrcList="textureSrc" @cancel="config.cancelCallback" @submit="config.submitCallback" />
|
||||||
</CfFlex>
|
</CfFlex>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -19,6 +19,7 @@ const container = useTemplateRef('container');
|
|||||||
const adjusterRef = useTemplateRef('adjuster');
|
const adjusterRef = useTemplateRef('adjuster');
|
||||||
const config = GetConfig();
|
const config = GetConfig();
|
||||||
const textureSrc = ref<string[]>(Array.from(config.textureSrc));
|
const textureSrc = ref<string[]>(Array.from(config.textureSrc));
|
||||||
|
const matName = ref<string>();
|
||||||
|
|
||||||
// 禁用右键菜单
|
// 禁用右键菜单
|
||||||
document.addEventListener('contextmenu', (e) => e.preventDefault());
|
document.addEventListener('contextmenu', (e) => e.preventDefault());
|
||||||
@ -46,9 +47,9 @@ function HandleChangeTexture() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function HandleUpdateConfig() {
|
async function HandleUpdateConfig() {
|
||||||
if (config.file && config.file.length > 0) {
|
if (config.updateModel) {
|
||||||
console.log("base64", config.file);
|
matName.value = config.updateModel.name;
|
||||||
const json = FromDeflateBase64(config.file);
|
const json = FromDeflateBase64(config.updateModel.file);
|
||||||
await scene.ImportMaterialAsync(json);
|
await scene.ImportMaterialAsync(json);
|
||||||
}
|
}
|
||||||
textureSrc.value = Array.from(config.textureSrc);
|
textureSrc.value = Array.from(config.textureSrc);
|
||||||
|
@ -25,8 +25,13 @@ export type LibOutputConfig = {
|
|||||||
host: string,
|
host: string,
|
||||||
/** 材质贴图链接列表,场景会只会载入第一个链接作为纹理预览,但是导出提交时会为所有链接创建材质 */
|
/** 材质贴图链接列表,场景会只会载入第一个链接作为纹理预览,但是导出提交时会为所有链接创建材质 */
|
||||||
textureSrc: Array<string>,
|
textureSrc: Array<string>,
|
||||||
/** 材质预设数据,base64编码 */
|
/** 更新模型,对材质进行编辑时赋值 */
|
||||||
file?: string,
|
updateModel?: {
|
||||||
|
/** 材质名 */
|
||||||
|
name: string;
|
||||||
|
/** 材质预设数据,base64编码 */
|
||||||
|
file: string;
|
||||||
|
}
|
||||||
/** 环境贴图链接(立方体贴图,按照顺序输入[右左上下前后]) */
|
/** 环境贴图链接(立方体贴图,按照顺序输入[右左上下前后]) */
|
||||||
envTextureSrc: string[],
|
envTextureSrc: string[],
|
||||||
/** 灰度环境贴图链接,输入格式与环境贴图一致 */
|
/** 灰度环境贴图链接,输入格式与环境贴图一致 */
|
||||||
|
Loading…
Reference in New Issue
Block a user