上面兩個(gè)例子都是應(yīng)用webGL3D模型貼圖實(shí)現(xiàn)的
按照上一篇介紹的步驟:
1、先初始化場(chǎng)景粒没、光源筛婉、物體
2、創(chuàng)建材質(zhì)癞松,在材質(zhì)上添加貼圖爽撒,再把材質(zhì)添加到物體上,具體代碼:
let img = require('../../img/earth.jpg');
let material = new THREE.MeshPhongMaterial({ map: THREE.ImageUtils.loadTexture(img)});
box = new THREE.Mesh(geometry, material );
這樣就可以實(shí)現(xiàn)最基本的貼圖功能了
[demo1展示中心]:https://yomonah.github.io/project/app.html#/webGL-img
[對(duì)應(yīng)源碼]:https://github.com/yomonah/react-demo/tree/master/src/components/webGL_img
[demo2展示中心]:https://yomonah.github.io/project/app.html#/webGL-earth
[對(duì)應(yīng)源碼]:https://github.com/yomonah/react-demo/tree/master/src/components/webGL_earth