Added Freecam + Player is now aligned with ground
This commit is contained in:
9
src/utils/placement.js
Normal file
9
src/utils/placement.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import * as THREE from 'three';
|
||||
|
||||
export function alignGround(ground, MovingObject){
|
||||
const boundingBoxGround = new THREE.Box3().setFromObject(ground);
|
||||
const boundingBoxMovingObject = new THREE.Box3().setFromObject(MovingObject);
|
||||
|
||||
const MovingObjectHeight = boundingBoxMovingObject.max.z - boundingBoxMovingObject.min.z;
|
||||
MovingObject.position.y = MovingObjectHeight/2 + boundingBoxGround.max.z;
|
||||
}
|
||||
Reference in New Issue
Block a user