History

Add hasProperty for checking whether a property exists

Dale Glass committed 3 years ago

Commit ac7ebe21 parent 5f2c13d6 files · +47 −5Browse files

Showing the changes to libraries/script-engine/src/ScriptValueUtils.cpp (1 of 6 files). Show all

Unified · Split

libraries/script-engine/src/ScriptValueUtils.cpp+4−4
@@ -140,7 +140,7 @@ bool vec2FromScriptValue(const ScriptValue& object, glm::vec2& vec2) { · 139 unmodified lines
140 140
141ScriptValue vec3ToScriptValue(ScriptEngine* engine, const glm::vec3& vec3) {141ScriptValue vec3ToScriptValue(ScriptEngine* engine, const glm::vec3& vec3) {
142 auto prototype = engine->globalObject().property("__hifi_vec3__");142 auto prototype = engine->globalObject().property("__hifi_vec3__");
143 if (!prototype.property("defined").toBool()) {143 if (!prototype.hasProperty("defined") || !prototype.property("defined").toBool()) {
144 prototype = engine->evaluate(144 prototype = engine->evaluate(
145 "__hifi_vec3__ = Object.defineProperties({}, { "145 "__hifi_vec3__ = Object.defineProperties({}, { "
146 "defined: { value: true },"146 "defined: { value: true },"
@@ -648,7 +648,7 @@ ScriptValue qColorToScriptValue(ScriptEngine* engine, const QColor& color) { · 501 unmodified lines
648}648}
649 649
650/**jsdoc650/**jsdoc
651 * An axis-aligned cube, defined as the bottom right near (minimum axes values) corner of the cube plus the dimension of its 651 * An axis-aligned cube, defined as the bottom right near (minimum axes values) corner of the cube plus the dimension of its
652 * sides.652 * sides.
653 * @typedef {object} AACube653 * @typedef {object} AACube
654 * @property {number} x - X coordinate of the brn corner of the cube.654 * @property {number} x - X coordinate of the brn corner of the cube.
@@ -812,8 +812,8 @@ bool qSizeFFromScriptValue(const ScriptValue& object, QSizeF& qSizeF) { · 157 unmodified lines
812 * The details of an animation that is playing.812 * The details of an animation that is playing.
813 * @typedef {object} Avatar.AnimationDetails813 * @typedef {object} Avatar.AnimationDetails
814 * @property {string} role - <em>Not used.</em>814 * @property {string} role - <em>Not used.</em>
815 * @property {string} url - The URL to the animation file. Animation files need to be in glTF or FBX format but only need to 815 * @property {string} url - The URL to the animation file. Animation files need to be in glTF or FBX format but only need to
816 * contain the avatar skeleton and animation data. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs 816 * contain the avatar skeleton and animation data. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs
817 * respectively).817 * respectively).
818 * <p><strong>Warning:</strong> glTF animations currently do not always animate correctly.</p>818 * <p><strong>Warning:</strong> glTF animations currently do not always animate correctly.</p>
819 * @property {number} fps - The frames per second(FPS) rate for the animation playback. 30 FPS is normal speed.819 * @property {number} fps - The frames per second(FPS) rate for the animation playback. 30 FPS is normal speed.