HelioAI's picture
LFM3-1.7B inference modules: experimental release
67ebcef verified
Raw History Blame Contribute Delete
3.53 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Solar system</title>
<style>html,body{margin:0;height:100%;overflow:hidden;background:#000}</style>
<script type="importmap">{"imports": {"three": "https://unpkg.com/three@0.160.0/build/three.module.js", "three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"}}</script>
</head>
<body>
<script type="module">
import * as THREE from 'three';
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(50, innerWidth / innerHeight, 0.1, 500);
camera.position.set(0, 16, 26);
camera.lookAt(0, 0, 0);
// background stars
const starGeo = new THREE.BufferGeometry();
const pos = new Float32Array(3000 * 3);
for (let i = 0; i < pos.length; i++) pos[i] = (Math.random() - 0.5) * 400;
starGeo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
scene.add(new THREE.Points(starGeo, new THREE.PointsMaterial({ color: 0xffffff, size: 0.6, sizeAttenuation: true })));
// sun: emissive sphere + additive halo sprites + a point light
const sun = new THREE.Mesh(new THREE.SphereGeometry(2.4, 48, 32), new THREE.MeshBasicMaterial({ color: 0xffd25e }));
scene.add(sun);
const haloTex = (() => {
const c = document.createElement('canvas'); c.width = c.height = 128;
const g = c.getContext('2d'), grd = g.createRadialGradient(64, 64, 0, 64, 64, 64);
grd.addColorStop(0, 'rgba(255,220,120,1)'); grd.addColorStop(0.35, 'rgba(255,170,40,0.5)'); grd.addColorStop(1, 'rgba(255,120,0,0)');
g.fillStyle = grd; g.fillRect(0, 0, 128, 128);
return new THREE.CanvasTexture(c);
})();
const halo = new THREE.Sprite(new THREE.SpriteMaterial({ map: haloTex, blending: THREE.AdditiveBlending, depthWrite: false }));
halo.scale.set(13, 13, 1);
scene.add(halo);
scene.add(new THREE.PointLight(0xfff1d0, 900, 0, 2));
scene.add(new THREE.AmbientLight(0x404060, 0.35));
function planet(radius, color, distance, speed) {
const pivot = new THREE.Object3D();
scene.add(pivot);
const mesh = new THREE.Mesh(new THREE.SphereGeometry(radius, 32, 24), new THREE.MeshStandardMaterial({ color, roughness: 0.8 }));
mesh.position.x = distance;
pivot.add(mesh);
const ring = new THREE.Mesh(new THREE.RingGeometry(distance - 0.03, distance + 0.03, 128),
new THREE.MeshBasicMaterial({ color: 0x334466, side: THREE.DoubleSide, transparent: true, opacity: 0.6 }));
ring.rotation.x = -Math.PI / 2;
scene.add(ring);
pivot.rotation.y = Math.random() * Math.PI * 2;
return { pivot, mesh, speed };
}
const planets = [planet(0.55, 0xb7b0a6, 5, 1.2), planet(0.95, 0x3d7bd9, 9, 0.7), planet(0.75, 0xd2603a, 13.5, 0.45)];
// moon around the blue planet
const moonPivot = new THREE.Object3D();
planets[1].mesh.add(moonPivot);
const moon = new THREE.Mesh(new THREE.SphereGeometry(0.25, 24, 16), new THREE.MeshStandardMaterial({ color: 0xdddddd }));
moon.position.x = 1.7;
moonPivot.add(moon);
addEventListener('resize', () => {
camera.aspect = innerWidth / innerHeight; camera.updateProjectionMatrix(); renderer.setSize(innerWidth, innerHeight);
});
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const dt = clock.getDelta();
for (const p of planets) { p.pivot.rotation.y += p.speed * dt; p.mesh.rotation.y += dt; }
moonPivot.rotation.y += 2.5 * dt;
renderer.render(scene, camera);
});
</script>
</body>
</html>