48 lines
1.1 KiB
ActionScript
48 lines
1.1 KiB
ActionScript
void renderCameraComponent(any@ data) {
|
|
Entity entity;
|
|
data.retrieve(entity);
|
|
|
|
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 removeCameraComponent(any@ entity) {
|
|
Entity ent;
|
|
entity.retrieve(ent);
|
|
|
|
if (UI::menuItem("Remove")) {
|
|
ent.removeCameraComponent();
|
|
}
|
|
}
|