Skip to content

Commit c9d07c1

Browse files
committed
docs: fix JSDoc syntax for p5.js compatibility
1 parent 8e199d8 commit c9d07c1

File tree

1 file changed

+34
-52
lines changed

1 file changed

+34
-52
lines changed

src/webgl/ShaderGenerator.js

Lines changed: 34 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,31 +1642,20 @@ if (typeof p5 !== 'undefined') {
16421642

16431643

16441644
/* ------------------------------------------------------------- */
1645-
/**
1646-
* @typedef {Object} Vertex
1647-
* @property {{x: number, y: number, z: number}} position - The position of the vertex in world space.
1648-
* @property {{x: number, y: number, z: number}} normal - The normal vector at the vertex in world space.
1649-
* @property {{x: number, y: number}} texCoord - The texture coordinates (x, y) for the vertex.
1650-
* @property {{r: number, g: number, b: number, a: number}} color - The color at the vertex.
1651-
*/
1652-
16531645
/**
16541646
* @function getWorldInputs
16551647
* @experimental
16561648
* @description
1657-
* Registers a callback to modify the world-space properties of each vertex in a shader. This hook can be used inside {@link p5.baseMaterialShader}.modify() and similar shader modify calls to customize vertex positions, normals, texture coordinates, and colors before rendering. "World space" refers to the coordinate system of the 3D scene, before any camera or projection transformations are applied.
1649+
* Registers a callback to modify the world-space properties of each vertex in a shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() and similar shader modify calls to customize vertex positions, normals, texture coordinates, and colors before rendering. "World space" refers to the coordinate system of the 3D scene, before any camera or projection transformations are applied.
16581650
*
16591651
* This hook is available in:
1660-
* - {@link p5.baseMaterialShader}
1661-
* - {@link p5.baseNormalShader}
1662-
* - {@link p5.baseColorShader}
1663-
* - {@link p5.baseStrokeShader}
1652+
* - <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>
1653+
* - <a href="#/p5/baseNormalShader">baseNormalShader()</a>
1654+
* - <a href="#/p5/baseColorShader">baseColorShader()</a>
1655+
* - <a href="#/p5/baseStrokeShader">baseStrokeShader()</a>
16641656
*
1665-
* @param {function(Vertex): Vertex} callback
1666-
* A callback function which receives and returns a Vertex struct.
1667-
*
1668-
* @see {@link p5.baseMaterialShader}
1669-
* @see {@link p5.Shader#modify}
1657+
* @param {function} callback
1658+
* A callback function which receives a vertex object containing position (vec3), normal (vec3), texCoord (vec2), and color (vec4) properties. The function should return the modified vertex object.
16701659
*
16711660
* @example
16721661
* <div modernizr='webgl'>
@@ -1700,19 +1689,16 @@ if (typeof p5 !== 'undefined') {
17001689
* @function combineColors
17011690
* @experimental
17021691
* @description
1703-
* Registers a callback to customize how color components are combined in the fragment shader. This hook can be used inside {@link p5.baseMaterialShader}.modify() and similar shader modify calls to control the final color output of a material. The callback receives a ColorComponents struct and should return an object with a `color` property ({ r, g, b }) and an `opacity` property (number).
1692+
* Registers a callback to customize how color components are combined in the fragment shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() and similar shader modify calls to control the final color output of a material. The callback receives color components (baseColor, diffuse, ambientColor, ambient, specularColor, specular, emissive, opacity) and returns a vec4 for the final color.
17041693
*
17051694
* This hook is available in:
1706-
* - {@link p5.baseMaterialShader}
1707-
* - {@link p5.baseNormalShader}
1708-
* - {@link p5.baseColorShader}
1709-
* - {@link p5.baseStrokeShader}
1710-
*
1711-
* @param {function(ColorComponents): { color: {r: number, g: number, b: number}, opacity: number }} callback
1712-
* A callback function which receives a ColorComponents struct and returns the final color and opacity.
1695+
* - <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>
1696+
* - <a href="#/p5/baseNormalShader">baseNormalShader()</a>
1697+
* - <a href="#/p5/baseColorShader">baseColorShader()</a>
1698+
* - <a href="#/p5/baseStrokeShader">baseStrokeShader()</a>
17131699
*
1714-
* @see {@link p5.baseMaterialShader}
1715-
* @see {@link p5.Shader#modify}
1700+
* @param {function} callback
1701+
* A callback function which receives color components (baseColor, diffuse, ambientColor, ambient, specularColor, specular, emissive, opacity) and returns a vec4 for the final color.
17161702
*
17171703
* @example
17181704
* <div modernizr='webgl'>
@@ -1723,21 +1709,20 @@ if (typeof p5 !== 'undefined') {
17231709
* myShader = baseMaterialShader().modify(() => {
17241710
* combineColors(components => {
17251711
* // Custom color combination: add a red tint
1726-
* let color = {
1727-
* r: components.baseColor.r * components.diffuse.r +
1728-
* components.ambientColor.r * components.ambient.r +
1729-
* components.specularColor.r * components.specular.r +
1730-
* components.emissive.r + 0.2,
1731-
* g: components.baseColor.g * components.diffuse.g +
1732-
* components.ambientColor.g * components.ambient.g +
1733-
* components.specularColor.g * components.specular.g +
1734-
* components.emissive.g,
1735-
* b: components.baseColor.b * components.diffuse.b +
1736-
* components.ambientColor.b * components.ambient.b +
1737-
* components.specularColor.b * components.specular.b +
1738-
* components.emissive.b
1739-
* };
1740-
* return { color, opacity: components.opacity };
1712+
* let r = components.baseColor.r * components.diffuse.r +
1713+
* components.ambientColor.r * components.ambient.r +
1714+
* components.specularColor.r * components.specular.r +
1715+
* components.emissive.r + 0.2;
1716+
* let g = components.baseColor.g * components.diffuse.g +
1717+
* components.ambientColor.g * components.ambient.g +
1718+
* components.specularColor.g * components.specular.g +
1719+
* components.emissive.g;
1720+
* let b = components.baseColor.b * components.diffuse.b +
1721+
* components.ambientColor.b * components.ambient.b +
1722+
* components.specularColor.b * components.specular.b +
1723+
* components.emissive.b;
1724+
* let a = components.opacity;
1725+
* return vec4(r, g, b, a);
17411726
* });
17421727
* });
17431728
* }
@@ -1757,20 +1742,17 @@ if (typeof p5 !== 'undefined') {
17571742
* @function getPointSize
17581743
* @experimental
17591744
* @description
1760-
* Registers a callback to modify the size of points when rendering with a shader. This hook can be used inside {@link p5.baseMaterialShader}.modify() or similar, when drawing points (e.g., with the point() function in WEBGL mode). The callback receives the current point size (number) and should return the new size (number).
1745+
* Registers a callback to modify the size of points when rendering with a shader. This hook can be used inside <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>.modify() or similar, when drawing points (e.g., with the point() function in WEBGL mode). The callback receives the current point size (number) and should return the new size (number).
17611746
*
17621747
* This hook is available in:
1763-
* - {@link p5.baseMaterialShader}
1764-
* - {@link p5.baseNormalShader}
1765-
* - {@link p5.baseColorShader}
1766-
* - {@link p5.baseStrokeShader}
1748+
* - <a href="#/p5/baseMaterialShader">baseMaterialShader()</a>
1749+
* - <a href="#/p5/baseNormalShader">baseNormalShader()</a>
1750+
* - <a href="#/p5/baseColorShader">baseColorShader()</a>
1751+
* - <a href="#/p5/baseStrokeShader">baseStrokeShader()</a>
17671752
*
1768-
* @param {function(size: number): number} callback
1753+
* @param {function} callback
17691754
* A callback function which receives and returns the point size.
17701755
*
1771-
* @see {@link p5.baseMaterialShader}
1772-
* @see {@link p5.Shader#modify}
1773-
*
17741756
* @example
17751757
* <div modernizr='webgl'>
17761758
* <code>

0 commit comments

Comments
 (0)