该函数用于将ObstacleAvoidanceBehavior中需要引用其他实体的属性转化为实际实体。
ObstacleAvoidanceBehavior.prototype.resolveReferences = function(entities) {
var self = this;
entities.forEach(function(entity) {
if (entity.name === self.obstacle.name) {
self.obstacle = entity;
}
});
};
该函数没有返回值,但会将ObstacleAvoidanceBehavior中需要引用其他实体的属性转化为实际实体。
var obstacleAvoidanceBehavior = new Yuka.ObstacleAvoidanceBehavior();
var obstacle = new Yuka.Obstacle(new Yuka.Vector3(1,1,1), 1);
var entities = [obstacle];
obstacleAvoidanceBehavior.obstacle = { name: obstacle.name };
obstacleAvoidanceBehavior.resolveReferences(entities);
console.log(obstacleAvoidanceBehavior.obstacle); // output: Obstacle {position: Vector3, radius: 1}