Hi there, I was wondering if its possible to save entities that are created outside the editor like in this code below
if(app.keyboard.wasReleased(pc.KEY_R) ){
player = this.app.root.findByName('Player');
var playerpos = this.player.getPosition();
var playerrot = this.player.getEulerAngles();
var entity = new pc.Entity('Model');
pc.app.root.addChild(entity);
console.log(playerrot);
entity.setLocalPosition(playerpos.x, playerpos.y - 0.932, playerpos.z + 1);
entity.setEulerAngles(playerrot.x, playerrot.y, playerrot.z);
app.assets.loadFromUrlAndFilename('https://threejs.org/examples/models/gltf/Soldier.glb', null, "container", function (err, asset) {
// Add the loaded scene to the hierarchy
entity.addComponent('model', {
asset: asset.resource.model
});
entity.addComponent('collision', {
type: 'mesh',
asset: asset.resource.model
});
entity.addComponent('rigidbody', {
type: pc.BODYTYPE_KINEMATIC
});
if (asset.resource.animations.length > 0) {
entity.addComponent('animation', {
assets: asset.resource.animations
});
}
});
}
And update the world for other players as well? (Multiplayer)
What if we use pure Js (on the bind 'R) to make a new file that loads and creates models/entities?