Permalink
Browse files

check for which span is bigger for some reason, fixes all stretching …

…issues seemingly
  • Loading branch information...
1 parent e51b920 commit bca00371b64b337a092fb17ea2d9d4ae05cd3759 @substack substack committed Jan 7, 2013
Showing with 35 additions and 18 deletions.
  1. +35 −18 index.js
View
@@ -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),

0 comments on commit bca0037

Please sign in to comment.