display .dae file and render jpg texture from dae file definition path

439 Views Asked by At

I have a set of kmz files and I want to separate out the dae files inside to display them individually by three.js.

I found that these dae skin renderings are jpg files, and the paths to these files are defined in the dae file:

    <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

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.

enter image description here

I can only find examples of loading kmz files so far, and I don't know how to load dae textures for rendering.

1

There are 1 best solutions below

6
Mugen87 On

When textures are defined in the Collada asset, ColladaLoader automatically loads and applies them to the respective materials. 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.

BTW: I've tested your asset from GitLab on my Computer and realized its definitions are buggy. It refers to geometries via instance_geometry (the IDs are GeometryNo2F8and GeometryNo1F8) which are not defined in the asset. You need to fix this otherwise ColladaLoader will throw an error.