添加地面很简单,使用API:
const ground = BABYLON.MeshBuilder.CreateGround("ground", {width:10, height:10});
options 参数设置了两个属性,x 方向的宽度和 z 方向的高度。(是的,我们同意,因为 y 是垂直的,所以属性为宽度和深度会更有意义。)
添加声音也很简单,
如果是连续的声音,用:
const sound = new BABYLON.Sound("name", "url to sound file", scene, null, { loop: true, autoplay: true });
如果是只播放一次的声音, 则用:
const sound = new BABYLON.Sound("sound", "url to sound file", scene);
//Leave time for the sound file to load before playing it
sound.play();