123456789101112131415161718192021222324252627282930313233 |
- import * as RE from 'rogue-engine'
- import * as THREE from 'three'
- export default class GetForwardVector {
- object3d: THREE.Object3D
- private vector: THREE.Vector3 = new THREE.Vector3()
- constructor(object3d: THREE.Object3D) {
- this.object3d = object3d
- }
- getForward(): THREE.Vector3 {
- this.vector.set(0,0,0)
- if(!this.object3d) {
- RE.Debug.logError("No Object3D provided to get forward vector from.")
- return this.vector
- }
- this.vector.setFromMatrixColumn( this.object3d.matrix, 0 );
- this.vector.crossVectors( this.object3d.up, this.vector );
- return this.vector.normalize()
- }
- getRight(): THREE.Vector3 {
-
- if(!this.object3d) {
- RE.Debug.logError("No Object3D provided to get right vector from.")
- return this.vector
- }
- this.vector.setFromMatrixColumn( this.object3d.matrix, 0 );
- return this.vector.normalize()
- }
- }
|