0.5.1 • Published 3 years ago

aframe-gui v0.5.1

Weekly downloads
51
License
MIT
Repository
github
Last release
3 years ago

aframe-gui

A graphical User Interface framework for A-Frame.

npm.io

The aframe-gui components provide layout and gui widgets that can be used to create a user interface in an A-Frame scene.

The dist/aframe-gui.js file defines the following components:

ComponentPrimitiveDescription
gui-flex-containera-gui-flex-containerLayout container with flexbox-inspired
gui-itemUsed by other components for common properties like height and width
gui-interactableUsed by other components to define onclick behavior
gui-cursora-gui-cursorCursor used to interact with GUI elements.
gui-buttona-gui-buttonStandard button component with text label
gui-icon-buttona-gui-icon-buttonButton with icon label instead of text
gui-icon-label-buttona-gui-icon-label-buttonButton with both icon and text labels
gui-radioa-gui-radioRadio button
gui-togglea-gui-toggleToggle button
gui-slidera-gui-sliderSlider component
gui-vertical-slidera-gui-sliderVertical slider component
gui-inputa-gui-inputText input field
gui-labela-gui-labelText label
gui-progress-bara-gui-progress-barProgress bar
gui-circle-loadera-gui-circle-loaderCircular progress meter
gui-circle-timera-gui-circle-timerCircular progress meter with timer

key_orange | '#ed5b21' | key_orange_light | '#ef8c60' | key_grey | '#22252a' | key_grey_dark | '#2c3037' | key_grey_light | '#606876' | key_offwhite | '#d3d3d4' | key_white | '#ffffff' |

Examples

Examples are available at:

https://rdub80.github.io/aframe-gui/examples/index.html

Use in your AFrame project

Include the following Javascript in the head of the page containing your AFrame scene:

https://rawgit.com/rdub80/aframe-gui/master/dist/aframe-gui.min.js

Building

Run the following to build to the examples/js folder:

npm run dist-example

npm run dist-example-min

Run locally

Run the following start the webpack-dev-server:

npm start

The webpack-dev-server should now be running at http://localhost:8080

Components

a-gui-flex-container Component

Properties

PropertyDescriptionDefault Value
flex-directionproperty specifies how flex items are placed in the flex container defining the main axis and the direction: 'row', 'column''row'
justify-contentproperty defines distributed space between and around content items along the main axis of their container: 'flexStart','center','flexEnd''flexStart'
align-itemsproperty defines distributed space between and around flex items along the cross-axis of their container. Like justify-content but in the perpendicular direction.'flexStart'
item-paddingPadding between items0.0
opacityTransparency of the flex-conntainer0.0
is-top-containerSetting background of the flex-containerfalse
panel-colorBackground color of the flex-container#22252a
panel-roundedflex-container panel rounding radius0.05
<a-gui-flex-container 
    flex-direction="column" justify-content="center" align-items="normal" component-padding="0.1" opacity="0.7" width="3.5" height="4.5" 
    panel-color="#072B73" 
    panel-rounded="0.2"
	position="0 2.5 -6" rotation="0 0 0"
>
... gui items here...

</a-gui-flex-container>

a-gui-cursor Component

Properties

PropertyDescriptionDefault Value
colorCursor initial color#ffffff
hover-colorCursor hover color#ffffff
active-colorCursor selection/active color#ed5b21
distancedistance of the pointer from the camera-1
designchoose a design: 'dot', 'ring', 'cross' or 'reticle''dot'
		<!-- Camera + cursor. -->
		<a-entity id="cameraRig" position="0 1.6 0">
			<a-camera look-controls wasd-controls position="0 0 0">
				<a-gui-cursor id="cursor"
						  raycaster="objects: [gui-interactable]"
						  fuse="true" fuse-timeout="2000"
						  color="#ECEFF1"
						  hover-color="#CFD8DC"
						  active-color="#607D8B"
						  design="ring" > <!-- dot, ring, reticle, cross  -->
				</a-gui-cursor> <!-- /cursor -->
			</a-camera> <!-- /camera -->
		</a-entity>		

Example without fuse/gaze trigger (click trigger):

		<!-- Camera + cursor. -->
		<a-entity id="cameraRig" position="0 1.6 0">
			<a-camera look-controls wasd-controls position="0 0 0">
				<a-gui-cursor id="cursor"
						  raycaster="objects: [gui-interactable]"
						  fuse="false"
				>
				</a-gui-cursor> <!-- /cursor -->
			</a-camera> <!-- /camera -->
		</a-entity>

a-gui-button Component

Properties

PropertyDescriptionDefault Value
onEvent that triggers onclick actionclick
valueText of button label
font-sizeFont size for button0.2
font-familyFont family for button''
font-colorText color for button label#d3d3d4
border-colorBorder color of button#d3d3d4
focus-colorFocus color of button#ef8c60
background-colorBackground color of button#22252a
hover-colorBackground color when button is in hover state#2c3037
active-colorBackground color when button is pressed down#ed5b21
toggleIf true, button acts as toggle button with on/off statefalse
toggle-stateSetting the toggle button on/off statefalse

| width | Width of button | 1 | | height | Height of button | 1 | | depth | Depth of button | 0.02 | | base-depth | Depth of the base of the button | 0.01 | | gap | Gap between button and base | 0.025 | | margin | Margin around button | 0 0 0 0 |

| bevel | If true, button bevel is enabled | false | | bevel-segments | Segments of the button bevel | 5 | | steps | Steps of the button bevel | 2 | | bevel-size | Size of the button bevel | 0.1 | | bevel-offset | Offset of the button bevel | 0 | | bevel-thickness | Thickness of the button bevel | 0.1 |

	<a-gui-button
		width="2.5" 
		height="0.7" 
		base-depth="0.025" 
		depth="0.1"
		gap="0.1"

		onclick="buttonActionFunction" key-code="32"
		value="Sample Button"
		font-family="assets/fonts/PermanentMarker-Regular.ttf"	
		font-size="0.25"
		margin="0 0 0.05 0"

		font-color="black"
		active-color="red"
		hover-color="yellow"
		border-color="white"
		focus-color="black"
		background-color="orange"

		bevel="true"
	>
	</a-gui-button>

a-gui-circle-loader Component

Properties

PropertyDescriptionDefault Value
active-colorColor of ring that indicates loading progress#ed5b21
background-colorBackground color of item#22252a
loadedInitial percentage progress value0.5
font-colorText color for progress percentage text#d3d3d4
font-familyFont family for progress percentage text''
font-sizeFont size for progress percentage text0.2
heightHeight of item1
widthWidth of item1
marginMargin around item0 0 0 0
	<a-gui-circle-loader
		height="0.75"
		font-family="assets/fonts/Plaster-Regular.ttf"					
		font-size="0.2"
		loaded="0.3456"		
		margin="0 0 0.1 0"
		background-color="#999"
	>
	</a-gui-circle-loader>	

a-gui-circle-timer Component

Properties

PropertyDescriptionDefault Value
font-sizeFont size for countdown text0.2
font-familyFont family for progress countdown text''
font-colorText color for progress countdown text#d3d3d4
border-colorColor of indicators that show 25/50/75/100 progress#22252a
background-colorBackground color of item#22252a
active-colorColor of ring that indicates countdown progress#ed5b21

| count-down | Initial countdown value in seconds | 0 | | callback | callback function that fires when countdown expires | '' |

| width | Width of item | 1 | | height | Height of item | 1 | | margin | Margin around item | 0 0 0 0 |

<a-gui-circle-timer
	height="0.75"
	count-down="60"
	callback="timedout"
	font-family="assets/fonts/PermanentMarker-Regular.ttf"				
	margin="0 0 0.1 0"
>
</a-gui-circle-timer>

a-gui-icon-button Component

Properties

PropertyDescriptionDefault Value
onEvent that triggers onclick actionclick

| icon | | '' | | icon-active | | '' | | icon-font | Icon font family | 'assets/fonts/fa-regular-400.ttf' | | icon-font-size | Icon Font size for button | 0.4 |

| font-color | Text color for button label | #d3d3d4 | | border-color | Border color of button | #d3d3d4 | | background-color | Background color of item | #22252a | | hover-color | Background color when button is in hover state | #2c3037 | | active-color | Background color when button is pressed down | #ed5b21 | | toggle | Toggle status | false | | toggle-state | Setting the toggle button on/off state | false |

| height | Height of item | 1 | | width | Width of item | 1 | | margin | Margin around item | 0 0 0 0 |

<a-gui-icon-button
	height="0.75"
	onclick="buttonActionFunction" key-code="32"
	icon="f09b"
	icon-font="assets/fonts/fa-brands-400.ttf"
	margin="0 0 0.05 0"
>
</a-gui-icon-button>

a-gui-icon-label-button Component

Properties

PropertyDescriptionDefault Value
onEvent that triggers onclick actionclick

| icon | icon char | '' | | icon-active | icon char for the active state | '' | | icon-font | Icon font family | 'assets/fonts/fa-regular-400.ttf' | | icon-font-size | Icon Font size for button | 0.35 |

| font-color | Text color for button label | #d3d3d4 | | value | | '' | | font-family | Font family for button | '' | | font-size | Font size for button | 0.2 | | font-color | Text color for button label | #d3d3d4 | | border-color | Border color of button | #d3d3d4 | | background-color | Background color of button | #22252a | | hover-color | Background color when button is in hover state | #2c3037 | | active-color | Background color when button is pressed down | #ed5b21 | | toggle | Toggle status | false | | toggle-state | Setting the toggle button on/off state | false |

| height | Height of button | 1 | | width | Width of button | 1 | | margin | Margin around button | 0 0 0 0 |

<a-gui-icon-label-button
	width="2.5" height="0.75"
	onclick="buttonActionFunction"
	icon="f2b9"
	icon-font="assets/fonts/fa-solid-900.ttf"
	value="icon label"
	font-family="assets/fonts/PressStart2P-Regular.ttf"
	font-size="0.16"
	margin="0 0 0.05 0"
>
</a-gui-icon-label-button>

a-gui-input Component

Properties

PropertyDescriptionDefault Value
onclickFunction to call on click event
onhoverFunction to call on hover event
valueInput text value

| font-size | Font size for input | 0.2 | | font-family | Font family for input | '' | | font-color | Text input color | #2c3037 | | border-color | Border color of input | #2c3037 | | background-color | Background color of input | #22252a | | border-hover-color | Border color when input is in hover state | #22252a | | hover-color | Background color when input is in hover state | #2c3037 |

| margin | Margin around item | 0 0 0 0 | | height | Height of item | 1 | | width | Width of item | 1 |

<a-gui-input
	width="2.5" height="0.75"
	onclick="inputActionFunction"
	font-family="assets/fonts/PermanentMarker-Regular.ttf"	
	font-size="0.2"
	value="Hello Wor_"
	margin="0 0 0.05 0"
>
</a-gui-input>

a-gui-label Component

Properties

PropertyDescriptionDefault Value
value''
aligntext-align: 'left','center','right''center'
anchortext anchor position: 'left','center','right''center'
lineHeightline-height of the label0.2
font-sizeFont size for input0.2
font-familyFont family for input''
font-colorText input color#2c3037
background-colorBackground color of label#d3d3d4

| text-depth | distance from the text to label background | 0.01 | | height | Height of item | 1 | | width | Width of item | 1 | | margin | Margin around item | 0 0 0 0 |

<a-gui-label
	width="2.5" height="0.75"
	value="test label"
	font-family="assets/fonts/DiplomataSC-Regular.ttf"
	font-size="0.35"
	line-height="0.8"
	letter-spacing="0"
	margin="0 0 0.05 0"
>
</a-gui-label>

a-gui-progress-bar Component

Properties

PropertyDescriptionDefault Value
background-colorBackground color of progress bar#22252a
active-colorColor for indicating progress level#ed5b21
heightHeight of item1
widthWidth of item1
marginMargin around item0 0 0 0
<a-gui-progressbar 
	width="2.5" height="0.25"
	margin="0 0 0.05 0"
>
</a-gui-progressbar>

a-gui-radio Component

Properties

PropertyDescriptionDefault Value
onEvent that triggers onclick actionclick
checkedfalse
activetrue
toggleToggle statusfalse
toggle-stateSetting the radio button on/off statefalse

| value | | '' | | font-family | Font family for radio button | '' | | font-size | Font size for radio button | 0.2 | | font-color | Text color for radio button label | #2c3037 | | border-width | | 1 | | border-color | Border color of radio button | #ffffff | | background-color | Background color of radio button | #d3d3d4 | | hover-color | Background color when radio button is in hover state | #606876 | | handle-color | | #22252a | | active-color | Background color when radio button is pressed down | #ed5b21 |

| height | Height of radio button | 1 | | width | Width of radio button | 1 | | margin | Margin around radio button | 0 0 0 0 |

<a-gui-radio
	width="2.5" height="0.75"
	onclick="toggleActionFunction"
	value="radio label"
	font-size="0.3"
	margin="0 0 0.05 0"
>
</a-gui-radio>

a-gui-slider Component

Properties

PropertyDescriptionDefault Value
active-color#ed5b21
background-color#d3d3d4
border-color#22252a
handle-color#ffffff
handle-outer-radius'0.17'
handle-inner-radius'0.13'
handle-outer-depth'0.04'
handle-inner-depth'0.02'
heightHeight of item1
hover-color#606876
left-right-padding'0.25'
marginMargin around item0 0 0 0
onclickJavascript function to execute on click
onhoverJavascript function to execute on click
percent'0.5'
slider-bar-depth'0.03'
slider-bar-height'0.05'
top-bottom-padding'0.125'
widthWidth of item1
<a-gui-slider 	
	width="2.5" height="0.75"
	onclick="slideActionFunction"
	percent="0.29"
	margin="0 0 0.05 0"
>
</a-gui-slider>

a-gui-toggle Component

Properties

PropertyDescriptionDefault Value
onEvent that triggers onclick actionclick
checkedfalse
activefalse
toggleToggle statusfalse
toggle-stateSetting the toggle toggle button on/off statefalse

| value | | '' | | font-family | Font family for toggle button | '' | | font-size | Font size for toggle button | 0.2 | | font-color | Text color for toggle button label | #d3d3d4 | | border-width | | 1 | | border-color | Border color of toggle button | #d3d3d4 | | background-color | Background color of toggle button | #22252a | | hover-color | Background color when toggle button is in hover state | #2c3037 | | handle-color | | #d3d3d4 | | active-color | Background color when toggle button is pressed down | #ed5b21 |

| height | Height of toggle button | 1 | | width | Width of toggle button | 1 | | margin | Margin around toggle button | 0 0 0 0 |

<a-gui-toggle
	width="2.5" height="0.75"
	onclick="testToggleAction"
	value="toggle label"
	font-family="assets/fonts/Plaster-Regular.ttf"
	font-size="0.2"
	margin="0 0 0.05 0"
>
</a-gui-toggle>

a-gui-vertical-slider Component

Properties

PropertyDescriptionDefault Value
active-color#ed5b21
background-color#d3d3d4
border-color#22252a
handle-color#ffffff
handle-outer-radius0.17
handle-inner-radius0.13
handle-outer-depth0.04
handle-inner-depth0.02
hover-color#606876
hover-font-sizeFont size of label indicating where user is hovering0.2
hover-heightHeight of label indicating where user is hovering1.0
hover-marginMargin of label indicating where user is hovering1.0
hover-percentCurrent percentage where user is hovering
hover-widthWidth of label indicating where user is hovering1.0
left-right-padding0.25
marginMargin around item'0 0 0 0'
onclickJavascript function to execute on click
onhoverJavascript function to execute on click
opacityTransparency of the vertical slider background1.0
output-font-sizeFont size of label indicating output value0.2
output-functionName of function to calculate output value from percent
output-heightHeight of label indicating output value1.0
output-marginMargin of label indicating output value'0 0 0 0'
output-widthWidth of label indicating output value1.0
percentCurrent selected slider value, from 0.0 to 1.00.5
slider-bar-depth0.03
slider-bar-height0.05
top-bottom-padding0.125
heightHeight of item1
widthWidth of item1
<a-gui-slider 	
	width="2.5" height="0.75"
	onclick="slideActionFunction"
	percent="0.29"
	margin="0 0 0.05 0"
>
</a-gui-slider>
0.5.0

3 years ago

0.5.1

3 years ago

0.3.8

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.5

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago