import * as THREE from 'three' export function getForwardVector(object3d) { const up = object3d.up.clone() const forwardVector = new THREE.Vector3(0,0,0) forwardVector.setFromMatrixColumn(object3d.matrix, 0) forwardVector.crossVectors(up.multiplyScalar(-1), forwardVector) return forwardVector.normalize() } export function getRightVector(object3d) { const up = object3d.up.clone() const rightVector = new THREE.Vector3(0,0,0) rightVector.setFromMatrixColumn(object3d.matrix, 0) rightVector.crossVectors(up.multiplyScalar(-1), rightVector) rightVector.crossVectors(object3d.up, rightVector) return rightVector.normalize() } export function drawDebugLine(game, startPoint, endPoint, color = 0xff0000, delay = 0) { const points = [] points.push(startPoint) points.push(endPoint) const geometry = new THREE.BufferGeometry().setFromPoints( points ); const material = new THREE.LineBasicMaterial( { color } ); const line = new THREE.Line( geometry, material ) game.scene.add(line) if(delay > 0) { setTimeout(() => { game.scene.remove(line) }, delay) } }