Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chinsun9/random-dice

Roll 🎲 !!! click & shake
https://github.com/chinsun9/random-dice

animation css

Last synced: about 1 month ago
JSON representation

Roll 🎲 !!! click & shake

Awesome Lists containing this project

README

        

# Random Dice

**3D CSS - lighting, animations, and more! - Kevin Powell**을 보고 μ‘μš©ν•΄μ„œ λ§Œλ“€μ—ˆλ‹€

- https://youtu.be/NdftnCDwKaU

## κΈ°λŠ₯

- μ£Όμ‚¬μœ„ 돌리기
- μ£Όμ‚¬μœ„ λŒλ¦¬λŠ” μ• λ‹ˆλ©”μ΄μ…˜
- 랜덀 결과 1~6
- ν•Έλ“œν°μ„ 흔듀어 μ£Όμ‚¬μœ„ 돌리기

## TMI

### ν•Έλ“œν° 흔듀기 감지 : devicemotion

```js
window.addEventListener('devicemotion', (event) => {
if (!event.acceleration) {
console.log(`no acceleration`);
return;
}

const currentTime = new Date().getTime();
if (currentTime - lastTimestamp < 300) {
return;
}

lastTimestamp = currentTime;

const acceleration = Math.max(
Math.abs(event.acceleration.x!),
Math.abs(event.acceleration.y!),
Math.abs(event.acceleration.z!)
);

if (acceleration >= 4) {
dice.roll();
}
});
```

- `devicemotion`λΌλŠ” window μ΄λ²€νŠΈμ—μ„œ κ°€μ Έμ˜¬ 수 μžˆλ‹€
- x, y, z의 가속도λ₯Ό μ–»μ–΄μ„œ κ°€μž₯ 큰 값을 κΈ°μ€€μœΌλ‘œ μ§€μ •ν•œ 값을 λ„˜κΈ°λ©΄ μ£Όμ‚¬μœ„λ₯Ό ꡴리도둝 ν–ˆλ‹€
- λ³΄μ•ˆ μ»¨ν…μŠ€νŠΈμ—μ„œλ§Œ λ™μž‘ν•˜κΈ° λ•Œλ¬Έμ— localhost λ˜λŠ” HTTPSμ—μ„œ λ™μž‘ν•œλ‹€