I need help figuring out how to extend the Object3D class in Three.js.
I've been trying to follow a Stackoverflow question on this topic, but despite multiple attempts, I haven't been successful.
Is there a way to extend a ThreeJS object?
If anyone has specific code examples or tips on how to make this work, it would be greatly appreciated. Here's what I have tried so far:
var MyObject3D = function() {
THREE.Object3D.call(this);
MyObject3D.prototype = new THREE.CubeGeometry();
MyObject3D.prototype.constructor = MyObject3D;
}
When creating an instance:
var thing = new MyObject3D();
var testGeo = new THREE.CubeGeometry(10, 10, 10);
var testMat = new THREE.MeshPhongMaterial();
var testMesh = new THREE.Mesh(testGeo, testMat);
thing.add(testMesh);
However, when trying to call the "add" method on the MyObject3D instance using "thing," an error saying that "thing" does not have a method "add" is returned.
Can someone please explain what might be causing this issue?