mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-25 23:17:57 +01:00
164 lines
5.5 KiB
HTML
164 lines
5.5 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Doedel Drie Dee || Slice Test</title>
|
|
<!--<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>-->
|
|
<script src="library/jquery.js"></script>
|
|
<script src="library/three.js"></script>
|
|
<script src="library/stl_loader.js"></script>
|
|
<script src="library/clipper.js"></script>
|
|
|
|
<script src="src/utils.js"></script>
|
|
<script src="src/box.js"></script>
|
|
<script src="src/printer.js"></script>
|
|
<script src="src/slicer.js"></script>
|
|
|
|
<script src="gcode/testgcode.js"></script>
|
|
<script src="gcode/easterbunny.js"></script>
|
|
|
|
<style>
|
|
canvas {border: 1px solid black;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<canvas id="3d-preview" height="400" width="400"></canvas>
|
|
<canvas id="canvas" width="400" height="400"></canvas>
|
|
|
|
<script>
|
|
//nieuwe config
|
|
//geimplimenteerd worden in de doodlebox?
|
|
var printerConfig = {
|
|
"printer.baudrate": "115200", //wat is dit?
|
|
"printer.bed.temperature": 70,
|
|
"printer.bottomFlowRate": 1.0,
|
|
"printer.bottomLayerSpeed": 35,
|
|
"printer.dimensions.x": 200,
|
|
"printer.dimensions.y": 200,
|
|
"printer.dimensions.z": 200,
|
|
"printer.enableTraveling": true, //wat is dit?
|
|
"printer.endcode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)",
|
|
"printer.filamentThickness": 2.89,
|
|
"printer.firstLayerSlow": true,
|
|
"printer.heatedbed": false,
|
|
"printer.heatup.bed.temperature": 70,
|
|
"printer.heatup.enabled": true,
|
|
"printer.heatup.temperature": 180,
|
|
"printer.layerHeight": 0.3,
|
|
"printer.retraction.amount": 3,
|
|
"printer.retraction.enabled": true,
|
|
"printer.retraction.minDistance": 5,
|
|
"printer.retraction.speed": 50,
|
|
"printer.screenToMillimeterScale": 0.3, //????
|
|
"printer.speed": 70,
|
|
"printer.startcode": ";Generated with Doodle3D (default)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 E0 ;zero the extruded length again\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)",
|
|
"printer.temperature": 230,
|
|
"printer.travelSpeed": 200,
|
|
"printer.type": "ultimaker",
|
|
"printer.useSubLayers": true, //wat is dit?
|
|
"printer.wallThickness": 0.4,
|
|
|
|
//variabele toevoegen;
|
|
//-snelheid, retraction etc voor verschillende types (outerlayer, innerlayer, fill)
|
|
"printer.shellThickness": 0.8,
|
|
"printer.fillSize": 5, //dit is het raster aan de binnen kant van de geometry
|
|
"printer.brimOffset": 5
|
|
};
|
|
var printer = new D3D.Printer(printerConfig);
|
|
|
|
var localIp = location.hash.substring(1);
|
|
var doodleBox = new D3D.Box(localIp);
|
|
//var printer = doodleBox.printer;
|
|
|
|
var scene = new THREE.Scene();
|
|
|
|
var renderer = new THREE.WebGLRenderer({canvas: document.getElementById("3d-preview")});
|
|
renderer.setClearColor(0xffffff, 1);
|
|
|
|
var camera = new THREE.PerspectiveCamera(75, renderer.domElement.width/renderer.domElement.height, 1, 10000);
|
|
|
|
applyMouseControls(renderer, camera, new THREE.Vector3(100, 0, 100), 1000);
|
|
|
|
var geometry = (function () {
|
|
"use strict";
|
|
|
|
var circle = new THREE.Shape();
|
|
circle.absarc(0, 0, 100, 0, Math.PI*2, false);
|
|
|
|
var hole = new THREE.Path();
|
|
hole.absarc(0, 0, 15, 0, Math.PI*2, true );
|
|
|
|
circle.holes.push(hole);
|
|
|
|
var matrix = new THREE.Matrix4();
|
|
matrix.makeRotationX(Math.PI*1.5);
|
|
|
|
var geometry = new THREE.ExtrudeGeometry(circle, {
|
|
amount: 3,
|
|
bevelEnabled: false,
|
|
steps: 1
|
|
});
|
|
geometry.applyMatrix(matrix);
|
|
|
|
return geometry;
|
|
})();
|
|
|
|
var material = new THREE.MeshBasicMaterial({color: 0x000000, wireframe: true});
|
|
//var geometry = new THREE.TorusGeometry(20, 10, 30, 30);
|
|
var geometry = new THREE.BoxGeometry(20, 20, 20, 1, 1, 1);
|
|
//var geometry = new THREE.SphereGeometry(10, 10, 10);
|
|
var mesh = new THREE.Mesh(geometry, material);
|
|
mesh.position.x = 100;
|
|
mesh.position.z = 100;
|
|
scene.add(mesh);
|
|
|
|
var canvas = document.getElementById("canvas");
|
|
var context = canvas.getContext("2d");
|
|
|
|
var slicer = new D3D.Slicer().setMesh(mesh);
|
|
|
|
gcode = slicer.getGcode(printer);
|
|
|
|
var canvas = document.getElementById("canvas");
|
|
var context = canvas.getContext("2d");
|
|
|
|
var layer = 0;
|
|
var img = slicer.drawPaths(printer, layer, layer + 1);
|
|
context.drawImage(img, 0, 0);
|
|
|
|
/*
|
|
var loader = new THREE.STLLoader();
|
|
loader.load('stl/overhang_test.stl', function (geometry) {
|
|
|
|
var matrix = new THREE.Matrix4();
|
|
matrix.makeRotationX(Math.PI*1.5);
|
|
|
|
geometry.applyMatrix(matrix);
|
|
|
|
var material = new THREE.MeshLambertMaterial({color: 0x000000, wireframe: true});
|
|
var mesh = new THREE.Mesh(geometry, material);
|
|
scene.add(mesh);
|
|
|
|
var canvas = document.getElementById("canvas");
|
|
var context = canvas.getContext("2d");
|
|
|
|
var slicer = new D3D.Slicer().setMesh(geometry);
|
|
|
|
var layer = 149;
|
|
var img = slicer.drawPaths(printer, layer, layer + 1);
|
|
context.drawImage(img, 0, 0);
|
|
|
|
var gcode = slicer.getGcode(printer);
|
|
console.log(gcode);
|
|
});
|
|
*/
|
|
|
|
(function animate () {
|
|
"use strict";
|
|
|
|
requestAnimationFrame(animate);
|
|
renderer.render(scene, camera);
|
|
})();
|
|
</script>
|
|
|
|
</body>
|
|
</html> |