add stl loader

This commit is contained in:
casperlamboo 2016-10-16 11:10:39 +02:00 committed by Simon Voordouw
parent 18456a402a
commit 52e9ba31e0
7 changed files with 333112 additions and 12 deletions

View File

@ -1,4 +1,5 @@
import THREE from 'three.js';
import 'three.js';
import 'three.js/loaders/STLLoader';
import React from 'react';
import ReactDOM, { render } from 'react-dom';
import * as SLICER from 'src/index.js';
@ -10,15 +11,35 @@ const settings = new SLICER.Settings({
...SLICER.userSettings
});
const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
geometry.applyMatrix(new THREE.Matrix4().setPosition(new THREE.Vector3(60, 0, 60)));
geometry.mergeVertices();
geometry.computeFaceNormals();
const stlLoader = new THREE.STLLoader();
const rawData = generateRawData(geometry, settings);
stlLoader.load('stl/Airplane.stl', (geometry) => {
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();
render(<SlicerViewer
layerIntersectionPoints={rawData.layerIntersectionPoints}
layerShapes={rawData.layerShapes}
settings={settings.config}
/>, document.getElementById('container'));
const rawData = generateRawData(geometry, settings);
render(<SlicerViewer
layerIntersectionPoints={rawData.layerIntersectionPoints}
layerShapes={rawData.layerShapes}
slices={rawData.slices}
settings={settings.config}
/>, document.getElementById('container'));
});
// const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
// geometry.applyMatrix(new THREE.Matrix4().setPosition(new THREE.Vector3(60, 0, 60)));
// geometry.mergeVertices();
// geometry.computeFaceNormals();
//
// const rawData = generateRawData(geometry, settings);
//
// render(<SlicerViewer
// layerIntersectionPoints={rawData.layerIntersectionPoints}
// layerShapes={rawData.layerShapes}
// slices={rawData.slices}
// settings={settings.config}
// />, document.getElementById('container'));

55582
example/stl/Airplane.stl Normal file

File diff suppressed because it is too large Load Diff

94222
example/stl/Rocket.stl Normal file

File diff suppressed because it is too large Load Diff

146358
example/stl/castle.stl Normal file

File diff suppressed because it is too large Load Diff

36906
example/stl/traktor.stl Normal file

File diff suppressed because it is too large Load Diff

View File

@ -137,8 +137,16 @@ SystemJS.config({
}
}
},
meta: {
"three.js/loaders/STLLoader": {
"deps": [
"three.js"
]
}
},
map: {
"babel": "npm:babel-core@5.8.38"
"babel": "npm:babel-core@5.8.38",
"three.js/loaders/STLLoader": "github:mrdoob/three.js@r75/examples/js/loaders/STLLoader.js",
}
});

View File

@ -43,6 +43,9 @@
"vm": "github:jspm/nodelibs-vm@^0.2.0-alpha"
},
"overrides": {
"github:mrdoob/three.js@r75": {
"format": "global"
},
"npm:babel-runtime@5.8.38": {
"main": false,
"dependencies": {},