Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSL: add mat convert #28890

Merged
merged 2 commits into from
Jul 16, 2024
Merged

TSL: add mat convert #28890

merged 2 commits into from
Jul 16, 2024

Conversation

z4122
Copy link
Contributor

@z4122 z4122 commented Jul 16, 2024

Support mat4 to mat3 and mat3 to mat2 in TSL.
In glsl, mat3(mat4) is a convinent method to convert matrix, it will help simpify code.

before

const bm = mat3(
			batchingMatrix[ 0 ].xyz,
			batchingMatrix[ 1 ].xyz,
			batchingMatrix[ 2 ].xyz
		 );

after

const bm = mat3( batchingMatrix );

Because WGSL doesn't support code like mat3(mat4). So it will be split into different part in NodeBuilder.js

if ( fromTypeLength === 16 && toTypeLength === 9 ) {

      return `${ this.getType( toType ) }(${ snippet }[0].xyz, ${ snippet }[1].xyz, ${ snippet }[2].xyz)`;

    }

@z4122 z4122 marked this pull request as draft July 16, 2024 16:23
Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
683.5 kB (169.2 kB) 683.5 kB (169.2 kB) +0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
460.7 kB (111.1 kB) 460.7 kB (111.1 kB) +0 B

@z4122 z4122 marked this pull request as ready for review July 16, 2024 16:29
@sunag sunag added this to the r167 milestone Jul 16, 2024
@sunag sunag merged commit dbd5e11 into mrdoob:dev Jul 16, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants