var DetectCollision = function () {
//被检测的物体
this.detectArray = [];
this.movingCube = function(){
var geometry = new THREE.SphereGeometry(0.5);
var cube = new THREE.Mesh(geometry);
cube.visible = false;
return cube;
};
};
DetectCollision.prototype.removeDetector = function(object){
var index = this.detectArray.indexOf(object);
if(index === -1) return;
this.detectArray.splice(index, 1);
};
//在数组中添加元素
DetectCollision.prototype.addDetector = function(object){
if(this.detectArray.indexOf(object) !== -1) return;
this.detectArray.push(object);
return this;
};
最后我初始化的时候
var detectCollision = new DetectCollision();
//console.log(detectCollision);
collisionArray = new DetectCollision().addDetector(cases1);
却提示我
DetectCollision is not a constructor
请问我该怎么写呢??