three.js first scene
Just a first scene with three.js
by hirako2000
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/93/three.min.js"></script>
JavaScript 1.7
let renderer;
let scene;
let camera;
let mesh;
init();
animate();
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.z = 10;
scene.add(camera);
let geometry = new THREE.ConeGeometry( 1, 5, 20 );
const material = new THREE.MeshBasicMaterial({color: 0x00ff00});
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
renderer = renderer = new THREE.WebGLRenderer({antialias: false});
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
}
function animate() {
requestAnimationFrame(animate);
render();
}
function render() {
renderer.render(scene, camera);
}