From 9379cf3c41eedbf3001d4f1e3872ced9a04e818e Mon Sep 17 00:00:00 2001 From: Cedric Guillemet <1312968+CedricGuillemet@users.noreply.github.com> Date: Fri, 7 Mar 2025 16:55:06 +0100 Subject: [PATCH 1/5] fix build regression (#1476) Fix build/installation regression introduced with https://github.com/BabylonJS/BabylonNative/pull/1472 --- .github/jobs/test_install_linux.yml | 2 +- Install/Install.cmake | 5 +++++ Install/Test/CMakeLists.txt | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/jobs/test_install_linux.yml b/.github/jobs/test_install_linux.yml index 903df6562..5548743df 100644 --- a/.github/jobs/test_install_linux.yml +++ b/.github/jobs/test_install_linux.yml @@ -23,7 +23,7 @@ jobs: - script: | sudo apt-get update - sudo apt-get install libjavascriptcoregtk-4.0-dev libgl1-mesa-dev libcurl4-openssl-dev + sudo apt-get install libjavascriptcoregtk-4.0-dev libgl1-mesa-dev libcurl4-openssl-dev libwayland-dev displayName: 'Install packages' - script: | diff --git a/Install/Install.cmake b/Install/Install.cmake index ef57b49ad..fef714c40 100644 --- a/Install/Install.cmake +++ b/Install/Install.cmake @@ -84,6 +84,11 @@ if(TARGET AppRuntime) install_include_for_targets(AppRuntime) endif() +if(TARGET Scheduling) + install_targets(Scheduling) + install_include_for_targets(Scheduling) +endif() + if(TARGET ScriptLoader) install_targets(ScriptLoader) install_include_for_targets(ScriptLoader) diff --git a/Install/Test/CMakeLists.txt b/Install/Test/CMakeLists.txt index 9310e8bc5..26ff94e60 100644 --- a/Install/Test/CMakeLists.txt +++ b/Install/Test/CMakeLists.txt @@ -166,6 +166,7 @@ target_link_libraries(TestInstall openxr_loader OSDependent ScriptLoader + Scheduling spirv-cross-core spirv-cross-hlsl SPIRV From 774ead9e75b81e3b061f7fb4f61e8d9181c31a61 Mon Sep 17 00:00:00 2001 From: Jun Min Cheong Date: Fri, 21 Mar 2025 16:56:31 +1100 Subject: [PATCH 2/5] .fill Path2D, add Path2D example to experience.js --- Apps/Playground/Scripts/experience.js | 11 ++- Polyfills/Canvas/Source/Context.cpp | 137 ++++++++++++++------------ Polyfills/Canvas/Source/Context.h | 2 + 3 files changed, 85 insertions(+), 65 deletions(-) diff --git a/Apps/Playground/Scripts/experience.js b/Apps/Playground/Scripts/experience.js index 36a6b4f8d..663eb70da 100644 --- a/Apps/Playground/Scripts/experience.js +++ b/Apps/Playground/Scripts/experience.js @@ -182,7 +182,6 @@ CreateBoxAsync(scene).then(function () { context.font = "bold 60px monospace"; context.fillText("Gradient Text!", 10, 420); - context.lineWidth = 5; // Rounded rectangle with zero radius (specified as a number) context.strokeStyle = "red"; @@ -214,6 +213,16 @@ CreateBoxAsync(scene).then(function () { context.roundRect(400, 350, -200, 100, [0, 30, 50, 60]); context.stroke(); + // Path 2D + context.strokeStyle = "black"; + context.lineWidth = 1; + let path = new _native.Path2D("M390,30 A 20, 20 0, 0, 1 430, 30 A 20, 20 0, 0, 1 470, 30 Q 470, 60 430, 90 Q 390, 60 390, 30 z"); // heart + //let path2 = new _native.Path2D("M380, 10 h100 v100 h-100 Z"); // square + //path.addPath(path2 , { a: 1, b: 0, c: 0, d: 1, e: 0, f: -5 }); // push square 5px up to center + //context.stroke(path); + context.fillStyle = "blue"; + context.fill(path); + // Draw clipped round rect // TODO: this is currently broken, clipping area does not have round corners context.beginPath(); diff --git a/Polyfills/Canvas/Source/Context.cpp b/Polyfills/Canvas/Source/Context.cpp index 99df01973..087e02745 100644 --- a/Polyfills/Canvas/Source/Context.cpp +++ b/Polyfills/Canvas/Source/Context.cpp @@ -245,8 +245,16 @@ namespace Babylon::Polyfills::Internal SetDirty(); } - void Context::Fill(const Napi::CallbackInfo&) + void Context::Fill(const Napi::CallbackInfo& info) { + // draw Path2D if exists + const NativeCanvasPath2D* path = info.Length() == 1 ? NativeCanvasPath2D::Unwrap(info[0].As()) : nullptr; + if (path != nullptr) + { + PlayPath2D(path); + SetDirty(); + } + nvgFill(*m_nvg); SetDirty(); } @@ -419,75 +427,76 @@ namespace Babylon::Polyfills::Internal SetDirty(); } + void Context::PlayPath2D(const NativeCanvasPath2D* path) + { + nvgBeginPath(*m_nvg); + for (const auto& command : *path) + { + const auto args = command.args; + bool setDirty = true; + switch (command.type) + { + case P2D_CLOSE: + nvgClosePath(*m_nvg); + break; + case P2D_MOVETO: + nvgMoveTo(*m_nvg, args.moveTo.x, args.moveTo.y); + break; + case P2D_LINETO: + nvgLineTo(*m_nvg, args.lineTo.x, args.lineTo.y); + break; + case P2D_BEZIERTO: + nvgBezierTo(*m_nvg, args.bezierTo.cp1x, args.bezierTo.cp1y, + args.bezierTo.cp2x, args.bezierTo.cp2y, + args.bezierTo.x, args.bezierTo.y); + break; + case P2D_QUADTO: + nvgQuadTo(*m_nvg, args.quadTo.cpx, args.quadTo.cpy, + args.quadTo.x, args.quadTo.y); + break; + case P2D_ARC: + nvgArc(*m_nvg, args.arc.x, args.arc.y, args.arc.radius, + args.arc.startAngle, args.arc.endAngle, + args.arc.counterclockwise ? NVG_CCW : NVG_CW); + break; + case P2D_ARCTO: + nvgArcTo(*m_nvg, args.arcTo.x1, args.arcTo.y1, + args.arcTo.x2, args.arcTo.y2, + args.arcTo.radius); + break; + case P2D_ELLIPSE: + // TODO: handle clockwise for nvgElipse (args.ellipse.counterclockwise) + nvgEllipse(*m_nvg, args.ellipse.x, args.ellipse.y, + args.ellipse.radiusX, args.ellipse.radiusY); + break; + case P2D_RECT: + nvgRect(*m_nvg, args.rect.x, args.rect.y, + args.rect.width, args.rect.height); + break; + case P2D_ROUNDRECT: + nvgRoundedRect(*m_nvg, args.roundRect.x, args.roundRect.y, + args.roundRect.width, args.roundRect.height, + args.roundRect.radii); + break; + case P2D_TRANSFORM: + nvgTransform(*m_nvg, + args.transform.a, args.transform.b, args.transform.c, + args.transform.d, args.transform.e, args.transform.f); + break; + default: + break; + } + } + } + void Context::Stroke(const Napi::CallbackInfo& info) { // draw Path2D if exists const NativeCanvasPath2D* path = info.Length() == 1 ? NativeCanvasPath2D::Unwrap(info[0].As()) : nullptr; if (path != nullptr) { - nvgBeginPath(*m_nvg); - for (const auto& command : *path) - { - const auto args = command.args; - bool setDirty = true; - switch (command.type) - { - case P2D_CLOSE: - nvgClosePath(*m_nvg); - break; - case P2D_MOVETO: - nvgMoveTo(*m_nvg, args.moveTo.x, args.moveTo.y); - break; - case P2D_LINETO: - nvgLineTo(*m_nvg, args.lineTo.x, args.lineTo.y); - break; - case P2D_BEZIERTO: - nvgBezierTo(*m_nvg, args.bezierTo.cp1x, args.bezierTo.cp1y, - args.bezierTo.cp2x, args.bezierTo.cp2y, - args.bezierTo.x, args.bezierTo.y); - break; - case P2D_QUADTO: - nvgQuadTo(*m_nvg, args.quadTo.cpx, args.quadTo.cpy, - args.quadTo.x, args.quadTo.y); - break; - case P2D_ARC: - nvgArc(*m_nvg, args.arc.x, args.arc.y, args.arc.radius, - args.arc.startAngle, args.arc.endAngle, - args.arc.counterclockwise ? NVG_CCW : NVG_CW); - break; - case P2D_ARCTO: - nvgArcTo(*m_nvg, args.arcTo.x1, args.arcTo.y1, - args.arcTo.x2, args.arcTo.y2, - args.arcTo.radius); - break; - case P2D_ELLIPSE: - // TODO: handle clockwise for nvgElipse (args.ellipse.counterclockwise) - nvgEllipse(*m_nvg, args.ellipse.x, args.ellipse.y, - args.ellipse.radiusX, args.ellipse.radiusY); - break; - case P2D_RECT: - nvgRect(*m_nvg, args.rect.x, args.rect.y, - args.rect.width, args.rect.height); - break; - case P2D_ROUNDRECT: - nvgRoundedRect(*m_nvg, args.roundRect.x, args.roundRect.y, - args.roundRect.width, args.roundRect.height, - args.roundRect.radii); - break; - case P2D_TRANSFORM: - nvgTransform(*m_nvg, - args.transform.a, args.transform.b, args.transform.c, - args.transform.d, args.transform.e, args.transform.f); - break; - default: - setDirty = false; // noop - break; - } - if (setDirty) - { - SetDirty(); - } - } + PlayPath2D(path); + SetDirty(); } nvgStroke(*m_nvg); diff --git a/Polyfills/Canvas/Source/Context.h b/Polyfills/Canvas/Source/Context.h index f314ca724..68d7c6b04 100644 --- a/Polyfills/Canvas/Source/Context.h +++ b/Polyfills/Canvas/Source/Context.h @@ -4,6 +4,7 @@ #include #include #include "Image.h" +#include "Path2D.h" struct NVGcontext; @@ -119,6 +120,7 @@ namespace Babylon::Polyfills::Internal std::unordered_map m_nvgImageIndices; void BindFillStyle(const Napi::CallbackInfo& info, float left, float top, float width, float height); void FlushGraphicResources() override; + void PlayPath2D(const NativeCanvasPath2D* path); friend class Canvas; }; From 43da28ddca0b9bd32a91d5fbabd3895c1a6f4c55 Mon Sep 17 00:00:00 2001 From: Jun Min Cheong Date: Fri, 21 Mar 2025 17:47:13 +1100 Subject: [PATCH 3/5] Path2D examples for stroke and fill --- Apps/Playground/Scripts/experience.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Apps/Playground/Scripts/experience.js b/Apps/Playground/Scripts/experience.js index 663eb70da..b9df2942b 100644 --- a/Apps/Playground/Scripts/experience.js +++ b/Apps/Playground/Scripts/experience.js @@ -213,15 +213,24 @@ CreateBoxAsync(scene).then(function () { context.roundRect(400, 350, -200, 100, [0, 30, 50, 60]); context.stroke(); - // Path 2D + // Path 2D stroke context.strokeStyle = "black"; - context.lineWidth = 1; - let path = new _native.Path2D("M390,30 A 20, 20 0, 0, 1 430, 30 A 20, 20 0, 0, 1 470, 30 Q 470, 60 430, 90 Q 390, 60 390, 30 z"); // heart - //let path2 = new _native.Path2D("M380, 10 h100 v100 h-100 Z"); // square - //path.addPath(path2 , { a: 1, b: 0, c: 0, d: 1, e: 0, f: -5 }); // push square 5px up to center - //context.stroke(path); - context.fillStyle = "blue"; - context.fill(path); + context.lineWidth = 2; + let heartPath = new _native.Path2D("M390,30 A 20, 20 0, 0, 1 430, 30 A 20, 20 0, 0, 1 470, 30 Q 470, 60 430, 90 Q 390, 60 390, 30 z"); + let squarePath = new _native.Path2D("M380, 10 h100 v100 h-100 Z"); + heartPath.addPath(squarePath, { a: 1, b: 0, c: 0, d: 1, e: 0, f: -5 }); // push square 5px up to center heart. + context.stroke(heartPath); + + // Path 2D fill + context.fillStyle = "yellow"; + let diamondPath = new _native.Path2D(); + diamondPath.moveTo(350, 200); // Start at the center + diamondPath.lineTo(375, 175); // Move to the top point + diamondPath.lineTo(400, 200); // Move to the right point + diamondPath.lineTo(375, 225); // Move to the bottom point + diamondPath.lineTo(350, 200); // Close back to the starting point + context.fill(diamondPath); + // Draw clipped round rect // TODO: this is currently broken, clipping area does not have round corners From 0d58adc59cd20931bed9eb9075550f33aff34dc5 Mon Sep 17 00:00:00 2001 From: Cedric Guillemet <1312968+CedricGuillemet@users.noreply.github.com> Date: Fri, 21 Mar 2025 14:27:39 +0100 Subject: [PATCH 4/5] upgrade bjs version (#1484) --- Apps/package-lock.json | 86 +++++++++++++++++++++--------------------- Apps/package.json | 10 ++--- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Apps/package-lock.json b/Apps/package-lock.json index 87d2a7b05..962ff09b1 100644 --- a/Apps/package-lock.json +++ b/Apps/package-lock.json @@ -8,11 +8,11 @@ "name": "BabylonNative", "version": "0.0.1", "dependencies": { - "babylonjs": "^7.48.3", - "babylonjs-gltf2interface": "^7.48.3", - "babylonjs-gui": "^7.48.3", - "babylonjs-loaders": "^7.48.3", - "babylonjs-materials": "^7.48.3", + "babylonjs": "^7.54.0", + "babylonjs-gltf2interface": "^7.54.0", + "babylonjs-gui": "^7.54.0", + "babylonjs-loaders": "^7.54.0", + "babylonjs-materials": "^7.54.0", "chai": "^4.3.4", "jsc-android": "^241213.1.0", "mocha": "^9.2.2", @@ -80,44 +80,44 @@ } }, "node_modules/babylonjs": { - "version": "7.48.3", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.48.3.tgz", - "integrity": "sha512-1oGfgN1MXMfjwcPMWEvmilEoo0DViW/JsZkRe7xyslfdRutcHoQd4zODlh/u+5IqOudtJKuEUTwxx70FX5I0HA==", + "version": "7.54.0", + "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.54.0.tgz", + "integrity": "sha512-7uZb/9ISxDASlcZi9Cw49PPgkrvnrdsaYYzvha80O52p72ScTkkMz4EiS+xZuZpIOj7CkxMfWpgeIdDByZXSWw==", "hasInstallScript": true, "license": "Apache-2.0" }, "node_modules/babylonjs-gltf2interface": { - "version": "7.48.3", - "resolved": "https://registry.npmjs.org/babylonjs-gltf2interface/-/babylonjs-gltf2interface-7.48.3.tgz", - "integrity": "sha512-0V2kWPX0oRqCybLgcXAd16faUUieJZVOZqg9P7IGoBHIvm3oHwgLQJGynuRDqQMNJMWxDvYtT9uBcygNyu4sPw==", + "version": "7.54.0", + "resolved": "https://registry.npmjs.org/babylonjs-gltf2interface/-/babylonjs-gltf2interface-7.54.0.tgz", + "integrity": "sha512-RxuRDjbzDsg43ItUdZZf5pgx9E6Pcb4YuEW/potc2+9oJvvKguwItE3DXereMs+q5ATYcdiQw2TEOtVgESOodg==", "license": "Apache-2.0" }, "node_modules/babylonjs-gui": { - "version": "7.48.3", - "resolved": "https://registry.npmjs.org/babylonjs-gui/-/babylonjs-gui-7.48.3.tgz", - "integrity": "sha512-e77yJ3qnfGp2yvBKonHBjmN8HC6lPNymALjEGtAf+gNrTnahPWYKPvlDKzCo/5jCZ9h87yFGbFiUDyRFR3itVw==", + "version": "7.54.0", + "resolved": "https://registry.npmjs.org/babylonjs-gui/-/babylonjs-gui-7.54.0.tgz", + "integrity": "sha512-RK0IaChhBRht0AmYb7urkaJepFf82poxzMgJMBpp5plKm4sWYiEoyvvmvRMVOoDvUO6TIvg8Oy7Tl1u8OtLm5A==", "license": "Apache-2.0", "dependencies": { - "babylonjs": "^7.48.3" + "babylonjs": "^7.54.0" } }, "node_modules/babylonjs-loaders": { - "version": "7.48.3", - "resolved": "https://registry.npmjs.org/babylonjs-loaders/-/babylonjs-loaders-7.48.3.tgz", - "integrity": "sha512-s18EwA3AOUy+LZ62Ya25U5LUr/lzmJ1ijl5iW2SSUn105q1YWON1BOgHTVrk9L8FNuofu/LH0Ij9Rs34NEjIPw==", + "version": "7.54.0", + "resolved": "https://registry.npmjs.org/babylonjs-loaders/-/babylonjs-loaders-7.54.0.tgz", + "integrity": "sha512-TIvxVNC3hMVvBU4iNEGe8N1IVpK8SU5dvQa0sn6eH4G4sl5p1nkAJUBFu2T+5YQcKkmaWi3e/rQ8+xlcEgm+Pg==", "license": "Apache-2.0", "dependencies": { - "babylonjs": "^7.48.3", - "babylonjs-gltf2interface": "^7.48.3" + "babylonjs": "^7.54.0", + "babylonjs-gltf2interface": "^7.54.0" } }, "node_modules/babylonjs-materials": { - "version": "7.48.3", - "resolved": "https://registry.npmjs.org/babylonjs-materials/-/babylonjs-materials-7.48.3.tgz", - "integrity": "sha512-SzrDeBvnIZ+hIPu5UKBVR0sMAZvd1/o2tqpJVE8rTHYuPfrBTBL3mZ/M/YmiMhOTAsW3WKG6cFxZ1dpe0OHUUA==", + "version": "7.54.0", + "resolved": "https://registry.npmjs.org/babylonjs-materials/-/babylonjs-materials-7.54.0.tgz", + "integrity": "sha512-RG5PH2m0OM7fhwI3N7M1RBJNoTEL8+DVQ/RnBZVpKaTYRKY9zANC9GBChgnKRRVAtsE2/np1O0vu5rhLcEuZaQ==", "license": "Apache-2.0", "dependencies": { - "babylonjs": "^7.48.3" + "babylonjs": "^7.54.0" } }, "node_modules/balanced-match": { @@ -1043,38 +1043,38 @@ "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" }, "babylonjs": { - "version": "7.48.3", - "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.48.3.tgz", - "integrity": "sha512-1oGfgN1MXMfjwcPMWEvmilEoo0DViW/JsZkRe7xyslfdRutcHoQd4zODlh/u+5IqOudtJKuEUTwxx70FX5I0HA==" + "version": "7.54.0", + "resolved": "https://registry.npmjs.org/babylonjs/-/babylonjs-7.54.0.tgz", + "integrity": "sha512-7uZb/9ISxDASlcZi9Cw49PPgkrvnrdsaYYzvha80O52p72ScTkkMz4EiS+xZuZpIOj7CkxMfWpgeIdDByZXSWw==" }, "babylonjs-gltf2interface": { - "version": "7.48.3", - "resolved": "https://registry.npmjs.org/babylonjs-gltf2interface/-/babylonjs-gltf2interface-7.48.3.tgz", - "integrity": "sha512-0V2kWPX0oRqCybLgcXAd16faUUieJZVOZqg9P7IGoBHIvm3oHwgLQJGynuRDqQMNJMWxDvYtT9uBcygNyu4sPw==" + "version": "7.54.0", + "resolved": "https://registry.npmjs.org/babylonjs-gltf2interface/-/babylonjs-gltf2interface-7.54.0.tgz", + "integrity": "sha512-RxuRDjbzDsg43ItUdZZf5pgx9E6Pcb4YuEW/potc2+9oJvvKguwItE3DXereMs+q5ATYcdiQw2TEOtVgESOodg==" }, "babylonjs-gui": { - "version": "7.48.3", - "resolved": "https://registry.npmjs.org/babylonjs-gui/-/babylonjs-gui-7.48.3.tgz", - "integrity": "sha512-e77yJ3qnfGp2yvBKonHBjmN8HC6lPNymALjEGtAf+gNrTnahPWYKPvlDKzCo/5jCZ9h87yFGbFiUDyRFR3itVw==", + "version": "7.54.0", + "resolved": "https://registry.npmjs.org/babylonjs-gui/-/babylonjs-gui-7.54.0.tgz", + "integrity": "sha512-RK0IaChhBRht0AmYb7urkaJepFf82poxzMgJMBpp5plKm4sWYiEoyvvmvRMVOoDvUO6TIvg8Oy7Tl1u8OtLm5A==", "requires": { - "babylonjs": "^7.48.3" + "babylonjs": "^7.54.0" } }, "babylonjs-loaders": { - "version": "7.48.3", - "resolved": "https://registry.npmjs.org/babylonjs-loaders/-/babylonjs-loaders-7.48.3.tgz", - "integrity": "sha512-s18EwA3AOUy+LZ62Ya25U5LUr/lzmJ1ijl5iW2SSUn105q1YWON1BOgHTVrk9L8FNuofu/LH0Ij9Rs34NEjIPw==", + "version": "7.54.0", + "resolved": "https://registry.npmjs.org/babylonjs-loaders/-/babylonjs-loaders-7.54.0.tgz", + "integrity": "sha512-TIvxVNC3hMVvBU4iNEGe8N1IVpK8SU5dvQa0sn6eH4G4sl5p1nkAJUBFu2T+5YQcKkmaWi3e/rQ8+xlcEgm+Pg==", "requires": { - "babylonjs": "^7.48.3", - "babylonjs-gltf2interface": "^7.48.3" + "babylonjs": "^7.54.0", + "babylonjs-gltf2interface": "^7.54.0" } }, "babylonjs-materials": { - "version": "7.48.3", - "resolved": "https://registry.npmjs.org/babylonjs-materials/-/babylonjs-materials-7.48.3.tgz", - "integrity": "sha512-SzrDeBvnIZ+hIPu5UKBVR0sMAZvd1/o2tqpJVE8rTHYuPfrBTBL3mZ/M/YmiMhOTAsW3WKG6cFxZ1dpe0OHUUA==", + "version": "7.54.0", + "resolved": "https://registry.npmjs.org/babylonjs-materials/-/babylonjs-materials-7.54.0.tgz", + "integrity": "sha512-RG5PH2m0OM7fhwI3N7M1RBJNoTEL8+DVQ/RnBZVpKaTYRKY9zANC9GBChgnKRRVAtsE2/np1O0vu5rhLcEuZaQ==", "requires": { - "babylonjs": "^7.48.3" + "babylonjs": "^7.54.0" } }, "balanced-match": { diff --git a/Apps/package.json b/Apps/package.json index 7febf9d0e..eff585d7f 100644 --- a/Apps/package.json +++ b/Apps/package.json @@ -6,11 +6,11 @@ "getNightly": "node scripts/getNightly.js" }, "dependencies": { - "babylonjs": "^7.48.3", - "babylonjs-gltf2interface": "^7.48.3", - "babylonjs-gui": "^7.48.3", - "babylonjs-loaders": "^7.48.3", - "babylonjs-materials": "^7.48.3", + "babylonjs": "^7.54.0", + "babylonjs-gltf2interface": "^7.54.0", + "babylonjs-gui": "^7.54.0", + "babylonjs-loaders": "^7.54.0", + "babylonjs-materials": "^7.54.0", "chai": "^4.3.4", "jsc-android": "^241213.1.0", "mocha": "^9.2.2", From 770fb669b9c251a6215e9ccabc060ffd8c25b26b Mon Sep 17 00:00:00 2001 From: Jun Min Cheong Date: Sat, 22 Mar 2025 08:39:31 +1100 Subject: [PATCH 5/5] use engine.createCanvasPath2D, handle undefined arg in Path2D constructor --- Apps/Playground/Scripts/experience.js | 6 +++--- Polyfills/Canvas/Source/Path2D.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Apps/Playground/Scripts/experience.js b/Apps/Playground/Scripts/experience.js index b9df2942b..0d26d1e5a 100644 --- a/Apps/Playground/Scripts/experience.js +++ b/Apps/Playground/Scripts/experience.js @@ -216,14 +216,14 @@ CreateBoxAsync(scene).then(function () { // Path 2D stroke context.strokeStyle = "black"; context.lineWidth = 2; - let heartPath = new _native.Path2D("M390,30 A 20, 20 0, 0, 1 430, 30 A 20, 20 0, 0, 1 470, 30 Q 470, 60 430, 90 Q 390, 60 390, 30 z"); - let squarePath = new _native.Path2D("M380, 10 h100 v100 h-100 Z"); + let heartPath = new engine.createCanvasPath2D("M390,30 A 20, 20 0, 0, 1 430, 30 A 20, 20 0, 0, 1 470, 30 Q 470, 60 430, 90 Q 390, 60 390, 30 z"); + let squarePath = new engine.createCanvasPath2D("M380, 10 h100 v100 h-100 Z"); heartPath.addPath(squarePath, { a: 1, b: 0, c: 0, d: 1, e: 0, f: -5 }); // push square 5px up to center heart. context.stroke(heartPath); // Path 2D fill context.fillStyle = "yellow"; - let diamondPath = new _native.Path2D(); + let diamondPath = new engine.createCanvasPath2D(); diamondPath.moveTo(350, 200); // Start at the center diamondPath.lineTo(375, 175); // Move to the top point diamondPath.lineTo(400, 200); // Move to the right point diff --git a/Polyfills/Canvas/Source/Path2D.cpp b/Polyfills/Canvas/Source/Path2D.cpp index 9551fbbce..44e9668d2 100644 --- a/Polyfills/Canvas/Source/Path2D.cpp +++ b/Polyfills/Canvas/Source/Path2D.cpp @@ -49,7 +49,7 @@ namespace Babylon::Polyfills::Internal : Napi::ObjectWrap{info} , m_commands{std::deque()} { - const std::string d = info.Length() == 1 ? info[0].As().Utf8Value() : ""; + const std::string d = info.Length() == 1 && info[0].IsString() ? info[0].As().Utf8Value() : ""; // auto context{info[0].As>().Data()}; // TODO: Path2D constructor if (!d.empty()) {