vivo
vivo

Reputation: 26

Why can't I save changes i do on a-frame inspector in Glitch.io

I remixed an a-frame WebVR project on Glitch. When I open the visual a-frame inspector and make changes, I was unable to save the changes. Pressing the SAVE button gives an error:

aframe-watcher not running. This feature requires a companion service running locally. npm install aframe-watcher to save changes back to file. Read more at supermedium.com/aframe-watcher

I am running this on Glitch so I have nothing local.

Can someone help?

Upvotes: 0

Views: 1073

Answers (2)

hilderonny
hilderonny

Reputation: 11

Sorry for the late answer. I could not get it running with aframe-watcher on glitch. But with a customized aframe-inspector component it IS possible.

For an example have a look at https://aframe-glitch-server-sync.glitch.me/ and in the project code at https://glitch.com/~aframe-glitch-server-sync

There you can see in public/aframe-inspector.js starting at line 21742 that the entire scene is serialized and sent to the server.

var scene = Toolbar._entity.getEntityClipboardRepresentation(AFRAME.scenes[0]);

var obj = {};
obj[location.pathname] = scene;
xhr.send(JSON.stringify(obj));

The getEntityClipboardRepresentation function is provided to the toolbar at line 21846. I know, it's an ugly hack, but it works.

Toolbar._entity = __webpack_require__(14);

In server.js the server side handling looks like this.

app.post('/savePlain', (req, res) => {
    var before = '<html><head><script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script></head><body>';
    var after = '</body></html>';
    for (const [filepath, content] of Object.entries(req.body)) {
        fs.writeFileSync('./public' + filepath, before + content + after);
    }
    res.sendStatus(200);
});

I hope this example can be a good start for further experiments. :)

Upvotes: 1

Diego Marcos
Diego Marcos

Reputation: 4585

The inspector cannot modify files on the server side. When using the aframe watcher the inspector can edit and save changes on a scene in your local machine.

Upvotes: 0

Related Questions