2021-03-26 12:30:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
export function addDimension(ent1, ent2, distance) {
|
|
|
|
|
|
|
|
|
|
|
|
// if (ent1.type ==)
|
|
|
|
|
|
|
|
this.constraints.set(++this.c_id,
|
|
|
|
[
|
|
|
|
'distance', distance,
|
|
|
|
[p1, p2, -1, -1]
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2021-03-31 16:07:34 +08:00
|
|
|
ent1.userData.constraints.push(this.c_id)
|
|
|
|
ent2.userData.constraints.push(this.c_id)
|
2021-03-26 12:30:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function setCoincident() {
|
|
|
|
const s = new Set()
|
|
|
|
const toComb = []
|
|
|
|
for (let node of this.selected) {
|
|
|
|
const xc = node.geometry.attributes.position.array[0]
|
|
|
|
if (!s.has(xc)) {
|
|
|
|
toComb.push(node)
|
|
|
|
s.add(xc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 1; i < toComb.length; i++) {
|
|
|
|
this.constraints.set(++this.c_id,
|
|
|
|
[
|
2021-04-03 03:33:09 +08:00
|
|
|
'points_coincident', -1,
|
2021-04-01 06:03:35 +08:00
|
|
|
[toComb[i - 1].name, toComb[i].name, -1, -1] ///////
|
2021-03-26 12:30:35 +08:00
|
|
|
]
|
|
|
|
)
|
2021-03-31 16:07:34 +08:00
|
|
|
toComb[i].userData.constraints.push(this.c_id)
|
|
|
|
toComb[i - 1].userData.constraints.push(this.c_id)
|
2021-03-26 12:30:35 +08:00
|
|
|
}
|
|
|
|
|
2021-03-29 05:34:55 +08:00
|
|
|
this.updateOtherBuffers()
|
|
|
|
this.solve()
|
|
|
|
|
|
|
|
// update state of points
|
|
|
|
for (let obj of this.selected) {
|
|
|
|
obj.geometry.computeBoundingSphere()
|
|
|
|
obj.material.color.set(0x555555)
|
|
|
|
}
|
2021-03-31 07:20:24 +08:00
|
|
|
this.selected = []
|
2021-04-01 13:35:08 +08:00
|
|
|
this.obj3d.dispatchEvent({ type: 'change' })
|
2021-03-26 12:30:35 +08:00
|
|
|
}
|