Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 22, 2023
1 parent 99a1fb3 commit f71b9ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion zndraw/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions zndraw/static/World/components/draw.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as THREE from "three";


const findClosestPoint = (points, position) => {
const closestPoint = new THREE.Vector3();
points.forEach((point) => {
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion zndraw/static/World/systems/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f71b9ed

Please sign in to comment.