mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-07-11 14:34:51 +00:00
cleanup
This commit is contained in:
parent
aeea7432c9
commit
825b21acfd
10 changed files with 6457 additions and 16 deletions
|
|
@ -11,32 +11,31 @@ import {
|
|||
import { Quaternion, Vector3 } from "three";
|
||||
|
||||
export function Camera({ object }: { object: ConsoleObject }) {
|
||||
const { fov } = useSettings();
|
||||
const { registerCamera, unregisterCamera } = useCameras();
|
||||
const id = useId();
|
||||
|
||||
const dataBlock = getProperty(object, "dataBlock").value;
|
||||
const [x, y, z] = useMemo(() => getPosition(object), [object]);
|
||||
const position = useMemo(() => getPosition(object), [object]);
|
||||
const q = useMemo(() => getRotation(object), [object]);
|
||||
|
||||
useEffect(() => {
|
||||
if (dataBlock === "Observer") {
|
||||
const camera = { id, position: new Vector3(x, y, z), rotation: q };
|
||||
const camera = { id, position: new Vector3(...position), rotation: q };
|
||||
registerCamera(camera);
|
||||
return () => {
|
||||
unregisterCamera(camera);
|
||||
};
|
||||
}
|
||||
}, [id, dataBlock, registerCamera, unregisterCamera, x, y, z, q]);
|
||||
}, [id, dataBlock, registerCamera, unregisterCamera, position, q]);
|
||||
|
||||
// Maps can define preset observer camera locations. You should be able to jump
|
||||
// to an observer camera position and then fly around from that starting point
|
||||
// But, we wouldn't want the user to take control of the actual camera's
|
||||
// But, we wouldn't want the user to take control of the actual camera's
|
||||
// position, because then if you want to cycle back through them again, the
|
||||
// "fixed" camera location has moved. There are two approaches for fixing this:
|
||||
// make Camera render an actual PerspectiveCamera, switch it when cycling,
|
||||
// but clone a new "flying" camera when the user moves. The other is to not have
|
||||
// multiple cameras at all, but rather update the one camera with fixed position
|
||||
// information when cycling. This uses the latter approach.
|
||||
// "fixed" camera location has moved. There are multiple approaches to fixing
|
||||
// this: make Camera render an actual PerspectiveCamera, switch it when cycling,
|
||||
// but clone a new "flying" camera when the user moves. The other is to not
|
||||
// have multiple cameras at all, but rather update the default camera with
|
||||
// new position information when cycling. This uses the latter approach.
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue