for developers
Sign In
Join
Discussions
Documentation
Tutorials
Examples
Editor
Scene
Import Scene
Export Scene
Load Last Scene
Save Current Scene
Model
Save Model
Upload Model
Show Printability
Render
Preferences
Help
Reference Guide
Examples
Tutorials
Generate
Save Model
Reset Params
Check Model
var params = [ { name: "size", label: "Size", desc: "Size(mm)", type: "double", rangeMin: 5, rangeMax: 25, step: 0.1, defaultVal: 15, unit: "MM" } ]; var voxelSize = 0.07 * MM; function makeText(str, width, height, depth, translation, rotations) { var text2d = new Text2D(str); text2d.setWidth(width); text2d.setHeight(height); text2d.setFontName("HelveticaRounded LT Std Bd"); text2d.setFontStyle(Text2D.BOLD); text2d.setHorizAlign(Text2D.HorizAlign.CENTER); text2d.setVoxelSize(voxelSize / 2); var text = new Image3D(text2d.getImage(), width, height, depth, voxelSize); text.setBaseThreshold(0.25); text.setBlurWidth(voxelSize / 2); text.setUseGrayscale(false); var trans = new CompositeTransform(); for (var i = 0; i < rotations.length; i++) { trans.add(rotations[i]); } trans.add(translation); text.setTransform(trans); return text; } // Make numbers and rotate/translate them to where each face would be function createNumbers(size, width, height, depth) { var union = new Union(); var rotations = new Array(); // Example for number 1: // Translate 1 to the front face, no rotation value rotations[0] = new Rotation(new Vector3d(1, 0, 0), 0); var translation = new Translation(0, 0, (size / 2 - depth / 2)); var text = makeText("1", width, height, 2 * depth, translation, rotations); union.add(text); // Example for number 2: // Rotate around the X axis by 90 degrees // Then translate it to the bottom face rotations[0] = new Rotation(new Vector3d(1, 0, 0), Math.PI / 2); translation = new Translation(0, -(size / 2 - depth / 2), 0); text = makeText("2", width, height, 2 * depth, translation, rotations); union.add(text); rotations[0] = new Rotation(new Vector3d(-1, 0, 0), Math.PI / 2); translation = new Translation(0, (size / 2 - depth / 2), 0); text = makeText("5", width, height, 2 * depth, translation, rotations); union.add(text); // Example for number 3: // Rotate around the Y axis by -90 degrees // Then rotate around the Z axis by 90 degrees // Then translate it to the left face rotations[0] = new Rotation(new Vector3d(0, -1, 0), Math.PI / 2); rotations[1] = new Rotation(new Vector3d(1, 0, 0), Math.PI / 2); translation = new Translation(-(size / 2 - depth / 2), 0, 0); text = makeText("3", width, height, 2 * depth, translation, rotations); union.add(text); rotations[0] = new Rotation(new Vector3d(0, 1, 0), Math.PI); rotations[1] = new Rotation(new Vector3d(0, 0, 1), Math.PI); translation = new Translation(0, 0, -(size / 2 - depth / 2)); text = makeText("4", width, height, 2 * depth, translation, rotations); union.add(text); rotations[0] = new Rotation(new Vector3d(1, 0, 0), Math.PI / 2); rotations[1] = new Rotation(new Vector3d(0, 0, 1), Math.PI / 2); translation = new Translation((size / 2 - depth / 2), 0, 0); text = makeText("6", width, height, 2 * depth, translation, rotations); union.add(text); return union; } function main(args) { // the cube for the dice var size = args.size; var box = new Box(0, 0, 0, size, size, size); // round the corners and edges by intersecting cube with sphere // sphere with radius 32% of cube length is sufficient var radius = size - 0.32 * size; var sphere = new Sphere(radius); var base = new Intersection(); base.add(box); base.add(sphere); // add numbers to each face by subtracting number text from the cube var tw = size / 2; var th = size / 2; var td = 0.026 * size; var numbers = createNumbers(size, tw, th, td); var result = new Subtraction(base, numbers); var halfgrid = (size / 2) + 2 * MM; var bounds = new Bounds(-halfgrid, halfgrid, -halfgrid, halfgrid, -halfgrid, halfgrid); var scene = new Scene(result, bounds); return scene; }
Preferences
Close
Printability Check
Region check
Voxel size
Number of regions
Largest region
Close