Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Texture in HoloJS not working #138

Open
KatayaAyman opened this issue Jan 26, 2018 · 2 comments
Open

Video Texture in HoloJS not working #138

KatayaAyman opened this issue Jan 26, 2018 · 2 comments

Comments

@KatayaAyman
Copy link

I tried video texture based on the following documentations:
https://github.com/mrdoob/three.js/blob/master/examples/canvas_materials_video.html
https://github.com/mrdoob/three.js/blob/master/examples/webgl_materials_video.html
https://stemkoski.github.io/Three.js/Video.html

I replaced CanvasRenderingExample in HoloJS -> ThreeJSApp example with the following two trials:

function CanvasRenderingExample(scene, renderer) {
	let canvas = document.createElement('canvas');
    canvas.width = 480;
    canvas.height = 204;
    
    var video = document.createElement("video");
    video.src = "http://techslides.com/demos/sample-videos/small.ogv";
    video.autoplay = true;
    
    videoImageContext = canvas.getContext('2d');
    videoImageContext.fillStyle = '#FFFFFF';
    videoImageContext.fillRect(0, 0, canvas.width, canvas.height);

    let texture = new THREE.Texture(canvas);
    texture.needsUpdate = true;
    texture.minFilter = THREE.LinearFilter;
    texture.magFilter = THREE.LinearFilter;

    let canvasCube = new THREE.Mesh(
        new THREE.PlaneGeometry(0.5, 0.5),
        new THREE.MeshStandardMaterial({ side: THREE.DoubleSide, map: texture, overdraw: 0.5 })
    );

    canvasCube.position.set(0, 0.2, -0.5);
    scene.add(canvasCube);

    var ambient = new THREE.AmbientLight(0xffffff, 1);
    scene.add(ambient);

    this.update = function() {
        if (video.readyState === video.HAVE_ENOUGH_DATA) {
            videoImageContext.drawImage(video, 0, 0);
            if (texture)
                texture.needsUpdate = true;
        }
    }
}
function CanvasRenderingExample(scene, renderer) {
	let canvas = document.createElement('canvas');
    canvas.width = 480;
    canvas.height = 204;
    
    var video = document.createElement("video");
    video.src = "http://techslides.com/demos/sample-videos/small.ogv";
    video.autoplay = true;
    
    videoImageContext = canvas.getContext('2d');
    videoImageContext.fillStyle = '#FFFFFF';
    videoImageContext.fillRect(0, 0, canvas.width, canvas.height);

    let texture = new THREE.VideoTexture(video);
    texture.format = THREE.RGBFormat;
    texture.minFilter = THREE.LinearFilter;
    texture.magFilter = THREE.LinearFilter;

    let canvasCube = new THREE.Mesh(
        new THREE.PlaneGeometry(0.5, 0.5),
        new THREE.MeshStandardMaterial({ side: THREE.DoubleSide, map: texture, overdraw: 0.5 })
    );

    canvasCube.position.set(0, 0.2, -0.5);
    scene.add(canvasCube);

    var ambient = new THREE.AmbientLight(0xffffff, 1);
    scene.add(ambient);
}

In the first example I am seeing a white plane, in the second example I am not getting anything on hololens.

@Almost-Done
Copy link
Member

I'm afraid it was never implemented properly - it was more like an experiment. It got completely broken with the new DOM implementation.

I made the required fixes in the develop/video-texture and threw together a sample; however performance is sub-par, the video element implementation is just enough to make the example run, colors are wrong etc.

The ogv format is not supported, the sample uses mp4.
The video texture should use RGBA but video decoding only works with ARGB so colors are off

@khalilkhalil25
Copy link

Hi, is there a possibility for you to merge this branch with master, even with its sub-par performance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants