mirror of
https://github.com/RGBCube/rgbcube.github.io
synced 2025-06-24 17:02:12 +00:00
Delta culling
This commit is contained in:
parent
169634ee44
commit
e02cc2608c
1 changed files with 11 additions and 6 deletions
17
index.html
17
index.html
|
@ -214,7 +214,7 @@
|
||||||
const z = axis.z * sinHalf;
|
const z = axis.z * sinHalf;
|
||||||
const w = cosHalf;
|
const w = cosHalf;
|
||||||
|
|
||||||
return new Quaternion({x: x, y: y, z: z, w: w})
|
return new Quaternion({x: x, y: y, z: z, w: w});
|
||||||
}
|
}
|
||||||
|
|
||||||
apply() {
|
apply() {
|
||||||
|
@ -242,13 +242,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let friction = 0.01;
|
let friction = 0.01;
|
||||||
let sensitivity = 0.001;
|
let sensitivity = 0.01;
|
||||||
|
|
||||||
const orientation = {
|
const orientation = {
|
||||||
__value: new Quaternion({x: 0, y: 0, z: 0, w: 1}),
|
__value: new Quaternion({x: 0, y: 0, z: 0, w: 1}),
|
||||||
|
|
||||||
set(value) {
|
set(value) {
|
||||||
console.log(value);
|
|
||||||
this.__value = value;
|
this.__value = value;
|
||||||
this.__value.apply();
|
this.__value.apply();
|
||||||
},
|
},
|
||||||
|
@ -261,6 +260,7 @@
|
||||||
(() => {
|
(() => {
|
||||||
const mouse = {
|
const mouse = {
|
||||||
down: false,
|
down: false,
|
||||||
|
lastMove: window.performance.now(),
|
||||||
previous: {
|
previous: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
|
@ -289,21 +289,26 @@
|
||||||
const newMouse = {
|
const newMouse = {
|
||||||
x: event.clientX,
|
x: event.clientX,
|
||||||
y: event.clientY,
|
y: event.clientY,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (window.performance.now() - mouse.lastMove > 100) {
|
||||||
|
mouse.previous = newMouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
const delta = {
|
const delta = {
|
||||||
x: newMouse.x - mouse.previous.x,
|
x: newMouse.x - mouse.previous.x,
|
||||||
y: newMouse.y - mouse.previous.y,
|
y: newMouse.y - mouse.previous.y,
|
||||||
}
|
};
|
||||||
|
|
||||||
mouse.previous = newMouse
|
mouse.previous = newMouse;
|
||||||
|
mouse.lastMove = window.performance.now();
|
||||||
|
|
||||||
const rotation = Quaternion.multiply(
|
const rotation = Quaternion.multiply(
|
||||||
Quaternion.fromAngleAxis(delta.x * sensitivity, Quaternion.up),
|
Quaternion.fromAngleAxis(delta.x * sensitivity, Quaternion.up),
|
||||||
Quaternion.fromAngleAxis(delta.y * sensitivity, Quaternion.right),
|
Quaternion.fromAngleAxis(delta.y * sensitivity, Quaternion.right),
|
||||||
);
|
);
|
||||||
|
|
||||||
orientation.set(Quaternion.multiply(orientation.get(), rotation))
|
orientation.set(Quaternion.multiply(orientation.get(), rotation));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue