Skip to content

Commit

Permalink
[Fix] Fix Entity.findComponent(s) functions (#6789)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Jul 8, 2024
1 parent 1698f10 commit af772a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/framework/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class Entity extends GraphNode {
* const light = entity.findComponent("light");
*/
findComponent(type) {
const entity = this.findOne(entity => entity?.c[type]);
const entity = this.findOne(entity => entity.c?.[type]);
return entity && entity.c[type];
}

Expand All @@ -442,7 +442,7 @@ class Entity extends GraphNode {
* const lights = entity.findComponents("light");
*/
findComponents(type) {
return this.find(entity => entity?.c[type]).map(entity => entity.c[type]);
return this.find(entity => entity.c?.[type]).map(entity => entity.c[type]);
}

/**
Expand Down

0 comments on commit af772a6

Please sign in to comment.