質問するログイン新規登録

質問編集履歴

1

コードの追加

2019/09/19 06:01

投稿

mukuta0111
mukuta0111

スコア18

title CHANGED
File without changes
body CHANGED
@@ -7,4 +7,42 @@
7
7
  ということ分かったのですが、
8
8
  初期化とは具体的にどういうことでしょうか。
9
9
 
10
- Three.js で3Dを作るときには必ず使用するという理解の仕方で大丈夫ですか??
10
+ Three.js で3Dを作るときには必ず使用するという理解の仕方で大丈夫ですか??
11
+
12
+
13
+ ```
14
+ <script>
15
+ window.addEventListener('load', init);
16
+
17
+ function init() {
18
+
19
+ const width = 960;
20
+ const height = 540;
21
+
22
+ const renderer = new THREE.WebGLRenderer({
23
+ canvas: document.querySelector('#myCanvas')
24
+ });
25
+ renderer.setPixelRatio(window.devicePixelRatio);
26
+ renderer.setSize(width, height);
27
+
28
+ const scene = new THREE.Scene();
29
+
30
+ const camera = new THREE.PerspectiveCamera(45, width / height);
31
+ camera.position.set(0, 0, +1000);
32
+
33
+ const geometry = new THREE.BoxGeometry(400, 400, 400);
34
+ const material = new THREE.MeshNormalMaterial();
35
+ const box = new THREE.Mesh(geometry, material);
36
+ scene.add(box);
37
+
38
+ tick();
39
+
40
+ function tick() {
41
+ box.rotation.y += 0.01;
42
+ renderer.render(scene, camera);
43
+
44
+ requestAnimationFrame(tick);
45
+ }
46
+ }
47
+ </script>
48
+ ```