package visualiser.layout;

import javafx.scene.shape.Shape3D;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Translate;

/**
 * Wrapper for controlling the position and heading of rendered 3D models.
 */
public class Subject3D {
    /**
     * Rendered mesh
     */
    private Shape3D mesh;

    /**
     * Position translation updated by state listeners
     */
    private Translate position;

    /**
     * Heading rotation updated by state listeners
     */
    private Rotate heading;

    /**
     * Constructor for view subject wrapper
     * @param mesh to be rendered
     */
    public Subject3D(Shape3D mesh) {
        this.mesh = mesh;
        this.position = new Translate();
        this.heading = new Rotate(0, Rotate.Y_AXIS);

        this.mesh.getTransforms().addAll(position, heading, new Rotate(90, Rotate.X_AXIS), new Rotate(180, Rotate.Y_AXIS));
    }

    public Shape3D getMesh() {
        return mesh;
    }

    public Translate getPosition() {
        return this.position;
    }

    public Rotate getHeading() {
        return heading;
    }

    public void setX(double x) {
        position.setX(x);
    }

    public void setY(double y) {
        position.setY(y);
    }

    public void setZ(double z) {
        position.setZ(z);
    }

    public void setHeading(double angle) {
        heading.setAngle(angle);
    }
}
