Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                   <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Babylon.js sample code</title>
      <!--
    Inspired from work of https://twitter.com/ge1doot
    https://codepen.io/ge1doot/pen/yLJwBrm?editors=1000
    images from Matthew Attard
		extracted from a Flash file
    vue_it___pine_shrine_
		by_priteeboy-d339ct2.swf
-->
    </head>
    <canvas id="renderCanvas"></canvas>

              
            
!

CSS

              
                  html, body {
    overflow: hidden;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
            }

#renderCanvas {
    width: 100%;
    height: 100%;
    touch-action: none;
    background-color: black
}
              
            
!

JS

              
                       const cubeSize= 500;
       var canvas = document.getElementById("renderCanvas");
       var engine = new BABYLON.Engine(canvas, true,  { 
         preserveDrawingBuffer: true,  stencil: true, disableWebGL2Support: true});
       var scene = new BABYLON.Scene(engine);
        
        //Create light
       var light2 = new BABYLON.HemisphericLight('light1', 
                      new BABYLON.Vector3(0, 1, 0), scene);
       var light2 = new BABYLON.HemisphericLight('light1', 
                      new BABYLON.Vector3(0, -1, 0), scene);
        
      //Create an Arc Rotate Camera
           var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI , 1.0, 110,                             BABYLON.Vector3.Zero(), scene);
               camera.attachControl(canvas, true);
        	
            var skyBox = BABYLON.Mesh.CreateBox("skyBox", cubeSize, scene);
            var cubeMaterial = new BABYLON.StandardMaterial("skyBoxMat", scene);
            skyBox.material=cubeMaterial;
            cubeMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
            cubeMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
        
        	let images =[
    "https://assets.codepen.io/222599/image+107.jpg", //Front
    "https://assets.codepen.io/222599/image+108.jpg", //Left
    "https://assets.codepen.io/222599/image+109.jpg", //top
    "https://assets.codepen.io/222599/image+110.jpg", //bottom
    "https://assets.codepen.io/222599/image+112.jpg", //back
    "https://assets.codepen.io/222599/image+111.jpg"] //right

        	//front
        	var frontMaterial=new BABYLON.StandardMaterial("frontMaterial",scene);
        	frontMaterial.diffuseTexture=new BABYLON.Texture(images[0], scene);
        	frontMaterial.diffuseTexture.uScale = 	frontMaterial.diffuseTexture.vScale = -1;
            frontMaterial.backFaceCulling = false
        
        	//back
        var backMaterial=new BABYLON.StandardMaterial("backMaterial",scene);
        backMaterial.diffuseTexture=new BABYLON.Texture(images[4], scene);
        backMaterial.diffuseTexture.uScale = backMaterial.diffuseTexture.vScale = 1;
            backMaterial.backFaceCulling = false
        
           //left
        var leftMaterial=new BABYLON.StandardMaterial("leftMaterial",scene);
        leftMaterial.diffuseTexture=new BABYLON.Texture(images[1], scene);
        leftMaterial.diffuseTexture.wAng = 0.5*Math.PI;
        leftMaterial.backFaceCulling = false
        
        var rightMaterial=new BABYLON.StandardMaterial("rightMaterial",scene);
        rightMaterial.diffuseTexture=new BABYLON.Texture(images[5], scene);
        rightMaterial.diffuseTexture.wAng = 0.5*Math.PI;
        rightMaterial.backFaceCulling = false
        
        	//top
        var topMaterial=new BABYLON.StandardMaterial("topMaterial",scene);
        topMaterial.diffuseTexture = new BABYLON.Texture(images[2], scene);
        topMaterial.diffuseTexture.wAng = -0.5 * Math.PI;
        topMaterial.backFaceCulling = false
        	
        	//bottom
        var bottomMaterial=new BABYLON.StandardMaterial("bottomMaterial",scene);
        bottomMaterial.diffuseTexture = new BABYLON.Texture(images[3], scene);
        bottomMaterial.diffuseTexture.wAng = 0.5 * Math.PI;
        bottomMaterial.diffuseTexture.uScale = 1;
        bottomMaterial.backFaceCulling = false
        
        	//put into one
        var multiMaterial =new BABYLON.MultiMaterial("cubetexture",scene);
        multiMaterial.subMaterials.push(
                frontMaterial, backMaterial ,
                leftMaterial , rightMaterial ,
                topMaterial, bottomMaterial);
        
        	//apply material
        skyBox.subMeshes=[];
        var verticesCount=skyBox.getTotalVertices();
        skyBox.subMeshes.push(
          new BABYLON.SubMesh(0, 0, verticesCount, 0, 6, skyBox) ,
          new BABYLON.SubMesh(1, 1, verticesCount, 6, 6, skyBox),
        	new BABYLON.SubMesh(2, 2, verticesCount, 12, 6, skyBox),
        	new BABYLON.SubMesh(3, 3, verticesCount, 18, 6, skyBox),
        	new BABYLON.SubMesh(4, 4, verticesCount, 24, 6, skyBox),
        	new BABYLON.SubMesh(5, 5, verticesCount, 30, 6, skyBox));
        skyBox.material = multiMaterial;
        
      engine.runRenderLoop( ()=> {
        if (scene && scene.activeCamera) {
          scene.render();
        }
      });
        
      // Resize
      window.addEventListener("resize",  ()=> {
        engine.resize();
      });
              
            
!
999px

Console