mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-09 15:52:09 +02:00
Merge pull request #14642 from dback2/propertyRangeAudit
Entity property range/step audit
This commit is contained in:
commit
4c6b14bf72
14 changed files with 362 additions and 189 deletions
|
@ -1747,7 +1747,8 @@ float EntityItem::getVolumeEstimate() const {
|
|||
void EntityItem::setRegistrationPoint(const glm::vec3& value) {
|
||||
if (value != _registrationPoint) {
|
||||
withWriteLock([&] {
|
||||
_registrationPoint = glm::clamp(value, 0.0f, 1.0f);
|
||||
_registrationPoint = glm::clamp(value, glm::vec3(ENTITY_ITEM_MIN_REGISTRATION_POINT),
|
||||
glm::vec3(ENTITY_ITEM_MAX_REGISTRATION_POINT));
|
||||
});
|
||||
dimensionsChanged(); // Registration Point affects the bounding box
|
||||
markDirtyFlags(Simulation::DIRTY_SHAPE);
|
||||
|
@ -1912,7 +1913,7 @@ void EntityItem::setVelocity(const glm::vec3& value) {
|
|||
}
|
||||
|
||||
void EntityItem::setDamping(float value) {
|
||||
auto clampedDamping = glm::clamp(value, 0.0f, 1.0f);
|
||||
auto clampedDamping = glm::clamp(value, ENTITY_ITEM_MIN_DAMPING, ENTITY_ITEM_MAX_DAMPING);
|
||||
withWriteLock([&] {
|
||||
if (_damping != clampedDamping) {
|
||||
_damping = clampedDamping;
|
||||
|
@ -1967,7 +1968,7 @@ void EntityItem::setAngularVelocity(const glm::vec3& value) {
|
|||
}
|
||||
|
||||
void EntityItem::setAngularDamping(float value) {
|
||||
auto clampedDamping = glm::clamp(value, 0.0f, 1.0f);
|
||||
auto clampedDamping = glm::clamp(value, ENTITY_ITEM_MIN_DAMPING, ENTITY_ITEM_MAX_DAMPING);
|
||||
withWriteLock([&] {
|
||||
if (_angularDamping != clampedDamping) {
|
||||
_angularDamping = clampedDamping;
|
||||
|
|
|
@ -2255,8 +2255,6 @@ void EntityItemPropertiesFromScriptValueHonorReadOnly(const QScriptValue &object
|
|||
|
||||
QScriptValue EntityPropertyFlagsToScriptValue(QScriptEngine* engine, const EntityPropertyFlags& flags) {
|
||||
return EntityItemProperties::entityPropertyFlagsToScriptValue(engine, flags);
|
||||
QScriptValue result = engine->newObject();
|
||||
return result;
|
||||
}
|
||||
|
||||
void EntityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags) {
|
||||
|
@ -2269,10 +2267,29 @@ QScriptValue EntityItemProperties::entityPropertyFlagsToScriptValue(QScriptEngin
|
|||
return result;
|
||||
}
|
||||
|
||||
static QHash<QString, EntityPropertyList> _propertyStringsToEnums;
|
||||
void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags) {
|
||||
if (object.isString()) {
|
||||
EntityPropertyInfo propertyInfo;
|
||||
if (getPropertyInfo(object.toString(), propertyInfo)) {
|
||||
flags << propertyInfo.propertyEnum;
|
||||
}
|
||||
}
|
||||
else if (object.isArray()) {
|
||||
quint32 length = object.property("length").toInt32();
|
||||
for (quint32 i = 0; i < length; i++) {
|
||||
QString propertyName = object.property(i).toString();
|
||||
EntityPropertyInfo propertyInfo;
|
||||
if (getPropertyInfo(propertyName, propertyInfo)) {
|
||||
flags << propertyInfo.propertyEnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static QHash<QString, EntityPropertyInfo> _propertyInfos;
|
||||
static QHash<EntityPropertyList, QString> _enumsToPropertyStrings;
|
||||
|
||||
void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags) {
|
||||
bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPropertyInfo& propertyInfo) {
|
||||
|
||||
static std::once_flag initMap;
|
||||
|
||||
|
@ -2286,9 +2303,10 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
|
|||
ADD_PROPERTY_TO_MAP(PROP_HREF, Href, href, QString);
|
||||
ADD_PROPERTY_TO_MAP(PROP_DESCRIPTION, Description, description, QString);
|
||||
ADD_PROPERTY_TO_MAP(PROP_POSITION, Position, position, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_DIMENSIONS, Dimensions, dimensions, vec3);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_DIMENSIONS, Dimensions, dimensions, vec3, ENTITY_ITEM_MIN_DIMENSION, FLT_MAX);
|
||||
ADD_PROPERTY_TO_MAP(PROP_ROTATION, Rotation, rotation, quat);
|
||||
ADD_PROPERTY_TO_MAP(PROP_REGISTRATION_POINT, RegistrationPoint, registrationPoint, vec3);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_REGISTRATION_POINT, RegistrationPoint, registrationPoint, vec3,
|
||||
ENTITY_ITEM_MIN_REGISTRATION_POINT, ENTITY_ITEM_MAX_REGISTRATION_POINT);
|
||||
ADD_PROPERTY_TO_MAP(PROP_CREATED, Created, created, quint64);
|
||||
ADD_PROPERTY_TO_MAP(PROP_LAST_EDITED_BY, LastEditedBy, lastEditedBy, QUuid);
|
||||
ADD_PROPERTY_TO_MAP(PROP_ENTITY_HOST_TYPE, EntityHostType, entityHostType, entity::HostType);
|
||||
|
@ -2322,15 +2340,20 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
|
|||
}
|
||||
|
||||
// Physics
|
||||
ADD_PROPERTY_TO_MAP(PROP_DENSITY, Density, density, float);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_DENSITY, Density, density, float,
|
||||
ENTITY_ITEM_MIN_DENSITY, ENTITY_ITEM_MAX_DENSITY);
|
||||
ADD_PROPERTY_TO_MAP(PROP_VELOCITY, Velocity, velocity, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_ANGULAR_VELOCITY, AngularVelocity, angularVelocity, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_GRAVITY, Gravity, gravity, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_ACCELERATION, Acceleration, acceleration, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_DAMPING, Damping, damping, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_ANGULAR_DAMPING, AngularDamping, angularDamping, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_RESTITUTION, Restitution, restitution, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_FRICTION, Friction, friction, float);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_DAMPING, Damping, damping, float,
|
||||
ENTITY_ITEM_MIN_DAMPING, ENTITY_ITEM_MAX_DAMPING);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ANGULAR_DAMPING, AngularDamping, angularDamping, float,
|
||||
ENTITY_ITEM_MIN_DAMPING, ENTITY_ITEM_MAX_DAMPING);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_RESTITUTION, Restitution, restitution, float,
|
||||
ENTITY_ITEM_MIN_RESTITUTION, ENTITY_ITEM_MAX_RESTITUTION);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_FRICTION, Friction, friction, float,
|
||||
ENTITY_ITEM_MIN_FRICTION, ENTITY_ITEM_MAX_FRICTION);
|
||||
ADD_PROPERTY_TO_MAP(PROP_LIFETIME, Lifetime, lifetime, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_COLLISIONLESS, Collisionless, collisionless, bool);
|
||||
ADD_PROPERTY_TO_MAP(PROP_COLLISIONLESS, unused, ignoreForCollisions, unused); // legacy support
|
||||
|
@ -2372,46 +2395,71 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
|
|||
ADD_PROPERTY_TO_MAP(PROP_LOCAL_ROTATION, LocalRotation, localRotation, quat);
|
||||
ADD_PROPERTY_TO_MAP(PROP_LOCAL_VELOCITY, LocalVelocity, localVelocity, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_LOCAL_ANGULAR_VELOCITY, LocalAngularVelocity, localAngularVelocity, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_LOCAL_DIMENSIONS, LocalDimensions, localDimensions, vec3);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_LOCAL_DIMENSIONS, LocalDimensions, localDimensions, vec3,
|
||||
ENTITY_ITEM_MIN_DIMENSION, FLT_MAX);
|
||||
|
||||
// Common
|
||||
ADD_PROPERTY_TO_MAP(PROP_SHAPE_TYPE, ShapeType, shapeType, ShapeType);
|
||||
ADD_PROPERTY_TO_MAP(PROP_COMPOUND_SHAPE_URL, CompoundShapeURL, compoundShapeURL, QString);
|
||||
ADD_PROPERTY_TO_MAP(PROP_COLOR, Color, color, u8vec3Color);
|
||||
ADD_PROPERTY_TO_MAP(PROP_ALPHA, Alpha, alpha, float);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ALPHA, Alpha, alpha, float, particle::MINIMUM_ALPHA, particle::MAXIMUM_ALPHA);
|
||||
ADD_PROPERTY_TO_MAP(PROP_TEXTURES, Textures, textures, QString);
|
||||
|
||||
// Particles
|
||||
ADD_PROPERTY_TO_MAP(PROP_MAX_PARTICLES, MaxParticles, maxParticles, quint32);
|
||||
ADD_PROPERTY_TO_MAP(PROP_LIFESPAN, Lifespan, lifespan, float);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_MAX_PARTICLES, MaxParticles, maxParticles, quint32,
|
||||
particle::MINIMUM_MAX_PARTICLES, particle::MAXIMUM_MAX_PARTICLES);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_LIFESPAN, Lifespan, lifespan, float,
|
||||
particle::MINIMUM_LIFESPAN, particle::MAXIMUM_LIFESPAN);
|
||||
ADD_PROPERTY_TO_MAP(PROP_EMITTING_PARTICLES, IsEmitting, isEmitting, bool);
|
||||
ADD_PROPERTY_TO_MAP(PROP_EMIT_RATE, EmitRate, emitRate, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_EMIT_SPEED, EmitSpeed, emitSpeed, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_SPEED_SPREAD, SpeedSpread, speedSpread, vec3);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_EMIT_RATE, EmitRate, emitRate, float,
|
||||
particle::MINIMUM_EMIT_RATE, particle::MAXIMUM_EMIT_RATE);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_EMIT_SPEED, EmitSpeed, emitSpeed, vec3,
|
||||
particle::MINIMUM_EMIT_SPEED, particle::MAXIMUM_EMIT_SPEED);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_SPEED_SPREAD, SpeedSpread, speedSpread, vec3,
|
||||
particle::MINIMUM_EMIT_SPEED, particle::MAXIMUM_EMIT_SPEED);
|
||||
ADD_PROPERTY_TO_MAP(PROP_EMIT_ORIENTATION, EmitOrientation, emitOrientation, quat);
|
||||
ADD_PROPERTY_TO_MAP(PROP_EMIT_DIMENSIONS, EmitDimensions, emitDimensions, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_EMIT_RADIUS_START, EmitRadiusStart, emitRadiusStart, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_POLAR_START, EmitPolarStart, polarStart, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_POLAR_FINISH, EmitPolarFinish, polarFinish, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_AZIMUTH_START, EmitAzimuthStart, azimuthStart, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_AZIMUTH_FINISH, EmitAzimuthFinish, azimuthFinish, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_EMIT_ACCELERATION, EmitAcceleration, emitAcceleration, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_ACCELERATION_SPREAD, AccelerationSpread, accelerationSpread, vec3);
|
||||
ADD_PROPERTY_TO_MAP(PROP_PARTICLE_RADIUS, ParticleRadius, particleRadius, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_RADIUS_SPREAD, RadiusSpread, radiusSpread, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_RADIUS_START, RadiusStart, radiusStart, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_RADIUS_FINISH, RadiusFinish, radiusFinish, float);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_EMIT_DIMENSIONS, EmitDimensions, emitDimensions, vec3,
|
||||
particle::MINIMUM_EMIT_DIMENSION, particle::MAXIMUM_EMIT_DIMENSION);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_EMIT_RADIUS_START, EmitRadiusStart, emitRadiusStart, float,
|
||||
particle::MINIMUM_EMIT_RADIUS_START, particle::MAXIMUM_EMIT_RADIUS_START);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_POLAR_START, EmitPolarStart, polarStart, float,
|
||||
particle::MINIMUM_POLAR, particle::MAXIMUM_POLAR);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_POLAR_FINISH, EmitPolarFinish, polarFinish, float,
|
||||
particle::MINIMUM_POLAR, particle::MAXIMUM_POLAR);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_AZIMUTH_START, EmitAzimuthStart, azimuthStart, float,
|
||||
particle::MINIMUM_AZIMUTH, particle::MAXIMUM_AZIMUTH);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_AZIMUTH_FINISH, EmitAzimuthFinish, azimuthFinish, float,
|
||||
particle::MINIMUM_AZIMUTH, particle::MAXIMUM_AZIMUTH);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_EMIT_ACCELERATION, EmitAcceleration, emitAcceleration, vec3,
|
||||
particle::MINIMUM_EMIT_ACCELERATION, particle::MAXIMUM_EMIT_ACCELERATION);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ACCELERATION_SPREAD, AccelerationSpread, accelerationSpread, vec3,
|
||||
particle::MINIMUM_ACCELERATION_SPREAD, particle::MAXIMUM_ACCELERATION_SPREAD);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_PARTICLE_RADIUS, ParticleRadius, particleRadius, float,
|
||||
particle::MINIMUM_PARTICLE_RADIUS, particle::MAXIMUM_PARTICLE_RADIUS);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_RADIUS_SPREAD, RadiusSpread, radiusSpread, float,
|
||||
particle::MINIMUM_PARTICLE_RADIUS, particle::MAXIMUM_PARTICLE_RADIUS);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_RADIUS_START, RadiusStart, radiusStart, float,
|
||||
particle::MINIMUM_PARTICLE_RADIUS, particle::MAXIMUM_PARTICLE_RADIUS);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_RADIUS_FINISH, RadiusFinish, radiusFinish, float,
|
||||
particle::MINIMUM_PARTICLE_RADIUS, particle::MAXIMUM_PARTICLE_RADIUS);
|
||||
ADD_PROPERTY_TO_MAP(PROP_COLOR_SPREAD, ColorSpread, colorSpread, u8vec3Color);
|
||||
ADD_PROPERTY_TO_MAP(PROP_COLOR_START, ColorStart, colorStart, vec3Color);
|
||||
ADD_PROPERTY_TO_MAP(PROP_COLOR_FINISH, ColorFinish, colorFinish, vec3Color);
|
||||
ADD_PROPERTY_TO_MAP(PROP_ALPHA_SPREAD, AlphaSpread, alphaSpread, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_ALPHA_START, AlphaStart, alphaStart, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_ALPHA_FINISH, AlphaFinish, alphaFinish, float);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ALPHA_SPREAD, AlphaSpread, alphaSpread, float,
|
||||
particle::MINIMUM_ALPHA, particle::MAXIMUM_ALPHA);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ALPHA_START, AlphaStart, alphaStart, float,
|
||||
particle::MINIMUM_ALPHA, particle::MAXIMUM_ALPHA);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ALPHA_FINISH, AlphaFinish, alphaFinish, float,
|
||||
particle::MINIMUM_ALPHA, particle::MAXIMUM_ALPHA);
|
||||
ADD_PROPERTY_TO_MAP(PROP_EMITTER_SHOULD_TRAIL, EmitterShouldTrail, emitterShouldTrail, bool);
|
||||
ADD_PROPERTY_TO_MAP(PROP_PARTICLE_SPIN, ParticleSpin, particleSpin, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_SPIN_SPREAD, SpinSpread, spinSpread, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_SPIN_START, SpinStart, spinStart, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_SPIN_FINISH, SpinFinish, spinFinish, float);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_PARTICLE_SPIN, ParticleSpin, particleSpin, float,
|
||||
particle::MINIMUM_PARTICLE_SPIN, particle::MAXIMUM_PARTICLE_SPIN);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_SPIN_SPREAD, SpinSpread, spinSpread, float,
|
||||
particle::MINIMUM_PARTICLE_SPIN, particle::MAXIMUM_PARTICLE_SPIN);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_SPIN_START, SpinStart, spinStart, float,
|
||||
particle::MINIMUM_PARTICLE_SPIN, particle::MAXIMUM_PARTICLE_SPIN);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_SPIN_FINISH, SpinFinish, spinFinish, float,
|
||||
particle::MINIMUM_PARTICLE_SPIN, particle::MAXIMUM_PARTICLE_SPIN);
|
||||
ADD_PROPERTY_TO_MAP(PROP_PARTICLE_ROTATE_WITH_ENTITY, RotateWithEntity, rotateWithEntity, float);
|
||||
|
||||
// Model
|
||||
|
@ -2437,7 +2485,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
|
|||
ADD_PROPERTY_TO_MAP(PROP_IS_SPOTLIGHT, IsSpotlight, isSpotlight, bool);
|
||||
ADD_PROPERTY_TO_MAP(PROP_INTENSITY, Intensity, intensity, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_EXPONENT, Exponent, exponent, float);
|
||||
ADD_PROPERTY_TO_MAP(PROP_CUTOFF, Cutoff, cutoff, float);
|
||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_CUTOFF, Cutoff, cutoff, float,
|
||||
LightEntityItem::MIN_CUTOFF, LightEntityItem::MAX_CUTOFF);
|
||||
ADD_PROPERTY_TO_MAP(PROP_FALLOFF_RADIUS, FalloffRadius, falloffRadius, float);
|
||||
|
||||
// Text
|
||||
|
@ -2552,20 +2601,27 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
|
|||
ADD_PROPERTY_TO_MAP(PROP_MINOR_GRID_EVERY, MinorGridEvery, minorGridEvery, float);
|
||||
});
|
||||
|
||||
if (object.isString()) {
|
||||
auto enumIter = _propertyStringsToEnums.find(object.toString());
|
||||
if (enumIter != _propertyStringsToEnums.end()) {
|
||||
flags << enumIter.value();
|
||||
}
|
||||
} else if (object.isArray()) {
|
||||
quint32 length = object.property("length").toInt32();
|
||||
for (quint32 i = 0; i < length; i++) {
|
||||
auto enumIter = _propertyStringsToEnums.find(object.property(i).toString());
|
||||
if (enumIter != _propertyStringsToEnums.end()) {
|
||||
flags << enumIter.value();
|
||||
}
|
||||
}
|
||||
auto iter = _propertyInfos.find(propertyName);
|
||||
if (iter != _propertyInfos.end()) {
|
||||
propertyInfo = *iter;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QScriptValue EntityPropertyInfoToScriptValue(QScriptEngine* engine, const EntityPropertyInfo& propertyInfo) {
|
||||
QScriptValue obj = engine->newObject();
|
||||
obj.setProperty("propertyEnum", propertyInfo.propertyEnum);
|
||||
obj.setProperty("minimum", propertyInfo.minimum.toString());
|
||||
obj.setProperty("maximum", propertyInfo.maximum.toString());
|
||||
return obj;
|
||||
}
|
||||
|
||||
void EntityPropertyInfoFromScriptValue(const QScriptValue& object, EntityPropertyInfo& propertyInfo) {
|
||||
propertyInfo.propertyEnum = (EntityPropertyList)object.property("propertyEnum").toVariant().toUInt();
|
||||
propertyInfo.minimum = object.property("minimum").toVariant();
|
||||
propertyInfo.maximum = object.property("maximum").toVariant();
|
||||
}
|
||||
|
||||
// TODO: Implement support for edit packets that can span an MTU sized buffer. We need to implement a mechanism for the
|
||||
|
|
|
@ -64,6 +64,17 @@ const std::array<ComponentPair, COMPONENT_MODE_ITEM_COUNT> COMPONENT_MODES = { {
|
|||
using vec3Color = glm::vec3;
|
||||
using u8vec3Color = glm::u8vec3;
|
||||
|
||||
struct EntityPropertyInfo {
|
||||
EntityPropertyInfo(EntityPropertyList propEnum) :
|
||||
propertyEnum(propEnum) {}
|
||||
EntityPropertyInfo(EntityPropertyList propEnum, QVariant min, QVariant max) :
|
||||
propertyEnum(propEnum), minimum(min), maximum(max) {}
|
||||
EntityPropertyInfo() = default;
|
||||
EntityPropertyList propertyEnum;
|
||||
QVariant minimum;
|
||||
QVariant maximum;
|
||||
};
|
||||
|
||||
/// A collection of properties of an entity item used in the scripting API. Translates between the actual properties of an
|
||||
/// entity and a JavaScript style hash/QScriptValue storing a set of properties. Used in scripting to set/get the complete
|
||||
/// set of entity item properties via JavaScript hashes/QScriptValues
|
||||
|
@ -102,6 +113,8 @@ public:
|
|||
static QScriptValue entityPropertyFlagsToScriptValue(QScriptEngine* engine, const EntityPropertyFlags& flags);
|
||||
static void entityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags);
|
||||
|
||||
static bool getPropertyInfo(const QString& propertyName, EntityPropertyInfo& propertyInfo);
|
||||
|
||||
// editing related features supported by all entities
|
||||
quint64 getLastEdited() const { return _lastEdited; }
|
||||
float getEditedAgo() const /// Elapsed seconds since this entity was last edited
|
||||
|
@ -478,6 +491,9 @@ Q_DECLARE_METATYPE(EntityPropertyFlags);
|
|||
QScriptValue EntityPropertyFlagsToScriptValue(QScriptEngine* engine, const EntityPropertyFlags& flags);
|
||||
void EntityPropertyFlagsFromScriptValue(const QScriptValue& object, EntityPropertyFlags& flags);
|
||||
|
||||
Q_DECLARE_METATYPE(EntityPropertyInfo);
|
||||
QScriptValue EntityPropertyInfoToScriptValue(QScriptEngine* engine, const EntityPropertyInfo& propertyInfo);
|
||||
void EntityPropertyInfoFromScriptValue(const QScriptValue& object, EntityPropertyInfo& propertyInfo);
|
||||
|
||||
// define these inline here so the macros work
|
||||
inline void EntityItemProperties::setPosition(const glm::vec3& value)
|
||||
|
|
|
@ -52,6 +52,9 @@ const QString ENTITY_ITEM_DEFAULT_SCRIPT = QString("");
|
|||
const quint64 ENTITY_ITEM_DEFAULT_SCRIPT_TIMESTAMP = 0;
|
||||
const QString ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS = QString("");
|
||||
const QString ENTITY_ITEM_DEFAULT_COLLISION_SOUND_URL = QString("");
|
||||
|
||||
const float ENTITY_ITEM_MIN_REGISTRATION_POINT = 0.0f;
|
||||
const float ENTITY_ITEM_MAX_REGISTRATION_POINT = 1.0f;
|
||||
const glm::vec3 ENTITY_ITEM_DEFAULT_REGISTRATION_POINT = ENTITY_ITEM_HALF_VEC3; // center
|
||||
|
||||
const float ENTITY_ITEM_IMMORTAL_LIFETIME = -1.0f; /// special lifetime which means the entity lives for ever
|
||||
|
@ -74,6 +77,8 @@ const glm::vec3 ENTITY_ITEM_DEFAULT_VELOCITY = ENTITY_ITEM_ZERO_VEC3;
|
|||
const glm::vec3 ENTITY_ITEM_DEFAULT_ANGULAR_VELOCITY = ENTITY_ITEM_ZERO_VEC3;
|
||||
const glm::vec3 ENTITY_ITEM_DEFAULT_GRAVITY = ENTITY_ITEM_ZERO_VEC3;
|
||||
const glm::vec3 ENTITY_ITEM_DEFAULT_ACCELERATION = ENTITY_ITEM_ZERO_VEC3;
|
||||
const float ENTITY_ITEM_MIN_DAMPING = 0.0f;
|
||||
const float ENTITY_ITEM_MAX_DAMPING = 1.0f;
|
||||
const float ENTITY_ITEM_DEFAULT_DAMPING = 0.39347f; // approx timescale = 2.0 sec (see damping timescale formula in header)
|
||||
const float ENTITY_ITEM_DEFAULT_ANGULAR_DAMPING = 0.39347f; // approx timescale = 2.0 sec (see damping timescale formula in header)
|
||||
|
||||
|
|
|
@ -401,12 +401,32 @@ inline QRect QRect_convertFromScriptValue(const QScriptValue& v, bool& isValid)
|
|||
static T _static##N;
|
||||
|
||||
#define ADD_PROPERTY_TO_MAP(P, N, n, T) \
|
||||
_propertyStringsToEnums[#n] = P; \
|
||||
_enumsToPropertyStrings[P] = #n;
|
||||
{ \
|
||||
EntityPropertyInfo propertyInfo = EntityPropertyInfo(P); \
|
||||
_propertyInfos[#n] = propertyInfo; \
|
||||
_enumsToPropertyStrings[P] = #n; \
|
||||
}
|
||||
|
||||
#define ADD_PROPERTY_TO_MAP_WITH_RANGE(P, N, n, T, M, X) \
|
||||
{ \
|
||||
EntityPropertyInfo propertyInfo = EntityPropertyInfo(P, M, X); \
|
||||
_propertyInfos[#n] = propertyInfo; \
|
||||
_enumsToPropertyStrings[P] = #n; \
|
||||
}
|
||||
|
||||
#define ADD_GROUP_PROPERTY_TO_MAP(P, G, g, N, n) \
|
||||
_propertyStringsToEnums[#g "." #n] = P; \
|
||||
_enumsToPropertyStrings[P] = #g "." #n;
|
||||
{ \
|
||||
EntityPropertyInfo propertyInfo = EntityPropertyInfo(P); \
|
||||
_propertyInfos[#g "." #n] = propertyInfo; \
|
||||
_enumsToPropertyStrings[P] = #g "." #n; \
|
||||
}
|
||||
|
||||
#define ADD_GROUP_PROPERTY_TO_MAP_WITH_RANGE(P, G, g, N, n, M, X) \
|
||||
{ \
|
||||
EntityPropertyInfo propertyInfo = EntityPropertyInfo(P, M, X); \
|
||||
_propertyInfos[#g "." #n] = propertyInfo; \
|
||||
_enumsToPropertyStrings[P] = #g "." #n; \
|
||||
}
|
||||
|
||||
#define DEFINE_CORE(N, n, T, V) \
|
||||
public: \
|
||||
|
|
|
@ -2266,6 +2266,12 @@ bool EntityScriptingInterface::verifyStaticCertificateProperties(const QUuid& en
|
|||
return result;
|
||||
}
|
||||
|
||||
const EntityPropertyInfo EntityScriptingInterface::getPropertyInfo(const QString& propertyName) const {
|
||||
EntityPropertyInfo propertyInfo;
|
||||
EntityItemProperties::getPropertyInfo(propertyName, propertyInfo);
|
||||
return propertyInfo;
|
||||
}
|
||||
|
||||
glm::vec3 EntityScriptingInterface::worldToLocalPosition(glm::vec3 worldPosition, const QUuid& parentID,
|
||||
int parentJointIndex, bool scalesWithParent) {
|
||||
bool success;
|
||||
|
|
|
@ -1695,6 +1695,16 @@ public slots:
|
|||
*/
|
||||
Q_INVOKABLE bool verifyStaticCertificateProperties(const QUuid& entityID);
|
||||
|
||||
/**jsdoc
|
||||
* Get information about entity properties including a minimum to maximum range for numerical properties
|
||||
* as well as property enum value.
|
||||
* @function Entities.getPropertyInfo
|
||||
* @param {string} propertyName - The name of the property to get the information for.
|
||||
* @returns {Entities.EntityPropertyInfo} The information data including propertyEnum, minimum, and maximum
|
||||
* if the property can be found, otherwise an empty object.
|
||||
*/
|
||||
Q_INVOKABLE const EntityPropertyInfo getPropertyInfo(const QString& propertyName) const;
|
||||
|
||||
signals:
|
||||
/**jsdoc
|
||||
* Triggered on the client that is the physics simulation owner during the collision of two entities. Note: Isn't triggered
|
||||
|
|
|
@ -25,6 +25,8 @@ const bool LightEntityItem::DEFAULT_IS_SPOTLIGHT = false;
|
|||
const float LightEntityItem::DEFAULT_INTENSITY = 1.0f;
|
||||
const float LightEntityItem::DEFAULT_FALLOFF_RADIUS = 0.1f;
|
||||
const float LightEntityItem::DEFAULT_EXPONENT = 0.0f;
|
||||
const float LightEntityItem::MIN_CUTOFF = 0.0f;
|
||||
const float LightEntityItem::MAX_CUTOFF = 90.0f;
|
||||
const float LightEntityItem::DEFAULT_CUTOFF = PI / 2.0f;
|
||||
|
||||
bool LightEntityItem::_lightsArePickable = false;
|
||||
|
@ -115,7 +117,7 @@ void LightEntityItem::setIsSpotlight(bool value) {
|
|||
}
|
||||
|
||||
void LightEntityItem::setCutoff(float value) {
|
||||
value = glm::clamp(value, 0.0f, 90.0f);
|
||||
value = glm::clamp(value, MIN_CUTOFF, MAX_CUTOFF);
|
||||
if (value == getCutoff()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ public:
|
|||
static const float DEFAULT_INTENSITY;
|
||||
static const float DEFAULT_FALLOFF_RADIUS;
|
||||
static const float DEFAULT_EXPONENT;
|
||||
static const float MIN_CUTOFF;
|
||||
static const float MAX_CUTOFF;
|
||||
static const float DEFAULT_CUTOFF;
|
||||
|
||||
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
|
|
@ -670,6 +670,7 @@ void ScriptEngine::init() {
|
|||
|
||||
qScriptRegisterMetaType(this, EntityPropertyFlagsToScriptValue, EntityPropertyFlagsFromScriptValue);
|
||||
qScriptRegisterMetaType(this, EntityItemPropertiesToScriptValue, EntityItemPropertiesFromScriptValueHonorReadOnly);
|
||||
qScriptRegisterMetaType(this, EntityPropertyInfoToScriptValue, EntityPropertyInfoFromScriptValue);
|
||||
qScriptRegisterMetaType(this, EntityItemIDtoScriptValue, EntityItemIDfromScriptValue);
|
||||
qScriptRegisterMetaType(this, RayToEntityIntersectionResultToScriptValue, RayToEntityIntersectionResultFromScriptValue);
|
||||
qScriptRegisterMetaType(this, RayToAvatarIntersectionResultToScriptValue, RayToAvatarIntersectionResultFromScriptValue);
|
||||
|
|
|
@ -422,7 +422,6 @@ const DEFAULT_ENTITY_PROPERTIES = {
|
|||
emitterShouldTrail: true,
|
||||
particleRadius: 0.25,
|
||||
radiusStart: 0,
|
||||
radiusFinish: 0.1,
|
||||
radiusSpread: 0,
|
||||
particleColor: {
|
||||
red: 255,
|
||||
|
@ -436,7 +435,6 @@ const DEFAULT_ENTITY_PROPERTIES = {
|
|||
},
|
||||
alpha: 0,
|
||||
alphaStart: 1,
|
||||
alphaFinish: 0,
|
||||
alphaSpread: 0,
|
||||
emitAcceleration: {
|
||||
x: 0,
|
||||
|
@ -449,12 +447,10 @@ const DEFAULT_ENTITY_PROPERTIES = {
|
|||
z: 0
|
||||
},
|
||||
particleSpin: 0,
|
||||
spinStart: 0,
|
||||
spinFinish: 0,
|
||||
spinSpread: 0,
|
||||
rotateWithEntity: false,
|
||||
polarStart: 0,
|
||||
polarFinish: 0,
|
||||
polarFinish: Math.PI,
|
||||
azimuthStart: -Math.PI,
|
||||
azimuthFinish: Math.PI
|
||||
},
|
||||
|
@ -2480,6 +2476,15 @@ var PropertiesTool = function (opts) {
|
|||
tooltips: Script.require('./assets/data/createAppTooltips.json'),
|
||||
hmdActive: HMD.active,
|
||||
});
|
||||
} else if (data.type === "propertyRangeRequest") {
|
||||
var propertyRanges = {};
|
||||
data.properties.forEach(function (property) {
|
||||
propertyRanges[property] = Entities.getPropertyInfo(property);
|
||||
});
|
||||
emitScriptEvent({
|
||||
type: 'propertyRangeReply',
|
||||
propertyRanges: propertyRanges,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ DraggableNumber.prototype = {
|
|||
|
||||
stepUp: function() {
|
||||
if (!this.isDisabled()) {
|
||||
this.elInput.stepUp();
|
||||
this.elInput.value = parseFloat(this.elInput.value) + this.step;
|
||||
this.inputChange();
|
||||
if (this.valueChangeFunction) {
|
||||
this.valueChangeFunction();
|
||||
|
@ -116,7 +116,7 @@ DraggableNumber.prototype = {
|
|||
|
||||
stepDown: function() {
|
||||
if (!this.isDisabled()) {
|
||||
this.elInput.stepDown();
|
||||
this.elInput.value = parseFloat(this.elInput.value) - this.step;
|
||||
this.inputChange();
|
||||
if (this.valueChangeFunction) {
|
||||
this.valueChangeFunction();
|
||||
|
@ -139,7 +139,14 @@ DraggableNumber.prototype = {
|
|||
},
|
||||
|
||||
inputChange: function() {
|
||||
this.setValue(this.elInput.value);
|
||||
let value = this.elInput.value;
|
||||
if (this.max !== undefined) {
|
||||
value = Math.min(this.max, value);
|
||||
}
|
||||
if (this.min !== undefined) {
|
||||
value = Math.max(this.min, value);
|
||||
}
|
||||
this.setValue(value);
|
||||
},
|
||||
|
||||
inputBlur: function(ev) {
|
||||
|
@ -156,6 +163,17 @@ DraggableNumber.prototype = {
|
|||
return this.elText.getAttribute("disabled") === "disabled";
|
||||
},
|
||||
|
||||
updateMinMax: function(min, max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
if (this.min !== undefined) {
|
||||
this.elInput.setAttribute("min", this.min);
|
||||
}
|
||||
if (this.max !== undefined) {
|
||||
this.elInput.setAttribute("max", this.max);
|
||||
}
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
this.onMouseDown = this.mouseDown.bind(this);
|
||||
this.onMouseUp = this.mouseUp.bind(this);
|
||||
|
@ -189,12 +207,7 @@ DraggableNumber.prototype = {
|
|||
this.elInput = document.createElement('input');
|
||||
this.elInput.className = "input";
|
||||
this.elInput.setAttribute("type", "number");
|
||||
if (this.min !== undefined) {
|
||||
this.elInput.setAttribute("min", this.min);
|
||||
}
|
||||
if (this.max !== undefined) {
|
||||
this.elInput.setAttribute("max", this.max);
|
||||
}
|
||||
this.updateMinMax(this.min, this.max);
|
||||
if (this.step !== undefined) {
|
||||
this.elInput.setAttribute("step", this.step);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ const GROUPS = [
|
|||
},
|
||||
{
|
||||
label: "Parent Joint Index",
|
||||
type: "number-draggable",
|
||||
type: "number",
|
||||
propertyID: "parentJointIndex",
|
||||
},
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ const GROUPS = [
|
|||
label: "Line Height",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
step: 0.005,
|
||||
step: 0.001,
|
||||
decimals: 4,
|
||||
unit: "m",
|
||||
propertyID: "lineHeight",
|
||||
|
@ -187,8 +187,8 @@ const GROUPS = [
|
|||
label: "Light Intensity",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 10,
|
||||
step: 0.1,
|
||||
max: 40,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
propertyID: "keyLight.intensity",
|
||||
showPropertyRule: { "keyLightMode": "enabled" },
|
||||
|
@ -196,6 +196,7 @@ const GROUPS = [
|
|||
{
|
||||
label: "Light Horizontal Angle",
|
||||
type: "number-draggable",
|
||||
step: 0.1,
|
||||
multiplier: DEGREES_TO_RADIANS,
|
||||
decimals: 2,
|
||||
unit: "deg",
|
||||
|
@ -205,6 +206,7 @@ const GROUPS = [
|
|||
{
|
||||
label: "Light Vertical Angle",
|
||||
type: "number-draggable",
|
||||
step: 0.1,
|
||||
multiplier: DEGREES_TO_RADIANS,
|
||||
decimals: 2,
|
||||
unit: "deg",
|
||||
|
@ -245,7 +247,7 @@ const GROUPS = [
|
|||
label: "Ambient Intensity",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 10,
|
||||
max: 200,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
propertyID: "ambientLight.ambientIntensity",
|
||||
|
@ -273,9 +275,9 @@ const GROUPS = [
|
|||
{
|
||||
label: "Range",
|
||||
type: "number-draggable",
|
||||
min: 5,
|
||||
min: 1,
|
||||
max: 10000,
|
||||
step: 5,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
unit: "m",
|
||||
propertyID: "haze.hazeRange",
|
||||
|
@ -292,7 +294,7 @@ const GROUPS = [
|
|||
type: "number-draggable",
|
||||
min: -1000,
|
||||
max: 1000,
|
||||
step: 10,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
unit: "m",
|
||||
propertyID: "haze.hazeBaseRef",
|
||||
|
@ -303,7 +305,7 @@ const GROUPS = [
|
|||
type: "number-draggable",
|
||||
min: -1000,
|
||||
max: 5000,
|
||||
step: 10,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
unit: "m",
|
||||
propertyID: "haze.hazeCeiling",
|
||||
|
@ -320,8 +322,8 @@ const GROUPS = [
|
|||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
step: 0.001,
|
||||
decimals: 3,
|
||||
propertyID: "haze.hazeBackgroundBlend",
|
||||
showPropertyRule: { "hazeMode": "enabled" },
|
||||
},
|
||||
|
@ -358,8 +360,8 @@ const GROUPS = [
|
|||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
step: 0.001,
|
||||
decimals: 3,
|
||||
propertyID: "bloom.bloomIntensity",
|
||||
showPropertyRule: { "bloomMode": "enabled" },
|
||||
},
|
||||
|
@ -368,8 +370,8 @@ const GROUPS = [
|
|||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
step: 0.001,
|
||||
decimals: 3,
|
||||
propertyID: "bloom.bloomThreshold",
|
||||
showPropertyRule: { "bloomMode": "enabled" },
|
||||
},
|
||||
|
@ -378,8 +380,8 @@ const GROUPS = [
|
|||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 2,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
step: 0.001,
|
||||
decimals: 3,
|
||||
propertyID: "bloom.bloomSize",
|
||||
showPropertyRule: { "bloomMode": "enabled" },
|
||||
},
|
||||
|
@ -543,16 +545,18 @@ const GROUPS = [
|
|||
label: "Intensity",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 10000,
|
||||
step: 0.1,
|
||||
decimals: 1,
|
||||
decimals: 2,
|
||||
propertyID: "intensity",
|
||||
},
|
||||
{
|
||||
label: "Fall-Off Radius",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 10000,
|
||||
step: 0.1,
|
||||
decimals: 1,
|
||||
decimals: 2,
|
||||
unit: "m",
|
||||
propertyID: "falloffRadius",
|
||||
},
|
||||
|
@ -564,6 +568,7 @@ const GROUPS = [
|
|||
{
|
||||
label: "Spotlight Exponent",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
propertyID: "exponent",
|
||||
|
@ -676,8 +681,6 @@ const GROUPS = [
|
|||
label: "Lifespan",
|
||||
type: "number-draggable",
|
||||
unit: "s",
|
||||
min: 0.01,
|
||||
max: 10,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
propertyID: "lifespan",
|
||||
|
@ -685,8 +688,6 @@ const GROUPS = [
|
|||
{
|
||||
label: "Max Particles",
|
||||
type: "number-draggable",
|
||||
min: 1,
|
||||
max: 10000,
|
||||
step: 1,
|
||||
propertyID: "maxParticles",
|
||||
},
|
||||
|
@ -706,26 +707,20 @@ const GROUPS = [
|
|||
{
|
||||
label: "Emit Rate",
|
||||
type: "number-draggable",
|
||||
min: 1,
|
||||
max: 1000,
|
||||
step: 1,
|
||||
propertyID: "emitRate",
|
||||
},
|
||||
{
|
||||
label: "Emit Speed",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 5,
|
||||
step: 0.01,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
propertyID: "emitSpeed",
|
||||
},
|
||||
{
|
||||
label: "Speed Spread",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 5,
|
||||
step: 0.01,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
propertyID: "speedSpread",
|
||||
},
|
||||
|
@ -733,7 +728,6 @@ const GROUPS = [
|
|||
label: "Emit Dimensions",
|
||||
type: "vec3",
|
||||
vec3Type: "xyz",
|
||||
min: 0,
|
||||
step: 0.01,
|
||||
round: 100,
|
||||
subLabels: [ "x", "y", "z" ],
|
||||
|
@ -742,10 +736,8 @@ const GROUPS = [
|
|||
{
|
||||
label: "Emit Radius Start",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
step: 0.001,
|
||||
decimals: 3,
|
||||
propertyID: "emitRadiusStart"
|
||||
},
|
||||
{
|
||||
|
@ -778,8 +770,6 @@ const GROUPS = [
|
|||
{
|
||||
label: "Start",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 4,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
propertyID: "radiusStart",
|
||||
|
@ -788,8 +778,6 @@ const GROUPS = [
|
|||
{
|
||||
label: "Middle",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 4,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
propertyID: "particleRadius",
|
||||
|
@ -797,8 +785,6 @@ const GROUPS = [
|
|||
{
|
||||
label: "Finish",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 4,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
propertyID: "radiusFinish",
|
||||
|
@ -809,8 +795,6 @@ const GROUPS = [
|
|||
{
|
||||
label: "Size Spread",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 4,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
propertyID: "radiusSpread",
|
||||
|
@ -867,29 +851,23 @@ const GROUPS = [
|
|||
{
|
||||
label: "Start",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
step: 0.001,
|
||||
decimals: 3,
|
||||
propertyID: "alphaStart",
|
||||
fallbackProperty: "alpha",
|
||||
},
|
||||
{
|
||||
label: "Middle",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
step: 0.001,
|
||||
decimals: 3,
|
||||
propertyID: "alpha",
|
||||
},
|
||||
{
|
||||
label: "Finish",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
step: 0.001,
|
||||
decimals: 3,
|
||||
propertyID: "alphaFinish",
|
||||
fallbackProperty: "alpha",
|
||||
},
|
||||
|
@ -898,10 +876,8 @@ const GROUPS = [
|
|||
{
|
||||
label: "Alpha Spread",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
step: 0.001,
|
||||
decimals: 3,
|
||||
propertyID: "alphaSpread",
|
||||
},
|
||||
]
|
||||
|
@ -944,10 +920,8 @@ const GROUPS = [
|
|||
{
|
||||
label: "Start",
|
||||
type: "number-draggable",
|
||||
min: -360,
|
||||
max: 360,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
multiplier: DEGREES_TO_RADIANS,
|
||||
unit: "deg",
|
||||
propertyID: "spinStart",
|
||||
|
@ -956,10 +930,8 @@ const GROUPS = [
|
|||
{
|
||||
label: "Middle",
|
||||
type: "number-draggable",
|
||||
min: -360,
|
||||
max: 360,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
multiplier: DEGREES_TO_RADIANS,
|
||||
unit: "deg",
|
||||
propertyID: "particleSpin",
|
||||
|
@ -967,10 +939,8 @@ const GROUPS = [
|
|||
{
|
||||
label: "Finish",
|
||||
type: "number-draggable",
|
||||
min: -360,
|
||||
max: 360,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
multiplier: DEGREES_TO_RADIANS,
|
||||
unit: "deg",
|
||||
propertyID: "spinFinish",
|
||||
|
@ -981,10 +951,8 @@ const GROUPS = [
|
|||
{
|
||||
label: "Spin Spread",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 360,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
multiplier: DEGREES_TO_RADIANS,
|
||||
unit: "deg",
|
||||
propertyID: "spinSpread",
|
||||
|
@ -1009,10 +977,8 @@ const GROUPS = [
|
|||
{
|
||||
label: "Start",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 180,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
multiplier: DEGREES_TO_RADIANS,
|
||||
unit: "deg",
|
||||
propertyID: "polarStart",
|
||||
|
@ -1020,10 +986,8 @@ const GROUPS = [
|
|||
{
|
||||
label: "Finish",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 180,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
multiplier: DEGREES_TO_RADIANS,
|
||||
unit: "deg",
|
||||
propertyID: "polarFinish",
|
||||
|
@ -1038,10 +1002,8 @@ const GROUPS = [
|
|||
{
|
||||
label: "Start",
|
||||
type: "number-draggable",
|
||||
min: -180,
|
||||
max: 180,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
multiplier: DEGREES_TO_RADIANS,
|
||||
unit: "deg",
|
||||
propertyID: "azimuthStart",
|
||||
|
@ -1049,10 +1011,8 @@ const GROUPS = [
|
|||
{
|
||||
label: "Finish",
|
||||
type: "number-draggable",
|
||||
min: -180,
|
||||
max: 180,
|
||||
step: 1,
|
||||
decimals: 0,
|
||||
step: 0.1,
|
||||
decimals: 2,
|
||||
multiplier: DEGREES_TO_RADIANS,
|
||||
unit: "deg",
|
||||
propertyID: "azimuthFinish",
|
||||
|
@ -1069,6 +1029,7 @@ const GROUPS = [
|
|||
label: "Position",
|
||||
type: "vec3",
|
||||
vec3Type: "xyz",
|
||||
step: 0.1,
|
||||
decimals: 4,
|
||||
subLabels: [ "x", "y", "z" ],
|
||||
unit: "m",
|
||||
|
@ -1079,6 +1040,7 @@ const GROUPS = [
|
|||
label: "Local Position",
|
||||
type: "vec3",
|
||||
vec3Type: "xyz",
|
||||
step: 0.1,
|
||||
decimals: 4,
|
||||
subLabels: [ "x", "y", "z" ],
|
||||
unit: "m",
|
||||
|
@ -1111,8 +1073,7 @@ const GROUPS = [
|
|||
label: "Dimensions",
|
||||
type: "vec3",
|
||||
vec3Type: "xyz",
|
||||
min: 0,
|
||||
step: 0.1,
|
||||
step: 0.01,
|
||||
decimals: 4,
|
||||
subLabels: [ "x", "y", "z" ],
|
||||
unit: "m",
|
||||
|
@ -1123,8 +1084,7 @@ const GROUPS = [
|
|||
label: "Local Dimensions",
|
||||
type: "vec3",
|
||||
vec3Type: "xyz",
|
||||
min: 0,
|
||||
step: 0.1,
|
||||
step: 0.01,
|
||||
decimals: 4,
|
||||
subLabels: [ "x", "y", "z" ],
|
||||
unit: "m",
|
||||
|
@ -1144,7 +1104,7 @@ const GROUPS = [
|
|||
label: "Pivot",
|
||||
type: "vec3",
|
||||
vec3Type: "xyz",
|
||||
step: 0.1,
|
||||
step: 0.001,
|
||||
decimals: 4,
|
||||
subLabels: [ "x", "y", "z" ],
|
||||
unit: "(ratio of dimension)",
|
||||
|
@ -1176,6 +1136,7 @@ const GROUPS = [
|
|||
{
|
||||
label: "Clone Lifetime",
|
||||
type: "number-draggable",
|
||||
min: -1,
|
||||
unit: "s",
|
||||
propertyID: "cloneLifetime",
|
||||
showPropertyRule: { "cloneable": "true" },
|
||||
|
@ -1183,6 +1144,7 @@ const GROUPS = [
|
|||
{
|
||||
label: "Clone Limit",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
propertyID: "cloneLimit",
|
||||
showPropertyRule: { "cloneable": "true" },
|
||||
},
|
||||
|
@ -1347,7 +1309,7 @@ const GROUPS = [
|
|||
label: "Linear Velocity",
|
||||
type: "vec3",
|
||||
vec3Type: "xyz",
|
||||
step: 0.1,
|
||||
step: 0.01,
|
||||
decimals: 4,
|
||||
subLabels: [ "x", "y", "z" ],
|
||||
unit: "m/s",
|
||||
|
@ -1358,8 +1320,8 @@ const GROUPS = [
|
|||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
decimals: 2,
|
||||
step: 0.001,
|
||||
decimals: 4,
|
||||
propertyID: "damping",
|
||||
},
|
||||
{
|
||||
|
@ -1377,33 +1339,27 @@ const GROUPS = [
|
|||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
step: 0.001,
|
||||
decimals: 4,
|
||||
propertyID: "angularDamping",
|
||||
},
|
||||
{
|
||||
label: "Bounciness",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
step: 0.001,
|
||||
decimals: 4,
|
||||
propertyID: "restitution",
|
||||
},
|
||||
{
|
||||
label: "Friction",
|
||||
type: "number-draggable",
|
||||
min: 0,
|
||||
max: 10,
|
||||
step: 0.1,
|
||||
step: 0.01,
|
||||
decimals: 4,
|
||||
propertyID: "friction",
|
||||
},
|
||||
{
|
||||
label: "Density",
|
||||
type: "number-draggable",
|
||||
min: 100,
|
||||
max: 10000,
|
||||
step: 1,
|
||||
decimals: 4,
|
||||
propertyID: "density",
|
||||
|
@ -1423,6 +1379,7 @@ const GROUPS = [
|
|||
type: "vec3",
|
||||
vec3Type: "xyz",
|
||||
subLabels: [ "x", "y", "z" ],
|
||||
step: 0.1,
|
||||
decimals: 4,
|
||||
unit: "m/s<sup>2</sup>",
|
||||
propertyID: "acceleration",
|
||||
|
@ -1504,6 +1461,7 @@ const JSON_EDITOR_ROW_DIV_INDEX = 2;
|
|||
|
||||
let elGroups = {};
|
||||
let properties = {};
|
||||
let propertyRangeRequests = [];
|
||||
let colorPickers = {};
|
||||
let particlePropertyUpdates = {};
|
||||
let selectedEntityProperties;
|
||||
|
@ -2006,6 +1964,18 @@ function createNumberProperty(property, elProperty) {
|
|||
return elInput;
|
||||
}
|
||||
|
||||
function updateNumberMinMax(property) {
|
||||
let elInput = property.elInput;
|
||||
let min = property.data.min;
|
||||
let max = property.data.max;
|
||||
if (min !== undefined) {
|
||||
elInput.setAttribute("min", min);
|
||||
}
|
||||
if (max !== undefined) {
|
||||
elInput.setAttribute("max", max);
|
||||
}
|
||||
}
|
||||
|
||||
function createNumberDraggableProperty(property, elProperty) {
|
||||
let elementID = property.elementID;
|
||||
let propertyData = property.data;
|
||||
|
@ -2035,6 +2005,11 @@ function createNumberDraggableProperty(property, elProperty) {
|
|||
return elDraggableNumber;
|
||||
}
|
||||
|
||||
function updateNumberDraggableMinMax(property) {
|
||||
let propertyData = property.data;
|
||||
property.elNumber.updateMinMax(propertyData.min, propertyData.max);
|
||||
}
|
||||
|
||||
function createRectProperty(property, elProperty) {
|
||||
let propertyData = property.data;
|
||||
|
||||
|
@ -2073,6 +2048,15 @@ function createRectProperty(property, elProperty) {
|
|||
return elResult;
|
||||
}
|
||||
|
||||
function updateRectMinMax(property) {
|
||||
let min = property.data.min;
|
||||
let max = property.data.max;
|
||||
property.elNumberX.updateMinMax(min, max);
|
||||
property.elNumberY.updateMinMax(min, max);
|
||||
property.elNumberWidth.updateMinMax(min, max);
|
||||
property.elNumberHeight.updateMinMax(min, max);
|
||||
}
|
||||
|
||||
function createVec3Property(property, elProperty) {
|
||||
let propertyData = property.data;
|
||||
|
||||
|
@ -2122,6 +2106,16 @@ function createVec2Property(property, elProperty) {
|
|||
return elResult;
|
||||
}
|
||||
|
||||
function updateVectorMinMax(property) {
|
||||
let min = property.data.min;
|
||||
let max = property.data.max;
|
||||
property.elNumberX.updateMinMax(min, max);
|
||||
property.elNumberY.updateMinMax(min, max);
|
||||
if (property.elNumberZ) {
|
||||
property.elNumberZ.updateMinMax(min, max);
|
||||
}
|
||||
}
|
||||
|
||||
function createColorProperty(property, elProperty) {
|
||||
let propertyName = property.name;
|
||||
let elementID = property.elementID;
|
||||
|
@ -3120,6 +3114,9 @@ function loaded() {
|
|||
if (property.type !== 'placeholder') {
|
||||
properties[propertyID] = property;
|
||||
}
|
||||
if (innerPropertyData.type === 'number' || innerPropertyData.type === 'number-draggable') {
|
||||
propertyRangeRequests.push(propertyID);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let property = createProperty(propertyData, propertyElementID, propertyName, propertyID, elProperty);
|
||||
|
@ -3129,6 +3126,10 @@ function loaded() {
|
|||
|
||||
if (property.type !== 'placeholder') {
|
||||
properties[propertyID] = property;
|
||||
}
|
||||
if (propertyData.type === 'number' || propertyData.type === 'number-draggable' ||
|
||||
propertyData.type === 'vec2' || propertyData.type === 'vec3' || propertyData.type === 'rect') {
|
||||
propertyRangeRequests.push(propertyID);
|
||||
}
|
||||
|
||||
let showPropertyRule = propertyData.showPropertyRule;
|
||||
|
@ -3499,11 +3500,48 @@ function loaded() {
|
|||
} else if (data.type === 'setSpaceMode') {
|
||||
currentSpaceMode = data.spaceMode === "local" ? PROPERTY_SPACE_MODE.LOCAL : PROPERTY_SPACE_MODE.WORLD;
|
||||
updateVisibleSpaceModeProperties();
|
||||
} else if (data.type === 'propertyRangeReply') {
|
||||
let propertyRanges = data.propertyRanges;
|
||||
for (let property in propertyRanges) {
|
||||
let propertyRange = propertyRanges[property];
|
||||
if (propertyRange !== undefined) {
|
||||
let propertyData = properties[property].data;
|
||||
let multiplier = propertyData.multiplier;
|
||||
if (propertyData.min === undefined && propertyRange.minimum != "") {
|
||||
propertyData.min = propertyRange.minimum;
|
||||
if (multiplier !== undefined) {
|
||||
propertyData.min /= multiplier;
|
||||
}
|
||||
}
|
||||
if (propertyData.max === undefined && propertyRange.maximum != "") {
|
||||
propertyData.max = propertyRange.maximum;
|
||||
if (multiplier !== undefined) {
|
||||
propertyData.max /= multiplier;
|
||||
}
|
||||
}
|
||||
switch (propertyData.type) {
|
||||
case 'number':
|
||||
updateNumberMinMax(properties[property]);
|
||||
break;
|
||||
case 'number-draggable':
|
||||
updateNumberDraggableMinMax(properties[property]);
|
||||
break;
|
||||
case 'vec3':
|
||||
case 'vec2':
|
||||
updateVectorMinMax(properties[property]);
|
||||
break;
|
||||
case 'rect':
|
||||
updateRectMinMax(properties[property]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Request tooltips as soon as we can process a reply:
|
||||
// Request tooltips and property ranges as soon as we can process a reply:
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'tooltipsRequest' }));
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'propertyRangeRequest', properties: propertyRangeRequests }));
|
||||
}
|
||||
|
||||
// Server Script Status
|
||||
|
|
|
@ -599,12 +599,10 @@ SelectionDisplay = (function() {
|
|||
|
||||
const STRETCH_CUBE_OFFSET = 0.06;
|
||||
const STRETCH_CUBE_CAMERA_DISTANCE_MULTIPLE = 0.02;
|
||||
const STRETCH_MINIMUM_DIMENSION = 0.001;
|
||||
const STRETCH_PANEL_WIDTH = 0.01;
|
||||
|
||||
const SCALE_OVERLAY_CAMERA_DISTANCE_MULTIPLE = 0.02;
|
||||
const SCALE_DIMENSIONS_CAMERA_DISTANCE_MULTIPLE = 0.5;
|
||||
const SCALE_MINIMUM_DIMENSION = 0.01;
|
||||
|
||||
const BOUNDING_EDGE_OFFSET = 0.5;
|
||||
|
||||
|
@ -1543,7 +1541,7 @@ SelectionDisplay = (function() {
|
|||
print(" SpaceMode: " + spaceMode);
|
||||
print(" DisplayMode: " + getMode());
|
||||
}
|
||||
|
||||
|
||||
if (SelectionManager.selections.length === 0) {
|
||||
that.setOverlaysVisible(false);
|
||||
that.clearDebugPickPlane();
|
||||
|
@ -1574,7 +1572,7 @@ SelectionDisplay = (function() {
|
|||
dimensions: dimensions
|
||||
};
|
||||
var isCameraInsideBox = isPointInsideBox(Camera.position, selectionBoxGeometry);
|
||||
|
||||
|
||||
// in HMD if outside the bounding box clamp the overlays to the bounding box for now so lasers can hit them
|
||||
var maxHandleDimension = 0;
|
||||
if (HMD.active && !isCameraInsideBox) {
|
||||
|
@ -2515,7 +2513,7 @@ SelectionDisplay = (function() {
|
|||
|
||||
var newDimensions = Vec3.sum(initialDimensions, changeInDimensions);
|
||||
|
||||
var minimumDimension = STRETCH_MINIMUM_DIMENSION;
|
||||
var minimumDimension = Entities.getPropertyInfo("dimensions").minimum;
|
||||
if (newDimensions.x < minimumDimension) {
|
||||
newDimensions.x = minimumDimension;
|
||||
changeInDimensions.x = minimumDimension - initialDimensions.x;
|
||||
|
@ -2634,7 +2632,7 @@ SelectionDisplay = (function() {
|
|||
newDimensions.y = Math.abs(newDimensions.y);
|
||||
newDimensions.z = Math.abs(newDimensions.z);
|
||||
|
||||
var minimumDimension = SCALE_MINIMUM_DIMENSION;
|
||||
var minimumDimension = Entities.getPropertyInfo("dimensions").minimum;
|
||||
if (newDimensions.x < minimumDimension) {
|
||||
newDimensions.x = minimumDimension;
|
||||
changeInDimensions.x = minimumDimension - initialDimensions.x;
|
||||
|
|
Loading…
Reference in a new issue