three.js CubeTextureLoader

2023-02-16 17:44 更新

加載CubeTexture的一個(gè)類。 內(nèi)部使用ImageLoader來(lái)加載文件。

代碼示例

const scene = new THREE.Scene();
scene.background = new THREE.CubeTextureLoader()
	.setPath( 'textures/cubeMaps/' )
	.load( [
		'px.png',
		'nx.png',
		'py.png',
		'ny.png',
		'pz.png',
		'nz.png'
	] );

例子

materials / cubemap
materials / cubemap / dynamic
materials / cubemap / refraction

構(gòu)造函數(shù)

CubeTextureLoader( manager : LoadingManager )

manager — 加載器使用的loadingManager。默認(rèn)為THREE.DefaultLoadingManager.創(chuàng)建一個(gè)新的CubeTextureLoader.

屬性

共有屬性請(qǐng)參見其基類Loader。

方法

共有方法請(qǐng)參見其基類Loader。

.load ( urls : String, onLoad : Function, onProgress : Function, onError : Function ) : null

urls — 數(shù)組長(zhǎng)度為6的圖像數(shù)組,數(shù)組內(nèi)容為URL,每一個(gè)URL用于CubeTexture的每一側(cè)。 這些URL將被指定順序: pos-x, neg-x, pos-y, neg-y, pos-z, neg-z. 數(shù)組內(nèi)容也可以為 Data URIs.
請(qǐng)注意,一般來(lái)說(shuō),在立方體貼圖坐標(biāo)系中,當(dāng)查找positive-z軸時(shí),positive-x表示右側(cè) - 換句話說(shuō),此坐標(biāo)系使用左手坐標(biāo)系。 由于three.js使用右手坐標(biāo)系, 環(huán)境貼圖將在three.js進(jìn)行pos-x和neg-x進(jìn)行交互.
onLoad — 加載完成時(shí)將調(diào)用。回調(diào)參數(shù)是已被加載的texture.
onProgress — 將在加載過(guò)程中進(jìn)行調(diào)用。參數(shù)為XMLHttpRequest實(shí)例, 其中包含 total 和 loaded 字節(jié)。
onError — 在加載錯(cuò)誤時(shí)被調(diào)用。

從URL中進(jìn)行加載,并將被加載的texture傳遞給onLoad。

src/loaders/CubeTextureLoader.js


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)