-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
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
GLTF2 Exporter #11917
GLTF2 Exporter #11917
Conversation
One of the issues I've found with the images is that GLTF lacks of support for |
e7fe438
to
6c894ca
Compare
In |
is OBJExporter geometry-only? I guess this hasn't come up yet. Maybe support for
Roughness and metalness must be packed together in a single texture for glTF. Also |
8597595
to
f8d0c1d
Compare
What's |
Yep! |
I think for the time I would just do |
^I would omit this. Most of the extension probably won't be added to glTF 2.0, just a slimmed down Phong-only version, which isn't finished yet. |
My fault 👼 I don't know what I was doing there :)
Right now you can store everything you want in
Cool, I'll give it a try thanks. |
Ok, I've just read that we could have
So what we do when the material is not |
444c090
to
91f0a99
Compare
…tributes in vertices
@mrdoob I can't find |
my fault, I believe you were referring to |
50ca8d3
to
4c3c7d0
Compare
4c3c7d0
to
84fccec
Compare
GLTF doesn't have support for the |
662a496
to
ea2f88e
Compare
examples/gltf_exporter.html
Outdated
// --------------------------------------------------------------------- | ||
// Ambient light | ||
// --------------------------------------------------------------------- | ||
scene1.add( new THREE.AmbientLight( 0xffffff ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have noticed that the glTF examples are over-bright. This should be something like:
scene1.add( new THREE.AmbientLight( 0xffffff, 0.2 ) );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done!
examples/gltf_exporter.html
Outdated
// --------------------------------------------------------------------- | ||
// DirectLight | ||
// --------------------------------------------------------------------- | ||
var light = new THREE.DirectionalLight( 0xffffff ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is OK. Same as:
var light = new THREE.DirectionalLight( 0xffffff, 1 );
Just so everyone is on the same page, with the exception of |
@WestLangley yes, but as GLTF doesn't allow us to define a flat shading material (AFAIK, /cc @donmccurdy) the only way we could differentiate between flat and smooth is by processing the vertex shader before exporting them |
bf07f99
to
4071a40
Compare
The exporter is already fully functional, the most important parts that are missing in this PR:
Here is the current example exported and imported on @donmccurdy 's viewer (note that ambient light is different too) I believe it's better to review the current features so we could keep evolving it in smaller feature-based PRs that would be easier to review than growing this one too much. |
@fernandojsg If normals are omitted, glTF requires viewers to display the mesh with flat shading (source). |
Sounds a bit too complicated. I would ignore this for now. |
Do you want to merge this in the meantime? |
@donmccurdy cool, I didn't know that, thanks! So a first approach could be to just delete de normals for the mesh with |
Many thanks! |
This is a WIP GLTF v2 Exporter.
The code is not clean yet but I wanted to have a place to discuss this implementation from the very beginning so I hope we could end up with a fully featured exporter.
Features / TO-DO:
Include
userData
inextras
?Scenes
Nodes
KHR_Light
extensionMaterials:
material.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 attributesparse
?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.
Output from the current example scene: https://pastebin.com/s8Hd1AWZ
NOTE: I've added a simple example (
gltf_exporter.html
) just to have something quick to test while developing./cc @donmccurdy @takahirox