three.js VideoTexture

2023-02-16 17:49 更新

創(chuàng)建一個(gè)使用視頻來作為貼圖的紋理對象。

注意:初次使用紋理后,無法更改視頻。相反,在紋理上調(diào)用 .dispose() 并實(shí)例化一個(gè)新紋理。

代碼示例

// assuming you have created a HTML video element with id="video"
const video = document.getElementById( 'video' );
const texture = new THREE.VideoTexture( video );

例子

materials / video
materials / video / webcam
video / kinect
video / panorama / equirectangular
vr / video

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

VideoTexture( video : Video, mapping : Constant, wrapS : Constant, wrapT : Constant, magFilter : Constant, minFilter : Constant, format : Constant, type : Constant, anisotropy : Number )

video -- 將被作為紋理貼圖來使用的Video元素。

mapping -- 紋理貼圖將被如何應(yīng)用(映射)到物體上,它是THREE.UVMapping中的對象類型。 

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.LinearFilter。

format -- The default is THREE.RGBAFormat. 

type -- 默認(rèn)值是THREE.UnsignedByteType. 

anisotropy -- 沿著軸,通過具有最高紋素密度的像素的采樣數(shù)。 默認(rèn)情況下,這個(gè)值為1。設(shè)置一個(gè)較高的值將會(huì)比基本的mipmap產(chǎn)生更清晰的效果,代價(jià)是需要使用更多紋理樣本。 使用renderer.getMaxAnisotropy() 來查詢GPU中各向異性的最大有效值;這個(gè)值通常是2的冪。

屬性

共有屬性請參見其基類Texture。

.generateMipmaps : Boolean

是否生成 mipmap。默認(rèn)為假。

.isVideoTexture : Boolean

只讀標(biāo)志,用于檢查給定對象是否屬于 VideoTexture 類型。

.needsUpdate : Boolean

在這里,你不必手動(dòng)設(shè)置這個(gè)值,因?yàn)樗怯蓇pdate()方法來進(jìn)行控制的。

方法

共有方法請參見其基類Texture。

.update () : undefined

在每一次新的一幀可用時(shí),這個(gè)方法將被自動(dòng)調(diào)用, 并將 .needsUpdate : Boolean設(shè)置為true。

源代碼

src/textures/VideoTexture.js


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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號