Skip to content

Instantly share code, notes, and snippets.

@marklundin
Created April 19, 2024 12:27
Show Gist options
  • Save marklundin/60cfcf891bcf8083258bcf2e527d87be to your computer and use it in GitHub Desktop.
Save marklundin/60cfcf891bcf8083258bcf2e527d87be to your computer and use it in GitHub Desktop.
class Rotator {
/**
* @attribute
* Including the `@attribute` block tag exposes the property to the editor.
*/
speed = 10
/**
* This is not an attribute and is not exposed to the editor
*/
notAnAttribute = false
/**
* @attribute
* Attributes can surface additional contextual metadata in the form of custom tags,
* which provide addition information. In the editor this is used to make decisions
* about presenting UI controls.
*
* Range, step, precision specifies numerical constraints
* @range [0.1, 10]
* @precision 0.01
* @step 0.005
*/
velocity = 2
/**
* @attribute
* The first paragraph of tex content in an attribute commenbt becomes a description
* in attribute metadata.
*
* The `@title` tag becomes a short label
* @title Max Speed
*/
someObscureAndLongInternalPropertyName = 'hmm'
/**
* @attribute
* If an attribute is initialized, it's type is inferred. If not, it
* must be defined via the `@type` tag. Without either, the attribute
* is invalid and is ignored. If both exist, the inferred type is used
*
* @type {string}
*/
uninitializedString
/**
* @attribute
* This covers the 'json' use case, and allows for complex type
*
* @type {EnemyType}
*/
enemy = new EnemyType()
/**
* @attribute
* @type {Lights}
*/
lights = 1
}
/**
* @serializable - TBD
* The `@serializalbe` allows a class to be used as an attribute type
*/
class EnemyType {
/**
* @attribute
*/
speed = 10
/**
* @attribute
*/
power = 3
}
/**
* @enum
* The `@enum` tag marks
*/
class Lights {
ON = 1
OFF = 0
UNKNOWN = 0.5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment