"use strict"; const MAX_BLOCK = process.argv[2]; const MAX_COLLECTION = process.argv[3]; const GAP = 2; console.log(process.argv); var csg = require("@jscad/csg").CSG; var block = []; var cube = csg.cube({ corner1: [0, 0, 0], corner2: [1, 1, 1] }); console.log("Creating " + MAX_BLOCK + "x" + MAX_BLOCK + " coplanar layer"); for (var x = 0; x < MAX_BLOCK; x++) { for (var y = 0; y < MAX_BLOCK; y++) { block.push(cube.translate([x, y, 0]).setColor([Math.random(), Math.random(), Math.random()])); } } console.log("Unioning " + MAX_BLOCK + "x" + MAX_BLOCK+ " coplanar layer"); block = block[0].union(block); console.log("creating " + MAX_COLLECTION + "x" + MAX_COLLECTION + " disconnected collection"); var collection = []; for (var x = 0; x < MAX_COLLECTION; x++) { for (var y = 0; y < MAX_COLLECTION; y++) { collection.push(block.translate([(MAX_COLLECTION + GAP) * x, (MAX_COLLECTION + GAP) * y, 0])); } } console.log("Unioning " + MAX_COLLECTION + "x" + MAX_COLLECTION + " disconnected collection"); collection = collection[0].union(collection); console.log("writing file"); var fs = require('fs'); var x3dSerializer = require('@jscad/x3d-serializer'); var output = x3dSerializer.serialize(collection); fs.writeFileSync("loadtest.x3d", output); console.log("Done");