diff --git a/src/component/Spine.js b/src/component/Spine.js index 5ddefbc..4b66c64 100644 --- a/src/component/Spine.js +++ b/src/component/Spine.js @@ -254,29 +254,38 @@ class Spine { slot._active.type = ATTACHMENT_TYPE.MESH; } + let texture = null; + + // search for texture property if it exists + if (attachment.region) { + if (attachment.region.texture) { + texture = attachment.region.texture.pcTexture; + } + if (attachment.region.page && attachment.region.page.texture) { + texture = attachment.region.page.texture.pcTexture; + } + } + // create / assign material - if (attachment.region && attachment.region.texture) { - const texture = attachment.region.texture.pcTexture; - if (texture) { - if (texture instanceof pc.StandardMaterial) { - this._materials[texture.name] = texture; - slot.material = texture.name; - } else { - // get a unique key for the texture - let key = null; - if (texture.name) { - key = texture.name; // texture name might not be unique - should be resolved with content - } else if (texture.getSource() instanceof Image) { - key = texture.getSource().getAttribute('src'); - } - if (key) { - // create a new material if required - if (this._materials[key] === undefined) { - const material = this.createMaterial(texture); - this._materials[key] = material; - } - slot.material = key; + if (texture) { + if (texture instanceof pc.StandardMaterial) { + this._materials[texture.name] = texture; + slot.material = texture.name; + } else { + // get a unique key for the texture + let key = null; + if (texture.name) { + key = texture.name; // texture name might not be unique - should be resolved with content + } else if (texture.getSource() instanceof Image) { + key = texture.getSource().getAttribute('src'); + } + if (key) { + // create a new material if required + if (this._materials[key] === undefined) { + const material = this.createMaterial(texture); + this._materials[key] = material; } + slot.material = key; } } }