snap improvements

master
howard 2021-04-21 15:32:34 -07:00
parent 33f572e3c2
commit 25791f40b9
3 changed files with 20 additions and 9 deletions

View File

@ -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

View File

@ -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()

View File

@ -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
@ -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