-
-
Save DhruvDange/2d1601539381843f0b2724f8be0b2a46 to your computer and use it in GitHub Desktop.
A-FRAME Alpha Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This component adds an alpha map to a mesh. | |
AFRAME.registerComponent('alpha-map', { | |
schema: { | |
src: {type: 'map'} | |
}, | |
init: function() { | |
this.el.sceneEl.systems.material.loadTexture(this.data.src, {src: this.data.src}, this.callback.bind(this)); | |
}, | |
callback: function(texture) { | |
this.el.object3DMap.mesh.material.alphaMap = texture; | |
} | |
}); | |
// Usage: | |
// <a-entity material="src: #texture" alpha-map="src: #alphaMap"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment