-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
333 lines (283 loc) · 12.1 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<!DOCTYPE html>
<html lang="en">
<head>
<title>luxe</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="style.css">
<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=Chivo+Mono:wght@500&display=swap" rel="stylesheet">
</head>
<body>
<div id="container"></div>
<!---->
<audio autoplay loop id="magenta_lofi">
<source src="https://raw.githubusercontent.com/amphinomid/luxe/main/assets/magenta_lofi.m4a" type="audio/mpeg">
</audio>
<audio autoplay loop id="meow">
<source src="https://raw.githubusercontent.com/amphinomid/luxe/main/assets/meow.m4a" type="audio/mpeg">
</audio>
<script>
var magenta_lofi = document.getElementById("magenta_lofi");
magenta_lofi.volume = 1;
var meow = document.getElementById("meow");
meow.volume = 0.5;
</script>
<!-- Import maps polyfill -->
<!-- Remove this when import maps will be widely supported -->
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/[email protected]/build/three.module.js",
"three/addons/": "https://unpkg.com/[email protected]/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { CSS3DRenderer, CSS3DObject } from 'three/addons/renderers/CSS3DRenderer.js';
let camera, controls, scene, css_scene, renderer, css_renderer;
let tv_image;
let ad1_src = 'https://raw.githubusercontent.com/amphinomid/luxe/main/assets/ad1.png';
let ad2_src = 'https://raw.githubusercontent.com/amphinomid/luxe/main/assets/ad2.png';
let ad3_src = 'https://raw.githubusercontent.com/amphinomid/luxe/main/assets/ad3.png';
const container = document.querySelector('#container');
// Configure and create Draco decoder.
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('decoder/');
dracoLoader.setDecoderConfig({ type: 'js' });
// Configure GLTF loader.
const gltfLoader = new GLTFLoader();
gltfLoader.setDRACOLoader(dracoLoader);
let render_requested = false;
init();
render();
//animate();
function init() {
camera = new THREE.PerspectiveCamera(35, window.innerWidth / window.innerHeight, 0.1, 15);
camera.position.set(-1, 1, 1);
camera.lookAt(0, 0, 0);
scene = new THREE.Scene();
scene.background = new THREE.Color(0x070112);
css_scene = new THREE.Scene();
// Lights
const hemiLight = new THREE.HemisphereLight(0xff1f71, 0xffffff, 0.4);
scene.add(hemiLight);
const spotLight = new THREE.SpotLight();
spotLight.intensity = 0.25;
spotLight.angle = Math.PI / 8;
spotLight.penumbra = 0.5;
spotLight.castShadow = true;
spotLight.position.set(-1, 1, 1);
scene.add(spotLight);
// Audio
/* // Positional audio doesn't work consistently; switching to HTML5 audio for now
const listener = new THREE.AudioListener();
camera.add(listener);
const audioLoader = new THREE.AudioLoader();
*/
gltfLoader.load('https://raw.githubusercontent.com/amphinomid/luxe/main/assets/room.glb', function (room) {
room.scene.scale.set(0.1, 0.1, 0.1);
scene.add(room.scene);
render();
});
/*
const cat_sound = new THREE.PositionalAudio(listener);
audioLoader.load('https://raw.githubusercontent.com/amphinomid/luxe/main/assets/meow.m4a', function (cat_buffer) {
cat_sound.setBuffer(cat_buffer);
cat_sound.setLoop(true);
cat_sound.setRefDistance(1);
cat_sound.setVolume(1);
cat_sound.play();
});
*/
gltfLoader.load('https://raw.githubusercontent.com/amphinomid/luxe/main/assets/cat.glb', function (cat) {
cat.scene.scale.set(0.1, 0.1, 0.1);
/*
var cat_obj = cat.scene.getObjectByName('cat_nose');
var cat_mesh = new THREE.Mesh(cat_obj.geometry, cat_obj.material);
cat_mesh.add(cat_sound);
*/
scene.add(cat.scene);
});
const mirror_text = document.createElement('div');
mirror_text.id = 'mirror_text';
mirror_text.textContent = 'body scan mode';
mirror_text.style.fontSize = '1rem';
mirror_text.style.color = '#fff';
mirror_text.style.textShadow = '-0.1rem -0.1rem 0.5rem #fff, 0.1rem 0.1rem 0.5rem #fff, 0 0 2rem #63cf8b, 0 0 4rem #63cf8b, 0 0 6rem #63cf8b';
mirror_text.style.webkitUserSelect = 'none';
mirror_text.style.userSelect = 'none';
const mirror_text_CSS = new CSS3DObject(mirror_text);
mirror_text_CSS.scale.set(0.0004, 0.0004, 0.0004);
mirror_text_CSS.position.set(0.23, 0.325, 0.3715);
mirror_text_CSS.lookAt(0, 0.325, 0.3715);
css_scene.add(mirror_text_CSS);
gltfLoader.load('https://raw.githubusercontent.com/amphinomid/luxe/main/assets/mirror.glb', function (mirror) {
mirror.scene.scale.set(0.1, 0.1, 0.1);
var mirror_obj = mirror.scene.getObjectByName('mirror');
mirror_obj.material = new THREE.MeshPhysicalMaterial({
clearcoat: 1,
opacity: 0,
reflectivity: 1,
transmission: 1,
})
scene.add(mirror.scene);
});
const monitor_text = document.createElement('div');
monitor_text.id = 'monitor_text';
monitor_text.innerHTML = 'WARNING: CHEATING<br><br>Keep your face<br>in view of your webcam.';
monitor_text.style.fontSize = '1rem';
monitor_text.style.color = '#f00';
monitor_text.style.textAlign = 'center';
monitor_text.style.backgroundColor = '#fff';
monitor_text.style.padding = '10px';
monitor_text.style.webkitUserSelect = 'none';
monitor_text.style.userSelect = 'none';
const monitor_text_CSS = new CSS3DObject(monitor_text);
monitor_text_CSS.scale.set(0.0005, 0.0005, 0.0005);
monitor_text_CSS.position.set(-0.13, 0.22, -0.215);
monitor_text_CSS.lookAt(-0.165, 0.275, 0.01);
css_scene.add(monitor_text_CSS);
gltfLoader.load('https://raw.githubusercontent.com/amphinomid/luxe/main/assets/monitor_screen.glb', function (monitor) {
monitor.scene.scale.set(0.1, 0.1, 0.1);
scene.add(monitor.scene);
});
/*
const speaker_sound = new THREE.PositionalAudio(listener);
audioLoader.load('https://raw.githubusercontent.com/amphinomid/luxe/main/assets/magenta_lofi.m4a', function (speaker_buffer) {
speaker_sound.setBuffer(speaker_buffer);
speaker_sound.setLoop(true);
speaker_sound.setRefDistance(1);
speaker_sound.setVolume(0.5);
speaker_sound.play();
});
*/
gltfLoader.load('https://raw.githubusercontent.com/amphinomid/luxe/main/assets/speaker.glb', function (speaker) {
speaker.scene.scale.set(0.1, 0.1, 0.1);
/*
var speaker_obj = speaker.scene.getObjectByName('speaker');
var speaker_mesh = new THREE.Mesh(speaker_obj.geometry, speaker_obj.material);
speaker_mesh.add(speaker_sound);
*/
scene.add(speaker.scene);
});
gltfLoader.load('https://raw.githubusercontent.com/amphinomid/luxe/main/assets/table_top.glb', function (table_top) {
table_top.scene.scale.set(0.1, 0.1, 0.1);
var table_top_obj = table_top.scene.getObjectByName('table_top');
table_top_obj.material = new THREE.MeshPhysicalMaterial({
roughness: 0.4,
transmission: 1,
});
scene.add(table_top.scene);
});
let tablet_image = document.createElement('img');
tablet_image.id = 'tv_image';
tablet_image.src = 'https://raw.githubusercontent.com/amphinomid/luxe/main/assets/doorbell_cam.png';
const tablet_image_CSS = new CSS3DObject(tablet_image);
tablet_image_CSS.scale.set(0.0000275, 0.0000275, 0.0000275);
tablet_image_CSS.position.set(-0.211, 0.14275, -0.166);
tablet_image_CSS.lookAt(-0.211, 1, -0.166);
tablet_image_CSS.rotateZ(10 * Math.PI / 180);
css_scene.add(tablet_image_CSS);
gltfLoader.load('https://raw.githubusercontent.com/amphinomid/luxe/main/assets/tablet.glb', function (tablet) {
tablet.scene.scale.set(0.1, 0.1, 0.1);
scene.add(tablet.scene);
});
tv_image = document.createElement('img');
tv_image.id = 'tv_image';
tv_image.src = ad1_src;
const tv_image_CSS = new CSS3DObject(tv_image);
tv_image_CSS.scale.set(0.0002, 0.0002, 0.0002);
tv_image_CSS.position.set(0.23, 0.325, 0.205);
tv_image_CSS.lookAt(0, 0.325, 0.205);
css_scene.add(tv_image_CSS);
gltfLoader.load('https://raw.githubusercontent.com/amphinomid/luxe/main/assets/tv.glb', function (tv) {
tv.scene.scale.set(0.1, 0.1, 0.1);
scene.add(tv.scene);
});
let about_link = document.createElement('a');
about_link.href = 'https://github.com/amphinomid/luxe/blob/main/README.md';
about_link.textContent = 'about';
about_link.style.fontSize = '1rem';
about_link.style.color = '#fff';
about_link.style.textShadow = '-0.1rem -0.1rem 0.5rem #fff, 0.1rem 0.1rem 0.5rem #fff, 0 0 2rem #0035c7, 0 0 4rem #0035c7, 0 0 6rem #0035c7';
about_link.addEventListener('pointerdown', () => { window.location.href = 'https://github.com/amphinomid/luxe/blob/main/README.md'; });
const about_link_CSS = new CSS3DObject(about_link);
about_link_CSS.scale.set(0.0015, 0.0015, 0.0015);
about_link_CSS.position.set(-0.1, 0.45, -0.23);
about_link_CSS.lookAt(-0.1, 0.45, 0);
css_scene.add(about_link_CSS);
let source_link = document.createElement('a');
source_link.href = 'https://github.com/amphinomid/luxe';
source_link.textContent = 'source';
source_link.style.fontSize = '1rem';
source_link.style.color = '#fff';
source_link.style.textShadow = '-0.1rem -0.1rem 0.5rem #fff, 0.1rem 0.1rem 0.5rem #fff, 0 0 2rem #0035c7, 0 0 4rem #0035c7, 0 0 6rem #0035c7';
source_link.addEventListener('pointerdown', () => { window.location.href = 'https://github.com/amphinomid/luxe'; });
const source_link_CSS = new CSS3DObject(source_link);
source_link_CSS.scale.set(0.0015, 0.0015, 0.0015);
source_link_CSS.position.set(0.23, 0.45, 0.1);
source_link_CSS.lookAt(0, 0.45, 0.1);
css_scene.add(source_link_CSS);
// renderer
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputEncoding = THREE.sRGBEncoding;
renderer.shadowMap.enabled = true;
container.appendChild(renderer.domElement);
// CSS renderer
css_renderer = new CSS3DRenderer();
css_renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(css_renderer.domElement);
// controls
controls = new OrbitControls(camera, css_renderer.domElement);
controls.listenToKeyEvents(window);
controls.addEventListener('change', requestRenderIfNotRequested);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
controls.screenSpacePanning = false;
controls.maxPolarAngle = Math.PI / 2;
window.addEventListener('resize', onWindowResize);
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
css_renderer.setSize(window.innerWidth, window.innerHeight);
}
function animate() {
requestAnimationFrame(animate);
controls.update();
render();
}
function render() {
render_requested = false;
const timer = Date.now();
const modulo_30 = timer % 15000;
if (modulo_30 < 5000) {
tv_image.src = ad1_src;
} else if (modulo_30 < 10000) {
tv_image.src = ad2_src;
} else {
tv_image.src = ad3_src;
}
controls.update();
renderer.render(scene, camera);
css_renderer.render(css_scene, camera);
}
function requestRenderIfNotRequested() {
if (!render_requested) {
render_requested = true;
requestAnimationFrame(render);
}
}
</script>
</body>
</html>