-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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 #11951
Comments
This is looking really good! By the way, we are planning to remove * @mrdoob, any preference on when that should happen? IMO we could do this now, unless we want to keep |
I think the sooner the better. As long as the new |
IIRC we can detect by seeing |
✅ Yep! #11864 |
Cool! But I've found a minor bug. I'm making PR now. Let's merge before we rename. |
Can we specify the items that someone is working on in the checklist? |
@takahirox sure! people could just write comments here and I could update the list and point to a PR if there's something going on already |
The next thing I'll be working is on the textures, to convert them to base64 instead of using just the url |
Thanks! I wanna help making glTF exporter. I'm looking into what I can help in the checklist... BTW have you purposely let two variables |
@takahirox cool! |
@takahirox btw feel free to propose new items to the list of course! ;) |
@fernandojsg Sure! About the variables, I wanted to propose to move them to somewhere if they're purposely declared as global so it's nice to know that you do. |
I wanna work on shared buffer view.
The reason why one for the attributes that share the same componentType, not one for all the attributes, is for data alignment, correct? https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment |
Cool, I've just added you to the list 👍 Yep, basically you want to share the same buffer view for component with the same type, for example if you have position and normal you'll have two VEC3 accessors but they'll point to the same bufferview. That could be a great starting point ;) |
I meant, the reason why we don't let buffer view be shared among different componentType (ex: float and short) is to keep good data alignment, correct? |
I believe you can store in the same buffer view different component types as long as they've the same |
Yep, agreed. And as this glTF specification mentions https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment
It's a good idea that we separate buffer views between the different componentType(=data type like float and short, not vec2 or vec3) for the simplicity. If we separate them between different data length componentType, it'd be more optimized. |
BTW is there any special reasons why the current exporter supports only |
@takahirox not really, I just defined these by now because are the ones used for the type of attributes we support right now (positions, normals, colors, uvs, indices..). |
OK, so I first will work on the |
Would you add animation to the list? |
@takahirox sure, it could be great to add animation. I just didn't add it because I wasn't familiar enough with the current state of the animation features on three.js, but if you feel like taking over it, it would be great ;) |
Do you plan to support BufferGeometry groups? |
@marcatec The glTF spec does have a "mesh" vs. "primitive" distinction that would allow you to create BufferGeometry groups that could each reference a different material. Currently THREE.GLTFLoader does not optimize loading primitives — it creates separate meshes — but that could be implemented. |
Great work, great list and good to know there is already so much support on the format! Also works very well together with gltf blender exporter too. Can't wait for lights support! Keep up the great work. |
I concur, great work! Are there plans to add support for other materials apart from StandardMaterial? Thanks! |
I've just noticed that the validator throws an error on every normal element on a bufferview that is not normalized. eg If I stored uninitialized values like [0,0,0] it will throw that error. |
Seems like https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#meshes
Agreed with ensuring because Three.js normal doesn't have such a limitation. |
Yep, but what to do when you don't have an actual normal, like an unused value of [0,0,0], just create a valid one and that's all right? let's say [1,0,0]. So we should modify the bufferview code to detect that we're parsing a normal attribute and normalize each one before saving it to the dataview. |
Hm.... replacing with a valid one and displaying warning?
I prefer doing that in
If we do that in |
Yep I like that approach, I was afraid to modify the normals after exporting, but it should be ok if we save a reference put them back again after finishing. 👍 Would you mind pushing a PR with these changes? or want me to do it? |
OK, I will. (Are you in hurry to fix that?) |
@takahirox cool, thanks! but no rush I was just reviewing the state of the exporter ^_^ |
OK, then I'll do |
Right, glTF does not allow for omitting normals on particular vertices but not others in a single primitive. We'll need to provide some sort of value, strip these vertices, or throw an error. |
I would prefer to make things easier for the user so my vote is for creating a new normals array normalizing them and adding a (0,1,0) value for the empty ones. |
Seems good. If it's slow for large models we might want a |
Yep I was just about to write the same! :D |
I'm gonna make PR without that option first. Let's add when/if necessary. Personally I suppose this check doesn't slow much. |
I was normalizing the whole buffers when loading each stroke on a-painter and it quite slow |
Even if just checking if they're normalized? |
@takahirox you will need to compute the length anyway so I guess it won't change that much |
Hm, ok. I'll evaluate with the PR. |
It is the first GLTFExporter feature we've introduced that does any computation with each vertex (except relative/absolute morph target conversion) so yeah potentially slower.. either way though. |
Great work! IMHO should be merged into core three.js, rather than in "examples". |
PR #15519 adds KHR_lights_punctual. :) |
I think this issue can probably be closed — the remaining items are less critical convenience or optimization, and can be tracked elsewhere:
|
Hey guys, does anyone know how can I export a custom shaped mesh by morph changes applying the morphs and removing it from the final object? |
@vini-guerrero Please use the forums (https://discourse.threejs.org/) or Stack Overflow for help, rather than GitHub issues. |
@qxx861305133 This issue will be resolved with the next release |
I would like to use this issue to keep track of the GLTF2 exporter features. I've copied the initial list of features discussed on the PR #11917 and I'll keep updating the list as we progress in the implementation.
Features / TO-DO
Export options
trs
to export TRS instead of matrixinput
:truncateDrawRange
: force exporting just the attribute values defined bydrawRange
:Include
userData
inextras
?Scenes
Nodes
TANGENTMaterials:
Ignore if default material is being usedmaterial.wireframe === true
pbrMetallicRoughness
forMeshStandardMaterial
baseColorFactor
metallicFactor
roughnessFactor
baseColorTexture
: It's supported (material.map
) but thetexCoord
is always set to 0.doubleSided
Samplers
Images
uri
usingmap.image.src
uri
base64bufferView
flipY
imagesAccessors
bufferView
for the same componentType instead of creating a new one for each attribute (WIP @takahirox)Supportsparse
?bufferView
byteOffset
: Currently it's using 0 always as I'm creating a new bufferView for each accessor.componentType
count
max
min
type
:SCALAR
VEC2
VEC3
VEC4
BufferViews: Currently I'm creating a new
bufferView
for eachAccessor
, this should be fixed to use just one for these attributes that share the samecomponentType
buffer
byteOffset
byteLength
byteStride
target
Buffers: Currently I'm saving everything to a single buffer so it will be just one entry in the buffers array.
Animations
misc:
stats
option to log the number of items exported and maybe some timing?GLB
Example
Current demo:

Exported gltf loaded on @donmccurdy 's gltf viewer

GLTF: https://gist.github.com/fernandojsg/0e86638d81839708bcbb78ab67142640
The text was updated successfully, but these errors were encountered: