-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
637 lines (548 loc) · 25.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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
<!DOCTYPE html>
<html>
<head>
<title>Tesseract Explorer</title>
<meta name="description" content="Explore a 4-dimensional tesseract in WebGL!">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="img/tesseract-16x16.png">
<meta property="og:image" content="https://tsherif.github.io/tesseract-explorer/img/tesseract-512x512.png">
<meta name="twitter:card" content="summary">
<meta name="twitter:creator" content="@thsherif">
<meta name="twitter:title" content="Tesseract Explorer">
<meta name="twitter:description" content="Explore a 4-dimensional tesseract in WebGL!">
<meta name="twitter:image" content="https://tsherif.github.io/tesseract-explorer/img/tesseract-512x512.png">
<link rel="stylesheet" type="text/css" href="css/styles.css">
<script src="lib/gl-matrix.js"></script>
<script src="lib/picogl.min.js"></script>
<script src="lib/dat.gui.min.js"></script>
</head>
<!--
The MIT License (MIT)
Copyright (c) 2020 Tarek Sherif
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<body>
<div id="info">
<h3>
Tesseract Explorer
</h3>
<div class="paragraph">
By <a href="https://twitter.com/thsherif" target="_blank">Tarek Sherif</a>
</div>
<div id="no-webgl2" class="paragraph">
Oh no! This browser doesn't support WebGL 2! You can read about the tesseract here, but you'll need the latest version of Chrome, Firefox or Edge on desktop or Android to use the Explorer!
</div>
<div class="paragraph">
Welcome to the 4<sup>th</sup> dimension! The controls on the right will manipulate the tesseract in 4D space, and you can explore its 3D projection by clicking and dragging with your mouse. To get you started, a favorite view of mine is cutout rendering, orthographic projection, and 45 degree rotations in the XW, YW, and ZW planes.
</div>
<div id="more-info-button">
Show Details
</div>
<div id="more-info">
<div class="paragraph">
A <a href="https://en.wikipedia.org/wiki/Tesseract" target="_blank">tesseract</a> is also known as a hypercube or 8-cell. It is the 4D analog to the 2D square and the 3D cube. Its 3D "surface" is composed of 8 cubes, which enclose a 4D hypervolume. What is rendered here is not the actual tesseract, but its projection into 3D space in a process similar to photographing a 3D world onto 2D camera film.
</div>
<div class="paragraph">
More information on 4D projections and descriptions of the available controls are provided in the <a href="https://github.com/tsherif/tesseract-explorer#tesseract-explorer" target="_blank">documentation</a>.
</div>
</div>
</div>
<canvas id="gl-canvas"></canvas>
<script type="module">
import { webgl2Test } from "./js/utils.js";
import {
createTesseract,
createTesseractProjections,
createTesseractUVProjections,
TESSERACT_BASE_UVS,
TESSERACT_UNFOLD_TRANSFORMS
} from "./js/tesseract.js";
import {
rotateXY, rotateCellXY,
rotateXZ, rotateCellXZ,
rotateXW, rotateCellXW,
rotateYZ, rotateCellYZ,
rotateYW, rotateCellYW,
rotateZW, rotateCellZW,
scale,
unfold,
perspectiveProjection,
orthographicProjection
} from "./js/transform4D.js";
import {
vsTesseract,
vsScreenQuad,
fsTransparent,
fsOpaque,
fsShadow,
fsOIT
} from "./js/shaders.js";
import {
updateNearFar,
orbitCamera,
zoomCamera
} from "./js/camera-utils.js";
import { setupInteractions } from "./js/interactions.js";
//////////////////////////
// CONSTANTS AND SETTINGS
//////////////////////////
const RADIANS = Math.PI / 180;
const FOCAL_LENGTH = 2;
const CAMERA_W_OFFSET = 3;
const MAX_ZOOM = 7;
const MIN_ZOOM = 0.1;
// To reduce aliasing in OIT
const SSAA_MULTIPLIER = 2;
const COLORS_AXIS = {
posX: new Float32Array([0.86, 0.08, 0.24]),
negX: new Float32Array([0.86, 0.08, 0.24]),
posY: new Float32Array([0.2, 0.8, 0.2]),
negY: new Float32Array([0.2, 0.8, 0.2]),
posZ: new Float32Array([0.12, 0.56, 1]),
negZ: new Float32Array([0.12, 0.56, 1]),
posW: new Float32Array([1, 0.84, 0.01]),
negW: new Float32Array([1, 0.84, 0.01])
};
const COLORS_CELL = {
posX: new Float32Array([0.86, 0.08, 0.24]),
negX: new Float32Array([0.80, 0.36, 0.36]),
posY: new Float32Array([0.2, 0.8, 0.2]),
negY: new Float32Array([0.21, 0.98, 0.80]),
posZ: new Float32Array([0.12, 0.56, 1]),
negZ: new Float32Array([0.69, 0.88, 0.90]),
posW: new Float32Array([1, 0.84, 0.01]),
negW: new Float32Array([1, 1, 0.5])
};
const QUAD_POSITIONS = new Float32Array([
-1, -1,
1, -1,
-1, 1,
1, 1,
]);
let imageDirty = true;
let transformDirty = false;
const settings = {
projection: "perspective",
rendering: "transparent",
colorization: "axis",
unfold: 0,
rotations: {
xy: 0,
xz: 0,
xw: 0,
yz: 0,
yw: 0,
zw: 0
},
autoRotations: {
xy: false,
xz: false,
xw: false,
yz: false,
yw: false,
zw: false
},
scales: {
x: 1,
y: 1,
z: 1,
w: 1
},
visibility: {
"posX": true,
"negX": true,
"posY": true,
"negY": true,
"posZ": true,
"negZ": true,
"posW": true,
"negW": true
},
reset: {
rotation() {
for (const plane in settings.rotations) {
settings.rotations[plane] = 0;
}
transformDirty = true;
imageDirty = true;
},
scale() {
for (const axis in settings.scales) {
settings.scales[axis] = 1;
}
transformDirty = true;
imageDirty = true;
},
visibility() {
for (const direction in settings.visibility) {
settings.visibility[direction] = true;
}
imageDirty = true;
}
}
};
const setImageDirty = () => {
imageDirty = true;
};
const setTransformDirty = () => {
imageDirty = true;
transformDirty = true;
};
const gui = new dat.GUI();
gui.add(settings, "rendering", ["transparent", "cutout", "solid"]).name("Rendering").onChange(setImageDirty);
gui.add(settings, "projection", ["perspective", "orthographic"]).name("Projection").onChange(setTransformDirty);
gui.add(settings, "colorization", ["axis", "cell"]).name("Colorization").onChange(setImageDirty);
gui.add(settings, "unfold", 0, 1).step(0.01).name("Unfold").onChange(setTransformDirty);
const rotationFolder = gui.addFolder("Rotate")
rotationFolder.add(settings.rotations, "xw", 0, 360).name("XW").listen().onChange(setTransformDirty);
rotationFolder.add(settings.rotations, "yw", 0, 360).name("YW").listen().onChange(setTransformDirty);
rotationFolder.add(settings.rotations, "zw", 0, 360).name("ZW").listen().onChange(setTransformDirty);
rotationFolder.add(settings.rotations, "xy", 0, 360).name("XY").listen().onChange(setTransformDirty);
rotationFolder.add(settings.rotations, "xz", 0, 360).name("XZ").listen().onChange(setTransformDirty);
rotationFolder.add(settings.rotations, "yz", 0, 360).name("YZ").listen().onChange(setTransformDirty);
rotationFolder.add(settings.reset, "rotation").name("Reset Rotation").onChange(setTransformDirty);
rotationFolder.open();
const autoRotationFolder = gui.addFolder("Autorotate")
autoRotationFolder.add(settings.autoRotations, "xw").name("XW");
autoRotationFolder.add(settings.autoRotations, "yw").name("YW");
autoRotationFolder.add(settings.autoRotations, "zw").name("ZW");
autoRotationFolder.add(settings.autoRotations, "xy").name("XY");
autoRotationFolder.add(settings.autoRotations, "xz").name("XZ");
autoRotationFolder.add(settings.autoRotations, "yz").name("YZ");
const scaleFolder = gui.addFolder("Scale")
scaleFolder.add(settings.scales, "x", 0, 1).name("X").step(0.01).listen().onChange(setTransformDirty);
scaleFolder.add(settings.scales, "y", 0, 1).name("Y").step(0.01).listen().onChange(setTransformDirty);
scaleFolder.add(settings.scales, "z", 0, 1).name("Z").step(0.01).listen().onChange(setTransformDirty);
scaleFolder.add(settings.scales, "w", 0, 1).name("W").step(0.01).listen().onChange(setTransformDirty);
scaleFolder.add(settings.reset, "scale").name("Reset Scale").onChange(setTransformDirty);
const visibilityFolder = gui.addFolder("Cell Visibility");
visibilityFolder.add(settings.visibility, "posX").name("Positive X").listen().onChange(setImageDirty);
visibilityFolder.add(settings.visibility, "negX").name("Negative X").listen().onChange(setImageDirty);
visibilityFolder.add(settings.visibility, "posY").name("Positive Y").listen().onChange(setImageDirty);
visibilityFolder.add(settings.visibility, "negY").name("Negative Y").listen().onChange(setImageDirty);
visibilityFolder.add(settings.visibility, "posZ").name("Positive Z").listen().onChange(setImageDirty);
visibilityFolder.add(settings.visibility, "negZ").name("Negative Z").listen().onChange(setImageDirty);
visibilityFolder.add(settings.visibility, "posW").name("Positive W").listen().onChange(setImageDirty);
visibilityFolder.add(settings.visibility, "negW").name("Negative W").listen().onChange(setImageDirty);
visibilityFolder.add(settings.reset, "visibility").name("Reset Visibility").onChange(setImageDirty);
const moreInfoPanel = document.getElementById("more-info");
document.getElementById("more-info-button").addEventListener("click", e => {
if (moreInfoPanel.clientWidth === 0) {
moreInfoPanel.style.display = "block";
e.target.innerText = "Hide Details"
} else {
moreInfoPanel.style.display = "none";
e.target.innerText = "Show Details"
}
});
/////////////
// APP SETUP
/////////////
const canvas = document.getElementById("gl-canvas");
if (!webgl2Test(canvas, ["EXT_color_buffer_float"])) {
document.getElementById("no-webgl2").style.display = "block";
}
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const app = PicoGL.createApp(canvas)
.clearColor(0.0, 0.0, 0.0, 1.0)
.enable(PicoGL.POLYGON_OFFSET_FILL);
const projMatrixParameters = {
fov: Math.PI / 3,
aspect: canvas.width / canvas.height,
near: 1,
far: 10
};
const projMatrix = mat4.perspective(mat4.create(),
projMatrixParameters.fov,
projMatrixParameters.aspect,
projMatrixParameters.near,
projMatrixParameters.far
);
const eye = new Float32Array([-3, 1.5, 5]);
const look = new Float32Array([0, 0, 0]);
const up = new Float32Array([0, 1, 0]);
const viewMatrix = mat4.lookAt(mat4.create(), eye, look, up);
const inverseViewMatrix = mat4.invert(mat4.create(), viewMatrix);
const lightPosition = new Float32Array([2, 2, 0]);
const shadowEyePosition = vec3.transformMat4(vec3.create(), lightPosition, inverseViewMatrix);
const shadowViewMatrix = mat4.lookAt(mat4.create(), shadowEyePosition, look, up);
app.createPrograms([vsTesseract, fsTransparent], [vsTesseract, fsOpaque], [vsTesseract, fsShadow], [vsScreenQuad, fsOIT]).then(([transparentProgram, opaqueProgram, shadowProgram, oitProgram]) => {
//////////////////////////
// OIT FRAMEBUFFERS
//////////////////////////
const oitTarget = app.createTexture2D(app.width * SSAA_MULTIPLIER, app.height * SSAA_MULTIPLIER, {
internalFormat: PicoGL.RGBA16F,
minFilter: PicoGL.LINEAR,
magFilter: PicoGL.LINEAR
});
const oitAlphaTarget = app.createTexture2D(app.width * SSAA_MULTIPLIER, app.height * SSAA_MULTIPLIER, {
internalFormat: PicoGL.RGBA16F,
minFilter: PicoGL.LINEAR,
magFilter: PicoGL.LINEAR
});
const oitBuffer = app.createFramebuffer()
.colorTarget(0, oitTarget)
.colorTarget(1, oitAlphaTarget);
////////////////////////////
// SHADOW FRAMEBUFFER
///////////////////////////
const shadowDepthTarget = app.createTexture2D(app.width, app.height, {
internalFormat: PicoGL.DEPTH_COMPONENT32F,
compareMode: PicoGL.COMPARE_REF_TO_TEXTURE
});
const shadowBuffer = app.createFramebuffer()
.depthTarget(shadowDepthTarget);
///////////////////////
// GEOMETRY
///////////////////////
const tesseract = createTesseract();
const uvProjections = createTesseractUVProjections();
const transformedTesseractA = createTesseract();
const transformedTesseractB = createTesseract();
const tesseractProjecton = createTesseractProjections(transformedTesseractA);
const sceneBoundary = {
min: new Float32Array(3),
max: new Float32Array(3)
};
perspectiveProjection(transformedTesseractA, CAMERA_W_OFFSET, FOCAL_LENGTH, tesseractProjecton, uvProjections, sceneBoundary);
const objects = new Array(8);
const uvs = app.createVertexBuffer(PicoGL.FLOAT, 2, TESSERACT_BASE_UVS);
["posW", "posX", "posY", "posZ", "negX", "negY", "negZ", "negW"].forEach((direction, i) => {
const positions = app.createVertexBuffer(PicoGL.FLOAT, 3, tesseractProjecton[direction]);
const uvFactors = app.createVertexBuffer(PicoGL.FLOAT, 1, uvProjections[direction]);
const vao = app.createVertexArray()
.vertexAttributeBuffer(0, positions)
.vertexAttributeBuffer(1, uvs)
.vertexAttributeBuffer(2, uvFactors);
const transparentDrawCall = app.createDrawCall(transparentProgram, vao)
.uniform("lightPosition", lightPosition);
const opaqueDrawCall = app.createDrawCall(opaqueProgram, vao)
.uniform("lightPosition", lightPosition)
.texture("shadowMap", shadowDepthTarget);
const shadowDrawCall = app.createDrawCall(shadowProgram, vao);
objects[i] = {
direction,
positions,
uvFactors,
vao,
transparentDrawCall,
opaqueDrawCall,
shadowDrawCall
}
});
const quadData = QUAD_POSITIONS;
const quadPositions = app.createVertexBuffer(PicoGL.FLOAT, 2, quadData);
const quadVAO = app.createVertexArray()
.vertexAttributeBuffer(0, quadPositions);
const oitDrawcall = app.createDrawCall(oitProgram, quadVAO)
.primitive(PicoGL.TRIANGLE_STRIP)
.texture("oitColor", oitTarget)
.texture("oitAlpha", oitAlphaTarget);
/////////////////
// INTERACTIONS
/////////////////
const DRAG_SCALE = 0.01;
const WHEEL_SCALE = 0.11;
const PINCH_SCALE = 0.05;
let zoom = vec3.length(vec3.subtract([], eye, look));
setupInteractions(canvas, {
onDrag: (dx, dy) => {
orbitCamera(eye, look, up, -dx * DRAG_SCALE, -dy * DRAG_SCALE);
imageDirty = true;
},
onWheel: d => {
zoom += d * WHEEL_SCALE;
zoom = Math.max(MIN_ZOOM, Math.min(zoom, MAX_ZOOM));
zoomCamera(eye, look, zoom);
imageDirty = true;
},
onPinch: d => {
zoom += d * PINCH_SCALE;
zoom = Math.max(MIN_ZOOM, Math.min(zoom, MAX_ZOOM));
zoomCamera(eye, look, zoom);
imageDirty = true;
}
});
window.addEventListener("resize", () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
app.resize(canvas.width, canvas.height);
oitBuffer.resize(app.width * SSAA_MULTIPLIER, app.height * SSAA_MULTIPLIER);
shadowBuffer.resize();
imageDirty = true;
});
/////////////////
// RENDER LOOP
/////////////////
let lastTime = performance.now();
function draw() {
requestAnimationFrame(draw);
const currentTime = performance.now();
const timeElapsed = Math.min(currentTime - lastTime, 100);
lastTime = currentTime;
const {rotations, autoRotations} = settings;
for (const plane in autoRotations) {
if (autoRotations[plane]) {
rotations[plane] = (rotations[plane] + 0.02 * timeElapsed) % 360;
transformDirty = true;
imageDirty = true;
}
}
if (!imageDirty) {
return;
}
imageDirty = false;
const transparent = settings.rendering === "transparent";
const cutout = settings.rendering === "cutout";
const colors = settings.colorization === "axis" ? COLORS_AXIS : COLORS_CELL;
mat4.lookAt(viewMatrix, eye, look, up);
mat4.invert(inverseViewMatrix, viewMatrix);
vec3.transformMat4(shadowEyePosition, lightPosition, inverseViewMatrix);
mat4.lookAt(shadowViewMatrix, shadowEyePosition, look, up);
if (transformDirty) {
updateTransform(tesseract, transformedTesseractA, transformedTesseractB, tesseractProjecton, uvProjections, objects, settings, sceneBoundary);
transformDirty = false;
}
projMatrixParameters.aspect = canvas.width / canvas.height;
updateNearFar(sceneBoundary, [viewMatrix, shadowViewMatrix], projMatrixParameters);
mat4.perspective(projMatrix,
projMatrixParameters.fov,
projMatrixParameters.aspect,
projMatrixParameters.near,
projMatrixParameters.far
);
if (transparent) {
app.drawFramebuffer(oitBuffer)
.viewport(0, 0, app.width * SSAA_MULTIPLIER, app.height * SSAA_MULTIPLIER)
.disable(PicoGL.DEPTH_TEST)
.enable(PicoGL.BLEND)
.blendFuncSeparate(PicoGL.ONE, PicoGL.ONE, PicoGL.ZERO, PicoGL.ONE_MINUS_SRC_ALPHA)
.clear();
for (let i = 0; i < objects.length; ++i) {
const object = objects[i];
if (settings.visibility[object.direction]) {
objects[i].transparentDrawCall
.uniform("proj", projMatrix)
.uniform("view", viewMatrix)
.uniform("eyePosition", eye)
.uniform("color", colors[objects[i].direction])
.draw();
}
}
app.defaultDrawFramebuffer()
.viewport(0, 0, app.width, app.height)
.blendFunc(PicoGL.ONE, PicoGL.ONE_MINUS_SRC_ALPHA)
.clear();
oitDrawcall.draw();
} else {
app.enable(PicoGL.DEPTH_TEST)
.disable(PicoGL.BLEND)
.clear();
if (cutout) {
app.drawFramebuffer(shadowBuffer)
.clear();
for (let i = 0; i < objects.length; ++i) {
const object = objects[i];
if (settings.visibility[object.direction]) {
app.polygonOffset(i * 0.1, i);
objects[i].shadowDrawCall
.uniform("proj", projMatrix)
.uniform("view", shadowViewMatrix)
.uniform("cutout", cutout)
.draw();
}
}
app.defaultDrawFramebuffer();
}
for (let i = 0; i < objects.length; ++i) {
const object = objects[i];
if (settings.visibility[object.direction]) {
app.gl.polygonOffset(i * 0.1, i);
objects[i].opaqueDrawCall
.uniform("proj", projMatrix)
.uniform("view", viewMatrix)
.uniform("eyePosition", eye)
.uniform("color", colors[objects[i].direction])
.uniform("cutout", cutout)
.uniform("shadowView", shadowViewMatrix)
.draw();
}
}
}
}
requestAnimationFrame(draw);
});
////////////////////////
// 4D TRANSFORM HELPER
////////////////////////
function updateTransform(tesseract, transformedTesseractA, transformedTesseractB, tesseractProjecton, uvProjections, objects, settings, sceneBoundary) {
const {rotations, scales} = settings;
let inTesseract = tesseract;
let outTesseract = transformedTesseractA;
if (settings.unfold > 0) {
unfold(inTesseract, TESSERACT_UNFOLD_TRANSFORMS, settings.unfold, outTesseract);
inTesseract = outTesseract;
outTesseract = inTesseract === transformedTesseractA ? transformedTesseractB : transformedTesseractA;
}
scale(inTesseract, scales, outTesseract);
inTesseract = outTesseract;
outTesseract = inTesseract === transformedTesseractA ? transformedTesseractB : transformedTesseractA;
if (rotations.xy !== 0) {
rotateXY(inTesseract, rotations.xy * RADIANS, outTesseract);
inTesseract = outTesseract;
outTesseract = inTesseract === transformedTesseractA ? transformedTesseractB : transformedTesseractA;
}
if (rotations.xz !== 0) {
rotateXZ(inTesseract, rotations.xz * RADIANS, outTesseract);
inTesseract = outTesseract;
outTesseract = inTesseract === transformedTesseractA ? transformedTesseractB : transformedTesseractA;
}
if (rotations.xw !== 0) {
rotateXW(inTesseract, rotations.xw * RADIANS, outTesseract);
inTesseract = outTesseract;
outTesseract = inTesseract === transformedTesseractA ? transformedTesseractB : transformedTesseractA;
}
if (rotations.yz !== 0) {
rotateYZ(inTesseract, rotations.yz * RADIANS, outTesseract);
inTesseract = outTesseract;
outTesseract = inTesseract === transformedTesseractA ? transformedTesseractB : transformedTesseractA;
}
if (rotations.yw !== 0) {
rotateYW(inTesseract, rotations.yw * RADIANS, outTesseract);
inTesseract = outTesseract;
outTesseract = inTesseract === transformedTesseractA ? transformedTesseractB : transformedTesseractA;
}
if (rotations.zw !== 0) {
rotateZW(inTesseract, rotations.zw * RADIANS, outTesseract);
inTesseract = outTesseract;
outTesseract = inTesseract === transformedTesseractA ? transformedTesseractB : transformedTesseractA;
}
if (settings.projection === "perspective") {
perspectiveProjection(inTesseract, CAMERA_W_OFFSET, FOCAL_LENGTH, tesseractProjecton, uvProjections, sceneBoundary);
} else {
orthographicProjection(inTesseract, tesseractProjecton, uvProjections, sceneBoundary);
}
for (let i = 0; i < objects.length; ++i) {
let object = objects[i];
let direction = object.direction;
object.positions.data(tesseractProjecton[direction]);
object.uvFactors.data(uvProjections[direction]);
}
}
</script>
</body>
</html>