-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·170 lines (142 loc) · 5.71 KB
/
index.html
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="Your description goes here">
<meta name="keywords" content="one, two, three">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:image" content="https://fortunewill.glitch.me/FWthumb-min.png" />
<link rel="icon" type="image/png" href="FW.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lobster&family=Oleo+Script+Swash+Caps:wght@700&family=Raleway:wght@200;300;600;700;800&display=swap" rel="stylesheet">
<title>FortuneWill</title>
<!-- external CSS link -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!-- TITLE -->
<header class="">
<h1 class="cursive-font">FortuneWill</h1>
</header>
<!-- MAIN PAGE -->
<main class="">
<!-- HOME SCREEN -->
<section class="home">
<!-- 3D MODEL -->
<section class="threeD-model">
</section>
<!-- ENTRY/RESPONSE SECTION -->
<section class="intro card-black">
<!-- ENTRY SCREEN -->
<section class="entry-screen">
<h2 class="cursive-font">What question does your heart seek to answer?</h2>
<p class="instructions">Ask Zoltar any yes or no question.</p>
<p class="example">'Will I be happy in 5 years?'</p>
<p class="error-box"></p>
<form class="question-form" onkeydown="return event.key != 'Enter';" action="">
<input class="question-input" type="text" placeholder="Enter question">
<button type="button" class="fortune-btn purple-btn">Get My Fortune</button>
</form>
</section>
<!-- RESPONSE SCREEN -->
<section class="response-screen hidden">
<h2 class="question cursive-font"></h2>
<h3 class="answer"></h3>
<button class="new-question purple-btn">New Question</button>
</section>
</section>
<!-- PAST FORTUNES SECTION -->
<section class="past-fortunes">
</section>
</section>
</main>
<footer>
Built by
<a href="https://github.com/tdo95">Tee O.</a> |
3D Models:
<a href="https://sketchfab.com/3d-models/fortune-teller-2b875c75e4ee429cbf3b0ba9e39188ca">Zoltar - Duznot</a>
<a href="https://polyhaven.com/a/sepulchral_chapel_rotunda">Lighting - Andreas Mischok</a>
</footer>
<script type="text/javascript" src="js/main.js"></script>
<script src="js/three.js"></script>
<script src="js/DRACOLoader.js"></script>
<script src="js/GLTFLoader.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/RGBELoader.js"></script>
<script>
let threeDBox = document.querySelector('.threeD-model');
//tool three.js uses to allocate a space (create canvas) on webpage for adding and animating 3d model
const renderer = new THREE.WebGLRenderer({antialias: true});
//sets the size of that canvas
renderer.setSize(threeDBox.offsetWidth,threeDBox.offsetHeight);
//injects canvas into the dom
threeDBox.appendChild(renderer.domElement);
//create scene
const scene = new THREE.Scene();
//create camera
const camera = new THREE.PerspectiveCamera(
75,
threeDBox.offsetWidth / threeDBox.offsetHeight,
0.1,
1000
);
//allows click and rotate functionality
let orbit = new THREE.OrbitControls(camera, renderer.domElement);
orbit.enableZoom = false;
orbit.update();
// //include helper - coordinate guide, the 3 represents the length of the axis
// const axesHelper = new THREE.AxesHelper(3);
// //add axis helper to scene
// scene.add(axesHelper);
//move camera backwards
camera.position.set(0,0,8);
let clock = new THREE.Clock();
//set background to clear
renderer.setClearColor( 0x000000, 0);
// set tone mapping properties for lighting environment
renderer.outputEncoding = THREE.sRGBEncoding;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 2.5;
//import models and environment lighting
let zoltar; //global varaible for model so we can apply animation
let ball;
const gltfLoader = new THREE.GLTFLoader();
const rgbeLoader = new THREE.RGBELoader();
// Optional: Provide a DRACOLoader instance to decode compressed mesh data
const dracoLoader = new THREE.DRACOLoader();
dracoLoader.setDecoderPath( '/js/draco/' );
gltfLoader.setDRACOLoader( dracoLoader );
rgbeLoader.load('./js/sepulchral_chapel_rotunda_1k.hdr', function(texture) {
texture.mapping = THREE.EquirectangularReflectionMapping;
scene.environment = texture;
gltfLoader.load('./js/fortune_teller.glb', function(gltf) {
const model = gltf.scene;
model.position.y = -4.2;
model.position.x = window.innerWidth > 960 ? 1 : 0;
model.rotation.x = .2;
// model.rotateZ(-.8)
model.scale.set(.006,.006,.006)
scene.add(model);
zoltar = model;
})
});
function animate() {
const time = clock.getElapsedTime();
if (zoltar) {
zoltar.position.y = -4.2 + (Math.cos( time ) * 0.2);
}
//link the scene and camera within the renderer (canvas)
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
//makes animation responsive
window.addEventListener('resize', function() {
camera.aspect = threeDBox.offsetWidth / threeDBox.offsetHeight;
camera.updateProjectionMatrix();
renderer.setSize(threeDBox.offsetWidth, threeDBox.offsetHeight);
});
</script>
</body>
</html>