fix basic extrude
parent
0ae39d196a
commit
51f53bf752
15
src/Scene.js
15
src/Scene.js
|
@ -72,6 +72,8 @@ export class Scene {
|
||||||
freePt.material.size=8
|
freePt.material.size=8
|
||||||
freePt.visible = false
|
freePt.visible = false
|
||||||
freePt.depthTest = false
|
freePt.depthTest = false
|
||||||
|
freePt.userData.type = 'point'
|
||||||
|
|
||||||
helpersGroup.add(freePt);
|
helpersGroup.add(freePt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,14 +213,16 @@ export class Scene {
|
||||||
for (let x = 0; x < this.selected.length; x++) {
|
for (let x = 0; x < this.selected.length; x++) {
|
||||||
const obj = this.selected[x]
|
const obj = this.selected[x]
|
||||||
obj.material.color.set(color[obj.userData.type])
|
obj.material.color.set(color[obj.userData.type])
|
||||||
|
if (obj.userData.type == 'point') obj.visible = false
|
||||||
}
|
}
|
||||||
|
this.selected = []
|
||||||
|
|
||||||
for (let x = 0; x < this.hovered.length; x++) {
|
for (let x = 0; x < this.hovered.length; x++) {
|
||||||
const obj = this.selected[x]
|
const obj = this.selected[x]
|
||||||
obj.material.color.set(color[obj.userData.type])
|
obj.material.color.set(color[obj.userData.type])
|
||||||
}
|
}
|
||||||
|
|
||||||
this.obj3d.dispatchEvent({ type: 'change' })
|
this.obj3d.dispatchEvent({ type: 'change' })
|
||||||
this.selected = []
|
|
||||||
console.log('fireed')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,10 +230,8 @@ export class Scene {
|
||||||
subtract (m1, m2) {
|
subtract (m1, m2) {
|
||||||
let bspA = CSG.fromMesh(m1)
|
let bspA = CSG.fromMesh(m1)
|
||||||
let bspB = CSG.fromMesh(m2)
|
let bspB = CSG.fromMesh(m2)
|
||||||
m1.traverse(e=>e.layers.disable(0))
|
m1.traverse(e=>e.layers.disableAll())
|
||||||
m2.traverse(e=>e.layers.disable(0))
|
m2.traverse(e=>e.layers.disableAll())
|
||||||
// m1.visible = false
|
|
||||||
// m2.visible = false
|
|
||||||
|
|
||||||
// // Subtract one bsp from the other via .subtract... other supported modes are .union and .intersect
|
// // Subtract one bsp from the other via .subtract... other supported modes are .union and .intersect
|
||||||
|
|
||||||
|
@ -240,6 +242,7 @@ export class Scene {
|
||||||
let mesh = CSG.toMesh(bspResult, m1.matrix, m1.material)
|
let mesh = CSG.toMesh(bspResult, m1.matrix, m1.material)
|
||||||
mesh.userData.type = 'mesh'
|
mesh.userData.type = 'mesh'
|
||||||
mesh.name = `${m1.name}-${m2.name}`
|
mesh.name = `${m1.name}-${m2.name}`
|
||||||
|
mesh.layers.enable(1)
|
||||||
|
|
||||||
const edges = new THREE.EdgesGeometry( mesh.geometry, 15 );
|
const edges = new THREE.EdgesGeometry( mesh.geometry, 15 );
|
||||||
edges.type = 'BufferGeometry'
|
edges.type = 'BufferGeometry'
|
||||||
|
|
|
@ -18,6 +18,7 @@ export function onHover(e) {
|
||||||
let hoverPts;
|
let hoverPts;
|
||||||
|
|
||||||
if (this.obj3d.userData.type != 'sketch') {
|
if (this.obj3d.userData.type != 'sketch') {
|
||||||
|
this.obj3d.children[0].children[0].visible = false
|
||||||
raycaster.layers.set(1)
|
raycaster.layers.set(1)
|
||||||
hoverPts = raycaster.intersectObjects(this.obj3d.children, true)
|
hoverPts = raycaster.intersectObjects(this.obj3d.children, true)
|
||||||
} else {
|
} else {
|
||||||
|
@ -49,8 +50,10 @@ export function onHover(e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (idx.length) { // after filtering, if hovered objs still exists
|
if (idx.length) { // after filtering, if hovered objs still exists
|
||||||
|
|
||||||
|
console.log(hoverPts)
|
||||||
if (hoverPts[idx[0]].object != this.hovered[0]) { // if the previous hovered obj is not the same as current
|
if (hoverPts[idx[0]].object != this.hovered[0]) { // if the previous hovered obj is not the same as current
|
||||||
|
|
||||||
for (let x = 0; x < this.hovered.length; x++) { // first clear old hovers that are not selected
|
for (let x = 0; x < this.hovered.length; x++) { // first clear old hovers that are not selected
|
||||||
|
@ -58,16 +61,11 @@ export function onHover(e) {
|
||||||
if (!this.selected.includes(obj)) {
|
if (!this.selected.includes(obj)) {
|
||||||
if (typeof obj == 'object') {
|
if (typeof obj == 'object') {
|
||||||
obj.material.color.set(color[obj.userData.type])
|
obj.material.color.set(color[obj.userData.type])
|
||||||
|
|
||||||
if (this.obj3d.userData.type != 'sketch') {
|
if (this.obj3d.userData.type != 'sketch') {
|
||||||
if (obj.userData.type == 'mesh') {
|
if (obj.userData.type == 'mesh') {
|
||||||
obj.children[0].material.color.set(color['line'])
|
obj.children[0].material.color.set(color['line'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
// this.obj3d.children[0].children[this.fptObj[obj]].visible = false
|
|
||||||
this.obj3d.children[0].children[0].visible = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,9 +125,6 @@ export function onHover(e) {
|
||||||
obj.children[0].material.color.set(color['line'])
|
obj.children[0].material.color.set(color['line'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// this.obj3d.children[0].children[this.fptObj[obj]].visible = false
|
|
||||||
this.obj3d.children[0].children[0].visible = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,11 +143,12 @@ export function onPick(e) {
|
||||||
if (this.mode || e.buttons != 1) return
|
if (this.mode || e.buttons != 1) return
|
||||||
|
|
||||||
if (this.hovered.length) {
|
if (this.hovered.length) {
|
||||||
const obj = this.hovered[this.hovered.length - 1]
|
let obj = this.hovered[this.hovered.length - 1]
|
||||||
|
|
||||||
this.selected.push(this.hovered[this.hovered.length - 1])
|
|
||||||
|
|
||||||
if (this.obj3d.userData.type != 'sketch') {
|
if (this.obj3d.userData.type == 'sketch') {
|
||||||
|
this.selected.push(obj)
|
||||||
|
} else {
|
||||||
if (typeof obj == 'object') {
|
if (typeof obj == 'object') {
|
||||||
if (obj.userData.type == "mesh") {
|
if (obj.userData.type == "mesh") {
|
||||||
obj.material.color.set(hoverColor[obj.userData.type])
|
obj.material.color.set(hoverColor[obj.userData.type])
|
||||||
|
@ -166,52 +162,53 @@ export function onPick(e) {
|
||||||
pp.geometry.attributes.position.needsUpdate = true
|
pp.geometry.attributes.position.needsUpdate = true
|
||||||
pp.visible = true
|
pp.visible = true
|
||||||
|
|
||||||
|
obj = pp
|
||||||
this.fptObj[obj] = this.fptIdx
|
this.fptObj[obj] = this.fptIdx
|
||||||
this.fptIdx++
|
this.fptIdx++
|
||||||
}
|
}
|
||||||
|
this.obj3d.dispatchEvent({ type: 'change' })
|
||||||
|
this.selected.push(obj)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof this.hovered[0] == 'object') {
|
switch (obj.userData.type) {
|
||||||
switch (this.hovered[0].userData.type) {
|
case 'dimension':
|
||||||
case 'dimension':
|
const idx = this.obj3d.children[1].children.indexOf(this.hovered[0])
|
||||||
const idx = this.obj3d.children[1].children.indexOf(this.hovered[0])
|
if (idx % 2) {
|
||||||
if (idx % 2) {
|
|
||||||
|
|
||||||
this.onDragDim = this._onMoveDimension(
|
this.onDragDim = this._onMoveDimension(
|
||||||
this.obj3d.children[1].children[idx],
|
this.obj3d.children[1].children[idx],
|
||||||
this.obj3d.children[1].children[idx - 1],
|
this.obj3d.children[1].children[idx - 1],
|
||||||
)
|
)
|
||||||
this.canvas.addEventListener('pointermove', this.onDragDim);
|
this.canvas.addEventListener('pointermove', this.onDragDim);
|
||||||
this.canvas.addEventListener('pointerup', this.onRelease)
|
|
||||||
}
|
|
||||||
|
|
||||||
draggedLabel = this.obj3d.children[1].children[idx].label
|
|
||||||
draggedLabel.style.zIndex = -1;
|
|
||||||
break;
|
|
||||||
case 'point':
|
|
||||||
|
|
||||||
this.canvas.addEventListener('pointermove', this.onDrag);
|
|
||||||
this.canvas.addEventListener('pointerup', this.onRelease)
|
this.canvas.addEventListener('pointerup', this.onRelease)
|
||||||
break;
|
}
|
||||||
|
|
||||||
default:
|
draggedLabel = this.obj3d.children[1].children[idx].label
|
||||||
break;
|
draggedLabel.style.zIndex = -1;
|
||||||
}
|
break;
|
||||||
|
case 'point':
|
||||||
|
|
||||||
|
this.canvas.addEventListener('pointermove', this.onDrag);
|
||||||
|
this.canvas.addEventListener('pointerup', this.onRelease)
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (let x = 0; x < this.selected.length; x++) {
|
for (let x = 0; x < this.selected.length; x++) {
|
||||||
const obj = this.selected[x]
|
const obj = this.selected[x]
|
||||||
if (typeof obj == 'object') {
|
obj.material.color.set(color[obj.userData.type])
|
||||||
obj.material.color.set(color[obj.userData.type])
|
if (this.obj3d.userData.type != 'sketch') {
|
||||||
if (this.obj3d.userData.type != 'sketch' && obj.userData.type == 'mesh') {
|
if (obj.userData.type == 'mesh') {
|
||||||
obj.children[0].material.color.set(color['line'])
|
obj.children[0].material.color.set(color['line'])
|
||||||
|
} else if (obj.userData.type == 'point') {
|
||||||
|
obj.visible = false
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.obj3d.children[0].children[this.fptObj[obj] + 1].visible = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.obj3d.children[0].children[0].visible = false
|
|
||||||
this.obj3d.dispatchEvent({ type: 'change' })
|
this.obj3d.dispatchEvent({ type: 'change' })
|
||||||
this.selected = []
|
this.selected = []
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,11 @@ export class DepTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
deleteNode(id) {
|
|
||||||
|
getDescendents(id) {
|
||||||
const dfs = (id) => {
|
const dfs = (id) => {
|
||||||
visited.add(id)
|
visited.add(id)
|
||||||
nodesToDel.push(id)
|
desc.push(id)
|
||||||
for (let k in this.tree[id]) {
|
for (let k in this.tree[id]) {
|
||||||
if (!visited.has(k)) {
|
if (!visited.has(k)) {
|
||||||
dfs(k)
|
dfs(k)
|
||||||
|
@ -45,10 +46,20 @@ export class DepTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
const visited = new Set()
|
const visited = new Set()
|
||||||
|
const desc = []
|
||||||
|
|
||||||
const nodesToDel = []
|
|
||||||
dfs(id)
|
dfs(id)
|
||||||
|
|
||||||
|
return desc
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
deleteNode(id) {
|
||||||
|
|
||||||
|
|
||||||
|
const nodesToDel = this.getDescendents(id)
|
||||||
|
|
||||||
nodesToDel.sort((a, b) => this.order[b] - this.order[a])
|
nodesToDel.sort((a, b) => this.order[b] - this.order[a])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,6 @@ export const ToolTip = () => {
|
||||||
|
|
||||||
|
|
||||||
function getTextWidth(text, font = "16px sans-serif") {
|
function getTextWidth(text, font = "16px sans-serif") {
|
||||||
console.log(text)
|
|
||||||
// https://stackoverflow.com/a/21015393
|
// https://stackoverflow.com/a/21015393
|
||||||
// re-use canvas object for better performance
|
// re-use canvas object for better performance
|
||||||
let canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
|
let canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
|
||||||
|
|
|
@ -46,12 +46,13 @@ const TreeEntry = ({ entId }) => {
|
||||||
const [_, forceUpdate] = useReducer(x => x + 1, 0);
|
const [_, forceUpdate] = useReducer(x => x + 1, 0);
|
||||||
|
|
||||||
// const vis = obj3d.visible
|
// const vis = obj3d.visible
|
||||||
const vis = obj3d.layers.mask&1
|
const vis = obj3d.layers.mask & 1
|
||||||
|
|
||||||
return <div className='btn-light select-none flex justify-start w-full h-7 items-center text-sm'
|
return <div className='btn-light select-none flex justify-start w-full h-7 items-center text-sm'
|
||||||
|
|
||||||
onDoubleClick={() => {
|
onDoubleClick={() => {
|
||||||
activeSketchId && treeEntries[activeSketchId].deactivate()
|
activeSketchId && treeEntries[activeSketchId].deactivate()
|
||||||
|
console.log(entry)
|
||||||
entry.activate()
|
entry.activate()
|
||||||
sc.clearSelection()
|
sc.clearSelection()
|
||||||
sc.activeSketch = entry;
|
sc.activeSketch = entry;
|
||||||
|
@ -95,7 +96,7 @@ const TreeEntry = ({ entId }) => {
|
||||||
vis ?
|
vis ?
|
||||||
<MdVisibility className='btn-green h-full w-auto p-1.5'
|
<MdVisibility className='btn-green h-full w-auto p-1.5'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
obj3d.traverse((e)=>e.layers.disable(0))
|
obj3d.traverse((e) => e.layers.disableAll())
|
||||||
sc.render()
|
sc.render()
|
||||||
forceUpdate()
|
forceUpdate()
|
||||||
}}
|
}}
|
||||||
|
@ -103,7 +104,15 @@ const TreeEntry = ({ entId }) => {
|
||||||
:
|
:
|
||||||
<MdVisibilityOff className='btn-green h-full w-auto p-1.5'
|
<MdVisibilityOff className='btn-green h-full w-auto p-1.5'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
obj3d.traverse((e)=>e.layers.enable(0))
|
if (obj3d.userData.type == 'sketch') {
|
||||||
|
obj3d.traverse((e) => e.layers.enable(0))
|
||||||
|
} else {
|
||||||
|
obj3d.traverse((e) => {
|
||||||
|
e.layers.enable(0)
|
||||||
|
e.layers.enable(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
sc.render()
|
sc.render()
|
||||||
forceUpdate()
|
forceUpdate()
|
||||||
}}
|
}}
|
||||||
|
|
48
todo.txt
48
todo.txt
|
@ -1,42 +1,38 @@
|
||||||
fix css on design tree (a lot of work) \
|
fix css on design tree (a lot of work) \\ done
|
||||||
clear dim on exit exit sketch / rehydrate when back or after loading \\\ done
|
clear dim on exit exit sketch / rehydrate when back or after loading \\\ done
|
||||||
|
|
||||||
dimension to origin // done
|
dimension to origin // done
|
||||||
|
|
||||||
|
- need to auto hide ( consume) when new boolean created \\ done
|
||||||
- select sketch for extrusion
|
|
||||||
reattaching sketch
|
|
||||||
- need to auto hide ( consume) when new boolean created \\
|
|
||||||
- sensible default names, like extrude 1, sketch 1, leverage react for this
|
- sensible default names, like extrude 1, sketch 1, leverage react for this
|
||||||
|
|
||||||
|
|
||||||
boolean flesh out refresh / replace mesh / delete mesh
|
boolean flesh out refresh / replace mesh
|
||||||
|
- / delete mesh \\ done
|
||||||
- create derived part using relationship as name \\ done
|
- create derived part using relationship as name \\ done
|
||||||
- hidden bodies messes up hover highlight \\ fixed
|
- hidden bodies messes up hover highlight \\ fixed
|
||||||
- add for union and intersect
|
- add for union and intersect
|
||||||
- auto update
|
- consume skeches after extrude // done
|
||||||
|
|
||||||
- consume skeches after extrude
|
|
||||||
|
|
||||||
extrude edit dialog. directio and magnitude
|
vertical // done
|
||||||
|
horizontal // done
|
||||||
fix extrusion loop find
|
|
||||||
|
|
||||||
file save
|
|
||||||
stl export
|
|
||||||
|
|
||||||
angle
|
|
||||||
other constraints / sprite
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tangent
|
- select sketch for extrusion
|
||||||
vertical
|
- boolean unable to select click
|
||||||
horizontal
|
|
||||||
angle
|
auto update extrude
|
||||||
|
extrude dialogue
|
||||||
|
|
||||||
|
loopfind
|
||||||
|
button panel cleanup
|
||||||
|
file save, stl export
|
||||||
|
|
||||||
|
constriant buttons ,tangent, angle
|
||||||
|
|
||||||
|
|
||||||
|
constraint labels
|
||||||
|
reattach sketch
|
||||||
|
auto snap
|
||||||
finish mode messed up after restore
|
tree ent renaming and better default names
|
Loading…
Reference in New Issue