Skip to content

Conversation

@Angel98518
Copy link

  • Add comprehensive JSDoc comments for array utility functions (arrayMin, arrayMax, arrayNeedsUint32)
  • Document typed array utilities (TYPED_ARRAYS constant and getTypedArray function)
  • Add documentation for DOM element creation functions (createElementNS, createCanvasElement)
  • Document console logging system (setConsoleFunction, getConsoleFunction, log, warn, error, warnOnce)
  • Add detailed JSDoc for WebGL synchronization function (probeAsync)
  • Document projection matrix conversion functions (toNormalizedProjectionMatrix, toReversedProjectionMatrix)
  • Include parameter types, return types, and detailed descriptions for all documented functions

This improves code maintainability and helps developers understand the purpose and usage of utility functions.

Related issue: #XXXX

Description

A clear and concise description of what the problem was and how this pull request solves it.

This contribution is funded by Example

- Add comprehensive JSDoc comments for array utility functions (arrayMin, arrayMax, arrayNeedsUint32)
- Document typed array utilities (TYPED_ARRAYS constant and getTypedArray function)
- Add documentation for DOM element creation functions (createElementNS, createCanvasElement)
- Document console logging system (setConsoleFunction, getConsoleFunction, log, warn, error, warnOnce)
- Add detailed JSDoc for WebGL synchronization function (probeAsync)
- Document projection matrix conversion functions (toNormalizedProjectionMatrix, toReversedProjectionMatrix)
- Include parameter types, return types, and detailed descriptions for all documented functions

This improves code maintainability and helps developers understand the purpose and usage of utility functions.
@github-actions
Copy link

github-actions bot commented Jan 13, 2026

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 355.57
84.48
355.57
84.48
+0 B
+0 B
WebGPU 621.09
172.46
621.09
172.46
+0 B
+0 B
WebGPU Nodes 619.7
172.22
619.7
172.22
+0 B
+0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 487.81
119.38
487.81
119.38
+0 B
+0 B
WebGPU 692.03
187.85
692.03
187.85
+0 B
+0 B
WebGPU Nodes 641.83
175.02
641.83
175.02
+0 B
+0 B

*
* @param {Array<number>} array - The array to search for the minimum value.
* @return {number} The minimum value in the array, or Infinity if the array is empty.
*/
Copy link
Collaborator

@Mugen87 Mugen87 Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for createCanvasElement(), setConsoleFunction(), getConsoleFunction(), log(), warn(), error(), warnOnce(), none of these functions are part of the public API so add the @private tag to them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean that Except for createCanvasElement(), setConsoleFunction(), getConsoleFunction(), log(), warn(), error(), warnOnce(), add @Private tag?

As requested by @Mugen87, marking all documented utility functions as @Private since they are not part of the public API.
src/utils.js Outdated
* display style set to 'block', which is commonly used in three.js
* rendering contexts to avoid inline element spacing issues.
*
* @private
Copy link
Collaborator

@Mugen87 Mugen87 Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exported functions should not be private, see

export { createCanvasElement, setConsoleFunction, getConsoleFunction, log, warn, error, warnOnce } from './utils.js';

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all exported functions should not be private?

Copy link
Collaborator

@Mugen87 Mugen87 Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these can be used by the developer and should be part of the public documentation.

* Map of typed array constructor names to their constructors.
* This mapping enables dynamic creation of typed arrays based on string type names.
*
* @constant
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be private as well.

Daniel added 4 commits January 14, 2026 14:36
As requested by @Mugen87, removed @Private tags from all exported utility functions since they are part of the public API.
As requested by @Mugen87, added @Private tag to functions that are not part of the public API:
- arrayMin, arrayMax, arrayNeedsUint32
- getTypedArray
- createCanvasElement
- probeAsync
- toNormalizedProjectionMatrix, toReversedProjectionMatrix

Public API functions (without @Private):
- createElementNS, setConsoleFunction, getConsoleFunction
- log, warn, error, warnOnce
- Add @Private to TYPED_ARRAYS constant (as requested)
- Remove @Private from createCanvasElement() since it's exported
Removed @Private tags from all exported functions as requested:
- arrayMin, arrayMax, arrayNeedsUint32
- getTypedArray
- probeAsync
- toNormalizedProjectionMatrix, toReversedProjectionMatrix

TYPED_ARRAYS constant keeps @Private as it's not exported.
@Angel98518
Copy link
Author

I have fixed feedback. Please check

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 14, 2026

This ins't correct since a lot of private tags are missing.

As requested by @Mugen87, added @Private tags to functions that are NOT part of the public API.

Public API functions (no @Private):
- createCanvasElement, setConsoleFunction, getConsoleFunction
- log, warn, error, warnOnce

Private functions (with @Private):
- arrayMin, arrayMax, arrayNeedsUint32
- getTypedArray, createElementNS
- probeAsync
- toNormalizedProjectionMatrix, toReversedProjectionMatrix
- TYPED_ARRAYS constant
@Angel98518
Copy link
Author

This ins't correct since a lot of private tags are missing.

Fixed this. Could you check again please?
Sorry

@Angel98518
Copy link
Author

@Mugen87
Can you check my updates?

/**
* Internal cache for tracking warning messages to prevent duplicate warnings.
*
* @type {Object<string, boolean>}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be private as well.

/**
* Custom console function handler for intercepting log, warn, and error calls.
*
* @type {Function|null}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And add private here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this.

Added @Private tags to:
- _cache constant (internal warning message cache)
- _setConsoleFunction variable (internal console function handler)

These are internal implementation details and should be marked as private.
@Angel98518
Copy link
Author

Hi.
@Mugen87
What about my updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants