MCPcopy
hub / github.com/AlloyTeam/PhyTouch / appendTransform

Method appendTransform

transformjs/react/transform.react.js:93–142  ·  view source on GitHub ↗
(x, y, z, scaleX, scaleY, scaleZ, rotateX, rotateY, rotateZ, skewX, skewY, originX, originY, originZ)

Source from the content-addressed store, hash-verified

91 }
92
93 appendTransform(x, y, z, scaleX, scaleY, scaleZ, rotateX, rotateY, rotateZ, skewX, skewY, originX, originY, originZ) {
94
95 var rx = rotateX * Matrix3D.DEG_TO_RAD;
96 var cosx = this._rounded(Math.cos(rx));
97 var sinx = this._rounded(Math.sin(rx));
98 var ry = rotateY * Matrix3D.DEG_TO_RAD;
99 var cosy = this._rounded(Math.cos(ry));
100 var siny = this._rounded(Math.sin(ry));
101 var rz = rotateZ * Matrix3D.DEG_TO_RAD;
102 var cosz = this._rounded(Math.cos(rz * -1));
103 var sinz = this._rounded(Math.sin(rz * -1));
104
105 this.multiplyMatrices(this, this._arrayWrap([
106 1, 0, 0, x,
107 0, cosx, sinx, y,
108 0, -sinx, cosx, z,
109 0, 0, 0, 1
110 ]));
111
112 this.multiplyMatrices(this, this._arrayWrap([
113 cosy, 0, siny, 0,
114 0, 1, 0, 0,
115 -siny, 0, cosy, 0,
116 0, 0, 0, 1
117 ]));
118
119 this.multiplyMatrices(this, this._arrayWrap([
120 cosz * scaleX, sinz * scaleY, 0, 0,
121 -sinz * scaleX, cosz * scaleY, 0, 0,
122 0, 0, 1 * scaleZ, 0,
123 0, 0, 0, 1
124 ]));
125
126 if (skewX || skewY) {
127 this.multiplyMatrices(this, this._arrayWrap([
128 this._rounded(Math.cos(skewX * Matrix3D.DEG_TO_RAD)), this._rounded(Math.sin(skewX * Matrix3D.DEG_TO_RAD)), 0, 0,
129 -1 * this._rounded(Math.sin(skewY * Matrix3D.DEG_TO_RAD)), this._rounded(Math.cos(skewY * Matrix3D.DEG_TO_RAD)), 0, 0,
130 0, 0, 1, 0,
131 0, 0, 0, 1
132 ]));
133 }
134
135
136 if (originX || originY || originZ) {
137 this.elements[12] -= originX * this.elements[0] + originY * this.elements[4] + originZ * this.elements[8];
138 this.elements[13] -= originX * this.elements[1] + originY * this.elements[5] + originZ * this.elements[9];
139 this.elements[14] -= originX * this.elements[2] + originY * this.elements[6] + originZ * this.elements[10];
140 }
141 return this;
142 }
143}
144
145var attrArr = ['translateX', 'translateY', 'translateZ', 'scaleX', 'scaleY', 'scaleZ', 'rotateX', 'rotateY', 'rotateZ', 'skewX', 'skewY', 'originX', 'originY', 'originZ'];

Callers 4

TransformFunction · 0.80
transform.jsFile · 0.80
TransformFunction · 0.80
transform.jsFile · 0.80

Calls 3

_roundedMethod · 0.95
multiplyMatricesMethod · 0.95
_arrayWrapMethod · 0.95

Tested by

no test coverage detected