feat: Add @typegpu/three package and Three.js integration example#1453
feat: Add @typegpu/three package and Three.js integration example#1453
Conversation
|
pkg.pr.new packages benchmark commit |
a799ca0 to
f055ea8
Compare
aleksanderkatan
left a comment
There was a problem hiding this comment.
Can we make fromTSL work in TGSL?
const getParticleMass = toTSL(() => {
'use gpu';
const instanceIndex = instanceIndexAccessor.$;
randf.seed(instanceIndex);
const base = (randf.sample() * 3 / 4 + 0.25) *
fromTSL(particleGlobalMass, { type: d.f32 }).$;
});
aleksanderkatan
left a comment
There was a problem hiding this comment.
I had a situation like the following:
const helper = () => { 'use gpu'; ... }
const anotherHelper = () => { 'use gpu'; helper(); ... }
const tslUpdate = Fn(() => { toTSL(helper); toTSL(anotherHelper); ... }This resolves helper function twice. Aside from code duplication, this also made my code incorrect, because I used an injected Math.random() and expected different calls to return the same result. I'm not sure if we can do something about it, if we can't, we should definitely mention it in docs.
By the way, a nice side effect of console logs being not supported is that we can check exactly how many times a function is resolved.
aleksanderkatan
left a comment
There was a problem hiding this comment.
Great changes! 3️⃣☕📝
apps/typegpu-docs/src/examples/threejs/compute-cloth/output.wgsl
Outdated
Show resolved
Hide resolved
apps/typegpu-docs/src/examples/threejs/compute-cloth/triNoise.ts
Outdated
Show resolved
Hide resolved
Sorry, it was my fault for using this function in compute and in render at the same time. |

Disclaimer: Very WIP