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