initialize method
void
initialize()
Initializes the VR universe.
Implementation
void initialize() {
particles.clear();
rings.clear();
constellations.clear();
scene.clear();
for (int i = 0; i < particleCount; i++) {
final theta = _random.nextDouble() * 2 * pi;
final phi = (_random.nextDouble() * 2 - 1) * pi / 2;
final radius = 0.8 + _random.nextDouble() * 0.4;
final p = _AudioParticle(
vrElement: VRParticle(
position: Offset3D.fromSpherical(theta, phi, radius),
radius: 1.0 + _random.nextDouble() * 3.0,
color: _getRandomStarColor(),
glowRadius: 4,
),
energy: 0.3 + _random.nextDouble() * 0.7,
pulsePhase: _random.nextDouble() * 2 * pi,
theta: theta, phi: phi, baseRadius: radius,
);
particles.add(p);
scene.addElement(p.vrElement);
}
for (int i = 0; i < ringCount; i++) {
final ringRadius = 0.3 + (i / ringCount) * 0.6;
final pointsInRing = 60 + i * 10;
for (int j = 0; j < pointsInRing; j++) {
final theta = (j / pointsInRing) * 2 * pi;
final p = _AudioParticle(
vrElement: VRParticle(
position: Offset3D.fromSpherical(theta, 0, ringRadius),
radius: 1.5, color: primaryColor, glowRadius: 2,
),
energy: 1.0, pulsePhase: i * 0.5,
theta: theta, phi: 0, baseRadius: ringRadius,
);
rings.add(p);
scene.addElement(p.vrElement);
}
}
_generateConstellations();
}