大网数据广告活动
Web 标准与前端开发

DOMMatrixReadOnly: scale3d() method

· 52CE 我爱测

The **`scale3d()`** method of the DOMMatrixReadOnly interface creates a new matrix which is the result of a 3D scale transform being applied to the matrix. It returns a new DOMMatrix created by scaling the source 3d matrix by the given scale factor centered on the origin point sp

Geometry Interfaces

The scale3d() method of the DOMMatrixReadOnly interface creates a new matrix which is the result of a 3D scale transform being applied to the matrix. It returns a new DOMMatrix created by scaling the source 3d matrix by the given scale factor centered on the origin point specified by the origin parameters, with a default origin of (0, 0, 0). The original matrix is not modified.

To mutate the matrix as you 3D-scale it, see DOMMatrix.scale3dSelf()

Syntax

scale3d()
scale3d(scale)
scale3d(scale, originX)
scale3d(scale, originX, originY)
scale3d(scale, originX, originY, originZ)

Parameters

  • scale
    • : A multiplier; the scale value. If no scale is supplied, this defaults to 1.
  • originX
    • : An x-coordinate for the origin of the transformation. If no origin is supplied, this defaults to 0.
  • originY
    • : A y-coordinate for the origin of the transformation. If no origin is supplied, this defaults to 0.
  • originZ
    • : A z-coordinate for the origin of the transformation. If this value is 0, the default if omitted, the resulting matrix may not be 3d.

Return value

A DOMMatrix.

Examples

const matrix = new DOMMatrix();
console.log(matrix.toString()); // no transforms applied
// matrix(1, 0, 0, 1, 0, 0)

console.log(matrix.scale3d(2).toString());
/* matrix3d(
    2, 0, 0, 0, 
    0, 2, 0, 0, 
    0, 0, 2, 0, 
    0, 0, 0, 1) */
console.log(matrix.scale3d(0.5, 25, 25, 1.25).toString());
/* matrix3d(
    0.5, 0, 0, 0, 
    0, 0.5, 0, 0, 
    0, 0, 0.5, 0, 1
    2.5, 12.5, 0.625, 1) */
console.log(matrix.toString()); // original matrix is unchanged
// matrix(1, 0, 0, 1, 0, 0)

Specifications

Browser compatibility

See also

  • DOMMatrix.scale3dSelf()
  • DOMMatrixReadOnly.scale()
  • CSS transform property and transform-function/scale3d and transform-function/matrix3d functions
  • CSS transforms module
  • SVG transform attribute
  • CanvasRenderingContext2D interface's CanvasRenderingContext2D.transform() method

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。