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: Introduce struct #30394

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft

TSL: Introduce struct #30394

wants to merge 3 commits into from

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Jan 25, 2025

Related issue: #29908, #29760

Description

PR introduces struct for TSL following the styntax below:

const BoundingBox = struct( {
	min: 'vec3',
	max: 'vec3'
} );

// style 1
const bb = BoundingBox( vec3( 0 ), vec3( 1 ) );

// style 1 - default value
const bb = BoundingBox();

// style 2
const bb = BoundingBox( {
	min: vec3( 0 ), 
	max: vec3( 1 ) 
} );

// style 2 - optional values
const bb = BoundingBox( {
	// min: vec3( 0 ),  // use optional value
	max: vec3( 1 ) 
} );

// assigns in TSL Fn
const bbFn = Fn( () => {

	const bb = BoundingBox();

	const bbMax = bb.get( 'max' );
	bbMax.assign( vec3( 1 ) );
	// or -> bb.get( 'max' ).assign( vec3( 1 ) );

	return bb;

} );

// debug
material.colorNode = bbFn().get( 'max' );

Copy link

github-actions bot commented Jan 25, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.27
78.29
336.27
78.29
+0 B
+0 B
WebGPU 512.43
142.35
514.55
142.95
+2.11 kB
+595 B
WebGPU Nodes 511.9
142.25
514.01
142.84
+2.11 kB
+594 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.25
112.13
465.25
112.13
+0 B
+0 B
WebGPU 586.38
159.04
587.2
159.31
+816 B
+278 B
WebGPU Nodes 541.76
148.6
542.58
148.87
+816 B
+268 B

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.

1 participant