Problem with scale when adding model entity/component during runtime

I am trying to add some functionality to the VR template project. I want to dynamically add a hand mesh to the controller during runtime, rather than have it set up in the hierarchy in the editor.

During the function Controller.prototype.setInputSource I am adding lines like this:

// Set model
        case pc.XRHAND_LEFT:
            this.modelEntity = new pc.Entity();
            this.modelComponent = this.modelEntity.addComponent('model', {
                type: 'asset',
                asset: this.LeftHandModel
            this.modelEntity.setLocalEulerAngles(-180, -45, -90);
   = 'LeftHandModel';

        ... etc.

If I simply added a model component to the controller entity directly, it seemed to work, but because I need to provide a rotation and scale offset, I am trying to create a new entity with the model component, add it as a child to the controller, and do the offset.

In fact, the above code works perfectly apart from the ‘setLocalScale’ function. Without that it works, but I want to be able to set the scale up a bit. As soon as the scale line is added in, the hands disappear.

What’s going on here?

1 Like

setLocalScale takes 3 params or a vec3. (X, Y, Z).

1 Like

Ah, for some reason thought you could set uniform scale with a single float. Thanks!

1 Like