About the Render component

A question. Does the Anim component only work with the Render component, or will Model still suffice?

Thing is, I’m having some trouble with the Render component. Something which seems to work with Model.

When I do this with the Model component, my model asset shows up all nicely in the scene without the same kind of error.

For future-proofing, I’d like to make the change to the Render component. But as I’d like to do it programmatically (no editor), this makes it a little hard. I’d much rather be able to just set the asset property and rely on the Asset system like I can with Model rather than having to make house keeping around say instantiateRenderEntity

Is this potentially an error in the engine?

Hi @damvad,

Yes, the Anim component works both with the Model and Render components. The legacy Animation component works only with Model comp.

Just to understand, you are trying to set the asset on the render component and it throws an error? That definitely works, for example this works:

entity.render.type = 'asset';
entity.render.asset = this.app.assets.find('My Render Asset').id;

But the problem is that render components aren’t usually meant to work like this, most likely the entity doesn’t show up because its scale is too big. Try scaling it down by 0.01.

When you instantiate a render entity, the internal hierarchy of the model is respected and position/rotation/scale of the model are correct.

1 Like

Slight correction, the Anim component works with both the model component and render/import hierarchy set.

The Animation component only works with the model component

1 Like

Ah right, got that wrong, thanks @yaustar, editing my message above.

Would you be able to share your project where you get this error? Is 100 a valid asset id?

Are you using the Editor at all or just the engine?

Hi again, thanks for the replies.

Ah, it’s good to know that I can always fall back to Model and still use the Anim component.

I’m just using the engine. Trying to get to know it better, how it works below the surface, enticed by its MIT license.

@Leonidas That is precisely all I’m doing, yeah.

@yaustar I fear sharing the project is not worth a lot at all. The code I posted is really all there is to it, at this point. I’ve registered the asset manually in a config.json of my own (explains the weird asset ID), which is loaded via the app.configure() method. But I could of course be doing that in a wrong manner. Its entry looks like this

		"100": {
			"branch_id": "be45985e-a595-4c61-be70-eaef9e5823da",
			"tags": [],
			"name": "colt-saa.glb",
			"revision": 1,
			"preload": true,
			"region": "eu-west-1",
			"meta": {
				"meshes": 10,
				"meshInstances": 10,
				"meshInstancesNames": [
					"Colt SAA",
				"nodes": 11,
				"skins": 0,
				"vertices": 7454,
				"triangles": 8414,
				"attributes": {
					"NORMAL": 10,
					"POSITION": 10,
					"TEXCOORD_0": 10
			"type": "model",
			"file": {
				"hash": "463729041ee7b5cd282da51af059fdd6",
				"size": 297508,
				"filename": "colt-saa.glb",
				"url": "./assets/colt-saa.glb"
			"i18n": {},
			"immutable_backup": "c61a5710-4a77-49b4-bf55-4587891e4b95",
			"same_as_backup": 1,
			"checkpoint_id": "bdb4e223-473d-4b26-ac66-83a1c859021f",
			"id": "100"

I’ve tried changing type to container as well, with no luck.

Ah, that asset listing helps a lot

Render components will only take render assets which is basically a bit of data that references a GLB container.

If you are using engine only and loading GLBs, the method is to load the GLB as a container.

Once the GLB container asset is loaded, the resource will contain all the assets that are needed including the render assets, material assets etc that you can do as you wish with: https://github.com/playcanvas/engine/blob/dev/src/resources/parser/glb-container-resource.js#L20

However, if you want to create the whole entity model, then using instantiateRenderEntity is the ‘correct’ method.

Changing the render hierarchy at runtime can be seen here on how it could be done: Change Render component asset at runtime

Or you can you use the model component which works with the Anim Component and isn’t likely to be removed until we go to engine 2.0


Alright. Sounds like I’ll stick with the Model component for now, then.

Thanks for the explanation, @yaustar! It’s very helpful. :+1: