Files
nothoughts/node_modules/pixi.js/lib/scene/mesh-perspective/PerspectivePlaneGeometry.mjs.map
2025-08-04 18:57:35 +02:00

1 line
5.7 KiB
Plaintext

{"version":3,"file":"PerspectivePlaneGeometry.mjs","sources":["../../../src/scene/mesh-perspective/PerspectivePlaneGeometry.ts"],"sourcesContent":["import { PlaneGeometry } from '../mesh-plane/PlaneGeometry';\nimport { applyProjectiveTransformationToPlane } from './utils/applyProjectiveTransformationToPlane';\nimport { compute2DProjection } from './utils/compute2DProjections';\n\nimport type { ArrayFixed } from '../../utils/types';\nimport type { PlaneGeometryOptions } from '../mesh-plane/PlaneGeometry';\n\n/**\n * Constructor options used for `PerspectivePlaneGeometry` instances.\n * @memberof scene\n */\nexport interface PerspectivePlaneGeometryOptions extends PlaneGeometryOptions\n{\n /** The width of the plane */\n width: number;\n /** The height of the plane */\n height: number;\n}\n\n/**\n * A PerspectivePlaneGeometry allows you to draw a 2d plane with perspective. Where ever you move the corners\n * the texture will be projected to look like it is in 3d space. Great for mapping a 2D mesh into a 3D scene.\n *\n * IMPORTANT: This is not a full 3D mesh, it is a 2D mesh with a perspective projection applied to it :)\n *\n * ```js\n * const perspectivePlaneGeometry = new PerspectivePlaneGeometry({\n * width: 100,\n * height: 100,\n * verticesX: 10,\n * verticesY: 10,\n * });\n * ```\n * @see {@link scene.PerspectivePlaneGeometry}\n * @memberof scene\n */\nexport class PerspectivePlaneGeometry extends PlaneGeometry\n{\n /** The corner points of the quad you can modify these directly, if you do make sure to call `updateProjection` */\n public corners: [number, number, number, number, number, number, number, number];\n private readonly _projectionMatrix: ArrayFixed<number, 9> = [0, 0, 0, 0, 0, 0, 0, 0, 0];\n\n /**\n * @param options - Options to be applied to MeshPlane\n * @param options.width - The width of the plane\n * @param options.height - The height of the plane\n * @param options.verticesX - The amount of vertices on the x axis\n * @param options.verticesY - The amount of vertices on the y axis\n */\n constructor(options: PerspectivePlaneGeometryOptions)\n {\n super(options);\n\n const { width, height } = options;\n\n this.corners = [0, 0, width, 0, width, height, 0, height];\n }\n\n /**\n * Will set the corners of the quad to the given coordinates\n * Calculating the perspective so it looks correct!\n * @param x0 - x coordinate of the first corner\n * @param y0 - y coordinate of the first corner\n * @param x1 - x coordinate of the second corner\n * @param y1 - y coordinate of the second corner\n * @param x2 - x coordinate of the third corner\n * @param y2 - y coordinate of the third corner\n * @param x3 - x coordinate of the fourth corner\n * @param y3 - y coordinate of the fourth corner\n */\n public setCorners(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number)\n {\n const corners = this.corners;\n\n corners[0] = x0;\n corners[1] = y0;\n corners[2] = x1;\n corners[3] = y1;\n corners[4] = x2;\n corners[5] = y2;\n corners[6] = x3;\n corners[7] = y3;\n\n this.updateProjection();\n }\n\n /** Update the projection matrix based on the corners */\n public updateProjection()\n {\n const { width, height } = this;\n const corners = this.corners;\n\n const projectionMatrix = compute2DProjection(\n this._projectionMatrix,\n 0, 0, // top-left source\n corners[0], corners[1], // top-left dest\n width, 0, // top-right source\n corners[2], corners[3], // top-right dest\n width, height, // bottom-right source\n corners[4], corners[5], // bottom-right dest\n 0, height, // bottom-left source\n corners[6], corners[7] // bottom-left dest\n );\n\n applyProjectiveTransformationToPlane(\n width,\n height,\n this,\n projectionMatrix\n );\n }\n}\n\n"],"names":[],"mappings":";;;;;AAoCO,MAAM,iCAAiC,aAC9C,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,YAAY,OACZ,EAAA;AACI,IAAA,KAAA,CAAM,OAAO,CAAA,CAAA;AAXjB,IAAiB,IAAA,CAAA,iBAAA,GAA2C,CAAC,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,GAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,CAAC,CAAA,CAAA;AAalF,IAAM,MAAA,EAAE,KAAO,EAAA,MAAA,EAAW,GAAA,OAAA,CAAA;AAE1B,IAAK,IAAA,CAAA,OAAA,GAAU,CAAC,CAAG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