From cfb80a46bab7a2807dc8231940d88880e64059b0 Mon Sep 17 00:00:00 2001 From: howard Date: Wed, 21 Apr 2021 04:46:55 -0700 Subject: [PATCH] fix angle bug --- src/drawDimension.js | 5 ++++- src/mouseEvents.js | 9 +-------- src/react/dropDown.jsx | 6 ++---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/drawDimension.js b/src/drawDimension.js index ffb0c0e..dd447b7 100644 --- a/src/drawDimension.js +++ b/src/drawDimension.js @@ -423,7 +423,7 @@ const _vec2 = new THREE.Vector2() let arr, i, j, centerScalar, r_cross_s, center, tagRadius let dA, tagtoMidline, shift, tA1, tA2, a1, deltaAngle; -function updateAngle(linegeom, pointgeom, _l1, _l2, offset) { +function updateAngle(line, point, _l1, _l2, offset) { /* l2:[x0,y0,z0,x1,y1,z1] / @@ -442,6 +442,9 @@ function updateAngle(linegeom, pointgeom, _l1, _l2, offset) { ] */ + const linegeom = line.geometry.attributes.position + const pointgeom = point.geometry.attributes.position + for (i = 0; i < 4;) { arr = i == 0 ? _l1 : _l2 vecArr[i++].set(arr[0], arr[1]) diff --git a/src/mouseEvents.js b/src/mouseEvents.js index 3fa0c72..6a2f749 100644 --- a/src/mouseEvents.js +++ b/src/mouseEvents.js @@ -5,8 +5,7 @@ import { onDimMoveEnd } from './drawDimension' let ptLoc export function onHover(e) { - // if (( this.mode && this.mode!='dimension') || e.buttons) return - if (e.buttons) return + if (( this.mode && this.mode!='dimension') || e.buttons) return raycaster.setFromCamera( new THREE.Vector2( @@ -32,7 +31,6 @@ export function onHover(e) { let idx = [] if (hoverPts.length) { - // console.log(hoverPts) let minDist = Infinity; for (let i = 0; i < hoverPts.length; i++) { if (!hoverPts[i].distanceToRay) continue; @@ -49,10 +47,6 @@ export function onHover(e) { if (!idx.length) { idx.push(0) - // if (idx.length >=2) { - // idx.push(1) - - // } } } @@ -91,7 +85,6 @@ export function onHover(e) { this.hovered.push(obj) } - console.log(this.hovered) // console.log('render1') this.obj3d.dispatchEvent({ type: 'change' }) diff --git a/src/react/dropDown.jsx b/src/react/dropDown.jsx index e7409ea..9666807 100644 --- a/src/react/dropDown.jsx +++ b/src/react/dropDown.jsx @@ -6,10 +6,8 @@ import { useDispatch, useSelector } from 'react-redux' export const DropDown = () => { const arr = [ - ['https://raw.githubusercontent.com/twpride/threeCAD/master/example_parts/test2.json', 'test2'], - ['https://raw.githubusercontent.com/twpride/threeCAD/master/example_parts/test2.json', 'test2'], - ['https://raw.githubusercontent.com/twpride/threeCAD/master/example_parts/test2.json', 'test2'], - ['https://raw.githubusercontent.com/twpride/threeCAD/master/example_parts/test2.json', 'test2'], + ['https://raw.githubusercontent.com/twpride/threeCAD/master/demo_parts/test2.json', 'test2'], + ['https://raw.githubusercontent.com/twpride/threeCAD/master/demo_parts/headphone-stand.json', 'headphone-stand'], ] const dispatch = useDispatch()