MCPcopy Create free account
hub / github.com/melonjs/melonJS / apply

Method apply

packages/melonjs/src/math/matrix3d.ts:502–518  ·  view source on GitHub ↗

* apply the current transform to the given 2d or 3d vector or point * @param v - the vector object to be transformed * @returns result vector object.

(v: Vector3d | Vector2d | Point)

Source from the content-addressed store, hash-verified

500 * @returns result vector object.
501 */
502 apply(v: Vector3d | Vector2d | Point) {
503 const a = this.val;
504 const x = v.x;
505 const y = v.y;
506 const z = "z" in v ? v.z : 1;
507
508 const w = a[3] * x + a[7] * y + a[11] * z + a[15] || 1.0;
509
510 v.x = (a[0] * x + a[4] * y + a[8] * z + a[12]) / w;
511 v.y = (a[1] * x + a[5] * y + a[9] * z + a[13]) / w;
512
513 if ("z" in v) {
514 v.z = (a[2] * x + a[6] * y + a[10] * z + a[14]) / w;
515 }
516
517 return v;
518 }
519
520 /**
521 * apply the inverted current transform to the given 2d or 3d vector

Callers 15

updateMethod · 0.45
patchFunction · 0.45
throttleFunction · 0.45
worldToScreenMethod · 0.45
localToWorldMethod · 0.45
worldToLocalMethod · 0.45
addPointMethod · 0.45
emitMethod · 0.45
pullMethod · 0.45
destroyMethod · 0.45
destroyMethod · 0.45
transformMethod · 0.45

Calls

no outgoing calls

Tested by 4

expectEquivalentFunction · 0.36
transformCornersFunction · 0.36
renderedVerticesFunction · 0.36
firstVertexWithFlagFunction · 0.36