使用ThreeJS添加纹理的方法
使用TextureLoader的方法,添加图片进行load
结果如下:
this.loader = new TextureLoader()
const {headerMaterial,middleMaterial,bottomMaterial} = this.loadTexture ()
loadTexture () {
const headerTexture = this.loader.load('/game/res/images/head.png')
const bottomTexture = this.loader.load('/game/res/images/bottom.png')
const middleTexture = this.loader.load('/game/res/images/middle.png')
const headerMaterial = new MeshBasicMaterial({
map: headerTexture
})
const middleMaterial = new MeshBasicMaterial({
map: middleTexture
})
const bottomMaterial = new MeshBasicMaterial({
map: bottomTexture
})
return {headerMaterial,middleMaterial,bottomMaterial}
}
页:
[1]