Skip to content

Commit

Permalink
feat: spinning cirno
Browse files Browse the repository at this point in the history
  • Loading branch information
aishenreemo committed Jul 16, 2024
1 parent fef82f3 commit 5e279a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Binary file added cirball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 15 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import * as three from 'three';
import cirball from './cirball.png';

const scene = new three.Scene();
const camera = new three.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);

const renderer = new three.WebGLRenderer({ canvas: document.getElementById("canvas") });
const geometry = new three.BoxGeometry(1, 1, 1);
const material = new three.MeshBasicMaterial({ color: 0x00ff00 });
const cube = new three.Mesh(geometry, material);
const ambientLight = new three.AmbientLight(0xffffff);
const nineball = new three.Mesh(
new three.SphereGeometry(10, 32, 32),
new three.MeshStandardMaterial({
map: new three.TextureLoader().load(cirball)
})
);

console.log(nineball);

function main() {
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setAnimationLoop(animate);

scene.add(cube);
scene.add(ambientLight);
scene.add(nineball);

camera.position.z = 5;
camera.position.z = 30;
}

function animate() {
cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
requestAnimationFrame(animate);
nineball.rotation.y += 0.0001;

renderer.render(scene, camera);
}
Expand Down

0 comments on commit 5e279a5

Please sign in to comment.