質問編集履歴

1

コードの追加

2019/09/19 06:01

投稿

mukuta0111
mukuta0111

スコア18

test CHANGED
File without changes
test CHANGED
@@ -17,3 +17,79 @@
17
17
 
18
18
 
19
19
  Three.js で3Dを作るときには必ず使用するという理解の仕方で大丈夫ですか??
20
+
21
+
22
+
23
+
24
+
25
+ ```
26
+
27
+ <script>
28
+
29
+ window.addEventListener('load', init);
30
+
31
+
32
+
33
+ function init() {
34
+
35
+
36
+
37
+ const width = 960;
38
+
39
+ const height = 540;
40
+
41
+
42
+
43
+ const renderer = new THREE.WebGLRenderer({
44
+
45
+ canvas: document.querySelector('#myCanvas')
46
+
47
+ });
48
+
49
+ renderer.setPixelRatio(window.devicePixelRatio);
50
+
51
+ renderer.setSize(width, height);
52
+
53
+
54
+
55
+ const scene = new THREE.Scene();
56
+
57
+
58
+
59
+ const camera = new THREE.PerspectiveCamera(45, width / height);
60
+
61
+ camera.position.set(0, 0, +1000);
62
+
63
+
64
+
65
+ const geometry = new THREE.BoxGeometry(400, 400, 400);
66
+
67
+ const material = new THREE.MeshNormalMaterial();
68
+
69
+ const box = new THREE.Mesh(geometry, material);
70
+
71
+ scene.add(box);
72
+
73
+
74
+
75
+ tick();
76
+
77
+
78
+
79
+ function tick() {
80
+
81
+ box.rotation.y += 0.01;
82
+
83
+ renderer.render(scene, camera);
84
+
85
+
86
+
87
+ requestAnimationFrame(tick);
88
+
89
+ }
90
+
91
+ }
92
+
93
+ </script>
94
+
95
+ ```