This commit is contained in:
casperlamboo 2018-01-10 15:24:25 +01:00
parent b674769ef8
commit 1b66fc21e0
14 changed files with 34 additions and 47 deletions

View File

@ -45,7 +45,7 @@ class DoodlePreview extends React.Component {
scene: null scene: null
}; };
async componentDidMount() { async componentWillMount() {
let { docData, sketchData } = this.props; let { docData, sketchData } = this.props;
if (docData) sketchData = await JSONToSketchData(this.props.docData); if (docData) sketchData = await JSONToSketchData(this.props.docData);

View File

@ -1,7 +1,5 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import initialMenuStructure from '../constants/menu.js';
import { connect } from 'react-redux';
// import createDebug from 'debug'; // import createDebug from 'debug';
// const debug = createDebug('d3d:menu'); // const debug = createDebug('d3d:menu');
@ -14,7 +12,7 @@ class Menu extends React.Component {
value: PropTypes.string, value: PropTypes.string,
className: PropTypes.string, className: PropTypes.string,
children: PropTypes.node, children: PropTypes.node,
stateMenu: PropTypes.object id: PropTypes.string
}; };
onSelect = (event) => { onSelect = (event) => {
const { onSelect, value } = this.props; const { onSelect, value } = this.props;
@ -23,7 +21,7 @@ class Menu extends React.Component {
if (onSelect) onSelect({ ...event, menuValue }); if (onSelect) onSelect({ ...event, menuValue });
}; };
render() { render() {
const { className = '', id, selectedValue, onOpen, onClose, value, children, stateMenu } = this.props; const { className = '', id, selectedValue, onOpen, onClose, children } = this.props;
return ( return (
<ul id={id} className={`menu ${className}`}> <ul id={id} className={`menu ${className}`}>
{React.Children.map(children, (child) => { {React.Children.map(children, (child) => {
@ -39,6 +37,4 @@ class Menu extends React.Component {
} }
} }
export default connect(state => ({ export default Menu;
stateMenu: state.sketcher.present.menus
}))(Menu);

View File

@ -234,13 +234,19 @@ const getMenus = createSelector([
state => state.sketcher.present.menus, state => state.sketcher.present.menus,
state => state.sketcher.present.d2.tool, state => state.sketcher.present.d2.tool,
state => state.sketcher.present.selection.objects.length, state => state.sketcher.present.selection.objects.length,
state => state.sketcher.present.selection.objects.filter(({ id }) => state.sketcher.present.objectsById[id].fill).length, state => state.sketcher.present.selection.objects.filter(({ id }) => {
state => state.sketcher.present.selection.objects.filter(({ id }) => state.sketcher.present.objectsById[id].solid).length, return state.sketcher.present.objectsById[id].fill;
state => state.sketcher.present.selection.objects.some(({ id }) => state.sketcher.present.objectsById[id].type === 'TEXT') }).length,
], (menus, activeTool, numSelectedObjects, numFilledObjects, numSolidObjects, selectionIncludesText) => ({ state => state.sketcher.present.selection.objects.filter(({ id }) => {
toolbar2d: filterMenus(activeTool, numSelectedObjects, numFilledObjects, numSolidObjects, selectionIncludesText, nestChildren(menus, menus[TOOLBAR2D])), return state.sketcher.present.objectsById[id].solid;
toolbar3d: filterMenus(activeTool, numSelectedObjects, numFilledObjects, numSolidObjects, selectionIncludesText, nestChildren(menus, menus[TOOLBAR3D])), }).length,
context: filterMenus(activeTool, numSelectedObjects, numFilledObjects, numSolidObjects, selectionIncludesText, nestChildren(menus, menus[CONTEXT])) state => state.sketcher.present.selection.objects.some(({ id }) => {
return state.sketcher.present.objectsById[id].type === 'TEXT';
})
], (menus, ...args) => ({
toolbar2d: filterMenus(...args, nestChildren(menus, menus[TOOLBAR2D])),
toolbar3d: filterMenus(...args, nestChildren(menus, menus[TOOLBAR3D])),
context: filterMenus(...args, nestChildren(menus, menus[CONTEXT]))
})); }));
export default injectSheet(styles)(connect(getMenus)(SketcherToolbars)); export default injectSheet(styles)(connect(getMenus)(SketcherToolbars));

View File

@ -67,7 +67,9 @@ class SubMenu extends React.Component {
} }
}; };
render() { render() {
const { id, value, selected, open, selectedValue, children, svg, toggleBehavior, color, solid } = this.props; const {
id, value, selected, open, selectedValue, children, svg, toggleBehavior, color, solid
} = this.props;
const style = {}; const style = {};
if (id === 'color-picker-tool') { if (id === 'color-picker-tool') {

View File

@ -65,7 +65,9 @@ export default class EventGroup extends Group {
if (event.event) gestureEvent.position = _convertEvent(event.event); if (event.event) gestureEvent.position = _convertEvent(event.event);
if (event.events) gestureEvent.positions = event.events.map(_convertEvent); if (event.events) gestureEvent.positions = event.events.map(_convertEvent);
if (event.preEvents) gestureEvent.preDrags = event.preEvents.map(_convertEvent); if (event.preEvents) gestureEvent.preDrags = event.preEvents.map(_convertEvent);
if (event.event && event.event.deltaY !== undefined) gestureEvent.wheelDelta = normalizeWheel(event.event).pixelY; if (event.event && event.event.deltaY !== undefined) {
gestureEvent.wheelDelta = normalizeWheel(event.event).pixelY;
}
this.onEvent(gestureEvent); this.onEvent(gestureEvent);
} }

View File

@ -58,24 +58,6 @@ export default class PolygonTool extends BaseTool {
context.restore(); context.restore();
context.beginPath(); context.beginPath();
// const anglePosition = this.anglePosition.applyMatrix(matrix);
// context.arc(anglePosition.x, anglePosition.y, 20, 0, this.angleDegrees, this.angleDegrees > Math.PI);
//
// context.strokeStyle = 'black';
// context.lineWidth = 1;
// context.stroke();
//
// const angleTextPos = new Vector(28, 0)
// .rotate((this.angleDegrees < Math.PI ? this.angleDegrees : this.angleDegrees - Math.PI * 2.0) / 2)
// .add(anglePosition);
// context.textAlign = 'start';
// context.textBaseline = 'middle';
// context.fillStyle = '#000';
// context.font = '10px Arial';
//
// const angleDegrees = this.angleDegrees < Math.PI ? this.angleDegrees : Math.PI * 2 - this.angleDegrees;
// dimensionsText.drawText(context, humanReadable.degrees(angleDegrees), angleTextPos.x, angleTextPos.y);
} }
} }
} }

View File

@ -42,7 +42,9 @@ export class EventScene extends THREE.Scene {
if (event.event) gestureEvent.position = _convertEvent(event.event); if (event.event) gestureEvent.position = _convertEvent(event.event);
if (event.events) gestureEvent.positions = event.events.map(_convertEvent); if (event.events) gestureEvent.positions = event.events.map(_convertEvent);
if (event.preEvents) gestureEvent.preDrags = event.preEvents.map(_convertEvent); if (event.preEvents) gestureEvent.preDrags = event.preEvents.map(_convertEvent);
if (event.event && event.event.deltaY !== undefined) gestureEvent.wheelDelta = normalizeWheel(event.event).pixelY; if (event.event && event.event.deltaY !== undefined) {
gestureEvent.wheelDelta = normalizeWheel(event.event).pixelY;
}
this.onEvent(gestureEvent); this.onEvent(gestureEvent);
}; };

2
src/d3/ShapeMesh.js vendored
View File

@ -21,7 +21,7 @@ class ShapeMesh extends THREE.Object3D {
super(); super();
this.name = shapeData.UID; this.name = shapeData.UID;
const { sculpt, rotate, twist, height, type, transform, z, color, fill, solid } = shapeData; const { sculpt, rotate, twist, height, type, transform, z, color, solid } = shapeData;
const material = new MatcapMaterial({ color: new THREE.Color(color) }); const material = new MatcapMaterial({ color: new THREE.Color(color) });

View File

@ -55,7 +55,7 @@ export default class AnaglyphPass {
this._renderTargetR.setSize(width * pixelRatio, height * pixelRatio); this._renderTargetR.setSize(width * pixelRatio, height * pixelRatio);
} }
render(renderer, writeBuffer, readBuffer, delta, maskActive) { render(renderer, writeBuffer, readBuffer) {
this.scene.updateMatrixWorld(); this.scene.updateMatrixWorld();
this._stereo.update(this.camera); this._stereo.update(this.camera);

View File

@ -1,5 +1,3 @@
import * as THREE from 'three';
export default class RenderPass { export default class RenderPass {
constructor(scene, camera, callbackBeforeRender) { constructor(scene, camera, callbackBeforeRender) {
this.scene = scene; this.scene = scene;
@ -10,10 +8,10 @@ export default class RenderPass {
this.renderToScreen = false; this.renderToScreen = false;
} }
setSize(width, height) { setSize() {
} }
render(renderer, writeBuffer, readBuffer, delta, maskActive) { render(renderer, writeBuffer, readBuffer) {
if (this._callbackBeforeRender) this._callbackBeforeRender(); if (this._callbackBeforeRender) this._callbackBeforeRender();
let oldAutoClear; let oldAutoClear;

View File

@ -1,5 +1,4 @@
import { CANVAS_SIZE } from '../../constants/d2Constants'; import { CANVAS_SIZE } from '../../constants/d2Constants';
import ShapeMesh from '../ShapeMesh.js';
import * as THREE from 'three'; import * as THREE from 'three';
import BaseTransformer from './BaseTransformer.js'; import BaseTransformer from './BaseTransformer.js';
import * as actions from '../../actions/index.js'; import * as actions from '../../actions/index.js';

View File

@ -1,5 +1,4 @@
import update from 'react-addons-update'; import update from 'react-addons-update';
import { Matrix } from 'cal';
import constrainMatrix from './constrainMatrix.js'; import constrainMatrix from './constrainMatrix.js';
import { calculateGestureMatrix } from '../../utils/matrixUtils.js'; import { calculateGestureMatrix } from '../../utils/matrixUtils.js';
import * as actions from '../../actions/index.js'; import * as actions from '../../actions/index.js';

View File

@ -31,5 +31,8 @@ function handleEraser(state, path, screenMatrixZoom) {
roundPrecision: 0.25 roundPrecision: 0.25
}); });
return subtractShapeFromState(state, eraserShape, d2Tools.ERASER, { matrix: screenMatrixZoom, scale: CLIPPER_PRECISION }); return subtractShapeFromState(state, eraserShape, d2Tools.ERASER, {
matrix: screenMatrixZoom,
scale: CLIPPER_PRECISION
});
} }

View File

@ -1,7 +1,5 @@
import { updateColor } from '../../selectionReducer.js'; import { updateColor } from '../../selectionReducer.js';
import { getColor } from '../../../utils/objectSelectors.js'; import { getColor } from '../../../utils/objectSelectors.js';
import { select } from '../../menusReducer.js';
import update from 'react-addons-update';
import { updateTool as updateTool2d } from '../toolReducer.js'; import { updateTool as updateTool2d } from '../toolReducer.js';
export default function pipetteReducer(state, action) { export default function pipetteReducer(state, action) {