toJSON
方法旨在将SteeringManager对象转换为JSON格式。
SteeringManager.toJSON()
无参数。
返回一个包含SteeringManager对象所有属性及其值的JSON对象。
let manager = new SteeringManager();
let vehicle = new Vehicle();
manager.addAgent(vehicle);
let json = manager.toJSON();
console.log(json);
输出结果为:
{
"agents": [{
"id": 0,
"position": {
"x": 0,
"y": 0
},
"velocity": {
"x": 0,
"y": 0
},
"maxSpeed": 1,
"maxForce": 1,
"mass": 1,
"angle": 0,
"angularVelocity": 0,
"rotation": 0,
"target": null
}],
"goal": {
"position": {
"x": 0,
"y": 0
},
"radius": 0
}
}
无异常。