1. 程式人生 > >[微信小遊戲+Three.JS]給場景添加一個天空盒

[微信小遊戲+Three.JS]給場景添加一個天空盒

load 測試的 class inf jpg style 微信 新建 three.js

其實微信小遊戲中天空盒的添加方法跟原生Three.js沒有什麽區別

第一步就是設置好天空盒的各個面的貼圖

技術分享圖片

貼圖可以去Three.js的項目地址的example裏下載

我是根據我的上一篇博客添加的

只用在新建場景之後添加以下代碼就可以了

this.scene.background = new THREE.CubeTextureLoader()
      .setPath(‘images/Background/‘)
      .load([‘px.jpg‘, ‘nx.jpg‘, ‘py.jpg‘, ‘ny.jpg‘, ‘pz.jpg‘, ‘nz.jpg‘]);
    console.log(
this.cube)

下面是測試的圖片

技術分享圖片

[微信小遊戲+Three.JS]給場景添加一個天空盒