Skip to content

Commit

Permalink
Fix compatibility with three.js r154
Browse files Browse the repository at this point in the history
  • Loading branch information
jtbandes committed Sep 25, 2023
1 parent 7a2003f commit cade387
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@foxglove/three-text",
"version": "0.2.0",
"version": "0.2.1",
"description": "Render text in 3D using Signed Distance Fields",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -43,7 +43,7 @@
"@types/jest": "29.5.2",
"@types/node": "20.3.1",
"@types/react": "18.2.12",
"@types/three": "0.152.1",
"@types/three": "0.156.0",
"@typescript-eslint/eslint-plugin": "5.59.11",
"@typescript-eslint/parser": "5.59.11",
"chromatic": "6.19.5",
Expand All @@ -63,7 +63,7 @@
"react-dom": "18.2.0",
"rimraf": "3.0.2",
"storybook": "7.0.20",
"three": "0.153.0",
"three": "0.156.1",
"ts-jest": "29.1.0",
"typescript": "5.1.3"
}
Expand Down
2 changes: 1 addition & 1 deletion src/FontManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type FontManagerOptions = {
* Manages the creation of a Signed Distance Field (SDF) font atlas, and performs text layout to
* generate attributes for rendering text using the atlas.
*/
export class FontManager extends EventDispatcher<{ type: "atlasChange" }> {
export class FontManager extends EventDispatcher<{ atlasChange: object }> {
private alphabet = "";
atlasData: AtlasData = {
data: new Uint8ClampedArray(),
Expand Down
9 changes: 7 additions & 2 deletions src/LabelPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ in mediump vec2 vPosInLabel;
in mediump vec2 vInsideChar;
out vec4 outColor;
${THREE.ShaderChunk.encodings_pars_fragment /* for LinearTosRGB() */}
${
// for LinearTosRGB()
THREE.ShaderChunk.colorspace_pars_fragment ??
// for backward compatibility with three@<154
(THREE.ShaderChunk as Record<string, string>).encodings_pars_fragment
}
// From https://github.com/Jam3/three-bmfont-text/blob/e17efbe4e9392a83d4c5ee35c67eca5a11a13395/shaders/sdf.js
float aastep(float threshold, float value) {
Expand Down Expand Up @@ -336,7 +341,7 @@ export class Label extends THREE.Object3D {
}
}

export class LabelPool extends EventDispatcher<{ type: "scaleFactorChange" | "atlasChange" }> {
export class LabelPool extends EventDispatcher<{ scaleFactorChange: object; atlasChange: object }> {
atlasTexture: THREE.DataTexture;

private availableLabels: Label[] = [];
Expand Down
38 changes: 16 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2603,11 +2603,6 @@
"@types/express" "^4.7.0"
file-system-cache "^2.0.0"

"@tweenjs/tween.js@~18.6.4":
version "18.6.4"
resolved "https://registry.yarnpkg.com/@tweenjs/tween.js/-/tween.js-18.6.4.tgz#40a3d0a93647124872dec8e0fd1bd5926695b6ca"
integrity sha512-lB9lMjuqjtuJrx7/kOkqQBtllspPIN+96OvTCeJ2j5FEzinoAXTdAMFnDAQT1KVPRlnYfBrqxtqP66vDM40xxQ==

"@types/babel__core@^7.0.0":
version "7.20.0"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.0.tgz#61bc5a4cae505ce98e1e36c5445e4bee060d8891"
Expand Down Expand Up @@ -2952,16 +2947,15 @@
resolved "https://registry.yarnpkg.com/@types/stats.js/-/stats.js-0.17.0.tgz#0ed81d48e03b590c24da85540c1d952077a9fe20"
integrity sha512-9w+a7bR8PeB0dCT/HBULU2fMqf6BAzvKbxFboYhmDtDkKPiyXYbjoe2auwsXlEFI7CFNMF1dCv3dFH5Poy9R1w==

"@types/three@0.152.1":
version "0.152.1"
resolved "https://registry.yarnpkg.com/@types/three/-/three-0.152.1.tgz#6f2ce49f7647c78855bc32544cc3e72145aa65cb"
integrity sha512-PMOCQnx9JRmq+2OUGTPoY9h1hTWD2L7/nmuW/SyNq1Vbq3Lwt3MNdl3wYSa4DvLTGv62NmIXD9jYdAOwohwJyw==
"@types/three@0.156.0":
version "0.156.0"
resolved "https://registry.yarnpkg.com/@types/three/-/three-0.156.0.tgz#cd49f2a12e858400962ea818d1e1c45e638141a8"
integrity sha512-733bXDSRdlrxqOmQuOmfC1UBRuJ2pREPk8sWnx9MtIJEVDQMx8U0NQO5MVVaOrjzDPyLI+cFPim2X/ss9v0+LQ==
dependencies:
"@tweenjs/tween.js" "~18.6.4"
"@types/stats.js" "*"
"@types/webxr" "*"
fflate "~0.6.9"
lil-gui "~0.17.0"
fflate "~0.6.10"
meshoptimizer "~0.18.1"

"@types/unist@^2.0.0":
version "2.0.6"
Expand Down Expand Up @@ -5232,7 +5226,7 @@ fetch-retry@^5.0.2:
resolved "https://registry.yarnpkg.com/fetch-retry/-/fetch-retry-5.0.5.tgz#61079b816b6651d88a022ebd45d51d83aa72b521"
integrity sha512-q9SvpKH5Ka6h7X2C6r1sP31pQoeDb3o6/R9cg21ahfPAqbIOkW9tus1dXfwYb6G6dOI4F7nVS4Q+LSssBGIz0A==

fflate@~0.6.9:
fflate@~0.6.10:
version "0.6.10"
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.6.10.tgz#5f40f9659205936a2d18abf88b2e7781662b6d43"
integrity sha512-IQrh3lEPM93wVCEczc9SaAOvkmcoQn/G8Bo1e8ZPlY3X3bnAxWaBdvTdvM1hP62iZp0BXWDy4vTAy4fF0+Dlpg==
Expand Down Expand Up @@ -6774,11 +6768,6 @@ levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"

lil-gui@~0.17.0:
version "0.17.0"
resolved "https://registry.yarnpkg.com/lil-gui/-/lil-gui-0.17.0.tgz#b41ae55d0023fcd9185f7395a218db0f58189663"
integrity sha512-MVBHmgY+uEbmJNApAaPbtvNh1RCAeMnKym82SBjtp5rODTYKWtM+MXHCifLe2H2Ti1HuBGBtK/5SyG4ShQ3pUQ==

lines-and-columns@^1.1.6:
version "1.2.4"
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
Expand Down Expand Up @@ -6979,6 +6968,11 @@ merge2@^1.3.0, merge2@^1.4.1:
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==

meshoptimizer@~0.18.1:
version "0.18.1"
resolved "https://registry.yarnpkg.com/meshoptimizer/-/meshoptimizer-0.18.1.tgz#cdb90907f30a7b5b1190facd3b7ee6b7087797d8"
integrity sha512-ZhoIoL7TNV4s5B6+rx5mC//fw8/POGyNxS/DZyCJeiZ12ScLfVwRE/GfsxwiTkMYYD5DmK2/JXnEVXqL4rF+Sw==

methods@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
Expand Down Expand Up @@ -8827,10 +8821,10 @@ text-table@^0.2.0:
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==

three@0.153.0:
version "0.153.0"
resolved "https://registry.yarnpkg.com/three/-/three-0.153.0.tgz#d8f2aab7b49ae4ac947fd0e24cebec11378758f0"
integrity sha512-OCP2/uQR6GcDpSLnJt/3a4mdS0kNWcbfUXIwLoEMgLzEUIVIYsSDwskpmOii/AkDM+BBwrl6+CKgrjX9+E2aWg==
three@0.156.1:
version "0.156.1"
resolved "https://registry.yarnpkg.com/three/-/three-0.156.1.tgz#bab4fec121a5b3975eb4f4d227d9c912171eb399"
integrity sha512-kP7H0FK9d/k6t/XvQ9FO6i+QrePoDcNhwl0I02+wmUJRNSLCUIDMcfObnzQvxb37/0Uc9TDT0T1HgsRRrO6SYQ==

through2@^2.0.3:
version "2.0.5"
Expand Down

0 comments on commit cade387

Please sign in to comment.