# Passing array to TSL function

**URL:** <https://discourse.threejs.org/t/passing-array-to-tsl-function/76859>\
**Category:** Questions\
**Tags:** tsl, shaders\
**Created:** [January 22, 2025, 2:38pm UTC](https://discourse.threejs.org/t/passing-array-to-tsl-function/76859 "2025-01-22T14:38:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [January 22, 2025, 4:16pm UTC](https://discourse.threejs.org/t/passing-array-to-tsl-function/76859/2 "2025-01-22T16:16:39Z")

</div>

If you need a uniform array, use `uniformArray()`. E.g.

```js
const tintColors = uniformArray( [
	new Color( 1, 0, 0 ),
	new Color( 0, 1, 0 ),
	new Color( 0, 0, 1 )
], 'color' );

```

If the array data are constants and don’t have to be uniforms, you have to wait until the following PR is merged:

> <https://github.com/mrdoob/three.js/pull/30386>
>
> Closes https://github.com/mrdoob/three.js/issues/30097
> 
> \*\*Description\*\*
> 
> The… implementation has two types of declarations \`array( \[...nodes \] )\` and \`array( 'type', count )\`. Both are compatible with \`.toConst()\` and \`.toVar()\` and have been updated in parse. \`TempNode\` has also been updated to automatically generate cache if \`.toVar()\` is not used.
> 
> \`\`\`js
> // style 1 - constants
> const a = array( \[vec3(), vec3() \] );
> 
> // style 1 - runtime values
> const b = array( \[uniform( 1 ), a.element( 0 ).x \] );
> 
> // style 2 - constants
> const c = array( 'vec3', 2 );
> 
> // style 3 - constants / runtime values
> const d = vec3( 0, 0, 1 ).toArray( 2 ); // the result will be: \[vec3( 0, 0, 1 ), vec3( 0, 0, 1 ) \]
> 
> // .toVar() and assigns
> const e = array( \[vec3(), vec3() \] ).toVar();
> e.element( 0 ).assign( vec3() );
> 
> // .toConst()
> const f = array( \[vec3(), vec3() \] ).toConst();
> const v = f.element( 0 );
> \`\`\`

---

_[View the full topic](https://discourse.threejs.org/t/passing-array-to-tsl-function/76859)._
