Last active
May 23, 2020 06:54
-
-
Save flushpot1125/95f62f3c8e97d0e128bf220e08d7ff8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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