在一个html中加载多个babylon文件

时间:2014-12-22 22:30:01

标签: html babylonjs

我想知道如何在一个html页面中加载两个或更多个babylon文件,或者是否可以加入它们。 我有以下代码,很高兴看到一个简单的模型(导出),但我需要在同一个html页面中添加更多导出的模型。我听说过" options.babylonFolder +" /",options.babylonFile"选项,但我不知道更多。

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Using babylon.js - How to load a scene</title>
<script type="text/javascript" src="./103A_files/hand.js"></script>
<script type="text/javascript" src="./103A_files/cannon.js"></script>
<script type="text/javascript" src="./103A_files/babylon.js"></script>
<style>
    html, body {
        width: 100%;
        height: 100%;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }

    #renderCanvas {
        width: 100%;
        height: 100%;
    }
  </style>
  </head>
  <body>
<canvas id="renderCanvas"></canvas>
<script>
    if (BABYLON.Engine.isSupported()) {
        var canvas = document.getElementById("renderCanvas");
        var engine = new BABYLON.Engine(canvas, true);

        BABYLON.SceneLoader.Load("", "101A.babylon", engine, function (newScene) {
          //BABYLON.SceneLoader.Load(options.babylonFolder + "./GrupoBabylon", options.babylonFile, engine, function (newScene) {  
            newScene.executeWhenReady(function () {
                // Attach camera to canvas inputs
                newScene.activeCamera.attachControl(canvas);

                // Once the scene is loaded, just register a render loop to render it
                engine.runRenderLoop(function() {
                    newScene.render();
                });
            });
        }, function (progress) {
            // To do: give progress feedback to user
        });


    }
</script>

1 个答案:

答案 0 :(得分:2)

您可以使用BABYLON.SceneLoader.Append将新场景与当前场景合并