Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

troika-three-text

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

troika-three-text - npm Package Compare versions

Comparing version 0.31.0 to 0.32.0

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [0.32.0](https://github.com/protectwise/troika/compare/v0.31.0...v0.32.0) (2020-09-16)
### Bug Fixes
* mutate boundingBox and set depth to 0 ([1f9b6be](https://github.com/protectwise/troika/commit/1f9b6bef083c26c9de9ac0ce169544ed3f99cf89))
### Features
* added boundingBox calculation ([140e9e8](https://github.com/protectwise/troika/commit/140e9e8bf2865c54f21877ca03834bbde4e9ab52))
# [0.31.0](https://github.com/protectwise/troika/compare/v0.30.2...v0.31.0) (2020-08-11)

@@ -8,0 +24,0 @@

8

package.json
{
"name": "troika-three-text",
"version": "0.31.0",
"version": "0.32.0",
"description": "SDF-based text rendering for Three.js",

@@ -18,4 +18,4 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>",

"dependencies": {
"troika-three-utils": "^0.31.0",
"troika-worker-utils": "^0.31.0"
"troika-three-utils": "^0.32.0",
"troika-worker-utils": "^0.32.0"
},

@@ -30,3 +30,3 @@ "devDependencies": {

},
"gitHead": "05e74d4a422538cf973fc2e670c78a4a8460abfa"
"gitHead": "9f263fcbf9d5c45dc3c73ede2baf7db26978f2ec"
}

@@ -214,2 +214,27 @@ # `troika-three-text`

## Handling Asynchronous Updates
Since the text processing occurs in a web worker, it is by definition asynchronous. This means that you can't rely on the text being visible or having a complete geometry immediately. If you need to do things like access the geometry's `boundingSphere` or the `textRenderInfo`, you will have to listen for completion. You can do this two ways:
1. Pass a callback function when you call the `sync` method:
```js
myText.sync(() => {
// code to execute after sync completes...
})
```
This is best when you want to only react to _that specific_ sync call. Keep in mind that the callback will not execute if the text is already fully synced.
2. Add a listener for the `synccomplete` event:
```js
myText.addEventListener('synccomplete', () => {
// code to execute after sync completes...
})
```
This will fire after _every_ sync, no matter who invoked it. This is best if you need to react to all syncs, for example to trigger a manual canvas render.
## Preloading

@@ -261,3 +286,3 @@

In addition to rendering text, it is possible to access positioning information for caret placement and selection ranges. To access that info, use the `getCaretAtPoint` and `getSelectionRects` utility functions. Both of these functions take a `textRenderInfo` object as input, which you can get from the `Text` object either in the `sync()` callback or from its `textRenderInfo` property after sync has completed.
In addition to rendering text, it is possible to access positioning information for caret placement and selection ranges. To access that info, use the `getCaretAtPoint` and `getSelectionRects` utility functions. Both of these functions take a `textRenderInfo` object as input, which you can get from the `Text` object's `textRenderInfo` property after sync has completed. See "Handling Asynchronous Updates" above for how to react to sync completion events.

@@ -264,0 +289,0 @@ #### `getCaretAtPoint(textRenderInfo, x, y)`

@@ -6,2 +6,3 @@ import {

Sphere,
Box3,
Vector3

@@ -65,2 +66,3 @@ } from 'three'

this.boundingSphere = new Sphere()
this.boundingBox = new Box3();
}

@@ -72,2 +74,6 @@

computeBoundingBox() {
// No-op; we'll sync the boundingBox proactively in `updateGlyphs`.
}
set detail(detail) {

@@ -118,2 +124,7 @@ if (detail !== this._detail) {

sphere.radius = sphere.center.distanceTo(tempVec3.set(totalBounds[0], totalBounds[1], 0))
// Update the boundingBox based on the total bounds
const box = this.boundingBox;
box.min.set(totalBounds[0], totalBounds[1], 0);
box.max.set(totalBounds[2], totalBounds[3], 0);
}

@@ -120,0 +131,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc