A
DOMPoint
object represents a 2D or 3D point in a coordinate system; it includes values for the coordinates in up to three dimensions, as well as an optional perspective value.
DOMPoint
基于
DOMPointReadOnly
but allows its properties' values to be changed.
In general, a positive
x
component represents a position to the right of the origin, a positive
y
component is downward from the origin, and a positive
z
component extends outward from the screen (in other words, toward the user).
DOMPoint()
DOMPoint
object given the values of zero or more of its coordinate components and optionally the
w
perspective value. You can also use an existing
DOMPoint
or
DOMPointReadOnly
或
DOMPointInit
dictionary to create a new point by calling the
DOMPoint.fromPoint()
静态方法。
DOMPoint
继承来自其父级的方法,
DOMPointReadOnly
.
DOMPoint.fromPoint()
DOMPoint
object given an existing point (or a
DOMPointInit
dictionary) which provides the values for its properties.
DOMPoint
继承的特性来自其父级,
DOMPointReadOnly
.
DOMPoint.x
x
coordinate of the
DOMPoint
.
DOMPoint.y
y
coordinate of the
DOMPoint
.
DOMPoint.z
z
coordinate of the
DOMPoint
.
DOMPoint.w
DOMPoint
.
在
WebXR Device API
,
DOMPointReadOnly
values are used to represent positions and orientations. In the following snippet, the pose of the XR device (such as a VR headset or phone with AR capabilities) can be retrieved by calling using
XRFrame.getViewerPose()
during an
XRSession
animation frame, then accessing the resulting
XRPose
's
transform
property, which contains two
DOMPointReadOnly
attributes:
位置
as a vector and
orientation
as a quaternion.
function onXRFrame(time, xrFrame) {
let viewerPose = xrFrame.getViewerPose(xrReferenceSpace);
if (viewerPose) {
let position = viewerPose.transform.position;
let orientation = viewerPose.transform.orientation;
console.log('XR Viewer Position: {x: ' + roundToTwo(position.x)
+ ', y: ' + roundToTwo(position.y)
+ ', z: ' + roundToTwo(position.z));
console.log('XR Viewer Orientation: {x: ' + roundToTwo(orientation.x)
+ ', y: ' + roundToTwo(orientation.y)
+ ', z: ' + roundToTwo(orientation.z)
+ ', w: ' + roundToTwo(orientation.w));
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Geometry Interfaces Module Level 1
The definition of 'DOMPoint' in that specification. |
候选推荐 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
DOMPoint
|
Chrome 61 | Edge 79 | Firefox 31 | IE No | Opera 48 | Safari 10.1 | WebView Android 61 | Chrome Android 61 | Firefox Android 31 | Opera Android 45 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
DOMPoint()
构造函数
|
Chrome 61 | Edge 79 | Firefox 31 | IE No | Opera 48 | Safari 10.1 | WebView Android 61 | Chrome Android 61 | Firefox Android 31 | Opera Android 45 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
| Available in workers | Chrome 61 | Edge 79 | Firefox 69 | IE No | Opera 48 | Safari 10.1 | WebView Android 61 | Chrome Android 61 | Firefox Android No | Opera Android 45 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
完整支持
不支持
实验。期望将来行为有所改变。
DOMPoint
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument