0
我想旋轉電機的軸,但沒有設法得到所需的行爲。javafx 3d Meshview旋轉
旋轉我得到是這樣的一個。
這是我使用其中軸是我想旋轉MeshView代碼:
Model3D motor = new Model3D("motor.obj");
Map<String, MeshView> meshMapMotor = motor.getMapMeshes();
Pane gpMotor = new Pane();
for (Map.Entry<String, MeshView> entry : meshMapMotor.entrySet()) {
String key = entry.getKey();
MeshView value = entry.getValue();
Rotate rot = new Rotate(180);
rot.axisProperty().set(Rotate.Y_AXIS);
value.getTransforms().add(rot);
gpMotor.getChildren().add(value);
System.out.println("name: " + key);
if (key.equals("default (3)")) {
shaft = value;
}
}
gpMotor.setTranslateZ(7);
Rotate rot = new Rotate(1);
rot.axisProperty().set(new Point3D(0, 0, 1));
shaft.getTransforms().add(rot);
if (shaft != null) {
KeyFrame shaftFrame = new KeyFrame(Duration.millis(100), new KeyValue(rot.angleProperty(), 360));
motorRunning = new Timeline(shaftFrame);
motorRunning.setCycleCount(Timeline.INDEFINITE);
motorRunning.play();
}