Alex/text updates (#5012)

* feat(viewer-lib): Text updates:
- Update to latest troika-three-text version
- Started working on the new TextBatch whoich will actually batch texts
- Augmented BatchedText type from troika
- Renamed old SpeckleText to TextLabel

* feat)viewer-lib): Copied over the batched version for the speckle text into our text material since troika won't export it

* feat(viewer-lib): First draft on text batching

* feat(viewer-lib): WIP on TextBatch and SpeckleText

* feat(viewer-lib): SpeckleText batch now has working TAS and BAS. Overloaded getBatches to also take an array of geometry types and added GeometryType.TEXT in places where required alongisde MESH

* feat(viewer-lib): Text batch has correctly transformed texts

* feat(viewer-lib): Patched troika BatchedText to allow per text opacity. Draw ranges for text batches are now functional

* feat(viewer-lib): Fixed an issue with the BAS not correctly reporting bounds. Had to override two methods completely in our SpeckleText extension of the BatchedText just so that we don't do stupid things and still get good performance when dealing with a huge number of texts

* feat(viewer-lib): Added text batch object count limit. Default is 5k. Implemented proper material caching and cloning inside SpeckleText. Overriden the default updateBounds function so that we don't waste tens of millisecons per frame!!! pointlessly

* feat(viewer-lib): Implemented TextBatchObject along with individual text batch object transform manipulation at batch level.

* chore(viewer-lib): Updated the pipelines to not render text geometries twice

* feat(viewer-lib): Implemented RTE for batched text rendering. As with the rest of the geometry types, RTE is automaic and will only be used when needed

* feat(viewer-lib): Integrated remaining text v3 features: alignments and maxWidth

* feat(viwer-lib): Implemented billboarding and RTE billboarding for text.

* feat(viewer-lib): Text batches now report correct object materials and can be filtered properly

* fix(viewer-lib): Some Fixes:
- The need for text RTE is now correctly being computed on the right text dimensions
- Sequential update ranges now correctly apply materials to all of them

* fix(viewer-lib): RTE text box is now correctly transformed. The text batch object only uses the TAS for intersecting since it's BAS is redundant.

* feat(viewer-lib): Text batches now correctly use gradient/ramp textures along with sample indices for colored filtering.

* feat(viewer-lib): Implemented raycasting for billboarded text batches in the most simple and robust way I was capable of. Lacks TAS speedup but it's a compromise we have to make and one which we probably will never regret

* feat(viewer-lib): Good progress on reworking TextLabel, which replaces the old multi purpose SpeckleText, which we use internally for measurements. More precise rendering, no more rogue margins between text and background. Regular billboarding now also works, along with non-billboarded rendering

* feat(viewer-lib): Finally a unified billboarding solution in SpeckleBasicMaterial. Supporting both world and screen billboarding; SpeckleTextMaterial now extends SpeckleBasicMaterial; TextLabel now has proper control over size and margins. No more weird offsets. Added background margins to the text params which work in both world and screen space.

* feat(viewer-lib): Implemented raycasting for all billboarding types. Spent quite some time on the screen billboarding one because of a stupid mistake

* chore(viewer-lib): Added (vibed) type declaration file for troika's Text class and fixed compiler errors for TextLabel

* chore(viewer-lib): Renamed SpeckleText to SpeckleBatchedText and fixed all compiler errors. Updated type definition file

* feat(viewer-lib): Integrated TextLabel with measurements. Simplified a lot of code

* fix(viewer-lib): Some updates and fixes to text and measurements integration
- Screen space billboarding now also takes an NDC offset alongside the size.
- Added auto margin calculation for TextLabel background so it's always centered regardless of anchor-ing
- DPR is automatically factored in for TextLabel
- Some changes to sizes and margins for measurements

* fix(viewer-lib): Bunch of fixes and tweaks

* fix(viewer-lib): Area measurement's area plane no longer overdraws on top of the area value text label via simple stenciling

* fix(viewer-lib): Fixed CI build

* fix(viewer-lib): Fixed CI build

* feat(viewer-lib): Slightly reduces the size and h margin of text gizmos for measurements

* fix(viewer-lib): Fixed incorrect text transformation when neither RTE nor billboarded

* chore(viewer-lib): Added review suggestions
This commit is contained in:
Alexandru Popovici
2025-07-15 14:48:13 +03:00
committed by GitHub
parent ed875f0134
commit f3974dd9d0
38 changed files with 2631 additions and 988 deletions
+31 -1
View File
@@ -16502,7 +16502,7 @@ __metadata:
three: "npm:^0.140.0"
three-mesh-bvh: "npm:0.5.17"
tree-model: "npm:1.0.7"
troika-three-text: "npm:0.47.2"
troika-three-text: "npm:0.52.4"
type-fest: "npm:^4.15.0"
typescript: "npm:^4.5.4"
vitest: "npm:^1.4.0"
@@ -47218,6 +47218,20 @@ __metadata:
languageName: node
linkType: hard
"troika-three-text@npm:0.52.4":
version: 0.52.4
resolution: "troika-three-text@npm:0.52.4"
dependencies:
bidi-js: "npm:^1.0.2"
troika-three-utils: "npm:^0.52.4"
troika-worker-utils: "npm:^0.52.0"
webgl-sdf-generator: "npm:1.1.1"
peerDependencies:
three: ">=0.125.0"
checksum: 10/bbc0aaaed657b30240b69034543ac71451590e0b7403ae9eadc6b0891b791434185e687c6db545c23433fea0bfe93d67def3e1d120ba73dae74fe08aea95e8ca
languageName: node
linkType: hard
"troika-three-utils@npm:^0.47.2":
version: 0.47.2
resolution: "troika-three-utils@npm:0.47.2"
@@ -47227,6 +47241,15 @@ __metadata:
languageName: node
linkType: hard
"troika-three-utils@npm:^0.52.4":
version: 0.52.4
resolution: "troika-three-utils@npm:0.52.4"
peerDependencies:
three: ">=0.125.0"
checksum: 10/cd2382b50584fdbec86c6ab9ac771c777cc937b9f23f40cb3f2fa3f401ba438ffea822171f84fddc7d6537798e4fc1cc8c2f5fe81b04b3e1e6e7bb6c2f228f5c
languageName: node
linkType: hard
"troika-worker-utils@npm:^0.47.2":
version: 0.47.2
resolution: "troika-worker-utils@npm:0.47.2"
@@ -47234,6 +47257,13 @@ __metadata:
languageName: node
linkType: hard
"troika-worker-utils@npm:^0.52.0":
version: 0.52.0
resolution: "troika-worker-utils@npm:0.52.0"
checksum: 10/7b58418a201611f0e350534c6ab6c4fcc0121d6ed3fdaf74b04b8d873e87341122e4f344d48c144d37cce73263d9948db9a7ab61141d90eed3652ebada4b56e4
languageName: node
linkType: hard
"true-myth@npm:^8.5.0":
version: 8.5.0
resolution: "true-myth@npm:8.5.0"