diff --git a/.vscode/settings.json b/.vscode/settings.json index 004e622e0..d39e73aa8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -26,6 +26,7 @@ "deburr", "decalmask", "diacriticless", + "drei", "dvpl", "DVPLCRC", "dxgi", diff --git a/src/app/tools/tankopedia/[id]/page.tsx b/src/app/tools/tankopedia/[id]/page.tsx index b0b7cfbe7..cf9f35a94 100644 --- a/src/app/tools/tankopedia/[id]/page.tsx +++ b/src/app/tools/tankopedia/[id]/page.tsx @@ -62,9 +62,6 @@ export default function Page({ params }: { params: { id: string } }) { const [versusTurret, setVersusTurret] = useState(versusTank.turrets.at(-1)!); const [versusGun, setVersusGun] = useState(versusTurret.guns.at(-1)!); const [versusTankTab, setVersusTankTab] = useState('search'); - const turretObject3D = useRef(null); - const mantletObject3D = useRef(null); - const gunObject3D = useRef(null); const canvas = useRef(null); const gltf = useLoader(GLTFLoader, '/test/5137.glb'); const turretOrigin = new Vector3( @@ -163,7 +160,7 @@ export default function Page({ params }: { params: { id: string } }) { {gltf.scene.children[0].children.map((child) => { const isHull = child.name === 'hull'; @@ -235,8 +232,12 @@ export default function Page({ params }: { params: { id: string } }) { })} {gltf.scene.children[0].children.map((child) => { const isTurret = child.name.startsWith('turret_'); @@ -261,33 +262,9 @@ export default function Page({ params }: { params: { id: string } }) { const isVisible = isCurrentTurret || isCurrentGun || isCurrentMantlet; let draftTurretRotation = 0; - const position = child.position.clone(); - const rotation = new Vector3().setFromEuler( - child.rotation, - ); if (!isVisible) return null; - if (isTurret || isMantlet) { - position - .sub(turretOrigin) - .applyAxisAngle( - new Vector3(0, 0, 1), - turretRotation, - ) - .add(turretOrigin); - rotation.add(new Vector3(0, 0, turretRotation)); - } else if (isGun) { - position - .sub(turretOrigin) - .applyAxisAngle( - new Vector3(0, 0, 1), - turretRotation, - ) - .add(turretOrigin); - rotation.add(new Vector3(0, 0, turretRotation)); - } - function handlePointerDown( event: ThreeEvent, ) { @@ -317,39 +294,15 @@ export default function Page({ params }: { params: { id: string } }) { event.movementX * rotationSpeed; draftTurretRotation += deltaTurretRotation; - if (turretObject3D.current) { - turretObject3D.current.position + if (turretContainer.current) { + turretContainer.current.position .sub(turretOrigin) .applyAxisAngle( new Vector3(0, 0, 1), deltaTurretRotation, ) .add(turretOrigin); - turretObject3D.current.rotation.z = - draftTurretRotation; - } - - if (mantletObject3D.current) { - mantletObject3D.current.position - .sub(turretOrigin) - .applyAxisAngle( - new Vector3(0, 0, 1), - deltaTurretRotation, - ) - .add(turretOrigin); - mantletObject3D.current.rotation.z = - draftTurretRotation; - } - - if (gunObject3D.current) { - gunObject3D.current.position - .sub(turretOrigin) - .applyAxisAngle( - new Vector3(0, 0, 1), - deltaTurretRotation, - ) - .add(turretOrigin); - gunObject3D.current.rotation.z = + turretContainer.current.rotation.z = draftTurretRotation; } } @@ -379,18 +332,9 @@ export default function Page({ params }: { params: { id: string } }) { receiveShadow geometry={(child as Mesh).geometry} material={(child as Mesh).material} - position={position} - rotation={rotation.toArray()} + position={child.position} + rotation={child.rotation} scale={child.scale} - ref={ - isTurret - ? turretObject3D - : isGun - ? gunObject3D - : isMantlet - ? mantletObject3D - : undefined - } /> ); })}