hover not working

master
howard 2021-04-17 02:54:41 -07:00
parent abb7891a7e
commit fbb4fefaa9
4 changed files with 61 additions and 33 deletions

View File

@ -7,7 +7,7 @@ import { Sketch } from './Sketch'
import Stats from '../lib/stats.module.js'; import Stats from '../lib/stats.module.js';
import { extrude, flipBufferGeometryNormals } from './extrude' import { extrude, flipBufferGeometryNormals } from './extrude'
import { onHover, onPick } from './mouseEvents'; import { onHover, onPick, clearSelection } from './mouseEvents';
import { _vec2, _vec3, color, awaitSelection, ptObj, setHover } from './shared' import { _vec2, _vec3, color, awaitSelection, ptObj, setHover } from './shared'
import { AxesHelper } from './axes' import { AxesHelper } from './axes'
@ -133,6 +133,7 @@ export class Scene {
this.extrude = extrude.bind(this); this.extrude = extrude.bind(this);
this.onHover = onHover.bind(this); this.onHover = onHover.bind(this);
this.onPick = onPick.bind(this); this.onPick = onPick.bind(this);
this.clearSelection = clearSelection.bind(this);
this.setHover = setHover.bind(this); this.setHover = setHover.bind(this);
this.awaitSelection = awaitSelection.bind(this); this.awaitSelection = awaitSelection.bind(this);
@ -225,26 +226,26 @@ export class Scene {
return entry return entry
} }
clearSelection() { // clearSelection() {
for (let x = 0, obj; x < this.selected.length; x++) { // for (let x = 0, obj; x < this.selected.length; x++) {
obj = this.selected[x] // obj = this.selected[x]
if (obj.userData.type == 'selpoint') { // if (obj.userData.type == 'selpoint') {
obj.visible = false // obj.visible = false
} else { // } else {
setHover(obj, 0) // setHover(obj, 0)
} // }
} // }
this.selected = [] // this.selected = []
for (let x = 0; x < this.hovered.length; x++) { // for (let x = 0; x < this.hovered.length; x++) {
const obj = this.hovered[x] // const obj = this.hovered[x]
setHover(obj, 0) // setHover(obj, 0)
} // }
} // }
boolOp(m1, m2, op, refresh = false) { boolOp(m1, m2, op, refresh = false) {
@ -315,8 +316,8 @@ export class Scene {
const { byId, tree } = this.store.getState().treeEntries const { byId, tree } = this.store.getState().treeEntries
while (idx < que.length) { while (idx < que.length) {
curId = que[idx++] curId = que[idx++]
console.log(curId,byId,'cc')
if (byId[curId].userData) {
const info = byId[curId].userData.featureInfo const info = byId[curId].userData.featureInfo
let newNode let newNode
if (info.length == 2) { if (info.length == 2) {
@ -324,8 +325,8 @@ export class Scene {
} else if (info.length == 3) { } else if (info.length == 3) {
newNode = this.boolOp(byId[info[0]], byId[info[1]], info[2], true) newNode = this.boolOp(byId[info[0]], byId[info[1]], info[2], true)
} }
byId[curId].geometry.copy(newNode.geometry) byId[curId].geometry.copy(newNode.geometry)
}
for (let k in tree[curId]) { for (let k in tree[curId]) {
que.push(k) que.push(k)

View File

@ -174,7 +174,9 @@ class Sketch {
// overkill but good solution if this check was more costly // overkill but good solution if this check was more costly
this.hasChanged = false this.hasChanged = false
this.idOnActivate = id this.idOnActivate = id
// console.log(this,this.selected)
const changeDetector = (e) => { const changeDetector = (e) => {
console.log(this.selected.length, e.buttons)
if (this.selected.length && e.buttons) { if (this.selected.length && e.buttons) {
this.canvas.removeEventListener('pointermove', changeDetector) this.canvas.removeEventListener('pointermove', changeDetector)
this.hasChanged = true this.hasChanged = true
@ -193,6 +195,7 @@ class Sketch {
this.obj3d.traverse(e => e.layers.disable(2)) this.obj3d.traverse(e => e.layers.disable(2))
this.scene.axes.visible = false this.scene.axes.visible = false
this.scene.activeSketch = null this.scene.activeSketch = null
this.selected = []
} }

View File

@ -254,3 +254,23 @@ export function onRelease(e) {
} }
} }
export function clearSelection() {
for (let x = 0, obj; x < this.selected.length; x++) {
obj = this.selected[x]
if (obj.userData.type == 'selpoint') {
obj.visible = false
} else {
setHover(obj, 0)
}
}
this.selected = []
for (let x = 0; x < this.hovered.length; x++) {
const obj = this.hovered[x]
setHover(obj, 0)
}
}

View File

@ -52,29 +52,33 @@ export const Dialog = () => {
className="btn w-auto h-full p-3.5" className="btn w-auto h-full p-3.5"
onClick={() => { onClick={() => {
if (sc.activeSketch.hasChanged || sc.activeSketch.idOnActivate != id) { if (sc.activeSketch.hasChanged || sc.activeSketch.idOnActivate != id) {
console.log(sc.activeSketch)
for (let k in sc.store.getState().treeEntries.tree[sc.activeSketch.obj3d.name]) { // for (let k in sc.store.getState().treeEntries.tree[sc.activeSketch.obj3d.name]) {
console.log('circlllles',k) // console.log('circlllles',k)
sc.refreshNode(k) // }
}
sc.render() sc.refreshNode(sc.activeSketch.obj3d.name)
} }
// dispatch({ type: 'update-descendents', sketch}) // dispatch({ type: 'update-descendents', sketch})
sc.activeSketch.deactivate() sc.activeSketch.deactivate()
sc.render()
dispatch({ type: "clear-dialog" }) dispatch({ type: "clear-dialog" })
}} }}
/> />
<MdClose className="btn w-auto h-full p-3.5 mr-6" <MdClose className="btn w-auto h-full p-3.5 mr-6"
onClick={() => { onClick={() => {
console.log('cancle',sc.activeSketch.hasChanged, sc.activeSketch.idOnActivate, id)
if (sc.activeSketch.hasChanged || sc.activeSketch.idOnActivate != id) { if (sc.activeSketch.hasChanged || sc.activeSketch.idOnActivate != id) {
console.log('has changed') console.log('has changed')
dispatch({ type: "cancel-sketch" }) dispatch({ type: "cancel-sketch" })
sc.render()
} }
sc.activeSketch.deactivate() sc.activeSketch.deactivate()
sc.render()
dispatch({ type: "clear-dialog" }) dispatch({ type: "clear-dialog" })
} }
} }
/> />