[SOLVED] Loading a container as a 'render' component?

Is there any way to load ‘container’ as a render component instead of a model?

const bitA = pc.app.assets.find('bit');
const modelEntity = new pc.Entity();
modelEntity.name = 'bit';
modelEntity.setPosition(21, 8.5, 0);
modelEntity.setLocalEulerAngles(90, 90, 90);
modelEntity.setLocalScale(2, 2, 2);
modelEntity.addComponent('model', {
    type: 'asset',
    asset: bitA.resource.model
modelEntity.addComponent('collision', {
    type: 'mesh',
    asset: bitA.resource.model
modelEntity.addComponent('rigidbody', {
    type: 'static',

instantiateRenderEntity(); sometimes gives a bad result, ‘view’ does not match ‘collision’

Make sure the asset is loaded, before you are using it as a collision mesh.

I believe it’s loaded

        assetListLoader.load(() => {

.. ammo config
..creating entities

maybe the sequence is wrong?

			 const bitA = pc.app.assets.find('bit');
			 var bit = bitA.resource.instantiateRenderEntity();
			 bit.name = 'bit';
		     bit.addComponent("collision", {
			 type: "mesh",
			 asset: bitA.resource.model
			 bit.addComponent('rigidbody', {
			 type: 'static',

there are no issues with model component though

The order is not important. Prefer to add rigidbody component first, though, to avoid a temporary trigger creation.

I probably misread your question. Do you mean the visual mesh doesn’t match collision mesh orientation? If so, you should change how you export model from your 3d modelling app.

Yeah that seems to be the problem,
I can confirm this works as expected:

app.assets.loadFromUrl("some url", "container", function (err, asset) {
    const entity = asset.resource.instantiateModelEntity({
        castShadows: true
	entity.addComponent('collision', {
    type: 'mesh',
    asset: asset.resource.model
entity.addComponent('rigidbody', {
    type: 'static',

confused :face_with_raised_eyebrow: I’ prefer using assetListLoader

Its only a guess, I don’t really know. You should use a debug draw to render the physics state to know what the actual issue is. This is just poking blindly.

I should probably have mentioned that I’m working on engine-only project

I’d recommend using @yaustar dev tools. Its a booklet, so there is no need to install anything or add any scripts. It includes an Ammo debug renderer.

Or you can grab a debug drawer script here. Its a standalone class, not the ScriptType script, so you can use it in self host:


1 Like


Yeah, seems like orientation issue. Try to export it differently from Blender. I think you can change the axis direction during export. I don’t have much experience with it, so can’t tell you exactly what needs to be set in the export settings.

Seems like there’s some sort of bug while using instantiateRenderEntity, tested with 10 models, 4 of them appear weird/broken… Ended up using model component instead