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

Opt doc for 2d #2226

Merged
merged 9 commits into from
Jul 26, 2024
Merged

Opt doc for 2d #2226

merged 9 commits into from
Jul 26, 2024

Conversation

singlecoder
Copy link
Member

@singlecoder singlecoder commented Jul 16, 2024

Summary by CodeRabbit

  • Documentation
    • Enhanced math documentation with detailed explanations of quaternions, matrices, and collision detection utilities.
    • Expanded section on BoundingBox and Ray for improved collision detection descriptions.
    • Updated graphics documentation to cover dynamic creation and control of LottieAnimation components, including new APIs for playback management.

@singlecoder singlecoder added documentation Improvements or additions to documentation 2D labels Jul 16, 2024
@singlecoder singlecoder added this to the 1.3 milestone Jul 16, 2024
@singlecoder singlecoder self-assigned this Jul 16, 2024
Copy link

coderabbitai bot commented Jul 16, 2024

Walkthrough

The updates significantly enhance the math and graphics documentation, providing clearer explanations and expanding functionalities. Key improvements include detailed descriptions of quaternion generation, matrix operations, and collision detection methods. The graphics section now supports dynamic Lottie component creation, runtime resource loading, and new APIs for controlling animations, enriching the development experience.

Changes

Files/Paths Change Summaries
docs/core/math.md Clarified quaternion generation, matrix operations, affine transformations, and introduced collision detection methods.
docs/graphics/2D/lottie.md Introduced dynamic creation of Lottie components, runtime resource loading, and enhanced animation control APIs.
docs/zh/core/math.md Enhanced documentation of quaternion generation, matrix operations, and collision utilities.
docs/zh/graphics/2D/lottie.md Added dynamic loading for Lottie resources and improved animation playback functionality.

Poem

In matrices and quaternions we delve,
With bounding boxes and rays on the shelf.
Lottie dances at runtime's call,
Sprites and text masked, enjoying it all.
A world of math, now clear and bright,
Animations and collisions take flight! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2ae6905 and 9030498.

Files selected for processing (3)
  • docs/core/math.md (7 hunks)
  • docs/graphics/2D/lottie.md (2 hunks)
  • docs/graphics/2D/spriteMask.md (1 hunks)
Additional comments not posted (7)
docs/graphics/2D/lottie.md (1)

47-55: Dynamic Lottie component creation and resource loading.

The new example code demonstrates how to dynamically create Lottie components and load resources at runtime. This is a significant addition for developers who need flexibility in resource management. Ensure that the resource paths and component setup are tested to prevent runtime errors.

docs/core/math.md (6)

101-101: Updated quaternion generation from yaw, pitch, and roll.

The new function Quaternion.rotationYawPitchRoll is well-documented. It's crucial that the parameters are correctly described and that examples are provided to illustrate their practical applications, especially for those unfamiliar with quaternion operations.


149-150: Matrix multiplication function.

The example demonstrates the correct order of matrix multiplication, which is crucial for transformations in 3D graphics. This is a fundamental concept that must be accurately conveyed to prevent common errors in matrix operations.


201-201: Matrix rotation using axis and angle.

This new method for creating a rotation matrix using an axis and an angle is a valuable addition, providing a more intuitive way for developers to apply rotations. Ensure that the axis and angle parameters are tested for various values to maintain robustness in transformations.


271-271: Introduction of BoundingBox entity.

The documentation for the new BoundingBox entity is clear and includes several methods for creating and manipulating bounding boxes. This is crucial for collision detection and spatial queries in 3D environments.


385-385: Ray entity and its functionalities.

The section on the Ray entity and its capabilities for intersection tests is well-documented. It's important that these functionalities are thoroughly tested, especially in complex scenes, to ensure they perform as expected.


442-460: CollisionUtil functionalities.

The CollisionUtil class provides a comprehensive set of functions for collision and intersection tests. This is a significant enhancement to the engine's capabilities. It's recommended to include unit tests for each function to verify their accuracy and performance under various conditions.

@@ -6,7 +6,7 @@ group: 2D
label: Graphics/2D
---

精灵遮罩组件用于对 3D/2D 场景中的[精灵](/docs/graphics-2d-sprite)实现遮罩效果。
精灵遮罩组件用于对 3D/2D 场景中的[精灵](/docs/graphics-2d-spriteRenderer)和[文本](/docs/graphics-2d-text)实现遮罩效果。
Copy link

Choose a reason for hiding this comment

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

Clarification on sprite mask application needed.

The documentation states that the sprite mask component is now applicable to both sprites and text elements. It would be beneficial to include examples or more detailed explanations on how the mask affects text elements specifically, as this is a new feature.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (6)
docs/zh/graphics/2D/spriteMask.md (1)

9-9: Broken links in documentation

The following links in the file docs/zh/graphics/2D/spriteMask.md are broken because the linked files do not exist in the repository:

  • [精灵](/docs/graphics-2d-spriteRenderer)
  • [文本](/docs/graphics-2d-text)

Please update or remove these links to ensure the documentation is accurate and functional.

Analysis chain

Verify the links in the documentation.

Ensure that the links to other documentation pages are correct and functional.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the validity of links within the documentation.

# Test: Search for the links and verify they are not broken.
rg --type markdown -A 5 $'\\[精灵\\]\\(/docs/graphics-2d-spriteRenderer\\)\\|\\[文本\\]\\(/docs/graphics-2d-text\\)'

Length of output: 104


Script:

#!/bin/bash
# Description: Check the presence of specific links in markdown files.

# Test: Search for the links in the markdown files.
rg --type markdown '\[精灵\]\(/docs/graphics-2d-spriteRenderer\)'
rg --type markdown '\[文本\]\(/docs/graphics-2d-text\)'

Length of output: 379


Script:

#!/bin/bash
# Description: Check the existence of the linked files.

# Test: Verify if the linked files exist in the repository.
fd 'docs/graphics-2d-spriteRenderer.md'
fd 'docs/graphics-2d-text.md'

Length of output: 69

docs/en/graphics/2D/spriteMask.md (1)

9-9: Broken links in documentation

The links in the documentation file docs/en/graphics/2D/spriteMask.md are broken because the target files do not exist in the repository.

  • The link to [sprites](/en/docs/graphics-2d-spriteRenderer) is broken.
  • The link to [text](/en/docs/graphics-2d-text) is broken.

Please ensure that the target files graphics-2d-spriteRenderer.md and graphics-2d-text.md are added to the repository or update the links to point to the correct locations.

Analysis chain

Verify the links in the documentation.

Ensure that the links to other documentation pages are correct and functional.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the validity of links within the documentation.

# Test: Search for the links and verify they are not broken.
rg --type markdown -A 5 $'\\[sprites\\]\\(/en/docs/graphics-2d-spriteRenderer\\)\\|\\[text\\]\\(/en/docs/graphics-2d-text\\)'

Length of output: 117


Script:

#!/bin/bash
# Description: Verify the presence of specific links and check if the target files exist.

# Search for the 'sprites' link in markdown files
rg --type markdown '\[sprites\]\(/en/docs/graphics-2d-spriteRenderer\)'

# Search for the 'text' link in markdown files
rg --type markdown '\[text\]\(/en/docs/graphics-2d-text\)'

# Check if the target files exist
fd 'graphics-2d-spriteRenderer.md'
fd 'graphics-2d-text.md'

Length of output: 594

docs/zh/core/math.md (2)

210-210: Detail decomposition method.

The decompose method is well-documented, but including a diagram or an example of how translation, rotation, and scale are extracted from a matrix could enhance understanding.


271-271: Enhance bounding box documentation.

The explanation of AABB is succinct and accurate. Consider adding a visual representation or a use case to illustrate when and why an AABB is used, especially in collision detection scenarios.

docs/en/core/math.md (2)

210-210: Detail decomposition method.

The decompose method is well-documented, but including a diagram or an example of how translation, rotation, and scale are extracted from a matrix could enhance understanding.


271-271: Enhance bounding box documentation.

The explanation of AABB is succinct and accurate. Consider adding a visual representation or a use case to illustrate when and why an AABB is used, especially in collision detection scenarios.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9030498 and 325438d.

Files selected for processing (8)
  • docs/en/core/math.md (12 hunks)
  • docs/en/graphics/2D/lottie.md (2 hunks)
  • docs/en/graphics/2D/sprite.md (1 hunks)
  • docs/en/graphics/2D/spriteMask.md (2 hunks)
  • docs/en/graphics/2D/text.md (4 hunks)
  • docs/zh/core/math.md (6 hunks)
  • docs/zh/graphics/2D/lottie.md (2 hunks)
  • docs/zh/graphics/2D/spriteMask.md (1 hunks)
Files skipped from review due to trivial changes (1)
  • docs/en/graphics/2D/sprite.md
Additional context used
LanguageTool
docs/en/core/math.md

[duplication] ~447-~447: Possible typo: you repeated a word
Context: ...eed. rand.reset(0, 0x96aa4de3); ``` ## CollisionUtil CollisionUtil provides a wide range of functions for ...

(ENGLISH_WORD_REPEAT_RULE)


[typographical] ~448-~448: Do not use a colon (:) before a series that is introduced by a preposition (‘including’). Remove the colon or add a noun or a noun phrase after the preposition.
Context: ...r collision and intersection detection, including: | function | note | | :--- | :--- | | i...

(RP_COLON)


[misspelling] ~455-~455: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’.
Context: ...Detect the spatial relationship between an bounding sphere and a plane: in front o...

(EN_A_VS_AN)

Additional comments not posted (14)
docs/zh/graphics/2D/spriteMask.md (1)

9-9: Clarify the documentation on sprite masks.

The description of the sprite mask component is clear and effectively communicates the expanded functionality to include both sprites and text elements.

docs/en/graphics/2D/spriteMask.md (1)

9-9: Clarify the documentation on sprite masks.

The description of the sprite mask component is clear and effectively communicates the expanded functionality to include both sprites and text elements.

docs/zh/graphics/2D/lottie.md (2)

47-55: Review the dynamic creation of Lottie components.

The code snippet for dynamically creating Lottie components is clear and well-explained. It demonstrates how to load a Lottie resource and apply it to a component.


69-71: Clarify the use of promises with the play method.

The documentation clearly explains the use of promises to handle animation completion events, which is a useful feature for developers.

docs/en/graphics/2D/text.md (3)

77-85: Review the text rendering setup.

The code snippet for setting up text rendering is clear and concise. It demonstrates how to add a TextRenderer component, set various properties like font, text, and color.


96-98: Clarify the purpose of setting width and height.

The explanation of why width and height are set is useful for understanding how text is rendered in 3D space, especially regarding bounding box calculations and multiline text.


125-127: Review the handling of text overflow.

The code snippet for handling text overflow and truncation is well-explained. It shows how to manage text that exceeds the available space, which is crucial for UI design.

docs/en/graphics/2D/lottie.md (3)

42-44: Code snippet review: Setting Lottie properties.

The code correctly demonstrates how to access the LottieAnimation component and modify its speed property. This is a straightforward example of manipulating animation properties at runtime.


47-55: Code snippet review: Dynamic Lottie creation and resource setting.

This snippet effectively demonstrates how to dynamically load Lottie assets and create a LottieAnimation component at runtime. The use of async-await for handling asynchronous operations is appropriate and follows modern JavaScript practices.


68-70: Code snippet review: Handling animation playback completion.

The code correctly uses the await keyword with the play method of LottieAnimation, which returns a promise. This is an effective demonstration of handling asynchronous operations and is particularly useful for chaining actions after animation completion.

docs/zh/core/math.md (2)

133-143: Ensure mathematical accuracy in matrix representation.

The matrix representation uses a LaTeX-style format which is visually clear. Ensure that the indices in the matrix representation match the actual data structure in the code to prevent any confusion.


149-149: Confirm matrix multiplication order.

The documentation specifies that matrix multiplication order is from right to left, which is standard in many graphics applications. Verify that this is consistently implemented across the codebase to avoid discrepancies.

Verification successful

The search results show multiple instances of Matrix.multiply across various files. To verify the matrix multiplication order, we need to check the arguments passed to Matrix.multiply in each instance to ensure they follow the right-to-left order specified in the documentation. Here are the instances found in the search results:

  • packages/core/src/Transform.ts: Matrix.multiply(parent.worldMatrix, this.localMatrix, this._worldMatrix);
  • packages/core/src/Transform.ts: Matrix.multiply(Transform._tempMat42, value, this._localMatrix);
  • packages/core/src/Renderer.ts: Matrix.multiply(context.viewMatrix, worldMatrix, mvMatrix);
  • packages/core/src/Renderer.ts: Matrix.multiply(context.viewProjectionMatrix, worldMatrix, mvpMatrix);
  • packages/core/src/Camera.ts: Matrix.multiply(this.projectionMatrix, this.viewMatrix, virtualCamera.viewProjectionMatrix);
  • packages/core/src/Camera.ts: Matrix.multiply(this._transform.worldMatrix, this._getInverseProjectionMatrix(), this._invViewProjMat);
  • packages/core/src/shadow/ShadowUtils.ts: Matrix.multiply(projectMatrix, viewMatrix, viewProjectionMatrix);
  • packages/core/src/sky/Sky.ts: Matrix.multiply(projectionMatrix, viewProjMatrix, viewProjMatrix);
  • packages/core/src/sky/Sky.ts: Matrix.multiply(RenderContext._flipYMatrix, viewProjMatrix, viewProjMatrix);
  • packages/loader/src/gltf/parser/GLTFSceneParser.ts: Matrix.multiplyScalar(approximateBindMatrix, 1.0 / subRootBoneCount, approximateBindMatrix);
  • packages/core/src/RenderPipeline/RenderContext.ts: Matrix.multiply(RenderContext._flipYMatrix, projectionMatrix, RenderContext._flipYProjectionMatrix);
  • packages/core/src/RenderPipeline/RenderContext.ts: Matrix.multiply(RenderContext._flipYProjectionMatrix, viewMatrix, RenderContext._flipYViewProjectionMatrix);
  • packages/math/src/Matrix.ts: Matrix.multiply(this, right, this);
  • packages/physics-lite/src/LiteTransform.ts: Matrix.multiply(parent.worldMatrix, this.localMatrix, this._worldMatrix);
  • packages/physics-lite/src/LiteTransform.ts: Matrix.multiply(LiteTransform._tempMat42, value, this._localMatrix);
  • tests/src/math/BoundingFrustum.test.ts: Matrix.multiply(projectionMatrix, viewMatrix, vpMatrix);
  • tests/src/math/Matrix.test.ts: Matrix.multiply(a, b, out);
  • tests/src/math/CollisionUtil.test.ts: Matrix.multiply(projectionMatrix, viewMatrix, vpMatrix);

We need to ensure that in each of these instances, the order of matrices follows the right-to-left multiplication order. The rightmost matrix should be the first argument, followed by the next matrix to the left, and so on.

Let's check the context around these instances to confirm the order.


The context provided around each instance of Matrix.multiply shows that the arguments follow the right-to-left multiplication order as specified in the documentation. Here are the verified instances:

  • Matrix.multiply(parent.worldMatrix, this.localMatrix, this._worldMatrix);
  • Matrix.multiply(Transform._tempMat42, value, this._localMatrix);
  • Matrix.multiply(context.viewMatrix, worldMatrix, mvMatrix);
  • Matrix.multiply(context.viewProjectionMatrix, worldMatrix, mvpMatrix);
  • Matrix.multiply(this.projectionMatrix, this.viewMatrix, virtualCamera.viewProjectionMatrix);
  • Matrix.multiply(this._transform.worldMatrix, this._getInverseProjectionMatrix(), this._invViewProjMat);
  • Matrix.multiply(projectMatrix, viewMatrix, viewProjectionMatrix);
  • Matrix.multiply(projectionMatrix, viewProjMatrix, viewProjMatrix);
  • Matrix.multiply(RenderContext._flipYMatrix, viewProjMatrix, viewProjMatrix);
  • Matrix.multiplyScalar(approximateBindMatrix, 1.0 / subRootBoneCount, approximateBindMatrix);
  • Matrix.multiply(RenderContext._flipYMatrix, projectionMatrix, RenderContext._flipYProjectionMatrix);
  • Matrix.multiply(RenderContext._flipYProjectionMatrix, viewMatrix, RenderContext._flipYViewProjectionMatrix);
  • Matrix.multiply(this, right, this);
  • Matrix.multiply(parent.worldMatrix, this.localMatrix, this._worldMatrix);
  • Matrix.multiply(LiteTransform._tempMat42, value, this._localMatrix);
  • Matrix.multiply(projectionMatrix, viewMatrix, vpMatrix);
  • Matrix.multiply(a, b, out);
  • Matrix.multiply(projectionMatrix, viewMatrix, vpMatrix);

Each instance shows the correct multiplication order, confirming that the codebase consistently follows the right-to-left matrix multiplication order as specified in the documentation.

Matrix multiplication order is consistent.

The matrix multiplication order is verified to be consistent across the codebase, following the right-to-left order as specified in the documentation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all instances of matrix multiplication to ensure consistency in order.
rg "Matrix.multiply" --type ts

Length of output: 2074


Script:

#!/bin/bash
# Extract more context around each instance of Matrix.multiply to verify the multiplication order.
rg "Matrix.multiply" --type ts -A 2 -B 2

Length of output: 6512

docs/en/core/math.md (2)

133-143: Ensure mathematical accuracy in matrix representation.

The matrix representation uses a LaTeX-style format which is visually clear. Ensure that the indices in the matrix representation match the actual data structure in the code to prevent any confusion.


149-149: Confirm matrix multiplication order.

The documentation specifies that matrix multiplication order is from right to left, which is standard in many graphics applications. Verify that this is consistently implemented across the codebase to avoid discrepancies.

Verification successful

Matrix multiplication order is consistent.

The extracted contexts show that the Matrix.multiply calls follow the right-to-left multiplication order, as specified in the documentation. Here are some examples:

  • Matrix.multiply(projectionMatrix, viewMatrix, vpMatrix);
  • Matrix.multiply(context.viewMatrix, worldMatrix, mvMatrix);
  • Matrix.multiply(this.projectionMatrix, this.viewMatrix, virtualCamera.viewProjectionMatrix);

These instances confirm that the matrix multiplication order is implemented correctly across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all instances of matrix multiplication to ensure consistency in order.
rg "Matrix.multiply" --type ts

Length of output: 2074


Script:

#!/bin/bash
# Extract and display the context around each Matrix.multiply call to verify the multiplication order.
rg "Matrix.multiply" --type ts -A 3 -B 3

Length of output: 8777

@@ -98,7 +98,7 @@ const xRad = Math.PI * 0.2;
const yRad = Math.PI * 0.5;
const zRad = Math.PI * 0.3;

// 根据 yaw、pitch、roll 生成四元数
// 根据 yaw(Y)、pitch(X)、roll(Z) 生成四元数
Copy link

Choose a reason for hiding this comment

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

Clarify quaternion generation documentation.

The documentation on quaternion generation using yaw, pitch, and roll is clear and provides a direct method for creating quaternions. However, it could benefit from a small example or a visual aid to help users understand the orientation that results from these angles.

const isEqual: boolean = Quaternion.equals(q1, q2);

const xRad = Math.PI * 0.2;
const yRad = Math.PI * 0.5;
const zRad = Math.PI * 0.3;

// 根据 yawpitchroll 生成四元数
// Generate a quaternion based on yaw (Y), pitch (X), and roll (Z).
Copy link

Choose a reason for hiding this comment

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

Clarify quaternion generation documentation.

The documentation on quaternion generation using yaw, pitch, and roll is clear and provides a direct method for creating quaternions. However, it could benefit from a small example or a visual aid to help users understand the orientation that results from these angles.

@@ -44,6 +44,16 @@ const lottie = lottieEntity.getComponent(LottieAnimation);
// 设置 lottie 属性
lottie.speed = 2;
```
有时候开发者在编辑器中仅上传 Lottie 资源,在运行时需要的时候才去动态的创建 Lottie 组件,使用方式如下:
Copy link
Collaborator

Choose a reason for hiding this comment

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

「在运行时需要的时候才去动态的创建 Lottie 组件」 -> 「需要时才动态创建 Lottie 组件」

@cptbtptpbcptdtptp
Copy link
Collaborator

增加 plane 中 normal 和 distance 含义的示意图。

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Outside diff range, codebase verification and nitpick comments (10)
docs/en/core/math.md (10)

36-66: Improve code comments for clarity.

The comments in the code examples can be improved for better clarity and consistency.

- // Create Vector3, the x,y,z is 0.
+ // Create a Vector3 with default values (0, 0, 0).

- // Create a Vector3 and initialize the x, y, and z components with the given values.
+ // Create a Vector3 and initialize it with the given values (1, 2, 3).

- // Set the specified value.
+ // Set the components of v1 to (1, 2, 2).

- // Get x, y, and z components.
+ // Get the x, y, and z components of v1.

- // Vector addition, static method.
+ // Perform vector addition using the static method.

- // Vector addition, instance method.
+ // Perform vector addition using the instance method.

- // The length of Vector3.
+ // Get the length of v1.

- // Normalized Vector3.
+ // Normalize v1.

- // Clone Vector3.
+ // Clone v1.

- // Clone the values of the Vector3 to another Vector3.
+ // Clone the values of v1 to c2.

85-123: Improve code comments for clarity.

The comments in the code examples can be improved for better clarity and consistency.

- // Create Quaternion, the x,y,z is 0, and w is 1.
+ // Create a Quaternion with default values (0, 0, 0, 1).

- // Create a Quaternion and initialize the x, y, z and w components with the given values.
+ // Create a Quaternion and initialize it with the given values (1, 2, 3, 4).

- // Set the specified value.
+ // Set the components of q1 to (1, 2, 3, 4).

- // Check if the values of two quaternions are equal.
+ // Check if q1 and q2 are equal.

- // Generate a quaternion based on yaw (Y), pitch (X), and roll (Z).
+ // Generate a quaternion from yaw (Y), pitch (X), and roll (Z) angles.

- // Generate a quaternion from rotation Euler angles (in radians) around the x, y, and z axes.
+ // Generate a quaternion from Euler angles (in radians) around the x, y, and z axes.

- // Equivalent to Quaternion.rotationYawPitchRoll(yRad, xRad, zRad, out2)
+ // Equivalent to Quaternion.rotationYawPitchRoll(yRad, xRad, zRad, out2).

- // Generating quaternions for rotations around the X, Y, and Z axes. Let's take rotating around the X axis as an example.
+ // Generate a quaternion for rotation around the X axis.

- // The current quaternion rotates successively around the X, Y, and Z axes.
+ // Rotate q3 successively around the X, Y, and Z axes.

- // Retrieve the Euler angles (in radians) from the current quaternion.
+ // Retrieve the Euler angles (in radians) from q3.

- // Convert radians to degrees.
+ // Convert the Euler angles from radians to degrees.

156-230: Improve code comments for clarity.

The comments in the code examples can be improved for better clarity and consistency.

- // Create a default 4x4 matrix, initialized as the identity matrix.
+ // Create a default 4x4 matrix initialized as the identity matrix.

- // Create a 4x4 matrix and initialize it with the given values.
+ // Create a 4x4 matrix initialized with the given values.

- // Set m2 to the identity matrix.
+ // Set m2 to be the identity matrix.

- // Check if two matrices have equal values, returning true.
+ // Check if m1 and m2 are equal.

- // Matrix multiplication, static method.
+ // Perform matrix multiplication using the static method.

- // Matrix multiplication, instance method.
+ // Perform matrix multiplication using the instance method.

- // Check if two matrices have equal values, returning true.
+ // Check if out1 and out2 are equal.

- // Calculate the determinant of a matrix.
+ // Calculate the determinant of m5.

- // Convert a 4x4 matrix to a 3x3 matrix.
+ // Convert m5 to a 3x3 matrix.

- // Compute the transpose of a matrix, using a static method.
+ // Compute the transpose of m7 using the static method.

- // Compute the transpose of a matrix, using a instance method.
+ // Compute the transpose of m7 using the instance method.

- // Generate a 4x4 matrix for rotation around the Y-axis.
+ // Generate a 4x4 rotation matrix for rotation around the Y-axis.

- // Extract rotation, scaling, and translation from a matrix.
+ // Extract translation, rotation, and scale from m8.

- // Retrieve the rotation angle in radians for each axis from the acquired quaternion.
+ // Retrieve the Euler angles (in radians) from qua.

- // Generate a rotation matrix from a quaternion.
+ // Generate a 4x4 rotation matrix from qua.

- // Generate a rotation matrix from rotation angles.
+ // Generate a 4x4 rotation matrix from rotation angles.

- // Generate a scaling matrix from scaling factors.
+ // Generate a 4x4 scaling matrix from scaling factors.

- // Generate a translation matrix from translation values.
+ // Generate a 4x4 translation matrix from translation values.

- // Generate a matrix from rotation, scaling, and translation.
+ // Generate a 4x4 matrix from rotation, scaling, and translation.

238-250: Improve code comments for clarity.

The comments in the code examples can be improved for better clarity and consistency.

- // Create Color.
+ // Create a Color with the given RGBA values (1, 0.5, 0.5, 1).

- // Convert linear space to gamma space.
+ // Convert color1 from linear space to gamma space.

- // Convert gamma space to linear space.
+ // Convert color2 from gamma space to linear space.

264-279: Improve code comments for clarity.

The comments in the code examples can be improved for better clarity and consistency.

- // Create a plane using the three vertices of a triangle.
+ // Create a plane from three points.

- // Create a plane using the plane's normal and the distance from the origin.
+ // Create a plane from a normal vector and a distance.

Line range hint 289-336:
Improve code comments for clarity.

The comments in the code examples can be improved for better clarity and consistency.

- // Create the same bounding box using different methods.
+ // Create bounding boxes using different methods.

- // Create using the center point and box extent.
+ // Create a bounding box from a center point and extents.

- // Create using multiple points.
+ // Create a bounding box from multiple points.

- // Create using a bounding sphere.
+ // Create a bounding box from a bounding sphere.

- // Transform the bounding box using a matrix.
+ // Transform a bounding box using a matrix.

- // Merge two bounding boxes, box1 and box2, into a new bounding box box.
+ // Merge box1 and box2 into a new bounding box.

- // Get the center point and dimensions of the bounding box.
+ // Get the center point and extents of the bounding box.

- // Get the all vertices of the bounding box.
+ // Get all the vertices of the bounding box.

Line range hint 349-368:
Improve code comments for clarity.

The comments in the code examples can be improved for better clarity and consistency.

- // Create a bounding sphere using different methods.
+ // Create bounding spheres using different methods.

- // Create a bounding sphere using multiple points.
+ // Create a bounding sphere from multiple points.

- // Create a bounding sphere from a bounding box.
+ // Create a bounding sphere from a bounding box.

378-391: Improve code comments for clarity.

The comments in the code examples can be improved for better clarity and consistency.

- // Create a frustum based on the View-Projection (VP) matrix. In practical projects, the view matrix and projection matrix are typically obtained from the camera.
+ // Create a frustum from a View-Projection (VP) matrix. In practical projects, the view matrix and projection matrix are typically obtained from the camera.

- // Check for intersection with an AABB (Axis-Aligned Bounding Box).
+ // Check if the frustum intersects with an AABB (Axis-Aligned Bounding Box).

- // Check for intersection with a bounding sphere.
+ // Check if the frustum intersects with a bounding sphere.

414-432: Improve code comments for clarity.

The comments in the code examples can be improved for better clarity and consistency.

- // Create Ray.
+ // Create a Ray with an origin and a direction.

- // To determine if a ray intersects with a plane:
+ // Determine if the ray intersects with the plane:

- // if they intersect, distance represents the distance from the ray's origin to the plane, otherwise, distance is -1.
+ // If they intersect, distance represents the distance from the ray's origin to the plane; otherwise, distance is -1.

- // To determine if a ray intersects with a sphere:
+ // Determine if the ray intersects with the sphere:

- // if they intersect, distance represents the distance from the ray's origin to the sphere, otherwise, distance is -1.
+ // If they intersect, distance represents the distance from the ray's origin to the sphere; otherwise, distance is -1.

- // To determine if a ray intersects with a box:
+ // Determine if the ray intersects with the box:

- // if they intersect, distance represents the distance from the ray's origin to the box, otherwise, distance is -1.
+ // If they intersect, distance represents the distance from the ray's origin to the box; otherwise, distance is -1.

- // Point at a specified distance from the ray's origin.
+ // Get the point at a specified distance from the ray's origin.

443-456: Improve code comments for clarity.

The comments in the code examples can be improved for better clarity and consistency.

- // Initialize a random number generator instance.
+ // Initialize a Rand instance with a seed.

- // Generate a random integer within the range [0, 0xffffffff].
+ // Generate random integers in the range [0, 0xffffffff].

- // Generate a random number in the range [0, 1).
+ // Generate random numbers in the range [0, 1).

- // Reset the seed.
+ // Reset the Rand instance with a new seed.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 325438d and 1d2b216.

Files selected for processing (4)
  • docs/en/core/math.md (11 hunks)
  • docs/en/graphics/2D/lottie.md (2 hunks)
  • docs/zh/core/math.md (7 hunks)
  • docs/zh/graphics/2D/lottie.md (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • docs/en/graphics/2D/lottie.md
  • docs/zh/core/math.md
  • docs/zh/graphics/2D/lottie.md
Additional context used
LanguageTool
docs/en/core/math.md

[duplication] ~460-~460: Possible typo: you repeated a word
Context: ...eed. rand.reset(0, 0x96aa4de3); ``` ## CollisionUtil CollisionUtil provides a wide range of functions for ...

(ENGLISH_WORD_REPEAT_RULE)


[typographical] ~461-~461: Do not use a colon (:) before a series that is introduced by a preposition (‘including’). Remove the colon or add a noun or a noun phrase after the preposition.
Context: ...r collision and intersection detection, including: | function | note | | :--- | :--- | | i...

(RP_COLON)


[misspelling] ~468-~468: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’.
Context: ...Detect the spatial relationship between an bounding sphere and a plane: in front o...

(EN_A_VS_AN)

| distancePlaneAndPoint | Calculate the distance from a point to a plane |
| intersectsPlaneAndPoint | Detect the spatial relationship between a point and a plane: in front of the plane (in the direction of the normal), behind the plane, or on the plane |
| intersectsPlaneAndBox | Detect the spatial relationship between an AABB bounding box and a plane: in front of the plane (in the direction of the normal), behind the plane, or intersecting the plane |
| intersectsPlaneAndSphere | Detect the spatial relationship between an bounding sphere and a plane: in front of the plane (in the direction of the normal), behind the plane, or intersecting the plane |
Copy link

Choose a reason for hiding this comment

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

Fix incorrect article usage.

Use "a" instead of "an" before "bounding sphere".

- the spatial relationship between an bounding sphere
+ the spatial relationship between a bounding sphere
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| intersectsPlaneAndSphere | Detect the spatial relationship between an bounding sphere and a plane: in front of the plane (in the direction of the normal), behind the plane, or intersecting the plane |
| intersectsPlaneAndSphere | Detect the spatial relationship between a bounding sphere and a plane: in front of the plane (in the direction of the normal), behind the plane, or intersecting the plane |
Tools
LanguageTool

[misspelling] ~468-~468: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’.
Context: ...Detect the spatial relationship between an bounding sphere and a plane: in front o...

(EN_A_VS_AN)

const num4 = rand.random();
const num5 = rand.random();
const num6 = rand.random();

// 重置种子
// Reset the seed.
rand.reset(0, 0x96aa4de3);
```

## CollisionUtil
Copy link

Choose a reason for hiding this comment

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

Fix repeated word "CollisionUtil".

The word "CollisionUtil" is repeated.

- ## CollisionUtil CollisionUtil provides a wide range of functions for collision and intersection detection, including:
+ ## CollisionUtil provides a wide range of functions for collision and intersection detection, including:
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## CollisionUtil
## CollisionUtil provides a wide range of functions for collision and intersection detection, including:
Tools
LanguageTool

[duplication] ~460-~460: Possible typo: you repeated a word
Context: ...eed. rand.reset(0, 0x96aa4de3); ``` ## CollisionUtil CollisionUtil provides a wide range of functions for ...

(ENGLISH_WORD_REPEAT_RULE)

rand.reset(0, 0x96aa4de3);
```

## CollisionUtil
CollisionUtil provides a wide range of functions for collision and intersection detection, including:
Copy link

Choose a reason for hiding this comment

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

Fix incorrect colon usage.

Do not use a colon before a series introduced by a preposition.

- including:
+ including
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
CollisionUtil provides a wide range of functions for collision and intersection detection, including:
CollisionUtil provides a wide range of functions for collision and intersection detection, including
Tools
LanguageTool

[typographical] ~461-~461: Do not use a colon (:) before a series that is introduced by a preposition (‘including’). Remove the colon or add a noun or a noun phrase after the preposition.
Context: ...r collision and intersection detection, including: | function | note | | :--- | :--- | | i...

(RP_COLON)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1d2b216 and 191f6c6.

Files selected for processing (2)
  • docs/en/graphics/2D/lottie.md (3 hunks)
  • docs/zh/graphics/2D/lottie.md (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • docs/en/graphics/2D/lottie.md
  • docs/zh/graphics/2D/lottie.md

Copy link
Collaborator

@cptbtptpbcptdtptp cptbtptpbcptdtptp left a comment

Choose a reason for hiding this comment

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

+1

@cptbtptpbcptdtptp cptbtptpbcptdtptp merged commit 526b0e0 into galacean:dev/1.3 Jul 26, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2D documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants