THREE.CanvasTexture needsUpdate no helps

可紊 提交于 2021-01-29 07:17:04

问题


  • I have video tag and he plays simple video. [works]
  • I have canvas2d with playing same video [works]
  • opencvjs video processing (canvas is output , video is input)- also works
  • I have three.js with plane mesh
          texture = new THREE.CanvasTexture(this.$refs.testcanvas)
          texture.needsUpdate = true;
          materialLocal = new THREE.MeshBasicMaterial({ map: texture })
          materialLocal.needsUpdate = true;
          materialLocal.map.needsUpdate = true;
          this.mainVideoMesh.material = materialLocal
          this.mainVideoMesh.material.needsUpdate = true;

No hepls . I got just first image screen texture and than stops updating.

In runtime i found ->

  this.scene.children[2].material.map.needsUpdate: undefined

Strange situation any suggestion.


回答1:


When using a video as a data source for a texture, the idea is to use the THREE.VideoTexture class. This type of texture will automatically manage its needsUpdate flag in order to ensure new frames are correctly displayed on your plane mesh.

Using THREE.VideoTexture requires that you use the video element as an argument, not the canvas.



来源:https://stackoverflow.com/questions/64249319/three-canvastexture-needsupdate-no-helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!