Jump to content

model from cloud


hunts
 Share

Recommended Posts

Hello:), i've been trying to load a scene from my github, but it doesn't load anything

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <title>Babylon.js sample code</title>
        <!-- Babylon.js -->
        <script src="http://www.babylonjs.com/hand.minified-1.2.js"></script>
        <script src="http://www.babylonjs.com/cannon.js"></script>
        <script src="http://www.babylonjs.com/oimo.js"></script>
        <script src="http://www.babylonjs.com/babylon.js"></script>
        <style>
            html, body {
                overflow: hidden;
                width: 100%;
                height: 100%;
                margin: 0;
                padding: 0;
            }

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

        var scene = new BABYLON.Scene(engine);
        
            if (BABYLON.Engine.isSupported()) {
                var canvas = document.getElementById("renderCanvas");
                var engine = new BABYLON.Engine(canvas, true);
        
                BABYLON.SceneLoader.Load("https://raw.githubusercontent.com/BabylonJS/Website/master/Scenes/Sponza/", "Sponza.babylon", engine, function (scene) {
                    // Wait for textures and shaders to be ready
                    scene.executeWhenReady(function () {
                    scene.activeCamera.attachControl(canvas);
        
                        // Once the scene is loaded, just register a render loop to render it
        var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 0.3, scene);
        
            // Move the sphere upward 1/2 its height
            sphere.position.y = 1;
        
        scene.onPointerDown = function (evt, pickResult) {
        console.log(pickResult);
        						if(pickResult.hit){
               //  if the click hits the ground object, we change the impact position
                if (pickResult.pickedMesh.name = "sphere1") {
                  sphere.dispose()
                }
                }
            };
        
                        engine.runRenderLoop(function() {
        sphere.position.z -= 0.002;
                            scene.render();
                        });
                    });
                }, function (progress) {
                    // To do: give progress feedback to user
                });
        
            }

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

        // Resize
        window.addEventListener("resize", function () {
            engine.resize();
        });
    </script>
</body>
</html>

 

Link to comment
Share on other sites

What does your console say?  There is no such thing as " doesn't load anything".  This is programming.  You can also turn on additional logging for sceneloader by placing this before the load statement, should the console does not show you your issue:

BABYLON.SceneLoader.loggingLevel = BABYLON.SceneLoader.DETAILED_LOGGING;

 

Link to comment
Share on other sites

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