Skip to content

Commit

Permalink
USDZExporter: Reduce vectors precision.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Feb 16, 2021
1 parent 4ad0d3c commit e35432a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/jsm/exporters/USDZExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ async function imgToU8( image ) {

//

const PRECISION = 7;

function buildHeader() {

return `#usda 1.0
Expand Down Expand Up @@ -224,7 +226,7 @@ function buildVector3Array( attribute, count ) {

for ( let i = 0; i < data.length; i += 3 ) {

array.push( `(${ data[ i + 0 ] }, ${ data[ i + 1 ] }, ${ data[ i + 2 ] })` );
array.push( `(${ data[ i + 0 ].toPrecision( PRECISION ) }, ${ data[ i + 1 ].toPrecision( PRECISION ) }, ${ data[ i + 2 ].toPrecision( PRECISION ) })` );

}

Expand All @@ -246,7 +248,7 @@ function buildVector2Array( attribute, count ) {

for ( let i = 0; i < data.length; i += 2 ) {

array.push( `(${ data[ i + 0 ] }, ${ 1 - data[ i + 1 ] })` );
array.push( `(${ data[ i + 0 ].toPrecision( PRECISION ) }, ${ 1 - data[ i + 1 ].toPrecision( PRECISION ) })` );

}

Expand Down

0 comments on commit e35432a

Please sign in to comment.