mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.7k stars 35.37k forks source link

Why `three/tsl` & `three/webgpu` exports are the same? #29847

Closed satelllte closed 2 days ago

satelllte commented 4 days ago

Description

I'm wondered why it turned out that these are the same?

https://github.com/mrdoob/three.js/blob/d35544a5c9fcb48c5020dac683c4e5ddb7f8aaf7/package.json#L18-L19

To my understanding of how WebGPU works in Three.js, I typically want to import only WebGPU-related things from three/webgpu (e.g., WebGPURenderer) while TSL-related things - from three/tsl, like so:

import { WebGPURenderer } from 'three/webgpu';
import { uniform } from 'three/tsl';

because TSL feels to me not a unique thing for WebGPU only, since TSL documentation states:

TSL is also capable of encoding code into different outputs such as WGSL/GLSL - WebGPU/WebGL

Solution

Wouldn't we want to leave only TSL things in three/tsl and WebGPU things in three/webgpu?

Alternatives

N/A

Additional context

No response

Spiri0 commented 3 days ago

Because all tsl elements come from three.webgpu.js if you use three.webgpu.js. As far as I know, you could use THREE. instead of import tsl. For example, THREE.MeshBasicNodeMaterial(). The advantage of import tsl from three.webgpu.js is that you don't need the prefix THREE. So tsl is an integral part of three.webgpu.js and nothing that exists alongside it.

Mugen87 commented 2 days ago

Merging this into #29644.

We are currently trying to figure out the imports which work for both WebGPURenderer and WebGLRenderer. This might take a few iterations until we find the best solution.

Spiri0 commented 2 days ago

Personally, it doesn't bother me whether it's tsl or three.webgpu.js, but the latter has the charm that it makes it clear that the nodes all come from three.webgpu.js

satelllte commented 1 day ago

In my opinion, it would be useful to have all TSL nodes exported under /tsl making sure it's backend-agnostic, while the stuff related to WebGPU can live under /webgpu.