3.CanvasTexture needsUpdate no help

Oct 07 2020
  • 나는 비디오 태그가 있고 그는 간단한 비디오를 재생합니다. [공장]
  • 같은 동영상을 재생하는 canvas2d가 있습니다.
  • opencvjs 비디오 처리 (캔버스 출력, 비디오 입력)-작동
  • 평면 메쉬가있는 three.js가 있습니다.
          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;

hepls가 없습니다. 나는 첫 번째 이미지 화면 텍스처를 얻었고 업데이트를 중단했습니다.

런타임에서 나는 발견했다->

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

어떤 제안이라도 이상한 상황.

답변

Mugen87 Oct 08 2020 at 08:52

비디오를 텍스처의 데이터 소스로 사용할 때 THREE.VideoTexture 클래스 를 사용하는 것이 아이디어입니다 . 이 유형의 텍스처는 needsUpdate새 프레임이 평면 메시에 올바르게 표시되도록 플래그를 자동으로 관리합니다 .

를 사용 THREE.VideoTexture하려면 캔버스가 아닌 비디오 요소를 인수로 사용해야합니다.