I have been working on setting up a constructor and trying to initialize an array inside the object that will be created. This specific array is meant to hold multiple objects.
function Cluster3DObject(name){
this.name = name;
this.array = [];
}
Cluster3DObject.prototype.add = function(obj) {
this.array.push(this.obj);
};
Here, I am creating the "class" and including a method called "add" which is intended to add an object to this.array.
var cluster = new Cluster3DObject("clster");
var testObj = new THREE.CSS3DObject(testDiv);
var testVector = new THREE.Vector3();
cluster.add(testObj);
However, when I try to call the cluster.add method, I encounter the error "undefined is not a function" and I can't quite pinpoint what I'm doing incorrectly. I'm fairly new to using constructors so any guidance would be greatly appreciated!