function create3DFrame (frame, index) {
const { width: w, height: h } = stageCanvas
let canvas = stageCanvas
let ctx = stageCtx
if (viewDebugFrames) {
canvas = document.createElement('canvas')
canvas.width = w
canvas.height = h
frameDebugContainer.appendChild(canvas)
ctx = canvas.getContext('2d')
}
ctx.clearRect(0, 0, w, h)
ctx.putImageData(frame.data, (w - imgDims.width) / 2, (h - imgDims.height) / 2)
const texture = new THREE.CanvasTexture(canvas)
const material = new THREE.ShaderMaterial({
vertexShader,
fragmentShader,
uniforms: {
tex: { type: "t", value: texture }
},
side: THREE.DoubleSide,
transparent: true
})
const geometry = new THREE.PlaneGeometry(w, h, 2)
const mesh = new THREE.Mesh(geometry, material)
mesh.position.z = index - 30
return mesh
}