interactive objects integration
This commit is contained in:
@@ -120,7 +120,10 @@ export default {
|
||||
*/
|
||||
async loadEnvironment(scene, target){
|
||||
//await gameEngine.loadPanorama(`/asset/default/43.webp`);
|
||||
gameEngine.hero?.destroy();
|
||||
gameEngine.dashboard?.reset();
|
||||
gameEngine.activeObjects.clear();
|
||||
gameEngine.physics.clear();
|
||||
await this.expandScenarioData(scene);
|
||||
target.objects = target.objects || {};
|
||||
let l = target.objects;
|
||||
@@ -129,7 +132,8 @@ export default {
|
||||
}
|
||||
if (this.scene.data.$scene){
|
||||
let env = await gameEngine.load(`/asset/default/${this.scene.data.$scene.asset.name}`);
|
||||
this.setObjectAttributes(l, this.scene.data, env, 100);
|
||||
//console.log('ENV', env)
|
||||
this.setObjectAttributes(l, this.scene.data, env.scene, env, 100);
|
||||
gameEngine.activeObjects.add(env.scene);
|
||||
}
|
||||
for (let i of this.scene.data.items || []) {
|
||||
@@ -137,17 +141,16 @@ export default {
|
||||
await io.ready;
|
||||
|
||||
//let gltf = await gameEngine.load(`/asset/default/${i.data.$go.asset.name}`);
|
||||
let objKey = (i.data.type == 'GenericObject' || !i.data.type) ? 'scene' : 'object'
|
||||
console.log(i.data, io.object)
|
||||
this.setObjectAttributes(l, i.data, io.object, 1, objKey);
|
||||
gameEngine.activeObjects.add(io.object[objKey]);
|
||||
//console.log(i.data, io.object)
|
||||
this.setObjectAttributes(l, i.data, io.object, io.source, 1);
|
||||
gameEngine.activeObjects.add(io.object);
|
||||
if (this.env == 'GamePlaying'){
|
||||
if (i.data.$go.type == 'player3d'){
|
||||
let hero = new Hero(io.object, i.data.$go);
|
||||
if (i.data.$go?.type == 'player3d'){
|
||||
let hero = new Hero(io.source, i.data.$go);
|
||||
hero.init(gameEngine);
|
||||
}else{
|
||||
if (io.object.animations?.length){
|
||||
gameEngine.playAnimation(gameEngine.scene, io.object.animations[0]);
|
||||
if (io.source?.animations?.length){
|
||||
gameEngine.playAnimation(gameEngine.scene, io.source.animations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,22 +188,22 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
setObjectAttributes(l, data, o, autoScaleFactor = 1, objectKey = 'scene'){
|
||||
setObjectAttributes(l, data, object, source, autoScaleFactor = 1){
|
||||
if (l[data.id]){
|
||||
['position', 'scale', 'rotation'].forEach(p=>{
|
||||
o[objectKey][p].copy(l[data.id][p])
|
||||
object[p].copy(l[data.id][p])
|
||||
})
|
||||
}else{
|
||||
gameEngine.autoScale(o[objectKey], autoScaleFactor);
|
||||
gameEngine.autoScale(object, autoScaleFactor);
|
||||
}
|
||||
l[data.id] = l[data.id] || {};
|
||||
['position', 'scale', 'rotation', 'visible'].forEach(p=>{
|
||||
l[data.id][p] = o[objectKey][p];
|
||||
l[data.id][p] = object[p];
|
||||
})
|
||||
l[data.id].__o = o[objectKey];
|
||||
l[data.id].__g = o;
|
||||
l[data.id].__o = object;
|
||||
l[data.id].__g = source;
|
||||
l[data.id].__title = data.title;
|
||||
o[objectKey].__pn_id = data.id;
|
||||
object.__pn_id = data.id;
|
||||
},
|
||||
|
||||
async toggleAnimation(animation){
|
||||
|
||||
Reference in New Issue
Block a user