Skip to content

ref

A reference to a value T. Can be passed to other functions to give them mutable access to the underlying value.

Conceptually, it represents a WGSL pointer.

T

readonly [$internal]: unknown

packages/typegpu/src/data/ref.ts:29


$

$: T

Derefences the reference, and gives access to the underlying value.

```ts
* const boid = Boid({ pos: d.vec3f(3, 2, 1) });
const posRef = d.ref(boid.pos);
// Actually updates `boid.pos`
posRef.$ = d.vec3f(1, 2, 3);
console.log(boid.pos); // Output: vec3f(1, 2, 3)
#### Defined in
[packages/typegpu/src/data/ref.ts:44](https://github.com/software-mansion/TypeGPU/blob/34bd217a96bf90a92a71321886c6b42239dade55/packages/typegpu/src/data/ref.ts#L44)
***
### type
> `readonly` **type**: `"ref"`
#### Defined in
[packages/typegpu/src/data/ref.ts:30](https://github.com/software-mansion/TypeGPU/blob/34bd217a96bf90a92a71321886c6b42239dade55/packages/typegpu/src/data/ref.ts#L30)