MCPcopy
hub / github.com/processing/p5.js / getWorldToScreenMatrix

Method getWorldToScreenMatrix

src/core/p5.Renderer3D.js:785–799  ·  view source on GitHub ↗

* Get a matrix from world-space to screen-space

()

Source from the content-addressed store, hash-verified

783 * Get a matrix from world-space to screen-space
784 */
785 getWorldToScreenMatrix() {
786 const modelMatrix = this.states.uModelMatrix;
787 const viewMatrix = this.states.uViewMatrix;
788 const projectionMatrix = this.states.uPMatrix;
789 const projectedToScreenMatrix = new Matrix(4);
790 projectedToScreenMatrix.scale(this.width, this.height, 1);
791 projectedToScreenMatrix.translate([0.5, 0.5, 0.5]);
792 projectedToScreenMatrix.scale(0.5, -0.5, 0.5);
793
794 const modelViewMatrix = modelMatrix.copy().mult(viewMatrix);
795 const modelViewProjectionMatrix = modelViewMatrix.mult(projectionMatrix);
796 const worldToScreenMatrix = modelViewProjectionMatrix
797 .mult(projectedToScreenMatrix);
798 return worldToScreenMatrix;
799 }
800
801 //////////////////////////////////////////////
802 // COLOR

Callers 1

environmentFunction · 0.45

Calls 4

scaleMethod · 0.95
translateMethod · 0.95
multMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected