Pen Settings



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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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



Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO


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.


Make Template?

Templates are Pens that can be used to start other Pens. You can view all of your templates, or learn more in the documentation.


Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO


                <!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
    <title>Babylon - Getting Started</title>
    <!--- Link to the last version of BabylonJS --->
    <script src=""></script>
  <span class="button">Enter Sphere's height <input type="text" onchange="updateValue(this)"></input></span>
  <span class="select">Select Texture: <select id="select_Texture" onchange="updateTexture(this)">
  <option name="1" value="">Texture 1</option>
  <option  name ="2" value="">Texture 2</option>
    <canvas id="renderCanvas"></canvas>


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

        #renderCanvas {
            width   : 100%;
            height  : 100%;
            touch-action: none;

 position: absolute;
    left: 100px;
    top: 50px;
    z-index: 100;

  position: absolute;
    left: 100px;
    top: 110px;
    z-index: 100;


                            // get the canvas DOM element
            var canvas = document.getElementById('renderCanvas');

            // load the 3D engine
            var engine = new BABYLON.Engine(canvas, true);

            // createScene function that creates and return the scene
            var createScene = function(){
                // create a basic BJS Scene object
                var scene = new BABYLON.Scene(engine);

                // create a FreeCamera, and set its position to (x:0, y:5, z:-10)
                var camera = new BABYLON.FreeCamera('camera1', new                                    BABYLON.Vector3(0, 5,-10), scene);

                // target the camera to scene origin

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

                // create a basic light, aiming 0,1,0 - meaning, to the sky
                var light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0,1,0), scene);

                // create a built-in "sphere" shape; its constructor takes 6 params: name, segment, diameter, scene, updatable, sideOrientation 
                var sphere = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene);

                // move the sphere upward 1/2 of its height
                sphere.position.y = 1;

                // create a built-in "ground" shape;
                var ground = BABYLON.Mesh.CreateGround('ground1', 6, 6, 2, scene);

                // return the created scene
                return scene;

            // call the createScene function
            var scene = createScene();

            // run the render loop

            // the canvas/window resize event handler
            window.addEventListener('resize', function(){
  //function to update sphere's height
  function updateValue(item){
    let sphere = scene.getMeshByName("sphere1");
    sphere.position.y = item.value;

//pre-load the materials
const options = [
  {id:1, url:''},
  {id:2, url:''}

let Tselect = document.getElementById("select_Texture");
for(let i=0;i<Tselect.options.length; i++){
  let item = Tselect.options[i];

  var backgroundMaterial = new BABYLON.BackgroundMaterial("mat_" + options[i].id, scene);
  backgroundMaterial.diffuseTexture = new BABYLON.Texture(options[i].url, scene);
  backgroundMaterial.diffuseTexture.uScale = 5.0;//Repeat 5 times on the Vertical Axes
  backgroundMaterial.diffuseTexture.vScale = 5.0;//Repeat 5 times on the Horizontal Axes
  item.value = options[i].id;

function updateTexture(item){
  let sphere = scene.getMeshByName("sphere1");
  let material = scene.getMaterialByName("mat_" + item.value);
  console.log(item.value, material, scene.materials);
  sphere.material = material;
💕 I'm the CSS to your HTML.