-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Examples - Update WebGPU Compute Water #30440
base: dev
Are you sure you want to change the base?
Conversation
@sunag looks good? |
@cmhhelgeson did a great job, I just would like to think a little more about |
Dirty version I was able to come up with in StructNode, though it currently has only limited use cases (i.e it can destructure right after creating a struct but not a struct that has been returned from a funtion). I'll try experimenting from here. destructure() {
const structMembers = this.structLayoutNode.membersLayout.map( member => member.name );
const memberNodes = {};
for ( const member of structMembers ) {
memberNodes[ member ] = this.get( member );
}
return memberNodes;
} // Use Case const neighborValues = NeighborValuesStruct();
const { north, south, east, west } = neighborValues.destructure();
north.assign( store.element( northIndex ) );
south.assign( store.element( southIndex ) );
east.assign( store.element( eastIndex ) );
west.assign( store.element( westIndex ) );
return neighborValues; Would we prefer destructure(StructNodeInstance) or StructNodeInstance.destructure() |
Initially I did the assignment directly from the declaration of const neighborValues = NeighborValuesStruct();
neighborValues.north.assign( ... ) The problem is that this doesn't work when we work with TSL function returns. So my solution was to create Then I thought about generating a member for properties that had the const neighborValues = NeighborValuesStruct();
neighborValues.$north.assign( ... ) This would solve the case, since with the prefix you could still access undefined properties of the Nodes. But I would be extremely dependent on the Proxy class, and to be honest, I hope we can do everything with prototype in the future. So I was thinking about using |
👍 |
Related issue: #30426
Description
Updates WebGPU Compute Water to demonstrate an example of returning a struct from a defined function. DOES NOT solve the issue mentioned by this comment in this initial struct implementation, which is still under investigation: #30394 (comment)