Added a rotating scene

To try
This commit is contained in:
2023-11-10 11:08:55 +01:00
parent 988039705c
commit 50ffd7911d
2 changed files with 19 additions and 1 deletions

View File

@@ -1,7 +1,11 @@
import * as THREE from 'three';
import {createGround} from './objects/ground.js';
console.log("OK")
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0EB1D2);
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
//const camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
@@ -9,16 +13,20 @@ document.body.appendChild( renderer.domElement );
const geometry = new THREE.BoxGeometry( 1, 1, 1 );
const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
const material = new THREE.MeshBasicMaterial( { color: 0xaabbff } );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );
scene.add(createGround());
camera.position.x = 0;
camera.position.y = 0;
camera.position.z = 5;
function animate() {
requestAnimationFrame( animate );
cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
camera.rotation.x += 0.01;
renderer.render( scene, camera );
}
animate();