khaelou
January 29, 2022, 9:41pm
#1
Considering my transition from Model + Animation components, how would I assign the asset of a .glb file to a Render component?
Heres what I have so far:
Function it resides in:
I’ve also attempted changing the material in a similar manner with no success, utilizing Loading glTF GLBs for setup.
Hi @khaelou ,
Check this example:
https://developer.playcanvas.com/en/tutorials/loading-gltf-glbs/
Basically from the asset you can instantiate a render entity, which you can append as a child to your hierarchy:
utils.loadGlbContainerFromAsset(this.glbAsset, null, this.glbAsset.name, function (err, asset) {
var renderRootEntity = asset.resource.instantiateRenderEntity();
self.entity.addChild(renderRootEntity);
});
If you don’t want to add a new entity, you can inspect the asset and grab the mesh instances directly. From there you can easily add them to any render component using this property:
https://developer.playcanvas.com/api/pc.RenderComponent.html#meshInstances
khaelou
January 31, 2022, 7:45am
#4
I’ve referenced this resource as stated in the thread, this way of doing so does not add the animations or detect the animations from Anim component.
In other words, it doesn’t work out of the box like the Model component method.
Idle Anim = Model Component
TPose = Render Component
Yes, for the animations you need some additional steps.
This may be of help:
Thanks that worked,
here the amended code for anyone finding this post:
utils.loadGlbContainerFromAsset(this.glbAsset, null, this.glbAsset.name, function (err, asset) {
var renderRootEntity = asset.resource.instantiateRenderEntity();
self.entity.addChild(renderRootEntity);
// add animation
renderRootEntity.addComponent('anim', { activate: true });
renderRootEntity.anim.assignAnimation('clip', asset.resource.animations[0].resource);
renderRo…
1 Like
khaelou
January 31, 2022, 11:35am
#6
Thanks for guiding me to this thread.
Yet I’m using the add-Animations.js script from Animation without State Graph on my Character entity, how would I take those animations and use instead?
yaustar
February 1, 2022, 5:35pm
#7
Something like this?
Press 5 to load a new GLB in place but use the same anim component (I’ve modified the example to load a GLB from a binary asset):
https://playcanvas.com/editor/scene/1325648
3 Likes
khaelou
February 19, 2022, 11:29am
#8
Exactly, this is the method I further progressed with as it does not require use of the StateGraph component and supports existing FBX animations.
yaustar
Split this topic
December 21, 2022, 10:21am
#10
A post was merged into an existing topic: Can’t found the entity in editor