Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tool
- extends MeshInstance
- var meshArray: = ArrayMesh.new()
- export (bool) var generate:bool = false setget set_generate
- var points: = [
- Vector3(-0.7, 0, -0.7),
- Vector3(-0.3, 0, 0.8),
- Vector3(0.8, 0, -0.3),
- Vector3(0, -1, 0),
- ]
- func set_generate(_value:bool)->void:
- generate = false
- var arr = []
- arr.resize(Mesh.ARRAY_MAX)
- var vertex: = PoolVector3Array(points)
- var indexes: = PoolIntArray([0,1,3,1,2,3,2,0,3,2,1,0 ])
- var normals: = []
- arr[Mesh.ARRAY_VERTEX] = vertex
- arr[Mesh.ARRAY_INDEX] = indexes
- for point in points:
- normals.append(point.normalized())
- arr[Mesh.ARRAY_NORMAL] = PoolVector3Array(normals)
- meshArray.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arr)
- mesh = meshArray
Add Comment
Please, Sign In to add comment