|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ E- t: ?) B8 Q" Y$ u* g使用TextureLoader的方法,添加图片进行load
( ]6 [0 E) ]6 x- q7 x& |6 e7 n% p4 ^" n
结果如下:9 Y% V- G; o4 |9 G
3 \% y: M8 m: [4 G
3 Y& r( {! ~, u0 o/ q6 T+ ^+ m- k9 C
this.loader = new TextureLoader()
- f0 d. I" L* ~, _ X: U3 k- C) j
const {headerMaterial,middleMaterial,bottomMaterial} = this.loadTexture ()
6 t' N4 J& ^+ I" L9 N
) t6 }- j: j$ ]0 {7 k; R) f$ Y2 F4 i) V" B$ b# n
' \2 R7 p. d- V7 I. a# [& F! D6 D+ [
loadTexture () {* X1 N& }( [$ H! G( N$ F1 N: j
8 U6 c1 k3 m2 T
const headerTexture = this.loader.load('/game/res/images/head.png')# y. h! G7 `! h1 s
const bottomTexture = this.loader.load('/game/res/images/bottom.png')- V: o! ?: O5 H3 Q9 @
const middleTexture = this.loader.load('/game/res/images/middle.png')+ ]& H: |; v! p$ h
: ?6 G% p( e* m3 M- t j3 s- ?2 O- o# @* ?1 K6 Q
const headerMaterial = new MeshBasicMaterial({
/ w1 Z. Q. R/ u9 H/ v8 o map: headerTexture4 g' Z b$ O, v0 o
})
! k4 C8 _; J& p) I) m3 d6 [0 I+ o const middleMaterial = new MeshBasicMaterial({
1 P! t5 n3 H" g& L( d map: middleTexture o$ [9 B _4 _: I; F
})' e4 g% I# h9 T' E: E! l
const bottomMaterial = new MeshBasicMaterial({% \- r, T9 `( ]
map: bottomTexture
. w5 n# E3 Y0 _0 Y })
1 T( P$ U: o. L4 J
: q+ k2 s# p D2 T3 K2 f* ^9 x' |. g* ~ return {headerMaterial,middleMaterial,bottomMaterial}
3 t3 m& j: f4 j6 z) n }* m- J( E' H F3 d6 Q+ N
/ t/ A. W( h( V( Q
: l$ d* u8 U- Y8 t5 e |
|