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 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

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

              
                <!-- babylon.min.js v3.3.0 -->
<script src="https://cdn.jsdelivr.net/npm/babylonjs@3.3.0/babylon.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/babylonjs-gui@3.3.0/babylon.gui.min.js"></script>

<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;
}
              
            
!

JS

              
                //Babylon.js Version 3.3.0 のライブラリを使用してみました
//
//Babylon.jsのサンプルがある「Babylon.js Playground」からのコードを参考にして
//Babylon.js のSound再生機能をテストしています
//
//Playgroundのサイトから直接wavファイルを読み込んでいるので、再生されるまで少し時間がかかるかもしれません
//
//
//以下の「Babylon.js Playground」のコードをそのまま流用させてもらいました
//
//Basic sounds
//https://playground.babylonjs.com/indexStable.html#DXAEUY#0
//

var canvas = document.getElementById("renderCanvas");

var createScene = function () {
    var scene = new BABYLON.Scene(engine);

    var camera = new BABYLON.FreeCamera("FreeCamera", new BABYLON.Vector3(0, 0, 0), scene);

    var gunshot = new BABYLON.Sound("Gunshot", "https://rawcdn.githack.com/BabylonJS/Babylon.js/824824036e157cfde96e881ca09c424d9b16cc4a/Playground/sounds/gunshot.wav", scene, function () {
        console.log("Sound is now ready to be played.");
        // Play immediatly
        gunshot.play();
        // Play after 3 seconds
        gunshot.play(3);
    });

    // Load the sound and play it automatically once ready
    var music = new BABYLON.Sound("Violons", "https://rawcdn.githack.com/BabylonJS/Babylon.js/824824036e157cfde96e881ca09c424d9b16cc4a/Playground/sounds/violons11.wav", scene, null, { loop: true, autoplay: true });

    window.addEventListener("keydown", function (evt) {
        // Press space key to fire
        if (evt.keyCode === 32) {
            gunshot.play();
        }
    });

    // Stop the music after 5 seconds
    window.setTimeout(function () {
        music.stop();
    }, 10000);

    return scene;
};

var engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true });
var scene = createScene();

engine.runRenderLoop(function () {
    if (scene) {
        scene.render();
    }
});

// Resize
window.addEventListener("resize", function () {
    engine.resize();
});


              
            
!
999px

Console