Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Last active May 23, 2020 06:54
Show Gist options
  • Select an option

  • Save flushpot1125/95f62f3c8e97d0e128bf220e08d7ff8f to your computer and use it in GitHub Desktop.

Select an option

Save flushpot1125/95f62f3c8e97d0e128bf220e08d7ff8f to your computer and use it in GitHub Desktop.
import * as THREE from 'three';
//スクリプトのロードが終わってからinitを実行させる
window.addEventListener('load', init);
let scene, camera;
//Renderer
const renderer = new THREE.WebGLRenderer({
canvas: document.querySelector('#myCanvas')
});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
function init(){
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.set(1,1,1000);
scene.add( camera );
const geometry = new THREE.BoxGeometry(400, 400, 400);
const material = new THREE.MeshNormalMaterial();
const box = new THREE.Mesh(geometry, material);
scene.add(box);
animate();
}
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment