50 lines
1.2 KiB
ActionScript

class CameraComponentRender {
Entity entity;
CameraComponentRender(Entity _entity) {
entity = _entity;
}
void render() {
if (!entity.hasCameraComponent())
return;
CameraComponent cameraComponent = entity.getCameraComponent();
float fov = cameraComponent.fov;
float aspect = cameraComponent.aspectRatio;
float nearZ = cameraComponent.nearZ;
float farZ = cameraComponent.farZ;
fov = UI::magicSlider("Fov", fov, 0.1);
if (fov > 180)
fov = 180;
if (fov < 0)
fov = 0;
aspect = UI::magicSlider("Aspect Ratio", aspect, 0.1);
if (aspect < 0.1)
aspect = 0.1;
nearZ = UI::magicSlider("Near Z", nearZ, 0.1);
if (nearZ < 0)
nearZ = 0;
farZ = UI::magicSlider("Far Z", farZ, 0.1);
if (farZ < 0)
farZ = 0;
if (nearZ > farZ)
farZ = nearZ;
cameraComponent.fov = fov;
cameraComponent.aspectRatio = aspect;
cameraComponent.nearZ = nearZ;
cameraComponent.farZ = farZ;
}
void remove() {
if (UI::menuItem("Remove")) {
entity.removeCameraComponent();
}
}
}