Showing the changes to interface/src/raypick/PickScriptingInterface.cpp (1 of 15 files). Show all
Unified · Split
| @@ -121,6 +121,7 @@ PickFilter getPickFilter(unsigned int filter) { · 120 unmodified lines | ||
| 121 | 121 | * @property {Vec3} [dirOffset] - Synonym for <code>direction</code>. |
| 122 | 122 | * @property {Quat} [orientation] - Alternative property for specifying <code>direction</code>. The value is applied to the |
| 123 | 123 | * default <code>direction</code> value. |
| 124 | + * @property {number} [delay=0.0] - The delay, in seconds, to apply to the ray direction. | |
| 124 | 125 | * @property {PickType} pickType - The type of pick when getting these properties from {@link Picks.getPickProperties} or |
| 125 | 126 | * {@link Picks.getPickScriptParameters}. A ray pick's type is {@link PickType.Ray}. |
| 126 | 127 | * @property {Vec3} baseScale - Returned from {@link Picks.getPickProperties} when the pick has a parent with varying scale |
| @@ -173,7 +174,14 @@ std::shared_ptr<PickQuery> PickScriptingInterface::buildRayPick(const QVariantMa · 46 unmodified lines | ||
| 173 | 174 | direction = vec3FromVariant(propMap["dirOffset"]); |
| 174 | 175 | } |
| 175 | 176 | |
| 176 | − auto rayPick = std::make_shared<RayPick>(position, direction, filter, maxDistance, enabled); | |
| 177 | + float delayHalf = 0.0f; | |
| 178 | + if (propMap["delay"].isValid()) { | |
| 179 | + // We want to be within 0.1% of the target in <delay> seconds | |
| 180 | + // https://twitter.com/FreyaHolmer/status/1757836988495847568 | |
| 181 | + delayHalf = -std::max(propMap["delay"].toFloat(), 0.0f) / log2(0.001); | |
| 182 | + } | |
| 183 | + | |
| 184 | + auto rayPick = std::make_shared<RayPick>(position, direction, filter, maxDistance, delayHalf, enabled); | |
| 177 | 185 | setParentTransform(rayPick, propMap); |
| 178 | 186 | |
| 179 | 187 | return rayPick; |