PLM之家PLMHome-国产软件践行者

[前端框架] 使用ThreeJS添加纹理的方法

[复制链接]

2020-2-6 12:46:58 1984 0

admin 发表于 2020-2-6 12:46:58 |阅读模式

admin 楼主

2020-2-6 12:46:58

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
/ c7 m# `" M; {  A" a
使用TextureLoader的方法,添加图片进行load* I6 f- c8 b7 e. B

5 `6 O: k3 k! E7 w, G结果如下:
( R2 q: _; \/ i- ~& m: n4 H
0 P4 ~2 y( N6 X8 Y* ]8 |' B$ }/ Y/ T* L' q
: Y$ f5 o2 }6 h8 _. I+ o
this.loader = new TextureLoader()
0 q. }, B) Y" ~! C! B% |# Z5 ]) A, ]/ @
const {headerMaterial,middleMaterial,bottomMaterial} = this.loadTexture ()
7 |) Z6 {% y) {9 O# |" ?4 L# f
) X* y6 L5 n* Y, [

/ L: ?* D3 y  C3 `+ P6 l2 a' S+ |
# O5 f( x8 i# @
loadTexture () {9 `+ }' b6 Q. W4 h5 Z+ \0 T5 ~) S* h

8 I6 K7 Z- K2 b! T4 q: p        const headerTexture = this.loader.load('/game/res/images/head.png')
- c, i9 f4 R2 P8 H; Z+ ?  ?        const bottomTexture = this.loader.load('/game/res/images/bottom.png')
  C$ P+ E; H( o7 y5 w( E% D        const middleTexture = this.loader.load('/game/res/images/middle.png')# K7 |3 ^; @/ L" `  r
% \9 V! }' R) ~) K5 {" d

! x( Y0 C1 b+ O0 S! ]# e. W        const headerMaterial = new MeshBasicMaterial({2 G! D4 E0 i+ i4 r/ W! e- c7 w
            map: headerTexture( i- G5 |+ c. w/ n% t/ T7 K1 E
        })) W% u9 U) s, ~0 g
        const middleMaterial = new MeshBasicMaterial({
- R3 S$ J, D$ ]& W( _8 {            map: middleTexture
# X+ H: r* X" R4 R        })
/ \* ^' z% |* P. s        const bottomMaterial = new MeshBasicMaterial({
1 L& n- _5 x0 d            map: bottomTexture
* Z. }$ q6 _9 r        })
6 E5 d) \- M! d2 \4 _' d# T2 A# _) M5 Q8 I$ K; Q% F% G0 k- L
        return {headerMaterial,middleMaterial,bottomMaterial}
0 [% B2 }6 _7 j, l0 M* _& m( v) V    }" K. S! W$ c; ]9 R' ?% j

4 x1 r9 g- x% `4 f/ I+ T! D8 l( h1 O7 [* A# U# c2 s1 x
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了