- Edited
Hi, my problem is that the 3D mesh only renders when I'm looking at it from the bottom. If the camera is pointing down and is above the mesh, nothing renders.
Note that it only happens with GDScript generated mesh.
Example of square planes slowly disappearing as I'm flying upwards: https://i.imgur.com/zkWmsc0.png
Code:
extends Spatial
var tmpMesh = Mesh.new()
var vertices = PoolVector3Array()
var normals = PoolVector3Array()
var UVs = PoolVector2Array()
var mat = SpatialMaterial.new()
func _ready():
var noise = OpenSimplexNoise.new()
noise.seed = randi()
noise.octaves = 4
noise.period = 20.0
noise.persistence = 0.8
var height = 0.10
var size = 0.01
for i in 1:
for j in 1:
vertices.push_back(Vector3((j+1)*size,height * noise.get_noise_2d(j, i),(i+0)*size))
vertices.push_back(Vector3((j+0)*size,height * noise.get_noise_2d(j, i),(i+0)*size))
vertices.push_back(Vector3((j+0)*size,height * noise.get_noise_2d(j, i),(i+1)*size))
vertices.push_back(Vector3((j+0)*size,height * noise.get_noise_2d(j, i),(i+1)*size))
vertices.push_back(Vector3((j+1)*size,height * noise.get_noise_2d(j, i),(i+1)*size))
vertices.push_back(Vector3((j+1)*size,height * noise.get_noise_2d(j, i),(i+0)*size))
mat.albedo_color = Color(0.9, 0.2, 0.5)
var st = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.set_material(mat)
for v in vertices.size():
var rand = rand_range(0.00, 1.00)
var color = Color(rand, rand, rand)
st.add_color(color)
st.add_vertex(vertices[v])
st.commit(tmpMesh)
$MeshInstance.mesh = tmpMesh