Doodle3D-Slicer/simpleExample/index.js

33 lines
969 B
JavaScript
Raw Normal View History

2017-11-11 20:23:45 +01:00
import React from 'react';
2017-07-20 12:12:25 +02:00
import * as THREE from 'three';
2017-11-11 20:23:45 +01:00
import { Interface } from 'doodle3d-slicer';
2017-11-12 00:11:05 +01:00
import fileURL from '!url-loader!./models/shape.json';
2017-11-11 20:23:45 +01:00
import { render } from 'react-dom';
2017-11-12 01:15:38 +01:00
import fileSaver from 'file-saver';
2017-11-12 16:58:59 +01:00
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();
2017-11-12 01:15:38 +01:00
2017-11-12 13:08:51 +01:00
document.body.style.margin = 0;
document.body.style.padding = 0;
2017-11-12 01:15:38 +01:00
const downloadGCode = gcode => {
const file = new File([gcode], 'gcode.gcode', { type: 'text/plain' });
fileSaver.saveAs(file);
};
2017-07-07 18:10:29 +02:00
2017-08-17 16:13:30 +02:00
const jsonLoader = new THREE.JSONLoader();
jsonLoader.load(fileURL, geometry => {
2017-11-12 01:41:09 +01:00
render((
2017-11-12 16:58:59 +01:00
<MuiThemeProvider>
2017-11-12 01:41:09 +01:00
<Interface
geometry={geometry}
2017-11-12 13:08:51 +01:00
width={window.innerWidth}
height={window.innerHeight}
2017-11-12 01:41:09 +01:00
onCompleteActions={[{ title: 'Download', callback: downloadGCode }]}
/>
2017-11-12 16:58:59 +01:00
</MuiThemeProvider>
2017-11-12 01:41:09 +01:00
), document.getElementById('app'));
2017-07-28 10:48:46 +02:00
});