Can't find ImageProxy undefined


(Lukas 87) #1

Hi,

When I try to call api.addTexture shows in console an error: "Can't find ImageProxy undefined".
Works only correct for image url: google maps static.
What"s wrong?


#2

Hi,

Are the images CORS enabled?


(Lukas 87) #3

No :smile:
Thanks


(Hakkun) #4

Hi,

I got the same error. I use CORS enabled Image from Imgur. Any suggestions whats wrong? I got uid: undefined in my ObjectTree.

Edit:
I found the problem. I noticed, that the viewer.api registers textures with some tmp_xxx number. And this tmp_xxx differs if i reload the page. So somtimes the same texture is registered with tmp_266 and sometimes the texture is registered with tmp_267. How do you avoid this issue?

How can I access the TextureUid variable as a global variable in other functions?

api.addTexture(
    'https://example.org/texture.png',
    function ( err, textureUid ) {
        console.log( 'New texture registered with ID ' + textureUid );
    }
);

#5

Declare a newTextureUid variable globally, then define it during the addTexture callback:

var newTextureUid;

api.addTexture(
    'https://example.org/texture.png',
    function ( err, textureUid ) {
        console.log( 'New texture registered with ID ' + textureUid );
        newTextureUid = textureUid;
    }
);