Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/components/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Inspector, and play with all the possible values to see the effects instantly!
| width | Width in meters. | *derived from geometry if exists* |
| wrapCount | Number of characters before wrapping text (more or less). | 40 |
| wrapPixels | Number of pixels before wrapping text. | *derived from wrapCount* |
| xOffset | X-offset to apply to add padding. | 0 |
| zOffset | Z-offset to apply to avoid Z-fighting if using with a geometry as a background. | 0.001 |

[threetextusage]: https://github.com/Jam3/three-bmfont-text#usage
Expand Down
4 changes: 3 additions & 1 deletion src/components/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ module.exports.Component = registerComponent('text', {
wrapCount: {type: 'number', default: 40},
// `wrapPixels` will wrap using bmfont pixel units (e.g., dejavu's is 32 pixels).
wrapPixels: {type: 'number'},
// `xOffset` to add padding.
xOffset: {type: 'number', default: 0},
// `yOffset` to adjust generated fonts from tools that may have incorrect metrics.
yOffset: {type: 'number', default: 0},
// `zOffset` will provide a small z offset to avoid z-fighting.
Expand Down Expand Up @@ -313,7 +315,7 @@ module.exports.Component = registerComponent('text', {
}

// Position and scale mesh to apply layout.
mesh.position.x = x * textScale;
mesh.position.x = x * textScale + data.xOffset;
mesh.position.y = y * textScale;
// Place text slightly in front to avoid Z-fighting.
mesh.position.z = data.zOffset;
Expand Down