mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
Fix: scroll track textures at the same rate
Dragging a tank's track scrolled its roughness/metalness texture at twice the speed of the base color and normal textures, so highlights drifted off the track links. **Cause** - `translateTexture` added the scroll offset to `roughnessMap` and `metalnessMap` separately - glTF has a single metallic-roughness texture, and the loader assigns that same texture object to both slots, so it received the offset twice **Changes** - Collect the track's maps in a `Set` before scrolling so a texture shared between slots is offset exactly once
This commit is contained in:
1 parent
067c9cb267
commit
c2c586c2e7
1 file changed
+11
-5
+11
-5
@@ -51,11 +51,17 @@ export function TankModel() {
|
|||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
||||||
if (material.map) material.map.offset.y += offset;
|
const textures = new Set([
|
||||||
if (material.aoMap) material.aoMap.offset.y += offset;
|
material.map,
|
||||||
if (material.normalMap) material.normalMap.offset.y += offset;
|
material.aoMap,
|
||||||
if (material.roughnessMap) material.roughnessMap.offset.y += offset;
|
material.normalMap,
|
||||||
if (material.metalnessMap) material.metalnessMap.offset.y += offset;
|
material.roughnessMap,
|
||||||
|
material.metalnessMap,
|
||||||
|
]);
|
||||||
|
|
||||||
|
for (const texture of textures) {
|
||||||
|
if (texture) texture.offset.y += offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPointerDown(event: ThreeEvent<PointerEvent>) {
|
function onPointerDown(event: ThreeEvent<PointerEvent>) {
|
||||||
|
|||||||
Reference in new issue
Block a user