Skip to content

Conversation

@mrdoob
Copy link
Owner

@mrdoob mrdoob commented Apr 27, 2023

Related issue: #25788 #25938

Description

Before this PR we had this setup:

GLTF channel attribute
TEXCOORD_0 0 uv
TEXCOORD_1 1 uv2
TEXCOORD_2 2 uv3
TEXCOORD_3 3 uv4

This PR renames the attributes to match GLTF ids and material.channel:

GLTF channel attribute
TEXCOORD_0 0 uv0 uv
TEXCOORD_1 1 uv1
TEXCOORD_2 2 uv2
TEXCOORD_3 3 uv3

@github-actions
Copy link

github-actions bot commented Apr 27, 2023

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
634.5 kB (157.3 kB) 634.5 kB (157.3 kB) +12 B

🌳 Bundle size after tree-shaking

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

Filesize dev Filesize PR Diff
425.6 kB (103.2 kB) 425.7 kB (103.2 kB) +12 B

@mrdoob
Copy link
Owner Author

mrdoob commented Apr 27, 2023

The uv to uv0 warnings make webgl_geometry_csg super slow.
Maybe we don't really need the warnings...

@mrdoob
Copy link
Owner Author

mrdoob commented Apr 27, 2023

I've updated all the code locally and I'm not loving this new pattern:

 		this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 		this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-		this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+		this.setAttribute( 'uv0', new Float32BufferAttribute( uvs, 2 ) );

I think for now I'm just going to go for this:

GLTF channel attribute
TEXCOORD_0 0 uv
TEXCOORD_1 1 uv1
TEXCOORD_2 2 uv2
TEXCOORD_3 3 uv3

@mrdoob mrdoob changed the title BufferGeometry: Rename uv, uv2, uv3, uv4 to uv0, uv1, uv2, uv3 BufferGeometry: Rename uv, uv2, uv3, uv4 to uv, uv1, uv2, uv3 Apr 27, 2023
@mrdoob mrdoob changed the title BufferGeometry: Rename uv, uv2, uv3, uv4 to uv, uv1, uv2, uv3 BufferGeometry: Renamed uv2, uv3, uv4 to uv1, uv2, uv3 Apr 27, 2023
@mrdoob
Copy link
Owner Author

mrdoob commented Apr 27, 2023

Hmm, I'm having a hard time trying to predict the side effects of this code:

// Backwards compatibilty

Object.defineProperties( this.attributes, {
	'uv2': {
		set: function ( value ) {

			if ( this.uv1 === undefined ) {

				console.warn( 'THREE.BufferGeometry: The attribute uv2 has been renamed to uv1.' );
				this.uv1 = value;

			}

			delete this.uv2;

		},
		configurable: true
	}
} );

I feel this code may break more things than fix...
It may be better to not have it for now and release a patch version when we gather more use cases.

@mrdoob mrdoob added this to the r152 milestone Apr 27, 2023
@mrdoob mrdoob merged commit ef03bdc into dev Apr 27, 2023
@mrdoob mrdoob deleted the uvs2 branch April 27, 2023 08:57

intersection.uv2 = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
intersection.uv2 = intersection.uv1; // Backwards compatibility
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add deprecation comment // @deprecated, r152 here?

SpriteMaterial: 'sprite'
};

function getChannel( value ) {
Copy link
Contributor

@LeviPesin LeviPesin May 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this function would be simpler just as

return value === 0 ? 'uv' : `uv${ value }`;

... Just as you did with the FBXLoader.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the ids are the same the code is more readable yes.

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.

3 participants