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,155 @@
import EventEmitter from 'eventemitter3';
import { Bounds } from '../../../../scene/container/bounds/Bounds';
import { Buffer } from '../buffer/Buffer';
import type { TypedArray } from '../buffer/Buffer';
import type { Topology, VertexFormat } from './const';
export type IndexBufferArray = Uint16Array | Uint32Array;
/**
* The attribute data for a geometries attributes
* @memberof rendering
*/
export interface Attribute {
/** the buffer that this attributes data belongs to */
buffer: Buffer;
/** the format of the attribute */
format?: VertexFormat;
/** the stride of the data in the buffer*/
stride?: number;
/** the offset of the attribute from the buffer, defaults to 0 */
offset?: number;
/** is this an instanced buffer? (defaults to false) */
instance?: boolean;
/** the number of elements to be rendered. If not specified, all vertices after the starting vertex will be drawn. */
size?: number;
/** the type of attribute */
type?: number;
/**
* the starting vertex in the geometry to start drawing from. If not specified,
* drawing will start from the first vertex.
*/
start?: number;
/**
* attribute divisor for instanced rendering. Note: this is a **WebGL-only** feature, the WebGPU renderer will
* issue a warning if one of the attributes has divisor set.
*/
divisor?: number;
}
/**
* The attribute options used by the constructor for adding geometries attributes
* extends {@link rendering.Attribute} but allows for the buffer to be a typed or number array
* @memberof rendering
*/
type AttributeOption = Omit<Attribute, 'buffer'> & {
buffer: Buffer | TypedArray | number[];
} | Buffer | TypedArray | number[];
export type AttributeOptions = Record<string, AttributeOption>;
/**
* the interface that describes the structure of the geometry
* @memberof rendering
*/
export interface GeometryDescriptor {
/** an optional label to easily identify the geometry */
label?: string;
/** the attributes that make up the geometry */
attributes: AttributeOptions;
/** optional index buffer for this geometry */
indexBuffer?: Buffer | TypedArray | number[];
/** the topology of the geometry, defaults to 'triangle-list' */
topology?: Topology;
instanceCount?: number;
}
/**
* A Geometry is a low-level object that represents the structure of 2D shapes in terms of vertices and attributes.
* It's a crucial component for rendering as it describes the shape and format of the data that will go through the shaders.
* Essentially, a Geometry object holds the data you'd send to a GPU buffer.
*
* A geometry is basically made of two components:
* <br>
* <b>Attributes</b>: These are essentially arrays that define properties of the vertices like position, color,
* texture coordinates, etc. They map directly to attributes in your vertex shaders.
* <br>
* <b>Indices</b>: An optional array that describes how the vertices are connected.
* If not provided, vertices will be interpreted in the sequence they're given.
* @example
*
* const geometry = new Geometry({
* attributes: {
* aPosition: [ // add some positions
* 0, 0,
* 0, 100,
* 100, 100,
* 100, 0,
* ],
* aUv: [ // add some uvs
* 0, 0,
* 0, 1,
* 1, 1,
* 1, 0,
* ]
* }
* });
* @memberof rendering
* @class
*/
export declare class Geometry extends EventEmitter<{
update: Geometry;
destroy: Geometry;
}> {
/** The topology of the geometry. */
topology: Topology;
/** The unique id of the geometry. */
readonly uid: number;
/** A record of the attributes of the geometry. */
readonly attributes: Record<string, Attribute>;
/** The buffers that the attributes use */
readonly buffers: Buffer[];
/** The index buffer of the geometry */
readonly indexBuffer: Buffer;
/**
* the layout key will be generated by WebGPU all geometries that have the same structure
* will have the same layout key. This is used to cache the pipeline layout
* @internal
* @ignore
*/
_layoutKey: number;
/** the instance count of the geometry to draw */
instanceCount: number;
private readonly _bounds;
private _boundsDirty;
/**
* Create a new instance of a geometry
* @param options - The options for the geometry.
*/
constructor(options: GeometryDescriptor);
protected onBufferUpdate(): void;
/**
* Returns the requested attribute.
* @param id - The name of the attribute required
* @returns - The attribute requested.
*/
getAttribute(id: string): Attribute;
/**
* Returns the index buffer
* @returns - The index buffer.
*/
getIndex(): Buffer;
/**
* Returns the requested buffer.
* @param id - The name of the buffer required.
* @returns - The buffer requested.
*/
getBuffer(id: string): Buffer;
/**
* Used to figure out how many vertices there are in this geometry
* @returns the number of vertices in the geometry
*/
getSize(): number;
/** Returns the bounds of the geometry. */
get bounds(): Bounds;
/**
* destroys the geometry.
* @param destroyBuffers - destroy the buffers associated with this geometry
*/
destroy(destroyBuffers?: boolean): void;
}
export {};

View File

@@ -0,0 +1,123 @@
'use strict';
var EventEmitter = require('eventemitter3');
var Bounds = require('../../../../scene/container/bounds/Bounds.js');
var uid = require('../../../../utils/data/uid.js');
var Buffer = require('../buffer/Buffer.js');
var ensureIsBuffer = require('./utils/ensureIsBuffer.js');
var getGeometryBounds = require('./utils/getGeometryBounds.js');
"use strict";
function ensureIsAttribute(attribute) {
if (attribute instanceof Buffer.Buffer || Array.isArray(attribute) || attribute.BYTES_PER_ELEMENT) {
attribute = {
buffer: attribute
};
}
attribute.buffer = ensureIsBuffer.ensureIsBuffer(attribute.buffer, false);
return attribute;
}
class Geometry extends EventEmitter {
/**
* Create a new instance of a geometry
* @param options - The options for the geometry.
*/
constructor(options) {
const { attributes, indexBuffer, topology } = options;
super();
/** The unique id of the geometry. */
this.uid = uid.uid("geometry");
/**
* the layout key will be generated by WebGPU all geometries that have the same structure
* will have the same layout key. This is used to cache the pipeline layout
* @internal
* @ignore
*/
this._layoutKey = 0;
/** the instance count of the geometry to draw */
this.instanceCount = 1;
this._bounds = new Bounds.Bounds();
this._boundsDirty = true;
this.attributes = attributes;
this.buffers = [];
this.instanceCount = options.instanceCount || 1;
for (const i in attributes) {
const attribute = attributes[i] = ensureIsAttribute(attributes[i]);
const bufferIndex = this.buffers.indexOf(attribute.buffer);
if (bufferIndex === -1) {
this.buffers.push(attribute.buffer);
attribute.buffer.on("update", this.onBufferUpdate, this);
attribute.buffer.on("change", this.onBufferUpdate, this);
}
}
if (indexBuffer) {
this.indexBuffer = ensureIsBuffer.ensureIsBuffer(indexBuffer, true);
this.buffers.push(this.indexBuffer);
}
this.topology = topology || "triangle-list";
}
onBufferUpdate() {
this._boundsDirty = true;
this.emit("update", this);
}
/**
* Returns the requested attribute.
* @param id - The name of the attribute required
* @returns - The attribute requested.
*/
getAttribute(id) {
return this.attributes[id];
}
/**
* Returns the index buffer
* @returns - The index buffer.
*/
getIndex() {
return this.indexBuffer;
}
/**
* Returns the requested buffer.
* @param id - The name of the buffer required.
* @returns - The buffer requested.
*/
getBuffer(id) {
return this.getAttribute(id).buffer;
}
/**
* Used to figure out how many vertices there are in this geometry
* @returns the number of vertices in the geometry
*/
getSize() {
for (const i in this.attributes) {
const attribute = this.attributes[i];
const buffer = attribute.buffer;
return buffer.data.length / (attribute.stride / 4 || attribute.size);
}
return 0;
}
/** Returns the bounds of the geometry. */
get bounds() {
if (!this._boundsDirty)
return this._bounds;
this._boundsDirty = false;
return getGeometryBounds.getGeometryBounds(this, "aPosition", this._bounds);
}
/**
* destroys the geometry.
* @param destroyBuffers - destroy the buffers associated with this geometry
*/
destroy(destroyBuffers = false) {
this.emit("destroy", this);
this.removeAllListeners();
if (destroyBuffers) {
this.buffers.forEach((buffer) => buffer.destroy());
}
this.attributes = null;
this.buffers = null;
this.indexBuffer = null;
this._bounds = null;
}
}
exports.Geometry = Geometry;
//# sourceMappingURL=Geometry.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,121 @@
import EventEmitter from 'eventemitter3';
import { Bounds } from '../../../../scene/container/bounds/Bounds.mjs';
import { uid } from '../../../../utils/data/uid.mjs';
import { Buffer } from '../buffer/Buffer.mjs';
import { ensureIsBuffer } from './utils/ensureIsBuffer.mjs';
import { getGeometryBounds } from './utils/getGeometryBounds.mjs';
"use strict";
function ensureIsAttribute(attribute) {
if (attribute instanceof Buffer || Array.isArray(attribute) || attribute.BYTES_PER_ELEMENT) {
attribute = {
buffer: attribute
};
}
attribute.buffer = ensureIsBuffer(attribute.buffer, false);
return attribute;
}
class Geometry extends EventEmitter {
/**
* Create a new instance of a geometry
* @param options - The options for the geometry.
*/
constructor(options) {
const { attributes, indexBuffer, topology } = options;
super();
/** The unique id of the geometry. */
this.uid = uid("geometry");
/**
* the layout key will be generated by WebGPU all geometries that have the same structure
* will have the same layout key. This is used to cache the pipeline layout
* @internal
* @ignore
*/
this._layoutKey = 0;
/** the instance count of the geometry to draw */
this.instanceCount = 1;
this._bounds = new Bounds();
this._boundsDirty = true;
this.attributes = attributes;
this.buffers = [];
this.instanceCount = options.instanceCount || 1;
for (const i in attributes) {
const attribute = attributes[i] = ensureIsAttribute(attributes[i]);
const bufferIndex = this.buffers.indexOf(attribute.buffer);
if (bufferIndex === -1) {
this.buffers.push(attribute.buffer);
attribute.buffer.on("update", this.onBufferUpdate, this);
attribute.buffer.on("change", this.onBufferUpdate, this);
}
}
if (indexBuffer) {
this.indexBuffer = ensureIsBuffer(indexBuffer, true);
this.buffers.push(this.indexBuffer);
}
this.topology = topology || "triangle-list";
}
onBufferUpdate() {
this._boundsDirty = true;
this.emit("update", this);
}
/**
* Returns the requested attribute.
* @param id - The name of the attribute required
* @returns - The attribute requested.
*/
getAttribute(id) {
return this.attributes[id];
}
/**
* Returns the index buffer
* @returns - The index buffer.
*/
getIndex() {
return this.indexBuffer;
}
/**
* Returns the requested buffer.
* @param id - The name of the buffer required.
* @returns - The buffer requested.
*/
getBuffer(id) {
return this.getAttribute(id).buffer;
}
/**
* Used to figure out how many vertices there are in this geometry
* @returns the number of vertices in the geometry
*/
getSize() {
for (const i in this.attributes) {
const attribute = this.attributes[i];
const buffer = attribute.buffer;
return buffer.data.length / (attribute.stride / 4 || attribute.size);
}
return 0;
}
/** Returns the bounds of the geometry. */
get bounds() {
if (!this._boundsDirty)
return this._bounds;
this._boundsDirty = false;
return getGeometryBounds(this, "aPosition", this._bounds);
}
/**
* destroys the geometry.
* @param destroyBuffers - destroy the buffers associated with this geometry
*/
destroy(destroyBuffers = false) {
this.emit("destroy", this);
this.removeAllListeners();
if (destroyBuffers) {
this.buffers.forEach((buffer) => buffer.destroy());
}
this.attributes = null;
this.buffers = null;
this.indexBuffer = null;
this._bounds = null;
}
}
export { Geometry };
//# sourceMappingURL=Geometry.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,18 @@
/**
* The different topology types supported by the renderer used to describe how the geometry should be renderer
* @memberof rendering
*/
export type Topology = 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
/** @deprecated since 8.0.0 */
export declare const DRAW_MODES: {
POINTS: string;
LINES: string;
LINE_STRIP: string;
TRIANGLES: string;
TRIANGLE_STRIP: string;
};
/**
* The different types of vertex formats supported by the renderer
* @memberof rendering
*/
export type VertexFormat = 'uint8x2' | 'uint8x4' | 'sint8x2' | 'sint8x4' | 'unorm8x2' | 'unorm8x4' | 'snorm8x2' | 'snorm8x4' | 'uint16x2' | 'uint16x4' | 'sint16x2' | 'sint16x4' | 'unorm16x2' | 'unorm16x4' | 'snorm16x2' | 'snorm16x4' | 'float16x2' | 'float16x4' | 'float32' | 'float32x2' | 'float32x3' | 'float32x4' | 'uint32' | 'uint32x2' | 'uint32x3' | 'uint32x4' | 'sint32' | 'sint32x2' | 'sint32x3' | 'sint32x4';

View File

@@ -0,0 +1,21 @@
'use strict';
var deprecation = require('../../../../utils/logging/deprecation.js');
"use strict";
const DEPRECATED_DRAW_MODES = {
POINTS: "point-list",
LINES: "line-list",
LINE_STRIP: "line-strip",
TRIANGLES: "triangle-list",
TRIANGLE_STRIP: "triangle-strip"
};
const DRAW_MODES = new Proxy(DEPRECATED_DRAW_MODES, {
get(target, prop) {
deprecation.deprecation(deprecation.v8_0_0, `DRAW_MODES.${prop} is deprecated, use '${DEPRECATED_DRAW_MODES[prop]}' instead`);
return target[prop];
}
});
exports.DRAW_MODES = DRAW_MODES;
//# sourceMappingURL=const.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"const.js","sources":["../../../../../src/rendering/renderers/shared/geometry/const.ts"],"sourcesContent":["import { deprecation, v8_0_0 } from '../../../../utils/logging/deprecation';\n\n/**\n * The different topology types supported by the renderer used to describe how the geometry should be renderer\n * @memberof rendering\n */\nexport type Topology =\n 'point-list'\n | 'line-list'\n | 'line-strip'\n | 'triangle-list'\n | 'triangle-strip';\n\nconst DEPRECATED_DRAW_MODES = {\n POINTS: 'point-list',\n LINES: 'line-list',\n LINE_STRIP: 'line-strip',\n TRIANGLES: 'triangle-list',\n TRIANGLE_STRIP: 'triangle-strip',\n};\n\n/** @deprecated since 8.0.0 */\nexport const DRAW_MODES = new Proxy(DEPRECATED_DRAW_MODES, {\n get(target, prop: keyof typeof DEPRECATED_DRAW_MODES)\n {\n // #if _DEBUG\n deprecation(v8_0_0, `DRAW_MODES.${prop} is deprecated, use '${DEPRECATED_DRAW_MODES[prop]}' instead`);\n // #endif\n\n return target[prop];\n },\n});\n\n/**\n * The different types of vertex formats supported by the renderer\n * @memberof rendering\n */\nexport type VertexFormat =\n | 'uint8x2'\n | 'uint8x4'\n | 'sint8x2'\n | 'sint8x4'\n | 'unorm8x2'\n | 'unorm8x4'\n | 'snorm8x2'\n | 'snorm8x4'\n | 'uint16x2'\n | 'uint16x4'\n | 'sint16x2'\n | 'sint16x4'\n | 'unorm16x2'\n | 'unorm16x4'\n | 'snorm16x2'\n | 'snorm16x4'\n | 'float16x2'\n | 'float16x4'\n | 'float32'\n | 'float32x2'\n | 'float32x3'\n | 'float32x4'\n | 'uint32'\n | 'uint32x2'\n | 'uint32x3'\n | 'uint32x4'\n | 'sint32'\n | 'sint32x2'\n | 'sint32x3'\n | 'sint32x4';\n\n"],"names":["deprecation","v8_0_0"],"mappings":";;;;;AAaA,MAAM,qBAAwB,GAAA;AAAA,EAC1B,MAAQ,EAAA,YAAA;AAAA,EACR,KAAO,EAAA,WAAA;AAAA,EACP,UAAY,EAAA,YAAA;AAAA,EACZ,SAAW,EAAA,eAAA;AAAA,EACX,cAAgB,EAAA,gBAAA;AACpB,CAAA,CAAA;AAGa,MAAA,UAAA,GAAa,IAAI,KAAA,CAAM,qBAAuB,EAAA;AAAA,EACvD,GAAA,CAAI,QAAQ,IACZ,EAAA;AAEI,IAAAA,uBAAA,CAAYC,oBAAQ,CAAc,WAAA,EAAA,IAAI,wBAAwB,qBAAsB,CAAA,IAAI,CAAC,CAAW,SAAA,CAAA,CAAA,CAAA;AAGpG,IAAA,OAAO,OAAO,IAAI,CAAA,CAAA;AAAA,GACtB;AACJ,CAAC;;;;"}

View File

@@ -0,0 +1,19 @@
import { deprecation, v8_0_0 } from '../../../../utils/logging/deprecation.mjs';
"use strict";
const DEPRECATED_DRAW_MODES = {
POINTS: "point-list",
LINES: "line-list",
LINE_STRIP: "line-strip",
TRIANGLES: "triangle-list",
TRIANGLE_STRIP: "triangle-strip"
};
const DRAW_MODES = new Proxy(DEPRECATED_DRAW_MODES, {
get(target, prop) {
deprecation(v8_0_0, `DRAW_MODES.${prop} is deprecated, use '${DEPRECATED_DRAW_MODES[prop]}' instead`);
return target[prop];
}
});
export { DRAW_MODES };
//# sourceMappingURL=const.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"const.mjs","sources":["../../../../../src/rendering/renderers/shared/geometry/const.ts"],"sourcesContent":["import { deprecation, v8_0_0 } from '../../../../utils/logging/deprecation';\n\n/**\n * The different topology types supported by the renderer used to describe how the geometry should be renderer\n * @memberof rendering\n */\nexport type Topology =\n 'point-list'\n | 'line-list'\n | 'line-strip'\n | 'triangle-list'\n | 'triangle-strip';\n\nconst DEPRECATED_DRAW_MODES = {\n POINTS: 'point-list',\n LINES: 'line-list',\n LINE_STRIP: 'line-strip',\n TRIANGLES: 'triangle-list',\n TRIANGLE_STRIP: 'triangle-strip',\n};\n\n/** @deprecated since 8.0.0 */\nexport const DRAW_MODES = new Proxy(DEPRECATED_DRAW_MODES, {\n get(target, prop: keyof typeof DEPRECATED_DRAW_MODES)\n {\n // #if _DEBUG\n deprecation(v8_0_0, `DRAW_MODES.${prop} is deprecated, use '${DEPRECATED_DRAW_MODES[prop]}' instead`);\n // #endif\n\n return target[prop];\n },\n});\n\n/**\n * The different types of vertex formats supported by the renderer\n * @memberof rendering\n */\nexport type VertexFormat =\n | 'uint8x2'\n | 'uint8x4'\n | 'sint8x2'\n | 'sint8x4'\n | 'unorm8x2'\n | 'unorm8x4'\n | 'snorm8x2'\n | 'snorm8x4'\n | 'uint16x2'\n | 'uint16x4'\n | 'sint16x2'\n | 'sint16x4'\n | 'unorm16x2'\n | 'unorm16x4'\n | 'snorm16x2'\n | 'snorm16x4'\n | 'float16x2'\n | 'float16x4'\n | 'float32'\n | 'float32x2'\n | 'float32x3'\n | 'float32x4'\n | 'uint32'\n | 'uint32x2'\n | 'uint32x3'\n | 'uint32x4'\n | 'sint32'\n | 'sint32x2'\n | 'sint32x3'\n | 'sint32x4';\n\n"],"names":[],"mappings":";;;AAaA,MAAM,qBAAwB,GAAA;AAAA,EAC1B,MAAQ,EAAA,YAAA;AAAA,EACR,KAAO,EAAA,WAAA;AAAA,EACP,UAAY,EAAA,YAAA;AAAA,EACZ,SAAW,EAAA,eAAA;AAAA,EACX,cAAgB,EAAA,gBAAA;AACpB,CAAA,CAAA;AAGa,MAAA,UAAA,GAAa,IAAI,KAAA,CAAM,qBAAuB,EAAA;AAAA,EACvD,GAAA,CAAI,QAAQ,IACZ,EAAA;AAEI,IAAA,WAAA,CAAY,QAAQ,CAAc,WAAA,EAAA,IAAI,wBAAwB,qBAAsB,CAAA,IAAI,CAAC,CAAW,SAAA,CAAA,CAAA,CAAA;AAGpG,IAAA,OAAO,OAAO,IAAI,CAAA,CAAA;AAAA,GACtB;AACJ,CAAC;;;;"}

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":"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"}

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":"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"}

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 = 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,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;;;;"}