-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday.js
More file actions
75 lines (56 loc) · 1.95 KB
/
day.js
File metadata and controls
75 lines (56 loc) · 1.95 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
73
74
75
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.lookAt(0, 0, 0);
const renderer = new THREE.WebGLRenderer();
const controls = new THREE.OrbitControls(camera, renderer.domElement);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// lights
const light = new THREE.AmbientLight("white", 0.4);
light.position.set(50, 50, 50);
const light2 = new THREE.PointLight("white", 1, 1000);
light2.position.set(-50, -50, -50);
const light3 = new THREE.PointLight("white", 1, 1000);
light2.position.set(50, -50, 50);
// geometry
const geometry = new THREE.SphereGeometry(0.7);
geometry.translate(1, 1, 1);
const geometry2 = new THREE.BoxGeometry(0.9, 0.9, 0.9);
geometry2.translate(2.5, 1.5, 1.5);
const geometry3 = new THREE.BoxGeometry(0.5, 0.5, 0.5);
geometry3.translate(0.1, 0.2, 0);
// textures
const myTextureLoader = new THREE.TextureLoader();
let myTexture;
myTexture = myTextureLoader.load('../images/1.jpg');
const material = new THREE.MeshPhongMaterial({
map: myTexture
});
myTexture = myTextureLoader.load('../images/2.jpg');
const material2 = new THREE.MeshPhongMaterial({
map: myTexture
});
myTexture = myTextureLoader.load('../images/3.jpg');
const material3 = new THREE.MeshPhongMaterial({
map: myTexture
});
// compose
const shape = new THREE.Mesh(geometry, material);
const shape2 = new THREE.Mesh(geometry2, material2);
const shape3 = new THREE.Mesh(geometry3, material3);
scene.add(shape, shape2, shape3);
camera.position.z = 5;
scene.add(light, light2, light3);
const animate = () => {
requestAnimationFrame(animate)
controls.update()
shape.rotation.x += 0.0025;
shape.rotation.y += 0.0025;
shape2.rotation.x -= 0.005;
shape2.rotation.y -= 0.005;
shape3.rotation.x -= 0.01;
shape3.rotation.y -= 0.01;
renderer.render(scene, camera);
};
animate();