fix dimension tag bugs
parent
a0f0566704
commit
930df2e288
Binary file not shown.
|
@ -16,13 +16,7 @@ import { AxesHelper } from './axes'
|
|||
import CSG from "../lib/three-csg"
|
||||
|
||||
|
||||
const eq = (a1, a2) => {
|
||||
if (a1.length != a2.length) return false
|
||||
for (let i = 0; i < a1.length; i++) {
|
||||
if (a1[i] != a2[i]) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
window.loader = new THREE.ObjectLoader();
|
||||
window.id = 0
|
||||
|
|
|
@ -313,9 +313,10 @@ class Sketch {
|
|||
obj.geometry.dispose()
|
||||
obj.material.dispose()
|
||||
|
||||
for (let c_id of obj.userData.constraints) {
|
||||
for (let c_id of obj.userData.constraints.slice()) { // i hate js
|
||||
this.deleteConstraints(c_id)
|
||||
}
|
||||
obj.userData.constraints = []
|
||||
}
|
||||
|
||||
this.obj3d.children.splice(i, link.length)
|
||||
|
@ -336,10 +337,11 @@ class Sketch {
|
|||
}
|
||||
this.constraints.delete(c_id)
|
||||
|
||||
for (let i = 0; i < this.obj3d.children[1].children.length; i++) {
|
||||
if (this.obj3d.children[1].children[i].name == c_id) {
|
||||
this.obj3d.children[1].children.splice(i, i + 2).forEach(
|
||||
for (let i = 0; i < this.dimGroup.children.length; i++) {
|
||||
if (this.dimGroup.children[i].name == c_id) {
|
||||
this.dimGroup.children.splice(i, i + 2).forEach(
|
||||
e => {
|
||||
if (e.label) e.label.remove()
|
||||
e.geometry.dispose()
|
||||
e.material.dispose()
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import * as THREE from '../node_modules/three/src/Three';
|
||||
import { color } from './shared'
|
||||
export function extrude(sketch, depth) {
|
||||
console.log(sketch, 'here')
|
||||
|
||||
let constraints = sketch.constraints;
|
||||
let linkedObjs = sketch.linkedObjs;
|
||||
|
@ -9,63 +8,70 @@ export function extrude(sketch, depth) {
|
|||
let objIdx = sketch.objIdx;
|
||||
let visited = new Set()
|
||||
let v2s = []
|
||||
let offSetPts = []
|
||||
|
||||
|
||||
|
||||
function findPair(node) {
|
||||
console.log(node.name,'xx')
|
||||
if (node.userData.construction) return;
|
||||
visited.add(node)
|
||||
let linkedObj = linkedObjs.get(node.userData.l_id)
|
||||
let arr;
|
||||
|
||||
let lineNode
|
||||
if (linkedObj[0] == 'line') {
|
||||
arr = children[objIdx.get(linkedObj[1][2])].geometry.attributes.position.array
|
||||
lineNode = linkedObj[1][2]
|
||||
} else if (linkedObj[0] == 'arc') {
|
||||
arr = children[objIdx.get(linkedObj[1][3])].geometry.attributes.position.array
|
||||
lineNode = linkedObj[1][3]
|
||||
}
|
||||
|
||||
arr = children[objIdx.get(lineNode)].geometry.attributes.position.array
|
||||
let nextIdx
|
||||
if (linkedObj[1][0] == node.name) {
|
||||
nextIdx = 1
|
||||
for (let i = 0; i < arr.length; i += 3) {
|
||||
v2s.push(new THREE.Vector2(arr[i], arr[i + 1]))
|
||||
}
|
||||
} else {
|
||||
nextIdx = 0
|
||||
for (let i = arr.length - 3; i >= 0; i -= 3) {
|
||||
v2s.push(new THREE.Vector2(arr[i], arr[i + 1]))
|
||||
}
|
||||
}
|
||||
|
||||
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[
|
||||
objIdx.get(
|
||||
linkedObj[1][i]
|
||||
linkedObj[1][nextIdx]
|
||||
)
|
||||
]
|
||||
if (d == -1 || d == node) continue;
|
||||
if (d == children[4]) {
|
||||
if (d == children[2]) {
|
||||
console.log('pair found')
|
||||
};
|
||||
findTouching(d)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function findTouching(node) {
|
||||
console.log(node.name,'yy')
|
||||
for (let t of node.userData.constraints) {
|
||||
console.log(constraints.get(t)[2],node.name )
|
||||
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)]
|
||||
if (d == node) continue;
|
||||
if (d == children[4]) {
|
||||
if (d == children[2]) {
|
||||
console.log('loop found')
|
||||
} else {
|
||||
if (!visited.has(d)) {
|
||||
// if (!visited.has(d)) {
|
||||
findPair(d)
|
||||
}
|
||||
// }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
findPair(children[4]) //??? need fixing
|
||||
findPair(children[2]) //??? need fixing
|
||||
|
||||
const shape = new THREE.Shape(v2s);
|
||||
// const extrudeSettings = { depth: Math.abs(depth), bevelEnabled: false };
|
||||
|
@ -74,29 +80,29 @@ export function extrude(sketch, depth) {
|
|||
|
||||
const geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings);
|
||||
|
||||
// const material = new THREE.MeshLambertMaterial({
|
||||
// const material = new THREE.MeshPhongMaterial({
|
||||
// color: color.mesh,
|
||||
// emissive: color.emissive,
|
||||
// });
|
||||
const material = new THREE.MeshPhongMaterial({
|
||||
color: color.mesh,
|
||||
emissive: color.emissive,
|
||||
// wireframe:true
|
||||
});
|
||||
|
||||
// const mesh = new THREE.Mesh(geometry, material)
|
||||
const mesh = new THREE.Mesh(geometry, material)
|
||||
|
||||
// const material = new THREE.MeshPhongMaterial({
|
||||
// color: color.mesh,
|
||||
// });
|
||||
// const wireframe = new THREE.EdgesGeometry( geometry );
|
||||
|
||||
// const wireframe = new THREE.WireframeGeometry( geometry );
|
||||
// const mesh = new THREE.LineSegments( wireframe );
|
||||
// // mesh.material.depthTest = false;
|
||||
// // mesh.material.opacity = 0.25;
|
||||
// // mesh.material.transparent = true;
|
||||
// mesh.material.transparent = false;
|
||||
// mesh.material.depthTest = true;
|
||||
// mesh.material.opacity = 0.8;
|
||||
// mesh.material.transparent = true;
|
||||
|
||||
const edges = new THREE.EdgesGeometry( geometry, 15 );
|
||||
edges.type = 'BufferGeometry'
|
||||
edges.parameters = undefined
|
||||
// const edges = new THREE.EdgesGeometry( geometry, 15 );
|
||||
// edges.type = 'BufferGeometry'
|
||||
// edges.parameters = undefined
|
||||
|
||||
const mesh = new THREE.LineSegments( edges, new THREE.LineBasicMaterial( { color: 0x000000 } ) );
|
||||
// const mesh = new THREE.LineSegments( edges, new THREE.LineBasicMaterial( { color: 0x000000 } ) );
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -105,16 +105,16 @@ int solver(int nPts, float *p_ptr, int nConst, float *c_ptr, int nLinks, float *
|
|||
l_ptr += 4;
|
||||
}
|
||||
|
||||
int c_id = 1;
|
||||
int c_pre = 1;
|
||||
sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
|
||||
c_id++, 2,
|
||||
c_pre++, 2,
|
||||
SLVS_C_POINTS_COINCIDENT,
|
||||
200,
|
||||
-1,
|
||||
101, geomStartIdx, -1, -1);
|
||||
|
||||
// it's 2 + nConst because c_id at this point is 2
|
||||
for (; c_id < 2 + nConst; c_id++, c_ptr += 6)
|
||||
|
||||
for (int c_id=c_pre; c_id < c_pre + nConst; c_id++, c_ptr += 6)
|
||||
{
|
||||
sys.constraint[sys.constraints++] = Slvs_MakeConstraint(
|
||||
c_id, g,
|
||||
|
|
Loading…
Reference in New Issue