Hi everyone,
I’m using the latest vue and I’m trying to integrate the playcanvas engine.
With the help of @Ivolutio I managed to load a model into the scene, but now I’m struggling to load and attach scripts as ScriptComponent to entities.
I have tried several ways to make loadFromUrl()
work, but without success:
- Loading a script from the public folder results in
pc
not being defined in the script. - Loading a script from src folder will be sent with html response headers.
I used this code for loading the script:
this.app.assets.loadFromUrl('../src/assets/scripts/orbitCamera.js', 'script', function (err, asset) {
//public path: ./scripts/orbitCamera.js
cameraEntity.addComponent('script');
cameraEntity.script.create('orbitCamera');
});
I then tried to add a script to the asset registry with a vue mixin, by just executing the script code, without loadFromUrl()
and then tried to add an instance of it manually: No success and probably bad practice.
So my question is, has anyone found a modular way to load and attach scripts to entities, running vue and pc engine?
Cheers