# GCode Editor

GCode viewer and CNC toolpath simulator powered by the webgcode library.

## Live Demo

<iframe id="gc-demo" src="/online/webapp/gcode-editor" width="100%" height="500" frameborder="0" style="border:1px solid #ccc; border-radius:4px;"></iframe>

<script>window._wsConnect('gc-demo', 'gcSocket');</script>

## Embed

```html
<iframe src="https://sgapps.io/online/webapp/gcode-editor"
    width="100%" height="600" frameborder="0"></iframe>
```

### Open with a GCode File

```js
var gcodeUrl = "https://example.com/design.gcode";
var src = "https://sgapps.io/online/webapp/gcode-editor/url/" + btoa(gcodeUrl);
```

## Events Reference

### `reset` -- Reset Simulation

Clears the current GCode and relaunches the simulation.

```js
socket.fire("webapp::instance::request", "reset", function () {
    console.log("Simulation reset");
});
```

<button onclick="window._ws('gcSocket')&&window.gcSocket.fire('webapp::instance::request','reset')">Try: Reset</button>

## Features

- 3D GCode toolpath visualization
- Real-time CNC simulation
- Load GCode files from URL (base64-encoded in URL path)
- Reset and relaunch simulation via API
