tomph Posted November 29, 2018 Share Posted November 29, 2018 Does anyone know how to extend the default babylon.js file parser? I'm successfuly loading a scene with the JSON data I have (Babylon File Format), but my JSON contains some custom metadata, which I'd like to handle when i load/parse. I'm aware of Scene.AddParser, but I feel like that is too far down the chain (my custom properties have been stripped out by the time it hits my parser function). Another thing I've noticed is you can do the following: BABYLON.SceneLoader.OnPluginActivatedObservable.add(function (loader:ISceneLoaderPlugin) { }); Is there anything I can hijack at that point? I can see loader has an extensions property..... Any help would be appreciated, thanks! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 29, 2018 Share Posted November 29, 2018 Hiya tomph. I don't know if useful/not, but the BJS SCENE class... has a .metadata property. I'm pretty sure... it wants a string. I heard that .metadata exports into BJS... just fine. When OnSceneReady... json-parse the giant serialized-json string found in scene.metadata. A database... in a storage pocket of a .babylon file! YAY! Also, all "nodes" have their own .metadata property, too... lights, cameras, mesh-erschmitts. A guy COULD... put a very large chunk of serialized json poop, inside a .metadata property. Would THAT work for you? Maybe. Here's a playground search for scene.metadata. bghgary 1 Quote Link to comment Share on other sites More sharing options...
bghgary Posted November 29, 2018 Share Posted November 29, 2018 6 hours ago, tomph said: Is there anything I can hijack at that point? I can see loader has an extensions property..... The extensions property is for supported file extensions and not any kind of extensibility mechanism. @tomph Can you explain your scenario? Quote Link to comment Share on other sites More sharing options...
tomph Posted November 30, 2018 Author Share Posted November 30, 2018 Thanks Wingnut/bghgary. I got there in the end - just had to keep digging. metadata was my friend I ended up writing a whole custom loader....and then realised I didn't have to. Learning is fun, right! bghgary, Sebavan and Wingnut 3 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 30, 2018 Share Posted November 30, 2018 Can we mark as "solved"? Close-up this issue and head for the tavern? PARTY!!! (Wingnut digs-into tomph's metadata to see if there's some Blackberry Brandy included. Yum! Maybe some serialized cereal.) (No brandy or cereal, but there's an aerosol can of BJS Scene Lube, in there. Greasome!) Quote Link to comment Share on other sites More sharing options...
Guest Posted December 3, 2018 Share Posted December 3, 2018 marked as solved 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.