clean up directory

master
howard 2021-04-10 16:50:12 -07:00
parent 9dccacdba9
commit 606e83e2d6
13 changed files with 13 additions and 521 deletions

View File

@ -2,11 +2,10 @@
import * as THREE from '../node_modules/three/src/Three';
import { TrackballControls } from './trackball'
import { TrackballControls } from '../lib/trackball'
import { Sketch } from './Sketch'
import Stats from './stats.module.js';
import Stats from '../lib/stats.module.js';
import { add3DPoint } from './datums'
import { extrude } from './extrude'
import { onHover, onPick } from './mouseEvents';
import { _vec2, _vec3, color, awaitSelection, ptObj } from './shared'
@ -14,7 +13,7 @@ import { _vec2, _vec3, color, awaitSelection, ptObj } from './shared'
import { AxesHelper } from './axes'
import CSG from "./three-csg.js"
import CSG from "../lib/three-csg"
const eq = (a1, a2) => {
@ -116,10 +115,10 @@ export class Scene {
const dist = 50
const light1 = new THREE.PointLight(color.lighting, 0.7);
light1.position.set(dist, dist, dist);
this.obj3d.add(light1);
helpersGroup.add(light1);
const light2 = new THREE.PointLight(color.lighting, 0.6);
light2.position.set(-dist, -dist, -dist);
this.obj3d.add(light2);
helpersGroup.add(light2);
this.render = render.bind(this);

View File

@ -1,74 +0,0 @@
import * as THREE from '../node_modules/three/src/Three';
export function add3DPoint(e) {
// const mouse = new THREE.Vector2(
// (e.clientX / window.innerWidth) * 2 - 1,
// - (e.clientY / window.innerHeight) * 2 + 1
// )
// console.log(new THREE.Vector3(mouse.x, mouse.y, 0).unproject(this.camera))
// this.raycaster.ray.intersectPlane(this.plane, this.target).applyMatrix4(this.inverse)
this.raycaster.setFromCamera(
new THREE.Vector2(
(e.clientX / window.innerWidth) * 2 - 1,
- (e.clientY / window.innerHeight) * 2 + 1
),
this.camera
);
// const hoverPts = this.raycaster.intersectObjects(this.sketch.children)
const hoverPts = this.raycaster.intersectObjects(this.sketch.children)
console.log(hoverPts)
let idx = []
if (hoverPts.length) {
let minDist = Infinity;
for (let i = 0; i < hoverPts.length; i++) {
if (!hoverPts[i].distanceToRay) continue;
if (hoverPts[i].distanceToRay < minDist) {
minDist = hoverPts[i].distanceToRay
idx = [i]
} else if (hoverPts[i].distanceToRay == minDist) {
idx.push(i)
}
}
if (!idx.length) idx.push(0)
}
if (idx.length) {
if (hoverPts[idx[0]].object != this.hovered[0]) {
for (let ob of this.hovered) {
if (ob && !this.selected.includes(ob)) {
ob.material.color.set(0x555555)
}
}
this.hovered = []
for (let i of idx) {
hoverPts[i].object.material.color.set(0x00FFFF)
this.hovered.push(hoverPts[i].object)
}
// console.log('render1')
this.render()
}
} else {
if (this.hovered.length) {
for (let ob of this.hovered) {
if (ob && !this.selected.includes(ob)) {
ob.material.color.set(0x555555)
}
}
this.hovered = []
// console.log('render2')
this.render()
}
}
}

View File

@ -70,12 +70,6 @@ export function extrude(sketch) {
const extrudeSettings = { depth: 8, bevelEnabled: false };
const geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings);
@ -85,24 +79,24 @@ export function extrude(sketch) {
emissive: color.emissive,
// flatShading:true,
});
const mesh = new THREE.Mesh(geometry, material)
mesh.name = 'm' + id++
mesh.userData.type = 'mesh'
mesh.layers.enable(1)
const vertices = new THREE.Points( mesh.geometry, new THREE.PointsMaterial() );
const vertices = new THREE.Points(mesh.geometry, new THREE.PointsMaterial({ size: 0 }));
vertices.userData.type = 'point'
vertices.layers.disable(0)
vertices.layers.enable(1)
mesh.add(vertices)
mesh.matrixAutoUpdate = false;
mesh.matrix.multiply(sketch.obj3d.matrix)
this.obj3d.add(mesh)
this.render()
// sketch.visible = false
this.store.dispatch({ type: 'rx-extrusion', mesh, sketchId: sketch.obj3d.name })
}

View File

@ -1,276 +0,0 @@
import * as React from "react";
function Arc(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
viewBox="0 0 16 16"
{...props}
>
<g stroke="currentColor" strokeLinecap="round">
<path
d="M7.75 2.35a13 13 0 016.5 11.281"
fill="none"
strokeWidth={1.5}
/>
<path
fill="#fff"
d="M.75 12.631h2v2h-2zM6.75 1.35h2v2h-2zM13.25 12.631h2v2h-2z"
/>
</g>
</svg>
);
}
function Dimension(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
fill="currentColor"
className="prefix__bi prefix__bi-intersect"
viewBox="0 0 16 16"
{...props}
>
<defs>
<marker
id="prefix__a"
refX={0}
refY={0}
orient="auto"
overflow="visible"
>
<path
d="M-1.154 0l1.73-1v2l-1.73-1z"
fillRule="evenodd"
stroke="currentColor"
strokeWidth=".2pt"
fill="currentColor"
/>
</marker>
<marker
id="prefix__b"
refX={0}
refY={0}
orient="auto"
overflow="visible"
>
<path
d="M1.154 0l-1.73 1v-2l1.73 1z"
fillRule="evenodd"
stroke="currentColor"
strokeWidth=".2pt"
fill="currentColor"
/>
</marker>
</defs>
<path
d="M4.009 10.009l6-6"
fill="none"
stroke="currentColor"
strokeWidth={2}
markerStart="url(#prefix__a)"
markerEnd="url(#prefix__b)"
/>
<path
d="M15.485 4.516l-4-4M4.516 15.485l-4-4"
fill="none"
stroke="currentColor"
strokeWidth={0.893}
/>
</svg>
);
}
function Intersect(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
fill="currentColor"
className="prefix__bi prefix__bi-intersect"
viewBox="0 0 16 16"
{...props}
>
<path
d="M5.55 5.5c-.018.166-.05.329-.05.5 0 2.491 2.009 4.5 4.5 4.5.171 0 .334-.032.5-.05V6c0-.286-.214-.5-.5-.5z"
fill="currentColor"
fillOpacity={0.7}
/>
<rect
width={10}
height={10}
x={1}
y={5}
rx={1}
ry={1}
fill="none"
stroke="currentColor"
strokeWidth={1.5}
strokeLinecap="round"
/>
<circle
cx={10}
cy={6}
r={5}
fill="none"
stroke="currentColor"
strokeWidth={1.5}
strokeLinecap="round"
/>
</svg>
);
}
function Intersect_thin(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
fill="currentColor"
className="prefix__bi prefix__bi-intersect"
viewBox="0 0 16 16"
{...props}
>
<path
d="M5.11 5.092c-.02.195-.059.384-.059.584a5.244 5.244 0 005.254 5.253c.2 0 .39-.037.583-.059V5.676a.57.57 0 00-.583-.584z"
fill="currentColor"
fillOpacity={0.7}
/>
<rect
width={10}
height={10}
x={1}
y={5}
rx={1}
ry={1}
fill="none"
stroke="currentColor"
strokeWidth={0.4}
strokeLinecap="round"
/>
<circle
cx={10}
cy={6}
r={5}
fill="none"
stroke="currentColor"
strokeWidth={0.4}
strokeLinecap="round"
/>
</svg>
);
}
function Line(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
viewBox="0 0 16 16"
{...props}
>
<g stroke="currentColor">
<path d="M2 14l3-6h6l3-6" fill="none" strokeWidth={1.5} />
<path
fill="#fff"
strokeLinecap="round"
d="M1 13h2v2H1zM4 7h2v2H4zM10 7h2v2h-2zM13 1h2v2h-2z"
/>
</g>
</svg>
);
}
function Subtract(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
fill="currentColor"
className="prefix__bi prefix__bi-intersect"
viewBox="0 0 16 16"
{...props}
>
<path
d="M2 5.5c-.286 0-.5.214-.5.5v8c0 .286.214.5.5.5h8c.286 0 .5-.214.5-.5v-2.525a5.504 5.504 0 01-.5.025A5.508 5.508 0 014.5 6c0-.169.01-.335.025-.5z"
fill="currentColor"
fillOpacity={0.7}
/>
<rect
width={10}
height={10}
x={1}
y={5}
rx={1}
ry={1}
fill="none"
stroke="currentColor"
strokeWidth={1.5}
strokeLinecap="round"
/>
<circle
cx={10}
cy={6}
r={5}
fill="none"
stroke="currentColor"
strokeWidth={1.5}
strokeLinecap="round"
/>
</svg>
);
}
function Union(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
fill="currentColor"
className="prefix__bi prefix__bi-intersect"
viewBox="0 0 16 16"
{...props}
>
<path
d="M5.55 5.5c-.018.166-.05.329-.05.5 0 2.491 2.009 4.5 4.5 4.5.171 0 .334-.032.5-.05V6c0-.286-.214-.5-.5-.5z"
fill="currentColor"
fillOpacity={0.7}
/>
<path
d="M2 5.5c-.286 0-.5.214-.5.5v8c0 .286.214.5.5.5h8c.286 0 .5-.214.5-.5v-2.525a5.504 5.504 0 01-.5.025A5.508 5.508 0 014.5 6c0-.169.01-.335.025-.5zM10 1.5a4.477 4.477 0 00-4.225 3H10c.822 0 1.5.678 1.5 1.5v4.225A4.477 4.477 0 0014.5 6c0-2.491-2.009-4.5-4.5-4.5z"
fill="currentColor"
fillOpacity={0.7}
/>
<rect
width={10}
height={10}
x={1}
y={5}
rx={1}
ry={1}
fill="none"
stroke="currentColor"
strokeWidth={1.5}
strokeLinecap="round"
/>
<circle
cx={10}
cy={6}
r={5}
fill="none"
stroke="currentColor"
strokeWidth={1.5}
strokeLinecap="round"
/>
</svg>
);
}
export { Arc, Dimension, Intersect, Intersect_thin, Line, Subtract, Union };

View File

@ -18,7 +18,7 @@ export function onHover(e) {
let hoverPts;
if (this.obj3d.userData.type != 'sketch') {
this.obj3d.children[0].children[0].visible = false
this.obj3d.children[0].children[0].visible = false // hide selpoint[0] before each redraw
raycaster.layers.set(1)
hoverPts = raycaster.intersectObjects(this.obj3d.children, true)
} else {

View File

@ -1,70 +0,0 @@
// import { LineSegments } from '../objects/LineSegments.js';
// import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
// import { Float32BufferAttribute } from '../core/BufferAttribute.js';
// import { BufferGeometry } from '../core/BufferGeometry.js';
import * as THREE from '../node_modules/three/src/Three';
import {ArrowHelper} from './ArrowHelper'
class Patch extends THREE.Mesh {
constructor(s = 1) {
const positions = [
0.5, 0,
0.3, 0.06,
0.3, 0.01,
0.0, 0.01,
0.0, -0.01,
0.3, -0.01,
0.3, -0.06,
];
const shape = new THREE.Shape()
shape.moveTo(positions[0], positions[1])
for (let i = 2; i < positions.length; i += 2) {
shape.lineTo(positions[i], positions[i+1])
}
console.log(shape)
const geometry = new THREE.ShapeGeometry( shape );;
super(
geometry,
new MeshBasicMaterial({
color: 0x0000ff,
opacity: 0.2,
side: DoubleSide,
transparent: true,
depthWrite: false,
toneMapped: false
})
)
this.scale.set( 1, 1, 1 );
return this;
}
}
export { Patch };

View File

@ -49,7 +49,7 @@ body {
cursor: pointer;
@apply fill-current
bg-transparent text-gray-200
hover:bg-gray-600 hover:text-gray-200;
hover:bg-gray-500 hover:text-gray-200;
}
.btn-light {

View File

@ -69,7 +69,7 @@ export class DepTree {
this.allIds.splice(spliceIdx, 1)
const deletedObj = sc.obj3d.children.splice(spliceIdx + 4, 1)[0] // first 4 elements are non geom
const deletedObj = sc.obj3d.children.splice(spliceIdx + 1, 1)[0] // first 1 elements are non geom
deletedObj.traverse((obj)=>{
if (obj.geometry) obj.geometry.dispose()

View File

@ -1,81 +0,0 @@
const lines = [
DlineObj(), // 0:
DlineObj(), // 1:
DlineObj(), // 2:
DlineObj(), // 2:
]
const points = [
DptObj(), // 1: |
DptObj(), // 1: |
DptObj(), // 1: |
DptObj(), // 2: |
DptObj(), // 3: |
DptObj(), // 4: |
DptObj(), // 5: |
DptObj(), // 6: |
]
const updatePoint = this.obj3d.children.length
let prev = points[points.length - 1]
for (let i = 0, j = 0; i < points.length; i++) {
const cur = points[i]
if (i % 2 == 0) {
this.constraints.set(++this.c_id, //??? increment investigation
[
'points_coincident', -1,
[prev.name, cur.name, -1, -1]
]
)
cur.userData.constraints.push(this.c_id)
prev.userData.constraints.push(this.c_id)
} else {
const toPush = [prev, cur, lines[j]]
this.linkedObjs.set(this.l_id, ['line', toPush.map(e => e.name)])
for (let obj of toPush) {
obj.userData.l_id = this.l_id
}
this.l_id += 1
if (j > 0) {
this.constraints.set(++this.c_id, //???
[
'perpendicular', -1,
[-1, -1, lines[j - 1].name, lines[j].name]
]
)
lines[j - 1].userData.constraints.push(this.c_id)
lines[j].userData.constraints.push(this.c_id)
}
this.obj3d.add(...toPush)
j += 1
}
if (i >= 3 && i <= 6) {
points[i].geometry.attributes.position.set(p2.geometry.attributes.position.array)
} else {
points[i].geometry.attributes.position.set(p1.geometry.attributes.position.array)
}
prev = cur
}
this.constraints.set(++this.c_id, //??? increment investigation
[
'points_coincident', -1,
[p2.name, points[5].name, -1, -1]
]
)
points[5].userData.constraints.push(this.c_id)
p2.userData.constraints.push(this.c_id)
this.constraints.set(++this.c_id, //??? increment investigation
[
'points_coincident', -1,
[p1.name, points[0].name, -1, -1]
]
)
points[0].userData.constraints.push(this.c_id)
p1.userData.constraints.push(this.c_id)