init
This commit is contained in:
3
src/index.scss
Normal file
3
src/index.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
37
src/index.ts
Normal file
37
src/index.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import * as THREE from 'three';
|
||||
import "./index.scss";
|
||||
|
||||
let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer;
|
||||
let geometry: THREE.BoxGeometry, material: THREE.MeshNormalMaterial, mesh: THREE.Mesh<THREE.BoxGeometry, THREE.MeshNormalMaterial>
|
||||
;
|
||||
|
||||
init();
|
||||
|
||||
function init() {
|
||||
|
||||
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
|
||||
camera.position.z = 1;
|
||||
|
||||
scene = new THREE.Scene();
|
||||
|
||||
geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
|
||||
material = new THREE.MeshNormalMaterial();
|
||||
|
||||
mesh = new THREE.Mesh( geometry, material );
|
||||
scene.add( mesh );
|
||||
|
||||
renderer = new THREE.WebGLRenderer( { antialias: true } );
|
||||
renderer.setSize( window.innerWidth, window.innerHeight );
|
||||
renderer.setAnimationLoop( animation );
|
||||
document.body.appendChild( renderer.domElement );
|
||||
|
||||
}
|
||||
|
||||
function animation( time: number ) {
|
||||
|
||||
mesh.rotation.x = time / 2000;
|
||||
mesh.rotation.y = time / 1000;
|
||||
|
||||
renderer.render( scene, camera );
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user