diff --git a/base/Sources/arm/Project.hx b/base/Sources/arm/Project.hx index 6cc6a6ad..7b409f6d 100644 --- a/base/Sources/arm/Project.hx +++ b/base/Sources/arm/Project.hx @@ -205,7 +205,7 @@ class Project { var raw: TMeshData = null; if (Context.raw.projectType == ModelSphere || Context.raw.projectType == ModelTessellatedPlane) { var mesh: Dynamic = Context.raw.projectType == ModelSphere ? - new arm.geom.Sphere(1, 512, 256) : + new arm.geom.UVSphere(1, 512, 256) : new arm.geom.Plane(1, 1, 512, 512); raw = { name: "Tessellated", diff --git a/base/Sources/arm/geom/Sphere.hx b/base/Sources/arm/geom/UVSphere.hx similarity index 93% rename from base/Sources/arm/geom/Sphere.hx rename to base/Sources/arm/geom/UVSphere.hx index 05c7eebc..44851f5a 100644 --- a/base/Sources/arm/geom/Sphere.hx +++ b/base/Sources/arm/geom/UVSphere.hx @@ -1,6 +1,6 @@ package arm.geom; -class Sphere { +class UVSphere { public var posa: kha.arrays.Int16Array = null; public var nora: kha.arrays.Int16Array = null; @@ -14,6 +14,7 @@ class Sphere { public function new(radius = 1.0, widthSegments = 32, heightSegments = 16, stretchUV = true, uvScale = 1.0) { // Pack positions to (-1, 1) range scalePos = radius; + scaleTex = uvScale; var inv = (1 / scalePos) * 32767; var pi2 = Math.PI * 2; @@ -48,8 +49,8 @@ class Sphere { posa[i4 + 3] = Std.int(nor.z * 32767); nora[i2 ] = Std.int(nor.x * 32767); nora[i2 + 1] = Std.int(nor.y * 32767); - texa[i2 ] = Std.int((u + uOff) * 32767 * uvScale) % 32767; - texa[i2 + 1] = Std.int(vFlip * 32767 * uvScale) % 32767; + texa[i2 ] = (Std.int((u + uOff) * 32767) - 1) % 32767; + texa[i2 + 1] = (Std.int(vFlip * 32767) - 1) % 32767; pos++; } }