mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: infinity aim
This commit is contained in:
1 parent
e5ddbc7297
commit
dced738055
1 file changed
+13
-10
+13
-10
@@ -3,7 +3,6 @@ import { clamp } from 'lodash-es';
|
||||
import { useRef } from 'react';
|
||||
import {
|
||||
ArrowHelper,
|
||||
AxesHelper,
|
||||
Group,
|
||||
MeshStandardMaterial,
|
||||
TextureLoader,
|
||||
@@ -22,7 +21,6 @@ const emptyVector = new Vector2();
|
||||
const modelDefinitions = await awaitableModelDefinitions;
|
||||
|
||||
export function SceneProps() {
|
||||
const shellTargetHelper = useRef<AxesHelper>(null);
|
||||
const shellPathHelper = useRef<ArrowHelper>(null);
|
||||
const show = TankopediaPersistent.use(
|
||||
(state) => state.showGrid && !state.showEnvironment,
|
||||
@@ -81,7 +79,6 @@ export function SceneProps() {
|
||||
if (
|
||||
display !== TankopediaDisplay.ShootingRange ||
|
||||
!playground.current ||
|
||||
!shellTargetHelper.current ||
|
||||
!shellPathHelper.current
|
||||
) {
|
||||
return;
|
||||
@@ -94,15 +91,22 @@ export function SceneProps() {
|
||||
true,
|
||||
);
|
||||
|
||||
if (intersections.length === 0) return;
|
||||
let length: number;
|
||||
let direction: Vector3;
|
||||
|
||||
const target = intersections[0].point;
|
||||
const path = target.clone().sub(shellOrigin);
|
||||
const direction = path.clone().normalize();
|
||||
if (intersections.length === 0) {
|
||||
length = 1000;
|
||||
direction = new Vector3(0, 0, -1).applyQuaternion(camera.quaternion);
|
||||
} else {
|
||||
const target = intersections[0].point;
|
||||
const path = target.clone().sub(shellOrigin);
|
||||
|
||||
length = path.length();
|
||||
direction = path.clone().normalize();
|
||||
}
|
||||
|
||||
shellTargetHelper.current.position.copy(intersections[0].point);
|
||||
shellPathHelper.current.setDirection(direction);
|
||||
shellPathHelper.current.setLength(path.length());
|
||||
shellPathHelper.current.setLength(length);
|
||||
|
||||
const [pitch, yaw] = applyPitchYawLimits(
|
||||
Math.asin(direction.y),
|
||||
@@ -124,7 +128,6 @@ export function SceneProps() {
|
||||
|
||||
{display === TankopediaDisplay.ShootingRange && (
|
||||
<>
|
||||
<axesHelper ref={shellTargetHelper} />
|
||||
<arrowHelper ref={shellPathHelper} position={shellOrigin} />
|
||||
|
||||
<group ref={playground}>
|
||||
|
||||
Reference in new issue
Block a user