提交 42a99e71 authored 作者: 詹银鑫's avatar 詹银鑫

3d模型添加贴图

上级 92f74167
......@@ -391,7 +391,8 @@ export class World extends Mini3d {
intensity: 200,
distance: 10000,
x: 0,
y: 2,
// y: 2,
y: -2,
z: 5,
})
}
......@@ -1282,9 +1283,27 @@ export class World extends Mini3d {
console.log("this.terrainResource",this.terrainResource);
// let terrainData = this.assets.instance.getResource("mapTerrain");
// console.log("terrainData", terrainData);
this.pngTexture = this.terrainResource.loaders.Texture.load("../../../public/assets/json/TrueColorImage.png");
this.pngTexture.flipY = false;
this.terrainResource.loaders.GLTF.load("../../../public/assets/json/Scene_cq15_200.gltf",
(gltf) => {
let terrain = gltf.scene;
// 调整 GLTF 模型的缩放比例和位置
terrain.scale.set(17, 17, 17);
// console.log("this.depth", this.depth);
// 根据需要调整位置
terrain.position.set(-0.8, this.depth + 1.1, 0.9);
terrain.traverse((node) => {
if (node.isMesh) {
// 替换基础颜色贴图
node.material.map = this.pngTexture;
node.material.needsUpdate = true; // 必须更新材质
// 若 PNG 需要透明度支持
node.material.transparent = true;
node.material.alphaTest = 0.5; // 避免边缘透明像素闪烁
}
});
this.scene.add(terrain);
},
(xhr) => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论