未验证 提交 62abc5a7 编写于 作者: M Michael Herzog 提交者: GitHub

Merge pull request #17553 from Mugen87/dev34

GLTFExporter: Introduce options maxTextureWidth and maxTextureHeight.
......@@ -94,6 +94,7 @@
<li>truncateDrawRange - bool. Export just the attributes within the drawRange, if defined, instead of exporting the whole array. Default is true.</li>
<li>binary - bool. Export in binary (.glb) format, returning an ArrayBuffer. Default is false.</li>
<li>embedImages - bool. Export with images embedded into the glTF asset. Default is true.</li>
<li>maxTextureSize - int. Restricts the image maximum size (both width and height) to the given value. This option works only if embedImages is true. Default is Infinity.</li>
<li>animations - Array<[page:AnimationClip AnimationClip]>. List of animations to be included in the export.</li>
<li>forceIndices - bool. Generate indices for non-index geometry and export with them. Default is false.</li>
<li>forcePowerOfTwoTextures - bool. Export with images resized to POT size. This option works only if embedImages is true. Default is false.</li>
......
......@@ -94,6 +94,7 @@
<li>truncateDrawRange - bool. Export just the attributes within the drawRange, if defined, instead of exporting the whole array. Default is true.</li>
<li>binary - bool. Export in binary (.glb) format, returning an ArrayBuffer. Default is false.</li>
<li>embedImages - bool. Export with images embedded into the glTF asset. Default is true.</li>
<li>maxTextureSize - int. Restricts the image maximum size (both width and height) to the given value. This option works only if embedImages is true. Default is Infinity.</li>
<li>animations - Array<[page:AnimationClip AnimationClip]>. List of animations to be included in the export.</li>
<li>forceIndices - bool. Generate indices for non-index geometry and export with them. Default is false.</li>
<li>forcePowerOfTwoTextures - bool. Export with images resized to POT size. This option works only if embedImages is true. Default is false.</li>
......
......@@ -78,6 +78,7 @@ THREE.GLTFExporter.prototype = {
onlyVisible: true,
truncateDrawRange: true,
embedImages: true,
maxTextureSize: Infinity,
animations: [],
forceIndices: false,
forcePowerOfTwoTextures: false,
......@@ -751,10 +752,10 @@ THREE.GLTFExporter.prototype = {
var canvas = cachedCanvas = cachedCanvas || document.createElement( 'canvas' );
canvas.width = image.width;
canvas.height = image.height;
canvas.width = Math.min( image.width, options.maxTextureSize );
canvas.height = Math.min( image.height, options.maxTextureSize );
if ( options.forcePowerOfTwoTextures && ! isPowerOfTwo( image ) ) {
if ( options.forcePowerOfTwoTextures && ! isPowerOfTwo( canvas ) ) {
console.warn( 'GLTFExporter: Resized non-power-of-two image.', image );
......
......@@ -102,6 +102,7 @@ GLTFExporter.prototype = {
onlyVisible: true,
truncateDrawRange: true,
embedImages: true,
maxTextureSize: Infinity,
animations: [],
forceIndices: false,
forcePowerOfTwoTextures: false,
......@@ -775,10 +776,10 @@ GLTFExporter.prototype = {
var canvas = cachedCanvas = cachedCanvas || document.createElement( 'canvas' );
canvas.width = image.width;
canvas.height = image.height;
canvas.width = Math.min( image.width, options.maxTextureSize );
canvas.height = Math.min( image.height, options.maxTextureSize );
if ( options.forcePowerOfTwoTextures && ! isPowerOfTwo( image ) ) {
if ( options.forcePowerOfTwoTextures && ! isPowerOfTwo( canvas ) ) {
console.warn( 'GLTFExporter: Resized non-power-of-two image.', image );
......
......@@ -22,6 +22,7 @@
<label><input id="option_binary" name="visible" type="checkbox">Binary (<code>.glb</code>)</label>
<label><input id="option_forceindices" name="visible" type="checkbox">Force indices</label>
<label><input id="option_forcepot" name="visible" type="checkbox">Force POT textures</label>
<label><input id="option_maxsize" name="maxSize" type="number" value="4096" min="2" max="8192" step="1"> Max texture size</label>
</div>
<script type="module">
......@@ -41,7 +42,8 @@
truncateDrawRange: document.getElementById( 'option_drawrange' ).checked,
binary: document.getElementById( 'option_binary' ).checked,
forceIndices: document.getElementById( 'option_forceindices' ).checked,
forcePowerOfTwoTextures: document.getElementById( 'option_forcepot' ).checked
forcePowerOfTwoTextures: document.getElementById( 'option_forcepot' ).checked,
maxTextureSize: Number( document.getElementById( 'option_maxsize' ).value ) || Infinity // To prevent NaN value
};
gltfExporter.parse( input, function ( result ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册