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: Add forcePowerOfTwoTexture option #13424

Merged
merged 3 commits into from
Feb 24, 2018

Conversation

takahirox
Copy link
Collaborator

@takahirox takahirox commented Feb 24, 2018

#13397 (comment)

This PR adds forcePowerOfTwoTexture option to GLTFExporter.

Repository owner deleted a comment from takahirox Feb 24, 2018
@@ -459,21 +473,36 @@ THREE.GLTFExporter.prototype = {
var mimeType = map.format === THREE.RGBAFormat ? 'image/png' : 'image/jpeg';
var gltfImage = { mimeType: mimeType };

if ( options.embedImages ) {
if ( options.embedImages || ( options.forcePowerOfTwoTexture && ! isPowerOfTwo( map.image ) ) ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this instead?

			if ( options.embedImages ) {

				var canvas = cachedCanvas = cachedCanvas || document.createElement( 'canvas' );

				canvas.width = map.image.width;
				canvas.height = map.image.height;

				if ( options.forcePowerOfTwoTexture && ! isPowerOfTwo( map.image ) ) {

					console.warn( 'GLTFExporter: image is not power of two. Resized and embedded.', image );

					canvas.width = THREE.Math.floorPowerOfTwo( canvas.width );
					canvas.height = THREE.Math.floorPowerOfTwo( canvas.height );

				}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, you meant you wanna POT conversion only if options.embedImages is true?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... At least for now.

Copy link
Collaborator Author

@takahirox takahirox Feb 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I've updated. We might need to make clear that .forcePowerOfTwoTexture option works only if .embedImages is true by renaming the option or adding note to doc. Let's do that in another PR if necessary (sorry time to sleep here now!).

@mrdoob
Copy link
Owner

mrdoob commented Feb 24, 2018

image

Uh? I didn't. I deleted my own comments...

@mrdoob mrdoob added this to the r91 milestone Feb 24, 2018
@takahirox
Copy link
Collaborator Author

Uh? I didn't. I deleted my own comments...

Haha, ok I believe in you.

@mrdoob mrdoob merged commit 69ebfb9 into mrdoob:dev Feb 24, 2018
@mrdoob
Copy link
Owner

mrdoob commented Feb 24, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants