javascript - Babylon JS - SceneLoader from Local File -


new babylon js user, looking speed fantastic framework. have had play sandbox , online editor, worked own coded model scratch using standard components - box, sphere etc. question relates how more complex custom geometry loaded. comfortable 3d cad - stl/obj files, got exports going blender .babylon format import great babylon's online sandbox & editors. however, can't seem sceneloader going read file local c:/ drive. code extract below:

// create new babylon scene var scene = new babylon.scene(engine);  // change scene background color scene.clearcolor = new babylon.color3(1, 1, 1);  // create , positions free camera var camera = new babylon.freecamera("camera1", new babylon.vector3(0, 10, 0), scene);   // target camera scene origin  camera.settarget(babylon.vector3.zero());  // attach camera canvas camera.attachcontrol(canvas, true);  // define built-in 'box' shape. var box = babylon.mesh.createbox("sphere1", 1, scene);  // define 'ground' plane var ground = babylon.mesh.createground("ground1", 100, 100, 100, scene);             ground.position.y = 0; //load local .babylon file root dir babylon.sceneloader.load("", "test.babylon", engine, scene); 

my model has standard box geometry ground plane. renders great in babylon - until add sceneloader line. when add stuck on babylon loading intro splash screen (rotating babylon logo). if comment out last line of code above model renders fine box. have had @ various forum pages on , wrecked brain point of being stuck e.g: http://www.html5gamedevs.com/topic/20924-stlobj-file-loader/ & https://www.eternalcoding.com/?p=313 believe google chrome may locking out local file links security, have tried running in -allow-local-file-access mode, still stuck on loading page. need web server (i wouldn't know start!) or can run babylon scenes locally?

so i’m not 100% sure answer, help. followed tutorial (skip down section scene gets loaded). 1 issue cross origin thing, other how call sceneloader.load method.

when try code tutorial regular chrome see 3 warnings in web console. 2 errors test.babylon.manifest (using example file naming) , 1 test.babylon. can ignore ones regarding manifests afaik. important 1 error test.babylon itself. default cross origin requests not allowed , babylon file not load (as expected).

now, when close chrome , reopen running open -a "google chrome" --args --allow-file-access-from-files in terminal (i’m on osx yosemite), , load page, object loads fine. still see 2 errors manifests in web console, can ignored.

note how babylon.sceneloader.load function being called. import process asynchronous, , last parameter looks callback function once object has loaded, don't think can pass scene in original code. check out function docs.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -