Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit d28ec62

Browse files
troika-three-text TextComponent (#9341)
* new: TroikaText package and TextComponent+TextNodeEditor registered * new: TextComponent+TextNodeEditor initial sketch * chg: Better Font properties editor mapping (grouped) * new,doc,fmt: FontFamily editor mapping and doc/fmt changes. See descr. doc: Better TextMesh doc comments formatting new: font family editor mapping doc: Reformated all temp TextMesh properties comments for better organization fmt: new "unlikely" temp section for TextMesh properties new: FontDefault value, for initializing the default font URI * doc: Grouped the properties into sections for wip work scheduling * new: Text Indentation property mapped to the editor * new: Letter Spacing property mapped to the editor * new: Text Width property mapped to the editor * new: Text Outline Width property mapped to the editor * new: Text Fill Opacity property mapped to the editor * new: Text Stroke Opacity property mapped to the editor * new: Text Outline Opacity property mapped to the editor * new: Text Stroke Width property mapped to the editor * new: Text Outline Blur property mapped to the editor * new: Text Outline Offset (x,y) properties mapped to the editor * new: GPU Acceleration force-disable property mapped to the editor * new: Text Anchor property mapped to the editor * new: Text Curve property mapped to the editor * new: Text Depth Offset property mapped to the editor * new: Text Direction property mapped to the editor * new: Text Alignment property mapped to the editor * new: Text Wrapping properties mapped to the editor * doc: Better FontDefault description * new: Text Outline+Stroke Color properties mapped to the editor * new: Advanced props hiding. Clipping+Glyph props mapped to the editor * doc: Fixed misuse of @abstract, removed @option and added @summary * doc: Updated the properties list for multilang and not-used props * chg: Moved SelectOptions to @Local scope, so the object is not GC'ed * fix: Correct MathUtils import for `npm run test` * fix: Correct Color and Material referencing from Three.js * new: Text LineHeight property mapped into the editor * new: Text Orientation property mapped into the editor * new,chg: Material property and new HoverInfo properties. See descr. new: Font Material property mapped to the editor. new: FontFamily, Clipping, GlyphResolution, GlyphDetail and GPUAccelerated hover info descriptions chg: <br> Separation between each InputGroup section for readability. chg: Default clipRectMin changed to a negative value, so it works as expected by default. * chg: Set safe max value for glyphResolution * doc: Small doc comments improvements * chg: Added onRelease support for BooleanInput * chg: Added onRelease behavior for the TextNodeEditor boolean inputs * fmt: Final polishing before PR review * chg: Applied PR review changes * chg: Translation ids for TextComponent editor properties * change mesh init * fix type * fix: Support for nullable TextMesh in text.troikaMesh * doc: Better use of JSDoc comments. Removed misuse of @enum --------- Co-authored-by: Daniel Belmes <3631206+DanielBelmes@users.noreply.github.com>
1 parent 63732ff commit d28ec62

9 files changed

Lines changed: 999 additions & 3 deletions

File tree

packages/client-core/i18n/en/editor.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,44 @@
835835
"description": "An object with a pose to define interactable behaviors.",
836836
"lbl-type": "Type",
837837
"lbl-dismount": "Dismount point, offsets this transform"
838+
},
839+
"text": {
840+
"textGroup": "Text",
841+
"textOpacity": "opacity",
842+
"textWidth": "width",
843+
"textIndent": "indent",
844+
"textAlign": "align",
845+
"textWrap": "wrap",
846+
"textAnchor": "anchor",
847+
"textDepthOffset": "depthOffset",
848+
"textCurveRadius": "curveRadius",
849+
"letterSpacing": "letterSpacing",
850+
"lineHeightGroup": "lineHeight",
851+
"lineHeight": "height",
852+
"textDirection": "direction",
853+
"fontGroup": "Font",
854+
"fontFamily": "family",
855+
"fontSize": "size",
856+
"fontColor": "color",
857+
"fontMaterial": "material",
858+
"outlineGroup": "Outline",
859+
"outlineColor": "color",
860+
"outlineOpacity": "opacity",
861+
"outlineWidth": "width",
862+
"outlineBlur": "blur",
863+
"outlineOffset": "offset",
864+
"strokeGroup": "Stroke",
865+
"strokeColor": "color",
866+
"strokeOpacity": "opacity",
867+
"strokeWidth": "width",
868+
"advancedActive": "Show Advanced",
869+
"advancedGroup": "Advanced",
870+
"clippingActive": "clip.active",
871+
"clippingMin": "clip.min",
872+
"clippingMax": "clip.max",
873+
"glyphResolution": "glyph.resolution",
874+
"glyphDetail": "glyph.detail",
875+
"gpuAccelerated": "GPU Accelerated"
838876
}
839877
},
840878
"projects": {

packages/editor/src/components/element/ElementList.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import { MountPointComponent } from '@etherealengine/engine/src/scene/components
6969
import { PostProcessingComponent } from '@etherealengine/engine/src/scene/components/PostProcessingComponent'
7070
import { SceneDynamicLoadTagComponent } from '@etherealengine/engine/src/scene/components/SceneDynamicLoadTagComponent'
7171
import { ShadowComponent } from '@etherealengine/engine/src/scene/components/ShadowComponent'
72+
import { TextComponent } from '@etherealengine/engine/src/scene/components/TextComponent'
7273
import { Vector3 } from 'three'
7374
import { PrimitiveGeometryComponent } from '../../../../engine/src/scene/components/PrimitiveGeometryComponent'
7475
import { ItemTypes } from '../../constants/AssetTypes'
@@ -114,7 +115,14 @@ export const ComponentShelfCategories: Record<string, Component[]> = {
114115
],
115116
FX: [LoopAnimationComponent, ShadowComponent, ParticleSystemComponent, EnvmapComponent, PostProcessingComponent],
116117
Scripting: [SystemComponent, BehaveGraphComponent],
117-
Misc: [EnvMapBakeComponent, ScenePreviewCameraComponent, SkyboxComponent, SplineTrackComponent, SplineComponent]
118+
Misc: [
119+
EnvMapBakeComponent,
120+
ScenePreviewCameraComponent,
121+
SkyboxComponent,
122+
SplineTrackComponent,
123+
SplineComponent,
124+
TextComponent
125+
]
118126
}
119127

120128
const SceneElementListItem = ({ item, onClick, onContextMenu }: SceneElementListItemType) => {

packages/editor/src/components/inputs/BooleanInput.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ let uniqueId = 0
3636
interface BooleanInputProp {
3737
value: boolean
3838
onChange: (value: boolean) => void
39+
onRelease?: (value: boolean) => void
3940
disabled?: boolean
4041
}
4142

@@ -46,6 +47,10 @@ export const BooleanInput = (props: BooleanInputProp) => {
4647
props.onChange(e.target.checked)
4748
}
4849

50+
const onBlur = (e) => {
51+
if (props.onRelease) props.onRelease(props.value)
52+
}
53+
4954
const onKeyPress = (e: KeyboardEvent<HTMLLabelElement>) => {
5055
if (e.key === 'Enter' || e.key === ' ') props.onChange(!props.value)
5156
}
@@ -58,6 +63,7 @@ export const BooleanInput = (props: BooleanInputProp) => {
5863
type="checkbox"
5964
checked={props.value}
6065
onChange={onChange}
66+
onBlur={onBlur}
6167
disabled={props.disabled}
6268
/>
6369
<label htmlFor={checkboxId} className="Input BooleanInputLabel" tabIndex={0} onKeyPress={onKeyPress}>

packages/editor/src/components/inputs/SelectInput.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ interface SelectInputProp<T> {
3737
value: T | string
3838
options: Array<{ label: string; value: T; info?: string }>
3939
onChange?: (value: T | string) => void
40+
onRelease?: (value: T | string) => void
4041
placeholder?: string
4142
disabled?: boolean
4243
creatable?: boolean
@@ -48,6 +49,7 @@ export function SelectInput<T extends string | ReadonlyArray<string> | number |
4849
value,
4950
options,
5051
onChange,
52+
onRelease,
5153
placeholder = 'Select...',
5254
disabled,
5355
creatable,
@@ -59,6 +61,10 @@ export function SelectInput<T extends string | ReadonlyArray<string> | number |
5961
onChange?.(event.target.value)
6062
}
6163

64+
const handleBlur = () => {
65+
if (onRelease) onRelease(value)
66+
}
67+
6268
const onValueChanged = (event, label, ...args) => {
6369
const value = options.find((el) => el.value === value)!.value
6470
onChange?.(value)
@@ -106,6 +112,7 @@ export function SelectInput<T extends string | ReadonlyArray<string> | number |
106112
id="select"
107113
value={value}
108114
onChange={handleChange}
115+
onBlur={handleBlur}
109116
placeholder={placeholder}
110117
size="small"
111118
classes={{

0 commit comments

Comments
 (0)