From 55521de63c5119ef7ac70aed882baaf40d58eacc Mon Sep 17 00:00:00 2001 From: Fran Carrascosa Date: Tue, 3 Oct 2023 12:10:48 +0200 Subject: [PATCH 1/2] Rebase version and add publish information --- lerna.json | 2 +- packages/troika-three-text/package.json | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lerna.json b/lerna.json index d2bb623c..45dbe1db 100644 --- a/lerna.json +++ b/lerna.json @@ -2,7 +2,7 @@ "packages": [ "packages/*" ], - "version": "0.48.1", + "version": "1.0.0", "command": { "version": { "conventionalCommits": true diff --git a/packages/troika-three-text/package.json b/packages/troika-three-text/package.json index d71a4ecf..e701f5c6 100644 --- a/packages/troika-three-text/package.json +++ b/packages/troika-three-text/package.json @@ -1,11 +1,22 @@ { "name": "troika-three-text", - "version": "0.48.1", "description": "SDF-based text rendering for Three.js", - "author": "Jason Johnston ", + "version": "1.0.0", + "author": { + "name": "Metrica Sports", + "email": "info@metrica-sports.com" + }, + "versionForked": "0.48.1", + "authorForked": { + "name": "Jason Johnston", + "email": "jason.johnston@protectwise.com" + }, + "publishConfig": { + "registry": "https://npm.pkg.github.com/" + }, "repository": { "type": "git", - "url": "https://github.com/protectwise/troika.git", + "url": "https://github.com/metrica-sports/troika.git", "directory": "packages/troika-three-text" }, "license": "MIT", From 18ae87ce6992761283844475dc146234afd453da Mon Sep 17 00:00:00 2001 From: Fran Carrascosa Date: Tue, 3 Oct 2023 12:14:32 +0200 Subject: [PATCH 2/2] Allow rendering in WebWorkers --- packages/troika-2d/src/HitTestContext.js | 4 ++-- packages/troika-3d/src/facade/WorldTextureProvider.js | 2 +- packages/troika-animation/src/Interpolators.js | 2 +- packages/troika-three-text/src/TextBuilder.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/troika-2d/src/HitTestContext.js b/packages/troika-2d/src/HitTestContext.js index 7425527f..5edb2aab 100644 --- a/packages/troika-2d/src/HitTestContext.js +++ b/packages/troika-2d/src/HitTestContext.js @@ -6,8 +6,8 @@ * whether an Object2DFacade is under the mouse cursor, by passing this as the context * to its render() method. */ - -const hitTestContext = document.createElement('canvas').getContext('2d') +const canvas = typeof document === 'undefined' ? new OffscreenCanvas() : document.createElement('canvas') +const hitTestContext = canvas.getContext('2d') hitTestContext.save() /** diff --git a/packages/troika-3d/src/facade/WorldTextureProvider.js b/packages/troika-3d/src/facade/WorldTextureProvider.js index 2d39c769..abe05e7a 100644 --- a/packages/troika-3d/src/facade/WorldTextureProvider.js +++ b/packages/troika-3d/src/facade/WorldTextureProvider.js @@ -76,7 +76,7 @@ export function makeWorldTextureProvider(WrappedFacadeClass) { } if (newWorldConfig) { this.worldTexture.dispose() - const canvas = document.createElement('canvas') + const canvas = typeof document === 'undefined' ? new OffscreenCanvas() : document.createElement('canvas') canvas.width = newWorldConfig.width canvas.height = newWorldConfig.height this.worldTexture = new CanvasTexture(canvas) diff --git a/packages/troika-animation/src/Interpolators.js b/packages/troika-animation/src/Interpolators.js index 5356c897..54897162 100644 --- a/packages/troika-animation/src/Interpolators.js +++ b/packages/troika-animation/src/Interpolators.js @@ -50,7 +50,7 @@ const colorValueToNumber = (function() { // 2D canvas for evaluating string values if (!colorCanvas) { - colorCanvas = document.createElement('canvas') + colorCanvas = typeof document === 'undefined' ? new OffscreenCanvas() : document.createElement('canvas') colorCanvasCtx = colorCanvas.getContext('2d') } diff --git a/packages/troika-three-text/src/TextBuilder.js b/packages/troika-three-text/src/TextBuilder.js index 1d7ce9c4..89623912 100644 --- a/packages/troika-three-text/src/TextBuilder.js +++ b/packages/troika-three-text/src/TextBuilder.js @@ -164,7 +164,7 @@ function getTextRenderInfo(args, callback) { const glyphsPerRow = (textureWidth / sdfGlyphSize * 4) let atlas = atlases[sdfGlyphSize] if (!atlas) { - const canvas = document.createElement('canvas') + const canvas = typeof document === 'undefined' ? new OffscreenCanvas() : document.createElement('canvas') canvas.width = textureWidth canvas.height = sdfGlyphSize * 256 / glyphsPerRow // start tall enough to fit 256 glyphs atlas = atlases[sdfGlyphSize] = {