mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: more props
This commit is contained in:
1 parent
65c52c2e82
commit
7f9a54ef85
3 files changed
+48
-29
No files matched your search
@@ -97,7 +97,7 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
|
|||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(${imgur('27Gwth4')})`,
|
backgroundImage: `url(${imgur('27Gwth4')})`,
|
||||||
backgroundSize: 'contain',
|
backgroundSize: 'contain',
|
||||||
transform: 'translate(-50%, -50%)',
|
transform: 'translateX(-50%)',
|
||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
-26
@@ -25,10 +25,8 @@ const ARCADE_MODE_ANGLE = Math.PI / 8;
|
|||||||
export const ARCADE_MODE_FOV = 54;
|
export const ARCADE_MODE_FOV = 54;
|
||||||
export const INSPECT_MODE_FOV = 25;
|
export const INSPECT_MODE_FOV = 25;
|
||||||
|
|
||||||
const emptyVector = new Vector2();
|
|
||||||
|
|
||||||
export function Controls() {
|
export function Controls() {
|
||||||
const helper = useRef<AxesHelper>(null);
|
|
||||||
const display = TankopediaEphemeral.use((state) => state.display);
|
const display = TankopediaEphemeral.use((state) => state.display);
|
||||||
const duelStore = Duel.useStore();
|
const duelStore = Duel.useStore();
|
||||||
const tankopediaEphemeralStore = TankopediaEphemeral.useStore();
|
const tankopediaEphemeralStore = TankopediaEphemeral.useStore();
|
||||||
@@ -81,8 +79,6 @@ export function Controls() {
|
|||||||
protagonistTurretOrigin.y +
|
protagonistTurretOrigin.y +
|
||||||
protagonistGunOrigin.y;
|
protagonistGunOrigin.y;
|
||||||
const initialPosition = [-8, gunHeight + 4, -13] as const;
|
const initialPosition = [-8, gunHeight + 4, -13] as const;
|
||||||
const raycaster = useThree((state) => state.raycaster);
|
|
||||||
const scene = useThree((state) => state.scene);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!orbitControls.current) return;
|
if (!orbitControls.current) return;
|
||||||
@@ -237,8 +233,6 @@ export function Controls() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
<axesHelper ref={helper} />
|
|
||||||
<OrbitControls
|
<OrbitControls
|
||||||
maxDistance={20}
|
maxDistance={20}
|
||||||
minDistance={5}
|
minDistance={5}
|
||||||
@@ -249,26 +243,6 @@ export function Controls() {
|
|||||||
maxPolarAngle={degToRad(100)}
|
maxPolarAngle={degToRad(100)}
|
||||||
autoRotate={autoRotate}
|
autoRotate={autoRotate}
|
||||||
autoRotateSpeed={1 / 4}
|
autoRotateSpeed={1 / 4}
|
||||||
onChange={() => {
|
|
||||||
if (display !== TankopediaDisplay.ShootingRange || !helper.current) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
raycaster.setFromCamera(emptyVector, camera);
|
|
||||||
|
|
||||||
const intersections = raycaster.intersectObjects(
|
|
||||||
scene.children,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
const first = intersections.find(
|
|
||||||
(intersection) => intersection.object !== helper.current,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (first === undefined) return;
|
|
||||||
|
|
||||||
helper.current.position.copy(first.point);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+47
-2
@@ -1,18 +1,28 @@
|
|||||||
import { useFrame, useLoader } from '@react-three/fiber';
|
import { useFrame, useLoader } from '@react-three/fiber';
|
||||||
import { clamp } from 'lodash-es';
|
import { clamp } from 'lodash-es';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import { MeshStandardMaterial, TextureLoader } from 'three';
|
import {
|
||||||
|
AxesHelper,
|
||||||
|
Group,
|
||||||
|
MeshStandardMaterial,
|
||||||
|
TextureLoader,
|
||||||
|
Vector2,
|
||||||
|
} from 'three';
|
||||||
import { TankopediaEphemeral } from '../../../../../../stores/tankopediaEphemeral';
|
import { TankopediaEphemeral } from '../../../../../../stores/tankopediaEphemeral';
|
||||||
import { TankopediaPersistent } from '../../../../../../stores/tankopediaPersistent';
|
import { TankopediaPersistent } from '../../../../../../stores/tankopediaPersistent';
|
||||||
import { TankopediaDisplay } from '../../../../../../stores/tankopediaPersistent/constants';
|
import { TankopediaDisplay } from '../../../../../../stores/tankopediaPersistent/constants';
|
||||||
|
|
||||||
|
const emptyVector = new Vector2();
|
||||||
|
|
||||||
export function SceneProps() {
|
export function SceneProps() {
|
||||||
|
const helper = useRef<AxesHelper>(null);
|
||||||
const show = TankopediaPersistent.use(
|
const show = TankopediaPersistent.use(
|
||||||
(state) => state.showGrid && !state.showEnvironment,
|
(state) => state.showGrid && !state.showEnvironment,
|
||||||
);
|
);
|
||||||
const texture = useLoader(TextureLoader, 'https://i.imgur.com/C28Z8nU.png');
|
const texture = useLoader(TextureLoader, 'https://i.imgur.com/C28Z8nU.png');
|
||||||
const material = useRef<MeshStandardMaterial>(null);
|
const material = useRef<MeshStandardMaterial>(null);
|
||||||
const display = TankopediaEphemeral.use((state) => state.display);
|
const display = TankopediaEphemeral.use((state) => state.display);
|
||||||
|
const playground = useRef<Group>(null);
|
||||||
|
|
||||||
useFrame(({ camera }) => {
|
useFrame(({ camera }) => {
|
||||||
if (!material.current) return;
|
if (!material.current) return;
|
||||||
@@ -21,6 +31,27 @@ export function SceneProps() {
|
|||||||
|
|
||||||
texture.anisotropy = 2;
|
texture.anisotropy = 2;
|
||||||
|
|
||||||
|
useFrame(({ raycaster, scene, camera }) => {
|
||||||
|
if (
|
||||||
|
display !== TankopediaDisplay.ShootingRange ||
|
||||||
|
!playground.current ||
|
||||||
|
!helper.current
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
raycaster.setFromCamera(emptyVector, camera);
|
||||||
|
|
||||||
|
const intersections = raycaster.intersectObjects(
|
||||||
|
playground.current.children,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (intersections.length === 0) return;
|
||||||
|
|
||||||
|
helper.current.position.copy(intersections[0].point);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{show && display !== TankopediaDisplay.ShootingRange && (
|
{show && display !== TankopediaDisplay.ShootingRange && (
|
||||||
@@ -29,13 +60,27 @@ export function SceneProps() {
|
|||||||
<meshStandardMaterial ref={material} map={texture} transparent />
|
<meshStandardMaterial ref={material} map={texture} transparent />
|
||||||
</mesh>
|
</mesh>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{display === TankopediaDisplay.ShootingRange && (
|
{display === TankopediaDisplay.ShootingRange && (
|
||||||
<>
|
<>
|
||||||
{/* <fog color="black" /> */}
|
<axesHelper ref={helper} />
|
||||||
|
|
||||||
|
<group ref={playground}>
|
||||||
<mesh rotation={[-Math.PI / 2, 0, 0]} receiveShadow>
|
<mesh rotation={[-Math.PI / 2, 0, 0]} receiveShadow>
|
||||||
<planeGeometry args={[100, 100]} />
|
<planeGeometry args={[100, 100]} />
|
||||||
<meshStandardMaterial color={0x404040} />
|
<meshStandardMaterial color={0x404040} />
|
||||||
</mesh>
|
</mesh>
|
||||||
|
|
||||||
|
<mesh
|
||||||
|
receiveShadow
|
||||||
|
castShadow
|
||||||
|
position={[10, 1.5, -10]}
|
||||||
|
rotation={[0, Math.PI / 4, 0]}
|
||||||
|
>
|
||||||
|
<boxGeometry args={[1, 3, 1]} />
|
||||||
|
<meshStandardMaterial color={0xff8040} />
|
||||||
|
</mesh>
|
||||||
|
</group>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in new issue
Block a user