a_entity: a_entity

Description Usage Arguments Details Value

View source: R/entity.R


Create an A-Frame entity


a_entity(.tag = "entity", .js_sources = NULL, id = NULL,
  .children = NULL, .assets = NULL, ...)



text for the entity tag. The default is "a-entity", but it can be used to create any of the A-Frame built-ins for example using "a-sphere"


a vector of links to Javascript files this entity depends on. Useful if adding a community-made component to an entity. The script file will be automatically be sourced in the html header by the parent scene.


an optional id for the entity, useful if you want to later add children to it.


a list of A-Frame entities to be nested within the HTML tag of this entity.


any assets needed by this entity that are not assigned in component configuration. For example it may be that this entity begins the scene with one texture and later is changed to second texture due to an event. It is preferable that the second texture is loaded in the asset block and so is cached and ready to go when the event happens.


components to be added to the entity. See description.


This function creates an A-Frame entity object to be inserted into to an A-Frame scene. The A-Frame scene object instructs entities to render themselves to html, when serving or writing itself.

Function arguments supplied in '...' map directly to underlying entity components expressed in the html. There two tricks to this: 1. components specified in R must use an single underscore ('_') where a single dash would appear in an A-Frame component name between words. It is converted to '-' when rendered in HTML. Double underscores and leading/trailing underscores are not converted. 2. Components specified by name only, without any configuration must use the form 'component_name = NULL' or component_name = "". For example: to create an A-Frame entity with the 'wasd-controls' component attached, this function would be called as 'a_entity(wasd_controls="")'.

Underscore conversion is provided as a convenience to save the user wrapping many component names in “. It can be swtiched off by supplying a "'" as the first character of a property name, e.g.: list(''this_is_really_what_want' = "foo"). The leading "'" is stripped when rendering to HTML.

Component configuration can be expressed in character form, e.g. 'wasd_controls = "fly: true; acceleration: 65"' in which case it is passed into html directly. It can also be expressed as a list: 'wasd_controls = list(fly = TRUE, acceleration = 65)', in which case it is converted to the appropriate text.

Child entities can be nested within the HTML tag of a parent entity by supplying them as a list in the 'children' argument.


A_Entity object

MilesMcBain/r2vr documentation built on Dec. 8, 2018, 10:13 a.m.