0

I have added particlesystem to threejs editor and trying to load its properties

const scene = await loader.parseAsync( json.scene );
        
scene.traverse(child => {
    console.log(child.config)
    if ((child.type=="ParticleSystem" || child.name=="ParticleSystem") && child.config) {
        const obj = ParticleSystem.fromJSON(child.config);
        // ✅ Only add if parent is a real Object3D
        if (parent && typeof parent.add === 'function') {
            parent.add(obj);
        }
    }
});

but objectloader not recognizingthe config but htey are present in json file. if I overrride the object loader like this it will work but other objects wont load

const originalParseObject = THREE.ObjectLoader.prototype.parseObject;

THREE.ObjectLoader.prototype.parseObject = function (data, parent) {
    console.log("Heyyy",data.config)
  if (data.type === 'ParticleSystem') {
    const obj = ParticleSystem.fromJSON(data);
    // ✅ Only add if parent is a real Object3D
    if (parent && typeof parent.add === 'function') {
      parent.add(obj);
      
    }

    return obj;
  }

  return originalParseObject.call(this, data, parent);
};

I tried extending the ObjectLoader and overriding the parseobject method still same problem

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.