|
1 | 1 | import { |
2 | 2 | Matrix3, |
3 | | - Vector3 |
| 3 | + Vector3, |
| 4 | + Color |
4 | 5 | } from 'three'; |
5 | 6 |
|
6 | 7 | /** |
@@ -112,6 +113,7 @@ class PLYExporter { |
112 | 113 |
|
113 | 114 | } ); |
114 | 115 |
|
| 116 | + const tempColor = new Color(); |
115 | 117 | const includeIndices = excludeAttributes.indexOf( 'index' ) === - 1; |
116 | 118 | includeNormals = includeNormals && excludeAttributes.indexOf( 'normal' ) === - 1; |
117 | 119 | includeColors = includeColors && excludeAttributes.indexOf( 'color' ) === - 1; |
@@ -305,13 +307,17 @@ class PLYExporter { |
305 | 307 |
|
306 | 308 | if ( colors != null ) { |
307 | 309 |
|
308 | | - output.setUint8( vOffset, Math.floor( colors.getX( i ) * 255 ) ); |
| 310 | + tempColor |
| 311 | + .fromBufferAttribute( colors, i ) |
| 312 | + .convertLinearToSRGB(); |
| 313 | + |
| 314 | + output.setUint8( vOffset, Math.floor( tempColor.r * 255 ) ); |
309 | 315 | vOffset += 1; |
310 | 316 |
|
311 | | - output.setUint8( vOffset, Math.floor( colors.getY( i ) * 255 ) ); |
| 317 | + output.setUint8( vOffset, Math.floor( tempColor.g * 255 ) ); |
312 | 318 | vOffset += 1; |
313 | 319 |
|
314 | | - output.setUint8( vOffset, Math.floor( colors.getZ( i ) * 255 ) ); |
| 320 | + output.setUint8( vOffset, Math.floor( tempColor.b * 255 ) ); |
315 | 321 | vOffset += 1; |
316 | 322 |
|
317 | 323 | } else { |
@@ -464,10 +470,14 @@ class PLYExporter { |
464 | 470 |
|
465 | 471 | if ( colors != null ) { |
466 | 472 |
|
| 473 | + tempColor |
| 474 | + .fromBufferAttribute( colors, i ) |
| 475 | + .convertLinearToSRGB(); |
| 476 | + |
467 | 477 | line += ' ' + |
468 | | - Math.floor( colors.getX( i ) * 255 ) + ' ' + |
469 | | - Math.floor( colors.getY( i ) * 255 ) + ' ' + |
470 | | - Math.floor( colors.getZ( i ) * 255 ); |
| 478 | + Math.floor( tempColor.r * 255 ) + ' ' + |
| 479 | + Math.floor( tempColor.g * 255 ) + ' ' + |
| 480 | + Math.floor( tempColor.b * 255 ); |
471 | 481 |
|
472 | 482 | } else { |
473 | 483 |
|
|
0 commit comments