From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/dompoint/dompoint/index.html | 68 +++++++++++++++ files/zh-cn/web/api/dompoint/index.html | 100 +++++++++++++++++++++++ files/zh-cn/web/api/dompoint/w/index.html | 45 ++++++++++ files/zh-cn/web/api/dompoint/x/index.html | 45 ++++++++++ files/zh-cn/web/api/dompoint/y/index.html | 45 ++++++++++ files/zh-cn/web/api/dompoint/z/index.html | 45 ++++++++++ 6 files changed, 348 insertions(+) create mode 100644 files/zh-cn/web/api/dompoint/dompoint/index.html create mode 100644 files/zh-cn/web/api/dompoint/index.html create mode 100644 files/zh-cn/web/api/dompoint/w/index.html create mode 100644 files/zh-cn/web/api/dompoint/x/index.html create mode 100644 files/zh-cn/web/api/dompoint/y/index.html create mode 100644 files/zh-cn/web/api/dompoint/z/index.html (limited to 'files/zh-cn/web/api/dompoint') diff --git a/files/zh-cn/web/api/dompoint/dompoint/index.html b/files/zh-cn/web/api/dompoint/dompoint/index.html new file mode 100644 index 0000000000..2688405313 --- /dev/null +++ b/files/zh-cn/web/api/dompoint/dompoint/index.html @@ -0,0 +1,68 @@ +--- +title: DOMPoint.DOMPoint() +slug: Web/API/DOMPoint/DOMPoint +translation_of: Web/API/DOMPoint/DOMPoint +--- +
{{APIRef("DOM")}}
+ +

DOMPoint()构造函数创建并返回一个 {{domxref("DOMPoint")}} 对象,可提供部分或全部属性值作为其参数。

+ +

也可以通过调用静态方法 {{domxref("DOMPoint.fromPoint()")}} 来创建 DOMPoint 。此方法接受一个 {{domxref("DOMPointInit")}} 兼容对象(DOMPoint 或 {{domxref("DOMPointReadOnly")}})作为参数 。

+ +

语法

+ +
point = new DOMPoint(x, y, z, w);
+ +

参数

+ +
+
x {{optional_inline}}
+
x 坐标。
+
y {{optional_inline}}
+
y 坐标。
+
z {{optional_inline}}
+
z 坐标。
+
w {{optional_inline}}
+
透视值。
+
+ +

示例

+ +

示例首先创建了一个表示当前窗口左上角的 DOMPoint ,接着根据第一个点创建一个新的 DOMPoint 并将其在垂直和水平方向上偏移100px。

+ +
var windTopLeft = new DOMPoint(window.screenX, window.screenY);
+var newTopLeft = DOMPoint.fromPoint(windTopLeft);
+newTopLeft.x += 100;
+newTopLeft.y += 100;
+
+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geometry Interfaces', '#dom-dompoint-dompoint', 'DOMPoint()')}}{{Spec2('Geometry Interfaces')}}Initial definition
+ +

浏览器兼容性

+ + + +

{{Compat("api.DOMPoint.DOMPoint")}}

+ +

相关链接

+ + diff --git a/files/zh-cn/web/api/dompoint/index.html b/files/zh-cn/web/api/dompoint/index.html new file mode 100644 index 0000000000..293859c636 --- /dev/null +++ b/files/zh-cn/web/api/dompoint/index.html @@ -0,0 +1,100 @@ +--- +title: DOMPoint +slug: Web/API/DOMPoint +translation_of: Web/API/DOMPoint +--- +
{{APIRef("DOM")}}
+ +

DOMPoint 对象表示坐标系中的2D 或3D 点;它包括三维度的坐标值以及可选的透视值。DOMPoint 基于 DOMPointReadOnly, 但允许更改其属性值。

+ +

通常, 正 x 分量表示原点右侧的位置, 正 y 分量从原点向下, 正 z 分量从屏幕向外延伸 (换言之, 朝向用户)。

+ +

Constructor

+ +
+
{{domxref("DOMPoint.DOMPoint","DOMPoint()")}}
+
Creates and returns a new 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 {{domxref("DOMPointInit")}} dictionary to create a new point by calling the {{domxref("DOMPoint.fromPoint()")}} static method.
+
+ +

Methods

+ +

DOMPoint inherits methods from its parent, {{domxref("DOMPointReadOnly")}}.

+ +
+
{{domxref("DOMPointReadOnly.fromPoint", "fromPoint()")}}
+
Creates a new mutable DOMPoint object given an existing point or a {{domxref("DOMPointInit")}} dictionary which provides the values for its properties.
+
+ +

Properties

+ +

DOMPoint inherits properties from its parent, {{domxref("DOMPointReadOnly")}}.

+ +
+
{{domxref("DOMPointReadOnly.x", "DOMPoint.x")}}
+
The x coordinate of the DOMPoint.
+
{{domxref("DOMPointReadOnly.y", "DOMPoint.y")}}
+
The y coordinate of the DOMPoint.
+
{{domxref("DOMPointReadOnly.z", "DOMPoint.z")}}
+
The z coordinate of the DOMPoint.
+
{{domxref("DOMPointReadOnly.w", "DOMPoint.w")}}
+
The perspective value of the DOMPoint.
+
+ +

Examples

+ +

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 {{domxref("PositionSensorVRDevice.getState()")}}, then accessing the resulting {{domxref("VRPositionState")}}'s {{domxref("VRPositionState.position","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.

+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geometry Interfaces', '#DOMPoint', 'DOMPoint')}}{{Spec2('Geometry Interfaces')}}Latest spec version is an ED.
+ +

Browser compatibility

+ + + +

{{Compat("api.DOMPoint")}}

+ +

See also

+ + diff --git a/files/zh-cn/web/api/dompoint/w/index.html b/files/zh-cn/web/api/dompoint/w/index.html new file mode 100644 index 0000000000..f52da8de19 --- /dev/null +++ b/files/zh-cn/web/api/dompoint/w/index.html @@ -0,0 +1,45 @@ +--- +title: DOMPoint.w +slug: Web/API/DOMPoint/w +translation_of: Web/API/DOMPoint/w +--- +
{{APIRef("DOM")}}
+ +

DOMPoint 的 w 属性表示该点的空间透视值。

+ +

语法

+ +
var perspective = DOMPoint.w;
+ +

+ +

双精度浮点值,表示该点的空间透视值。这个值的类型并没有严格限制,意味着它可以是 {{jsxref("NaN")}} 或 {{jsxref("Infinity", "±Infinity")}}。 默认值为 1.0。

+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geometry Interfaces', '#dom-dompoint-w', 'w')}}{{Spec2('Geometry Interfaces')}}Initial definition
+ +

浏览器兼容性

+ + + +

{{Compat("api.DOMPointReadOnly.w")}}

+ +

相关链接

+ + diff --git a/files/zh-cn/web/api/dompoint/x/index.html b/files/zh-cn/web/api/dompoint/x/index.html new file mode 100644 index 0000000000..d695b9d1a6 --- /dev/null +++ b/files/zh-cn/web/api/dompoint/x/index.html @@ -0,0 +1,45 @@ +--- +title: DOMPoint.x +slug: Web/API/DOMPoint/x +translation_of: Web/API/DOMPoint/x +--- +
{{APIRef("DOM")}}
+ +

DOMPoint 的 x 属性表示该点的水平坐标。 通常, x 的正值表示右边,负值表示左边,除非改变了默认的轴方向。

+ +

语法

+ +
var xPos = DOMPoint.x;
+ +

+ +

双精度浮点值,表示该点的 x 坐标值。这个值的类型并没有严格限制,意味着它可以是 {{jsxref("NaN")}} 或 {{jsxref("Infinity", "±Infinity")}}。

+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geometry Interfaces', '#dom-dompoint-x', 'x')}}{{Spec2('Geometry Interfaces')}}Initial definition
+ +

浏览器兼容性

+ + + +

{{Compat("api.DOMPointReadOnly.x")}}

+ +

相关链接

+ + diff --git a/files/zh-cn/web/api/dompoint/y/index.html b/files/zh-cn/web/api/dompoint/y/index.html new file mode 100644 index 0000000000..ea4baedabd --- /dev/null +++ b/files/zh-cn/web/api/dompoint/y/index.html @@ -0,0 +1,45 @@ +--- +title: DOMPoint.y +slug: Web/API/DOMPoint/y +translation_of: Web/API/DOMPoint/y +--- +
{{APIRef("DOM")}}
+ +

DOMPoint 的 y 属性表示该点的垂直坐标。y 值增加表示向下偏移,减小表示向上偏移,除非改变了默认轴方向。

+ +

语法

+ +
var yPos = DOMPoint.y;
+ +

+ +

双精度浮点值,表示该点的 y 坐标值。这个值的类型并没有严格限制,意味着它可以是 {{jsxref("NaN")}} 或 {{jsxref("Infinity", "±Infinity")}}。

+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geometry Interfaces', '#dom-dompoint-y', 'y')}}{{Spec2('Geometry Interfaces')}}Initial definition
+ +

浏览器兼容性

+ + + +

{{Compat("api.DOMPointReadOnly.y")}}

+ +

相关链接

+ + diff --git a/files/zh-cn/web/api/dompoint/z/index.html b/files/zh-cn/web/api/dompoint/z/index.html new file mode 100644 index 0000000000..e813e18954 --- /dev/null +++ b/files/zh-cn/web/api/dompoint/z/index.html @@ -0,0 +1,45 @@ +--- +title: DOMPoint.z +slug: Web/API/DOMPoint/z +translation_of: Web/API/DOMPoint/z +--- +
{{APIRef("DOM")}}
+ +

DOMPoint 的 z 属性表示该点的深度坐标。 z 值为 0 表示屏幕平面,正值表示从屏幕前面向靠近用户的方向延伸,负值表示从屏幕后面向远离用户的方向延伸,除非改变了默认的轴方向。

+ +

语法

+ +
var zPos = DOMPoint.z;
+ +

+ +

双精度浮点值,表示该点的 z 坐标值。这个值的类型并没有严格限制,意味着它可以是 {{jsxref("NaN")}} 或 {{jsxref("Infinity", "±Infinity")}}。

+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geometry Interfaces', '#dom-dompoint-z', 'z')}}{{Spec2('Geometry Interfaces')}}Initial definition
+ +

浏览器兼容性

+ + + +

{{Compat("api.DOMPointReadOnly.z")}}

+ +

相关链接

+ + -- cgit v1.2.3-54-g00ecf