ObjectLoader is not loading custom made JSON scene

Hi here!

I’m trying to parse custom made JSON Scene Object, assembled from the backend database. The structure of JSON is the same as described in the documentation, I also compared it with the structure of Scene.toJSON() made json, it’s same.

If I create a pre-defined string variable from my json, it’s parsing it normally. But if I dynamically load the same json, it’s loading an empty scene.

What am I doing wrong?

Thanks in advance!

It is hard to tell without the possibility to see and debug the complete code.

If a direct string works, but a loaded string does not work, make sure you process the string after it is actually loaded. Loading is asynchronous, so when you request a resource to be loaded, it is actually available later in time. This is usually done with a call-back function, executed automatically when the resource is completely loaded.

var loader = new THREE.ObjectLoader().load( url, objectLoaded );

function objectLoaded( data )
	// parse the data here
	loader.parse( ... );

I assume you have already done this, so most likely the cause is something else.