[LayaAirIDE 2.0]box2d动态创建绑定多个关节报错 Node:the component is singleton,can't add the second one.

需求:模拟粘性小球,与任何物体发生碰撞后,在容器内动态创建多个DistanceJoint 与多个不同rigBody做距离关系绑定
代码片段: 
onTriggerEnter(other: any, self: any, contact: any) { 
let pointes = contact.getHitInfo().points; 
let potSelf = new Laya.Point(pointes[0].x, pointes[0].y);
let potOther = new Laya.Point(pointes[0].x, pointes[0].y);
self.owner.globalToLocal(potSelf); 
other.owner.globalToLocal(potOther); 
var distanceJoint = new Laya.DistanceJoint();
 
distanceJoint.otherBody = other.rigidBody;
distanceJoint.otherAnchor = [potOther.x, potOther.y]
distanceJoint.selfAnchor = [potSelf.x, potSelf.y]; 
this.owner.addComponentIntance(distanceJoint);
 
}报错信息如下: Node:the component is singleton,can't add the second one.
 
翻看源码后发现有这么一段判断单例组件的限制
__proto.addComponentIntance=function(comp){
        if (comp.owner)
            throw "Node:the component has belong to other node.";
        if (comp.isSingleton && this.getComponent((comp).constructor))
            throw "Node:the component is singleton,can't add the second one.";
        this._addComponentInstance(comp);
        return comp;
    }
 
暂时的处理方式是把isSingleton的判断注释了
 
但是很不解,按照原设计思路是不允许在一个容器添加多个同类型的component的吗?
可是在可视化界面上是可以在同个容器下添加多个同类型的关节的呀?
那么这个限制的目的是什么呢?
已邀请:

要回复问题请先

商务合作
商务合作