Jump to content

How to assign an Exported Scene to Scene variable


Vijay Kumar
 Share

Recommended Posts

Hi,

My name is vijay.I am new to this forum and new to Babylonjs.

i got very much existed by the wonders we can create by using babylonjs so i started working on it.

Especially in this forum people were very kind and good in helping others.

My Issue is:

 we can assign a babylon scene to a scene variable

ex:  var createScene = function(){

                // create a basic BJS Scene object
                var scene = new BABYLON.Scene(engine);
                ...........
                // return the created scene
                return scene;
            }
 
            // call the createScene function
            var scene = createScene();
 
But how can we assign a scene loaded from other exporters like unity to a variable scene.
The below is working perfectly but i want to assign the newscene to a variable scene like above.so that i can use scene in globally also.
 
 BABYLON.SceneLoader.Load("", "scene.babylon", engine, function (newScene)       
            newScene.executeWhenReady(function () {
                newScene.activeCamera.attachControl(canvas);
                engine.runRenderLoop(function() {
                    newScene.render();
                });
            });
        }
 
please help me and sry for my english.

 

Link to comment
Share on other sites

Here is simple example: 

var gameScene= null;BABYLON.SceneLoader.Load("assets/", "dungeon.babylon", engine, function(scene) {   gameScene = scene;   initGame();   gameScene.executeWhenReady(function() {      engine.runRenderLoop(function () {            gameScene .render();      });   });});function initGame() {  // use gameScene here}
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...