@Override public void start() { final Box aBox = (Box) add( new Box(a, new Vector3(0.1, 0.1, 0.1), new Vector3()) .surface(new ColorSurface(Color.White.alpha(0.5)))); final Box bBox = (Box) add( new Box(b, new Vector3(0.1, 0.1, 0.1), new Vector3()) .surface(new ColorSurface(Color.White.alpha(0.5)))); VectorFont font = getThe(VectorFont.class); label = new StringVar("???"); whenSizeChanges = add( new IfVector3Changes(aBox.getAbsolutePosition(), bBox.getAbsolutePosition()) { @Override public void afterVectorChanged(Vector3 v, double dx, double dy, double dz) { Vector3 aAbs = aBox.getAbsolutePosition(); Vector3 bAbs = bBox.getAbsolutePosition(); double dist = Vector3.subtract(aAbs, bAbs).getMagnitude(); label.set(Double.toString(dist)); } }); whenPointsChange = add( new IfVector3Changes(a, b) { @Override public void afterVectorChanged(Vector3 v, double dx, double dy, double dz) { updateTextPosition(); } }); text = add(new TextRect(label, font, 30)); updateTextPosition(); }
@Override public Space newEdgeSpace(Object edge, Box pa, Box pb) { return new Line3D(pa.getPosition(), pb.getPosition(), new DoubleVar(0.02), 2); }
@Override public Space newEdgeSpace(Object edge, Box pa, Box pb) { Line3D fl = new Line3D(pa.getPosition(), pb.getPosition(), new DoubleVar(0.02), 2); fl.color(Color.newRandomHSB(0.5, 0.5)); return fl; }