|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! [ K. C k) n2 y% G
使用TextureLoader的方法,添加图片进行load
" l8 W R* }% e! C7 Y9 x/ G J% ~" I( ^- b* a: ~+ L9 N6 L, ^; Y
结果如下:
* @$ B; B4 S. o8 {$ k5 G m
. V4 y1 i: J& q4 l
& f! e: e. K. V' o7 |- v9 D% E+ l! x3 n! F
this.loader = new TextureLoader(): d) {8 P8 `3 J2 n2 w% ]6 l, z
+ o7 `- K) o) O/ P8 F: ^
const {headerMaterial,middleMaterial,bottomMaterial} = this.loadTexture ()2 Q# E8 Z/ |5 X4 \- i" R
_) B% r+ f. ]& U9 P/ e! i
; b/ H6 M2 |/ S( X9 g: I$ ~8 J
- |% i. p5 f3 H, K7 E% a. q4 L. b4 }: s: t2 P# ~. T; K
loadTexture () {" u3 ?: @) s) n# f& b5 n9 u; C
2 k( K5 V0 r4 e# T
const headerTexture = this.loader.load('/game/res/images/head.png')6 C2 {- J( {0 L* Q, B# u% \2 C
const bottomTexture = this.loader.load('/game/res/images/bottom.png')
9 V7 o. x0 K: B8 ~+ Z2 x% A const middleTexture = this.loader.load('/game/res/images/middle.png')* V$ h/ m: A. ]6 C8 o& o
6 ]; y% {6 w9 s# o s9 [
+ a) \' S+ g# L, H
const headerMaterial = new MeshBasicMaterial({8 m; v6 Z8 D4 ~0 z/ C
map: headerTexture' ?2 u3 V0 Y$ G" S9 H
})
7 N- `+ w5 w8 B( e: v* V6 Y# n3 h const middleMaterial = new MeshBasicMaterial({
7 o: A! h5 \7 e& K8 Y- y: k4 u% N) t map: middleTexture( D, w2 X( W1 {1 G- {8 p. v
})4 f( c1 |0 l! p M
const bottomMaterial = new MeshBasicMaterial({
x+ V: n: B& X* R0 i2 k/ R; v" n5 Q map: bottomTexture
4 H5 C6 x( K, Q })( E- p+ ?9 y8 {6 \
+ i- i; @% U6 a2 F8 |6 _9 [! G return {headerMaterial,middleMaterial,bottomMaterial}
1 @% R$ F9 c5 E! Q1 U }' |' i5 y, v7 U7 @6 M
/ l5 k5 t9 N1 [3 u5 e _
5 q' m$ `1 ~8 P/ g t! h C$ }' l |
|