game.var.pinwheelDistance = new THREE.Vector3();
game.var.notCollectedPos = new THREE.Vector3();
game.var.collectedPos = new THREE.Vector3();
- game.var.letterPos = new THREE.Vector3();
renderer.setAnimationLoop(() => { animate(game, renderer, scene); });
}
let randomPlacementAngle = Math.random() * 2 * Math.PI;
let randomPlacementX = Math.sin(randomPlacementAngle) * randomPlacementRadius;
let randomPlacementY = Math.cos(randomPlacementAngle) * randomPlacementRadius;
- word.mapPos = new THREE.Vector3(
- randomCameraX + randomPlacementX,
- randomCameraY + randomPlacementY,
- 0,
- );
+ word.position.set(randomCameraX + randomPlacementX, randomCameraY + randomPlacementY, 0);
placementSuccess = true;
for(let j = 0; j < i; j++) {
- if(interWordDistance.subVectors(word.mapPos, game.objects.words[j].mapPos).length() <= 1.2) {
+ if(interWordDistance.subVectors(word.position, game.objects.words[j].position).length() <= 1.2) {
placementSuccess = false;
break;
}
let word = game.objects.words[i];
if(!word.collected &&
game.objects.feather.speed.length() < 10.0 &&
- new THREE.Vector3().subVectors(word.mapPos, game.objects.feather.position).length() < collectingRadius) {
+ new THREE.Vector3().subVectors(word.position, game.objects.feather.position).length() < collectingRadius) {
word.collected = game.view.clock.getElapsedTime();
game.objects.words.collectedCount += 1;
}
let animationProgress = (((game.timeProgress + 5 * word.randomAnimOffset) % 5) / 5 + j / 37) % 1;
if(!word.collected || game.view.clock.getElapsedTime() - word.collected <= collectionAnimationDuration) {
const wordAnimationRadius = 0.2;
- x = word.mapPos.x + wordAnimationRadius * Math.cos(animationProgress * 5 * Math.PI * 2);
- y = word.mapPos.y + wordAnimationRadius * Math.sin(animationProgress * 4 * Math.PI * 2);
+ x = word.position.x + wordAnimationRadius * Math.cos(animationProgress * 5 * Math.PI * 2);
+ y = word.position.y + wordAnimationRadius * Math.sin(animationProgress * 4 * Math.PI * 2);
z = wordAnimationRadius * Math.sin(animationProgress * 6 * Math.PI * 2);
game.var.notCollectedPos.set(x, y, z);
}
}
if(game.var.notCollectedPos.length() > 0 && game.var.collectedPos.length() > 0) {
let collectingProgress = easeInOut(Math.max(0.0, Math.min(1.0, (game.view.clock.getElapsedTime() - word.collected) / collectionAnimationDuration)));
- game.var.letterPos.lerpVectors(game.var.notCollectedPos, game.var.collectedPos, collectingProgress);
+ letter.position.lerpVectors(game.var.notCollectedPos, game.var.collectedPos, collectingProgress);
let scale = lerp(1.0, collectedScale, collectingProgress);
letter.scale.set(scale, scale, scale);
} else if(game.var.notCollectedPos.length() > 0) {
- game.var.letterPos.set(game.var.notCollectedPos.x, game.var.notCollectedPos.y, game.var.notCollectedPos.z);
+ letter.position.set(game.var.notCollectedPos.x, game.var.notCollectedPos.y, game.var.notCollectedPos.z);
} else if(game.var.collectedPos.length() > 0) {
- game.var.letterPos.set(game.var.collectedPos.x, game.var.collectedPos.y, game.var.collectedPos.z);
+ letter.position.set(game.var.collectedPos.x, game.var.collectedPos.y, game.var.collectedPos.z);
}
- letter.position.set(game.var.letterPos.x, game.var.letterPos.y, game.var.letterPos.z);
+ letter.position.sub(word.position);
let rotation = (game.timeProgress * 3) % (2 * Math.PI);
letter.rotation.set(rotation + j, rotation + 2*j, rotation + 3*j);
}