mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-26 07:24:57 +01:00
use printer from state
This commit is contained in:
parent
ccc676ebd1
commit
40d505d754
@ -53,6 +53,14 @@ class Interface extends React.Component {
|
|||||||
sliced: false
|
sliced: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
printer: props.defaultPrinter
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { canvas } = this.refs;
|
const { canvas } = this.refs;
|
||||||
const scene = createScene(canvas, this.props, this.state);
|
const scene = createScene(canvas, this.props, this.state);
|
||||||
@ -84,11 +92,11 @@ class Interface extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
slice = async () => {
|
slice = async () => {
|
||||||
const { mesh, render, scene, control } = this.state;
|
const { mesh, render, scene, control, printer } = this.state;
|
||||||
const settings = {
|
const settings = {
|
||||||
...baseSettings,
|
...baseSettings,
|
||||||
...materialSettings.pla,
|
...materialSettings.pla,
|
||||||
...printerSettings[this.props.defaultPrinter]
|
...printerSettings[printer]
|
||||||
};
|
};
|
||||||
|
|
||||||
const { dimensions } = settings;
|
const { dimensions } = settings;
|
||||||
|
@ -26,7 +26,8 @@ export function createScene(canvas, props, state) {
|
|||||||
const centerZ = (geometry.boundingBox.max.z + geometry.boundingBox.min.z) / 2;
|
const centerZ = (geometry.boundingBox.max.z + geometry.boundingBox.min.z) / 2;
|
||||||
geometry.applyMatrix(new THREE.Matrix4().makeTranslation(-centerX, -centerY, -centerZ));
|
geometry.applyMatrix(new THREE.Matrix4().makeTranslation(-centerX, -centerY, -centerZ));
|
||||||
|
|
||||||
const { width, height, printers, defaultPrinter } = props;
|
const { width, height, printers } = props;
|
||||||
|
const { controlMode, printer } = state;
|
||||||
|
|
||||||
const renderer = new THREE.WebGLRenderer({ canvas, alpha: true });
|
const renderer = new THREE.WebGLRenderer({ canvas, alpha: true });
|
||||||
renderer.setClearColor(0xffffff, 0);
|
renderer.setClearColor(0xffffff, 0);
|
||||||
@ -52,7 +53,7 @@ export function createScene(canvas, props, state) {
|
|||||||
const editorControls = new THREE.EditorControls(camera, canvas);
|
const editorControls = new THREE.EditorControls(camera, canvas);
|
||||||
|
|
||||||
const control = new THREE.TransformControls(camera, canvas);
|
const control = new THREE.TransformControls(camera, canvas);
|
||||||
control.setMode(state.controlMode);
|
control.setMode(controlMode);
|
||||||
control.setRotationSnap(THREE.Math.degToRad(45));
|
control.setRotationSnap(THREE.Math.degToRad(45));
|
||||||
control.addEventListener('mouseDown', () => editorControls.enabled = false);
|
control.addEventListener('mouseDown', () => editorControls.enabled = false);
|
||||||
control.addEventListener('mouseUp', () => {
|
control.addEventListener('mouseUp', () => {
|
||||||
@ -76,7 +77,7 @@ export function createScene(canvas, props, state) {
|
|||||||
box.material.color.setHex(0x72bcd4);
|
box.material.color.setHex(0x72bcd4);
|
||||||
scene.add(box);
|
scene.add(box);
|
||||||
|
|
||||||
const { dimensions } = printers[defaultPrinter];
|
const { dimensions } = printers[printer];
|
||||||
box.scale.set(dimensions.y, dimensions.z, dimensions.x);
|
box.scale.set(dimensions.y, dimensions.z, dimensions.x);
|
||||||
|
|
||||||
render();
|
render();
|
||||||
|
Loading…
Reference in New Issue
Block a user