Skip to content

Commit

Permalink
Fix Android build
Browse files Browse the repository at this point in the history
  • Loading branch information
bghgary committed Oct 28, 2022
1 parent 309c4d9 commit da0d314
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
4 changes: 4 additions & 0 deletions Apps/Playground/Scripts/experience.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ CreateBoxAsync(scene).then(function () {
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/RiggedFigure/glTF/RiggedFigure.gltf").then(function () {
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMan/glTF/CesiumMan.gltf").then(function () {
//BABYLON.SceneLoader.AppendAsync("https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/ClearCoatTest/glTF/ClearCoatTest.gltf").then(function () {
//BABYLON.SceneLoader.AppendAsync("file:///C:/Users/garyhsu/Downloads/alien/alien.gltf").then(function () {
BABYLON.Tools.Log("Loaded");

//scene.animationGroups[0].goToFrame(5 * scene.animationGroups[0].targetedAnimations[0].animation.framePerSecond);
//scene.animationGroups[0].pause();

// This creates and positions a free camera (non-mesh)
scene.createDefaultCamera(true, true, true);
scene.activeCamera.alpha += Math.PI;
Expand Down
20 changes: 0 additions & 20 deletions Polyfills/Window/Source/TimeoutDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,6 @@ namespace Babylon::Polyfills::Internal
}
}

struct TimeoutDispatcher::Timeout
{
TimeoutId id;

// Make this non-shared when JsRuntime::Dispatch supports it.
std::shared_ptr<Napi::FunctionReference> function;

TimePoint time;

Timeout(TimeoutId id, std::shared_ptr<Napi::FunctionReference> function, TimePoint time)
: id{id}
, function{std::move(function)}
, time{time}
{
}

Timeout(const Timeout&) = delete;
Timeout(Timeout&&) = delete;
};

TimeoutDispatcher::TimeoutDispatcher(Babylon::JsRuntime& runtime)
: m_runtimeScheduler{runtime}
, m_thread{std::thread{&TimeoutDispatcher::ThreadFunction, this}}
Expand Down
25 changes: 22 additions & 3 deletions Polyfills/Window/Source/TimeoutDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@

namespace Babylon::Polyfills::Internal
{
using TimeoutId = int32_t;

class TimeoutDispatcher
{
using TimeoutId = int32_t;
struct Timeout;

public:
TimeoutDispatcher(Babylon::JsRuntime& runtime);
~TimeoutDispatcher();
Expand All @@ -28,6 +27,26 @@ namespace Babylon::Polyfills::Internal
private:
using TimePoint = std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds>;

struct Timeout
{
TimeoutId id;

// Make this non-shared when JsRuntime::Dispatch supports it.
std::shared_ptr<Napi::FunctionReference> function;

TimePoint time;

Timeout(TimeoutId id, std::shared_ptr<Napi::FunctionReference> function, TimePoint time)
: id{id}
, function{std::move(function)}
, time{time}
{
}

Timeout(const Timeout&) = delete;
Timeout(Timeout&&) = delete;
};

TimeoutId NextTimeoutId();
void ThreadFunction();
void CallFunction(std::shared_ptr<Napi::FunctionReference> function);
Expand Down
1 change: 0 additions & 1 deletion Polyfills/Window/Source/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <Babylon/JsRuntimeScheduler.h>
#include "TimeoutDispatcher.h"
#include <optional>

namespace Babylon::Polyfills::Internal
{
Expand Down

0 comments on commit da0d314

Please sign in to comment.