mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-27 04:29:50 +01:00
feat: apply quaternion rotation
This commit is contained in:
1 parent
15cb472189
commit
0ab53a7825
1 file changed
+11
-3
@@ -1,8 +1,14 @@
|
|||||||
import { MeshProps, useFrame, useThree } from '@react-three/fiber';
|
import { MeshProps, useFrame, useThree } from '@react-three/fiber';
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import { IUniform, Mesh, ShaderMaterial, Vector2, Vector3 } from 'three';
|
import {
|
||||||
|
IUniform,
|
||||||
|
Mesh,
|
||||||
|
Quaternion,
|
||||||
|
ShaderMaterial,
|
||||||
|
Vector2,
|
||||||
|
Vector3,
|
||||||
|
} from 'three';
|
||||||
import { degToRad } from 'three/src/math/MathUtils';
|
import { degToRad } from 'three/src/math/MathUtils';
|
||||||
import { I_HAT } from '../../../../constants/axis';
|
|
||||||
import { canSplash } from '../../../../core/blitz/canSplash';
|
import { canSplash } from '../../../../core/blitz/canSplash';
|
||||||
import { isExplosive } from '../../../../core/blitz/isExplosive';
|
import { isExplosive } from '../../../../core/blitz/isExplosive';
|
||||||
import { resolveNearPenetration } from '../../../../core/blitz/resolveNearPenetration';
|
import { resolveNearPenetration } from '../../../../core/blitz/resolveNearPenetration';
|
||||||
@@ -139,7 +145,9 @@ export function ArmorMesh({
|
|||||||
shellNormal.copy(
|
shellNormal.copy(
|
||||||
cameraNormal.copy(camera.position).sub(event.point).normalize(),
|
cameraNormal.copy(camera.position).sub(event.point).normalize(),
|
||||||
);
|
);
|
||||||
surfaceNormal.copy(event.normal!).applyAxisAngle(I_HAT, -Math.PI / 2);
|
surfaceNormal
|
||||||
|
.copy(event.normal!)
|
||||||
|
.applyQuaternion(event.object.getWorldQuaternion(new Quaternion()));
|
||||||
const angle = Math.acos(surfaceNormal.dot(shellNormal));
|
const angle = Math.acos(surfaceNormal.dot(shellNormal));
|
||||||
const shell = useDuel.getState().antagonist!.shell;
|
const shell = useDuel.getState().antagonist!.shell;
|
||||||
const intersections = event.intersections
|
const intersections = event.intersections
|
||||||
|
|||||||
Reference in new issue
Block a user