该代码使用继承的孩子,我在场景中添加一些东西,在父声明我怎么能做到这一点得到它在看到现场错误的子级别我怎么能在子代码中使用父变量?
function parent (domElement, renderStatistics) {
this.scene = new THREE.Scene();
}
function child(domElement) {
parent.call(this, domElement);
this.init();
}
child.prototype = Object.create(parent.prototype);
child.prototype.constructor = Young;
child.prototype.init = function() {
function createLab(geometry) {
var mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial());
this.scene.add(mesh); // this error Cannot call method 'add' of undefined
}
}
感谢这是我的错误没有在代码中 –