1
This commit is contained in:
@ -72,28 +72,35 @@ export class GameManager extends Monobehiver {
|
||||
return;
|
||||
}
|
||||
|
||||
// 初始化材质字典
|
||||
// 初始化材质和网格字典
|
||||
this.updateDictionaries();
|
||||
|
||||
this.cacheRollerDoorMeshes();
|
||||
console.log('材质字典:', this.materialDic);
|
||||
this.setRollerDoorScale("Box006.001", new Vector3(0.12, 0.02, 0.118));
|
||||
this.setRollerDoorScale("Box005.001", new Vector3(0.13, 0.02, 0.12));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新材质和网格字典(从场景中同步)
|
||||
*/
|
||||
updateDictionaries(): void {
|
||||
const scene = this.mainApp.appScene?.object;
|
||||
if (!scene) return;
|
||||
|
||||
// 更新材质字典
|
||||
for (const mat of scene.materials) {
|
||||
if (!this.materialDic.Has(mat.name)) {
|
||||
// 初始化材质属性
|
||||
// mat.transparencyMode = PBRMaterial.PBRMATERIAL_ALPHABLEND;
|
||||
this.materialDic.Set(mat.name, mat as PBRMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化网格字典
|
||||
// 更新网格字典
|
||||
for (const mesh of scene.meshes) {
|
||||
if (mesh instanceof Mesh) {
|
||||
|
||||
if (mesh instanceof Mesh && !this.meshDic.Has(mesh.name)) {
|
||||
this.meshDic.Set(mesh.name, mesh);
|
||||
}
|
||||
}
|
||||
this.cacheRollerDoorMeshes();
|
||||
console.log('材质字典:', this.materialDic);
|
||||
this.setRollerDoorScale("Box006.001", new Vector3(0.12,0.02,0.118));
|
||||
|
||||
// 单独设置 Box005.001 的缩放为 (1, 2, 1)
|
||||
this.setRollerDoorScale("Box005.001", new Vector3(0.13,0.02,0.12));
|
||||
}
|
||||
|
||||
/** 初始化设置材质 */
|
||||
@ -760,11 +767,14 @@ export class GameManager extends Monobehiver {
|
||||
|
||||
// 3. 应用材质到目标网格
|
||||
targetMaterials.forEach(material => {
|
||||
if (material[attribute]) {
|
||||
if (attribute === 'baseColor' && typeof value === 'string') {
|
||||
// 如果是 baseColor 且值是字符串(16进制颜色),转换为 Color3
|
||||
material.albedoColor = Color3.FromHexString(value);
|
||||
console.log(`Applying baseColor ${value} to material: ${material.name}`);
|
||||
} else if (material[attribute]) {
|
||||
material[attribute] = value;
|
||||
console.log(`Applying attribute ${attribute} to ${value} to mesh: ${material.name}`);
|
||||
}
|
||||
console.log(`Applying attribute ${attribute} to ${value} to mesh: ${material.name}`);
|
||||
// 这里需要根据实际的材质系统实现
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user