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

allow arrays for uniforms #348

Merged
merged 3 commits into from
Apr 5, 2022
Merged

Conversation

schiller-manuel
Copy link
Contributor

No description provided.

Copy link
Contributor

@wcandillon wcandillon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic thks!
I've made a minor refactoring in the JS part, I think you will approve.
I also seen that we do a flat(4) at the end but that's actually a bit random right? (my original thinking was like vec4 -> flat(4) but that's not how it works 😂

@wcandillon wcandillon merged commit b0e2c4f into Shopify:main Apr 5, 2022
| Vector
| readonly [number, number]
| readonly [number, number, number]
| readonly [number, number, number, number];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you replace ReadonlyArray<number>[]?
The current types do not allow e.g. uniform float3 colors[12];

When trying to pass in a number[][] as a uniform, I get:

Type 'number[][]' is not assignable to type 'Uniform'.
  Type 'number[][]' is not assignable to type 'readonly UniformValue[]'.
    Type 'number[]' is not assignable to type 'UniformValue'.
      Type 'number[]' is not assignable to type 'readonly [number, number, number]'.
        Target requires 3 element(s) but source may have fewer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to allow for number[][]? 🤔

Copy link
Contributor

@wcandillon wcandillon Apr 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you send the example where you need number[][]? I would love to check it.

@schiller-manuel
Copy link
Contributor Author

I also seen that we do a flat(4) at the end but that's actually a bit random right? (my original thinking was like vec4 -> flat(4) but that's not how it works 😂

Yes, I guess a normal flatMap should be used here, no need to specify a flatten depth here.

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

Successfully merging this pull request may close these issues.

2 participants