diff --git a/src/drawArc.js b/src/drawArc.js index 2218a1a..586f5b0 100644 --- a/src/drawArc.js +++ b/src/drawArc.js @@ -122,6 +122,7 @@ export function drawArc4(mouseLoc, toPush) { points ); arc.geometry.attributes.position.needsUpdate = true; + arc.geometry.computeBoundingSphere() arc.userData.ccw = ccw; return ccw diff --git a/src/drawEvents.js b/src/drawEvents.js index c745409..64ec487 100644 --- a/src/drawEvents.js +++ b/src/drawEvents.js @@ -33,6 +33,7 @@ export function drawOnClick1(e) { } else { + console.log(this.hovered) if (this.hovered.length) { this.constraints.set(++this.c_id, //??? why incremennt before not after @@ -41,6 +42,8 @@ export function drawOnClick1(e) { [this.hovered[this.hovered.length - 1].name, this.toPush[0].name, -1, -1] ] ) + this.hovered[this.hovered.length - 1].userData.constraints.push(this.c_id) + this.toPush[0].userData.constraints.push(this.c_id) this.updateOtherBuffers() } @@ -59,6 +62,8 @@ export function drawOnClick1(e) { [this.hovered[this.hovered.length - 1].name, this.toPush[0].name, -1, -1] ] ) + this.hovered[this.hovered.length - 1].userData.constraints.push(this.c_id) + this.toPush[0].userData.constraints.push(this.c_id) this.updateOtherBuffers() } @@ -110,11 +115,11 @@ export function drawOnClick2(e) { // a this.mode == "" will prevent event chain from persisisting if (this.mode == "line") { - if (this.hovered.length >= 2) { + if (this.hovered.length>=2) { this.constraints.set(++this.c_id, //??? why incremennt before not after [ 'points_coincident', -1, - [this.hovered[this.hovered.length - 2].name, this.hovered[this.hovered.length - 1].name, -1, -1] + [this.hovered[this.hovered.length - 2].name, this.toPush[1].name, -1, -1] ] ) this.updateOtherBuffers() @@ -127,13 +132,12 @@ export function drawOnClick2(e) { } else if (this.mode == "point") { this.drawOnClick1(e) } else if (this.mode == "arc") { - this.snap = false - if (this.hovered.length >= 2) { + if (this.hovered.length>=2) { this.constraints.set(++this.c_id, //??? why incremennt before not after [ 'points_coincident', -1, - [this.hovered[this.hovered.length - 2].name, this.hovered[this.hovered.length - 1].name, -1, -1] + [this.hovered[this.hovered.length - 2].name, this.toPush[1].name, -1, -1] ] ) this.updateOtherBuffers() diff --git a/src/mouseEvents.js b/src/mouseEvents.js index 36bd547..763e574 100644 --- a/src/mouseEvents.js +++ b/src/mouseEvents.js @@ -1,6 +1,7 @@ import * as THREE from '../node_modules/three/src/Three'; import { raycaster, setHover } from './shared'; import { onDimMoveEnd } from './drawDimension' +import { connectAdvanced } from 'react-redux'; let ptLoc @@ -18,7 +19,7 @@ export function onHover(e) { let hoverPts; - + if (this.obj3d.userData.type != 'sketch') { this.selpoints[0].visible = false // hide selpoint[0] before each redraw raycaster.layers.set(1) @@ -34,7 +35,7 @@ export function onHover(e) { const thresh = this.snap ? 1 : 0.0001 if (hoverPts.length) { - console.log('here', hoverPts) + // console.log('here', hoverPts) let minDist = Infinity; for (let i = 0; i < hoverPts.length; i++) { if (!hoverPts[i].distanceToRay) continue; @@ -70,9 +71,14 @@ export function onHover(e) { for (let x = 0; x < idx.length; x++) { let obj = hoverPts[idx[x]].object - // if (!this.snap || (this.snap && x < idx.length-1) ) { + if (this.snap) { + if (idx.length==1 || x != idx.length - 1) { + setHover(obj, 1, false) + } + } else { setHover(obj, 1, false) - // } + } + if (this.obj3d.userData.type != 'sketch' && obj.userData.type == 'point') { ptLoc = obj.geometry.attributes.position.array