We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

How to get texture image url?

Home Forums Programming How to get texture image url?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #52910
    vern
    Customer

    Does anyone know how to get the url of the image of a texture?
    I know how to access any texture from a material including getting its name but haven’t figured out how to get the image’s url.

    I’ve checked the ThreeJS and Verge3D developer reference and a ton of Google searches as well.

    #52912
    kdv
    Participant
    function getTexturesUrl(objNames) {
        objNames = retrieveObjectNames(objNames);
        if (!objNames)
            return;
        for (var i = 0; i < objNames.length; i++) {
            var objName = objNames
            if (!objName)
                continue;
            var obj = getObjectByName(objName);
            if (!obj)
                continue;
            var meshArray = obj.resolveMultiMaterial();
            var firstSubMeshMat = meshArray[0].material;
            for (var name in firstSubMeshMat.nodeTextures) {
                console.log(firstSubMeshMat.nodeTextures[name].image.currentSrc);
            }
        }
    }

    prints to the console urls for all textures used in object’s material

    Puzzles and JS. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of meaning at all.

    #52916
    vern
    Customer

    Thank you!! @kdv77kdv

    I saw nodeTextures before but didn’t have the correct calls to it so thanks a ton! I’ll check it out.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.