mirror of
https://github.com/RGBCube/rgbcube.github.io
synced 2025-07-24 15:37:41 +00:00
313 lines
No EOL
6.6 KiB
HTML
313 lines
No EOL
6.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<meta property="og:type" content="website">
|
|
|
|
<title>RGBCube</title>
|
|
<meta name="author" content="RGBCube" />
|
|
|
|
<meta property="og:site_name" content="RGBCube" />
|
|
<meta property="og:title" content="RGBCube" />
|
|
|
|
<meta name="description" content="The official website and link portal of RGBCube and his work." />
|
|
<meta property="og:description" content="The official website and link portal of RGBCube and his work." />
|
|
|
|
<meta property="og:image" content="/thumbnail.png" />
|
|
<meta property="og:image:type" content="image/png" />
|
|
<meta property="og:image:height" content="" />
|
|
<meta property="og:image:width" content="" />
|
|
|
|
<meta property="og:url" content="https://rgbcube.github.io/" />
|
|
<link rel="canonical" href="https://rgbcube.github.io/">
|
|
</head>
|
|
|
|
<body>
|
|
<style>
|
|
/* STYLING */
|
|
|
|
@font-face {
|
|
font-family: "Bai Jamjuree";
|
|
font-weight: 700;
|
|
src: url(BaiJamjuree700.woff2) format(woff2);
|
|
}
|
|
|
|
html {
|
|
background-color: #000000;
|
|
font-family: "Bai Jamjuree", sans;
|
|
font-size: 300%;
|
|
}
|
|
|
|
a {
|
|
color: #000000;
|
|
text-decoration-line: none;
|
|
}
|
|
|
|
.frame {
|
|
background-color: #FFFFFF;
|
|
|
|
width: min-content;
|
|
|
|
padding: 0 .3em;
|
|
border-radius: 1em;
|
|
|
|
user-select: none;
|
|
}
|
|
|
|
.frame:hover {
|
|
background-color: #FFFF00;
|
|
}
|
|
|
|
/* POSITIONING */
|
|
|
|
body,
|
|
html {
|
|
height: 100%;
|
|
margin: 0;
|
|
}
|
|
|
|
.scene {
|
|
height: 100%;
|
|
width: 100%;
|
|
perspective: 15em;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.cube {
|
|
height: 5em;
|
|
width: 5em;
|
|
|
|
position: relative;
|
|
|
|
transform: translateZ(-2.5em);
|
|
transform-style: preserve-3d;
|
|
}
|
|
|
|
.face {
|
|
background-size: cover;
|
|
background-position: center;
|
|
|
|
width: 5em;
|
|
height: 5em;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
position: absolute;
|
|
}
|
|
|
|
.front {
|
|
transform: rotateY(0deg) translateZ(2.5em);
|
|
background-image: url(front.png);
|
|
}
|
|
|
|
.top {
|
|
transform: rotateX(90deg) translateZ(2.5em);
|
|
background-image: url(top.png);
|
|
}
|
|
|
|
.back {
|
|
transform: rotateY(180deg) translateZ(2.5em);
|
|
background-image: url(back.png);
|
|
}
|
|
|
|
.bottom {
|
|
transform: rotateX(-90deg) translateZ(2.5em);
|
|
background-image: url(bottom.png);
|
|
}
|
|
|
|
.right {
|
|
transform: rotateY(90deg) translateZ(2.5em);
|
|
background-image: url(right.png);
|
|
}
|
|
|
|
.left {
|
|
transform: rotateY(-90deg) translateZ(2.5em);
|
|
background-image: url(left.png);
|
|
}
|
|
</style>
|
|
|
|
<div class="scene">
|
|
<div class="cube">
|
|
<div class="face front">
|
|
<a href="/contact">
|
|
<div class="frame">
|
|
<p>contact</p>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="face top">
|
|
<a href="https://github.com/RGBCube">
|
|
<div class="frame">
|
|
<p>github</p>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="face back">
|
|
<a href="/">
|
|
<div class="frame">
|
|
<p></p>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="face bottom">
|
|
<a href="/">
|
|
<div class="frame">
|
|
<p></p>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="face right">
|
|
<a href="/">
|
|
<div class="frame">
|
|
<p></p>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="face left">
|
|
<a href="/">
|
|
<div class="frame">
|
|
<p></p>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
class Quaternion {
|
|
static __cube = document.querySelector(".cube");
|
|
|
|
static up = new Quaternion({x: 0, y: 1, z: 0, w: 0});
|
|
static right = new Quaternion({x: 1, y: 0, z: 0, w: 0});
|
|
|
|
constructor({x, y, z, w}) {
|
|
this.x = x;
|
|
this.y = y;
|
|
this.z = z;
|
|
this.w = w;
|
|
}
|
|
|
|
static fromAngleAxis(angle, axis) {
|
|
axis.normalize();
|
|
|
|
const half = angle / 2;
|
|
|
|
const sinHalf = Math.sin(half);
|
|
const cosHalf = Math.cos(half);
|
|
|
|
const x = axis.x * sinHalf;
|
|
const y = axis.y * sinHalf;
|
|
const z = axis.z * sinHalf;
|
|
const w = cosHalf;
|
|
|
|
return new Quaternion({x: x, y: y, z: z, w: w})
|
|
}
|
|
|
|
apply() {
|
|
Quaternion.__cube.style.transform = `rotate3d(${this.x}, ${this.y}, ${this.z}, ${this.w}rad)`;
|
|
}
|
|
|
|
normalize() {
|
|
const length = Math.sqrt(this.x ** 2 + this.y ** 2 + this.z ** 2);
|
|
|
|
if (length != 0) {
|
|
this.x /= length;
|
|
this.y /= length;
|
|
this.z /= length;
|
|
}
|
|
}
|
|
|
|
static multiply(q, r) {
|
|
return new Quaternion({
|
|
x: q.w * r.x + q.x * r.w + q.y * r.z - q.z * r.y,
|
|
y: q.w * r.y - q.x * r.z + q.y * r.w + q.z * r.x,
|
|
z: q.w * r.z + q.x * r.y - q.y * r.x + q.z * r.w,
|
|
w: q.w * r.w - q.x * r.x - q.y * r.y - q.z * r.z,
|
|
});
|
|
}
|
|
}
|
|
|
|
let friction = 0.01;
|
|
let sensitivity = 0.001;
|
|
|
|
const orientation = {
|
|
__value: new Quaternion({x: 0, y: 0, z: 0, w: 1}),
|
|
|
|
set(value) {
|
|
console.log(value);
|
|
this.__value = value;
|
|
this.__value.apply();
|
|
},
|
|
|
|
get() {
|
|
return this.__value;
|
|
},
|
|
};
|
|
|
|
(() => {
|
|
const mouse = {
|
|
down: false,
|
|
previous: {
|
|
x: 0,
|
|
y: 0,
|
|
},
|
|
};
|
|
|
|
let velocity = 0;
|
|
|
|
const mouseLeaveListener = (event) => {
|
|
mouse.down = false;
|
|
mouse.previous = {
|
|
x: event.clientX,
|
|
y: event.clientY,
|
|
};
|
|
};
|
|
|
|
document.addEventListener("mouseleave", mouseLeaveListener);
|
|
document.addEventListener("mouseup", mouseLeaveListener);
|
|
|
|
document.addEventListener("mousedown", () => {
|
|
mouse.down = true;
|
|
});
|
|
|
|
document.addEventListener("mousemove", (event) => {
|
|
if (mouse.down) {
|
|
const newMouse = {
|
|
x: event.clientX,
|
|
y: event.clientY,
|
|
}
|
|
|
|
const delta = {
|
|
x: newMouse.x - mouse.previous.x,
|
|
y: newMouse.y - mouse.previous.y,
|
|
}
|
|
|
|
mouse.previous = newMouse
|
|
|
|
const rotation = Quaternion.multiply(
|
|
Quaternion.fromAngleAxis(delta.x * sensitivity, Quaternion.up),
|
|
Quaternion.fromAngleAxis(delta.y * sensitivity, Quaternion.right),
|
|
);
|
|
|
|
orientation.set(Quaternion.multiply(orientation.get(), rotation))
|
|
}
|
|
});
|
|
})();
|
|
</script>
|
|
</body>
|
|
|
|
</html> |