- 📝 I regularly write articles on https://xuzhusheng.medium.com
xuzhusheng / gltf-to-3d-tiles Goto Github PK
View Code? Open in Web Editor NEWglTF to 3d Tiles Converter. Convert glTF model to Glb, b3dm or 3d tiles format.
License: MIT License
glTF to 3d Tiles Converter. Convert glTF model to Glb, b3dm or 3d tiles format.
License: MIT License
Hi,
I'm trying the CLI to convert a 16MB glTF to 3d-tiles and the process takes more than 10 BG of RAM until it is killed by my kernel.
The gltf file uses big coordinates (up to ~5 000 000), I don't know if it may be related.
python main.py tileset building.gltf outputs/
system Env: windows 10
python Version: 3.10.6
Traceback (most recent call last):
File "C:\Users\ming\Desktop\work\gltf-to-3d-tiles\main.py", line 80, in
app()
File "C:\Users\ming\AppData\Local\Programs\Python\Python310\lib\site-packages\typer\main.py", line 214, in call
return get_command(self)(*args, **kwargs)
File "C:\Users\ming\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1130, in call
return self.main(*args, **kwargs)
File "C:\Users\ming\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
File "C:\Users\ming\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\ming\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\ming\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 760, in invoke
return _callback(*args, **kwargs)
File "C:\Users\ming\AppData\Local\Programs\Python\Python310\lib\site-packages\typer\main.py", line 500, in wrapper
return callback(**use_params) # type: ignore
File "C:\Users\ming\Desktop\work\gltf-to-3d-tiles\main.py", line 33, in tileset
gltf_to_tileset(fin, fout, measure, up_direction)
File "C:\Users\ming\Desktop\work\gltf-to-3d-tiles\converter\gltf_to_tileset.py", line 75, in gltf_to_tileset
gltf, buffers = io.read_gltf(fin)
File "C:\Users\ming\Desktop\work\gltf-to-3d-tiles\gltf\io.py", line 14, in read_gltf
data = json.load(f)
File "C:\Users\ming\AppData\Local\Programs\Python\Python310\lib\json_init.py", line 293, in load
return loads(fp.read(),
File "C:\Users\ming\AppData\Local\Programs\Python\Python310\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x88 in position 8: invalid start byte
Thank you for writing this tool.
I want to convert a gltf/glb file to b3dm.
But EVERY file I tried throws errors.
some errors:
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 8: invalid continuation byte
Glb(buffers, **gltf.as_dict(False)).as_bytes()).as_bytes())
TypeError: Glb.__init__() got multiple values for argument 'buffers'
I've tried to tweak some codes but no luck.
I wonder if my files are broken or my environment got something wrong.
One of the test files: https://models.babylonjs.com/aerobatic_plane.glb
What's the expected python version to run this tool? I'm using 3.10.
Execute the command: python .\main.py glb demo.gltf demo.glb prompts the following error,how to fix?
Traceback (most recent call last):
File "\gltf-to-3d-tiles-main\main.py", line 104, in
app()
File " \lib\site-packages\typer\main.py", line 214, in call
return get_command(self)(*args, **kwargs)
File " \lib\site-packages\click\core.py", line 1128, in call
return self.main(*args, **kwargs)
File " \lib\site-packages\click\core.py", line 1053, in main
rv = self.invoke(ctx)
File " \lib\site-packages\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File " \lib\site-packages\click\core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File " \lib\site-packages\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
File " \lib\site-packages\typer\main.py", line 500, in wrapper
return callback(**use_params) # type: ignore
File " \gltf-to-3d-tiles-main\main.py", line 85, in glb
copy_textures(fin, fout, gltf.images)
File " \gltf-to-3d-tiles-main\main.py", line 50, in copy_textures
for image in images:
TypeError: 'NoneType' object is not iterable
In the Slicer class, the entry point is a root node. However, not all glTF files have a root node. Some files may have multiple nodes at the same level, which seems to be incompatible with this project.
I converted some models into tiles-set getting incorrect bounding box volume values, that reason only some tiles loading on fit view.
I used your project to convert a gltf model into 3D Tiles, but I can't adjust its position.
when i put a gltf path in b3dm() or other function ,it has fault like:
OSError: [Errno 63] File name too long: '/Users/zc/work/test/data:application/octet-stream;base64
this is why?how i can solve this problem or how can i convert gltf to b3dm or 3dtiles?
Original GLTF has a texture assigned and is pre-tiled as you can see in the picture
I am trying to generate a tileset based on the GLTF, after executing the command
python main.py tileset path_to_gltf.gtlf
the tileset.json as well as the .b3dm files corresponding to the tiles are generated successfully. Upon loading the 3D tiles in a 3D viewer the texture is missing from most of the tiles. I also tried loading the tiles in a Cesium-based viewer and the textures are also missing. What would be the solution here? I saw that there are some recent commits addressing texture issues, maybe this problem is related? Let me know if this information is enough, thanks for looking into it.
Hi!
I have a GLB-file with cube model that I want view in the cesium (cube.glb). Trying to generate tiles produces the result:
{
"asset": {
"version": "1.0",
"tilesetVersion": "1.0.0.0"
},
"geometricError": 6.928203230275509,
"root": {
"boundingVolume": {
"box": [
0.0, 0.0, 0.0,
2.0, 0, 0,
0, 2.0, 0,
0, 0, 2.0
]
},
"geometricError": 6.928203230275509,
"refine": "ADD",
"children": [
{
"boundingVolume": {
"box": [
0.0, 0.0, 0.0,
1.0, 0, 0,
0, 1.0, 0,
0, 0, 1.0
]
},
"geometricError": 6.928203230275509,
"transform": [
2.0, 0.0, 0.0, 0.0,
0.0, 2.0, 0.0, 0.0,
0.0, 0.0, 2.0, 0.0,
0.0, 0.0, 0.0, 1.0
],
"content": {
"uri": "0.b3dm"
}
}
]
}
}
Q: Is the transform section positioned correctly?
In order to get the correct result in a cesium, I have to generate a b3dm file (b3dm mode), replace name inside uri section and move the transform section to the correct place and change it's content. It seems to me that there are too many operations.
split model:
Horse.zip
I try to convert gltf to tileset ,but get the error:
AttributeError: 'NoneType' object has no attribute 'as_dict'
gltf data:
AllFiles2.zip
I generated a .gltf
file using another tool. When processing it with gltf-to-3d-tiles
, I found that self.scene = None
in Slicer.__init__()
.
This is easily fixed by setting self.scene = 0
to make the tool resilient, though it is probably an error in the previous tool that I used that caused no scene to be set in that resulting data.
A high-level error message could be preferable to this:
File "...\gltf-to-3d-tiles\gltf\slicer.py", line 24, in __init__
root = self.scenes[self.scene].nodes[0]
TypeError: list indices must be integers or slices, not **NoneType**
I have some glTF files which are in z-up coordinates (i.e. they came in UTM-ish coordinates). It would be useful if there was an option to tell the converter not to apply the Z_UP_TO_Y_UP_MATRIX
when generating tilesets.
`PS \gltf-to-3d-tiles-main> python .\main.py tileset .\0input\shenzhenxiaoxue.gltf
Traceback (most recent call last):
File ".\main.py", line 80, in
app()
File ".\main.py", line 33, in tileset
gltf_to_tileset(fin, fout, measure, up_direction)
File "D:\Users\hpl\Downloads\Compressed\gltf-to-3d-tiles-main_2\gltf-to-3d-tiles-main\converter\gltf_to_tileset.py", line 79, in gltf_to_tileset
tiles = list(map(lambda id: Tile(content_id=id, instance_box=gltf_slicer.get_bounding_box(
File "D:\Users\hpl\Downloads\Compressed\gltf-to-3d-tiles-main_2\gltf-to-3d-tiles-main\converter\gltf_to_tileset.py", line 80, in
id), instances_matrices=gltf_slicer.get_matrices(id), matrix=Matrix4(), gltf=gltf_slicer.slice_mesh(id).as_bytes(), extras=gltf_slicer.get_extras(id)), range(gltf_slicer.meshes_count)))
File "D:\Users\hpl\Downloads\Compressed\gltf-to-3d-tiles-main_2\gltf-to-3d-tiles-main\gltf\slicer.py", line 125, in slice_mesh
return self.slice_primitives(self.meshes[mesh_id].primitives)
File "D:\Users\hpl\Downloads\Compressed\gltf-to-3d-tiles-main_2\gltf-to-3d-tiles-main\gltf\slicer.py", line 89, in slice_primitives
return Glb([self.__get_buffer(buffer_view_indices)], meshes=self.__get_meshes(primitives, accessor_indices, material_indices), accessors=self.__get_accessors(accessor_indices, buffer_view_indices),
File "D:\Users\hpl\Downloads\Compressed\gltf-to-3d-tiles-main_2\gltf-to-3d-tiles-main\gltf\slicer.py", line 152, in __get_buffer
view = self.buffer_views[index]
TypeError: list indices must be integers or slices, not NoneType`
I generated a tileset from this gltf and the resulting tileset seems to be either missing nodes or is incorrectly generated.
acc_base_model_gltf.zip
acc_base_model.bin
It generated this tileset.json
tileset.json.zip
This is what the tileset looks like in Cesium
Cesium Sandcastle test
Cesium generated tileset.json
tileset.json.zip
Hello, is it possible with this exporter to assign latitude/longitude/altitude for tileset calculations ?
Hi, is there a way to apply an adjustment transform? I need to adjust the position of the 3d tiles. This works on Cesium ion, it adds a transform array but I would like to be able to do this kind of thing with this library or is there a way to patch the generated tileset.json file?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.