Create a single self-contained HTML file using Three.js that renders a beautiful animated voxel-art 3D scene: "The Hourglass of Two Worlds". A giant antique hourglass of glass and aged brass floats in a deep indigo starry void, wrapped in slowly turning astrolabe rings, with drifting voxel clouds around it.
Each glass chamber holds a complete miniature world on a round stone plate with a funnel hole at its center. Each plate stays level like a gimbal, even when the hourglass turns.
UPPER WORLD, golden hour: a sunlit hilltop kingdom with a castle and fluttering banners, a turning windmill, a stone bridge over a turquoise stream, tiled village houses, wheat fields and blossoming trees, lit by a tiny voxel sun inside the chamber.
LOWER WORLD, moonlit: at first only an empty plate under a tiny voxel moon, faint aurora and stars on the inner glass. It will become a silver-blue winter kingdom with a crystal citadel, a frozen waterfall, snowy pines and glowing mushrooms, with a layout that does not mirror the upper world.
THE STORY, a seamless 16-second cycle:
0-2s: Calm. Life in the upper world: smoke from chimneys, birds, the windmill turning. A tiny hooded keeper, about 8 voxels tall, carries a warm lantern across the village.
2-11s: The upper world dissolves from the outer edges and rooftops inward. Voxels loosen, tumble and slide as sand toward the funnel, and buildings collapse in satisfying stages. They pour through the neck as a thin twisting rope of light, changing color from warm gold to icy blue at a white-hot point in the narrowest part. In the lower world, the same voxels land and hop into place, building the winter kingdom from the ground up, layer by layer. The keeper runs ahead of the collapse, climbing the last standing tower.
11-13s: The tower crumbles. The keeper leaps, falls down the stream with the lantern as the only warm light, and lands softly in the new world. They set the lantern on a post, and a wave of warm windows and street lamps spreads across the winter kingdom.
13-16s: The hourglass slowly flips 180 degrees with weight and overshoot, while the plates stay level, the chambers swap places and light sweeps across the glass. The next cycle runs the other way: the winter kingdom pours down and rebuilds into the golden kingdom.
KEY RULE: Conservation of voxels. No voxel is created or destroyed. Both worlds use exactly the same voxel count, and every voxel has a home position in each world. Use one InstancedMesh with per-instance color, aiming for 60,000+ voxels at smooth framerates. Pair voxels so the first to leave the top fill the lowest positions at the bottom, and use a compute-free, GPU-friendly approach such as animating in the vertex shader.
VISUAL POLISH: Physically convincing glass with Fresnel reflections, soft refraction and moving highlights; engraved brass with gears that turn during the flip; warm sunlight in one chamber and cool moonlight in the other, so the frame is split into orange and teal; a glowing neck that lights both worlds; bloom, soft shadows, voxel ambient occlusion, floating dust, and sand sparkle in the stream.
CAMERA: A slow cinematic orbit that keeps the whole hourglass in frame, with extra headroom at the top. Add a gentle push-in toward the neck when the keeper falls, then pull back for the flip. Allow drag to orbit.
Everything must be procedural, with no external assets. Make it as detailed and polished as possible.