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

fix: GLTFExporter update #167

Closed
wants to merge 2 commits into from

Conversation

mysterybear
Copy link
Contributor

Why

GLTFExporter stopped working

What

Copied some code across from three/jsm/examples

Checklist

  • Ready to be merged

@vercel
Copy link

vercel bot commented Jul 13, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
three-stdlib ✅ Ready (Inspect) Visit Preview Jul 22, 2022 at 0:45AM (UTC)


canvas.width = Math.min(image.width, options.maxTextureSize)
canvas.height = Math.min(image.height, options.maxTextureSize)
canvas.width = Math.min(image.width, options.maxTextureSize!)
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 horrible but let me know how you want to handle this and I'll fix it?


const context = canvas.getContext('2d')

if (!context) throw new Error('No context')
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 maybe horrible too? Let me know how you like to handle this

@mysterybear
Copy link
Contributor Author

Hi, I've written two comments: i) non-null assertion I wrote seems bad; ii) "if no context then throw error" might not be how you like to handle this. Let me know your preferred way to handle these cases and I can change the code!

Also, IIRC this is tested by running the storybook. There isn't a story for GLTFExporter yet. I just tried to start writing one, the Storybook setup isn't easy to understand though, it's not like I can just write some react. What I would think to do is to put a button or a click handler on a mesh, so you click the button or the mesh to export the GLTF. It's not immediately clear to me how to do this, if you could let me know or point me to some prior docs that would help with this then I can!

This was referenced Jul 13, 2022
package.json Outdated Show resolved Hide resolved
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 861a62f:

Sandbox Source
three-stdlib-ssr Configuration

@mysterybear
Copy link
Contributor Author

Thanks for that @CodyJasonBennett, I tested the package that was built for CSB with yarn add https://pkg.csb.dev/pmndrs/three-stdlib/commit/861a62fe/three-stdlib. It doesn't error or make any interesting noise in the console but it doesn't export the GLTF successfully as the exporter from examples/jsm does.

This is what it's supposed to look like:

image

This is what it looks like:
image

I'm pretty clueless about this code tbh, I just tried copying across stuff from the diff between when this was last updated and it doesn't seem to have worked unfortunately. Any suggestions?

@Ctrlmonster
Copy link

I just ran into the same issue. The working example linked from the three docs (https://threejs.org/examples/#misc_exporter_gltf)
imports from "addons". Why not copy the code the from there?

import {GLTFExporter} from "three/addons/exporters/GLTFExporter.js";

@CodyJasonBennett
Copy link
Member

Continuing in #241.

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.

3 participants