Voxc.js is meant to be a lightweight, easy to use library for converting voxel objects into JavaScript matrixes for easy manipulation. These matrixes can then be used for creating more meshes that have different goals. This library will contain a series of converters that all have a different purpose. The creation and formatting of these converters stay consistent by using JavaScriptmatrixes as input and output.
The first converter in the demo takes a .obj voxel file that *is uploaded by the user* (still in development) and firstly converts this file to JavaScript matrixes containing the vertices, edges, faces and normals.The first converter then uses these to create and output an array of hex valued colors to be used in follow up converters. The 2nd converter then evaluates the array against a JSON rules file *either uploaded by the user or typed by the user in the text editor on the demo* (still in development). The evaluation will consider the color of the voxel cubes stored in the array and texture them accordingly, the converter will evaluate single colors as well as colors that appear next to each other.
voxc.js is used by downloading the minified javascript file and including it in your project.
voxc.min.js contains a class called VoxJSCanvas, and by constructing the class with the id of any div such as, new VoxJSCanvas("VoxelDemo"), the class will create a THREE.js canvas/scene with the required basics to display all our meshes.
var converterOne_canvas = new voxJSCanvas("voxelDemo");
var converterOne_model;
var arrayToMesh = new ArrayToMesh(converterOne_canvas.scene, model);
converterOne_model = arrayToMesh.output();
converterOne_canvas.CameraPosition(0, 0, -10);
converterOne_canvas.setMesh(converterOne_model);
converterOne_canvas.start();