allow generic objects animation filtering
This commit is contained in:
@@ -2,6 +2,7 @@ import { EventManager } from '@/lib/EventManager';
|
||||
|
||||
class GenericObject extends EventManager{
|
||||
emits = ['finish', 'interaction']
|
||||
#actions = [];
|
||||
constructor(engine, data){
|
||||
super();
|
||||
return new Promise(async(resolve, reject)=>{
|
||||
@@ -17,14 +18,25 @@ class GenericObject extends EventManager{
|
||||
})
|
||||
}
|
||||
|
||||
if (this.source?.animations?.length){
|
||||
let mix = this.source.animations.filter(a=>a.name.match(/\.mix/));
|
||||
if (!mix.length) mix = [this.source.animations[0]];
|
||||
mix.forEach(m=>{
|
||||
this.#actions.push(engine.playAnimation(this.object, m));
|
||||
})
|
||||
}
|
||||
|
||||
if (!data.exclude){
|
||||
engine.clickable.add(this.object, async e=>{
|
||||
this.object.__onhud = !this.object.__onhud;
|
||||
if (engine.dashboard){
|
||||
if (data.hud){
|
||||
const filterNoHud = a=>a.getClip().name.match(/\.nohud/)
|
||||
if (this.object._hud ){
|
||||
this.#actions.filter(filterNoHud).forEach(a=>a.play());
|
||||
engine.dashboard.detach(this.object);
|
||||
}else{
|
||||
this.#actions.filter(filterNoHud).forEach(a=>a.stop());
|
||||
let bb = engine.meshUtils.getBoundingBox(this.object);
|
||||
let scale = 0.5 * engine.dashboard.height/engine.meshUtils.getBoundingBoxMaxLength(bb);
|
||||
let position = engine.meshUtils.getBoundingBoxCenterPoint(bb, this.object.position).multiplyScalar(scale).negate()
|
||||
|
||||
Reference in New Issue
Block a user