Doodle3D-Slicer/example/viewer.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-10-16 11:10:39 +02:00
import 'three.js';
import 'three.js/loaders/STLLoader';
2016-10-13 16:33:40 +02:00
import React from 'react';
import ReactDOM, { render } from 'react-dom';
import * as SLICER from 'src/index.js';
import generateRawData from './generateRawData.js';
import SlicerViewer from './SlicerViewer.js';
2015-07-26 15:32:10 +02:00
2016-07-19 14:23:23 +02:00
const settings = new SLICER.Settings({
2017-05-13 14:48:48 +02:00
...SLICER.printerSettings['ultimaker2go'],
...SLICER.userSettings
2016-07-19 14:23:23 +02:00
});
2015-07-26 15:32:10 +02:00
2016-10-16 11:10:39 +02:00
const stlLoader = new THREE.STLLoader();
stlLoader.load('stl/Airplane.stl', (geometry) => {
2017-05-13 15:39:45 +02:00
geometry = new THREE.Geometry().fromBufferGeometry(geometry);
2017-05-13 14:48:48 +02:00
geometry.applyMatrix(new THREE.Matrix4().makeRotationX(Math.PI / -2));
geometry.applyMatrix(new THREE.Matrix4().setPosition(new THREE.Vector3(50, -0.1, 50)));
// geometry.applyMatrix(new THREE.Matrix4().scale(0.8));
geometry.mergeVertices();
geometry.computeFaceNormals();
2015-07-26 15:32:10 +02:00
2017-05-13 14:48:48 +02:00
const rawData = generateRawData(geometry, settings);
2016-10-16 11:10:39 +02:00
2017-05-13 15:39:45 +02:00
render(
<SlicerViewer
layerIntersectionPoints={rawData.layerIntersectionPoints}
layerShapes={rawData.layerShapes}
slices={rawData.slices}
2017-07-18 11:39:38 +02:00
settings={settings}
2017-05-13 15:39:45 +02:00
/>,
document.getElementById('container')
);
2016-10-16 11:10:39 +02:00
});