mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 13:56:24 +02:00
fixes in edit.js UI
This commit is contained in:
parent
2b745395ec
commit
5a8106a049
3 changed files with 16 additions and 13 deletions
|
@ -1224,7 +1224,8 @@ PropertiesTool = function(opts) {
|
|||
entity.properties.rotation = Quat.safeEulerAngles(entity.properties.rotation);
|
||||
}
|
||||
if (entity.properties.keyLightDirection !== undefined) {
|
||||
entity.properties.keyLightDirection = Vec3.toPolar(entity.properties.keyLightDirection);
|
||||
entity.properties.keyLightDirection = Vec3.multiply(RADIANS_TO_DEGREES, Vec3.toPolar(entity.properties.keyLightDirection));
|
||||
entity.properties.keyLightDirection.z = 0.0;
|
||||
}
|
||||
selections.push(entity);
|
||||
}
|
||||
|
@ -1254,7 +1255,8 @@ PropertiesTool = function(opts) {
|
|||
data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z);
|
||||
}
|
||||
if (data.properties.keyLightDirection !== undefined) {
|
||||
data.properties.keyLightDirection = Vec3.fromPolar(data.properties.keyLightDirection.x, data.properties.keyLightDirection.y);
|
||||
data.properties.keyLightDirection = Vec3.fromPolar(
|
||||
data.properties.keyLightDirection.x * DEGREES_TO_RADIANS, data.properties.keyLightDirection.y * DEGREES_TO_RADIANS);
|
||||
}
|
||||
Entities.editEntity(selectionManager.selections[0], data.properties);
|
||||
if (data.properties.name != undefined) {
|
||||
|
|
|
@ -80,22 +80,23 @@ glm::vec3 Vec3::toPolar(const glm::vec3& v) {
|
|||
if (glm::abs(radius) < EPSILON) {
|
||||
return glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
glm::vec3 u = v / radius;
|
||||
|
||||
float azimuth, elevation;
|
||||
float elevation, azimuth;
|
||||
|
||||
azimuth = glm::asin(-u.y);
|
||||
elevation = atan2(v.x, v.z);
|
||||
elevation = glm::asin(-u.y);
|
||||
azimuth = atan2(v.x, v.z);
|
||||
|
||||
// Round off small decimal values
|
||||
if (glm::abs(azimuth) < EPSILON) {
|
||||
azimuth = 0.0f;
|
||||
}
|
||||
if (glm::abs(elevation) < EPSILON) {
|
||||
elevation = 0.0f;
|
||||
}
|
||||
if (glm::abs(azimuth) < EPSILON) {
|
||||
azimuth = 0.0f;
|
||||
}
|
||||
|
||||
return glm::vec3(azimuth, elevation, radius);
|
||||
return glm::vec3(elevation, azimuth, radius);
|
||||
}
|
||||
|
||||
glm::vec3 Vec3::fromPolar(const glm::vec3& polar) {
|
||||
|
@ -113,12 +114,12 @@ glm::vec3 Vec3::fromPolar(const glm::vec3& polar) {
|
|||
if (glm::abs(z) < EPSILON) {
|
||||
z = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
return polar.z * glm::vec3(x, y, z);
|
||||
}
|
||||
|
||||
glm::vec3 Vec3::fromPolar(float azimuth, float elevation) {
|
||||
glm::vec3 v = glm::vec3(azimuth, elevation, 1.0f);
|
||||
glm::vec3 Vec3::fromPolar(float elevation, float azimuth) {
|
||||
glm::vec3 v = glm::vec3(elevation, azimuth, 1.0f);
|
||||
return fromPolar(v);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public slots:
|
|||
bool equal(const glm::vec3& v1, const glm::vec3& v2);
|
||||
glm::vec3 toPolar(const glm::vec3& v);
|
||||
glm::vec3 fromPolar(const glm::vec3& polar);
|
||||
glm::vec3 fromPolar(float pitch, float yaw);
|
||||
glm::vec3 fromPolar(float elevation, float azimuth);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue