-
Notifications
You must be signed in to change notification settings - Fork 0
/
second.js
122 lines (108 loc) · 3.36 KB
/
second.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{
/* <script> */
}
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerWidth,
0.1,
1000
);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerWidth);
document.body.appendChild(renderer.domElement);
window.addEventListener("resize", function () {
var width = window.innerWidth;
var height = window.innerWidth;
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
});
controls = new THREE.OrbitControls(camera, renderer.domElement);
//create the shape
var geometry = new THREE.BoxGeometry(1.2, 1.2, 1.2);
var cubeMaterials = [
new THREE.MeshBasicMaterial({
map: new THREE.TextureLoader().load("img/Chol&Ryueae.png"),
side: THREE.DoubleSide, //Right Side
}),
new THREE.MeshBasicMaterial({
map: new THREE.TextureLoader().load("img/Chol.png"),
side: THREE.DoubleSide, //Left Side
}),
new THREE.MeshBasicMaterial({
map: new THREE.TextureLoader().load("img/eis.png"),
side: THREE.DoubleSide, //Top Side
}),
new THREE.MeshBasicMaterial({
map: new THREE.TextureLoader().load("img/mcrc.png"),
side: THREE.DoubleSide, //Bottom Side
}),
new THREE.MeshBasicMaterial({
map: new THREE.TextureLoader().load("img/Ryueae.png"),
side: THREE.DoubleSide, //Front Side
}),
new THREE.MeshBasicMaterial({
color: 0xffffff,
side: THREE.DoubleSide, //Back Side
}),
];
//create a amterial, color, or image texture
var material = new THREE.MeshFaceMaterial(cubeMaterials);
var cube = new THREE.Mesh(geometry, material);
scene.add(cube);
camera.position.z = 3;
// controls = new THREE.OrbitControls(camera, renderer.domElement);
// camera.position.z = 3;
// //create the shape
// //var geometry = new THREE.BoxGeometry(1.2, 1.2, 1.2);
// var geometry = new THREE.BoxGeometry(1000, 1000, 1000);
// var cubeMaterials = [
// new THREE.MeshBasicMaterial({
// map: new THREE.TextureLoader().load("img/px.jpg"), //
// side: THREE.DoubleSide, //Right Side
// }),
// new THREE.MeshBasicMaterial({
// map: new THREE.TextureLoader().load("img/nx.jpg"), //ok
// side: THREE.DoubleSide, //Left Side
// }),
// new THREE.MeshBasicMaterial({
// map: new THREE.TextureLoader().load("img/py.jpg"), //ok
// side: THREE.DoubleSide, //Top Side
// }),
// new THREE.MeshBasicMaterial({
// map: new THREE.TextureLoader().load("img/ny.jpg"), //
// side: THREE.DoubleSide, //Bottom Side
// }),
// new THREE.MeshBasicMaterial({
// map: new THREE.TextureLoader().load("img/pz.jpg"), //
// side: THREE.DoubleSide, //Front Side
// }),
// new THREE.MeshBasicMaterial({
// map: new THREE.TextureLoader().load("img/nz.jpg"), //
// side: THREE.DoubleSide, //Back Side
// }),
// ];
//create a material, color, or image texture
var cubeMaterial = new THREE.MeshFaceMaterial(cubeMaterials);
var cube = new THREE.Mesh(geometry, cubeMaterial);
scene.add(cube);
// var ambientLight = new THREE.ambientLight(0xffffff, 0.3);
// scene.add(ambientLight);
//Game logic
var update = function () {
// cube.rotation.x += 0.01;
// cube.rotation.y += 0.005;
};
//Draw scene
var render = function () {
renderer.render(scene, camera);
};
//run game loop(update, render, repeate)
var GameLoop = function () {
requestAnimationFrame(GameLoop);
update();
render();
};
GameLoop();
// </script>