VideoTexture.js 842 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import { Texture } from './Texture.js';
  5. function VideoTexture( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
  6. Texture.call( this, video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
  7. this.generateMipmaps = false;
  8. this.frameRate = 30;
  9. }
  10. VideoTexture.prototype = Object.assign( Object.create( Texture.prototype ), {
  11. constructor: VideoTexture,
  12. isVideoTexture: true,
  13. update: ( function () {
  14. var prevTime = 0;
  15. return function () {
  16. var video = this.image;
  17. if ( video.readyState >= video.HAVE_CURRENT_DATA ) {
  18. var time = performance.now();
  19. if ( prevTime + ( 1 / this.frameRate ) < time ) {
  20. this.needsUpdate = true;
  21. prevTime = time;
  22. }
  23. }
  24. }
  25. } )()
  26. } );
  27. export { VideoTexture };
粤ICP备19079148号