###Set Keyframe
To set a keyframe, you need to indicate “what to do“ at that time, we need to use setAt()
, which only has a little difference with set()
, we need to indicate the “time“ in the end, the command looks like,
ctx('name#Plug[name=Operator]').setAt({"Primitive":value}, key);
For Example:Set time 10 as keyframe, and then translate “MyBox“ to (10, 10, 0) at that time,
ctx('MyBox#Transform[name=Transform]').setAt({"translation":{"x":10,"y":10,"z":0}}, 10);
###Clear A Keyframe
To clear a keyframe of an object, you need to use removeKeyFrame()
which is similar to setAt()
, but you don’t need to indicate the value of the primitives, the command looks like,
ctx('name#Plug[name=Operator]').removeKeyFrame("Primitive", key);
For Example: Clear the translation
of “MyBox“ at time 10,
ctx('MyBox#Transform[name=Transform]').removeKeyFrame("translation", 10);
###Clear All Keyframes
To clear all keyframes of an object, the command looks like,
ctx.exec("animation/clearKeyFrames", 'name');
you just need to indicate the name of the object which you want to clear all its keyframes.
For Example: Clear all keyframes of “MyBox“,
ctx.exec("animation/clearKeyFrames", 'MyBox');
###Play and Stop
For Example: Play
the animation,
ctx.editor.scene.plugs.Timeline.play();
For Example: Stop
the animation,
ctx.editor.scene.plugs.Timeline.stop();
Use gotoTime()
to move forward to a specific keyframe, you can use setTime()
of scene to move to that keyframe, the command looks like,
ctx(sceneName).scene.setTime(key);
For Example: Go to keyframe 20,
ctx('Untitled Scene').scene.setTime(20);
ctx.editor.scene.plugs.Timeline.gotoTime(20);