{"id":"QYFDDP","version":1,"description":"Babylon demonstration","jsonPayload":"{\"code\":\"var createScene = function () {\\r\\n    var scene = new BABYLON.Scene(engine);\\r\\n\\r\\n    var light = new BABYLON.PointLight(\\\"Omni\\\", new BABYLON.Vector3(0, 100, 100), scene);\\r\\n    var camera = new BABYLON.ArcRotateCamera(\\\"Camera\\\", 0, 0.8, 100, new BABYLON.Vector3.Zero(), scene);\\r\\n    camera.attachControl(canvas, true);\\r\\n\\r\\n    //Boxes\\r\\n    var box1 = BABYLON.Mesh.CreateBox(\\\"Box1\\\", 10.0, scene);\\r\\n    box1.position.x = -20;\\r\\n    var box2 = BABYLON.Mesh.CreateBox(\\\"Box2\\\", 10.0, scene);\\r\\n\\r\\n    var materialBox = new BABYLON.StandardMaterial(\\\"texture1\\\", scene);\\r\\n    materialBox.diffuseColor = new BABYLON.Color3(0, 1, 0);//Green\\r\\n    var materialBox2 = new BABYLON.StandardMaterial(\\\"texture2\\\", scene);\\r\\n\\r\\n    //Applying materials\\r\\n    box1.material = materialBox;\\r\\n    box2.material = materialBox2;\\r\\n\\r\\n    //Positioning box\\r\\n    box2.position.x = 20;\\r\\n\\r\\n    // Creation of a basic animation with box 1\\r\\n    //----------------------------------------\\r\\n\\r\\n    //Create a scaling animation at 30 FPS\\r\\n    var animationBox = new BABYLON.Animation(\\\"tutoAnimation\\\", \\\"scaling.x\\\", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT,\\r\\n                                                                    BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);\\r\\n    //Here we have chosen a loop mode, but you can change to :\\r\\n    //  Use previous values and increment it (BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE)\\r\\n    //  Restart from initial value (BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE)\\r\\n    //  Keep the final value (BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT)\\r\\n\\r\\n    // Animation keys\\r\\n    var keys = [];\\r\\n    //At the animation key 0, the value of scaling is \\\"1\\\"\\r\\n    keys.push({\\r\\n        frame: 0,\\r\\n        value: 1\\r\\n    });\\r\\n\\r\\n    //At the animation key 20, the value of scaling is \\\"0.2\\\"\\r\\n    keys.push({\\r\\n        frame: 20,\\r\\n        value: 0.2\\r\\n    });\\r\\n\\r\\n    //At the animation key 100, the value of scaling is \\\"1\\\"\\r\\n    keys.push({\\r\\n        frame: 100,\\r\\n        value: 1\\r\\n    });\\r\\n\\r\\n    //Adding keys to the animation object\\r\\n    animationBox.setKeys(keys);\\r\\n\\r\\n    //Then add the animation object to box1\\r\\n    box1.animations.push(animationBox);\\r\\n\\r\\n    //Finally, launch animations on box1, from key 0 to key 100 with loop activated\\r\\n    scene.beginAnimation(box1, 0, 100, true);\\r\\n\\r\\n    // Creation of a manual animation with box 2\\r\\n    //------------------------------------------\\r\\n    setInterval(function () {\\r\\n\\r\\n        //The color is defined at run time with random()\\r\\n        box2.material.diffuseColor = new BABYLON.Color3(Math.random(), Math.random(), Math.random());\\r\\n\\r\\n    }, 1000);\\r\\n\\r\\n    return scene;\\r\\n}\"}","name":"PGDemo","snippetIdentifier":"QYFDDP-1","tags":"","date":"2024-04-12T10:11:22.403Z"}