diff --git a/zndraw/frame.py b/zndraw/frame.py index f793148cc..c0f68bb00 100644 --- a/zndraw/frame.py +++ b/zndraw/frame.py @@ -52,7 +52,9 @@ class Frame: """ positions: np.ndarray = None - cell: np.ndarray = dataclasses.field(default_factory=lambda: np.array([0.0, 0.0, 0.0])) + cell: np.ndarray = dataclasses.field( + default_factory=lambda: np.array([0.0, 0.0, 0.0]) + ) numbers: np.ndarray = None colors: np.ndarray = None radii: np.ndarray = None diff --git a/zndraw/static/World/components/draw.js b/zndraw/static/World/components/draw.js index d730233c7..2d8fc1f83 100644 --- a/zndraw/static/World/components/draw.js +++ b/zndraw/static/World/components/draw.js @@ -1,6 +1,5 @@ import * as THREE from "three"; - const findClosestPoint = (points, position) => { const closestPoint = new THREE.Vector3(); points.forEach((point) => { @@ -228,20 +227,22 @@ export class Line3D extends THREE.Group { }); this.virtualPoints.clear(); - + if (this.anchorPoints.children.length > 1) { // divide the number of points by the number of anchor points to get the points per segment - const pointsPerSegment = Math.ceil(points.length / (this.anchorPoints.children.length - 1)); - console.log("pointsPerSegment", pointsPerSegment) + const pointsPerSegment = Math.ceil( + points.length / (this.anchorPoints.children.length - 1), + ); + console.log("pointsPerSegment", pointsPerSegment); // place a sphere between two anchor points for (let i = 0; i < this.anchorPoints.children.length - 1; i++) { const sphere = new THREE.Mesh(geometry2, material2); sphere.index = i; - + const position = this.anchorPoints.children[i].position.clone(); position.lerp(this.anchorPoints.children[i + 1].position, 0.5); - + // find the closes point on the curve to the position // TODO: only search in the correct segment const closestPoint = findClosestPoint(points, position); diff --git a/zndraw/static/World/systems/select.js b/zndraw/static/World/systems/select.js index d6f7291ba..248f63c12 100644 --- a/zndraw/static/World/systems/select.js +++ b/zndraw/static/World/systems/select.js @@ -178,7 +178,10 @@ class Selection { if (virtualPointsIntersects.length > 0) { const position = virtualPointsIntersects[0].point.clone(); console.log(virtualPointsIntersects[0]); - this.line3D.pointer = this.line3D.addPoint(position, virtualPointsIntersects[0].object.index + 1); + this.line3D.pointer = this.line3D.addPoint( + position, + virtualPointsIntersects[0].object.index + 1, + ); this.transform_controls.attach(this.line3D.pointer); } else if (anchorPointsIntersects.length > 0) { const object = anchorPointsIntersects[0].object;