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: export rendertarget #28653

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

marwie
Copy link
Contributor

@marwie marwie commented Jun 13, 2024

Related issue: #28652

Description

Currently exporting a scene that has a WebGLRendertarget Texture on any object breaks export altogether.

This PR adds a reference to the original WebGLRenderTarget to the underlying textures - not sure if this coupling is something you'd consider keeping.

Perhaps the same could be done by a writer plugin - but I'm not sure how how to 1) either get a reference to the WebGLRenderTarget to be able to readback the pixels or 2) if there's a different preferred solution (e.g. blitting the render target to a new texture like with compressed textures)

This contribution is funded by Needle

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
679.4 kB (168.3 kB) 679.5 kB (168.3 kB) +42 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
457.4 kB (110.4 kB) 457.4 kB (110.4 kB) +42 B

const cube = new THREE.Mesh( new THREE.BoxGeometry( 200, 200, 200 ), new THREE.MeshBasicMaterial( { color: 0xffffff, map: renderTexture.texture } ) );
scene1.add( cube );

}, 10)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just some hacky test code of course.

const cube = new THREE.Mesh( new THREE.BoxGeometry( 200, 200, 200 ), new THREE.MeshBasicMaterial( { color: 0xffffff, map: renderTexture.texture } ) );
scene1.add( cube );

}, 10)

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (99% of all statements in
the enclosing function
have an explicit semicolon).

const width = map.image.width;
const height = map.image.height;
const buffer = new Uint8Array(width * height * 4);
Copy link
Collaborator

@Mugen87 Mugen87 Jun 15, 2024

Choose a reason for hiding this comment

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

Always assuming RGBA8 is not safe, see #28652 (comment).

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.

None yet

2 participants