CGinSeattle

Members
  • Content Count

    19
  • Joined

  • Last visited

About CGinSeattle

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. CGinSeattle

    Importing OBJ files directly from computer?

    @Deltakosh @Daiki Thanks, and I've updated my sample to note this new information in the code comments. Daiki, hope this helps. https://www.babylonjs-playground.com/#6N13NV#33
  2. CGinSeattle

    Importing OBJ files directly from computer?

    @Deltakosh Thanks, and one follow up question and one behavior note with the invisible buttons on special navbar I've added (to get it to appear the babylon GUI buttons are doing it): 0) confirmed that it worked in standalone, static html, Brackets-livepreview/localserver, and Playground on my machine (see note below/#2). Hurrah!! Thank you!! (also, this method does not require manifest file either) 1) But...Why? Why the keyword "file:" and the need to fill in the FilesInput structure? Why does that make it such that I can bypass the crossbrowser issue and for that matter, the need for a .manifest file. I can load an obj from disk and all by itself. (yes, I checked the docs, either they don't explicitly call this out, or I missed the correct page.) This is all I found: https://doc.babylonjs.com/tutorials/how_to_use_assetsmanager https://doc.babylonjs.com/classes/3.0/filesinput So why does this make such a difference? BABYLON.FilesInput.FilesToLoad[objfilename] = files[0]; var myObj = loader.addMeshTask(name, "", "file:", objfilename); vs. var myObj = loader.addMeshTask(name, "", "", objfilename); and 2) I noticed that while the Playground sample will work (dialog will come up) on loading - even if the navbar I've added to hold the invisible controls is not visible. However, if you modify the script (something minor like var mynewval = 0; being added or deleted) and hit RUN, then the dialogs stop working. I suspect because something in the Run command now does something where it notices the navbar is hidden and so hides the controls, essentially disabling them. You must do a full reload to get it working again (with navbar hidden). I tried it out by also moving the controls to a different navbar class (one that appears at a lower browser width) and noticed the same behavior. As I don't use the same CSS on my offline/localserver sample (the code just creates plain CSS additions), it's definitely tied to the navbar ability to appear/disappear. But mainly, I'm thinking that if the navbar isn't going to be visible on initial load, then it's odd that it still creates the controls on the client side html and allows the behavior. I would think the opposite would be true. But I'm not a DOM/server/client expert, so perhaps the initial load working (with hidden navbar) is expected behavior. https://www.babylonjs-playground.com/#6N13NV#30 Not sure if you care about this behavior or not in Playground, just thought I'd mention it.
  3. CGinSeattle

    Importing OBJ files directly from computer?

    @Deltakosh @Daiki @JohnK @adam EDIT: Apparently this is a cross browser gotcha, meaning that it considers loading locally to be crossbrowser if somewhere it is expecting http or https. Don't know whether babylon.js is doing this internally or not. Especially as .babylon files seem to be immune (they worked), and the sandbox url allows OBJs to be dragged/dropped from the desktop and without a manifest. Easiest solution is *probably* to run a localserver. I didn't realize but the live preview of Brackets (an HTML/CSS/Javascript Web editor) was doing this (somehow), so that's why I didn't notice the problem until I tested purely from desktop. This is also the most secure alternative. Apparently, you can tell the browser (upon first start up of the very first instance of the browser?? **) to allow files but others have cautioned that this is not secure, it opens your browser up to anything. **haven't tried this yet, so going by the post information...perhaps one *can* launch an instance, after browser already started, and tell that instance to allow files? Would be interesting to find out. See these two stackoverflow posts: https://stackoverflow.com/questions/10752055/cross-origin-requests-are-only-supported-for-http-error-when-loading-a-local https://stackoverflow.com/questions/18586921/how-to-launch-html-using-chrome-at-allow-file-access-from-files-mode I may try to write a convert OBJ to basic .babylon "on the fly" (in memory, after loading the mesh info raw), but that would be a bit more work than I currently want to do. Though perhaps that is why sandbox is working? Perhaps it converts OBJs that are dragged/dropped into a .babylon file? Or not. If I do, I'll update my sample at that point. Final workaround, don't use OBJs that are local. Convert them to .babylon files using a DCC tool first (a pain, but .babylon files seem to be immune to this...so far.) Original: Apparently, I jumped the gun a bit. When I run my code in Brackets, I suspect it is creating a localserver for me as part of it's live debugging feature. When I try to run everything purely from desktop, i.e. all files local, index.html, the obj's, even a full custom babylon.js with everything in it, and even with jquery.pep.js made local, then I get this error. (I also got it when trying to use the pep.js and babylon.js files from the preview url. So it seems to be tied to OBJs only. Babylon files are OK. Is this a bug, that OBJs really really can't be pure local? (even with a manifest saying to load from local?) Or is it a limitation? The babylon code will only allow OBJs to be loaded when there is a localserver (as the offline option). Or am I missing something? p.s. I will be updating a playground example showing my code, I just happened to do a test outside of Brackets and discovered this. EDIT: here is the code in the playground, you'll notice that it also doesn't work in playground (http or https),. a 404, again, somehow connected with the manifest. http://www.babylonjs-playground.com/#6N13NV#9 Thanks! Failed to load file:///C:/Users/c_000/Desktop/babtest2/soccerball.obj.manifest?1507685352542: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. t.checkManifestFile @ babylon.customfull.js:sourcemap:28 babylon.customfull.js:sourcemap:28 Failed to load file:///C:/Users/c_000/Desktop/babtest2/soccerball.obj.manifest: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. (anonymous) @ babylon.customfull.js:sourcemap:28 babylon.customfull.js:sourcemap:3 Failed to load file:///C:/Users/c_000/Desktop/babtest2/soccerball.obj: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. h @ babylon.customfull.js:sourcemap:3
  4. CGinSeattle

    Importing OBJ files directly from computer?

    @Daiki Hi, First, drag and drop the obj into the sandbox location. It should load OK. If not, then something may be wrong. Second, to programmatically load the obj file. First create a manifest file. This is going to be your manifest file for your obj file. Name it the same as your obj file, except you will add .manifest In other words, if your obj is named... myobject.obj then create... myobject.obj.manifest Then put the following text in the manifest file. { "version" : 1, "enableSceneOffline" : true, "enableTexturesOffline" : true } I have attached an example to this note. Next: You will now load the obj using a loader. As a first test, you can simply load it using the same location as your offline index.html file. This index.html file contains your babylon html code. With the obj and manifest in the same directory as this file, it should find it. For example, say your obj file is named soccerball.obj You will create a soccerball.obj.manifest file You will have your index.html babylon file and these two files together in the same directory. Your loader will call: var loader = new BABYLON.AssetsManager(scene); var myObj = loader.addMeshTask("soccerball", "", "", "soccerball.obj"); //will look in same location as html file BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true; I will be creating a playground sample with my code for loading an offline obj file tomorrow sometime. I will post the location here when I have done that. But the above is the basic procedure. I hope this makes sense? soccerball.obj.manifest
  5. CGinSeattle

    Importing OBJ files directly from computer?

    Ha! Solved it! To load a straight OBJ file locally (no localserver, no webserver, just from disk), OBJ files still need a .manifest file to tell the browser NOT to load from a webserver. See this link: http://doc.babylonjs.com/tutorials/caching_resources_in_indexeddb Once I added a myobjectfile.obj.manifest file with the info per that article inside. i.e. { "version" : 1, "enableSceneOffline" : true, "enableTexturesOffline" : true } then I could use an AssetsManager loader to load the individual OBJ mesh into the current scene. i.e. var loader = new BABYLON.AssetsManager(scene); var myObj = loader.addMeshTask(name, "", "", filename); I used the filename from the <input> to get the name of the mesh (single mesh per OBJ) and the file name itself (filename.obj after being stripped of the fakepath part). However, calling SceneLoader.ImportMesh did not work. Apparently, it only accepts .babylon files
  6. CGinSeattle

    Importing OBJ files directly from computer?

    @Deltakosh I also tried. And I can drag and drop the obj file of mine into that sandbox.babylonjs.com site. But why? I'm using the same obj loader and location to it in my code, but it will not load from disk no matter what I try. I've tried the file loader method to get the path, and just having it in the same directory as the index. html file. I either get file not found or unable to load no matter what. So now I know my obj is fine, but somehow the sandbox.babylonjs.com site can pick it up but I can't. What is being done differently? Thanks! Edit: nevermind, solved it! see next message.
  7. CGinSeattle

    Importing OBJ files directly from computer?

    @Daiki @Deltakosh I also tried a simple OBJ file exported from Maya 2015 and can't get it to load. I keep getting JSON parsing/undefined token errors (even when I strip it down to just vertex information). And any other attempt to load OBJ's directly (no manifest, no babylon file, etc.) with any objloader I've found on the babylon sites (demos and git) doesn't seem to work (playground or local/static). So I'm thinking now that perhaps the Objloader is pretty finicky and perhaps looking for some special stuff that an older Blender or Maya doesn't do. I don't have any new OBJ files to play with, so I guess the next step would be to debug the obj loader to see if I can spot why it's rejecting a perfectly fine, plain old OBJ file. Or it simply doesn't work on pure .obj files anymore for some reason, i.e. .obj not .babylon. In fact, the OBJ demo doesn't seem to work any more either. https://doc.babylonjs.com/extensions/obj I assumed it was because maybe the obj urls were no longer good, but now, I'm wondering if perhaps it's the objreader itself. The demo was dependent on babylon js 2.1. Basically, I'm out of ideas for now. Pure OBJs would be lovely, vs having to pack them inside some other format via Blender or whatever, but if it is possible, I can't seem to find the right combination. Please let me know if you get your OBJ to load, as I'd like to compare it with the ones I'm using and the code your using to make it work with the current version of babylonJS.
  8. CGinSeattle

    Importing OBJ files directly from computer?

    @Daiki @Deltakosh OK, tried running my code (again, it's in playground and based off loading the obj loader from another example) but ran it in http (not https) *** EDIT: I also tried on a local (static) version I'm working on. Same error as the playground (below). Caveats: I also can't load an obj created a few years ago with Blender (a local file) and shipped by a commercial AR kit maker, and it gives an error indicating that the loader I'm using doesn't like the OBJ file, while Unity is ok with the same OBJ file. I also tried using the obj loader the playground uses (namely) <script src="https://preview.babylonjs.com/loaders/babylon.objFileLoader.js"></script> So the OBJ format expected/accepted by babylon objloaders (the two I've tried) may be different. But I haven't tried a number of different OBJs yet to see if I can get any to work. *** End Edit: Still no joy on your obj file, Daiki. But the error is different ***EDIT (same for both the obj loader from the example on OBJ loading, and the one used by the playground, and both in the playground and statically on my local machine). ***End Edi Hope this helps. Error follows: Failed to load http://www.jp-wolters.de/shop/helloworld/door.obj.manifest?1507585329366: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.babylonjs-playground.com' is therefore not allowed access. The response had HTTP status code 404.
  9. CGinSeattle

    Importing OBJ files directly from computer?

    @Daiki Also, are you also doing something like this to force a render? loader.onFinish = function() { engine.runRenderLoop(function () { scene.render(); }); };
  10. CGinSeattle

    Importing OBJ files directly from computer?

    @Daiki I tried loading your obj file using the code I'm working on in the Playground. see: https://www.babylonjs-playground.com/#6N13NV#8 It may not be the problem, because I am loading up the objloader based on another example in Playground, but I also couldn't load your file. the error (Mixed Content Error) indicated that the url must be HTTPS not HTTP Again, this might only be because I'm trying from the playground, which is https. Error Output from console follows: about to run loader for obj VM5027:136 about to try door babylon.js:30 Mixed Content: The page at 'https://www.babylonjs-playground.com/#6N13NV#7' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.jp-wolters.de/shop/helloworld/door.obj.manifest?1507584842956'. This request has been blocked; the content must be served over HTTPS. t.checkManifestFile @ babylon.js:30 t @ babylon.js:30 t._loadData @ babylon.js:29 t.ImportMesh @ babylon.js:29 i.runTask @ babylon.js:42 e.run @ babylon.js:42 t._runTask @ babylon.js:42 t.load @ babylon.js:42 reader.onload @ VM5027:149 FileReader (async) handleObjFileSelect @ VM5027:153 babylon.js:30 Mixed Content: The page at 'https://www.babylonjs-playground.com/#6N13NV#7' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.jp-wolters.de/shop/helloworld/door.obj.manifest'. This request has been blocked; the content must be served over HTTPS. (anonymous) @ babylon.js:30 XMLHttpRequest.send (async) t.checkManifestFile @ babylon.js:30 t @ babylon.js:30 t._loadData @ babylon.js:29 t.ImportMesh @ babylon.js:29 i.runTask @ babylon.js:42 e.run @ babylon.js:42 t._runTask @ babylon.js:42 t.load @ babylon.js:42 reader.onload @ VM5027:149 FileReader (async) handleObjFileSelect @ VM5027:153 babylon.js:3 Mixed Content: The page at 'https://www.babylonjs-playground.com/#6N13NV#7' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.jp-wolters.de/shop/helloworld/door.obj'. This request has been blocked; the content must be served over HTTPS. l @ babylon.js:3 t.LoadFile @ babylon.js:3 p @ babylon.js:29 t @ babylon.js:30 (anonymous) @ babylon.js:30 VM5027:115 something bad happened: Unable to import meshes from http://www.jp-wolters.de/shop/helloworld/door.obj: 0 :undefined
  11. @Gijs Perfect! That did it! Thank you so much!! I don't have enough experience yet with babylonJS to spot such a simple fix, so thank you! @Deltakosh This page is where I got the HTML. http://babylonjsguide.github.io/begins/Introducing_Babylonjs You may want to ask the doc writers to update it to the correct call and the correct url for babylon.js online. It's a minor thing, of course, but for newbies like me, that don't know any better, it might be helpful...
  12. I know something seems to be wrong here. I"m using the simpliest example, the one in the beginning docs, the full HTML given there. I am running static. I've managed to get the HTML to load statically (i.e. no localserver, no webserver, just off the desktop) and have the generated babylon.js file in the same directory as the index.html page. I know it's loading and finding the .js file. It fails in the same place whether I use my custom generated babylon js file or if I point the page to the same babylon.js file that the playground uses. the error from the inspector is: Uncaught TypeError: scene.render is not a function I am running in Chrome, but I have no issues with running Playground in Chrome. Also the HTML does the same thing in IE (though it's debugger picks up no errors, just won't run beyond creating the canvas). Error reported from Chrome: BJS - [17:31:37]: Babylon.js engine (v3.1-alpha) launched index.html:79 Uncaught TypeError: scene.render is not a function at index.html:79 at r._renderLoop (babylon.js:4) It points at the line in index.html (at scene.render) engine.runRenderLoop(function () { // Register a render loop to repeatedly render the scene scene.render(); }); Attaching the index.html file. Any ideas? I don't want to have to deal with localserver. And am working on a way to load OBJ files (that's how I got here. I wanted to see if I could get the objloader to work from the desktop, since I cannot get it to work in the Playground via file chooser. I can only get .babylon files to load successfully in that case.) If you're curious about that, see: https://www.babylonjs-playground.com/#6N13NV#7 So I thought I would try a different tack. After all, I should be able to load .js files locally (static HTML), including the objloader extension. But I didn't anticipate that I would have problems with getting babylon.js to work in that situation. It seems it must be something simple, after all this is just the beginner sample that the docs list. Nothing fancy. But after a number of hours of searching forums and experimenting, I'm out of ideas. Thanks! index.html
  13. CGinSeattle

    Importing OBJ files directly from computer?

    @Deltakosh @adam @JohnK Did an update of adam's original to live create the upper navbar and label along with the choose file button. And included some comments and tests within and outside the callback just for completeness. Should work now in both Chrome and IE since it creates the button and new div's live. Learned alot, thanks all! https://playground.babylonjs.com/#5JBSHD#20 Edit: still can't get the objloader extension to work with the file chooser method. Don't know why yet, but in case, others are interested. If you're curious about that, see: https://www.babylonjs-playground.com/#6N13NV#7 This version has two buttons added dynamically to Playground, and two different methods being tried to load the obj file. Note: the button for OBJ loading also loads .babylon files. so I'm wondering if the objloader extension, despite being run (console log message confirms it starts to run), is being ignored? And I'm wondering why Playground won't just load an OBJ (I tried, it doesn't, at least not in my setup) since I looked at the HTML scripts Playground is loading, and an objloader js is one of them. Will update again if I get it running with file choosing from disk.
  14. CGinSeattle

    Importing OBJ files directly from computer?

    @Deltakosh actually the original goal was and still is to load OBJs for quick prototyping (no need for textures yet) and no need to try to get the mesh into a new format (new exporter, etc. etc.) Quick and easy. But .babylon file loading taught me a lot in my second day of play in a webgl/HTML/javascript world. Haven't hit shaders yet, as that will be a much bigger goal - save that for day 5 maybe. LOL. Being able to load up individual shaders quickly (from disk) to test before working out a way to test them quickly on a mobile device will be huge. And *not* having to setup a localserver (fake server) system like A-Frame requires just to test a prototype is a very good thing!
  15. CGinSeattle

    Importing OBJ files directly from computer?

    @DeltakoshYep, that was it. For whatever reason, the first mesh when loading a number of different .babylon samples, wasn't a good one to test with. But doing it to all of them in version17, did show an effect! Only wish this loader worked with straight obj's as well. I set the element to accept both .babylon and .obj like @JohnK 's example using @adam's code but no joy. The loader in adam's example must not accept obj's and adjusting for obj's isn't in my wheelhouse yet. I'm still using a plastic shovel and pail in the playground.