XRAnchor: delete() 方法

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

实验性: 这是一项实验性技术
在生产中使用此技术之前,请仔细检查浏览器兼容性表格

安全上下文: 此功能仅在安全上下文(HTTPS)中可用,且支持此功能的浏览器数量有限。

XRAnchor 接口的 delete() 方法会移除一个锚点。当应用程序不再需要接收锚点的更新时,这会非常有用。

语法

js
delete()

参数

无。

返回值

无(undefined)。

示例

移除所有锚点

js
let anchorsCollection = new Set();

// Upon creating anchors, add them to the Set
// anchorsCollection.add(anchor);

for (const anchor of anchorsCollection) {
  anchor.delete();
}

anchorsCollection.clear();

规范

规范
WebXR Anchors 模块
# dom-xranchor-delete

浏览器兼容性