mirror of
https://github.com/Doodle3D/Doodle3D-Core.git
synced 2024-12-22 02:53:50 +01:00
clean up
This commit is contained in:
parent
15f2237d27
commit
ec72a0097d
@ -62,7 +62,7 @@ class D3Panel extends React.Component {
|
||||
componentWillMount() {
|
||||
this.createScene();
|
||||
|
||||
const toonShader = hasExtensionsFor.toonShaderPreview
|
||||
const toonShader = hasExtensionsFor.toonShaderPreview;
|
||||
this.renderChain = new RenderChain(this.renderer, this.scene, this.camera, toonShader, {
|
||||
UI: this.UIContainer,
|
||||
shapes: this.shapesManager,
|
||||
|
@ -20,20 +20,20 @@ const CONTEXT = 'context';
|
||||
|
||||
const styles = {
|
||||
contextMenuContainer: {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
pointerEvents: 'none', /* enable clicking through object */
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
pointerEvents: 'none', /* enable clicking through object */
|
||||
'& *': {
|
||||
pointerEvents: 'visible' /* enable clicking in children */
|
||||
pointerEvents: 'visible' /* enable clicking in children */
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class SketcherToolbars extends React.Component {
|
||||
|
||||
@ -41,7 +41,8 @@ class SketcherToolbars extends React.Component {
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
toolbar2d: PropTypes.object, // TODO: specify further
|
||||
toolbar3d: PropTypes.object, // TODO: specify further
|
||||
context: PropTypes.object // TODO: specify further
|
||||
context: PropTypes.object, // TODO: specify further
|
||||
classes: PropTypes.objectOf(PropTypes.string)
|
||||
};
|
||||
onSelect2D = ({ value }) => {
|
||||
const { dispatch } = this.props;
|
||||
|
@ -2,7 +2,6 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Button from './Button.js';
|
||||
import Menu from './Menu.js';
|
||||
import bowser from 'bowser';
|
||||
import { connect } from 'react-redux';
|
||||
import { hexToStyle } from '../utils/colorUtils.js';
|
||||
// import createDebug from 'debug';
|
||||
@ -21,7 +20,9 @@ class SubMenu extends React.Component {
|
||||
svg: PropTypes.string,
|
||||
children: PropTypes.node,
|
||||
selectOnOpen: PropTypes.bool,
|
||||
toggleBehavior: PropTypes.bool
|
||||
toggleBehavior: PropTypes.bool,
|
||||
color: PropTypes.number,
|
||||
solid: PropTypes.bool
|
||||
};
|
||||
componentWillMount = () => {
|
||||
// Listeners to close the submenu when anywhere else is clicked
|
||||
|
@ -46,7 +46,7 @@ const toolbar3d = {
|
||||
children: [
|
||||
{ value: d3Tools.HEIGHT },
|
||||
{ value: d3Tools.SCULPT },
|
||||
{ value: d3Tools.TWIST },
|
||||
{ value: d3Tools.TWIST }
|
||||
// { value: d3Tools.STAMP }
|
||||
]
|
||||
};
|
||||
|
9
src/d3/MatcapMaterial.js
vendored
9
src/d3/MatcapMaterial.js
vendored
@ -12,9 +12,9 @@ export default class MatcapMaterial extends THREE.ShaderMaterial {
|
||||
constructor({ color = new THREE.Color(), opacity = 1 }) {
|
||||
super({
|
||||
uniforms: {
|
||||
"opacity": { type: 'f', value: opacity },
|
||||
"tMatcap": { type: 't', value: matcapTexture },
|
||||
"color": { type: 'vec3', value: new THREE.Vector3() }
|
||||
opacity: { type: 'f', value: opacity },
|
||||
tMatcap: { type: 't', value: matcapTexture },
|
||||
color: { type: 'vec3', value: new THREE.Vector3() }
|
||||
},
|
||||
vertexShader: matcapVert,
|
||||
fragmentShader: matcapFrag
|
||||
@ -35,7 +35,8 @@ export default class MatcapMaterial extends THREE.ShaderMaterial {
|
||||
|
||||
set opacity(opacity) {
|
||||
if (!this.uniforms) return opacity;
|
||||
return this.uniforms.opacity.value = opacity;
|
||||
this.uniforms.opacity.value = opacity;
|
||||
return opacity;
|
||||
}
|
||||
|
||||
clone() {
|
||||
|
12
src/d3/OutlinePass.js
vendored
12
src/d3/OutlinePass.js
vendored
@ -26,8 +26,8 @@ export default class OutlinePass {
|
||||
|
||||
this._edgeMaterial = new THREE.ShaderMaterial({
|
||||
uniforms: {
|
||||
"tDiffuse": { type: 't', value: this._depthNormalRenderTarget.texture },
|
||||
"resolution": { type: 'v2', value: new THREE.Vector2() }
|
||||
tDiffuse: { type: 't', value: this._depthNormalRenderTarget.texture },
|
||||
resolution: { type: 'v2', value: new THREE.Vector2() }
|
||||
},
|
||||
vertexShader: edgeVert,
|
||||
fragmentShader: edgeFrag
|
||||
@ -35,12 +35,12 @@ export default class OutlinePass {
|
||||
|
||||
this._copyEdge = new THREE.ShaderMaterial({
|
||||
uniforms: {
|
||||
"tDiffuse": { type: 't', value: null },
|
||||
"uTexArray" : { type: 'tv', value: [this._edgeRenderTarget.texture] }
|
||||
tDiffuse: { type: 't', value: null },
|
||||
uTexArray : { type: 'tv', value: [this._edgeRenderTarget.texture] }
|
||||
},
|
||||
vertexShader: combineVert,
|
||||
fragmentShader: combineFrag
|
||||
})
|
||||
});
|
||||
|
||||
this._camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
||||
this._scene = new THREE.Scene();
|
||||
@ -55,7 +55,7 @@ export default class OutlinePass {
|
||||
this._edgeMaterial.uniforms.resolution.value.set(width, height);
|
||||
}
|
||||
|
||||
render(renderer, writeBuffer, readBuffer, delta, maskActive) {
|
||||
render(renderer, writeBuffer, readBuffer) {
|
||||
if (this._callbackBeforeRender) this._callbackBeforeRender();
|
||||
|
||||
this._copyEdge.uniforms.tDiffuse.value = readBuffer.texture;
|
||||
|
@ -52,13 +52,13 @@ export function createThrottle() {
|
||||
|
||||
if (!startLoop) return null;
|
||||
|
||||
return function loop() {
|
||||
return (function loop() {
|
||||
const promise = next().then(() => {
|
||||
if (typeof next === 'function') return loop();
|
||||
});
|
||||
next = true;
|
||||
return promise;
|
||||
}().then(() => {
|
||||
})().then(() => {
|
||||
next = null;
|
||||
});
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ export function getDbUrl(db) {
|
||||
} else {
|
||||
return `${db.protocol}${db.host}`;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const dbs = {};
|
||||
export function getDb(dbUrl) {
|
||||
|
@ -79,7 +79,10 @@ export function generateExportMesh(state, options = {}) {
|
||||
};
|
||||
|
||||
for (const id in state.objectsById) {
|
||||
exportState.objectsById[id] = createExportShapeData(state.objectsById[id], offsetSingleWalls || unionGeometry, lineWidth);
|
||||
const shapeData = state.objectsById[id];
|
||||
if (!SHAPE_TYPE_PROPERTIES[shapeData.type].D3Visible) continue;
|
||||
const exportShapeData = createExportShapeData(shapeData, offsetSingleWalls || unionGeometry, lineWidth);
|
||||
exportState.objectsById[id] = exportShapeData;
|
||||
}
|
||||
|
||||
const shapesManager = new ShapesManager({ toonShader: false });
|
||||
@ -91,10 +94,11 @@ export function generateExportMesh(state, options = {}) {
|
||||
const shapeData = exportState.objectsById[mesh.name];
|
||||
if (mesh instanceof THREE.Mesh && shapeData.solid) {
|
||||
const { geometry, material } = mesh;
|
||||
const objectMatrix = state.spaces[shapeData.space].matrix;
|
||||
|
||||
let objectGeometry = geometry.clone();
|
||||
objectGeometry.mergeVertices();
|
||||
objectGeometry.applyMatrix(new THREE.Matrix4().multiplyMatrices(state.spaces[shapeData.space].matrix, matrix));
|
||||
objectGeometry.applyMatrix(new THREE.Matrix4().multiplyMatrices(objectMatrix, matrix));
|
||||
|
||||
const colorHex = material.color.getHex();
|
||||
let materialIndex = materials.findIndex(exportMaterial => exportMaterial.color.getHex() === colorHex);
|
||||
@ -149,7 +153,7 @@ export async function createFile(state, type, options) {
|
||||
}
|
||||
case 'stl-blob': {
|
||||
const buffer = exportSTL.fromMesh(exportMesh, true);
|
||||
return new Blob([buffer], { type: 'application/vnd.ms-pki.stl' })
|
||||
return new Blob([buffer], { type: 'application/vnd.ms-pki.stl' });
|
||||
}
|
||||
case 'obj-blob': {
|
||||
const buffer = await exportOBJ.fromMesh(exportMesh);
|
||||
|
@ -45,5 +45,5 @@ export function asyncValidateForm(dispatch, form, asyncValidate, formData) {
|
||||
dispatch(stopAsyncValidation(form));
|
||||
}).catch(error => {
|
||||
dispatch(stopAsyncValidation(form, error));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import * as THREE from 'three';
|
||||
import { shapeToPoints } from '../shape/shapeToPoints.js'
|
||||
import { getPointsBounds } from '../shape/shapeDataUtils.js'
|
||||
import { shapeToPoints } from '../shape/shapeToPoints.js';
|
||||
import { getPointsBounds } from '../shape/shapeDataUtils.js';
|
||||
import { Vector } from 'cal';
|
||||
import arrayMemoizer from './arrayMemoizer.js';
|
||||
import memoize from 'memoizee';
|
||||
// import createDebug from 'debug';
|
||||
// const debug = createDebug('d3d:util:selection');
|
||||
|
||||
// Memoized selector that returns the same array of shapeSata's when
|
||||
// Memoized selector that returns the same array of shapeData's when
|
||||
// - the selection array didn't change
|
||||
// - the objects in the resulting array didn't change
|
||||
// enables memoization of utils that use this array
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as THREE from 'three';
|
||||
import { loadImage } from './imageUtils.js'
|
||||
import { loadImage } from './imageUtils.js';
|
||||
import createDebug from 'debug';
|
||||
const debug = createDebug('d3d:threeUtils');
|
||||
|
||||
|
@ -74,9 +74,7 @@ function floodFill(imageData, start, tolerance) {
|
||||
for (let i = 0; i < neighbours.length; i ++) {
|
||||
const neighbourIndex = neighbours[i];
|
||||
|
||||
if (!done[neighbourIndex]) {
|
||||
stack.push(neighbourIndex);
|
||||
}
|
||||
if (!done[neighbourIndex]) stack.push(neighbourIndex);
|
||||
done[neighbourIndex] = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user