It looks like you're new here. If you want to get involved, click one of these buttons!

First of all. I am using the latest Beta. I used this code here to generate a sphere(for a planet), and always scale the surface 100 meters away. With my distance and radius parameter, i control the distance and parameter. This all works when I am decreasing the distance or increasing the radius, but as if i come closer and go further again it stays the same. I am sure I did everything correctly. Here is the code:

```
function setup()
s = sphere(600000)
parameter.number("d",601000,800000,800000)
parameter.number("r",500000,600000,500000)
end
function draw()
scl = (d-r)/100
perspective(90)
camera(0,d/scl,0,0,0,0,0,0,1)
scale(r/scl)
s:draw()
end
function sphere(radius)
s = mesh()
vertices = {}
for x = -180, 175, 5 do
for y = -90, 85, 5 do
table.insert(vertices,sphereRotate(x,y)*radius/600000)
table.insert(vertices,sphereRotate(x+5,y)*radius/600000)
table.insert(vertices,sphereRotate(x+5,y+5)*radius/600000)
table.insert(vertices,sphereRotate(x,y)*radius/600000)
table.insert(vertices,sphereRotate(x+5,y+5)*radius/600000)
table.insert(vertices,sphereRotate(x,y+5)*radius/600000)
end
end
s.vertices = vertices
s:setColors(color(0,0,255,255))
return s
end
function rotate3D(vec,angle,x,y,z)
x = x or 0
y = y or 0
z = z or 1
local a,s,c = math.rad(angle),math.sin,math.cos
if x == 1 then
return vec3(vec.x,vec.y*c(a)-vec.z*s(a),vec.y*s(a)+vec.z*c(a))
elseif y == 1 then
return vec3(vec.z*c(a)-vec.x*s(a),vec.y,vec.z*c(a)-vec.x*s(a))
elseif z == 1 then
return vec3(vec.x*c(a)-vec.y*s(a),vec.x*s(a)+vec.y*c(a),vec.z)
end
return vec
end
function sphereRotate(x,y)
return rotate3D(rotate3D(vec3(0,1,0),y,1,0,0),x,0,0,1)
end
```

## Comments

@GR00G0 Please post bugs and comments on the beta in the beta thread. https://codea.io/talk/discussion/8298/codea-craft-2-5-74-75-76-beta#latest

Also, please reformat your code so that you have three ~ before and after your code.

Also I cant even change it for some reason. Wether or not I have the 3 ~ there it always highlights that part.

@GR00G0 I don't understand why you are trying to use meshes to create your planets, as Codea Craft would be much simpler. Is there a limitation of Codea Craft that makes it not worth using in this instance?

@GR00G0 The 3~'s have to be on a line by themselves. You had them as

`~~~function setup`

and`end~~~`

.@GR00G0 Example of how easy this is to do with Codea Craft:

@Attila717 Its just with the lack of documentation, things are way simpler for me using normal meshes.

@GR00G0 You forgot background(0) at the start of the draw() function. That's the reason your circle gets bigger but not smaller. You're not clearing the previous drawings.

Here's a sphere program I have.

@GR00G0 How much do you know about putting an image onto a mesh. I don't want to be to basic if you know some stuff already, or I don't want to get to involved if you don't know too much.

EDIT: Instead of my explaining it, here's a link that will give you a better explanation.

@dave1707 i know how to map textures onto a sphere, but what I want to know is if I have a sphere, with the the surface about 1 meter away, and another mesh wich is bigger than 1 m, how I can draw the bigger mesh in front of the other mesh. i need this so I can scale down the planet by alot.

@GR00G0 So what I'm hearing is that you want the sphere that makes up the solid body of the planet behind some other mesh (with an image texture) that encases the aforementioned sphere?

@Attila717 This is just something thats gonna happen when I scale the planet down.

Scalimg down the radius also means scaling down the distance. the actual mesh could just be a few meters away. and having a rocket in front of you would collide it with the planet(or it would just be inside it).