我正在开发一种太阳系。行星绕着太阳运动,地球上不同的东西(例如树木和花朵是通过交互式网格导入的)围绕着行星的中心。
我尝试使用.add(calibration)来移动中心,其中校准是一个变量,该变量保存假定的错误偏移值
//shape is javafx Shape3D[] and it is set to interactive mesh ModelImporter.
Shape3D[] stuffOnEarth = Shape3dConstructor.getShape3D(name);//works fine. adds a 3d object to the scene. You can imagine it as an array of Sphere
for (Shape3D part : stuffOnEarth) {
var movement = new PathTransition(new Duration(DAY), new Circle(earth.RADIUS+distanceFromSurface), part);
movement.play();
}
StackPane stuffPane = new StackPane();
stuffPane.translateXProperty().bind(Earth.translateXProperty()); stuffPane.translateYProperty().bind(Earth.translateYProperty().add(calibration));
stuffPane.getChildren().addAll(stuffOnEarth);
// Earth is a javafx sphere that rotates around the Sun
Sphere earth = new Sphere(RADIUS);
var rotate = new PathTransition(new Duration(YEAR), new Circle(distanceFromTheSun), earth);
rotate.play();
但是这些东西并没有绕地球中心旋转,相反,它绕着我不知道的方向移动。
答案 0 :(得分:0)
要将3d对象绑定到地球表面,我执行了以下操作:我创建了一个球体和一个pathtransition,其路径用地球半径的圆表示;然后将3d对象绑定到中心球体。这就是解决方案