简体   繁体   English

display.dae 文件并从 dae 文件定义路径渲染 jpg 纹理

[英]display .dae file and render jpg texture from dae file definition path

I have a set of kmz files and I want to separate out the dae files inside to display them individually by three.js .我有一组kmz文件,我想将其中的dae文件分离出来,以便通过three.js单独显示它们。

I found that these dae skin renderings are jpg files, and the paths to these files are defined in the dae file:我发现这些dae皮肤效果图都是jpg文件,这些文件的路径是在dae文件中定义的:

    <library_images>
        <image id="ImageNo2F">
            <init_from>.\texture\35748_0001009011_6283.jpg</init_from>
        </image>
        <image id="ImageNo1F">
            <init_from>.\texture\10608_2064.jpg</init_from>
        </image>
        <image id="ImageNoRoof">
            <init_from>.\texture\ROOF_1LG9R6P0RD.jpg</init_from>
        </image>
    </library_images>

dae example file: https://gitlab.com/po_developer/kml-file-exp/-/tree/main dae 示例文件: https://gitlab.com/po_developer/kml-file-exp/-/tree/main

I previewed the image through the online service , and indeed the skin of the model is only black when no image is loaded.This service also doesn't seem to support loading textures.我通过在线服务预览了图像,确实model的皮肤在没有加载图像时是黑色的。这个服务似乎也不支持加载纹理。

在此处输入图像描述

I can only find examples of loading kmz files so far, and I don't know how to load dae textures for rendering.目前只能找到加载kmz文件的例子,不知道怎么加载dae纹理进行渲染。

When textures are defined in the Collada asset, ColladaLoader automatically loads and applies them to the respective materials.在 Collada 资源中定义纹理时, ColladaLoader自动加载并将它们应用到相应的材质。 So there is no need for a manual (additional) loading process.因此不需要手动(额外)加载过程。 I suggest you use the basic Collada example webgl_loader_collada as a code template.我建议您使用基本的 Collada 示例webgl_loader_collada作为代码模板。

BTW: I've tested your asset from GitLab on my Computer and realized its definitions are buggy.顺便说一句:我已经在我的计算机上从 GitLab 测试了您的资产,并意识到它的定义是错误的。 It refers to geometries via instance_geometry (the IDs are GeometryNo2F8 and GeometryNo1F8 ) which are not defined in the asset.它通过未在资产中定义的instance_geometry (ID 为GeometryNo2F8GeometryNo1F8 )引用几何。 You need to fix this otherwise ColladaLoader will throw an error.您需要解决此问题,否则ColladaLoader将引发错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM