semi working dimension line
parent
3dd7d47071
commit
fdf5dc628b
Binary file not shown.
|
@ -13,6 +13,7 @@ export function extrude(sketch) {
|
|||
|
||||
|
||||
function findPair(node) {
|
||||
if (node.userData.construction) return;
|
||||
visited.add(node)
|
||||
let linkedObj = linkedObjs.get(node.userData.l_id)
|
||||
let arr;
|
||||
|
@ -25,8 +26,8 @@ export function extrude(sketch) {
|
|||
v2s.push(new THREE.Vector2(arr[i], arr[i + 1]))
|
||||
}
|
||||
|
||||
offSetPts.push(arr[0], arr[1])
|
||||
offSetPts.push(arr[arr.length - 3], arr[arr.length - 2])
|
||||
offSetPts.push(arr[0], arr[1]) //make work points for sketch creation
|
||||
// offSetPts.push(arr[arr.length - 3], arr[arr.length - 2])
|
||||
|
||||
for (let i = 0; i < 2; i++) {
|
||||
let d = children[
|
||||
|
@ -46,7 +47,7 @@ export function extrude(sketch) {
|
|||
|
||||
function findTouching(node) {
|
||||
for (let t of node.userData.constraints) {
|
||||
if (constraints.get(t)[0] != 'coincident') continue
|
||||
if (constraints.get(t)[0] != 'points_coincident') continue
|
||||
for (let c of constraints.get(t)[2]) {
|
||||
if (c == -1) continue;
|
||||
const d = children[objIdx.get(c)]
|
||||
|
|
|
@ -181,7 +181,6 @@ class Sketch {
|
|||
break;
|
||||
case 'd':
|
||||
this.drawDimensionPre()
|
||||
this.mode = "arc"
|
||||
break;
|
||||
case 'x':
|
||||
this.deleteSelected()
|
||||
|
|
|
@ -1,6 +1,28 @@
|
|||
import * as THREE from '../../node_modules/three/src/Three';
|
||||
import { ptObj, lineObj, awaitPts } from '../utils/shared'
|
||||
|
||||
const color = {
|
||||
hover: 0x00ff00,
|
||||
lighting: 0xFFFFFF,
|
||||
emissive: 0x072534,
|
||||
d: 0xf5bc42, //datums: planes
|
||||
p: 0x555555, //points
|
||||
l: 0x555555, //lines
|
||||
m: 0x156289, //mesh: extrude
|
||||
}
|
||||
|
||||
const lineMaterial = new THREE.LineBasicMaterial({
|
||||
linewidth: 2,
|
||||
color: color.l,
|
||||
})
|
||||
|
||||
|
||||
const pointMaterial = new THREE.PointsMaterial({
|
||||
color: color.p,
|
||||
size: 4,
|
||||
})
|
||||
|
||||
|
||||
const DptObj = (n) => {
|
||||
const ret = new THREE.Points(
|
||||
new THREE.BufferGeometry().setAttribute('position',
|
||||
|
@ -12,6 +34,7 @@ const DptObj = (n) => {
|
|||
|
||||
ret.matrixAutoUpdate = false;
|
||||
ret.userData.constraints = []
|
||||
ret.userData.construction = true
|
||||
|
||||
return ret
|
||||
}
|
||||
|
@ -62,12 +85,15 @@ export async function drawDimensionPre() {
|
|||
p1.userData.constraints.push(this.c_id)
|
||||
p2.userData.constraints.push(this.c_id)
|
||||
|
||||
// this.updateOtherBuffers()
|
||||
// console.log(points)
|
||||
|
||||
for (let i = 1; i++; i < points.length) {
|
||||
const updatePoint = this.obj3d.children.length
|
||||
for (let i = 1; i < points.length; i++) {
|
||||
if (i % 2) {
|
||||
this.constraints.set(++this.c_id, //??? increment investigation
|
||||
[
|
||||
'coincident', -1,
|
||||
'points_coincident', -1,
|
||||
[points[i - 1].name, points[i].name, -1, -1]
|
||||
]
|
||||
)
|
||||
|
@ -75,9 +101,10 @@ export async function drawDimensionPre() {
|
|||
points[i].userData.constraints.push(this.c_id)
|
||||
|
||||
|
||||
} else {
|
||||
} else { // even
|
||||
|
||||
const toPush = [...points.slice(i - 1, i + 1), lines[i / 2 - 1]]
|
||||
|
||||
const toPush = [...points.slice(i - 2, i), lines[i / 2 - 1]]
|
||||
this.linkedObjs.set(this.l_id, ['line', toPush.map(e => e.name)])
|
||||
for (let obj of toPush) {
|
||||
obj.userData.l_id = this.l_id
|
||||
|
@ -95,10 +122,29 @@ export async function drawDimensionPre() {
|
|||
lines[i / 2 - 1].userData.constraints.push(this.c_id)
|
||||
}
|
||||
|
||||
this.obj3d.add(...toPush) // not to be confused with this.topush
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (i<=3) { // move pts to their respective spots to spread them
|
||||
points[i].geometry.attributes.position.set(p1.geometry.attributes.position.array)
|
||||
} else {
|
||||
points[i].geometry.attributes.position.set(p2.geometry.attributes.position.array)
|
||||
}
|
||||
}
|
||||
|
||||
lines[0].userData.construction = true
|
||||
lines[2].userData.construction = true
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.updatePointsBuffer(updatePoint)
|
||||
this.updateOtherBuffers()
|
||||
|
||||
// line[1].geometry.attributes.position.set(p1.geometry.attributes.position.array)
|
||||
// line[1].geometry.attributes.position.set(p1.geometry.attributes.position.array, 3)
|
||||
|
@ -117,7 +163,7 @@ export async function drawDimensionPre() {
|
|||
|
||||
|
||||
|
||||
return [p1, p2, line];
|
||||
return
|
||||
}
|
||||
|
||||
export function drawLine(mouseLoc) {
|
||||
|
@ -132,7 +178,7 @@ export function drawLine(mouseLoc) {
|
|||
|
||||
this.constraints.set(++this.c_id,
|
||||
[
|
||||
'coincident', -1,
|
||||
'points_coincident', -1,
|
||||
[this.obj3d.children[this.obj3d.children.length - 2].name, p1.name, -1, -1]
|
||||
]
|
||||
)
|
||||
|
|
|
@ -31,6 +31,7 @@ export function onHover(e) {
|
|||
idx.push(i)
|
||||
}
|
||||
}
|
||||
// console.log(hoverPts, idx)
|
||||
if (!idx.length) idx.push(0)
|
||||
}
|
||||
|
||||
|
@ -92,13 +93,19 @@ export function onPick(e) {
|
|||
export function onDrag(e) {
|
||||
const mouseLoc = this.getLocation(e);
|
||||
|
||||
for (let x = 0; x < this.hovered.length; x++) {
|
||||
const obj = this.hovered[x]
|
||||
// for (let x = 0; x < this.hovered.length; x++) {
|
||||
// const obj = this.hovered[x]
|
||||
// this.ptsBuf.set(
|
||||
// mouseLoc,
|
||||
// this.objIdx.get(obj.name) * 3
|
||||
// )
|
||||
// }
|
||||
|
||||
const obj = this.hovered[this.hovered.length-1]
|
||||
this.ptsBuf.set(
|
||||
mouseLoc,
|
||||
this.objIdx.get(obj.name) * 3
|
||||
)
|
||||
}
|
||||
|
||||
this.solve()
|
||||
this.obj3d.dispatchEvent({ type: 'change' })
|
||||
|
|
|
@ -77,6 +77,7 @@ int solver(int nPts, float *p_ptr, int nConst, float *c_ptr, int nLinks, float *
|
|||
{
|
||||
if (isnan((float)*p_ptr))
|
||||
{
|
||||
// printf("%i\n",i);
|
||||
p_ptr += 3;
|
||||
continue;
|
||||
}
|
||||
|
@ -92,13 +93,14 @@ int solver(int nPts, float *p_ptr, int nConst, float *c_ptr, int nLinks, float *
|
|||
switch ((int)*l_ptr++)
|
||||
{
|
||||
case 0:
|
||||
sys.entity[sys.entities++] = Slvs_MakeLineSegment(lh++, g,
|
||||
// printf("matching %i\n",(int)*(l_ptr + 2));
|
||||
sys.entity[sys.entities++] = Slvs_MakeLineSegment((int)*(l_ptr + 2), g,
|
||||
200, (int)*l_ptr, (int)*(l_ptr + 1));
|
||||
break;
|
||||
case 1:
|
||||
/* And arc, centered at point 303, starting at point 304, ending at
|
||||
* point 305. */
|
||||
sys.entity[sys.entities++] = Slvs_MakeArcOfCircle(lh++, g, 200, 102,
|
||||
sys.entity[sys.entities++] = Slvs_MakeArcOfCircle((int)*(l_ptr + 3), g, 200, 102,
|
||||
(int)*(l_ptr + 2), (int)*(l_ptr), (int)*(l_ptr + 1));
|
||||
break;
|
||||
default:
|
||||
|
@ -108,50 +110,15 @@ int solver(int nPts, float *p_ptr, int nConst, float *c_ptr, int nLinks, float *
|
|||
l_ptr += 4;
|
||||
}
|
||||
|
||||
for (int i = 0; i < nConst; i++)
|
||||
for (int i = 0; i < nConst; i++, c_ptr += 6)
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch ((int)*c_ptr + 100000)
|
||||
{
|
||||
case SLVS_C_POINTS_COINCIDENT:
|
||||
c_ptr += 2;
|
||||
// printf("%i here %i\n",(int)*c_ptr, nConst);
|
||||
sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
|
||||
con_id++, g,
|
||||
SLVS_C_POINTS_COINCIDENT,
|
||||
(int)*c_ptr + 100000,
|
||||
200,
|
||||
0.0,
|
||||
(int)*c_ptr, (int)*(c_ptr + 1), 0, 0);
|
||||
|
||||
c_ptr += 4;
|
||||
break;
|
||||
case 1:
|
||||
|
||||
break;
|
||||
default:
|
||||
c_ptr += 6;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if ((int)*c_ptr + 100000 == SLVS_C_POINTS_COINCIDENT)
|
||||
// {
|
||||
// c_ptr += 2;
|
||||
// sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
|
||||
// con_id++, g,
|
||||
// SLVS_C_POINTS_COINCIDENT,
|
||||
// 200,
|
||||
// 0.0,
|
||||
// (int)*c_ptr, (int)*(c_ptr + 1), 0, 0);
|
||||
|
||||
// c_ptr += 4;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// c_ptr += 6;
|
||||
// }
|
||||
*(c_ptr + 1),
|
||||
(int)*(c_ptr + 2), (int)*(c_ptr + 3), (int)*(c_ptr + 4), (int)*(c_ptr + 5));
|
||||
}
|
||||
|
||||
/* And solve. */
|
||||
|
|
Loading…
Reference in New Issue