標(biāo)簽將繪制定位在三維場景中的視區(qū)對齊文本。不應(yīng)直接使用此構(gòu)造函數(shù),而應(yīng)通過調(diào)用
new Label()
LabelCollection#add
來創(chuàng)建標(biāo)簽。
Throws
-
DeveloperError : translucencybydistance.far必須大于translucencybydistance.near。
-
DeveloperError : pixeloffsetscaleByDistance.far必須大于pixeloffsetscaleByDistance.near。
-
DeveloperError : 距離displayCondition.far必須大于距離displayCondition.near
Members
(static) enableRightToLeftDetection : Boolean
確定是否運(yùn)行與標(biāo)簽文本從右向左語言匹配的算法
-
Default Value:
false
Examples:
// Example 1.
// Set a label's rightToLeft before init
bmgl.Label.enableRightToLeftDetection = true;
var myLabelEntity = viewer.entities.add({
label: {
id: 'my label',
text: '?? ???? ?????? \n ?????? ?????? ????',
}
});
// Example 2.
var myLabelEntity = viewer.entities.add({
label: {
id: 'my label',
text: 'English text'
}
});
// Set a label's rightToLeft after init
bmgl.Label.enableRightToLeftDetection = true;
myLabelEntity.text = '???? ???';
backgroundColor : Color
獲取或設(shè)置此標(biāo)簽的背景色。
-
Default Value:
new Color(0.165, 0.165, 0.165, 0.8)
backgroundPadding : Cartesian2
獲取或設(shè)置此標(biāo)簽的背景填充(以像素為單位)。
x
值控制水平填充,y
值控制垂直填充。
-
Default Value:
new Cartesian2(7, 5)
disableDepthTestDistance : Number
獲取或設(shè)置與要禁用深度測試的照相機(jī)之間的距離,例如,防止對地形進(jìn)行剪切。當(dāng)設(shè)置為零時(shí),始終應(yīng)用深度測試。當(dāng)設(shè)置為數(shù)字正無窮大時(shí),深度測試永遠(yuǎn)不會應(yīng)用。
distanceDisplayCondition : DistanceDisplayCondition
獲取或設(shè)置條件,該條件指定此標(biāo)簽將顯示在距相機(jī)的距離處。
-
Default Value:
undefined
eyeOffset : Cartesian3
獲取和設(shè)置在眼坐標(biāo)中應(yīng)用于此標(biāo)簽的三維笛卡爾偏移量。眼睛坐標(biāo)系是左手坐標(biāo)系,其中
眼睛偏移通常用于在同一位置排列多個(gè)標(biāo)簽或?qū)ο螅纾谄鋵?yīng)的3D模型上方排列標(biāo)簽。
下面,標(biāo)簽位于地球中心,但眼睛偏移使其始終出現(xiàn)在地球頂部,無論觀眾或地球的方向如何。
x
指向觀看者的右側(cè),y
指向上方,z
指向屏幕。眼睛坐標(biāo)使用與世界和模型坐標(biāo)相同的比例,通常是米。眼睛偏移通常用于在同一位置排列多個(gè)標(biāo)簽或?qū)ο螅纾谄鋵?yīng)的3D模型上方排列標(biāo)簽。
下面,標(biāo)簽位于地球中心,但眼睛偏移使其始終出現(xiàn)在地球頂部,無論觀眾或地球的方向如何。
![]() | ![]() |
l.eyeOffset = new Cartesian3(0.0, 8000000.0, 0.0);
-
Default Value:
Cartesian3.ZERO
fillColor : Color
獲取或設(shè)置此標(biāo)簽的填充顏色。
-
Default Value:
Color.WHITE
See:
font : String
獲取或設(shè)置用于繪制此標(biāo)簽的字體。使用與CSS“字體”屬性相同的語法指定字體。
-
Default Value:
'30px sans-serif'
See:
heightReference : HeightReference
獲取或設(shè)置此公告牌的高度引用。
-
Default Value:
HeightReference.NONE
horizontalOrigin : HorizontalOrigin
獲取或設(shè)置此標(biāo)簽的水平原點(diǎn),該原點(diǎn)確定標(biāo)簽是繪制到其定位點(diǎn)位置的左側(cè)、中心還是右側(cè)。


-
Default Value:
HorizontalOrigin.LEFT
Example:
// Use a top, right origin
l.horizontalOrigin = bmgl.HorizontalOrigin.RIGHT;
l.verticalOrigin = bmgl.VerticalOrigin.TOP;
id : *
獲取或設(shè)置拾取標(biāo)簽時(shí)返回的用戶定義值。
outlineColor : Color
獲取或設(shè)置此標(biāo)簽的大綱顏色。
-
Default Value:
Color.BLACK
See:
outlineWidth : Number
獲取或設(shè)置此標(biāo)簽的輪廓寬度。
-
Default Value:
1.0
See:
pixelOffset : Cartesian2
獲取或設(shè)置屏幕空間中距此標(biāo)簽原點(diǎn)的像素偏移量。這通常用于在同一位置對齊多個(gè)標(biāo)簽和廣告牌,例如圖像和文本。屏幕空間原點(diǎn)是畫布的左上角;
標(biāo)簽的原點(diǎn)用黃色點(diǎn)表示。
x
從左到右增加,y
從上到下增加。default ![]() | l.pixeloffset = new Cartesian2(25, 75); ![]() |
-
Default Value:
Cartesian2.ZERO
pixelOffsetScaleByDistance : NearFarScalar
獲取或設(shè)置基于標(biāo)簽與相機(jī)的距離的標(biāo)簽的近像素和遠(yuǎn)像素偏移縮放屬性。標(biāo)簽的像素偏移量將在
NearFarScalar#nearValue
和NearFarScalar#farValue
之間縮放,而相機(jī)距離在指定NearFarScalar#near
和NearFarScalar#far
的上下限內(nèi)。在這些范圍之外,標(biāo)簽的像素偏移比例保持固定到最近的界限。如果未定義,將禁用PixeLoffSetscaleByDistance。
Examples:
// Example 1.
// Set a label's pixel offset scale to 0.0 when the
// camera is 1500 meters from the label and scale pixel offset to 10.0 pixels
// in the y direction the camera distance approaches 8.0e6 meters.
text.pixelOffset = new bmgl.Cartesian2(0.0, 1.0);
text.pixelOffsetScaleByDistance = new bmgl.NearFarScalar(1.5e2, 0.0, 8.0e6, 10.0);
// Example 2.
// disable pixel offset by distance
text.pixelOffsetScaleByDistance = undefined;
position : Cartesian3
獲取或設(shè)置此標(biāo)簽的笛卡爾位置。
scale : Number
獲取或設(shè)置與標(biāo)簽大?。ㄒ韵袼貫閱挝唬┫喑说慕y(tǒng)一比例。 比例尺為
應(yīng)用較大的值可能會使標(biāo)簽像素化。 要使文本變大而沒有像素化,請?jiān)谡{(diào)用
在上圖中從左到右,比例為
1.0
不會更改標(biāo)簽的大小; 大于1.0
的比例會放大標(biāo)簽; 小于1.0
的正比例會縮小標(biāo)簽。 應(yīng)用較大的值可能會使標(biāo)簽像素化。 要使文本變大而沒有像素化,請?jiān)谡{(diào)用
Label#font
時(shí)使用更大的字體。 
在上圖中從左到右,比例為
0.5
,1.0
和2.0
。 -
Default Value:
1.0
scaleByDistance : NearFarScalar
根據(jù)標(biāo)簽與相機(jī)的距離獲取或設(shè)置標(biāo)簽的近縮放和遠(yuǎn)縮放屬性。標(biāo)簽的比例將在
NearFarScalar#nearValue
和NearFarScalar#farValue
之間插入,而相機(jī)距離在指定NearFarScalar#near
和NearFarScalar#far
的上下限內(nèi)。在這些范圍之外,標(biāo)簽的刻度將保持在最近的范圍內(nèi)。如果未定義,將禁用scaleByDistance。
Examples:
// Example 1.
// Set a label's scaleByDistance to scale by 1.5 when the
// camera is 1500 meters from the label and disappear as
// the camera distance approaches 8.0e6 meters.
label.scaleByDistance = new bmgl.NearFarScalar(1.5e2, 1.5, 8.0e6, 0.0);
// Example 2.
// disable scaling by distance
label.scaleByDistance = undefined;
show : Boolean
確定是否顯示此標(biāo)簽。使用此選項(xiàng)可隱藏或顯示標(biāo)簽,而不是將其刪除并重新添加到集合中。
-
Default Value:
true
showBackground : Boolean
確定是否顯示此標(biāo)簽后面的背景。
-
Default Value:
false
style : LabelStyle
獲取或設(shè)置此標(biāo)簽的樣式。
-
Default Value:
LabelStyle.FILL
text : String
獲取或設(shè)置此標(biāo)簽的文本。
totalScale : Number
獲取標(biāo)簽的總比例,該比例是標(biāo)簽的比例乘以所需字體的計(jì)算相對大?。ㄅc生成的glyph大小相比)。
-
Default Value:
1.0
translucencyByDistance : NearFarScalar
根據(jù)標(biāo)簽與相機(jī)的距離獲取或設(shè)置標(biāo)簽的近半透明屬性和遠(yuǎn)半透明屬性。標(biāo)簽的半透明將插入
NearFarScalar#nearValue
和NearFarScalar#farValue
之間,而相機(jī)距離在指定NearFarScalar#near
和NearFarScalar#far
的上下限內(nèi)。在這些范圍之外,標(biāo)簽的半透明性保持固定到最近的邊界。如果未定義,半透明Y距離將被禁用。
Examples:
// Example 1.
// Set a label's translucencyByDistance to 1.0 when the
// camera is 1500 meters from the label and disappear as
// the camera distance approaches 8.0e6 meters.
text.translucencyByDistance = new bmgl.NearFarScalar(1.5e2, 1.0, 8.0e6, 0.0);
// Example 2.
// disable translucency by distance
text.translucencyByDistance = undefined;
verticalOrigin : VerticalOrigin
獲取或設(shè)置此標(biāo)簽的垂直原點(diǎn),該原點(diǎn)確定標(biāo)簽是位于其定位點(diǎn)位置的上方、下方還是中心。


-
Default Value:
VerticalOrigin.BASELINE
Example:
// Use a top, right origin
l.horizontalOrigin = bmgl.HorizontalOrigin.RIGHT;
l.verticalOrigin = bmgl.VerticalOrigin.TOP;
Methods
computeScreenSpacePosition(scene, result) → {Cartesian2}
計(jì)算標(biāo)簽原點(diǎn)的屏幕空間位置,同時(shí)考慮眼睛和像素偏移。屏幕空間原點(diǎn)是畫布的左上角;
x
從左到右增加,y
從上到下增加。
Parameters:
確定此標(biāo)簽是否等于另一個(gè)標(biāo)簽。如果標(biāo)簽的所有屬性都相同,則標(biāo)簽是相等的。不同集合中的標(biāo)簽可以相等。
Parameters:
如果此對象被破壞,則返回true;否則返回false。
如果此對象被破壞,則不應(yīng)使用它;調(diào)用除
如果此對象被破壞,則不應(yīng)使用它;調(diào)用除
isDestroyed
以外的任何函數(shù)將導(dǎo)致DeveloperError
異常。