mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
fix: clipping plane intersections
This commit is contained in:
1 parent
abc8acb6ed
commit
f73426df6a
3 files changed
+22
-1
No files matched your search
@@ -17,6 +17,7 @@ import { resolvePenetrationCoefficient } from '../../../../core/blitz/resolvePen
|
|||||||
import { hasEquipment } from '../../../../core/blitzkit/hasEquipment';
|
import { hasEquipment } from '../../../../core/blitzkit/hasEquipment';
|
||||||
import { jsxTree } from '../../../../core/blitzkit/jsxTree';
|
import { jsxTree } from '../../../../core/blitzkit/jsxTree';
|
||||||
import { ShellType } from '../../../../core/blitzkit/tankDefinitions';
|
import { ShellType } from '../../../../core/blitzkit/tankDefinitions';
|
||||||
|
import { discardClippingPlane } from '../../../../core/three/discardClippingPlane';
|
||||||
import * as Duel from '../../../../stores/duel';
|
import * as Duel from '../../../../stores/duel';
|
||||||
import * as TankopediaEphemeral from '../../../../stores/tankopediaEphemeral';
|
import * as TankopediaEphemeral from '../../../../stores/tankopediaEphemeral';
|
||||||
import { ArmorType } from '../SpacedArmorScene';
|
import { ArmorType } from '../SpacedArmorScene';
|
||||||
@@ -109,7 +110,9 @@ export function SpacedArmorSceneComponent({
|
|||||||
resolvePenetrationCoefficient(hasCalibratedShells, shell.type);
|
resolvePenetrationCoefficient(hasCalibratedShells, shell.type);
|
||||||
const thicknessCoefficient = hasEnhancedArmor ? 1.03 : 1;
|
const thicknessCoefficient = hasEnhancedArmor ? 1.03 : 1;
|
||||||
const filteredIntersections = intersections.filter(
|
const filteredIntersections = intersections.filter(
|
||||||
(intersection) => 'type' in intersection.object.userData,
|
(intersection) =>
|
||||||
|
'type' in intersection.object.userData &&
|
||||||
|
!discardClippingPlane(intersection.object, intersection.point),
|
||||||
) as unknown as Intersection<Object3D & { userData: ArmorUserData }>[];
|
) as unknown as Intersection<Object3D & { userData: ArmorUserData }>[];
|
||||||
const encounteredExternalModuleVariants: ExternalModuleVariant[] = [];
|
const encounteredExternalModuleVariants: ExternalModuleVariant[] = [];
|
||||||
const noDuplicateIntersections: typeof filteredIntersections = [];
|
const noDuplicateIntersections: typeof filteredIntersections = [];
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
Quaternion,
|
Quaternion,
|
||||||
} from 'three';
|
} from 'three';
|
||||||
import { jsxTree } from '../../../core/blitzkit/jsxTree';
|
import { jsxTree } from '../../../core/blitzkit/jsxTree';
|
||||||
|
import { discardClippingPlane } from '../../../core/three/discardClippingPlane';
|
||||||
import * as TankopediaEphemeral from '../../../stores/tankopediaEphemeral';
|
import * as TankopediaEphemeral from '../../../stores/tankopediaEphemeral';
|
||||||
import { ThicknessRange } from '../../StaticArmor';
|
import { ThicknessRange } from '../../StaticArmor';
|
||||||
import { ArmorType } from './SpacedArmorScene';
|
import { ArmorType } from './SpacedArmorScene';
|
||||||
@@ -166,6 +167,8 @@ export function StaticArmorSceneComponent({
|
|||||||
} satisfies ArmorUserData,
|
} satisfies ArmorUserData,
|
||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
|
if (discardClippingPlane(event.object, event.point)) return;
|
||||||
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
const { editStatic } = tankopediaEphemeralStore.getState();
|
const { editStatic } = tankopediaEphemeralStore.getState();
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { Material, Mesh, Object3D, Vector3 } from 'three';
|
||||||
|
|
||||||
|
export function discardClippingPlane(object: Object3D, point: Vector3) {
|
||||||
|
if (
|
||||||
|
object instanceof Mesh &&
|
||||||
|
object.material instanceof Material &&
|
||||||
|
object.material.clippingPlanes !== null
|
||||||
|
) {
|
||||||
|
return object.material.clippingPlanes.every(
|
||||||
|
(plane) => plane.distanceToPoint(point) < 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user