mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
15 lines
388 B
TypeScript
15 lines
388 B
TypeScript
import { Euler, Quaternion, Vector3 } from 'three';
|
|
import { J_HAT } from '../../constants/axis';
|
|
|
|
const quaternion = new Quaternion();
|
|
const axis = new Vector3();
|
|
|
|
export function normalToEuler(normal: Vector3, up = J_HAT) {
|
|
return new Euler().setFromQuaternion(
|
|
quaternion.setFromAxisAngle(
|
|
axis.crossVectors(up, normal).normalize(),
|
|
up.angleTo(normal),
|
|
),
|
|
);
|
|
}
|