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
is based on 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
or a DOMPointInit
dictionary to create a new point by calling the DOMPoint.fromPoint()
static method.DOMPoint
inherits methods from its parent, DOMPointReadOnly
.
fromPoint()
DOMPoint
object given an existing point or a DOMPointInit
dictionary which provides the values for its properties.DOMPoint
inherits properties from its parent, DOMPointReadOnly
.
DOMPoint.x
DOMPoint
.DOMPoint.y
DOMPoint
.DOMPoint.z
DOMPoint
.DOMPoint.w
DOMPoint
.In the WebVR API, DOMPoint
values are used to represent points in the coordinate space that the user's head mounted display exists in. In the following snippet, the position of the VR HMD can be retrieved by first grabbing a reference to the position sensor's current state using PositionSensorVRDevice.getState()
, then accessing the resulting VRPositionState
's position
property, which returns a DOMPoint
. Note below the usage of position.x
, position.y
, and position.z
.
function setView() { var posState = gPositionSensor.getState(); if (posState.hasPosition) { posPara.textContent = 'Position: x' + roundToTwo(posState.position.x) + " y" + roundToTwo(posState.position.y) + " z" + roundToTwo(posState.position.z); xPos = -posState.position.x * WIDTH * 2; yPos = posState.position.y * HEIGHT * 2; if (-posState.position.z > 0.01) { zPos = -posState.position.z; } else { zPos = 0.01; } } /* ... */ }
Note: See our positionsensorvrdevice demo for the full code.
Specification | Status | Comment |
---|---|---|
Geometry Interfaces Module Level 1 The definition of 'DOMPoint' in that specification. | Candidate Recommendation | Latest spec version is an ED. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 61 | No | 31 | No | 48 | No |
DOMPoint() constructor
|
61 | No | 31 | No | 48 | No |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 58 | 61 | No | 31 | 48 | No | ? |
DOMPoint() constructor
|
58 | 61 | No | 31 | 48 | No | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DOMPoint