better 3d effect
This commit is contained in:
parent
404563fba4
commit
adc27cc80e
@ -1386,11 +1386,13 @@ namespace pxsim.visuals {
|
|||||||
let state = this.board;
|
let state = this.board;
|
||||||
if (!state || !state.accelerometerState.accelerometer.isActive) return;
|
if (!state || !state.accelerometerState.accelerometer.isActive) return;
|
||||||
|
|
||||||
let x = state.accelerometerState.accelerometer.getX();
|
const x = state.accelerometerState.accelerometer.getX();
|
||||||
let y = -state.accelerometerState.accelerometer.getY();
|
const y = -state.accelerometerState.accelerometer.getY();
|
||||||
let af = 8 / 1023;
|
const af = 8 / 1023;
|
||||||
|
const s = 1 - Math.min(0.1, Math.pow(Math.max(Math.abs(x), Math.abs(y)) / 1023, 2) / 35);
|
||||||
|
|
||||||
this.element.style.transform = "perspective(30em) rotateX(" + y * af + "deg) rotateY(" + x * af + "deg)"
|
this.element.style.transform = `perspective(30em) rotateX(${y * af}deg) rotateY(${x * af}deg) scale(${s}, ${s})`
|
||||||
|
|
||||||
this.element.style.perspectiveOrigin = "50% 50% 50%";
|
this.element.style.perspectiveOrigin = "50% 50% 50%";
|
||||||
this.element.style.perspective = "30em";
|
this.element.style.perspective = "30em";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user