Skip to content

Commit b2f7db5

Browse files
authored
docs: Don't use unnecessary comptime in Three.js Attractors example (#2053)
1 parent 6b8540a commit b2f7db5

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

  • apps/typegpu-docs/src/examples/threejs/attractors

apps/typegpu-docs/src/examples/threejs/attractors/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
} from 'three/addons/controls/TransformControls.js';
1212
import { color, uniform } from 'three/tsl';
1313
import * as THREE from 'three/webgpu';
14-
import tgpu from 'typegpu';
1514
import * as d from 'typegpu/data';
1615
import * as std from 'typegpu/std';
1716

@@ -151,7 +150,7 @@ const velocityBuffer = t3.instancedArray(count, d.vec3f);
151150

152151
// typegpu accessors
153152

154-
const comptimeRandom = tgpu['~unstable'].comptime(() => Math.random());
153+
const seed = Math.random();
155154

156155
const velocityBufferAttributeTA = t3.fromTSL(
157156
velocityBuffer.node.toAttribute(),
@@ -174,7 +173,7 @@ const sphericalToVec3 = (phi: number, theta: number) => {
174173
const initCompute = t3.toTSL(() => {
175174
'use gpu';
176175
const instanceIndex = t3.instanceIndex.$;
177-
randf.seed(instanceIndex / count + comptimeRandom());
176+
randf.seed(instanceIndex / count + seed);
178177

179178
const basePosition = randf.inUnitCube()
180179
.sub(0.5)
@@ -194,7 +193,7 @@ reset();
194193

195194
const getParticleMassMultiplier = () => {
196195
'use gpu';
197-
randf.seed(t3.instanceIndex.$ / count + comptimeRandom());
196+
randf.seed(t3.instanceIndex.$ / count + seed);
198197
// in the original example, the values are remapped to [-1/3, 1] instead of [1/4, 1]
199198
const base = 0.25 + randf.sample() * 3 / 4;
200199
return base;

0 commit comments

Comments
 (0)