Display MoreHi,
i have such in an opensource barebone example here:
https://www.virtualtuur.com/krpano/122/bar…lb/1/index.html
xml:
https://www.virtualtuur.com/krpano/122/bar…/glb/1/tour.xmllook in the DoOnclick action.
.. to be short... use a 'counter'
Hope it helps,
Tuur
Thanks! Here's an action game that solved this issue.:
Code
<action name="DoOnclick_model2" type="js"><![CDATA[
// ========== ANIMATION SETTINGS ==========
// Array defining the sequence of animations to play
var animation_sequence = ["fly", "fly_right", "glide"];
// Number of repeats for each corresponding animation
var repeat_counts = [3, 2, 1];
// Transition time between animations in seconds
var blend_time = 0.3;
// ========== SYSTEM VARIABLES ==========
// Get reference to our hotspot
var hs = krpano.get("hotspot[model2]");
// Index of current animation in sequence
var current_animation_index = 0;
// Counter for current animation repeats
var current_repeat_count = 0;
// ========== MAIN PLAYBACK FUNCTION ==========
function playNextAnimation() {
// Loop back to first animation when sequence completes
if (current_animation_index >= animation_sequence.length) {
current_animation_index = 0;
}
// Get current animation name and object
var anim_name = animation_sequence[current_animation_index];
var anim = hs.animations.getItem(anim_name);
// Reset repeat counter for new animation
current_repeat_count = 0;
// Clean up previous handler if exists
if (anim.onloop) anim.onloop = null;
// ===== ANIMATION LOOP HANDLER =====
anim.onloop = function() {
// Increment repeat counter
current_repeat_count++;
// Debug output
console.log("Animation " + anim_name + ", loop: " + current_repeat_count);
// Check if reached required repeats
if (current_repeat_count >= repeat_counts[current_animation_index]) {
// Remove handler
anim.onloop = null;
// Move to next animation
current_animation_index++;
// Play next animation
playNextAnimation();
}
};
// ===== START ANIMATION WITH PARAMETERS =====
// 1. "repeat" - loop mode
// 2. blend_time - transition duration
// 3. true - stop other animations (playalone)
// 4. null - no callback function
anim.play("repeat", blend_time, true, null);
// Log animation start
console.log("Starting animation: " + anim_name);
}
// ========== INITIATE ANIMATION CYCLE ==========
playNextAnimation();
]]></action>
Display More