Skip to content

feat: add entity render mesh helpers#8960

Closed
kpal81xd wants to merge 1 commit into
mainfrom
issue-8958-entity-helpers
Closed

feat: add entity render mesh helpers#8960
kpal81xd wants to merge 1 commit into
mainfrom
issue-8958-entity-helpers

Conversation

@kpal81xd

@kpal81xd kpal81xd commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Refs #8958

Description

  • Adds Entity#forEachRenderMeshInstance(cb) to traverse render/model mesh instances across an entity subtree.
  • Adds Entity#getAabb(result?) to compute subtree render bounds without reading live meshInstances arrays.
  • Covers runtime behavior with entity tests.

Manual smoke test

  1. Create an entity hierarchy with render or model components on parent and child entities.
  2. Call entity.forEachRenderMeshInstance(cb) and confirm cb receives each mesh instance with its owning component and entity.
  3. Call entity.getAabb() and confirm it returns a bounding box covering the rendered subtree, or null for an empty hierarchy.

Checklist

  • I have read the contributing guidelines
  • My code follows the project coding standards
  • This PR focuses on a single change

Comment thread src/framework/entity.js
* meshInstance.visible = false;
* });
*/
forEachRenderMeshInstance(callback, thisArg) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why is it called forEachRenderMeshInstance when it works on model components.
it should be forEachMeshInstance

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is just a draft for now - the exact names we can modify. I am just collating findings from my experiments with agents

Comment thread src/framework/entity.js
* // use aabb
* }
*/
getAabb(result) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not sure this function is good as is, I think meshInstance.aabb is only updated during rendering, so on the first frame it's not valid. we should not expose this for now till that is sorted. separate PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Still working on this - this is not merge ready at all

@kpal81xd kpal81xd marked this pull request as draft June 24, 2026 14:28
@LeXXik

LeXXik commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

There is also related: #7844

@github-actions

Copy link
Copy Markdown

Build size report

This PR changes the size of the minified bundles.

Bundle Minified Gzip Brotli
playcanvas.min.js 2261.6 KB (+0.3 KB, +0.02%) 581.9 KB (+0.1 KB, +0.02%) 452.3 KB (+0.1 KB, +0.03%)
playcanvas.min.mjs 2259.1 KB (+0.3 KB, +0.02%) 581.0 KB (+0.1 KB, +0.02%) 451.9 KB (+0.2 KB, +0.04%)

@github-actions

Copy link
Copy Markdown

Public API report

This PR changes the public API surface (+3 / −0), per the docs' rules (@ignore / @Private / undocumented are excluded).

Show API diff
+Entity.forEachRenderMeshInstance(callback: RenderMeshInstanceCallback, thisArg?: any): void
+Entity.getAabb(result?: BoundingBox): BoundingBox | null
+type RenderMeshInstanceCallback = (meshInstance: MeshInstance, component: RenderComponent | ModelComponent, entity: Entity) => any

Informational only — this never fails the build.

@kpal81xd kpal81xd closed this Jun 25, 2026
@kpal81xd kpal81xd deleted the issue-8958-entity-helpers branch June 25, 2026 11:07
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.

3 participants