|
@@ -14,9 +14,9 @@ import {
|
|
|
NearestMipmapLinearFilter,
|
|
|
NearestMipmapNearestFilter,
|
|
|
PropertyBinding,
|
|
|
- RepeatWrapping,
|
|
|
RGBAFormat,
|
|
|
RGBFormat,
|
|
|
+ RepeatWrapping,
|
|
|
Scene,
|
|
|
Vector3
|
|
|
} from "../../../build/three.module.js";
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
//------------------------------------------------------------------------------
|
|
|
// Constants
|
|
|
//------------------------------------------------------------------------------
|
|
|
+
|
|
|
var WEBGL_CONSTANTS = {
|
|
|
POINTS: 0x0000,
|
|
|
LINES: 0x0001,
|
|
@@ -753,7 +754,7 @@ GLTFExporter.prototype = {
|
|
|
/**
|
|
|
* Process image
|
|
|
* @param {Image} image to process
|
|
|
- * @param {Integer} format of the image (e.g. THREE.RGBFormat, RGBAFormat etc)
|
|
|
+ * @param {Integer} format of the image (e.g. RGBFormat, RGBAFormat etc)
|
|
|
* @param {Boolean} flipY before writing out the image
|
|
|
* @return {Integer} Index of the processed texture in the "images" array
|
|
|
*/
|
|
@@ -807,21 +808,32 @@ GLTFExporter.prototype = {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- if ( format !== RGBAFormat && format !== RGBFormat )
|
|
|
- throw "Only RGB and RGBA formats are supported";
|
|
|
+ if ( format !== RGBAFormat && format !== RGBFormat ) {
|
|
|
+
|
|
|
+ console.error( 'GLTFExporter: Only RGB and RGBA formats are supported.' );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( image.width > options.maxTextureSize || image.height > options.maxTextureSize ) {
|
|
|
+
|
|
|
+ console.warn( 'GLTFExporter: Image size is bigger than maxTextureSize', image );
|
|
|
|
|
|
- if ( image.width !== canvas.width || image.height !== canvas.height )
|
|
|
- console.warn( "Image size and imposed canvas sized do not match" );
|
|
|
+ }
|
|
|
|
|
|
let data = image.data;
|
|
|
+
|
|
|
if ( format === RGBFormat ) {
|
|
|
|
|
|
data = new Uint8ClampedArray( image.height * image.width * 4 );
|
|
|
- data.forEach( function ( _, i ) {
|
|
|
|
|
|
- data[ i ] = i % 4 === 3 ? 255 : image.data[ 3 * Math.floor( i / 4 ) + i % 4 ];
|
|
|
+ for ( var i = 0; i < data.length; i += 4 ) {
|
|
|
+
|
|
|
+ data[ i + 0 ] = image.data[ i + 0 ];
|
|
|
+ data[ i + 1 ] = image.data[ i + 1 ];
|
|
|
+ data[ i + 2 ] = image.data[ i + 2 ];
|
|
|
+ data[ i + 3 ] = 255;
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|