Popup
大约 1 分钟
Popup
HTML内容提示控件,常用于点击提示或内容呈现。继承自BaseEvent。
构造
new VT.Popup({
// 偏移 [x, y]
offset: null,
// 类名
className: "",
// 是否显示底部小箭头
tip: true,
// 是否显示右上角的close按钮
closeButton: true,
// 位置,三维坐标 [x, y, z] | THREE.Vector3
position: null,
// HTMLElement
html: "",
lineWidth: 0,
lineColor: "rgba(25,25,25, 1)",
lineDash: [0, 0],
lineEndPosition: [0.5, 1.0], // 0, 0.5, 1
lineStartOffsetRatio: [1, 1],
linePointSize: 0,
linePointColor: "#00ffff",
avoid: false,
})
点击对象提示对象的名称属性:
// 点击对象,并提示对象的名称
var popup = null;
viewer.on("click", (e) => {
const {object, position} = e;
if(popup) {
popup.remove();
}
if(position && object) {
const content = object.name;
popup = new VT.Popup({
position: position,
html: content,
}).addTo(viewer).show();
}
})
属性成员
id
- 类型:
{String}
唯一ID
container
- 类型:
{HTMLElement}
DIV容器
visible
- 类型:
{Boolean}
是否显示
方法
setPosition
设置位置
- setPosition(position)
- 类型:
Function
- 参数:
- position
{Array|THREE.Vector3}
位置
- position
- 返回:
this
setHTML
设置内容
- setHTML(htmlContent)
- 类型:
Function
- 参数:
- htmlContent
{String|HTMLElement}
html字符串或HTMLElement对象
- htmlContent
- 返回:
this
show
显示
- show()
- 类型:
Function
- 参数:无
- 返回:
this
hidden
隐藏
- hidden()
- 类型:
Function
- 参数:无
- 返回:
this
remove
移除popup,信息提示控件
- remove()
- 类型:
Function
- 参数:无
- 返回:
this
addTo
添加到 Viewer
- addTo(viewer)
- 类型:
Function
- 参数:
- viewer
{Viewer}
Viewer
- viewer
- 返回:
this
update
更新
- update()
- 类型:
Function
- 参数:无
- 返回:
this