Created
March 21, 2018 10:40
-
-
Save nerestaren/3150822fffa96a4a14aa01dd50d131a0 to your computer and use it in GitHub Desktop.
A-FRAME Alpha Map
This file contains hidden or 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