character collider dimensions
This commit is contained in:
@@ -145,7 +145,7 @@ class MazeObject {
|
||||
roughness: 0, metalness:1, color: 0x00ffff, side: DoubleSide
|
||||
}))
|
||||
floor.rotation.set(Math.PI/2, 0, 0)
|
||||
floor.position.set((bbox.l + bbox.r)/2, 0.3, bbox.f/2);
|
||||
floor.position.set((bbox.l + bbox.r)/2, 0, bbox.f/2);
|
||||
root.add(floor);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -2,6 +2,7 @@ import { AnimationMixer } from 'three';
|
||||
import { PointerControls } from './PointerControls';
|
||||
import { CharacterControls } from './CharacterControls';
|
||||
import * as THREE from 'three';
|
||||
import { getBoundingBox, getBoundingBoxCenterPoint, getBoundingBoxSize } from './MeshUtils';
|
||||
|
||||
class Hero{
|
||||
|
||||
@@ -27,8 +28,12 @@ class Hero{
|
||||
this.pointerControls = new PointerControls(gameEngine.camera, this.model, gameEngine.renderer.domElement);
|
||||
gameEngine.hero = this;
|
||||
|
||||
let po = gameEngine.physics.add(this.model, 'kinematicPositionBased', false, undefined, 'capsule', { radius: 0.5, halfHeight: 1})
|
||||
po.collider.setTranslationWrtParent({ x: 0, y: 2.0, z: 0 });
|
||||
let bb = getBoundingBox(this.model);
|
||||
let size = getBoundingBoxSize(bb);
|
||||
let center = getBoundingBoxCenterPoint(bb, this.model.position).negate();
|
||||
|
||||
let po = gameEngine.physics.add(this.model, 'kinematicPositionBased', false, undefined, 'capsule', { radius: size.x/2, halfHeight: size.y/2})
|
||||
po.collider.setTranslationWrtParent({x: center.x, y: -this.model.position.y, z: center.z});
|
||||
//po.collider.setActiveEvents(RAPIER.ActiveEvents.COLLISION_EVENTS);
|
||||
|
||||
this.characterControls = new CharacterControls(this.model,
|
||||
|
||||
Reference in New Issue
Block a user