feilong Posted November 13, 2017 Share Posted November 13, 2017 I have try to load a glb file generate by microsoft 3d paint. my file is in here. i test createScene function in http://www.babylonjs-playground.com/#6MZV8R and it works well.but use my code it doesn't work.? ![]() console show me ![]() my js code is before,and div with class name 'gltfobj'. "use strict"; function setGltf(gltfarea) { //$(".gltfobj")[0].id.match(/(.*\/)(.*\.gl(?:b|tf))/) var rooturl = gltfarea.id.match(/(.*\/)(.*\.gl(?:b|tf))/)[1]; var gltfname = gltfarea.id.match(/(.*\/)(.*\.gl(?:b|tf))/)[2]; console.log('root: ' + rooturl + ' ,name: ' + gltfname); var canvas = document.createElement("CANVAS"); canvas.width = 400; canvas.height = 400; gltfarea.appendChild(canvas); var engine = new BABYLON.Engine(canvas, true); var createScene = function () { // This creates a basic Babylon Scene object (non-mesh) var scene = new BABYLON.Scene(engine); // glTF Files use right handed system scene.useRightHandedSystem = true; // Configuring camera var camera = new BABYLON.ArcRotateCamera("camera", 1.55, 1.6, 2, BABYLON.Vector3(0, 0, 0), scene); camera.attachControl(canvas, true); camera.wheelPrecision = 100.0; camera.minZ = 0.01; camera.maxZ = 1000; // This creates a light, aiming 0,1,0 - to the sky (non-mesh) var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); // Default intensity is 1. Let's dim the light a small amount light.intensity = 0.7; // Append sample glTF model to scene BABYLON.SceneLoader.Append("https://raw.githubusercontent.com/feilongfl/pic-bed/master/201711/", "%E6%BB%91%E7%A8%BD.glb", scene, function (scene) {}, null, function (scene) { console.log("error!")+ }); return scene; }; var scene = createScene(); engine.runRenderLoop(function () { scene.render(); }); window.addEventListener("resize", function () { // Watch for browser/canvas resize events engine.resize(); }); } // require(['https://cdnjs.cloudflare.com/ajax/libs/babylonjs/3.0.1-beta/babylon.max.js'], function () { require(['https://cdn.babylonjs.com/babylon.js'], function () { require(['https://cdn.rawgit.com/BabylonJS/Babylon.js/master/dist/preview%20release/loaders/babylon.glTFFileLoader.min.js'], function () { for (var i = 0; i < $(".gltfobj").length; i++) { setGltf($(".gltfobj")[i]); // console.log(i); } }); }); Quote Link to comment Share on other sites More sharing options...
feilong Posted November 13, 2017 Author Share Posted November 13, 2017 whole project is in https://github.com/feilongfl/nodebb-plugin-babylon-gltf Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 13, 2017 Share Posted November 13, 2017 Hi @feilong, welcome to the forum Have you tried using the latest versions of both babylon and the gltf loader? I think you are using the latest GLTF loader, but not the latest babylon, which has a different API (the AddToMesh function was added in 3.1) feilong 1 Quote Link to comment Share on other sites More sharing options...
feilong Posted November 14, 2017 Author Share Posted November 14, 2017 Thank you very mach!I have changed the babylon.js to the latest version.and it works well. RaananW 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.