gResourceReadyCalled = true;
}
+static bool gLoadCompletedCalled = false;
+void OnLoadCompleted(Scene3D::Model model, bool succeeded)
+{
+ gLoadCompletedCalled = true;
+}
+
void ApplyAllMaterialPropertyRecursively(Scene3D::ModelNode modelNode, const std::vector<KeyValuePair>& materialPropertyValues)
{
if(!modelNode)
DALI_TEST_EQUALS(modelNode2.GetProperty<int>(shadowReceivingIndex2), 0, TEST_LOCATION);
END_TEST;
-}
\ No newline at end of file
+}
+
+int UtcDaliModelLoadComplete(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+
+ gLoadCompletedCalled = false;
+ model.LoadCompletedSignal().Connect(&OnLoadCompleted);
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gLoadCompletedCalled, true, TEST_LOCATION);
+
+ END_TEST;
+}
ModelCacheManager::Get().UnreferenceModelCache(mModelUrl);
}
+ EmitLoadCompletedSignal(false);
+
return;
}
mModelResourceReady = true;
ResetResourceTask(mModelLoadTask);
NotifyResourceReady();
+
+ EmitLoadCompletedSignal(true);
}
void Model::OnIblDiffuseLoadComplete()
return mMeshHitSignal;
}
+ /**
+ * @copydoc Scene3D::Model::LoadCompletedSignal()
+ */
+ Scene3D::Model::LoadCompletedSignalType& LoadCompletedSignal()
+ {
+ return mLoadCompletedSignal;
+ }
+
+ /**
+ * @brief Emits LoadCompletedSignal
+ * @param[in] succeeded Whether model loading has been successful
+ */
+ void EmitLoadCompletedSignal(bool succeeded)
+ {
+ if(!mLoadCompletedSignal.Empty())
+ {
+ Scene3D::Model handle(GetOwner());
+ mLoadCompletedSignal.Emit(handle, succeeded);
+ }
+ }
+
/**
* @brief Emits MeshHitSignal
* @param[in] modelNode ModelNode that has been hit
Dali::PropertyNotification mSizeNotification;
// Signals
- Scene3D::Model::MeshHitSignalType mMeshHitSignal;
+ Scene3D::Model::MeshHitSignalType mMeshHitSignal;
+ Scene3D::Model::LoadCompletedSignalType mLoadCompletedSignal;
Dali::Scene3D::Loader::ShaderManagerPtr mShaderManager;
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return GetImpl(*this).MeshHitSignal();
}
+Model::LoadCompletedSignalType& Model::LoadCompletedSignal()
+{
+ return GetImpl(*this).LoadCompletedSignal();
+}
+
} // namespace Dali::Scene3D
using MeshHitSignalType = Signal<bool(Model, Scene3D::ModelNode)>; ///< Mesh hit signal type @SINCE_2_2.53
using ColliderMeshPtr = std::unique_ptr<Algorithm::NavigationMesh>;
+ using LoadCompletedSignalType = Signal<void(Model, bool)>; ///< Model load completed signal type @SINCE_2_3.46
+
/**
* @brief Create an initialized Model.
*
*/
MeshHitSignalType& MeshHitSignal();
+ /**
+ * @brief This signal is emitted when the model loading is completed.
+ *
+ * Two parameters are sent as part of this signal, the first being the model that is loaded,
+ * the second being whether the loading has been successful.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(Model model, bool succeeded);
+ * @endcode
+ * Here the model is the one that has finifhed loading.
+ *
+ * @SINCE_2_3.46
+ * @return The signal to connect to
+ */
+ LoadCompletedSignalType& LoadCompletedSignal();
+
public: // Not intended for application developers
/// @cond internal
/**