Skip to content

TSL: Cannot Assign Arrays Conditionally in TSL #31308

Open
@RenaudRohlinger

Description

@RenaudRohlinger

Description

Conditional Array Assignment Limitation

Target WGSL pattern:

var<function> nodeVar: array<vec4<f32>, N>;

if (1 > 0) {
    nodeVar = nodebuffer;
} else {
    nodeVar = otherBuffer;
}

Current TSL Workaround:

const tempArr = array(new Array(22).fill(vec3(0, 0, 0))).toVar();

If(a.greaterThan(0), () => {
  Loop({ start: 0, end: 22, type: 'int' }, ({ i }) => {
    tempArr.element(i).assign(uniformArr.element(i));
  });
});

Requires explicit element-wise copying inside a conditional.

Desired Syntax - Enable array-level assignment:

const tempArr = array(new Array(22).fill(vec3(0, 0, 0))).toVar();

If(a.greaterThan(0), () => {
  tempArr.assign(uniformArr);
});
// or using select

Metadata

Metadata

Assignees

Labels

TSLThree.js Shading Language

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions