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

lightPosition attribute not working #72

Open
alfongj opened this issue Nov 5, 2021 · 1 comment
Open

lightPosition attribute not working #72

alfongj opened this issue Nov 5, 2021 · 1 comment

Comments

@alfongj
Copy link

alfongj commented Nov 5, 2021

Just copy paste the example from the docs:

<a-entity environment="lightPosition: 1 5 -2; groundColor: #445"></a-entity>

doesn't work, the scene is dark. No matter what value of lightPosition I choose

The console prints preset: default; lightPosition: NaN NaN NaN; groundColor: #445 which looks sus..

@alfongj
Copy link
Author

alfongj commented Nov 5, 2021

I think there's an issue with parsing coordinate attributes in general.

A quick hack that fixes this:

In the update() function

const parsedAttributes = JSON.parse(JSON.stringify(this.el.components.environment.attrValue));

      // Add this
      **Object.keys(parsedAttributes).map(function(key, index) {
        const val = parsedAttributes[key];
        if (typeof val == 'string' && val.split(' ').length == 3) {
          const coords = val.split(' ');
          parsedAttributes[key] = {x: coords[0], y: coords[1], z: coords[2]};
        }
      });**

      this.environmentData = {};
      Object.assign(this.environmentData, this.data);
      Object.assign(this.environmentData, this.presets[this.data.preset]);
      // Change this
      **Object.assign(this.environmentData, parsedAttributes);**
      console.log(this.environmentData);

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

1 participant