ugly but works 2
parent
fbb4fefaa9
commit
4076c90e58
|
@ -412,10 +412,14 @@ async function addSketch() {
|
|||
sketch.activate()
|
||||
|
||||
this.render()
|
||||
|
||||
|
||||
}
|
||||
|
||||
window.sc = new Scene(store)
|
||||
sc.loadState()
|
||||
|
||||
|
||||
|
||||
// sc.camera.layers.enable(1)
|
||||
// rc.layers.set(1)
|
|
@ -5,7 +5,7 @@ import * as THREE from '../node_modules/three/src/Three';
|
|||
import { _vec2, _vec3, raycaster, awaitSelection, ptObj, setHover } from './shared'
|
||||
|
||||
import { drawOnClick1, drawOnClick2, drawPreClick2, drawOnClick3, drawPreClick3, drawClear, drawPoint } from './drawEvents'
|
||||
import { onHover, onDrag, onPick, onRelease } from './mouseEvents'
|
||||
import { onHover, onDrag, onPick, onRelease, clearSelection} from './mouseEvents'
|
||||
import { setCoincident, setOrdinate, setTangent } from './constraintEvents'
|
||||
import { get3PtArc } from './drawArc'
|
||||
import { replacer, reviver } from './utils'
|
||||
|
@ -148,6 +148,7 @@ class Sketch {
|
|||
this.onKeyPress = this.onKeyPress.bind(this);
|
||||
|
||||
this.setHover = setHover.bind(this);
|
||||
this.clearSelection = clearSelection.bind(this)
|
||||
|
||||
}
|
||||
|
||||
|
@ -186,6 +187,7 @@ class Sketch {
|
|||
}
|
||||
|
||||
deactivate() {
|
||||
console.log('deactivateeeeeeee')
|
||||
window.removeEventListener('keydown', this.onKeyPress)
|
||||
this.canvas.removeEventListener('pointerdown', this.onPick)
|
||||
this.canvas.removeEventListener('pointermove', this.onHover)
|
||||
|
@ -195,7 +197,9 @@ class Sketch {
|
|||
this.obj3d.traverse(e => e.layers.disable(2))
|
||||
this.scene.axes.visible = false
|
||||
this.scene.activeSketch = null
|
||||
this.selected = []
|
||||
|
||||
this.clearSelection()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,11 +72,14 @@ export const Dialog = () => {
|
|||
if (sc.activeSketch.hasChanged || sc.activeSketch.idOnActivate != id) {
|
||||
console.log('has changed')
|
||||
dispatch({ type: "cancel-sketch" })
|
||||
sc.store.getState().treeEntries.byId[sc.activeSketch.obj3d.name].deactivate()
|
||||
} else {
|
||||
|
||||
sc.activeSketch.deactivate()
|
||||
}
|
||||
|
||||
sc.activeSketch.deactivate()
|
||||
sc.render()
|
||||
|
||||
sc.render()
|
||||
dispatch({ type: "clear-dialog" })
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,16 @@ export const NavBar = () => {
|
|||
forceUpdate()
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => { // hacky way to handle mounting and unmounting mouse listeners for feature mode
|
||||
if (!activeSketchId) {
|
||||
sc.canvas.addEventListener('pointermove', sc.onHover)
|
||||
sc.canvas.addEventListener('pointerdown', sc.onPick)
|
||||
return () => {
|
||||
sc.canvas.removeEventListener('pointermove', sc.onHover)
|
||||
sc.canvas.removeEventListener('pointerdown', sc.onPick)
|
||||
}
|
||||
}
|
||||
}, [activeSketchId])
|
||||
|
||||
const sketchModeButtons = [
|
||||
[Icon.Extrude, () => {
|
||||
|
|
|
@ -50,12 +50,15 @@ export function treeEntries(state = defaultState, action) {
|
|||
const deletedObj = sc.obj3d.children.splice(state.order[state.activeSketchId] + 1, 1,
|
||||
sketch.obj3d
|
||||
)[0]
|
||||
console.log('spliced and starting to delete')
|
||||
|
||||
deletedObj.traverse((obj) => {
|
||||
if (obj.geometry) obj.geometry.dispose()
|
||||
if (obj.material) obj.material.dispose()
|
||||
})
|
||||
|
||||
// sketch.deactivate()
|
||||
|
||||
return update(state, {
|
||||
activeSketchId: { $set: "" },
|
||||
byId: { [state.activeSketchId]: { $set: sketch } },
|
||||
|
|
Loading…
Reference in New Issue