|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ y6 m5 C& Q8 D9 G( T6 ]
使用TextureLoader的方法,添加图片进行load
_- E5 h( ]' I$ m& C0 |4 h+ N" z' ]2 i
结果如下:* l1 w7 R! S& Y( `# c0 x
" ` C( y8 z/ r! ?2 z
# h+ f" j5 A" @* z* `, L, |' S) R& M a0 ~! I" \/ \
this.loader = new TextureLoader()
1 F0 r2 p! s. B( {( C
' j, U, D$ s* B* Kconst {headerMaterial,middleMaterial,bottomMaterial} = this.loadTexture ()
. l# Y$ B# C+ X" q' m+ ^# r: M k, ]& Y0 Z% C) f8 S
/ z% @+ ?) l# E; W z# p
7 y/ x$ L ?, v! r& G n& S
0 o$ Z% k+ f( M6 |5 c2 s) q" I
loadTexture () {6 M+ _9 m1 H3 F; t C
# E* m! {: l9 S P# i3 [: @* x const headerTexture = this.loader.load('/game/res/images/head.png')5 W" P/ r1 t1 o$ c8 I, B6 v& y9 X
const bottomTexture = this.loader.load('/game/res/images/bottom.png')
. C8 G- l$ `/ v const middleTexture = this.loader.load('/game/res/images/middle.png'). k8 D# R) B; R M; o- E
. Q8 g* b# V( p& l
$ {2 Y! E' D# v/ R% R' Q9 b5 h9 h9 A
const headerMaterial = new MeshBasicMaterial({
' I c. B; f$ J+ j* T, i map: headerTexture7 M0 K$ I7 s# m6 O
})2 b z5 I- F" g3 t; O: r; Y
const middleMaterial = new MeshBasicMaterial({/ t1 U* Y! l. l6 `
map: middleTexture, E/ ~$ H6 \3 q/ M! k
})# H* ]1 T+ A! ^8 ]4 ^, |$ I0 F) u
const bottomMaterial = new MeshBasicMaterial({
* U8 L, k- N$ n. }! l( Z# @/ N0 F4 B/ P map: bottomTexture
, k/ m. ? M3 ?. u })! p1 l; ^6 ^; \, p+ \% W1 L. t$ T
% b0 z% A N2 D9 w return {headerMaterial,middleMaterial,bottomMaterial}
' ^1 O, o2 @6 ~" X/ ]3 J }5 k1 J/ \" h B8 t4 y8 l
4 h+ K# k9 S I0 }# V! H" T+ p4 q4 _
7 F8 x% Z, ?/ b9 h0 E* ~; Y |
|