mirror of
https://github.com/Doodle3D/Doodle3D-Core.git
synced 2024-12-22 11:03:48 +01:00
add download stl function
This commit is contained in:
parent
12b3e70544
commit
f243d98431
13
index.js
13
index.js
@ -19,9 +19,20 @@ const store = createStore(reducer, enhancer);
|
|||||||
import actionWrapper from 'redux-action-wrapper';
|
import actionWrapper from 'redux-action-wrapper';
|
||||||
import * as actions from './src/actions/index.js';
|
import * as actions from './src/actions/index.js';
|
||||||
window.actions = actionWrapper(actions, store.dispatch);
|
window.actions = actionWrapper(actions, store.dispatch);
|
||||||
|
import { saveAs as saveAsLib } from 'file-saver';
|
||||||
|
|
||||||
|
// download file
|
||||||
|
import { createFile } from './src/utils/exportUtils.js';
|
||||||
|
window.downloadStl = () => {
|
||||||
|
store.dispatch(async (dispatch, getState) => {
|
||||||
|
const state = getState();
|
||||||
|
const blob = await createFile(state.sketcher.present, 'stl-blob');
|
||||||
|
saveAsLib(blob, 'doodle.stl');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// add model to store
|
// add model to store
|
||||||
import modelData from './models/noodlebot.d3sketch';
|
import modelData from './models/simple_hole.d3sketch';
|
||||||
import JSONToSketchData from './src/shape/JSONToSketchData.js';
|
import JSONToSketchData from './src/shape/JSONToSketchData.js';
|
||||||
JSONToSketchData(JSON.parse(modelData)).then(data => {
|
JSONToSketchData(JSON.parse(modelData)).then(data => {
|
||||||
store.dispatch(actions.openSketch({ data }));
|
store.dispatch(actions.openSketch({ data }));
|
||||||
|
1
models/simple_hole.d3sketch
Normal file
1
models/simple_hole.d3sketch
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"data":"{\"spaces\":[{\"matrix\":{\"metadata\":{\"type\":\"Matrix4\",\"library\":\"three.js\"},\"elements\":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]},\"objects\":[{\"height\":21.005096748926302,\"transform\":{\"metadata\":{\"library\":\"CAL\",\"type\":\"Matrix\"},\"matrix\":[1,0,8.214849921011051,0,1,-3.7914691943127927]},\"z\":7.243224684956081,\"sculpt\":[{\"pos\":0,\"scale\":1},{\"pos\":1,\"scale\":1}],\"twist\":0,\"fill\":true,\"solid\":false,\"star\":{\"rays\":5,\"innerRadius\":18.00947867298578,\"outerRadius\":38.54660347551342},\"color\":6873597,\"type\":\"STAR\"},{\"height\":20,\"transform\":{\"metadata\":{\"library\":\"CAL\",\"type\":\"Matrix\"},\"matrix\":[1,0,-14.533965244865726,0,1,7.266982622432863]},\"z\":0,\"sculpt\":[{\"pos\":0,\"scale\":1},{\"pos\":1,\"scale\":1}],\"twist\":0,\"fill\":true,\"solid\":true,\"star\":{\"rays\":5,\"innerRadius\":18.00947867298578,\"outerRadius\":38.54660347551342},\"color\":6873597,\"type\":\"STAR\"}]}]}","appVersion":"0.17.4"}
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -4306,6 +4306,11 @@
|
|||||||
"object-assign": "4.1.1"
|
"object-assign": "4.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"file-saver": {
|
||||||
|
"version": "1.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/file-saver/-/file-saver-1.3.3.tgz",
|
||||||
|
"integrity": "sha1-zdTETTqiZOrC9o7BZbx5HDSvEjI="
|
||||||
|
},
|
||||||
"filename-regex": {
|
"filename-regex": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
"eslint": "^1.10.3",
|
"eslint": "^1.10.3",
|
||||||
"eslint-config-airbnb": "^3.1.0",
|
"eslint-config-airbnb": "^3.1.0",
|
||||||
"eslint-plugin-react": "^3.16.1",
|
"eslint-plugin-react": "^3.16.1",
|
||||||
|
"file-saver": "^1.3.3",
|
||||||
"html-webpack-plugin": "^2.30.1",
|
"html-webpack-plugin": "^2.30.1",
|
||||||
"html-webpack-template": "^6.0.2",
|
"html-webpack-template": "^6.0.2",
|
||||||
"jss-preset-default": "^4.0.1",
|
"jss-preset-default": "^4.0.1",
|
||||||
|
Loading…
Reference in New Issue
Block a user