Hiber3D HDK React
Hiber3D HDK is a Typescript library for creating web-based 3D experiences. Powered by the lightweight Hiber engine it is compatible across all major mobile, tablet, and desktop browsers. It features built-in multiplayer, character controls, gameplay mechanics, customizable avatars and more, allowing you to create interactive 3D worlds rapidly.
The hdk-react
package contains only basic renderer and core functions for working with a scene graph with a React component architecture. It is typically used together with component libraries like hdk-react-components (opens in a new tab) and helper libraries like hdk-utils (opens in a new tab).
Installation
Install with NPM:
npm i @hiber3d/hdk-react-components
or with yarn:
yarn add @hiber3d/hdk-react-components
Usage
import { HNode, Prefab, render } from '@hiber3d/hdk-react';
import { Ground, ImagePanel } from '@hiber3d/hdk-react-components';
const World = () => (
<HNode>
<Ground material="t_snow_01" water waterOffset={0.2} />
<Prefab id="gpl_spawn_point_01" y={1} rotY={270} />
<ImagePanel
src="https://cdn.hibervr.com/demo/img/Lunch.jpg"
scale={2}
x={15}
y={3}
rotY={90}
ratio={1000 / 750}
backside
frame="modern"
/>
</HNode>
);
render(<World />, { environment: 'planet_01' });
Animations
Animation()
function Animation(animation): HDK React Component
Makes children animate.
Parameters
Parameter | Type |
---|---|
animation | AnimationValues & AnimationOptions & { steps?: number[]; easing?: common.EasingType } |
Returns
HDK React Component
See
- Fundamentals (opens in a new tab) for basic component placement.
- Animations (opens in a new tab) for general info about animations.
- Signals (opens in a new tab) for info about signals.
Assets
AssetIDOptions
type AssetIDOptions: object;
Used to specify the id of the skybox, reflection box and light box assets for an Environment.
Type declaration
Name | Type |
---|---|
lightboxID ? | LiteralUnion <CubeMapID , string > |
reflectionboxID ? | LiteralUnion <CubeMapID , string > |
skyboxID ? | LiteralUnion <CubeMapID , string > |
BloomOptions
type BloomOptions: object;
Options for bloom effects in an Environment.
Type declaration
Name | Type |
---|---|
blendAlpha ? | number |
brightThreshold ? | number |
ColorGradingOptions
type ColorGradingOptions: object;
Color grading configuration options for an Environment.
Type declaration
Name | Type |
---|---|
brightness ? | number |
contrast ? | number |
hue ? | number |
saturation ? | number |
tintBlue ? | float3 |
tintGreen ? | float3 |
tintRed ? | float3 |
CubeMapFace
type CubeMapFace: object;
Configuration for a face of a cubemap texture.
Type declaration
Name | Type |
---|---|
url | string |
CubeMapOptions
type CubeMapOptions: object;
Specifies the URLs for the six faces of a cubemap texture.
Type declaration
Name | Type |
---|---|
back | CubeMapFace |
bottom | CubeMapFace |
front | CubeMapFace |
left | CubeMapFace |
right | CubeMapFace |
top | CubeMapFace |
FogOptions
type FogOptions: object;
Configuration options for fog effects in an Environment.
Type declaration
Name | Type |
---|---|
color ? | Color |
density ? | number |
height ? | number |
invert ? | boolean |
skyboxAlpha ? | number |
skyboxGradient ? | number |
SunOptions
type SunOptions: object;
Represents options for configuring the sun in an Environment.
Type declaration
Name | Type |
---|---|
color ? | Color |
exposureLuminanceAvg ? | number |
position ? | Vec3 |
strength ? | number |
WeatherOptions
type WeatherOptions: Pick<EnvironmentOptions, "weather">;
Options for weather configuration in an Environment.
Audio()
function Audio(
attenuationModel,
enabled,
looping,
maxAttenuationDist,
minAttenuationDist,
playOnSignal,
playSpeed,
rollOffFactor,
solo,
soundType,
src,
startPlayingDist,
volume): HDK React Component
Add an audio source, either an audio preset or an external url. An audio source can be added to any object, or to a point in space.
Parameters
Parameter | Type | Description |
---|---|---|
attenuationModel | common.AudioAttenuationModel | The way sound changes as you move around. NO_ATTENUATION , INVERSE_DISTANCE , EXPONENTIAL_DISTANCE or the default LINEAR_DISTANCE |
enabled | boolean | false means the audio is absent from the scene. |
looping | boolean | false means the sound will only play once, otherwise it will repeat. |
maxAttenuationDist | number | The maximum distance the sound can be heard, defaults to 20 . |
minAttenuationDist | number | The minimum distance the sound can be heard, defaults to 5 . |
playOnSignal | SignalListenerReference & PlayAudioOnSignalSoloProps | If defined, uses a signal to toggle playing the sound. |
playSpeed | number | - |
rollOffFactor | number | How fast the sound tapers away. |
solo | boolean | true means all other sounds are paused while playing this one. |
soundType | common.SoundType | - |
src | AudioSource | The source of the sound, either an id or an external url. |
startPlayingDist | number | The distance at which the sound starts playing, defaults to 20.1 . |
volume | number | The volume of the sound, defaults to 2 . |
Returns
HDK React Component
See
- Fundamentals (opens in a new tab) for basic component placement.
- Sound (opens in a new tab) for sound options.
Example
<Audio src={{ id: "a_am_city_01" }} volume={3} />
Environment()
function Environment(
assetIDs,
bloom,
colorGrading,
extendEnvironment,
fog,
id,
lightboxBrightness,
reflectionboxBrightness,
skybox,
skyboxBrightness,
skyboxSaturation,
sun,
weather): HDK React Component
Registers an environment for rendering scenes.
Parameters
Parameter | Type | Description |
---|---|---|
assetIDs | AssetIDOptions | Ids for skybox, reflection box, and light box assets. |
bloom | BloomOptions | Options for bloom's bright threshold and blend alpha. |
colorGrading | ColorGradingOptions | Options for color grading's hue, saturation, brightness, contrast, and tint colors. |
extendEnvironment | EnvironmentId | id of the environment to extend. |
fog | FogOptions | Options for fog's color, density, height, inversion, and skybox effects. |
id | string | The id of the environment. |
lightboxBrightness | number | - |
reflectionboxBrightness | number | - |
skybox | CubeMapOptions | URLs for each side of the skybox. |
skyboxBrightness | number | - |
skyboxSaturation | number | - |
sun | SunOptions | Options for sun's position, color, strength, and exposure luminance. |
weather | Weather | Settings for the weather, refer to WeatherPresets . |
Returns
HDK React Component
See
Fundamentals (opens in a new tab) for basic component placement.
Example
const World = () => (
<HNode>
<Prefab id={'sphere_01'} scale={3} scaleY={1.5} y={-3} material={'chrome'} />
<Environment
id="my_env"
sun={{
position: [-1, 1, 1],
color: '#63c5ea',
}}
fog={{
color: '#63c5ea',
density: 0.0000001,
}}
weather={weather.dandelion}
skybox={{
back: { url: 'https://cdn.hibervr.com/skybox_cubemaps/underwater_realm/cube_back.png' },
bottom: { url: 'https://cdn.hibervr.com/skybox_cubemaps/underwater_realm/cube_down.png' },
front: { url: 'https://cdn.hibervr.com/skybox_cubemaps/underwater_realm/cube_front.png' },
left: { url: 'https://cdn.hibervr.com/skybox_cubemaps/underwater_realm/cube_left.png' },
right: { url: 'https://cdn.hibervr.com/skybox_cubemaps/underwater_realm/cube_right.png' },
top: { url: 'https://cdn.hibervr.com/skybox_cubemaps/underwater_realm/cube_up.png' },
}}
/>
</HNode>
);
render(<World />, { environment: 'my_env' });
Prefab()
function Prefab(id, material): HDK React Component
Represents a prefabricated object in the scene.
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The id of the prefab to add. |
material | MaterialId | The material to apply to the prefab. |
Returns
HDK React Component
See
Fundamentals (opens in a new tab) for basic component placement.
Example
<Prefab id="cube_01" />
PrefabSpawner()
function PrefabSpawner(
angularVelocity,
firstSpawnShouldBeInstant,
intervalRule,
linearVelocity,
networkSynced,
prefabID,
resetOnPlayerIntentChanged,
resetOnPlayerRespawn,
spawnAmount,
spawnAmountMax,
spawnAmountMin,
spawnAmountRule,
spawnInterval,
spawnIntervalMax,
spawnIntervalMin,
spawnRule,
spawnedAmountLimit,
startIdle): HDK React Component
A component that spawns a prefab.
Parameters
Parameter | Type | Description |
---|---|---|
angularVelocity | types.float3 | - |
firstSpawnShouldBeInstant | boolean | Whether the first spawn should be instant. Defaults to true. |
intervalRule | common.PrefabSpawnerIntervalRule | The rule that determines how often the spawner should spawn a prefab. Defaults to 'DEFAULT'. |
linearVelocity | types.float3 | - |
networkSynced | boolean | - |
prefabID | PrefabId | The ID of the prefab to spawn. Optional if using built in prefab id. |
resetOnPlayerIntentChanged | boolean | Whether the spawner should reset when the player changes intent. Defaults to true. |
resetOnPlayerRespawn | boolean | Whether the spawner should reset when the player respawns. Defaults to true. |
spawnAmount | number | The amount of prefabs to spawn. Used when spawnAmountRule = DEFAULT . Defaults to 1. |
spawnAmountMax | number | The maximum amount of prefabs to spawn. Used when spawnAmountRule = RANDOM . Defaults to 0. |
spawnAmountMin | number | The minimum amount of prefabs to spawn. Used when spawnAmountRule = RANDOM . Defaults to 0. |
spawnAmountRule | common.PrefabSpawnAmountRule | The rule that determines how many prefabs should be spawned. Defaults to 'DEFAULT'. |
spawnInterval | number | The interval in seconds between each spawn. Defaults to 1. |
spawnIntervalMax | number | - |
spawnIntervalMin | number | - |
spawnRule | common.PrefabSpawnerSpawnRule | The rule that determines when the spawner should spawn a prefab. Defaults to 'START_WHEN_EMPTY'. |
spawnedAmountLimit | number | The maximum amount of spawned prefabs that exist in the world simultaneously. Defaults to 1. |
startIdle | boolean | Whether the spawner shouldn't spawn a prefab automatically. Defaults to false. |
Returns
HDK React Component
See
Fundamentals (opens in a new tab) for basic component placement.
Examples
Spawn a built in prefab
<PrefabSpawner prefabID="cube_01" />
Spawn a custom prefab, a spinning hovering cube
<PrefabSpawner y={2} z={2}>
<Spinning>
<Hovering>
<Prefab id="cube_01" />
</Hovering>
</Spinning>
</PrefabSpawner>
Temporary()
function Temporary(lifespan): HDK React Component
A component that provides property context for all children and removes them after a specified lifespan. This component has no placing or rendering capabilities. It is only used to add context to children.
Parameters
Parameter | Type | Description |
---|---|---|
lifespan | number | The lifespan in seconds. |
Returns
HDK React Component
Example
<Temporary lifespan={5}>
<HNode z={2}>
<Prefab id="cube_01" />
<Prefab id="cube_01" x={5} y={2} />
<Prefab id="cylinder_01" />
</HNode>
</Temporary>
Text()
function Text(
billboard,
color,
shadow,
size,
transparency): HDK React Component
A component that renders text.
Parameters
Parameter | Type | Description |
---|---|---|
billboard | boolean | Whether the text should face the user. |
color | Color | The color of the text. |
shadow | boolean | Whether the text should have a shadow. |
size | number | The size of the text. |
transparency | number | The transparency of the text color. A value between 0 and 1. |
Returns
HDK React Component
Example
<Text billboard size={2} shadow>Hello, world!</Text>
Context
Apply()
function Apply(props): HDK React Component
Provides property context for all children. This is used to provide a default set of props that will be applied to all children. This component has no placing or rendering capabilities. It is only used to add context to children.
Parameters
Parameter | Type | Description |
---|---|---|
props | Omit <MetadataProps & object & object & DeepPartial <VectorProperties & RotationProperties & ScaleProperties >, | "acceleration" | "maxSpeed" | "stickToCenterEnabled" | "stickToCenterSpeedFactor" | "stickToCenterDamping" | "stickToCenterPerpDamping" | "showCollider" | "direction" | "colliderMeshId" > & object & Omit <AccelerationVolume , "dir" > | Context to apply. |
Returns
HDK React Component
Example
// Apply x:2 on all nodes named 'arm', even if 'x' is explicitly set.
<Apply props={{ x: 2 }} when={node => node.name === 'arm'}>
<HNode z={2}>
<Prefab id="cube_01" name="arm" />
<Prefab id="cube_01" name="arm" x={5} y={2} />
<Prefab id="cylinder_01" name="body" />
</HNode>
</Apply>
Random()
function Random(seed): HDK React Component
Set a new random seed context for its children.
Since we want to have the same random values every time we render the scene, we need to use a random seed algorithm. This algorithm is based on the seed value that is passed to the Random component and will generate the same random values every time the seed is the same. If you want another set of random values, you can pass another seed value.
To wrap your component in a random seed context is only needed if you want to use another seed context that the default one. In most cases you don't have to use this component.
This component has no placing or rendering capabilities. It is only used to add context to children.
Parameters
Parameter | Type | Description |
---|---|---|
seed | number | The seed value to use for the random seed algorithm. |
Returns
HDK React Component
Example
// Lets create a component that returns a set number of items with random values.
type MyRandomThingProps = {
numberOfThings?: number;
};
const MyRandomThing: HDKComponent<MyRandomThingProps> = ({ numberOfThings = 10, ...props }) => {
const things = [];
const random = useRandom();
for (let index = 0; index < numberOfThings; index++) {
things.push(
<Prefab
id="rounded_cube_01"
scaleX={random.range(1, 3)}
scaleY={random.range(1, 3)}
scaleZ={random.range(1, 3)}
x={random.range(-4, 4)}
y={random.range(0, 8)}
z={random.range(-4, 4)}
rotX={random.range(0, 360)}
rotY={random.range(0, 360)}
rotZ={random.range(0, 360)}
material={random.fromArray(['palette_01_green', 'palette_01_red', 'palette_01_blue', 'palette_01_yellow'])}
/>
);
}
return <HNode {...props}>{things}</HNode>;
}
// Now we can use this component in our scene.
// We wrap the component in a <Random> component to set the seed.
<Random seed={42}>
<MyRandomThing z={10} />
</Random>
};
Gameplay
AccelerationVolume()
function AccelerationVolume(
acceleration,
colliderMeshId,
direction,
maxSpeed,
showCollider,
stickToCenterDamping,
stickToCenterEnabled,
stickToCenterPerpDamping,
stickToCenterSpeedFactor): HDK React Component
Represents an acceleration volume component in the Hiber3D environment.
Acceleration volumes provide directional acceleration to entities within their bounds. This can be used to slowly accelerate entities in a certain direction, or to shot them off like a spring board.
Parameters
Parameter | Type | Description |
---|---|---|
acceleration | number | The acceleration magnitude applied by the volume (default: 160). |
colliderMeshId | MeshId | Mesh id for the shape of the volume (default: cylinder). |
direction | float3 | The direction of acceleration as a 3-element array (default: [0, 1, 0]). |
maxSpeed | number | The maximum speed an entity can reach while inside the volume (default: 20). |
showCollider | boolean | Indicates whether to display the collider mesh for debugging purposes. |
stickToCenterDamping | number | Damping factor for sticking entities to the center (default: 1). |
stickToCenterEnabled | boolean | Indicates whether sticking to the center is enabled (default: true). |
stickToCenterPerpDamping | number | Damping factor for sticking perpendicular to the center (default: 7.5). |
stickToCenterSpeedFactor | number | Speed factor for sticking to the center (default: 5). |
Returns
HDK React Component
See
Fundamentals (opens in a new tab) for basic component placement.
Example
<AccelerationVolume
showCollider={true}
acceleration={200}
maxSpeed={25}
direction={[1, 0, 0]}
stickToCenterDamping={0.5}
stickToCenterEnabled={false}
stickToCenterPerpDamping={10}
stickToCenterSpeedFactor={3}
/>
Collectible()
function Collectible(
collectFxId,
resetFxId,
type): HDK React Component
The Collectible
component represents an in-game collectible item that can be picked up by the player. It will apply collectible properies to its only child. The component supports different types of
collectibles and can be assigned custom effects when collected or reset.
Parameters
Parameter | Type | Description |
---|---|---|
collectFxId | EffectId | The ID of the effect to play when the collectible is picked up. |
resetFxId | EffectId | The ID of the effect to play when the collectible is reset. |
type | LogicGateType | The type of collectible "MANDATORY", "GEM", "INCREMENT_TIME", "DECREMENT_TIME". |
Returns
HDK React Component
Example
<Collectible type="MANDATORY" z={4} x={3} thumbnailUrl="https://m.media-amazon.com/images/I/710dct68n1L.jpg">
<Prefab id="cube_01" />
</Collectible>
PowerUp()
function PowerUp(abilities, spawnerProps): HDK React Component
Add a power up pick up that spawns on an interval. Its children will be the pick up.
Parameters
Parameter | Type | Description |
---|---|---|
abilities | (AbilityId \ | Omit<AbilityProps, 'id'>)[] |
spawnerProps | Omit <PrefabSpawner , "prefabID" > | Config for the spawner. |
Returns
HDK React Component
See
Fundamentals (opens in a new tab) for basic component placement.
Example
<PowerUp abilities={["a_consume_increase_speed"]} spawnerProps={{ spawnInterval: 5 }}>
<Prefab id="gpl_dynamite_01" />
</PowerUp>
Light
PointLight()
function PointLight(
color,
lightOnSignal,
offset,
radius,
strength): HDK React Component
Add a point light to the scene.
Parameters
Parameter | Type | Description |
---|---|---|
color | Color | The color of the light, defaults to white. |
lightOnSignal | SignalListenerReference | If specified, use a signal to turn the light on and off. |
offset | types.float3 | - |
radius | number | The radius of the light, defaults to 10. |
strength | number | The strength of the light, defaults to 50. |
Returns
HDK React Component
Warning
Don't place too many lights close to each other, this will cause artifacts.
See
Fundamentals (opens in a new tab) for basic component placement.
Example
<PointLight strength={50} color="#ffff00" radius={10} />
SpotLight()
function SpotLight(
color,
dir,
lightOnSignal,
offset,
openingAngleDegs,
radius,
strength): HDK React Component
Add a spotlight to the scene.
Parameters
Parameter | Type | Description |
---|---|---|
color | Color | The color of the spotlight, defaults to yellow [255, 213, 97]. Warm white |
dir | types.float3 | The direction of the spotlight, defaults is down [0, -1.0, 0]. |
lightOnSignal | SignalListenerReference | Use a signal to turn the light on and off, defaults to undefined. |
offset | types.float3 | The offset of the spotlight, defaults to [0, 0, 0]. |
openingAngleDegs | number | The opening angle of the spotlight, defaults to 130. |
radius | number | The radius of the spotlight, defaults to 10. |
strength | number | The strength of the spotlight, defaults to 25. |
Returns
HDK React Component
Warning
Don't place too many lights close to each other, this will cause artifacts.
See
Fundamentals (opens in a new tab) for basic component placement.
Example
<SpotLight openingAngleDegs={30} radius={200} strength={50} color="#00aeff">
<Mesh id="en_p_light_cone_02" material={'t_light_cone_01' as Material} y={2.2} rotX={180} physical={false} />
</SpotLight>
Media
GLB()
function GLB(
collider,
material,
render,
src): HDK React Component
Adds an external GLB Mesh to the scene. Supports GLB format.
Parameters
Parameter | Type | Description |
---|---|---|
collider | boolean | false means the object will be non-physical. |
material | MaterialId | Override the built in material to use for the mesh. |
render | boolean | - |
src | AudioSource | Url of the glb file |
Returns
HDK React Component
See
Fundamentals (opens in a new tab) for basic component placement.
Example
<GLB src="https://cdn.hibervr.com/test/Spheres.glb" y={2} z={3}></GLB>
InfoPanel()
function InfoPanel(
autoOpenOverlay,
body,
header,
imageID,
isOpenInNewTabEnabled,
isOpenInOverlayEnabled,
isOpenInOverlayOnTouch,
isSidebarOverlay,
maxShowDistance,
minShowDistance,
openUrlInNewTab,
preBody,
showOpenBinding,
url): HDK React Component
Makes all children show an info panel when looking at them. The info panel can be used to open up a web page for further interaction.
Parameters
Parameter | Type | Description |
---|---|---|
autoOpenOverlay | boolean | - |
body | types.str80 | The body of the info panel, max 80 characters. |
header | string | The header of the info panel. |
imageID | types.TextureID | The icon that should be shown the info panel. |
isOpenInNewTabEnabled | boolean | true if interacting withthe info panel should open the url in a new tab. |
isOpenInOverlayEnabled | boolean | true if opening the url should be in an overlay, if applicable. |
isOpenInOverlayOnTouch | boolean | true if the overlay should be available on touch. |
isSidebarOverlay | boolean | false if the overlay should be shown as a sidebar. |
maxShowDistance | number | The max distance at which the info panel should be shown. |
minShowDistance | number | The min distance at which the info panel should be shown. |
openUrlInNewTab | boolean | true if the url should be opened in a new tab rather than the current. |
preBody | types.str80 | The ingress of the info panel, max 80 characters. |
showOpenBinding | boolean | true if the 'open' binding key should be shown in the panel. |
url | string | The target url for interacting with the panel. |
Returns
HDK React Component
Example
<InfoPanel
header="Hiber3D Development Kit"
body="Check out our documentation!"
url="https://developer.hiber3d.com/docs"
openUrlInNewTab={true}>
<Prefab id="hologram_01_hibert" />
</InfoPanel>
Other
HDKComponentArgs
type HDKComponentArgs: HDKElementArgs & object & TransformProperties;
Base props for all placeable HDK React components
HDKElementArgs
type HDKElementArgs: MetadataProps & object;
Base props for nodes in a HDK React component tree
Type declaration
Name | Type |
---|---|
children ? | React.ReactNode |
key ? | string | number | null |
name ? | string |
tag ? | string | string [] |
MetadataProps
type MetadataProps: object;
Base metadata props for all HDK React components
Type declaration
Name | Type |
---|---|
metadata ? | DeepPartial <Metadata > |
GameplaySettings()
function GameplaySettings(
gameplayMatchSettings,
gameplayRequestRespawnSetting,
gameplayRules,
gameplaySpawnStrategy,
id): HDK React Component
Registers gameplay settings for the world
Parameters
Parameter | Type | Description |
---|---|---|
gameplayMatchSettings | GameplayMatchSettings | - |
gameplayRequestRespawnSetting | GameplayRequestRespawnSetting | - |
gameplayRules | GameplayRule[] | - |
gameplaySpawnStrategy | GameplaySpawnStrategy | - |
id | string | The id of the gameplay settings, to be referenced as "gameplaySettings" in the render function |
Returns
HDK React Component
HttpOnSignal()
function HttpOnSignal(input, url): HDK React Component
Component that triggers a HTTP request to a specified url when a signal is activated This component has no placing or rendering capabilities. It is only used to emit signals.
Parameters
Parameter | Type | Description |
---|---|---|
input | SignalId | The signal to listen to |
url | string | The url to request when the signal is activated |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
HttpSensor()
function HttpSensor(
output,
pollEnabled,
pollInterval,
url): HDK React Component
Sensor component that activates its signal when it gets a 200 statusCode back from an external url This component has no placing or rendering capabilities. It is only used to emit signals.
Parameters
Parameter | Type | Description |
---|---|---|
output | SignalId | The output signal |
pollEnabled | boolean | Enable polling for an updated status code. Defaults to true |
pollInterval | number | The interval to poll in seconds. Defaults to 10. |
url | string | The url to poll for a status code |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
LatchGate()
function LatchGate(
input,
output,
resetInput): HDK React Component
A Gate that will toggle its output each time the input signal switches from OFF to ON.
Parameters
Parameter | Type | Description |
---|---|---|
input | SignalId | The input signal |
output | SignalId | The output signal that will be toggled |
resetInput | SignalId | An optional signal that will reset the output to OFF |
Returns
HDK React Component
MatchStateSensor()
function MatchStateSensor(
output,
state,
turnSignalOffNextTick): HDK React Component
Sensor component that activates its signal when the match state enters the given state
Parameters
Parameter | Type | Description |
---|---|---|
output | SignalId | The output signal |
state | SignalMatchState | The state to listen for |
turnSignalOffNextTick | boolean | If true, the signal will be turned off the next tick after it has been turned on |
Returns
HDK React Component
RaycastSenderSensor()
function RaycastSenderSensor(
collisionGroup,
collisionMask,
direction,
filterTags,
maxDistance,
output,
showRay): HDK React Component
Component which sends a raycast in a given direction and outputs a signal if it hits something.
Parameters
Parameter | Type | Description |
---|---|---|
collisionGroup | PhysicsFilter | The collision group of the raycast. Defaults to PhysicsFilter.Default. |
collisionMask | PhysicsFilter | The collision mask of the raycast. This specifies which objects groups the raycast will hit. Defaults to PhysicsFilter.All. |
direction | float3 | The direction of the raycast. Defaults to [0, 0, 1]. |
filterTags | string [] | An array of tags to filter the raycast against. The raycast will only activate its signal if the object it hits has at least one of these tags. Defaults to an empty array. |
maxDistance | number | The maximum distance the raycast can travel. Defaults to 10. |
output | SignalId | The signal to output when the raycast hits something. |
showRay | boolean | If true , shows the raycast in the scene. |
Returns
HDK React Component
See
- Fundamentals (opens in a new tab) for basic component placement.
- Signals (opens in a new tab) for info about signals.
Example
<RaycastSenderSensor output="raycast" showRay collisionMask={PhysicsFilter.All} />
ResetOnSignal()
function ResetOnSignal(
input,
resetPlayers,
restartLevel): HDK React Component
Component that resets the level and/or players when a signal is activated
Parameters
Parameter | Type | Description |
---|---|---|
input | SignalId | The signal to listen to |
resetPlayers | false | "RESTART" | "RESPAWN" | Whether to reset or respawn the players. Defaults to 'RESTART' |
restartLevel | boolean | Whether to restart the level state. This will reset all animations / signals etc. Defaults to true |
Returns
HDK React Component
RiveUI()
function RiveUI(
filename,
height,
horizontalAlignment,
margin,
maxHeight,
maxWidth,
stretch,
uiComponent,
verticalAlignment,
width,
zIndex): HDK React Component
Registers a custom Rive UI component
Parameters
Parameter | Type | Description |
---|---|---|
filename | string | Should match the filename of the riv file, with or without extension. |
height | number | - |
horizontalAlignment | UiHorizontalAlignment | - |
margin | types.float4 | - |
maxHeight | number | - |
maxWidth | number | - |
stretch | UiStretch | - |
uiComponent | types.UiComponentID | - |
verticalAlignment | UiVerticalAlignment | - |
width | number | - |
zIndex | number | - |
Returns
HDK React Component
Example
<RiveUI id="healthbar" />
SetMatchStateOnSignal()
function SetMatchStateOnSignal(input, state): HDK React Component
Set the match state when a signal is activated
Parameters
Parameter | Type | Description |
---|---|---|
input | SignalId | The signal to listen to |
state | SignalMatchState | The state to set the match to |
Returns
HDK React Component
TaggedSignalSourceSensor()
function TaggedSignalSourceSensor(output, sensorTag): HDK React Component
Sensor component that activates its signal when another sensor having the specified tag is activated. This can be used for listening to signals from outside a runtime spawneed prefab
Parameters
Parameter | Type | Description |
---|---|---|
output | SignalId | The output signal |
sensorTag | string \ | string[] |
Returns
HDK React Component
Signals
AndGate()
function AndGate(inputs, output): HDK React Component
Logical AND gate component. The output signal is true if all input signals are true. This component has no placing or rendering capabilities. It is only used to process signals.
Parameters
Parameter | Type | Description |
---|---|---|
inputs | SignalId[] | A list of input signals. At least 2 |
output | SignalId | The output signal. Must be unique |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<ButtonSensor output="myButton2" x={2} />
<AndGate output="myOutput" inputs={["myButton1", "myButton2"]} />
<VisibleOnSignal input="myOutput">
<Prefab id="ancient_urn_01" />
</VisibleOnSignal>
ButtonSensor()
function ButtonSensor(
cooldownInSeconds,
durationInSeconds,
materialOff,
materialOn,
maxDistance,
meshId,
onPress,
onPressAudioId,
output,
resetInput,
text): HDK React Component
Sensor Component that toggles its output signal ON and OFF when the button is pressed.
Parameters
Parameter | Type | Description |
---|---|---|
cooldownInSeconds | number | The cooldown in seconds after which the button can be pressed again. Defaults to undefined, which means the button can be pressed again immediately. |
durationInSeconds | number | The duration in seconds after which the button will turn off again. Defaults to undefined, which means the button will stay on forever. |
materialOff | MaterialId | The material to use when the output signal is OFF. Defaults to a red material |
materialOn | MaterialId | The material to use when the output signal is ON. Defaults to a green material |
maxDistance | number | The maximum distance at which the button can be pressed. Defaults to 10. |
meshId | MeshId | The mesh to use for the button. Defaults to a button mesh |
onPress | SignalId | A pulse signal output that will be sent when the button is pressed. Useful for resetting other ButtonSensors by setting this output as resetInput prop on them. Optional. |
onPressAudioId | AudioId \ | false |
output | SignalId | The output signal that will be toggled by pressing the button |
resetInput | SignalId | A signal that will reset the button to OFF. Prefarably a pulse since the ButtonSensor will forced to off as long as this signal is on. Defaults to no signal which means it will not be used. |
text | string | The text to display next to the "F" overlay on desktop browsers. Defaults to undefined, which will show "Use". |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<VisibleOnSignal input="myButton1">
<Prefab id="ancient_urn_01" x={2} />
</VisibleOnSignal>
CapacitorSensor()
function CapacitorSensor(
delayInSeconds,
input,
output): HDK React Component
Sensor Component that delays inactivation of the output signal by a given amount of time. Meaning that the output signal will stay active for the given amount of time after the input signal has turned off. This component has no placing or rendering capabilities. It is only used to emit signals.
Parameters
Parameter | Type | Description |
---|---|---|
delayInSeconds | number | The delay in seconds. Defaults to 1 second. |
input | SignalId | The input signal to listen to |
output | SignalId | The output signal that will have the inactivation delay |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<CapacitorSensor input="myButton1" output="myButton1Delayed" delayInSeconds={2} />
<VisibleOnSignal input="myButton1Delayed">
<Prefab id="ancient_urn_01" x={2} />
</VisibleOnSignal>
InvisibleOnSignal()
function InvisibleOnSignal(input): HDK React Component
Component that makes its children invisible when the input signal is true.
Parameters
Parameter | Type | Description |
---|---|---|
input | SignalId | The input signal to listen to |
Returns
HDK React Component
Example
<ButtonSensor output="myButton1" />
<InvisibleOnSignal input="myButton1">
<Prefab id="ancient_urn_01" x={2} />
</InvisibleOnSignal>
LogicGate()
function LogicGate(
input1,
input2,
output,
type): HDK React Component
Base logic gate component. The output signal value is determined by the type of gate and the input signals. This component has no placing or rendering capabilities. It is only used to process signals.
Parameters
Parameter | Type | Description |
---|---|---|
input1 | SignalId | An input signal |
input2 | SignalId | Another input signal |
output | SignalId | The output signal. Must be unique |
type | LogicGateType | - |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<ButtonSensor output="myButton2" x={2} />
<LogicGate type="AND" output="myOutput" input1={'myButton1'} input2={'myButton2'} />
<VisibleOnSignal input="myOutput">
<Prefab id="ancient_urn_01" />
</VisibleOnSignal>
LookAtSensor()
function LookAtSensor(
maxDistance,
mesh,
minDistance,
output,
showMesh): HDK React Component
Sensor Component that activates its output signal when looked at by the player. This component has no placing or rendering capabilities. It is only used to emit signals.
Parameters
Parameter | Type | Description |
---|---|---|
maxDistance | number | The maximum distance at which the sensor will activate its output signal. Defaults to 1000 |
mesh | MeshId | The mesh to use for the sensor. Defaults to sphere |
minDistance | number | The minimum distance at which the sensor will activate its output signal. Defaults to 0 |
output | SignalId | The output signal that will be activated when looked at |
showMesh | boolean | true will show the sensor's mesh for debugging purposes. |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<LookAtSensor output="mySignal" mesh="box" />
<VisibleOnSignal input="mySignal">
<Prefab id="ancient_urn_01" x={2} />
</VisibleOnSignal>
LookAtSphereSensor()
function LookAtSphereSensor(
maxDistance,
minDistance,
output,
showSphere): HDK React Component
Sensor Component that activates its output signal when looked at by the player. This component has no placing or rendering capabilities. It is only used to emit signals.
Parameters
Parameter | Type | Description |
---|---|---|
maxDistance | number | The maximum distance at which the sensor will activate its output signal. Defaults to 1000 |
minDistance | number | The minimum distance at which the sensor will activate its output signal. Defaults to 0 |
output | SignalId | The output signal that will be activated when looked at |
showSphere | boolean | - |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<LookAtSphereSensor output="mySignal" />
<VisibleOnSignal input="mySignal">
<Prefab id="ancient_urn_01" x={2} />
</VisibleOnSignal>
MaterialOnSignal()
function MaterialOnSignal(
input,
materialOff,
materialOn): HDK React Component
Component that makes its children change material when the input signal is true.
Parameters
Parameter | Type | Description |
---|---|---|
input | SignalId | The input signal to listen to |
materialOff | MaterialId | The material to apply when the signal is false |
materialOn | MaterialId | The material to apply when the signal is true |
Returns
HDK React Component
Example
<ButtonSensor output="myButton1" />
<MaterialOnSignal input="myButton1" materialOn="palette_01_black" materialOff="palette_01_white">
<Prefab id="ancient_urn_01" x={2} />
</MaterialOnSignal>
MultiInputGate()
function MultiInputGate(
inputs,
output,
renderGate): HDK React Component
Multi-input gate component. The output signal value is determined by the type of gate and the input signals. This component has no placing or rendering capabilities. It is only used to process signals. Used by AndGate, OrGate, XnorGate etc.
Parameters
Parameter | Type | Description |
---|---|---|
inputs | SignalId[] | A list of input signals. At least 2 |
output | SignalId | The output signal. Must be unique |
renderGate | Logic gate factory function | function to use when rendering a gate. |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
NandGate()
function NandGate(inputs, output): HDK React Component
Logical NAND gate component. The output signal is true as if NOT all input signals are true. This component has no placing or rendering capabilities. It is only used to process signals.
Parameters
Parameter | Type | Description |
---|---|---|
inputs | SignalId[] | A list of input signals. At least 2 |
output | SignalId | The output signal. Must be unique |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<ButtonSensor output="myButton2" x={2} />
<NandGate output="myOutput" inputs={["myButton1", "myButton2"]} />
<VisibleOnSignal input="myOutput">
<Prefab id="ancient_urn_01" />
</VisibleOnSignal>
NorGate()
function NorGate(inputs, output): HDK React Component
Logical NOR gate component. The output signal is true if all input signals are false. This component has no placing or rendering capabilities. It is only used to process signals.
Parameters
Parameter | Type | Description |
---|---|---|
inputs | SignalId[] | A list of input signals. At least 2 |
output | SignalId | The output signal. Must be unique |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<ButtonSensor output="myButton2" x={2} />
<NorGate output="myOutput" inputs={["myButton1", "myButton2"]} />
<VisibleOnSignal input="myOutput">
<Prefab id="ancient_urn_01" />
</VisibleOnSignal>
NotGate()
function NotGate(input, output): HDK React Component
Logical NOT gate component. The output signal is true if the input signal is false. This component has no placing or rendering capabilities. It is only used to process signals.
Parameters
Parameter | Type | Description |
---|---|---|
input | SignalId | An input signal to invert |
output | SignalId | The output signal. Must be unique |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<NotGate output="myOutput" input="myButton1" />
<VisibleOnSignal input="myOutput">
<Prefab id="ancient_urn_01" />
</VisibleOnSignal>
OrGate()
function OrGate(inputs, output): HDK React Component
Logical OR gate component. The output signal is true if any of the input signals are true. This component has no placing or rendering capabilities. It is only used to process signals.
Parameters
Parameter | Type | Description |
---|---|---|
inputs | SignalId[] | A list of input signals. At least 2 |
output | SignalId | The output signal. Must be unique |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<ButtonSensor output="myButton2" x={2} />
<OrGate output="myOutput" inputs={["myButton1", "myButton2"]} />
<VisibleOnSignal input="myOutput">
<Prefab id="ancient_urn_01" />
</VisibleOnSignal>
ProximitySensor()
function ProximitySensor(
maxDistance,
minDistance,
output,
showMaxDistance): HDK React Component
Sensor Component that activates its output signal when the player gets close enough. This component has no placing or rendering capabilities. It is only used to emit signals.
Parameters
Parameter | Type | Description |
---|---|---|
maxDistance | number | The maximum distance at which the sensor will activate its output signal. Defaults to 1000 |
minDistance | number | The minimum distance at which the sensor will activate its output signal. Defaults to 0 |
output | SignalId | The output signal that will be activated when looked at |
showMaxDistance | boolean | true will show the sensor's distance trigger for debugging purposes. |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<HNode x={10}>
<ProximitySensor output="mySignal" />
<Prefab id="cube_01" />
</HNode>
<VisibleOnSignal input="mySignal">
<Prefab id="ancient_urn_01" x={2} />
</VisibleOnSignal>
ResistorSensor()
function ResistorSensor(
delayInSeconds,
input,
output): HDK React Component
Sensor Component that delays activation of the output signal by a given amount of time. Meaning that the action of the output signal will be delayed by the given amount of time after the input signal has turned on. This component has no placing or rendering capabilities. It is only used to emit signals.
Parameters
Parameter | Type | Description |
---|---|---|
delayInSeconds | number | The delay in seconds. Defaults to 1 second. |
input | SignalId | The input signal to listen to |
output | SignalId | The output signal that will have the activation delay |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<ResistorSensor input="myButton1" output="myButton1Delayed" delayInSeconds={1} />
<VisibleOnSignal input="myButton1Delayed">
<Prefab id="ancient_urn_01" x={2} />
</VisibleOnSignal>
SignalListener()
function SignalListener(input): HDK React Component
Represents a component signal input source, as a composite part of a listener.
Parameters
Parameter | Type | Description |
---|---|---|
input | SignalId | The input signal |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
SpawnPrefabOnSignal()
function SpawnPrefabOnSignal(
id,
input,
networkSynced): HDK React Component
Component that spawns a prefab at this objects position when the input signal is true.
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The prefab ID to spawn |
input | SignalId | The input signal to listen to |
networkSynced | boolean | - |
Returns
HDK React Component
Example
<ButtonSensor output="myButton1" />
<SpawnPrefabOnSignal input="myButton1" id="balloons_01" />
VisibleOnSignal()
function VisibleOnSignal(input): HDK React Component
Component that makes its children visible when the input signal is true.
Parameters
Parameter | Type | Description |
---|---|---|
input | SignalId | The input signal to listen to |
Returns
HDK React Component
Example
<ButtonSensor output="myButton1" />
<VisibleOnSignal input="myButton1">
<Prefab id="ancient_urn_01" x={2} />
</VisibleOnSignal>
XnorGate()
function XnorGate(inputs, output): HDK React Component
Logical XNOR gate component. The output signal is true if all input signals match each other. This component has no placing or rendering capabilities. It is only used to process signals.
Parameters
Parameter | Type | Description |
---|---|---|
inputs | SignalId[] | A list of input signals. At least 2 |
output | SignalId | The output signal. Must be unique |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<ButtonSensor output="myButton2" x={2} />
<XnorGate output="myOutput" inputs={["myButton1", "myButton2"]} />
<VisibleOnSignal input="myOutput">
<Prefab id="ancient_urn_01" />
</VisibleOnSignal>
XorGate()
function XorGate(inputs, output): HDK React Component
Logical XOR gate component. The output signal is true if any of the input signals doesn't match the others. This component has no placing or rendering capabilities. It is only used to process signals.
Parameters
Parameter | Type | Description |
---|---|---|
inputs | SignalId[] | A list of input signals. At least 2 |
output | SignalId | The output signal. Must be unique |
Returns
HDK React Component
See
Signals (opens in a new tab) for more info about signals.
Example
<ButtonSensor output="myButton1" />
<ButtonSensor output="myButton2" x={2} />
<XorGate output="myOutput" inputs={["myButton1", "myButton2"]} />
<VisibleOnSignal input="myOutput">
<Prefab id="ancient_urn_01" />
</VisibleOnSignal>