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

GLTFExporter: Fix regression in normalized attributes #25076

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions examples/jsm/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ function getMinMax( attribute, start, count ) {
else if ( a === 2 ) value = attribute.getZ( i );
else if ( a === 3 ) value = attribute.getW( i );

if ( attribute.normalized === true ) {

value = MathUtils.normalize( value, attribute.array );

}

}

output.min[ a ] = Math.min( output.min[ a ], value );
Expand Down Expand Up @@ -876,6 +882,12 @@ class GLTFWriter {
else if ( a === 2 ) value = attribute.getZ( i );
else if ( a === 3 ) value = attribute.getW( i );

if ( attribute.normalized === true ) {

value = MathUtils.normalize( value, attribute.array );

}

}

if ( componentType === WEBGL_CONSTANTS.FLOAT ) {
Expand Down Expand Up @@ -1606,12 +1618,14 @@ class GLTFWriter {

for ( let j = 0, jl = attribute.count; j < jl; j ++ ) {

relativeAttribute.setXYZ(
j,
attribute.getX( j ) - baseAttribute.getX( j ),
attribute.getY( j ) - baseAttribute.getY( j ),
attribute.getZ( j ) - baseAttribute.getZ( j )
);
for ( let a = 0; a < attribute.itemSize; a ++ ) {

if ( a === 0 ) relativeAttribute.setX( j, attribute.getX( j ) - baseAttribute.getX( j ) );
if ( a === 1 ) relativeAttribute.setY( j, attribute.getY( j ) - baseAttribute.getY( j ) );
if ( a === 2 ) relativeAttribute.setZ( j, attribute.getZ( j ) - baseAttribute.getZ( j ) );
if ( a === 3 ) relativeAttribute.setW( j, attribute.getW( j ) - baseAttribute.getW( j ) );

}
donmccurdy marked this conversation as resolved.
Show resolved Hide resolved

}

Expand Down