diff --git a/src/materials/VideoTexture.ts b/src/materials/VideoTexture.ts new file mode 100644 index 0000000..dd2a716 --- /dev/null +++ b/src/materials/VideoTexture.ts @@ -0,0 +1,22 @@ +import { defineComponent, watch } from 'vue' +import { VideoTexture } from 'three' +import Texture from './Texture' + +export default defineComponent({ + extends: Texture, + props: { + videoId: { + type: String, + required: true, + }, + }, + created() { + watch(() => this.videoId, this.refreshTexture) + }, + methods: { + createTexture() { + const video = document.getElementById(this.videoId) as HTMLVideoElement + return new VideoTexture(video) + }, + }, +}) diff --git a/src/materials/index.ts b/src/materials/index.ts index c2403bd..7051713 100644 --- a/src/materials/index.ts +++ b/src/materials/index.ts @@ -5,5 +5,6 @@ export { default as SubSurfaceMaterial } from './SubSurfaceMaterial' export { default as Texture } from './Texture' export { default as CubeTexture } from './CubeTexture' +export { default as VideoTexture } from './VideoTexture' export type { MaterialPublicInterface } from './Material'