Last active
February 2, 2024 10:35
-
-
Save ozw-sei/b31b1aee1d41a23e7718ed0a0ddc9353 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function init() { | |
window.Store = {} | |
window.Store.pos = [ | |
[1,1,1,1], | |
[1,1,1,1], | |
[1,1,1,1], | |
] | |
window.Store.rot = [ | |
[1,1,1,1], | |
[1,1,1,1], | |
[1,1,1,1], | |
] | |
} | |
// Canvasから回転座標を渡されて計算した結果を保存する | |
function writeCurrentPositionFromCanvas(rot: number[][]) { | |
window.Store = // 回転座標を計算した結果を入れる | |
} | |
const readCurrentRotationHooks = () => { | |
return [window.Store.pos, window.Store.rot] | |
} | |
const warpPinPoint = (pinId: string) => { | |
// ピンの位置を参照して自分の位置をピンの座標に変更する | |
// これをCanvasや全画面に共有する | |
// window.Store.pos = // 新しい座標を入れる | |
// window.Store.rot = // 新しい角度を入れる | |
} | |
function DisplayRotationComponent() { | |
const [pos, rot] = readCurrentRotationHooks() | |
// 毎フレーム更新したい | |
return ( | |
<div> | |
<p>pos: {pos}</p> | |
<p>rot: {rot}</p> | |
</div> | |
) | |
} | |
function App() { | |
// | |
const [pos, rot] = readCurrentRotationHooks() | |
useEffect( | |
() => fooFunc(pos, rot) // 初回だけ処理したい, | |
[] | |
) | |
return ( | |
<div> | |
<DisplayRotationComponent /> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment