master
howard 2021-04-14 22:32:20 -07:00
parent bdf1871b44
commit 79ccc4f83c
6 changed files with 65 additions and 41 deletions

View File

@ -39,7 +39,7 @@ var TrackballControls = function ( object, domElement ) {
this.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ]; this.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ];
this.mouseButtons = { LEFT: null, MIDDLE: MOUSE.ROTATE, RIGHT: MOUSE.PAN }; this.mouseButtons = { LEFT: null, MIDDLE: MOUSE.PAN, RIGHT: MOUSE.ROTATE };
// internals // internals
@ -506,7 +506,11 @@ var TrackballControls = function ( object, domElement ) {
break; break;
case 2: case 2:
_state = scope.mouseButtons.RIGHT; if (event.ctrlKey) {
_state = scope.mouseButtons.MIDDLE;
} else {
_state = scope.mouseButtons.RIGHT;
}
break; break;
default: default:

View File

@ -215,7 +215,7 @@ export class Scene {
} }
subtract(m1, m2, op) { boolOp(m1, m2, op) {
let bspA = CSG.fromMesh(m1) let bspA = CSG.fromMesh(m1)
let bspB = CSG.fromMesh(m2) let bspB = CSG.fromMesh(m2)
m1.visible = false m1.visible = false
@ -223,7 +223,6 @@ export class Scene {
m1.traverse(e => e.layers.disable(1)) m1.traverse(e => e.layers.disable(1))
m2.traverse(e => e.layers.disable(1)) m2.traverse(e => e.layers.disable(1))
// // Subtract one bsp from the other via .subtract... other supported modes are .union and .intersect
let bspResult, opChar; let bspResult, opChar;
switch (op) { switch (op) {
@ -243,24 +242,18 @@ export class Scene {
break; break;
} }
// //Get the resulting mesh from the result bsp, and assign meshA.material to the resulting mesh
let mesh = CSG.toMesh(bspResult, m1.matrix, m1.material) let mesh = CSG.toMesh(bspResult, m1.matrix, m1.material)
mesh.userData.type = 'mesh' mesh.userData.type = 'mesh'
mesh.name = `(${m1.name}${opChar}${m2.name})` mesh.name = `(${m1.name}${opChar}${m2.name})`
mesh.layers.enable(1) mesh.layers.enable(1)
const vertices = new THREE.Points(mesh.geometry, new THREE.PointsMaterial({ size: 0 })); const vertices = new THREE.Points(mesh.geometry, new THREE.PointsMaterial({ size: 0 }));
vertices.userData.type = 'point' vertices.userData.type = 'point'
vertices.layers.enable(1) vertices.layers.enable(1)
// mesh.add(line)
mesh.add(vertices) mesh.add(vertices)
sc.obj3d.add(mesh) sc.obj3d.add(mesh)
this.store.dispatch({ this.store.dispatch({
@ -313,19 +306,10 @@ function render() {
} }
this.stats.end(); this.stats.end();
} }
async function addSketch() { async function addSketch() {
let sketch; let sketch;

View File

@ -114,6 +114,7 @@ export function onHover(e) {
let draggedLabel; let draggedLabel;
export function onPick(e) { export function onPick(e) {
console.log(e)
if (this.mode || e.buttons != 1) return if (this.mode || e.buttons != 1) return
if (this.hovered.length) { if (this.hovered.length) {
@ -151,9 +152,13 @@ export function onPick(e) {
obj obj
) )
this.setHover(obj, 1) this.setHover(obj, 1)
} else { } else {
this.setHover(this.selected[idx], 0) this.setHover(this.selected[idx], 0)
this.selected.splice(idx, 1) this.selected.splice(idx, 1)
} }
} }
@ -204,6 +209,13 @@ export function onPick(e) {
if (obj.userData.type == 'selpoint') { if (obj.userData.type == 'selpoint') {
obj.visible = false obj.visible = false
} }
// dont think this would have been possible without redux
if (obj.userData.type == 'sketch' && !sc.store.getState().treeEntries.visible[obj.name]) {
obj.visible = false
}
} }
this.obj3d.dispatchEvent({ type: 'change' }) this.obj3d.dispatchEvent({ type: 'change' })
this.selected = [] this.selected = []

View File

@ -19,7 +19,7 @@ export const NavBar = () => {
const boolOp = (code) => { const boolOp = (code) => {
if (sc.selected.length != 2 || !sc.selected.every(e => e.userData.type == 'mesh')) return if (sc.selected.length != 2 || !sc.selected.every(e => e.userData.type == 'mesh')) return
const [m1, m2] = sc.selected const [m1, m2] = sc.selected
const mesh = sc.subtract(m1, m2, code) const mesh = sc.boolOp(m1, m2, code)
dispatch({ type: 'rx-boolean', mesh, deps: [m1.name, m2.name] }) dispatch({ type: 'rx-boolean', mesh, deps: [m1.name, m2.name] })
sc.render() sc.render()
forceUpdate() forceUpdate()

View File

@ -29,12 +29,10 @@ const TreeEntry = ({ entId }) => {
const treeEntries = useSelector(state => state.treeEntries.byId) const treeEntries = useSelector(state => state.treeEntries.byId)
const dispatch = useDispatch() const dispatch = useDispatch()
const visible = useSelector(state => state.treeEntries.visible[entId]) const visible = useSelector(state => state.treeEntries.visible[entId])
let obj3d, sketch; let obj3d, sketch;
if (treeEntries[entId].obj3d) { if (treeEntries[entId].obj3d) {
obj3d = treeEntries[entId].obj3d obj3d = treeEntries[entId].obj3d
sketch = treeEntries[entId] sketch = treeEntries[entId]
@ -44,10 +42,9 @@ const TreeEntry = ({ entId }) => {
let Icon = treeIcons[obj3d.userData.type] let Icon = treeIcons[obj3d.userData.type]
const [_, forceUpdate] = useReducer(x => x + 1, 0); const [_, forceUpdate] = useReducer(x => x + 1, 0);
const [mouseOn, setMouseOn] = useState(false)
return <div className='btn select-none flex justify-start w-full h-7 items-center text-sm' return <div className='btn select-none flex justify-start w-full h-7 items-center text-sm'
onDoubleClick={() => { onDoubleClick={() => {
if (obj3d.userData.type == 'sketch') { if (obj3d.userData.type == 'sketch') {
sc.activeSketch && sc.activeSketch.deactivate() sc.activeSketch && sc.activeSketch.deactivate()
@ -60,35 +57,43 @@ const TreeEntry = ({ entId }) => {
}} }}
onPointerEnter={() => { onPointerEnter={() => {
if (mouseOn) return
setMouseOn(true)
if (obj3d.userData.type == 'sketch') {
obj3d.visible = true
}
sc.setHover(obj3d, 1) sc.setHover(obj3d, 1)
sc.render() sc.render()
}} }}
onPointerLeave={() => { onPointerLeave={() => {
// if (visible & obj3d.userData.type == 'sketch') return if (!mouseOn) return
if (sc.selected.includes(obj3d) || sc.activeSketch && sc.activeSketch.name == obj3d.name) return setMouseOn(false)
if (obj3d.userData.type == 'sketch'
&& !sc.selected.includes(obj3d)
&& !visible
) {
obj3d.visible = false
}
if (sc.selected.includes(obj3d)) return
sc.setHover(obj3d, 0) sc.setHover(obj3d, 0)
sc.render() sc.render()
}} }}
onClick={() => { onClick={() => {
// if (obj3d.userData.type == 'mesh') {
// console.log(obj3d, sc.selected)
const idx = sc.selected.indexOf(obj3d) const idx = sc.selected.indexOf(obj3d)
if (idx == -1) { if (idx == -1) {
sc.selected.push( sc.selected.push(obj3d)
obj3d
)
sc.setHover(obj3d, 1) sc.setHover(obj3d, 1)
} else { } else {
sc.setHover(sc.selected[idx], 0) sc.setHover(sc.selected[idx], 0)
sc.selected.splice(idx, 1) sc.selected.splice(idx, 1)
} }
// sc.selected.push(
// obj3d
// )
// }
sc.render() sc.render()
}} }}
> >

View File

@ -23,6 +23,8 @@ horizontal // done
constraint angle // done constraint angle // done
button panel cleanup // done button panel cleanup // done
3 pt arc // done
tangent // done to the best of my ability
-unable to delete arc -unable to delete arc
@ -30,6 +32,8 @@ hover not clearing sometimes
dim tags are not clearing dim tags are not clearing
should unselect after boolean should unselect after boolean
auto update extrude auto update extrude
extrude dialogue extrude dialogue
loopfind especially arc loopfind especially arc
@ -37,13 +41,28 @@ file save, stl export
better default ent names better default ent names
reattach sketch reattach sketch
3 pt arc // done
auto snap auto snap
constraint labels,tangent, equal constraint labels,equal
parallel parallel
tree ent renaming tree ent renaming
set pieces
hover state for sketch
await selection
3 point arc implementation