Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export function get_mesh(is_faced){
- var mesh = {};
- mesh.vertices = [];
- mesh.normals = [];
- mesh.uvs = [];
- mesh.indices = [];
- var faces;
- /* +--------+
- * x/ /|
- * / / |
- * +--------+ |
- * ^| z-> | |
- * || | +
- * y| | /
- * | |/
- * +--------+
- */
- for(let x=0;x<=cell_size;x++){
- faces = get_faces(function(y,z){return is_faced(x, y, z, [-1,0,0]);});
- for(let i=0;i<faces.length;i++){
- add_face_x(mesh, x, faces[i]);
- }
- }
- for(let y=0;y<=cell_size;y++){
- faces = get_faces(function(x,z){return is_faced(x,y,z, [0,-1,0]);});
- for(let i=0;i<faces.length;i++){
- add_face_y(mesh, y, faces[i]);
- }
- }
- for(let z=0;z<=cell_size;z++){
- faces = get_faces(function(x,y){return is_faced(x,y,z, [0,0,-1]);});
- for(let i=0;i<faces.length;i++){
- add_face_z(mesh, z, faces[i]);
- }
- }
- return mesh;
- }
Advertisement
Add Comment
Please, Sign In to add comment