three.js CanvasTexture

2023-02-16 17:48 更新

從Canvas元素中創(chuàng)建紋理貼圖。

它幾乎與其基類Texture相同,但它直接將needsUpdate(需要更新)設(shè)置為了true。

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

CanvasTexture( canvas : HTMLElement, mapping : Constant, wrapS : Constant, wrapT : Constant, magFilter : Constant, minFilter : Constant, format : Constant, type : Constant, anisotropy : Number )

canvas -- 將會(huì)被用于加載紋理貼圖的Canvas元素。
mapping -- 紋理貼圖將被如何應(yīng)用(映射)到物體上,它是THREE.UVMapping中的對(duì)象類型。
wrapS -- 默認(rèn)值是THREE.ClampToEdgeWrapping. 
wrapT -- 默認(rèn)值是THREE.ClampToEdgeWrapping. 
magFilter -- 當(dāng)一個(gè)紋素覆蓋大于一個(gè)像素時(shí),貼圖將如何采樣。 其默認(rèn)值為THREE.LinearFilter。
minFilter -- 當(dāng)一個(gè)紋素覆蓋小于一個(gè)像素時(shí),貼圖將如何采樣。 其默認(rèn)值為THREE.LinearMipmapLinearFilter。
format -- 在紋理貼圖中使用的格式。
type -- 默認(rèn)值是THREE.UnsignedByteType. 
anisotropy -- 沿著軸,通過(guò)具有最高紋素密度的像素的樣本數(shù)。 默認(rèn)情況下,這個(gè)值為1。設(shè)置一個(gè)較高的值將會(huì)產(chǎn)生比基本的mipmap更清晰的效果,代價(jià)是需要使用更多紋理樣本。 使用renderer.getMaxAnisotropy() 來(lái)查詢GPU中各向異性的最大有效值;這個(gè)值通常是2的冪。

屬性

共有方法請(qǐng)參見(jiàn)其基類Texture。

.isCanvasTexture : Boolean

用于檢查給定對(duì)象是否為 CanvasTexture 類型的只讀標(biāo)志。

.needsUpdate : Boolean

默認(rèn)值為true,這是必須的,以便使得Canvas中的數(shù)據(jù)能夠載入。

方法

共有方法請(qǐng)參見(jiàn)其基類Texture。

源代碼

src/textures/CanvasTexture.js


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

掃描二維碼

下載編程獅App

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

編程獅公眾號(hào)