This commit is contained in:
@@ -412,8 +412,9 @@ class GameEngine extends THREE.EventDispatcher{
|
||||
}
|
||||
if ( object instanceof THREE.Mesh ) {
|
||||
//object.material.envMap = this.scene.environment;
|
||||
if (object.material.map) object.material.map.colorSpace = THREE.SRGBColorSpace;
|
||||
//object.material.metalness = 0;
|
||||
if (object.material.map) {
|
||||
object.material.map.colorSpace = THREE.SRGBColorSpace;
|
||||
}
|
||||
}
|
||||
//object.frustumCulled = false;
|
||||
object.castShadow = true;
|
||||
|
||||
+5
-5
@@ -21,10 +21,10 @@ class Hero{
|
||||
|
||||
lerp = (x, y, a) => x * (1 - a) + y * a;
|
||||
|
||||
constructor(engine, io, data){
|
||||
constructor(engine, io){
|
||||
this.source = io.source;
|
||||
this.model = io.object
|
||||
this.data = data;
|
||||
//this.data = data;
|
||||
|
||||
this.engine = engine;
|
||||
|
||||
@@ -51,14 +51,14 @@ class Hero{
|
||||
this.runVelocity = this.size.y * 5
|
||||
this.walkVelocity = this.size.y * 3
|
||||
|
||||
this.po = engine.physics.add(this.model, 'kinematicPositionBased', false, undefined, 'capsule', { radius: this.size.x/2, halfHeight: (this.size.y-this.size.x)/2})
|
||||
this.po = engine.physics.add(this.model, 'kinematicPositionBased', false, undefined, 'capsule', { radius: this.size.y/4, halfHeight: this.size.y/4})
|
||||
this.po.collider.setTranslationWrtParent({x: 0, y: this.size.y/2, z: 0});
|
||||
|
||||
this.currentAction = 'idle';
|
||||
this.animationsMap[this.currentAction].play()
|
||||
|
||||
this.characterController = this.engine.physics.world.createCharacterController(this.characterGapOffset);
|
||||
this.characterController.setUp({x:0, y:1, z:0});
|
||||
//this.characterController.setUp({x:0, y:1, z:0});
|
||||
this.po.rigidBody.setTranslation(this.model.position)
|
||||
this.po.characterController = this.characterController;
|
||||
//this.characterController.enableSnapToGround(0.5);
|
||||
@@ -67,7 +67,7 @@ class Hero{
|
||||
// Automatically slide down on slopes smaller than 30 degrees.
|
||||
// this.characterController.setMinSlopeSlideAngle(30 * Math.PI / 180);
|
||||
// this.characterController.enableAutostep(0.5, 0.2, true);
|
||||
this.characterController.setApplyImpulsesToDynamicBodies(true);
|
||||
//this.characterController.setApplyImpulsesToDynamicBodies(true);
|
||||
// this.characterController.setCharacterMass(50);
|
||||
|
||||
this.orbitControl = this.engine.orbitControls
|
||||
|
||||
@@ -50,6 +50,7 @@ function getBoundingBoxCenterPoint(bb, relativeTo){
|
||||
}
|
||||
|
||||
function autoScale(object, mk = 1) {
|
||||
if (mk === null) return;
|
||||
let bb = getBoundingBox(object);
|
||||
let k = getBoundingBoxMaxLength(bb);
|
||||
object.scale.multiplyScalar(mk / k);
|
||||
@@ -74,7 +75,7 @@ function centerOrigin(object){
|
||||
|
||||
function bottomOrigin(object){
|
||||
let group = centerOrigin(object);
|
||||
group.userData.object.position.y += (group.userData.bbox.max.y - group.userData.bbox.min.y)/2
|
||||
group.userData.object.position.y = -group.userData.bbox.min.y
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -86,7 +86,6 @@ class Physics{
|
||||
|
||||
colliderDesc = RAPIER.ColliderDesc.trimesh( vertices, indices );
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if (!colliderDesc) {
|
||||
@@ -104,6 +103,7 @@ class Physics{
|
||||
if (colliderSettings.root){
|
||||
collider.setTranslationWrtParent(colliderSettings.root.position)
|
||||
collider.setRotationWrtParent(colliderSettings.root.quaternion)
|
||||
console.log(colliderSettings.root.position, mesh.position)
|
||||
}
|
||||
const physicsObject = { mesh, collider, rigidBody, fn: postPhysicsFn, autoAnimate }
|
||||
this.physicsObjects.push(physicsObject)
|
||||
|
||||
Reference in New Issue
Block a user