Public
Edited
Dec 14, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fAxesDim = 3
Insert cell
thickness = 2.0
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
toolDiameter = 0.125
Insert cell
minDepth = 0.25
Insert cell
maxToolDepth = 1
Insert cell
Insert cell
baseThickness = thickness - maxToolDepth
Insert cell
Insert cell
stepover = 0.65
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
xBreadth = 1
Insert cell
Insert cell
function makeMeshWithFunc(func) {
let material = new THREE.MeshPhongMaterial({
color: 0xff0000,
side: THREE.DoubleSide,
transparent: true,
opacity: 0.85
});
let geom = new ParametricGeometry(func, 120, 120, false);
let mesh = new THREE.Mesh(geom, material);
mesh.rotateY(Math.PI);
invalidation.then((_) => {
geom.dispose();
material.dispose();
});
return mesh;
}
Insert cell
function gpWithOrigin(xOrigin, zOrigin) {
function goldsteinPrice(u, v, optionalTarget) {
const eps = 0.000001;
var result = optionalTarget || new THREE.Vector3();
var xOrig = u * fAxesDim;
var zOrig = v * fAxesDim;
let x = (u - xBreadth / 2 - xOrigin) * xBreadth;
let z = (v - zBreadth / 2 - zOrigin) * zBreadth;
let y =
(1 +
(x + z + 1) ** 2 *
(19 - 14 * x + 3 * x ** 2 - 14 * z + 6 * x * z + 3 * z ** 2)) *
(30 +
(2 * x - 3 * z) ** 2 *
(18 - 32 * x + 12 * x ** 2 + 48 * z - 36 * x * z + 27 * z ** 2));

y = -Math.log10(y);
y = y / division;
y = y + yOffset;
//x = x + xOffset;
//z = z + zOffset;

// Major scaledown
if (clipFn) {
if (y < minDepth) {
y = minDepth;
} else if (y > maxToolDepth) {
y = maxToolDepth;
}
}

return result.set(xOrig, y, zOrig);
}
return goldsteinPrice;
}
Insert cell
meshGrid = {
let spaceOffset = fAxesDim + 0.5;
let meshes = [-1, 0, 1]
.map((xOrig) => {
return [0, 1, 2].map((zOrig) => {
let f = gpWithOrigin(xOrig, zOrig);
let mesh = makeMeshWithFunc(f);
mesh.position.set(xOrig * spaceOffset, 0, zOrig * spaceOffset);
return mesh;
});
})
.flat();
let tests = meshes.map((m) => {
m.geometry.computeBoundingBox;
let idk = m.position;
return idk;
});
mutable test = tests;
let group = new THREE.Group();
meshes.forEach((m) => group.add(m));
return group;
}
Insert cell
gridGpFunctions = {
return [-1, 0, 1]
.map((xOrig) => {
return [0, 1, 2].map((zOrig) => {
let f = gpWithOrigin(xOrig, zOrig);
return f;
});
})
.flat();
}
Insert cell
currGridFunc = gridGpFunctions[meshGridIndex]
Insert cell
// Uncomment if you want to render intermediate steps to the space
{
if (renderSurfaceMeshes) {
fVizSpace.scene.add(meshGrid);
fVizSpace.threeRenderScene();
invalidation.then((_) => {
fVizSpace.scene.remove(meshGrid);
fVizSpace.threeRenderScene();
});
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable test = 0
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
gp2Points = {
var n = 256,
m = 256,
values = new Array(n * m);
for (var j = 0.5, k = 0; j < m; ++j) {
for (var i = 0.5; i < n; ++i, ++k) {
values[k] = goldsteinPrice((i / n) * 4 - 2, 1 - (j / m) * 3);
}
}
return values;
}
Insert cell
contours = d3
.contours()
.size([256, 256])
.thresholds(Array.from({ length: 19 }, (_, i) => Math.pow(2, i + 2)))(
gp2Points
)
Insert cell
Insert cell
Insert cell
import {
serverUrl,
socket,
latestMessage,
toggleSocketButton,
availableEndMills,
invalidEndMillsForMaterial,
setMachineStateParameter,
sendRegionDims,
sendThickness,
sbpButton,
sendInstsToOverlay,
sendParamsToOverlay,
feedSpeedTable,
generateChecklist
// VisualizationSpace,
// VisualizationInterpreters
} from "@jtranoleary/woodgrain-authoring"
Insert cell
socket
Insert cell
toggleSocketButton
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more