arx-tools/arx-level-generator

normalizeUV() fails when a single polygon has more than 1.0 textures fit either horizontally or vertically

Opened this issue · 0 comments

This looks okay:

// 2x100 x 2x100 tiles
const geometry = new PlaneGeometry(200, 200, 2, 2)

const material = new MeshBasicMaterial({
  map: Material.fromTexture(Texture.l2TrollStoneGround04, { flags: ArxPolygonFlags.DoubleSided }),
})
const mesh = new Mesh(geometry, material)
geometry.rotateX(MathUtils.degToRad(-90))

// every tile 2x2 texture mapped onto
scaleUV(new Vector2(4, 4), geometry)

// normalizeUV(geometry)

applyTransformations(mesh)
mesh.translateX(map.config.offset.x)
mesh.translateY(map.config.offset.y)
mesh.translateZ(map.config.offset.z)
applyTransformations(mesh)
map.polygons.addThreeJsMesh(mesh, { tryToQuadify: QUADIFY, shading: SHADING_SMOOTH })

Observe that UV goes from 0.00 to 2.00
image

Enabling the normalizeUV(geometry) line will make the UV coordinates clamp from 0.00 to 0.00:
image