Not sure what you are actually trying to achieve, but this should work.
I noticed that when trying to output the object (for example console.log) it complains about a missing getDesc function. Going to the original post you linked, the function looks like this:
The getOwnPropertyDescriptor is calling this function as well, so to me, without analyzing this entire thing for too long, it seems like a never ending loop (which is what the browser is also complaining about, when adding this function - maximum call stack size exceeded).
Couldn’t you get the same effect with prototype inheritance?
The goal is to have two prototypes: one with the data (loaded from json) and one with functionality (the ParticleSystem.) This avoids giant functions full of particleSystem.minSize = 1; particleSystem.maxSize = 2; etc...
Object.create() (prototypical inheritance) does not seem to work either:
get_particle_system(type){
let particle_system = new BABYLON.ParticleSystem("particles", 2000, _.scene);
let proto = this.particles[type];
for(let prop of Object.keys(proto)){
particle_system[prop] = proto[prop];
}
return particle_system;
}
if you just want to combine a json and a js, you can use Object.assign, or, as you did, iterate over the keys of props… then metaprogramming is an overkill in that case, as you only one one prototype.