44 lines
1.2 KiB
ActionScript
44 lines
1.2 KiB
ActionScript
class CameraComponentRender {
|
|
Entity entity;
|
|
CameraComponent cameraComponent;
|
|
|
|
CameraComponentRender(Entity _entity) {
|
|
entity = _entity;
|
|
cameraComponent = entity.getComponent<CameraComponent>();
|
|
}
|
|
|
|
void render() {
|
|
if (!entity.hasComponent<CameraComponent>())
|
|
return;
|
|
|
|
float fov = cameraComponent.fov;
|
|
float aspect = cameraComponent.aspectRatio;
|
|
float nearZ = cameraComponent.nearZ;
|
|
float farZ = cameraComponent.farZ;
|
|
|
|
fov = ImGui::magicSlider("Fov", fov, 0.1f);
|
|
if (fov > 180.0f) fov = 180.0f;
|
|
if (fov < 1.0f) fov = 1.0f;
|
|
|
|
aspect = ImGui::magicSlider("Aspect Ratio", aspect, 0.1f);
|
|
if (aspect < 0.1f) aspect = 0.1f;
|
|
|
|
nearZ = ImGui::magicSlider("Near Z", nearZ, 0.1f);
|
|
if (nearZ < 0.001f) nearZ = 0.001f;
|
|
|
|
farZ = ImGui::magicSlider("Far Z", farZ, 0.1f);
|
|
if (farZ < nearZ) farZ = nearZ;
|
|
|
|
cameraComponent.set_fov(fov);
|
|
cameraComponent.set_aspectRatio(aspect);
|
|
cameraComponent.set_nearZ(nearZ);
|
|
cameraComponent.set_farZ(farZ);
|
|
}
|
|
|
|
void remove() {
|
|
if (ImGui::menuItem("Remove")) {
|
|
entity.removeComponent<CameraComponent>();
|
|
}
|
|
}
|
|
}
|