|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ f& f; Y1 W: @' w6 P2 h
使用TextureLoader的方法,添加图片进行load/ W& P* A9 F2 E2 m2 B% M/ }/ J. z9 Y
8 ~8 D3 e! A; l* |
结果如下:/ A+ J- l1 o. x( J, h) r6 x
0 c/ \% T) I2 \: q; V: a8 Q
1 R& z/ _8 u4 X. `, Y8 g5 x) j
! J/ b0 B9 k! V& f* Q8 p$ y0 v8 A
this.loader = new TextureLoader()
; L( s* E/ T' l% d8 w k* j$ y( }; E9 b. d1 ~. c
const {headerMaterial,middleMaterial,bottomMaterial} = this.loadTexture ()
$ j2 _' N9 S, [5 R3 l% X. Z% ]2 |3 c0 k4 D2 Y
3 F% W7 l) {( }( ]' j h
: [2 S- Y: Y. k
, t5 q5 y4 t8 Z! {0 }# aloadTexture () {! _1 R3 a) n w/ j1 B9 B
3 J' J% K: H9 P
const headerTexture = this.loader.load('/game/res/images/head.png')4 s9 B. N) A D( R1 c
const bottomTexture = this.loader.load('/game/res/images/bottom.png')
7 O! a' e6 J$ I& |$ { const middleTexture = this.loader.load('/game/res/images/middle.png')
& c2 e9 b9 v- Z; y) |% l8 T( o0 W# d% p; X ~
3 P) T K7 {+ h3 S( F$ U3 d
const headerMaterial = new MeshBasicMaterial({
! m5 |# \% j6 A, p$ b3 @, k map: headerTexture
E7 x, T; M/ K* q" E% w: J# B })0 I; ~8 r% W- E) ^: m/ z9 Q) \
const middleMaterial = new MeshBasicMaterial({
7 K$ p; v1 p. R( Y9 I# Z5 k. T9 V map: middleTexture- a; x; \8 O# p/ ~9 K4 D9 I4 [* ^
})6 ~$ m& m* u& f2 _
const bottomMaterial = new MeshBasicMaterial({( u9 L9 {2 g8 Q8 |
map: bottomTexture. K3 u" Y9 J& E/ ^$ z6 G; T
})2 ^* l+ |) V" ?, V: S
; W( i, j# m5 _" v% l# u2 g. M
return {headerMaterial,middleMaterial,bottomMaterial}
4 w. m0 i. @5 u }
3 Z2 f! Y6 x( t7 Q" ^' }# C
' j+ M$ N/ T) `' \
9 Y' G& f. w7 B* b$ j, Z$ y |
|