Skip to content

lightPosition attribute not working #72

Open

Description

@alfongj

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..

Activity

  1. alfongj commented on Nov 5, 2021

    @alfongj
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions