0
votes

i'm trying to reload the scene on AFrame, i have a scene with a robot and i need to load back to original state of the scene when users click a button.

What i already tried is:

var sceneElement = document.querySelector("a-scene");
  sceneElement.reload();

And:

location.reload()

The first one raise an error on browser console showing that reload() method is not a function but documentation on AFrame supports it. I don't know if i'm using this function right.

Uncaught TypeError: sceneElement.reload is not a function
    at HTMLDocument.eval (websim.js:64)
    at HTMLButtonElement.eval (editor.js:23)
    at HTMLButtonElement.dispatch (jquery.js:4953)
    at HTMLButtonElement.elemData.handle (jquery.js:4758)

The last code from below reloads the entire page and this is not what i need.

Thank you! :)

2

2 Answers

0
votes

That method was removed a while ago, I just pushed a change to remove that from the docs, thanks.

You can do window.location.reload().

Else you can just revert whatever you need reverted manually (.setAttributes, removing components). aframe-state-component can also help if it's more complex and you don't want a page reload.

0
votes

I've found a solution to my problem, my robot has dynamic-body component so i'm able to use robot.body.quaternion.set with robot.body.initQuaternion x, y and z as input parameters and reload the robot.

I know is not the full scene reloaded but it works fine for this particular issue.

Thank you @ngokevin for your answers