UNPKG

@threlte/rapier

Version:

Components and hooks to use the Rapier physics engine in Threlte

41 lines (40 loc) 1.03 kB
import { Object3D, Quaternion, Vector3 } from 'three'; const tempPosition = new Vector3(); const tempQuaternion = new Quaternion(); const tempScale = new Vector3(); /** * Get the world position of an object. * If no target is provided, a globally used * temporary Vector3 is used. * * @param object * @param target * @returns */ export const getWorldPosition = (object, target) => { return object.getWorldPosition(target ?? tempPosition); }; /** * Get the world quaternion of an object. * If no target is provided, a globally used * temporary Quaternion is used. * * @param object * @param target * @returns */ export const getWorldQuaternion = (object, target) => { return object.getWorldQuaternion(target ?? tempQuaternion); }; /** * Get the world scale of an object. * If no target is provided, a globally used * temporary Vector3 is used. * * @param object * @param target * @returns */ export const getWorldScale = (object, target) => { return object.getWorldScale(target ?? tempScale); };