Skip to content

Commit

Permalink
check for which span is bigger for some reason, fixes all stretching …
Browse files Browse the repository at this point in the history
…issues seemingly
  • Loading branch information
James Halliday committed Jan 7, 2013
1 parent e51b920 commit bca0037
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions index.js
Expand Up @@ -90,31 +90,48 @@ Mesh.prototype.faceVertexUv = function(i) {
this.meshed.vertices[i*4+2],
this.meshed.vertices[i*4+3]
]
var spans = {
x0: vs[0][0] - vs[1][0],
x1: vs[1][0] - vs[2][0],
y0: vs[0][1] - vs[1][1],
y1: vs[1][1] - vs[2][1],
z0: vs[0][2] - vs[1][2],
z1: vs[1][2] - vs[2][2]
}
var size = {
x: Math.max(
Math.abs(vs[0][0] - vs[1][0]),
Math.abs(vs[1][0] - vs[2][0])
),
y: Math.max(
Math.abs(vs[0][1] - vs[1][1]),
Math.abs(vs[1][1] - vs[2][1])
),
z: Math.max(
Math.abs(vs[0][2] - vs[1][2]),
Math.abs(vs[1][2] - vs[2][2])
)
x: Math.max(Math.abs(spans.x0), Math.abs(spans.x1)),
y: Math.max(Math.abs(spans.y0), Math.abs(spans.y1)),
z: Math.max(Math.abs(spans.z0), Math.abs(spans.z1))
}
if (size.x === 0) {
var width = size.z
var height = size.y
if (spans.y0 > spans.y1) {
var width = size.y
var height = size.z
}
else {
var width = size.z
var height = size.y
}
}
if (size.y === 0) {
var width = size.x
var height = size.z
if (spans.x0 > spans.x1) {
var width = size.x
var height = size.z
}
else {
var width = size.z
var height = size.x
}
}
if (size.z === 0) {
var width = size.x
var height = size.y
if (spans.x0 > spans.x1) {
var width = size.x
var height = size.y
}
else {
var width = size.y
var height = size.x
}
}
return [
new THREE.Vector2(0, 0),
Expand Down

0 comments on commit bca0037

Please sign in to comment.