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

DOMMatrix: scale3dSelf() method

· 52CE 我爱测

The **`scale3dSelf()`** method of the DOMMatrix interface is a mutable transformation method that modifies a matrix by applying a specified scaling factor to all three axes, centered on the given origin, with a default origin of `(0, 0, 0)`, returning the 3D-scaled matrix.

Geometry Interfaces

The scale3dSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix by applying a specified scaling factor to all three axes, centered on the given origin, with a default origin of (0, 0, 0), returning the 3D-scaled matrix.

To 3D-scale a matrix without mutating it, see DOMMatrixReadOnly.scale3d(), which creates a new scaled matrix while leaving the original unchanged.

Syntax

scale3dSelf()
scale3dSelf(scale)
scale3dSelf(scale, originX)
scale3dSelf(scale, originX, originY)
scale3dSelf(scale, originX, originY, originZ)

Parameters

  • scale
    • : A multiplier; the scale value. If no scale is supplied, this defaults to 1. If scale is not 1, the DOMMatrixReadOnly.is2D property of the current matrix is set to false.
  • 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 no origin is supplied, this defaults to 0.

Return value

Returns itself; a DOMMatrix.

Examples

const matrix = new DOMMatrix();
console.log(matrix.scale3dSelf(2).toString());
/* matrix3d(
    2, 0, 0, 0, 
    0, 2, 0, 0, 
    0, 0, 2, 0, 
    0, 0, 0, 1) */
console.log(matrix.scale3dSelf(3.1, 25, 25, 1.25).toString());
/* matrix3d(
    6.2, 0, 0, 0,
    0, 6.2, 0, 0, 
    0, 0, 6.2, 0, 
    -105, -105, -5.25, 1) */
console.log(matrix.toString());
/* matrix3d(
    6.2, 0, 0, 0, 
    0, 6.2, 0, 0, 
    0, 0, 6.2, 0, 
    -105, -105, -5.25, 1) (same as above) */

Specifications

Browser compatibility

See also

  • DOMMatrixReadOnly.scale3d()
  • DOMMatrix.scaleSelf()
  • CSS transform property and the transform-function/scale3d and transform-function/matrix3d functions
  • CSS transforms module
  • SVG transform attribute
  • CanvasRenderingContext2D interface CanvasRenderingContext2D.transform() method

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

资料来源与适用范围

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

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

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