!2883 修复:材质贴图旋转后显示不正确的BUG

pull/2870/MERGE
罗春太 3 months ago committed by ChenX
parent 217abd1738
commit 8d5ad9263b

@ -1,4 +1,4 @@
import { DoubleSide, MathUtils, MeshPhongMaterial, MeshPhysicalMaterial, MeshPhysicalMaterial2, RepeatWrapping, Texture } from "three";
import { DoubleSide, MathUtils, MeshPhongMaterial, MeshPhysicalMaterial, MeshPhysicalMaterial2, RepeatWrapping, Texture, Vector2 } from "three";
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader";
import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices";
import { LoadImageFromUrl } from "../../Loader/ImageLoader";
@ -147,7 +147,7 @@ export async function ConverMaterial2(m: MeshPhongMaterial, url: string)
mtl[U_WORLD_REP] = data[U_WORLD_REP] ?? 1;
mtl[V_WORLD_REP] = data[V_WORLD_REP] ?? 1;
mtl[U_WORLD_RO] = MathUtils.DEG2RAD * (data[U_WORLD_RO] ?? data[U_RO] ?? 0);
mtl[U_WORLD_RO] = -MathUtils.DEG2RAD * (data[U_WORLD_RO] ?? data[U_RO] ?? 0);
mtl[U_WORLD_MOVE] = data[U_WORLD_MOVE] ?? 0;
mtl[V_WORLD_MOVE] = data[V_WORLD_MOVE] ?? 0;
@ -155,20 +155,15 @@ export async function ConverMaterial2(m: MeshPhongMaterial, url: string)
else
{
t.repeat.set(data[U_REP] ?? 1, data[V_REP] ?? 1);
t.rotation = MathUtils.DEG2RAD * data[U_RO] ?? 0;
if (data[U_MOVE] !== undefined)
t.offset.set(
//1. 0.5 - rep *0.5 位移到中心0.5,0.5
//2. 后面部分再次位移
0.5 - t.repeat.x * 0.5 + t.repeat.x * data[U_MOVE],
0.5 - t.repeat.y * 0.5 - t.repeat.y * data[V_MOVE],
);
else
t.offset.set(
//1. 0.5 - rep *0.5 位移到中心0.5,0.5
0.5 - t.repeat.x * 0.5,
0.5 - t.repeat.y * 0.5,
);
t.rotation = -MathUtils.DEG2RAD * data[U_RO] ?? 0;
//位移到中心0.5,0.5
t.offset.set((1 - t.repeat.x) * 0.5, (1 - t.repeat.y) * 0.5);
if (data[U_MOVE] !== undefined || data[V_MOVE] !== undefined)
{
let off = new Vector2(t.repeat.x * (data[U_MOVE] ?? 0), -t.repeat.y * (data[V_MOVE] ?? 0));
off.rotateAround(new Vector2(0, 0), -t.rotation);
t.offset.add(off);
}
}
}

Loading…
Cancel
Save