mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
optimize intro naimaiton
This commit is contained in:
1 parent
63a0143d4f
commit
cead140855
1 file changed
+34
-26
+34
-26
@@ -19,6 +19,8 @@ const poseDistances: Record<Pose, number> = {
|
|||||||
[Pose.Default]: -1,
|
[Pose.Default]: -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const inspectModeInitialPosition = new Vector3(-8, 2, -13);
|
||||||
|
|
||||||
const modelDefinitions = await awaitableModelDefinitions;
|
const modelDefinitions = await awaitableModelDefinitions;
|
||||||
|
|
||||||
interface ControlsProps {
|
interface ControlsProps {
|
||||||
@@ -77,22 +79,6 @@ export function Controls({
|
|||||||
protagonistHullOrigin.y +
|
protagonistHullOrigin.y +
|
||||||
protagonistTurretOrigin.y +
|
protagonistTurretOrigin.y +
|
||||||
protagonistGunOrigin.y;
|
protagonistGunOrigin.y;
|
||||||
const inspectModeInitialPosition = new Vector3(-8, 2, -13);
|
|
||||||
|
|
||||||
const t0 = useRef(Date.now() / 1000);
|
|
||||||
useFrame(() => {
|
|
||||||
if (!doAutoRotate) return;
|
|
||||||
|
|
||||||
const now = Date.now() / 1000;
|
|
||||||
const t = now - t0.current;
|
|
||||||
|
|
||||||
camera.position
|
|
||||||
.copy(inspectModeInitialPosition)
|
|
||||||
.applyAxisAngle(I_HAT, (Math.PI / 32) * Math.sin(t / 9))
|
|
||||||
.applyAxisAngle(J_HAT, (-Math.PI / 16) * Math.sin(t / 7));
|
|
||||||
|
|
||||||
invalidate();
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleControlsEnabled(event: QuicklimeEvent<boolean>) {
|
function handleControlsEnabled(event: QuicklimeEvent<boolean>) {
|
||||||
@@ -249,15 +235,37 @@ export function Controls({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OrbitControls
|
<>
|
||||||
enableRotate={enableRotate}
|
{doAutoRotate && <Animator />}
|
||||||
maxDistance={40}
|
|
||||||
minDistance={5}
|
<OrbitControls
|
||||||
enableZoom={zoomable}
|
enableRotate={enableRotate}
|
||||||
zoomSpeed={zoomable ? undefined : 0}
|
maxDistance={40}
|
||||||
ref={orbitControls}
|
minDistance={5}
|
||||||
enabled={controlsEnabledEvent.last!}
|
enableZoom={zoomable}
|
||||||
enableDamping={false}
|
zoomSpeed={zoomable ? undefined : 0}
|
||||||
/>
|
ref={orbitControls}
|
||||||
|
enabled={controlsEnabledEvent.last!}
|
||||||
|
enableDamping={false}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Animator() {
|
||||||
|
const clock = useThree((state) => state.clock);
|
||||||
|
const t0 = useRef(clock.elapsedTime);
|
||||||
|
|
||||||
|
useFrame(({ camera }) => {
|
||||||
|
const t = clock.elapsedTime - t0.current;
|
||||||
|
|
||||||
|
camera.position
|
||||||
|
.copy(inspectModeInitialPosition)
|
||||||
|
.applyAxisAngle(I_HAT, (Math.PI / 32) * Math.sin(t / 9))
|
||||||
|
.applyAxisAngle(J_HAT, (-Math.PI / 16) * Math.sin(t / 7));
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user