void CreateSceneFromGLTF(uint32_t index)
{
+ mReadyToLoad = false;
if(mModel)
{
mWindow.GetRootLayer().Remove(mModel);
mModel.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
mModel.SetImageBasedLightSource(uri_diffuse_texture, uri_specular_texture, 0.6f);
+ mModel.ResourceReadySignal().Connect(this, &Scene3DModelExample::ResourceReady);
+
mWindow.Add(mModel);
+ }
+
+ void ResourceReady(Control control)
+ {
+ mReadyToLoad = true;
if(mModel.GetAnimationCount() > 0)
{
- Animation animation = (index == 0u) ? mModel.GetAnimation(0u) : mModel.GetAnimation("idleToSquatClip_0");
+ Animation animation = (mCurrentGlTF == 0u) ? mModel.GetAnimation(0u) : mModel.GetAnimation("idleToSquatClip_0");
animation.Play();
animation.SetLoopCount(0);
}
void ChangeModel(int32_t direction)
{
+ if(!mReadyToLoad)
+ {
+ return;
+ }
+
mCurrentGlTF += direction;
if(mCurrentGlTF >= NUM_OF_GLTF_MODELS)
{
float mWheelDelta{1.0f};
int32_t mCurrentGlTF{0};
+
+ bool mReadyToLoad{true};
};
int32_t DALI_EXPORT_API main(int32_t argc, char** argv)
\r
if(!animations->empty())\r
{\r
- auto getActor = [&root](const Scene3D::Loader::AnimatedProperty& property) {\r
- return root.FindChildByName(property.mNodeName);\r
+ auto getActor = [&](const Scene3D::Loader::AnimatedProperty& property)\r
+ {\r
+ Dali::Actor actor;\r
+ if(property.mNodeIndex != Scene3D::Loader::INVALID_INDEX)\r
+ {\r
+ auto* node = scene.GetNode(property.mNodeIndex);\r
+ if(node != nullptr)\r
+ {\r
+ actor = root.FindChildById(node->mNodeId);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ actor = root.FindChildByName(property.mNodeName);\r
+ }\r
+ return actor;\r
};\r
\r
animation = (*animations)[0].ReAnimate(getActor);\r
\r
auto id = mItemView.GetItemId(actor);\r
\r
+ Scene3D::Loader::InitializeGltfLoader();\r
try\r
{\r
auto window = mApp.GetWindow();\r