Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes vertex-format type fix #6124

Merged
merged 16 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/platform/graphics/vertex-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,8 @@ const deviceCache = new DeviceCache();
*/
class VertexFormat {
/**
* Create a new VertexFormat instance.
*
* @param {import('./graphics-device.js').GraphicsDevice} graphicsDevice - The graphics device
* used to manage this vertex format.
* @param {object[]} description - An array of vertex attribute descriptions.
* @param {string} description[].semantic - The meaning of the vertex element. This is used to
* @typedef {object} AttributeDescription
* @property {string} semantic - The meaning of the vertex element. This is used to
* link the vertex data to a shader input. Can be:
*
* - {@link SEMANTIC_POSITION}
Expand All @@ -90,9 +86,9 @@ class VertexFormat {
*
* If vertex data has a meaning other that one of those listed above, use the user-defined
* semantics: {@link SEMANTIC_ATTR0} to {@link SEMANTIC_ATTR15}.
* @param {number} description[].components - The number of components of the vertex attribute.
* @property {number} components - The number of components of the vertex attribute.
* Can be 1, 2, 3 or 4.
* @param {number} description[].type - The data type of the attribute. Can be:
* @property {number} type - The data type of the attribute. Can be:
*
* - {@link TYPE_INT8}
* - {@link TYPE_UINT8}
Expand All @@ -103,13 +99,21 @@ class VertexFormat {
* - {@link TYPE_FLOAT16}
* - {@link TYPE_FLOAT32}
*
* @param {boolean} [description[].normalize] - If true, vertex attribute data will be mapped
* @property {boolean} [normalize] - If true, vertex attribute data will be mapped
* from a 0 to 255 range down to 0 to 1 when fed to a shader. If false, vertex attribute data
* is left unchanged. If this property is unspecified, false is assumed. This property is
* ignored when asInt is true.
* @param {boolean} [description[].asInt] - If true, vertex attribute data will be accessible
* @property {boolean} [asInt] - If true, vertex attribute data will be accessible
* as integer numbers in shader code. Defaults to false, which means that vertex attribute data
* will be accessible as floating point numbers. Can be only used with INT and UINT data types.
*/

/**
* Create a new VertexFormat instance.
*
* @param {import('./graphics-device.js').GraphicsDevice} graphicsDevice - The graphics device
* used to manage this vertex format.
* @param {AttributeDescription[]} description - An array of vertex attribute descriptions.
* @param {number} [vertexCount] - When specified, vertex format will be set up for
* non-interleaved format with a specified number of vertices. (example: PPPPNNNNCCCC), where
* arrays of individual attributes will be stored one right after the other (subject to
Expand Down
10 changes: 3 additions & 7 deletions utils/types-fixup.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import fs from 'fs';

// Fix up description parameter for VertexFormat constructor because tsc
// doesn't recognize it as an array
let path = './types/platform/graphics/vertex-format.d.ts';
let dts = fs.readFileSync(path, 'utf8');
dts = dts.replace('}, vertexCount?: number);', '}[], vertexCount?: number);');
fs.writeFileSync(path, dts);

// A regex that matches a string starting with 'constructor' and ending with ');'
const regexConstructor = /constructor(.*?)\);/g;

Expand All @@ -23,6 +16,9 @@ const getDeclarations = (properties) => {

return declarations;
};

let path, dts;

const elementComponentProps = [
['alignment', 'Vec2'],
['autoFitHeight', 'boolean'],
Expand Down