finish events

This commit is contained in:
2025-10-29 13:34:54 +02:00
parent 93e03b4843
commit 127f71f345
8 changed files with 104 additions and 82 deletions
+8 -8
View File
@@ -2,7 +2,6 @@ import { AnimationMixer } from 'three';
import { PointerControls } from './PointerControls';
import { CharacterControls } from './CharacterControls';
import * as THREE from 'three';
import * as RAPIER from '@dimforge/rapier3d'
class Hero{
@@ -18,9 +17,9 @@ class Hero{
gameEngine.camera.position.set(0,17,-30)
gameEngine.camera.lookAt(new THREE.Vector3(this.model.position.x, 5, this.model.position.z))
this.heroCamera = new THREE.Object3D()
this.model.add(this.heroCamera)
this.heroCamera.applyMatrix4(gameEngine.camera.matrix)
// this.heroCamera = new THREE.Object3D()
// this.model.add(this.heroCamera)
// this.heroCamera.applyMatrix4(gameEngine.camera.matrix)
this.mixer = new AnimationMixer(this.model);
gameEngine.mixers.push( this.mixer );
@@ -35,6 +34,7 @@ class Hero{
let po = gameEngine.phy.add(this.model, 'kinematicPositionBased', false, undefined, 'capsule', { radius: 0.5, halfHeight: 1})
po.collider.setTranslationWrtParent({ x: 0, y: 2.0, z: 0 });
//po.collider.setActiveEvents(RAPIER.ActiveEvents.COLLISION_EVENTS);
this.characterControls = new CharacterControls(this.model, this.mixer,
this.animationsMap, gameEngine, 'idle', po, this.pointerControls)
@@ -53,16 +53,16 @@ class Hero{
//return
if (this.gameEngine.renderer.xr.isPresenting) return;
if (this.ready) {
if (this.ready && !this.disableInput) {
let pc = this.pointerControls;
pc.update();
let dlt = this.clock.getDelta();
this.delta += dlt;
if (this.delta > 0.00001){
this.gameEngine.phy.step()
//if (this.delta > 0.00001){
this.characterControls.update(this.gameEngine.phy.world, this.delta, pc)
this.gameEngine.phy.step()
this.delta = 0;
}
//}
}