diff --git a/src/engine/sample_engine.cpp b/src/engine/sample_engine.cpp index b379187..c81f8a5 100644 --- a/src/engine/sample_engine.cpp +++ b/src/engine/sample_engine.cpp @@ -1099,9 +1099,15 @@ std::vector SampleEngine::get_cameras_names() void SampleEngine::append_glb(const std::string& filename) { std::vector entities; - parse_scene(filename.c_str(), entities); - main_scene->add_nodes(entities); + parse_scene(filename.c_str(), entities, true, scene_root); + + if (!entities.empty()) { + assert(!scene_root); + assert(entities.size() == 1u); + scene_root = static_cast(entities[0]); + main_scene->add_nodes(entities); + } } Camera* SampleEngine::get_current_camera() diff --git a/src/engine/sample_engine.h b/src/engine/sample_engine.h index 66de248..133bd97 100644 --- a/src/engine/sample_engine.h +++ b/src/engine/sample_engine.h @@ -11,6 +11,7 @@ class EntityCamera; class MeshInstance3D; +class Node3D; class SampleEngine : public Engine { @@ -26,6 +27,8 @@ class SampleEngine : public Engine { std::vector cameras; bool rotate_scene = false; + Node3D* scene_root = nullptr; + float camera_interp_speed = 1.0f; // Vpet connection diff --git a/src/main.cpp b/src/main.cpp index 710f3a5..865d702 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,12 +38,11 @@ EMSCRIPTEN_BINDINGS(_Class_) { emscripten::class_("Engine") .constructor<>() + .class_function("getInstance", &SampleEngine::get_sample_instance, emscripten::return_value_policy::reference()) .function("setEnvironment", &SampleEngine::set_skybox_texture) .function("loadGLB", &SampleEngine::load_glb) - .function("appendGLB", &SampleEngine::append_glb) .function("loadPly", &SampleEngine::load_ply) .function("setCameraType", &SampleEngine::set_camera_type) - .class_function("getInstance", &SampleEngine::get_sample_instance, emscripten::return_value_policy::reference()) .function("setCameraLookAtIndex", &SampleEngine::set_camera_lookat_index) .function("setCameraSpeed", &SampleEngine::set_camera_speed) .function("resetCamera", &SampleEngine::reset_camera) @@ -55,6 +54,7 @@ EMSCRIPTEN_BINDINGS(_Class_) { //.function("getVPETContext", &SampleEngine::get_vpet_context); .function("loadTracerScene", &SampleEngine::load_tracer_scene) // UHasselt gltf streaming demo + .function("appendGLB", &SampleEngine::append_glb) .function("getCamera", &SampleEngine::get_current_camera, emscripten::return_value_policy::reference()) .function("setLightColor", &SampleEngine::set_light_color) .function("setLightIntensity", &SampleEngine::set_light_intensity);