Jump to content

How to load a json file using assetManager?


Vorion
 Share

Recommended Posts

Hi,

I've been trying to load a json file using the assetmanagers textfile task, but this only returns an arraybuffer. I would have expected that the task returns a simple string which I then can parse to a json object.

When loading the file directly through an xmlhttprequest, I get the string which can be parsed without a problem.

Here's an example:

http://www.babylonjs-playground.com/#GIKDTN#3

You can see in the console log, that the textfile task returns an arraybuffer and then fails to parse it as a json object.

What am I doing wrong here?

Thanks :)

EDIT: I guess this is a bug in Babylon.js 3.2.0, when I switch to stable version in the playground, it works as I expected.

Link to comment
Share on other sites

Hi Vorion... sorry to hear you are having problems.

I did some testing/playing... https://www.babylonjs-playground.com/#GP88V#6

As you can see, I "hijacked" some of the BJS core TextFileAssetTask functionality... into the playground.

See that 'false' in line 73?  That is the useArrayBuffer parameter... as seen in line 3.

For some reason, BABYLON.Tools.LoadFile (possibly line 24) is ignoring or over-riding that parameter.

So, just like you, I get an arrayBuffer, but no text... in my tests.  Sorry, I have no solution, but I'm studying it. 

Hopefully, smarter people than I... will comment soon.

I'm also wondering... if a recent security situation... which is rumored to cause trouble with shared memory... has affected this situation.

See this post and its follow-up.   Maybe... related.  Not sure.  https://blog.barkly.com/meltdown-spectre-patches-list-windows-update-help

Sorry I don't have good answers yet, but I can smell something nearby.  :)  Something is stinky... in this dumpster that I'm currently exploring.  heh.

XMLHttpRequestObject is a "reach out and touch someone" (groping) thing (just like the current USA president and other mostly-male decadents).  It has been a "house of ill-repute" for its entire existence.  Some changes in XHR about 12 years ago... killed a 7 year marriage between me and a multimedia chat client I was developing. 

So, I don't trust it.  It is like a seaport or bus depot - slimy things ooze in/out of it.  :)  Virus coders and sandbox/firewall hackers... are also "slimy" and hang-out around ports.  Smell 'em?  *nod*  Can't back-up the text truck and load any parse-able json into it.  Hacker poop... making the loading ramps and docks... too slippery.   (Wingy watching Saturday morning cartoons... being goofy-minded)  :)

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