mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 13:37:58 +01:00
pack scene state in scene object
This commit is contained in:
parent
ecc37273ca
commit
212075e306
@ -139,15 +139,15 @@ class Interface extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
const { editorControls, mesh: { material }, renderer } = this.state;
|
const { scene: { editorControls, mesh: { material } }, renderer } = this.state;
|
||||||
editorControls.dispose();
|
editorControls.dispose();
|
||||||
material.dispose();
|
material.dispose();
|
||||||
renderer.dispose();
|
renderer.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
resetMesh = () => {
|
resetMesh = () => {
|
||||||
const { mesh, render, isSlicing } = this.state;
|
|
||||||
if (isSlicing) return;
|
if (isSlicing) return;
|
||||||
|
const { scene: { mesh, render }, isSlicing, isLoading } = this.state;
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
mesh.position.set(0, 0, 0);
|
mesh.position.set(0, 0, 0);
|
||||||
mesh.scale.set(1, 1, 1);
|
mesh.scale.set(1, 1, 1);
|
||||||
@ -161,8 +161,8 @@ class Interface extends React.Component {
|
|||||||
scaleUp = () => this.scaleMesh(0.9);
|
scaleUp = () => this.scaleMesh(0.9);
|
||||||
scaleDown = () => this.scaleMesh(1.0 / 0.9);
|
scaleDown = () => this.scaleMesh(1.0 / 0.9);
|
||||||
scaleMesh = (factor) => {
|
scaleMesh = (factor) => {
|
||||||
const { mesh, render, isSlicing } = this.state;
|
|
||||||
if (isSlicing) return;
|
if (isSlicing) return;
|
||||||
|
const { scene: { mesh, render }, isSlicing, isLoading } = this.state;
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
mesh.scale.multiplyScalar(factor);
|
mesh.scale.multiplyScalar(factor);
|
||||||
mesh.updateMatrix();
|
mesh.updateMatrix();
|
||||||
@ -175,8 +175,8 @@ class Interface extends React.Component {
|
|||||||
rotateY = () => this.rotate(new Vector3(1, 0, 0), Math.PI / 2.0);
|
rotateY = () => this.rotate(new Vector3(1, 0, 0), Math.PI / 2.0);
|
||||||
rotateZ = () => this.rotate(new Vector3(0, 1, 0), Math.PI / 2.0);
|
rotateZ = () => this.rotate(new Vector3(0, 1, 0), Math.PI / 2.0);
|
||||||
rotate = (axis, angle) => {
|
rotate = (axis, angle) => {
|
||||||
const { mesh, render, isSlicing } = this.state;
|
|
||||||
if (isSlicing) return;
|
if (isSlicing) return;
|
||||||
|
const { scene: { mesh, render }, isSlicing, isLoading } = this.state;
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
mesh.rotateOnWorldAxis(axis, angle);
|
mesh.rotateOnWorldAxis(axis, angle);
|
||||||
placeOnGround(mesh);
|
placeOnGround(mesh);
|
||||||
@ -185,7 +185,7 @@ class Interface extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
slice = async (target) => {
|
slice = async (target) => {
|
||||||
const { isSlicing, settings, printers, quality, material, mesh: { matrix } } = this.state;
|
const { isSlicing, isLoading, settings, printers, quality, scene: { material, mesh: { matrix } } } = this.state;
|
||||||
const { name, mesh } = this.props;
|
const { name, mesh } = this.props;
|
||||||
|
|
||||||
if (isSlicing) return;
|
if (isSlicing) return;
|
||||||
@ -233,7 +233,8 @@ class Interface extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentWillUpdate(nextProps, nextState) {
|
componentWillUpdate(nextProps, nextState) {
|
||||||
const { box, render, setSize } = this.state;
|
if (!this.state.scene) return;
|
||||||
|
const { scene: { box, render, setSize } } = this.state;
|
||||||
let changed = false;
|
let changed = false;
|
||||||
if (box && nextState.settings.dimensions !== this.state.settings.dimensions) {
|
if (box && nextState.settings.dimensions !== this.state.settings.dimensions) {
|
||||||
const { dimensions } = nextState.settings;
|
const { dimensions } = nextState.settings;
|
||||||
@ -245,14 +246,14 @@ class Interface extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
const { updateCanvas } = this.state;
|
const { scene: { updateCanvas } } = this.state;
|
||||||
const { canvas } = this.refs;
|
const { canvas } = this.refs;
|
||||||
if (updateCanvas && canvas) updateCanvas(canvas);
|
if (updateCanvas && canvas) updateCanvas(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
onResize3dView = (width, height) => {
|
onResize3dView = (width, height) => {
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
const { setSize } = this.state;
|
const { scene: { setSize } } = this.state;
|
||||||
const { pixelRatio } = this.props;
|
const { pixelRatio } = this.props;
|
||||||
if (setSize) setSize(width, height, pixelRatio);
|
if (setSize) setSize(width, height, pixelRatio);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user