-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
72 lines (48 loc) · 1.6 KB
/
index.js
File metadata and controls
72 lines (48 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// 1. Scene . 2 Mesh(Obejects) 3. Camera 4. Renderer
// Scene
const scene = new THREE.Scene();
// Mesh
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({color: "yellow"});
const mesh = new THREE.Mesh(geometry, material);
// Position (X , Y, Z)
// mesh.position.x = 1;
// mesh.position.y = -0.5;
// mesh.position.z = 1;
// Scale
// mesh.scale.x = 0.5;
// mesh.scale.y = 1.7;
// mesh.scale.set(0.5 , 1.7);
// Rotation
// mesh.rotation.x = Math.PI * 0.25;
// scene.add(mesh);
const geometryT = new THREE.BoxGeometry(1, 1, 1);
const materialT = new THREE.MeshBasicMaterial({color: "blue"});
const meshT = new THREE.Mesh(geometryT, materialT);
// Posicionando a meshT
meshT.position.y = 2;
// Criando um grupo e adicionando meshT
const Group = new THREE.Group();
Group.add(mesh, meshT);
Group.position.x = 1;
Group.position.y = -1;
// Adicionando o grupo à cena
scene.add(Group);
// scene.add(meshT);
// AxesHelper
const axesHelper = new THREE.AxesHelper(2);
scene.add(axesHelper);
// Camera
const aspect = {
width: window.innerWidth,
height: window.innerHeight
}
const camera = new THREE.PerspectiveCamera(75, aspect.width / aspect.height ) // near value is 1 , and for value is 2000
// Position (X , Y, Z)
camera.position.z = 4;
scene.add(camera)
// Renderer
const canvas = document.querySelector(".draw"); // slect the canvas element
const rederer = new THREE.WebGLRenderer({ canvas }); // add the WebGLRenderer
rederer.setSize( aspect.width, aspect.height); // Rederer size
rederer.render(scene, camera); // display what the camera in the scene patured