Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                		<canvas id ="glCanvas"></canvas>
              
            
!

CSS

              
                			html,body {
				overflow:hidden;
				width:100%;
				height:100%;
				margin:0;
				padding:0;
			}
			
			#glCanvas{
				width:100%;
				height:100%;
				touch-action:none;
			}

video{
  position:absolute;
  left: 0;
  top:0;
}
              
            
!

JS

              
                var ground, videoTexture;
$(function(){
	var canvas = document.getElementById("glCanvas");
	var engine = new BABYLON.Engine(canvas, true);
	
	var createScene = function (){
		    if (Hls.isSupported()) {
      var vidEl = document.createElement("video");
      vidEl.src = 'http://www.streambox.fr/playlists/test_001/stream.m3u8';
      vidEl.setAttribute('crossorigin', 'anonymous');
      vidEl.load();
      var hls = new Hls();
      hls.loadSource(vidEl.src);
      hls.attachMedia(vidEl);
      console.log(vidEl);
      hls.on(Hls.Events.MANIFEST_PARSED, function () {
        console.log(true);
        vidEl.play();
        document.body.appendChild(vidEl);
      });
    }
    else {
      console.error("not supported");
    }


  var scene = new BABYLON.Scene(engine);

    // Change the scene background color to black.
    scene.clearColor = new BABYLON.Color3(0, 0, 0);

    // This creates and positions a free camera
    var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);

    // This targets the camera to scene origin
    camera.setTarget(BABYLON.Vector3.Zero());

    // This attaches the camera to the canvas
    camera.attachControl(canvas, false);

    // This creates a light, aiming 0,1,0 - to the sky.
    var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);

    // Dim the light a small amount
    light.intensity = .5;

    // Let's try our built-in 'sphere' shape. Params: name, subdivisions, size, scene
    var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);

    // Move the sphere upward 1/2 its height
    sphere.position.y = 1;
    var mat = new BABYLON.StandardMaterial("mat", scene);

    videoTexture = new BABYLON.VideoTexture("video", [vidEl.src], scene, true, true);

    scene.onPointerUp = function () {
      videoTexture.video.play();
    };
    // Let's try our built-in 'ground' shape.  Params: name, width, depth, subdivisions, scene
    ground = BABYLON.MeshBuilder.CreatePlane("plane", {width: 5, height: 5, sideOrientation: 2, updatable: true}, scene);

    var materialSphere1 = new BABYLON.StandardMaterial("texture1", scene);
    
    //disable the line below and scene renders
    materialSphere1.diffuseTexture = videoTexture;
    materialSphere1.emissiveColor = new BABYLON.Color3(1,1,1);
    ground.material = materialSphere1;
    // Leave this function
    return scene;

  }; 

	var scene = createScene();
	  engine.runRenderLoop(function () {
    scene.render();
  });
	
	window.addEventListener("resize", function () {
		engine.resize();
	});
});
              
            
!
999px

Console