add physics to interactive objects
This commit is contained in:
@@ -2,7 +2,7 @@ import { InteractiveObject } from '@/components/InteractiveObjects/InteractiveOb
|
||||
import { VideoPlayer } from '@/components/InteractiveObjects/VideoPlayer';
|
||||
import { GameEngine } from '@/lib/GameEngine';
|
||||
import { Hero } from '@/lib/Hero';
|
||||
import { autoScale } from '@/lib/MeshUtils';
|
||||
import { autoScale, getBoundingBox, getBoundingBoxCenterPoint, getBoundingBoxSize } from '@/lib/MeshUtils';
|
||||
let gameEngine = null;
|
||||
|
||||
export default {
|
||||
@@ -151,6 +151,14 @@ export default {
|
||||
if (io.source?.animations?.length){
|
||||
gameEngine.playAnimation(gameEngine.scene, io.source.animations[0]);
|
||||
}
|
||||
|
||||
if (!i.data.noPhysics){
|
||||
let bb = getBoundingBox(io.object);
|
||||
let bbs = getBoundingBoxSize(bb);
|
||||
gameEngine.physics.add(io.object, 'fixed', false, undefined, 'capsule', {
|
||||
radius: Math.max(bbs.x, bbs.z)/2, halfHeight: bbs.y/2
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user