Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persisting the old enviornment and generating the old enviornment with the same html in the a-scene #51

Open
lazychip opened this issue Sep 20, 2018 · 7 comments

Comments

@lazychip
Copy link

When i try to generate the old environment by saving it and injecting it in the a-scene environment is broken.

@feiss
Copy link
Contributor

feiss commented Sep 29, 2018

sorry, I don't understand what you are doing exacly. Could you explain?

@lazychip
Copy link
Author

lazychip commented Oct 1, 2018

I want to save the scene state and reload with the saved scene state
Step 1 => flush the dom
Step 2 => save the scene in the local storage
Step 3 => on reload get the scene state from the local storage and load the scene.
So what happening is everything is working fine but the environment is not loading properly

@feiss
Copy link
Contributor

feiss commented Oct 4, 2018

how are you saving the scene?

@lazychip
Copy link
Author

lazychip commented Oct 4, 2018

saving the entities and assets as the separate arrays
making a template from the saved entities and assets to load the scene back

what i did to make environment work

  1. save the outerHTML only not the child entities(innerHTML)
  2. this repo has default values for the specific preset so what i did is just save the difference of the default values and the flushed environment that gives me the only changed properties of the environment that has been made through the inspector.

I know this is a hack there should be more simple and consistent way of doing it.

@lazychip
Copy link
Author

lazychip commented Oct 4, 2018

const t = entity.cloneNode(true); const differenceInAttr = difference( entity.getAttribute('environment'), environmentDefaultProps[entity.getAttribute('environment').preset], ); let attrInString = ''; Object.keys(differenceInAttr).forEach(attr => { attrInString +=${attr}:${differenceInAttr[attr]};; }); t.attributes.environment.value = attrInString; t.innerHTML = ''; entitiesString.push(t.outerHTML);

@feiss
Copy link
Contributor

feiss commented Oct 5, 2018

Yeah i think all this is unnecesary complex. If you call to the dumpParametersDiff() function of the component:

document.querySelector('[environment]').components['environment'].dumpParametersDiff();

you will get the settings you need to recreate the same environment:

 document.querySelector('[environment]').setAttribute('environment', settings);

I just realized that dumpParametersDiff() only dumps to console, doesn't return an object with the settings so you can save them programatically. I can fix that if you feel this solves your problem.

@lazychip
Copy link
Author

Yeah sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants