diff --git a/README.md b/README.md index 1ef9fd3..9b5943c 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ const renderer = new GCodeRenderer(gcodeString, 800, 600, new Color(0x808080)) // * SimpleColorizer (default) - sets all lines to the same color // * SpeedColorizer - colorizes based on the speed / feed rate // * TempColorizer - colorizes based on the temperature +// * LineColorizer - colorizes based on the gcodeLine renderer.colorizer = new SpeedColorizer(this.renderer.getMinMaxValues().minSpeed || 0, this.renderer.getMinMaxValues().maxSpeed) document.getElementById("gcode-viewer").append(renderer.element()) @@ -71,3 +72,28 @@ You can change the line width of travel lines: renderer. travelWidth = 0.1 ``` The default is `0.01`. `0` is also possible to completely hide them. + +### Access three.js +Both, the scene and the whole three.js is exported, so you can use it. +For example you can customize the scene setup: + +```js +renderer.setupScene = () => { + // Set up some lights. (use different lights in this example) + const ambientLight = new gcodeViewer.THREE.AmbientLight(0xff0000, 0.5); + renderer.scene.add(ambientLight); + + const spotLight = new gcodeViewer.THREE.SpotLight(0x00ff00, 0.9); + spotLight.position.set(200, 400, 300); + spotLight.lookAt(new gcodeViewer.THREE.Vector3(0, 0, 0)) + + const spotLight2 = new gcodeViewer.THREE.SpotLight(0x0000ff, 0.9); + spotLight2.position.set(-200, -400, -300); + spotLight2.lookAt(new gcodeViewer.THREE.Vector3(0, 0, 0)) + renderer.scene.add(spotLight); + renderer.scene.add(spotLight2); + + renderer.fitCamera() +} +renderer.render().then(() => console.log("rendering finished")) +``` \ No newline at end of file diff --git a/example/index.html b/example/index.html index 65bb47e..adcc0de 100644 --- a/example/index.html +++ b/example/index.html @@ -6,12 +6,54 @@ - +
+ +