之前主要是Entity的一个大概流程,本文主要介绍Cesium的属性,比如defineProperties,Property(ConstantProperty,CallbackProperty,ConstantPositionProperty)以及createPropertyDescriptor的相关内容,研究一下Cesium对Object的属性设计和使用方式。
我们以Entity为例,看看它是如何封装自己的属性:
function Entity(options) { var id = options.id; if (!defined(id)) {
id = createGuid();
} this._id = id; this._name = options.name; this._description = undefined; this._position = undefined; this._rectangle = undefined;
}// Key 1:definePropertiesdefineProperties(Entity.prototype, {
id : {
get : function() { return this._id;
}
}, // Key 2:createRawPropertyDescriptor
name : createRawPropertyDescriptor('name'), // Key 3:createPropertyDescriptor
description : createPropertyDescriptor('description'), // Key 4:createPositionPropertyDescriptor
position : createPositionPropertyDescriptor('position'), // Key 5:createPropertyTypeDescriptor
rectangle : createPropertyTypeDescriptor('rectangle', RectangleGraphics)
});
网友评论


