Closed zysyz closed 2 months ago
Hello! Just like Draco decompression, KTX2 support must be added to a custom-registered GLTFLoader manually. See this section in the docs:
This is done since loading worker / wasm data cannot be published internally in the package and not all tile sets require this functionality so we can avoid downloading it unless needed.
你好!就像 Draco 解压缩一样,必须手动将 KTX2 支持添加到自定义注册的 GLTFLoader 中。请参阅文档中的此部分:
这样做是因为加载 worker / wasm 数据无法在包内部发布,并且并非所有图块集都需要此功能,因此我们可以避免下载它,除非需要。
Thank you for your reply. I have added support for ktx2 in my code, but it did not work and the error still exists
tiles = new TilesRenderer( url );
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath( 'https://unpkg.com/three@0.153.0/examples/jsm/libs/draco/gltf/' );
const ktx2loader = new KTX2Loader();
ktx2loader.setTranscoderPath( 'https://unpkg.com/three@0.153.0/examples/jsm/libs/basis/' );
ktx2loader.detectSupport( renderer );
const loader = new GLTFLoader( tiles.manager );
loader.setDRACOLoader( dracoLoader );
loader.setKTX2Loader( ktx2loader );
loader.register( () => new GLTFCesiumRTCExtension() );
tiles.fetchOptions.mode = 'cors';
tiles.manager.addHandler( /\.gltf$/, loader );
geospatialRotationParent.add( tiles.group );
tiles.manager.addHandler( /\.gltf$/, loader );
This will need to account for gltf
as well as glb
extensions since your files are packed as b3dm. I've updated the docs to reflect this:
tilesRenderer.manager.addHandler( /\.(gltf|glb)$/g, loader );
tiles.manager.addHandler( /\.gltf$/, loader );
This will need to account for
gltf
as well asglb
extensions since your files are packed as b3dm. I've updated the docs to reflect this:这需要考虑到gltf
和glb
扩展名,因为你的文件是打包为b3dm的。我更新了文档以反映这一点:tilesRenderer.manager.addHandler( /\.(gltf|glb)$/g, loader );
After I switched to tilesRenderer. manager. addHandler (/. (gltf | glb) $/g, loader), the error still persists and the texture cannot be loaded. Can you load the texture on your end
It looks like your models do not specify the correct extension required for supporting KTX2 textures.
It looks like your models do not specify the correct extension required for supporting KTX2 textures.看起来您的模型没有指定支持KTX2纹理所需的正确扩展名。
Okay, I tried using Cesium to load this model and there were no issues
Cesium's loader may be a bit looser with the requirements but three.js' GLTFLoader expects the extension to be defined as the GLTF specification requires:
https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md
Cesium's loader may be a bit looser with the requirements but three.js' GLTFLoader expects the extension to be defined as the GLTF specification requires:Cesium的加载器的要求可能有点宽松,但three.js的GLTFLoader希望扩展被定义为GLTF规范要求:
https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md
Thank you for your reply. I think I may have to temporarily give up loading 3dtiles data with ktx2 texture
Adding the necessary extension to GLTF binary shouldn't be too intrusive but it depends on how you are generating the assets. Unfortunately this isn't something I can help with, though. In general files should follow the GLTF specification to ensure portability.
I'll close this for now, though, because ultimately this is an issue related to three.js' GLTFLoader.
I performed KTX2 texture compression on my 3D Tiles data, but when I replaced the JSON file path in the index.html example from the example folder with my 3D Tiles data in 3DTilesRendererJS, an error appeared in the browser console. Please see the screenshot below.
Platform: