docs(cli): fix gaps agents hit authoring animated files (#15237) * docs(cli): fix contradictions and gaps agents hit authoring animated files - skeleton: property="rotation" works as well as propertyKey - format, workflow: ids are written back only when a .rev is made - AnimaScript/Luau: an artboard instance's advance runs its default state machine; how to play animations by hand and where script writes stick - drawing: rectangle radius clamp, cubic vertex handle directions, ClippingShape clips every drawable under its parent - transforms: positive rotation is clockwise on screen - easing: whole-frame keys, linear-timing cubicValue, keys are absolute * fix(defs): describe StateTransition.stateToId as the destination state The description was copied from stateFromId. Regenerated rive_core and rml outputs with the core generators. Drops the docs note that worked around the wrong schema text. * fix(scripting): Animation.advance(0) returns true while the animation can play LinearAnimationInstance::advance returns false for a zero step, so the Luau and wasm bindings reported false for loop and pingPong animations, against their documented contract. Fall back to keepGoing() at 0, as StateMachineInstance::advanceAndApply does. * docs(scripting): say when animation.advance then instance.advance(0) works The Animation examples only pose the component when its artboard has no default state machine; with one, instance.advance(0) applies the machine over the pose. Regenerated the CLI API docs and the rasc REPL bundle. * docs(cli): padding, margin and gap default to points in RML Only insets, size limits and borders need explicit units; maxWidth without units is ignored. * docs(cli): inner feather offset direction and the default IK bend side * fix(scripting): name the callee in the advance(0) comment; speed 0 caveat * docs(cli): drop the removed --once from the id write-back notes * chore(rasc): rebuild the site REPL bundle Rive-Mono-Commit: 6ba63e75a861cc0f2e5f9ac978e6308f65506093
diff --git a/src/lua/lua_artboards.cpp b/src/lua/lua_artboards.cpp index 7e311c4..2fa381b 100644 --- a/src/lua/lua_artboards.cpp +++ b/src/lua/lua_artboards.cpp
@@ -864,7 +864,9 @@ { auto seconds = float(luaL_checknumber(m_state, 2)); - bool advanced = m_animation->advance(seconds); + // LinearAnimationInstance::advance(0) returns false whatever the loop mode. + bool advanced = m_animation->advance(seconds) || + (seconds == 0.0f && m_animation->keepGoing()); m_animation->apply(); lua_pushboolean(m_state, advanced ? 1 : 0); return 1;
diff --git a/src/wasm/wasm_scripting_vm.cpp b/src/wasm/wasm_scripting_vm.cpp index 69a63ba..6a2fca4 100644 --- a/src/wasm/wasm_scripting_vm.cpp +++ b/src/wasm/wasm_scripting_vm.cpp
@@ -7992,7 +7992,9 @@ { return 0; } - bool advanced = host->animation->advance(seconds); + // LinearAnimationInstance::advance(0) returns false whatever the loop mode. + bool advanced = host->animation->advance(seconds) || + (seconds == 0.0f && host->animation->keepGoing()); host->animation->apply(); return advanced ? 1 : 0; }
diff --git a/tests/unit_tests/runtime/scripting/scripting_artboard_test.cpp b/tests/unit_tests/runtime/scripting/scripting_artboard_test.cpp index 1273086..9bc7d29 100644 --- a/tests/unit_tests/runtime/scripting/scripting_artboard_test.cpp +++ b/tests/unit_tests/runtime/scripting/scripting_artboard_test.cpp
@@ -1,6 +1,8 @@ #include "catch.hpp" #include "scripting_test_utilities.hpp" +#include "rive/animation/linear_animation.hpp" +#include "rive/animation/loop.hpp" #include "rive/animation/state_machine_instance.hpp" #include "rive/viewmodel/viewmodel_instance_boolean.hpp" #include "rive/lua/rive_lua_libs.hpp" @@ -152,6 +154,58 @@ CHECK(vm.serializer()->matches("scripted_artboard_render")); } +TEST_CASE("scripted Animation advance(0) follows the loop mode", "[scripting]") +{ + ScriptingTest vm("function zero(artboard:Artboard, name:string)\n" + " local anim = artboard:animation(name)\n" + " return anim ~= nil and anim:advance(0)\n" + "end\n" + "function zeroAfterEnd(artboard:Artboard, name:string)\n" + " local anim = artboard:animation(name)\n" + " if anim == nil then\n" + " return false\n" + " end\n" + " anim:advance(anim.duration + 1)\n" + " return anim:advance(0)\n" + "end\n"); + lua_State* L = vm.state(); + auto file = ReadRiveFile("assets/coin.riv", vm.serializer()); + auto artboard = file->artboard(); + REQUIRE(artboard != nullptr); + auto animation = artboard->animation(0); + REQUIRE(animation != nullptr); + REQUIRE(animation->speed() > 0.0f); + lua_newrive<ScriptedArtboard>( + L, + L, + file.get(), + artboard->instance(), + nullptr, + nullptr); + + auto call = [&](const char* function) { + lua_getglobal(L, function); + lua_pushvalue(L, -2); + lua_pushstring(L, animation->name().c_str()); + REQUIRE(lua_pcall(L, 2, 1, 0) == LUA_OK); + bool result = lua_toboolean(L, -1); + lua_pop(L, 1); + return result; + }; + + animation->loopValue(static_cast<int>(Loop::loop)); + CHECK(call("zero")); + CHECK(call("zeroAfterEnd")); + + animation->loopValue(static_cast<int>(Loop::pingPong)); + CHECK(call("zero")); + CHECK(call("zeroAfterEnd")); + + animation->loopValue(static_cast<int>(Loop::oneShot)); + CHECK(call("zero")); + CHECK_FALSE(call("zeroAfterEnd")); +} + TEST_CASE("can detect hit test from PointerEvent", "[scripting]") { ScriptingTest vm("function pointerDown(event:PointerEvent):number\n"