function init(game, canvas) {
game.timeProgress = 0;
- game.timeTotal = 5;
+ game.timeTotal = 258;
game.courseRadius = 50;
game.objects = {};
game.objects.feather.position.setY(-game.courseRadius - 5.4 * Math.min(1, easeInOut(1 - Math.max(0, 4 - game.timeProgress) / 4)));
game.objects.feather.position.setZ(-6.6 * Math.min(1, easeInOut(1 - Math.max(0, 4 - game.timeProgress) / 4)));
game.objects.pinwheel.material[4].opacity = easeInOut(Math.max(0, (1 - game.timeProgress)));
+ let letterScale = lerp(0.3, 0.0, easeInOut(Math.max(0, Math.min(1, game.timeProgress - 6))));
+ for(let i = 0; i < game.objects.words.length; i++) {
+ let word = game.objects.words[i];
+ if(!word.collected) {
+ continue;
+ }
+ let x, y, z;
+ let collectionAnimationDuration = 1.0;
+ for(let j = 0; j < word.children.length; j++) {
+ let letter = word.children[j];
+ let wordProgress = j / word.children.length;
+ let animationProgress = (((game.timeProgress + 5 * word.randomAnimOffset) % 5) / 5 + j / 37) % 1;
+ x = game.objects.feather.scale.x * 0.5 * Math.cos(animationProgress * 1 * Math.PI * 2);
+ y = 0.2 * Math.sin(animationProgress * 7 * Math.PI * 2);
+ z = 0.2 * Math.cos(animationProgress * 7 * Math.PI * 2);
+ x = x * Math.cos(game.objects.feather.rotation.z) - y * Math.sin(game.objects.feather.rotation.z);
+ y = y * Math.cos(game.objects.feather.rotation.z) + x * Math.sin(game.objects.feather.rotation.z);
+ x += game.objects.feather.position.x;
+ y += game.objects.feather.position.y;
+ z += game.objects.feather.position.z;
+ if(i == 0 && !word.collected) {
+ // If we don't catch this edge case here, the manually placed first word might be visible
+ // in the closing cutscene if it is not collected.
+ x = 9999;
+ }
+ letter.position.set(x, y, z);
+ let rotation = (game.timeProgress * 3) % (2 * Math.PI);
+ letter.rotation.set(rotation + j, rotation + 2*j, rotation + 3*j);
+ letter.scale.set(letterScale, letterScale, letterScale);
+ }
+ }
if(game.timeProgress >= 8) {
game.ui.root.querySelector('.ui-page.title').classList.add('end');
game.ui.moveToPage('outro', true);