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 14 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
25 changes: 15 additions & 10 deletions src/platform/graphics/vertex-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,11 @@ const deviceCache = new DeviceCache();
* @property {number} elements[].size The size of the attribute in bytes.
* @category Graphics
*/

kpal81xd marked this conversation as resolved.
Show resolved Hide resolved
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 +87,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 +100,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
11 changes: 2 additions & 9 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 Down Expand Up @@ -41,8 +34,8 @@ const buttonComponentProps = [
['transitionMode', 'number']
];

path = './types/framework/components/button/component.d.ts';
dts = fs.readFileSync(path, 'utf8');
let path = './types/framework/components/button/component.d.ts';
let dts = fs.readFileSync(path, 'utf8');
dts = dts.replace(regexConstructor, '$&\n' + getDeclarations(buttonComponentProps));
// We need to import types that are newly introduced in the property list above
dts += `
Expand Down