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

Engine exception if model has no graph node #2514

Closed
LeXXik opened this issue Oct 30, 2020 · 3 comments
Closed

Engine exception if model has no graph node #2514

LeXXik opened this issue Oct 30, 2020 · 3 comments
Assignees
Labels
area: graphics Graphics related issue bug

Comments

@LeXXik
Copy link
Contributor

LeXXik commented Oct 30, 2020

The engine will throw, if a model that has no graph node is added to the entity. For example, the following will result in engine error:

    var entity = new pc.Entity();
    entity.addComponent('model', {});
    entity.model.model = new pc.Model();

The cause is in the model component:

this.entity.addChild(this._model.graph);

which then tries to look for null's parent:

		addChild: function (node) {
			if (node._parent !== null)
@mvaligursky mvaligursky self-assigned this Oct 31, 2020
@mvaligursky mvaligursky added area: graphics Graphics related issue bug labels Oct 31, 2020
@mvaligursky
Copy link
Contributor

I'm not sure this is an actual problem. The model class is designed to contain a hierarchy (a single node would do), which is then connected to the entity when you add the component to it.

See the API docs:
https://developer.playcanvas.com/en/api/pc.Model.html
... It contains a hierarchy and any number of mesh instances.

@LeXXik
Copy link
Contributor Author

LeXXik commented Nov 3, 2020

I agree. Thought perhaps you wanted to put a guard for unhandled exception, hence the report. Feel free to ignore.

@mvaligursky
Copy link
Contributor

We had a discussion and will at some point implement a larger system to handle this.
#2529

Thanks for bringing this to our attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue bug
Projects
None yet
Development

No branches or pull requests

2 participants