This commit is contained in:
Akko
2025-08-04 18:57:35 +02:00
parent 8cf6e78a79
commit 9495868c2e
5030 changed files with 518594 additions and 17609 deletions

View File

@@ -0,0 +1,16 @@
import type { Matrix } from '../../../../../maths/matrix/Matrix';
/**
* Takes a vertices array and a matrix and transforms the vertices based on the matrix.
* this out put is written to the uvs array
* @param vertices - the vertices to calculate uvs from
* @param verticesStride - the stride of the vertice
* @param verticesOffset - the offset of the vertices
* @param uvs - the uvs to fill
* @param uvsOffset - the offset of the uvs
* @param uvsStride - the stride of the uvs
* @param size - the size of the vertices
* @param matrix - the matrix to apply to the uvs
* @memberof rendering
*/
export declare function buildUvs(vertices: number[], verticesStride: number, verticesOffset: number, uvs: number[], uvsOffset: number, uvsStride: number, size: number, matrix?: Matrix): void;
export declare function buildSimpleUvs(uvs: number[], uvsOffset: number, uvsStride: number, size: number): void;

View File

@@ -0,0 +1,37 @@
'use strict';
"use strict";
function buildUvs(vertices, verticesStride, verticesOffset, uvs, uvsOffset, uvsStride, size, matrix = null) {
let index = 0;
verticesOffset *= verticesStride;
uvsOffset *= uvsStride;
const a = matrix.a;
const b = matrix.b;
const c = matrix.c;
const d = matrix.d;
const tx = matrix.tx;
const ty = matrix.ty;
while (index < size) {
const x = vertices[verticesOffset];
const y = vertices[verticesOffset + 1];
uvs[uvsOffset] = a * x + c * y + tx;
uvs[uvsOffset + 1] = b * x + d * y + ty;
uvsOffset += uvsStride;
verticesOffset += verticesStride;
index++;
}
}
function buildSimpleUvs(uvs, uvsOffset, uvsStride, size) {
let index = 0;
uvsOffset *= uvsStride;
while (index < size) {
uvs[uvsOffset] = 0;
uvs[uvsOffset + 1] = 0;
uvsOffset += uvsStride;
index++;
}
}
exports.buildSimpleUvs = buildSimpleUvs;
exports.buildUvs = buildUvs;
//# sourceMappingURL=buildUvs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"buildUvs.js","sources":["../../../../../../src/rendering/renderers/shared/geometry/utils/buildUvs.ts"],"sourcesContent":["import type { Matrix } from '../../../../../maths/matrix/Matrix';\n\n/**\n * Takes a vertices array and a matrix and transforms the vertices based on the matrix.\n * this out put is written to the uvs array\n * @param vertices - the vertices to calculate uvs from\n * @param verticesStride - the stride of the vertice\n * @param verticesOffset - the offset of the vertices\n * @param uvs - the uvs to fill\n * @param uvsOffset - the offset of the uvs\n * @param uvsStride - the stride of the uvs\n * @param size - the size of the vertices\n * @param matrix - the matrix to apply to the uvs\n * @memberof rendering\n */\nexport function buildUvs(\n vertices: number[],\n verticesStride: number,\n verticesOffset: number,\n\n uvs: number[],\n uvsOffset: number,\n uvsStride: number,\n\n size: number,\n matrix: Matrix = null\n): void\n{\n let index = 0;\n\n verticesOffset *= verticesStride;\n uvsOffset *= uvsStride;\n\n const a = matrix.a;\n const b = matrix.b;\n const c = matrix.c;\n const d = matrix.d;\n const tx = matrix.tx;\n const ty = matrix.ty;\n\n while (index < size)\n {\n const x = vertices[verticesOffset];\n const y = vertices[verticesOffset + 1];\n\n uvs[uvsOffset] = (a * x) + (c * y) + tx;\n uvs[uvsOffset + 1] = (b * x) + (d * y) + ty;\n\n uvsOffset += uvsStride;\n\n verticesOffset += verticesStride;\n\n index++;\n }\n}\n\nexport function buildSimpleUvs(\n uvs: number[],\n uvsOffset: number,\n uvsStride: number,\n size: number,\n)\n{\n let index = 0;\n\n uvsOffset *= uvsStride;\n\n while (index < size)\n {\n uvs[uvsOffset] = 0;\n uvs[uvsOffset + 1] = 0;\n\n uvsOffset += uvsStride;\n\n index++;\n }\n}\n"],"names":[],"mappings":";;;AAegB,SAAA,QAAA,CACZ,UACA,cACA,EAAA,cAAA,EAEA,KACA,SACA,EAAA,SAAA,EAEA,IACA,EAAA,MAAA,GAAiB,IAErB,EAAA;AACI,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AAEZ,EAAkB,cAAA,IAAA,cAAA,CAAA;AAClB,EAAa,SAAA,IAAA,SAAA,CAAA;AAEb,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,KAAK,MAAO,CAAA,EAAA,CAAA;AAClB,EAAA,MAAM,KAAK,MAAO,CAAA,EAAA,CAAA;AAElB,EAAA,OAAO,QAAQ,IACf,EAAA;AACI,IAAM,MAAA,CAAA,GAAI,SAAS,cAAc,CAAA,CAAA;AACjC,IAAM,MAAA,CAAA,GAAI,QAAS,CAAA,cAAA,GAAiB,CAAC,CAAA,CAAA;AAErC,IAAA,GAAA,CAAI,SAAS,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AACrC,IAAA,GAAA,CAAI,YAAY,CAAC,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AAEzC,IAAa,SAAA,IAAA,SAAA,CAAA;AAEb,IAAkB,cAAA,IAAA,cAAA,CAAA;AAElB,IAAA,KAAA,EAAA,CAAA;AAAA,GACJ;AACJ,CAAA;AAEO,SAAS,cACZ,CAAA,GAAA,EACA,SACA,EAAA,SAAA,EACA,IAEJ,EAAA;AACI,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AAEZ,EAAa,SAAA,IAAA,SAAA,CAAA;AAEb,EAAA,OAAO,QAAQ,IACf,EAAA;AACI,IAAA,GAAA,CAAI,SAAS,CAAI,GAAA,CAAA,CAAA;AACjB,IAAI,GAAA,CAAA,SAAA,GAAY,CAAC,CAAI,GAAA,CAAA,CAAA;AAErB,IAAa,SAAA,IAAA,SAAA,CAAA;AAEb,IAAA,KAAA,EAAA,CAAA;AAAA,GACJ;AACJ;;;;;"}

View File

@@ -0,0 +1,34 @@
"use strict";
function buildUvs(vertices, verticesStride, verticesOffset, uvs, uvsOffset, uvsStride, size, matrix = null) {
let index = 0;
verticesOffset *= verticesStride;
uvsOffset *= uvsStride;
const a = matrix.a;
const b = matrix.b;
const c = matrix.c;
const d = matrix.d;
const tx = matrix.tx;
const ty = matrix.ty;
while (index < size) {
const x = vertices[verticesOffset];
const y = vertices[verticesOffset + 1];
uvs[uvsOffset] = a * x + c * y + tx;
uvs[uvsOffset + 1] = b * x + d * y + ty;
uvsOffset += uvsStride;
verticesOffset += verticesStride;
index++;
}
}
function buildSimpleUvs(uvs, uvsOffset, uvsStride, size) {
let index = 0;
uvsOffset *= uvsStride;
while (index < size) {
uvs[uvsOffset] = 0;
uvs[uvsOffset + 1] = 0;
uvsOffset += uvsStride;
index++;
}
}
export { buildSimpleUvs, buildUvs };
//# sourceMappingURL=buildUvs.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"buildUvs.mjs","sources":["../../../../../../src/rendering/renderers/shared/geometry/utils/buildUvs.ts"],"sourcesContent":["import type { Matrix } from '../../../../../maths/matrix/Matrix';\n\n/**\n * Takes a vertices array and a matrix and transforms the vertices based on the matrix.\n * this out put is written to the uvs array\n * @param vertices - the vertices to calculate uvs from\n * @param verticesStride - the stride of the vertice\n * @param verticesOffset - the offset of the vertices\n * @param uvs - the uvs to fill\n * @param uvsOffset - the offset of the uvs\n * @param uvsStride - the stride of the uvs\n * @param size - the size of the vertices\n * @param matrix - the matrix to apply to the uvs\n * @memberof rendering\n */\nexport function buildUvs(\n vertices: number[],\n verticesStride: number,\n verticesOffset: number,\n\n uvs: number[],\n uvsOffset: number,\n uvsStride: number,\n\n size: number,\n matrix: Matrix = null\n): void\n{\n let index = 0;\n\n verticesOffset *= verticesStride;\n uvsOffset *= uvsStride;\n\n const a = matrix.a;\n const b = matrix.b;\n const c = matrix.c;\n const d = matrix.d;\n const tx = matrix.tx;\n const ty = matrix.ty;\n\n while (index < size)\n {\n const x = vertices[verticesOffset];\n const y = vertices[verticesOffset + 1];\n\n uvs[uvsOffset] = (a * x) + (c * y) + tx;\n uvs[uvsOffset + 1] = (b * x) + (d * y) + ty;\n\n uvsOffset += uvsStride;\n\n verticesOffset += verticesStride;\n\n index++;\n }\n}\n\nexport function buildSimpleUvs(\n uvs: number[],\n uvsOffset: number,\n uvsStride: number,\n size: number,\n)\n{\n let index = 0;\n\n uvsOffset *= uvsStride;\n\n while (index < size)\n {\n uvs[uvsOffset] = 0;\n uvs[uvsOffset + 1] = 0;\n\n uvsOffset += uvsStride;\n\n index++;\n }\n}\n"],"names":[],"mappings":";AAegB,SAAA,QAAA,CACZ,UACA,cACA,EAAA,cAAA,EAEA,KACA,SACA,EAAA,SAAA,EAEA,IACA,EAAA,MAAA,GAAiB,IAErB,EAAA;AACI,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AAEZ,EAAkB,cAAA,IAAA,cAAA,CAAA;AAClB,EAAa,SAAA,IAAA,SAAA,CAAA;AAEb,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,IAAI,MAAO,CAAA,CAAA,CAAA;AACjB,EAAA,MAAM,KAAK,MAAO,CAAA,EAAA,CAAA;AAClB,EAAA,MAAM,KAAK,MAAO,CAAA,EAAA,CAAA;AAElB,EAAA,OAAO,QAAQ,IACf,EAAA;AACI,IAAM,MAAA,CAAA,GAAI,SAAS,cAAc,CAAA,CAAA;AACjC,IAAM,MAAA,CAAA,GAAI,QAAS,CAAA,cAAA,GAAiB,CAAC,CAAA,CAAA;AAErC,IAAA,GAAA,CAAI,SAAS,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AACrC,IAAA,GAAA,CAAI,YAAY,CAAC,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AAEzC,IAAa,SAAA,IAAA,SAAA,CAAA;AAEb,IAAkB,cAAA,IAAA,cAAA,CAAA;AAElB,IAAA,KAAA,EAAA,CAAA;AAAA,GACJ;AACJ,CAAA;AAEO,SAAS,cACZ,CAAA,GAAA,EACA,SACA,EAAA,SAAA,EACA,IAEJ,EAAA;AACI,EAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AAEZ,EAAa,SAAA,IAAA,SAAA,CAAA;AAEb,EAAA,OAAO,QAAQ,IACf,EAAA;AACI,IAAA,GAAA,CAAI,SAAS,CAAI,GAAA,CAAA,CAAA;AACjB,IAAI,GAAA,CAAA,SAAA,GAAY,CAAC,CAAI,GAAA,CAAA,CAAA;AAErB,IAAa,SAAA,IAAA,SAAA,CAAA;AAEb,IAAA,KAAA,EAAA,CAAA;AAAA,GACJ;AACJ;;;;"}

View File

@@ -0,0 +1,12 @@
import { Buffer } from '../../buffer/Buffer';
import type { TypedArray } from '../../buffer/Buffer';
/**
* Converts something into a buffer. If it is already a buffer it will pass it through
* if it is a number array it will convert it to a float32 array before being passed into a buffer
* the buffer will be created with the correct usage flags for geometry attributes
* @param buffer - number array
* @param index - is this an index buffer?
* @returns a buffer
* @memberof rendering
*/
export declare function ensureIsBuffer(buffer: Buffer | TypedArray | number[], index: boolean): Buffer;

View File

@@ -0,0 +1,29 @@
'use strict';
var Buffer = require('../../buffer/Buffer.js');
var _const = require('../../buffer/const.js');
"use strict";
function ensureIsBuffer(buffer, index) {
if (!(buffer instanceof Buffer.Buffer)) {
let usage = index ? _const.BufferUsage.INDEX : _const.BufferUsage.VERTEX;
if (buffer instanceof Array) {
if (index) {
buffer = new Uint32Array(buffer);
usage = _const.BufferUsage.INDEX | _const.BufferUsage.COPY_DST;
} else {
buffer = new Float32Array(buffer);
usage = _const.BufferUsage.VERTEX | _const.BufferUsage.COPY_DST;
}
}
buffer = new Buffer.Buffer({
data: buffer,
label: index ? "index-mesh-buffer" : "vertex-mesh-buffer",
usage
});
}
return buffer;
}
exports.ensureIsBuffer = ensureIsBuffer;
//# sourceMappingURL=ensureIsBuffer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ensureIsBuffer.js","sources":["../../../../../../src/rendering/renderers/shared/geometry/utils/ensureIsBuffer.ts"],"sourcesContent":["import { Buffer } from '../../buffer/Buffer';\nimport { BufferUsage } from '../../buffer/const';\n\nimport type { TypedArray } from '../../buffer/Buffer';\n\n/**\n * Converts something into a buffer. If it is already a buffer it will pass it through\n * if it is a number array it will convert it to a float32 array before being passed into a buffer\n * the buffer will be created with the correct usage flags for geometry attributes\n * @param buffer - number array\n * @param index - is this an index buffer?\n * @returns a buffer\n * @memberof rendering\n */\nexport function ensureIsBuffer(buffer: Buffer | TypedArray | number[], index: boolean): Buffer\n{\n if (!(buffer instanceof Buffer))\n {\n let usage: number = index ? BufferUsage.INDEX : BufferUsage.VERTEX;\n\n // its an array!\n if (buffer instanceof Array)\n {\n if (index)\n {\n buffer = new Uint32Array(buffer);\n usage = BufferUsage.INDEX | BufferUsage.COPY_DST;\n }\n\n else\n {\n buffer = new Float32Array(buffer);\n usage = BufferUsage.VERTEX | BufferUsage.COPY_DST;\n }\n }\n\n buffer = new Buffer({\n data: buffer,\n label: index ? 'index-mesh-buffer' : 'vertex-mesh-buffer',\n usage\n });\n }\n\n return buffer;\n}\n"],"names":["Buffer","BufferUsage"],"mappings":";;;;;;AAcgB,SAAA,cAAA,CAAe,QAAwC,KACvE,EAAA;AACI,EAAI,IAAA,EAAE,kBAAkBA,aACxB,CAAA,EAAA;AACI,IAAA,IAAI,KAAgB,GAAA,KAAA,GAAQC,kBAAY,CAAA,KAAA,GAAQA,kBAAY,CAAA,MAAA,CAAA;AAG5D,IAAA,IAAI,kBAAkB,KACtB,EAAA;AACI,MAAA,IAAI,KACJ,EAAA;AACI,QAAS,MAAA,GAAA,IAAI,YAAY,MAAM,CAAA,CAAA;AAC/B,QAAQ,KAAA,GAAAA,kBAAA,CAAY,QAAQA,kBAAY,CAAA,QAAA,CAAA;AAAA,OAI5C,MAAA;AACI,QAAS,MAAA,GAAA,IAAI,aAAa,MAAM,CAAA,CAAA;AAChC,QAAQ,KAAA,GAAAA,kBAAA,CAAY,SAASA,kBAAY,CAAA,QAAA,CAAA;AAAA,OAC7C;AAAA,KACJ;AAEA,IAAA,MAAA,GAAS,IAAID,aAAO,CAAA;AAAA,MAChB,IAAM,EAAA,MAAA;AAAA,MACN,KAAA,EAAO,QAAQ,mBAAsB,GAAA,oBAAA;AAAA,MACrC,KAAA;AAAA,KACH,CAAA,CAAA;AAAA,GACL;AAEA,EAAO,OAAA,MAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,27 @@
import { Buffer } from '../../buffer/Buffer.mjs';
import { BufferUsage } from '../../buffer/const.mjs';
"use strict";
function ensureIsBuffer(buffer, index) {
if (!(buffer instanceof Buffer)) {
let usage = index ? BufferUsage.INDEX : BufferUsage.VERTEX;
if (buffer instanceof Array) {
if (index) {
buffer = new Uint32Array(buffer);
usage = BufferUsage.INDEX | BufferUsage.COPY_DST;
} else {
buffer = new Float32Array(buffer);
usage = BufferUsage.VERTEX | BufferUsage.COPY_DST;
}
}
buffer = new Buffer({
data: buffer,
label: index ? "index-mesh-buffer" : "vertex-mesh-buffer",
usage
});
}
return buffer;
}
export { ensureIsBuffer };
//# sourceMappingURL=ensureIsBuffer.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ensureIsBuffer.mjs","sources":["../../../../../../src/rendering/renderers/shared/geometry/utils/ensureIsBuffer.ts"],"sourcesContent":["import { Buffer } from '../../buffer/Buffer';\nimport { BufferUsage } from '../../buffer/const';\n\nimport type { TypedArray } from '../../buffer/Buffer';\n\n/**\n * Converts something into a buffer. If it is already a buffer it will pass it through\n * if it is a number array it will convert it to a float32 array before being passed into a buffer\n * the buffer will be created with the correct usage flags for geometry attributes\n * @param buffer - number array\n * @param index - is this an index buffer?\n * @returns a buffer\n * @memberof rendering\n */\nexport function ensureIsBuffer(buffer: Buffer | TypedArray | number[], index: boolean): Buffer\n{\n if (!(buffer instanceof Buffer))\n {\n let usage: number = index ? BufferUsage.INDEX : BufferUsage.VERTEX;\n\n // its an array!\n if (buffer instanceof Array)\n {\n if (index)\n {\n buffer = new Uint32Array(buffer);\n usage = BufferUsage.INDEX | BufferUsage.COPY_DST;\n }\n\n else\n {\n buffer = new Float32Array(buffer);\n usage = BufferUsage.VERTEX | BufferUsage.COPY_DST;\n }\n }\n\n buffer = new Buffer({\n data: buffer,\n label: index ? 'index-mesh-buffer' : 'vertex-mesh-buffer',\n usage\n });\n }\n\n return buffer;\n}\n"],"names":[],"mappings":";;;;AAcgB,SAAA,cAAA,CAAe,QAAwC,KACvE,EAAA;AACI,EAAI,IAAA,EAAE,kBAAkB,MACxB,CAAA,EAAA;AACI,IAAA,IAAI,KAAgB,GAAA,KAAA,GAAQ,WAAY,CAAA,KAAA,GAAQ,WAAY,CAAA,MAAA,CAAA;AAG5D,IAAA,IAAI,kBAAkB,KACtB,EAAA;AACI,MAAA,IAAI,KACJ,EAAA;AACI,QAAS,MAAA,GAAA,IAAI,YAAY,MAAM,CAAA,CAAA;AAC/B,QAAQ,KAAA,GAAA,WAAA,CAAY,QAAQ,WAAY,CAAA,QAAA,CAAA;AAAA,OAI5C,MAAA;AACI,QAAS,MAAA,GAAA,IAAI,aAAa,MAAM,CAAA,CAAA;AAChC,QAAQ,KAAA,GAAA,WAAA,CAAY,SAAS,WAAY,CAAA,QAAA,CAAA;AAAA,OAC7C;AAAA,KACJ;AAEA,IAAA,MAAA,GAAS,IAAI,MAAO,CAAA;AAAA,MAChB,IAAM,EAAA,MAAA;AAAA,MACN,KAAA,EAAO,QAAQ,mBAAsB,GAAA,oBAAA;AAAA,MACrC,KAAA;AAAA,KACH,CAAA,CAAA;AAAA,GACL;AAEA,EAAO,OAAA,MAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,6 @@
import type { VertexFormat } from '../const';
export declare function getAttributeInfoFromFormat(format: VertexFormat): {
size: number;
stride: number;
normalised: boolean;
};

View File

@@ -0,0 +1,41 @@
'use strict';
"use strict";
const attributeFormatData = {
uint8x2: { size: 2, stride: 2, normalised: false },
uint8x4: { size: 4, stride: 4, normalised: false },
sint8x2: { size: 2, stride: 2, normalised: false },
sint8x4: { size: 4, stride: 4, normalised: false },
unorm8x2: { size: 2, stride: 2, normalised: true },
unorm8x4: { size: 4, stride: 4, normalised: true },
snorm8x2: { size: 2, stride: 2, normalised: true },
snorm8x4: { size: 4, stride: 4, normalised: true },
uint16x2: { size: 2, stride: 4, normalised: false },
uint16x4: { size: 4, stride: 8, normalised: false },
sint16x2: { size: 2, stride: 4, normalised: false },
sint16x4: { size: 4, stride: 8, normalised: false },
unorm16x2: { size: 2, stride: 4, normalised: true },
unorm16x4: { size: 4, stride: 8, normalised: true },
snorm16x2: { size: 2, stride: 4, normalised: true },
snorm16x4: { size: 4, stride: 8, normalised: true },
float16x2: { size: 2, stride: 4, normalised: false },
float16x4: { size: 4, stride: 8, normalised: false },
float32: { size: 1, stride: 4, normalised: false },
float32x2: { size: 2, stride: 8, normalised: false },
float32x3: { size: 3, stride: 12, normalised: false },
float32x4: { size: 4, stride: 16, normalised: false },
uint32: { size: 1, stride: 4, normalised: false },
uint32x2: { size: 2, stride: 8, normalised: false },
uint32x3: { size: 3, stride: 12, normalised: false },
uint32x4: { size: 4, stride: 16, normalised: false },
sint32: { size: 1, stride: 4, normalised: false },
sint32x2: { size: 2, stride: 8, normalised: false },
sint32x3: { size: 3, stride: 12, normalised: false },
sint32x4: { size: 4, stride: 16, normalised: false }
};
function getAttributeInfoFromFormat(format) {
return attributeFormatData[format] ?? attributeFormatData.float32;
}
exports.getAttributeInfoFromFormat = getAttributeInfoFromFormat;
//# sourceMappingURL=getAttributeInfoFromFormat.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getAttributeInfoFromFormat.js","sources":["../../../../../../src/rendering/renderers/shared/geometry/utils/getAttributeInfoFromFormat.ts"],"sourcesContent":["import type { VertexFormat } from '../const';\n\nconst attributeFormatData = {\n uint8x2: { size: 2, stride: 2, normalised: false },\n uint8x4: { size: 4, stride: 4, normalised: false },\n sint8x2: { size: 2, stride: 2, normalised: false },\n sint8x4: { size: 4, stride: 4, normalised: false },\n unorm8x2: { size: 2, stride: 2, normalised: true },\n unorm8x4: { size: 4, stride: 4, normalised: true },\n snorm8x2: { size: 2, stride: 2, normalised: true },\n snorm8x4: { size: 4, stride: 4, normalised: true },\n uint16x2: { size: 2, stride: 4, normalised: false },\n uint16x4: { size: 4, stride: 8, normalised: false },\n sint16x2: { size: 2, stride: 4, normalised: false },\n sint16x4: { size: 4, stride: 8, normalised: false },\n unorm16x2: { size: 2, stride: 4, normalised: true },\n unorm16x4: { size: 4, stride: 8, normalised: true },\n snorm16x2: { size: 2, stride: 4, normalised: true },\n snorm16x4: { size: 4, stride: 8, normalised: true },\n float16x2: { size: 2, stride: 4, normalised: false },\n float16x4: { size: 4, stride: 8, normalised: false },\n float32: { size: 1, stride: 4, normalised: false },\n float32x2: { size: 2, stride: 8, normalised: false },\n float32x3: { size: 3, stride: 12, normalised: false },\n float32x4: { size: 4, stride: 16, normalised: false },\n uint32: { size: 1, stride: 4, normalised: false },\n uint32x2: { size: 2, stride: 8, normalised: false },\n uint32x3: { size: 3, stride: 12, normalised: false },\n uint32x4: { size: 4, stride: 16, normalised: false },\n sint32: { size: 1, stride: 4, normalised: false },\n sint32x2: { size: 2, stride: 8, normalised: false },\n sint32x3: { size: 3, stride: 12, normalised: false },\n sint32x4: { size: 4, stride: 16, normalised: false },\n};\n\nexport function getAttributeInfoFromFormat(format: VertexFormat): { size: number; stride: number; normalised: boolean }\n{\n return attributeFormatData[format] ?? attributeFormatData.float32;\n}\n"],"names":[],"mappings":";;;AAEA,MAAM,mBAAsB,GAAA;AAAA,EACxB,SAAS,EAAE,IAAA,EAAM,GAAG,MAAQ,EAAA,CAAA,EAAG,YAAY,KAAM,EAAA;AAAA,EACjD,SAAS,EAAE,IAAA,EAAM,GAAG,MAAQ,EAAA,CAAA,EAAG,YAAY,KAAM,EAAA;AAAA,EACjD,SAAS,EAAE,IAAA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K,mBAAoB,CAAA,OAAA,CAAA;AAC9D;;;;"}

View File

@@ -0,0 +1,39 @@
"use strict";
const attributeFormatData = {
uint8x2: { size: 2, stride: 2, normalised: false },
uint8x4: { size: 4, stride: 4, normalised: false },
sint8x2: { size: 2, stride: 2, normalised: false },
sint8x4: { size: 4, stride: 4, normalised: false },
unorm8x2: { size: 2, stride: 2, normalised: true },
unorm8x4: { size: 4, stride: 4, normalised: true },
snorm8x2: { size: 2, stride: 2, normalised: true },
snorm8x4: { size: 4, stride: 4, normalised: true },
uint16x2: { size: 2, stride: 4, normalised: false },
uint16x4: { size: 4, stride: 8, normalised: false },
sint16x2: { size: 2, stride: 4, normalised: false },
sint16x4: { size: 4, stride: 8, normalised: false },
unorm16x2: { size: 2, stride: 4, normalised: true },
unorm16x4: { size: 4, stride: 8, normalised: true },
snorm16x2: { size: 2, stride: 4, normalised: true },
snorm16x4: { size: 4, stride: 8, normalised: true },
float16x2: { size: 2, stride: 4, normalised: false },
float16x4: { size: 4, stride: 8, normalised: false },
float32: { size: 1, stride: 4, normalised: false },
float32x2: { size: 2, stride: 8, normalised: false },
float32x3: { size: 3, stride: 12, normalised: false },
float32x4: { size: 4, stride: 16, normalised: false },
uint32: { size: 1, stride: 4, normalised: false },
uint32x2: { size: 2, stride: 8, normalised: false },
uint32x3: { size: 3, stride: 12, normalised: false },
uint32x4: { size: 4, stride: 16, normalised: false },
sint32: { size: 1, stride: 4, normalised: false },
sint32x2: { size: 2, stride: 8, normalised: false },
sint32x3: { size: 3, stride: 12, normalised: false },
sint32x4: { size: 4, stride: 16, normalised: false }
};
function getAttributeInfoFromFormat(format) {
return attributeFormatData[format] ?? attributeFormatData.float32;
}
export { getAttributeInfoFromFormat };
//# sourceMappingURL=getAttributeInfoFromFormat.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getAttributeInfoFromFormat.mjs","sources":["../../../../../../src/rendering/renderers/shared/geometry/utils/getAttributeInfoFromFormat.ts"],"sourcesContent":["import type { VertexFormat } from '../const';\n\nconst attributeFormatData = {\n uint8x2: { size: 2, stride: 2, normalised: false },\n uint8x4: { size: 4, stride: 4, normalised: false },\n sint8x2: { size: 2, stride: 2, normalised: false },\n sint8x4: { size: 4, stride: 4, normalised: false },\n unorm8x2: { size: 2, stride: 2, normalised: true },\n unorm8x4: { size: 4, stride: 4, normalised: true },\n snorm8x2: { size: 2, stride: 2, normalised: true },\n snorm8x4: { size: 4, stride: 4, normalised: true },\n uint16x2: { size: 2, stride: 4, normalised: false },\n uint16x4: { size: 4, stride: 8, normalised: false },\n sint16x2: { size: 2, stride: 4, normalised: false },\n sint16x4: { size: 4, stride: 8, normalised: false },\n unorm16x2: { size: 2, stride: 4, normalised: true },\n unorm16x4: { size: 4, stride: 8, normalised: true },\n snorm16x2: { size: 2, stride: 4, normalised: true },\n snorm16x4: { size: 4, stride: 8, normalised: true },\n float16x2: { size: 2, stride: 4, normalised: false },\n float16x4: { size: 4, stride: 8, normalised: false },\n float32: { size: 1, stride: 4, normalised: false },\n float32x2: { size: 2, stride: 8, normalised: false },\n float32x3: { size: 3, stride: 12, normalised: false },\n float32x4: { size: 4, stride: 16, normalised: false },\n uint32: { size: 1, stride: 4, normalised: false },\n uint32x2: { size: 2, stride: 8, normalised: false },\n uint32x3: { size: 3, stride: 12, normalised: false },\n uint32x4: { size: 4, stride: 16, normalised: false },\n sint32: { size: 1, stride: 4, normalised: false },\n sint32x2: { size: 2, stride: 8, normalised: false },\n sint32x3: { size: 3, stride: 12, normalised: false },\n sint32x4: { size: 4, stride: 16, normalised: false },\n};\n\nexport function getAttributeInfoFromFormat(format: VertexFormat): { size: number; stride: number; normalised: boolean }\n{\n return attributeFormatData[format] ?? attributeFormatData.float32;\n}\n"],"names":[],"mappings":";AAEA,MAAM,mBAAsB,GAAA;AAAA,EACxB,SAAS,EAAE,IAAA,EAAM,GAAG,MAAQ,EAAA,CAAA,EAAG,YAAY,KAAM,EAAA;AAAA,EACjD,SAAS,EAAE,IAAA,EAAM,GAA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SAAS,2BAA2B,MAC3C,EAAA;AACI,EAAO,OAAA,mBAAA,CAAoB,MAAM,CAAA,IAAK,mBAAoB,CAAA,OAAA,CAAA;AAC9D;;;;"}

View File

@@ -0,0 +1,10 @@
import type { Bounds } from '../../../../../scene/container/bounds/Bounds';
import type { Geometry } from '../Geometry';
/**
* Gets the 2D bounds of a geometry, based on a specific attribute.
* @param geometry - Geometry to to measure
* @param attributeId - AttributeId that contains the x,y data
* @param bounds - Bounds to store the result in
* @returns the bounds
*/
export declare function getGeometryBounds(geometry: Geometry, attributeId: string, bounds: Bounds): Bounds;

View File

@@ -0,0 +1,41 @@
'use strict';
"use strict";
function getGeometryBounds(geometry, attributeId, bounds) {
const attribute = geometry.getAttribute(attributeId);
if (!attribute) {
bounds.minX = 0;
bounds.minY = 0;
bounds.maxX = 0;
bounds.maxY = 0;
return bounds;
}
const data = attribute.buffer.data;
let minX = Infinity;
let minY = Infinity;
let maxX = -Infinity;
let maxY = -Infinity;
const byteSize = data.BYTES_PER_ELEMENT;
const offset = (attribute.offset || 0) / byteSize;
const stride = (attribute.stride || 2 * 4) / byteSize;
for (let i = offset; i < data.length; i += stride) {
const x = data[i];
const y = data[i + 1];
if (x > maxX)
maxX = x;
if (y > maxY)
maxY = y;
if (x < minX)
minX = x;
if (y < minY)
minY = y;
}
bounds.minX = minX;
bounds.minY = minY;
bounds.maxX = maxX;
bounds.maxY = maxY;
return bounds;
}
exports.getGeometryBounds = getGeometryBounds;
//# sourceMappingURL=getGeometryBounds.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getGeometryBounds.js","sources":["../../../../../../src/rendering/renderers/shared/geometry/utils/getGeometryBounds.ts"],"sourcesContent":["import type { Bounds } from '../../../../../scene/container/bounds/Bounds';\nimport type { Geometry } from '../Geometry';\n\n/**\n * Gets the 2D bounds of a geometry, based on a specific attribute.\n * @param geometry - Geometry to to measure\n * @param attributeId - AttributeId that contains the x,y data\n * @param bounds - Bounds to store the result in\n * @returns the bounds\n */\nexport function getGeometryBounds(geometry: Geometry, attributeId: string, bounds: Bounds): Bounds\n{\n const attribute = geometry.getAttribute(attributeId);\n\n if (!attribute)\n {\n bounds.minX = 0;\n bounds.minY = 0;\n bounds.maxX = 0;\n bounds.maxY = 0;\n\n return bounds;\n }\n\n const data = attribute.buffer.data as Float32Array;\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n const byteSize = data.BYTES_PER_ELEMENT;\n\n // stride and offset MAY have not been calculated yet.. so go with assumed defaults\n const offset = (attribute.offset || 0) / byteSize;\n const stride = (attribute.stride || (2 * 4)) / byteSize;\n\n for (let i = offset; i < data.length; i += stride)\n {\n const x = data[i];\n const y = data[i + 1];\n\n if (x > maxX)maxX = x;\n if (y > maxY)maxY = y;\n if (x < minX)minX = x;\n if (y < minY)minY = y;\n }\n\n bounds.minX = minX;\n bounds.minY = minY;\n bounds.maxX = maxX;\n bounds.maxY = maxY;\n\n return bounds;\n}\n"],"names":[],"mappings":";;;AAUgB,SAAA,iBAAA,CAAkB,QAAoB,EAAA,WAAA,EAAqB,MAC3E,EAAA;AACI,EAAM,MAAA,SAAA,GAAY,QAAS,CAAA,YAAA,CAAa,WAAW,CAAA,CAAA;AAEnD,EAAA,IAAI,CAAC,SACL,EAAA;AACI,IAAA,MAAA,CAAO,IAAO,GAAA,CAAA,CAAA;AACd,IAAA,MAAA,CAAO,IAAO,GAAA,CAAA,CAAA;AACd,IAAA,MAAA,CAAO,IAAO,GAAA,CAAA,CAAA;AACd,IAAA,MAAA,CAAO,IAAO,GAAA,CAAA,CAAA;AAEd,IAAO,OAAA,MAAA,CAAA;AAAA,GACX;AAEA,EAAM,MAAA,IAAA,GAAO,UAAU,MAAO,CAAA,IAAA,CAAA;AAE9B,EAAA,IAAI,IAAO,GAAA,QAAA,CAAA;AACX,EAAA,IAAI,IAAO,GAAA,QAAA,CAAA;AACX,EAAA,IAAI,IAAO,GAAA,CAAA,QAAA,CAAA;AACX,EAAA,IAAI,IAAO,GAAA,CAAA,QAAA,CAAA;AAEX,EAAA,MAAM,WAAW,IAAK,CAAA,iBAAA,CAAA;AAGtB,EAAM,MAAA,MAAA,GAAA,CAAU,SAAU,CAAA,MAAA,IAAU,CAAK,IAAA,QAAA,CAAA;AACzC,EAAA,MAAM,MAAU,GAAA,CAAA,SAAA,CAAU,MAAW,IAAA,CAAA,GAAI,CAAM,IAAA,QAAA,CAAA;AAE/C,EAAA,KAAA,IAAS,IAAI,MAAQ,EAAA,CAAA,GAAI,IAAK,CAAA,MAAA,EAAQ,KAAK,MAC3C,EAAA;AACI,IAAM,MAAA,CAAA,GAAI,KAAK,CAAC,CAAA,CAAA;AAChB,IAAM,MAAA,CAAA,GAAI,IAAK,CAAA,CAAA,GAAI,CAAC,CAAA,CAAA;AAEpB,IAAA,IAAI,CAAI,GAAA,IAAA;AAAK,MAAO,IAAA,GAAA,CAAA,CAAA;AACpB,IAAA,IAAI,CAAI,GAAA,IAAA;AAAK,MAAO,IAAA,GAAA,CAAA,CAAA;AACpB,IAAA,IAAI,CAAI,GAAA,IAAA;AAAK,MAAO,IAAA,GAAA,CAAA,CAAA;AACpB,IAAA,IAAI,CAAI,GAAA,IAAA;AAAK,MAAO,IAAA,GAAA,CAAA,CAAA;AAAA,GACxB;AAEA,EAAA,MAAA,CAAO,IAAO,GAAA,IAAA,CAAA;AACd,EAAA,MAAA,CAAO,IAAO,GAAA,IAAA,CAAA;AACd,EAAA,MAAA,CAAO,IAAO,GAAA,IAAA,CAAA;AACd,EAAA,MAAA,CAAO,IAAO,GAAA,IAAA,CAAA;AAEd,EAAO,OAAA,MAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,39 @@
"use strict";
function getGeometryBounds(geometry, attributeId, bounds) {
const attribute = geometry.getAttribute(attributeId);
if (!attribute) {
bounds.minX = 0;
bounds.minY = 0;
bounds.maxX = 0;
bounds.maxY = 0;
return bounds;
}
const data = attribute.buffer.data;
let minX = Infinity;
let minY = Infinity;
let maxX = -Infinity;
let maxY = -Infinity;
const byteSize = data.BYTES_PER_ELEMENT;
const offset = (attribute.offset || 0) / byteSize;
const stride = (attribute.stride || 2 * 4) / byteSize;
for (let i = offset; i < data.length; i += stride) {
const x = data[i];
const y = data[i + 1];
if (x > maxX)
maxX = x;
if (y > maxY)
maxY = y;
if (x < minX)
minX = x;
if (y < minY)
minY = y;
}
bounds.minX = minX;
bounds.minY = minY;
bounds.maxX = maxX;
bounds.maxY = maxY;
return bounds;
}
export { getGeometryBounds };
//# sourceMappingURL=getGeometryBounds.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getGeometryBounds.mjs","sources":["../../../../../../src/rendering/renderers/shared/geometry/utils/getGeometryBounds.ts"],"sourcesContent":["import type { Bounds } from '../../../../../scene/container/bounds/Bounds';\nimport type { Geometry } from '../Geometry';\n\n/**\n * Gets the 2D bounds of a geometry, based on a specific attribute.\n * @param geometry - Geometry to to measure\n * @param attributeId - AttributeId that contains the x,y data\n * @param bounds - Bounds to store the result in\n * @returns the bounds\n */\nexport function getGeometryBounds(geometry: Geometry, attributeId: string, bounds: Bounds): Bounds\n{\n const attribute = geometry.getAttribute(attributeId);\n\n if (!attribute)\n {\n bounds.minX = 0;\n bounds.minY = 0;\n bounds.maxX = 0;\n bounds.maxY = 0;\n\n return bounds;\n }\n\n const data = attribute.buffer.data as Float32Array;\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n const byteSize = data.BYTES_PER_ELEMENT;\n\n // stride and offset MAY have not been calculated yet.. so go with assumed defaults\n const offset = (attribute.offset || 0) / byteSize;\n const stride = (attribute.stride || (2 * 4)) / byteSize;\n\n for (let i = offset; i < data.length; i += stride)\n {\n const x = data[i];\n const y = data[i + 1];\n\n if (x > maxX)maxX = x;\n if (y > maxY)maxY = y;\n if (x < minX)minX = x;\n if (y < minY)minY = y;\n }\n\n bounds.minX = minX;\n bounds.minY = minY;\n bounds.maxX = maxX;\n bounds.maxY = max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AAA,IAAA;AAAK,MAAO,IAAA,GAAA,CAAA,CAAA;AACpB,IAAA,IAAI,CAAI,GAAA,IAAA;AAAK,MAAO,IAAA,GAAA,CAAA,CAAA;AACpB,IAAA,IAAI,CAAI,GAAA,IAAA;AAAK,MAAO,IAAA,GAAA,CAAA,CAAA;AAAA,GACxB;AAEA,EAAA,MAAA,CAAO,IAAO,GAAA,IAAA,CAAA;AACd,EAAA,MAAA,CAAO,IAAO,GAAA,IAAA,CAAA;AACd,EAAA,MAAA,CAAO,IAAO,GAAA,IAAA,CAAA;AACd,EAAA,MAAA,CAAO,IAAO,GAAA,IAAA,CAAA;AAEd,EAAO,OAAA,MAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,11 @@
import type { Matrix } from '../../../../../maths/matrix/Matrix';
/**
* Transforms the vertices in an array with the given matrix.
* @param vertices - the vertices to transform
* @param m - the matrix to apply to the vertices
* @param offset - the offset of the vertices (defaults to 0)
* @param stride - the stride of the vertices (defaults to 2)
* @param size - the size of the vertices (defaults to vertices.length / stride - offset)
* @memberof rendering
*/
export declare function transformVertices(vertices: number[], m: Matrix, offset?: number, stride?: number, size?: number): void;

View File

@@ -0,0 +1,25 @@
'use strict';
"use strict";
function transformVertices(vertices, m, offset, stride, size) {
const a = m.a;
const b = m.b;
const c = m.c;
const d = m.d;
const tx = m.tx;
const ty = m.ty;
offset = offset || 0;
stride = stride || 2;
size = size || vertices.length / stride - offset;
let index = offset * stride;
for (let i = 0; i < size; i++) {
const x = vertices[index];
const y = vertices[index + 1];
vertices[index] = a * x + c * y + tx;
vertices[index + 1] = b * x + d * y + ty;
index += stride;
}
}
exports.transformVertices = transformVertices;
//# sourceMappingURL=transformVertices.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"transformVertices.js","sources":["../../../../../../src/rendering/renderers/shared/geometry/utils/transformVertices.ts"],"sourcesContent":["import type { Matrix } from '../../../../../maths/matrix/Matrix';\n\n/**\n * Transforms the vertices in an array with the given matrix.\n * @param vertices - the vertices to transform\n * @param m - the matrix to apply to the vertices\n * @param offset - the offset of the vertices (defaults to 0)\n * @param stride - the stride of the vertices (defaults to 2)\n * @param size - the size of the vertices (defaults to vertices.length / stride - offset)\n * @memberof rendering\n */\nexport function transformVertices(vertices: number[], m: Matrix, offset?: number, stride?: number, size?: number)\n{\n const a = m.a;\n const b = m.b;\n const c = m.c;\n const d = m.d;\n const tx = m.tx;\n const ty = m.ty;\n\n offset = offset || 0;\n stride = stride || 2;\n size = size || (vertices.length / stride) - offset;\n\n let index = offset * stride;\n\n for (let i = 0; i < size; i++)\n {\n const x = vertices[index];\n const y = vertices[index + 1];\n\n vertices[index] = (a * x) + (c * y) + tx;\n vertices[index + 1] = (b * x) + (d * y) + ty;\n\n index += stride;\n }\n}\n"],"names":[],"mappings":";;;AAWO,SAAS,iBAAkB,CAAA,QAAA,EAAoB,CAAW,EAAA,MAAA,EAAiB,QAAiB,IACnG,EAAA;AACI,EAAA,MAAM,IAAI,CAAE,CAAA,CAAA,CAAA;AACZ,EAAA,MAAM,IAAI,CAAE,CAAA,CAAA,CAAA;AACZ,EAAA,MAAM,IAAI,CAAE,CAAA,CAAA,CAAA;AACZ,EAAA,MAAM,IAAI,CAAE,CAAA,CAAA,CAAA;AACZ,EAAA,MAAM,KAAK,CAAE,CAAA,EAAA,CAAA;AACb,EAAA,MAAM,KAAK,CAAE,CAAA,EAAA,CAAA;AAEb,EAAA,MAAA,GAAS,MAAU,IAAA,CAAA,CAAA;AACnB,EAAA,MAAA,GAAS,MAAU,IAAA,CAAA,CAAA;AACnB,EAAO,IAAA,GAAA,IAAA,IAAS,QAAS,CAAA,MAAA,GAAS,MAAU,GAAA,MAAA,CAAA;AAE5C,EAAA,IAAI,QAAQ,MAAS,GAAA,MAAA,CAAA;AAErB,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,IAAA,EAAM,CAC1B,EAAA,EAAA;AACI,IAAM,MAAA,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AACxB,IAAM,MAAA,CAAA,GAAI,QAAS,CAAA,KAAA,GAAQ,CAAC,CAAA,CAAA;AAE5B,IAAA,QAAA,CAAS,KAAK,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AACtC,IAAA,QAAA,CAAS,QAAQ,CAAC,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AAE1C,IAAS,KAAA,IAAA,MAAA,CAAA;AAAA,GACb;AACJ;;;;"}

View File

@@ -0,0 +1,23 @@
"use strict";
function transformVertices(vertices, m, offset, stride, size) {
const a = m.a;
const b = m.b;
const c = m.c;
const d = m.d;
const tx = m.tx;
const ty = m.ty;
offset = offset || 0;
stride = stride || 2;
size = size || vertices.length / stride - offset;
let index = offset * stride;
for (let i = 0; i < size; i++) {
const x = vertices[index];
const y = vertices[index + 1];
vertices[index] = a * x + c * y + tx;
vertices[index + 1] = b * x + d * y + ty;
index += stride;
}
}
export { transformVertices };
//# sourceMappingURL=transformVertices.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"transformVertices.mjs","sources":["../../../../../../src/rendering/renderers/shared/geometry/utils/transformVertices.ts"],"sourcesContent":["import type { Matrix } from '../../../../../maths/matrix/Matrix';\n\n/**\n * Transforms the vertices in an array with the given matrix.\n * @param vertices - the vertices to transform\n * @param m - the matrix to apply to the vertices\n * @param offset - the offset of the vertices (defaults to 0)\n * @param stride - the stride of the vertices (defaults to 2)\n * @param size - the size of the vertices (defaults to vertices.length / stride - offset)\n * @memberof rendering\n */\nexport function transformVertices(vertices: number[], m: Matrix, offset?: number, stride?: number, size?: number)\n{\n const a = m.a;\n const b = m.b;\n const c = m.c;\n const d = m.d;\n const tx = m.tx;\n const ty = m.ty;\n\n offset = offset || 0;\n stride = stride || 2;\n size = size || (vertices.length / stride) - offset;\n\n let index = offset * stride;\n\n for (let i = 0; i < size; i++)\n {\n const x = vertices[index];\n const y = vertices[index + 1];\n\n vertices[index] = (a * x) + (c * y) + tx;\n vertices[index + 1] = (b * x) + (d * y) + ty;\n\n index += stride;\n }\n}\n"],"names":[],"mappings":";AAWO,SAAS,iBAAkB,CAAA,QAAA,EAAoB,CAAW,EAAA,MAAA,EAAiB,QAAiB,IACnG,EAAA;AACI,EAAA,MAAM,IAAI,CAAE,CAAA,CAAA,CAAA;AACZ,EAAA,MAAM,IAAI,CAAE,CAAA,CAAA,CAAA;AACZ,EAAA,MAAM,IAAI,CAAE,CAAA,CAAA,CAAA;AACZ,EAAA,MAAM,IAAI,CAAE,CAAA,CAAA,CAAA;AACZ,EAAA,MAAM,KAAK,CAAE,CAAA,EAAA,CAAA;AACb,EAAA,MAAM,KAAK,CAAE,CAAA,EAAA,CAAA;AAEb,EAAA,MAAA,GAAS,MAAU,IAAA,CAAA,CAAA;AACnB,EAAA,MAAA,GAAS,MAAU,IAAA,CAAA,CAAA;AACnB,EAAO,IAAA,GAAA,IAAA,IAAS,QAAS,CAAA,MAAA,GAAS,MAAU,GAAA,MAAA,CAAA;AAE5C,EAAA,IAAI,QAAQ,MAAS,GAAA,MAAA,CAAA;AAErB,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,IAAA,EAAM,CAC1B,EAAA,EAAA;AACI,IAAM,MAAA,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AACxB,IAAM,MAAA,CAAA,GAAI,QAAS,CAAA,KAAA,GAAQ,CAAC,CAAA,CAAA;AAE5B,IAAA,QAAA,CAAS,KAAK,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AACtC,IAAA,QAAA,CAAS,QAAQ,CAAC,CAAA,GAAK,CAAI,GAAA,CAAA,GAAM,IAAI,CAAK,GAAA,EAAA,CAAA;AAE1C,IAAS,KAAA,IAAA,MAAA,CAAA;AAAA,GACb;AACJ;;;;"}