add missing sketch module, remove logic
This commit is contained in:
parent
32e57fd00e
commit
aae60f1b05
2 changed files with 91 additions and 1 deletions
|
|
@ -36,7 +36,6 @@
|
|||
"earcut": "^2.2.3",
|
||||
"express-useragent": "^1.0.13",
|
||||
"jszip": "^3.7.1",
|
||||
"logicjs": "^1.0.0",
|
||||
"manifold-3d": "^2.5.1",
|
||||
"moment": "^2.29.4",
|
||||
"serve-static": "^1.14.1",
|
||||
|
|
|
|||
91
src/mesh/sketch.js
Normal file
91
src/mesh/sketch.js
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||
|
||||
"use strict";
|
||||
|
||||
// dep: add.array
|
||||
// dep: add.three
|
||||
// dep: moto.license
|
||||
// dep: moto.client
|
||||
// dep: mesh.object
|
||||
// use: mesh.api
|
||||
// use: mesh.util
|
||||
// use: mesh.group
|
||||
gapp.register("mesh.sketch", [], (root, exports) => {
|
||||
|
||||
const { MeshBasicMaterial, LineBasicMaterial, LineSegments, DoubleSide } = THREE;
|
||||
const { PlaneGeometry, EdgesGeometry, SphereGeometry, Group, Mesh } = THREE;
|
||||
const { mesh, moto } = root;
|
||||
const { space } = moto;
|
||||
|
||||
const mapp = mesh;
|
||||
const worker = moto.client.fn;
|
||||
|
||||
const material = {
|
||||
plane: new MeshBasicMaterial({ color: 0x888888, side: DoubleSide, transparent: true, opacity: 0.25 }),
|
||||
outline: new LineBasicMaterial({ color: 0x88dddd, side: DoubleSide, transparent: true, opacity: 0.25 }),
|
||||
handle: new MeshBasicMaterial({ color: 0x88dddd, side: DoubleSide, transparent: true, opacity: 0.25 }),
|
||||
highlight: new LineBasicMaterial({ color: 0x88ffdd, side: DoubleSide, transparent: true, opacity: 0.5 }),
|
||||
selected: new MeshBasicMaterial({ color: 0x88aa88, side: DoubleSide, transparent: true, opacity: 0.25 }),
|
||||
};
|
||||
|
||||
/** 2D plane containing open and closed polygons which can be extruded **/
|
||||
mesh.sketch = class MeshSketch extends mesh.object {
|
||||
constructor(model, face, id) {
|
||||
super(id);
|
||||
|
||||
const planeGeometry = new PlaneGeometry(10, 10);
|
||||
const planeMaterial = material.plane;
|
||||
const plane = this.plane = new Mesh(planeGeometry, planeMaterial);
|
||||
|
||||
const outlineGeometry = new EdgesGeometry(planeGeometry);
|
||||
const outlineMaterial = material.outline;
|
||||
const outline = this.outline = new LineSegments(outlineGeometry, outlineMaterial);
|
||||
plane.add(outline);
|
||||
|
||||
const handleGeometry = new SphereGeometry(0.2, 16, 16);
|
||||
const handleMaterial = material.handle;
|
||||
|
||||
const handles = [];
|
||||
const corners = [ [-5, 5, 0], [5, 5, 0], [-5, -5, 0], [5, -5, 0] ];
|
||||
|
||||
for (let corner of corners) {
|
||||
const handle = new Mesh(handleGeometry, handleMaterial);
|
||||
handle.position.set(...corner);
|
||||
plane.add(handle);
|
||||
handles.push(handle);
|
||||
}
|
||||
}
|
||||
|
||||
get type() {
|
||||
return "sketch";
|
||||
}
|
||||
|
||||
get object() {
|
||||
return this.plane;
|
||||
}
|
||||
|
||||
rename(newname) {
|
||||
this.file = newname;
|
||||
}
|
||||
|
||||
highlight() {
|
||||
this.outline.material = material.highlight;
|
||||
}
|
||||
|
||||
unhighlight() {
|
||||
this.outline.material = material.outline;
|
||||
}
|
||||
|
||||
select(bool) {
|
||||
if (bool === undefined) {
|
||||
return this.plane.material === material.selected;
|
||||
}
|
||||
if (bool.toggle) {
|
||||
return this.select(!this.select());
|
||||
}
|
||||
return this.plane.material = (bool ? material.selected : material.plane);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue