|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
@1 c; t+ f) L* A/ t/ F
使用TextureLoader的方法,添加图片进行load
5 D, `" E- i( B* n. a
+ ~* d( K! M1 c! v7 J7 u结果如下:: E/ T% |8 b! E% ], e- [1 W) f
. ^4 A. x7 [+ Y B% K4 `; S7 L# |& t. G- s# I$ P
6 J: D6 ?" [9 [6 v this.loader = new TextureLoader()
2 c4 T8 Z7 e' Z c y0 Q6 C. y
# \/ @6 O& o3 z+ y1 X* iconst {headerMaterial,middleMaterial,bottomMaterial} = this.loadTexture ()
m" p% |9 z# V# q$ F; ~
: w" E- U' O8 C, Q. |) y1 p
/ W+ ^+ W# Q1 [2 S' J d3 \
) P* [+ m- G! n0 |% v! G7 x! i" r( `& f+ j) y
loadTexture () {
4 Q& p! G3 @4 O+ Z4 E5 h( e% Y8 K$ i% N* l: H- ~5 ` J' P
const headerTexture = this.loader.load('/game/res/images/head.png')3 l$ ]! U( E7 ]( s# t
const bottomTexture = this.loader.load('/game/res/images/bottom.png')
# R& |, w# F& J! ? const middleTexture = this.loader.load('/game/res/images/middle.png')/ t5 _! Z- Y: @5 l X
$ t) \. a' i8 O9 E! o
* [, {. ], w7 \% @* y7 a3 X
const headerMaterial = new MeshBasicMaterial({
' ~$ u" v- V3 u3 R( r6 | map: headerTexture/ w" i- b' W3 L4 m2 g0 ]4 F
})/ p+ I7 o2 }# g* T0 y4 {
const middleMaterial = new MeshBasicMaterial({
c* e& \- ~; q; Y map: middleTexture
4 I2 }0 |& k3 [* x9 t })
3 T8 [, c" n: X% w0 a+ m$ v const bottomMaterial = new MeshBasicMaterial({
% K+ v, Z7 [: @3 G a- C! Y map: bottomTexture
: s! G" D% N* M- t })1 k7 ^/ X8 R" g+ Y: d
* \, B- [1 r* w @
return {headerMaterial,middleMaterial,bottomMaterial}, A6 `4 s, j, {: O5 w3 J) n/ ~! O4 p
}- W4 M( g5 S; N/ H7 V m& B
" | `6 e: E1 Q, N% F0 j# d
: [6 Z/ q) a j K2 W3 i |
|