jQuery addClass example

Change class name on click in jQuery

by Michael Prosser

HTML

<script src="https://preview.babylonjs.com/babylon.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<canvas id="renderCanvas" touch-action="none"></canvas>

CSS

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

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

JavaScript

var canvas = document.getElementById("renderCanvas"); // Get the canvas element 
        var engine = new BABYLON.Engine(canvas, true); // Generate the BABYLON 3D engine

        /******* Add the create scene function ******/
        var createScene = function () {

            // Create the scene space
            var scene = new BABYLON.Scene(engine);
						
           
            // Add a camera to the scene and attach it to the canvas
            var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 2, new BABYLON.Vector3(0,0,5), scene);
            camera.attachControl(canvas, true);

            // Add lights to the scene
            //var light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(1, 1, 0), scene);
            var light2 = new BABYLON.PointLight("light2", new BABYLON.Vector3(50, 50, -10), scene);

            // Add and manipulate meshes in the scene
            var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", {diameter:5, diameterY:1 }, scene);
						sphere.position.y = 4;
            
             window.sphere = sphere;
             
             var sphere2 = BABYLON.MeshBuilder.CreateSphere("sphere2", {diameter:5, diameterX: 9 }, scene);
						sphere2.position.y = 8;
            sphere2.position.x = 8;
            sphere2.position.z = 8;
            
             window.sphere2 = sphere2;
             
              var sphere3 = BABYLON.MeshBuilder.CreateSphere("sphere3", {diameter:5, diameterZ: 19 }, scene);
						sphere3.position.y = 18;
            sphere3.position.x = 18;
            sphere3.position.z = 18;
            
             window.sphere3 = sphere3;
             
						   // Ground
            var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
            groundMaterial.diffuseTexture = new BABYLON.Texture("https://www.babylonjs-playground.com/textures/earth.jpg", scene);

            var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground",...