These are usually created by a TextureManager and accessed via TextureManager.getInstance(). Its role is to provide a proxy to a texture and provides a notification mechanism to allow other code to update texture references, for example when a texture is downloaded.
The TextureInstance are reference counted.
Required scripts
The TextureInstance object requires:
/*{{ javascript("jslib/texturemanager.js") }}*/
/*{{ javascript("jslib/observer.js") }}*/
/*{{ javascript("jslib/utilities.js") }}*/
Summary
Set the texture object associated with the TextureInstance. This will notify any observer function registered with subscribeTextureChanged.
Syntax
textureInstance.setTexture(texture);
Summary
Get the texture object associated with the TextureInstance.
Syntax
var texture = textureInstance.getTexture();
Returns a Texture object.
Summary
Register a function object to call when the texture changes.
Syntax
textureInstance.subscribeTextureChanged(textureChangedCallback);
Summary
Unregistered a function object previously registered with subscribeTextureChanged.
Syntax
textureInstance.unsubscribeTextureChanged(textureChangedCallback);
Summary
Free the resources attached to the object. This is normally called automatically when the reference count drops to 0.
Syntax
textureInstance.destroy();