HDK React Core API

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

ParameterType
animationAnimationValues & AnimationOptions & { steps?: number[]; easing?: common.EasingType }

Returns

HDK React Component

See

Assets

AssetIDOptions

type AssetIDOptions: object;

Used to specify the id of the skybox, reflection box and light box assets for an Environment.

Type declaration

MemberType
lightboxIDLiteralUnion<CubeMapID, string>
reflectionboxIDLiteralUnion<CubeMapID, string>
skyboxIDLiteralUnion<CubeMapID, string>

BloomOptions

type BloomOptions: object;

Options for bloom effects in an Environment.

Type declaration

MemberType
blendAlphanumber
brightThresholdnumber

ColorGradingOptions

type ColorGradingOptions: object;

Color grading configuration options for an Environment.

Type declaration

MemberType
brightnessnumber
contrastnumber
huenumber
saturationnumber
tintBluefloat3
tintGreenfloat3
tintRedfloat3

CubeMapFace

type CubeMapFace: object;

Configuration for a face of a cubemap texture.

Type declaration

MemberType
urlstring

CubeMapOptions

type CubeMapOptions: object;

Specifies the URLs for the six faces of a cubemap texture.

Type declaration

MemberType
backCubeMapFace
bottomCubeMapFace
frontCubeMapFace
leftCubeMapFace
rightCubeMapFace
topCubeMapFace

FogOptions

type FogOptions: object;

Configuration options for fog effects in an Environment.

Type declaration

MemberType
colorColor
densitynumber
heightnumber
invertboolean
skyboxAlphanumber
skyboxGradientnumber

SunOptions

type SunOptions: object;

Represents options for configuring the sun in an Environment.

Type declaration

MemberType
colorColor
exposureLuminanceAvgnumber
positionVec3
strengthnumber

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

ParameterTypeDescription
attenuationModelcommon.AudioAttenuationModelThe way sound changes as you move around. NO_ATTENUATION, INVERSE_DISTANCE, EXPONENTIAL_DISTANCE or the default LINEAR_DISTANCE
enabledbooleanfalse means the audio is absent from the scene.
loopingbooleanfalse means the sound will only play once, otherwise it will repeat.
maxAttenuationDistnumberThe maximum distance the sound can be heard, defaults to 20.
minAttenuationDistnumberThe minimum distance the sound can be heard, defaults to 5.
playOnSignalSignalListenerReference & PlayAudioOnSignalSoloPropsIf defined, uses a signal to toggle playing the sound.
playSpeednumber-
rollOffFactornumberHow fast the sound tapers away.
solobooleantrue means all other sounds are paused while playing this one.
soundTypecommon.SoundType-
srcAudioSourceThe source of the sound, either an id or an external url.
startPlayingDistnumberThe distance at which the sound starts playing, defaults to 20.1.
volumenumberThe volume of the sound, defaults to 2.

Returns

HDK React Component

See

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

ParameterTypeDescription
assetIDsAssetIDOptionsIds for skybox, reflection box, and light box assets.
bloomBloomOptionsOptions for bloom's bright threshold and blend alpha.
colorGradingColorGradingOptionsOptions for color grading's hue, saturation, brightness, contrast, and tint colors.
extendEnvironmentEnvironmentIdid of the environment to extend.
fogFogOptionsOptions for fog's color, density, height, inversion, and skybox effects.
idstringThe id of the environment.
lightboxBrightnessnumber-
reflectionboxBrightnessnumber-
skyboxCubeMapOptionsURLs for each side of the skybox.
skyboxBrightnessnumber-
skyboxSaturationnumber-
sunSunOptionsOptions for sun's position, color, strength, and exposure luminance.
weatherWeatherSettings 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' });

Custom environment


Prefab()

function Prefab(id, material): HDK React Component

Represents a prefabricated object in the scene.

Parameters

ParameterTypeDescription
idstringThe id of the prefab to add.
materialMaterialIdThe 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(
   firstSpawnShouldBeInstant, 
   intervalRule, 
   networkSynced, 
   prefabID, 
   resetOnPlayerIntentChanged, 
   resetOnPlayerRespawn, 
   spawnAmount, 
   spawnAmountMax, 
   spawnAmountMin, 
   spawnAmountRule, 
   spawnInterval, 
   spawnIntervalMax, 
   spawnIntervalMin, 
   spawnRule, 
   spawnedAmountLimit, 
   startIdle): HDK React Component

A component that spawns a prefab.

Parameters

ParameterTypeDescription
firstSpawnShouldBeInstantbooleanWhether the first spawn should be instant. Defaults to true.
intervalRulecommon.PrefabSpawnerIntervalRuleThe rule that determines how often the spawner should spawn a prefab. Defaults to 'DEFAULT'.
networkSyncedboolean-
prefabIDPrefabIdThe ID of the prefab to spawn. Optional if using built in prefab id.
resetOnPlayerIntentChangedbooleanWhether the spawner should reset when the player changes intent. Defaults to true.
resetOnPlayerRespawnbooleanWhether the spawner should reset when the player respawns. Defaults to true.
spawnAmountnumberThe amount of prefabs to spawn. Used when spawnAmountRule = DEFAULT. Defaults to 1.
spawnAmountMaxnumberThe maximum amount of prefabs to spawn. Used when spawnAmountRule = RANDOM. Defaults to 0.
spawnAmountMinnumberThe minimum amount of prefabs to spawn. Used when spawnAmountRule = RANDOM. Defaults to 0.
spawnAmountRulecommon.PrefabSpawnAmountRuleThe rule that determines how many prefabs should be spawned. Defaults to 'DEFAULT'.
spawnIntervalnumberThe interval in seconds between each spawn. Defaults to 1.
spawnIntervalMaxnumber-
spawnIntervalMinnumber-
spawnRulecommon.PrefabSpawnerSpawnRuleThe rule that determines when the spawner should spawn a prefab. Defaults to 'START_WHEN_EMPTY'.
spawnedAmountLimitnumberThe maximum amount of spawned prefabs that exist in the world simultaneously. Defaults to 1.
startIdlebooleanWhether 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

ParameterTypeDescription
lifespannumberThe 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

ParameterTypeDescription
billboardbooleanWhether the text should face the user.
colorColorThe color of the text.
shadowbooleanWhether the text should have a shadow.
sizenumberThe size of the text.
transparencynumberThe 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

ParameterTypeDescription
propsOmit<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

ParameterTypeDescription
seednumberThe 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

ParameterTypeDescription
accelerationnumberThe acceleration magnitude applied by the volume (default: 160).
colliderMeshIdMeshId

Mesh id for the shape of the volume (default: cylinder).

AccelerationVolume

directionfloat3The direction of acceleration as a 3-element array (default: [0, 1, 0]).
maxSpeednumberThe maximum speed an entity can reach while inside the volume (default: 20).
showColliderbooleanIndicates whether to display the collider mesh for debugging purposes.
stickToCenterDampingnumberDamping factor for sticking entities to the center (default: 1).
stickToCenterEnabledbooleanIndicates whether sticking to the center is enabled (default: true).
stickToCenterPerpDampingnumberDamping factor for sticking perpendicular to the center (default: 7.5).
stickToCenterSpeedFactornumberSpeed 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}
/>

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

ParameterTypeDescription
abilities(AbilityId \Omit<AbilityProps, 'id'>)[]
spawnerPropsOmit<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

ParameterTypeDescription
colorColorThe color of the light, defaults to white.
lightOnSignalSignalListenerReferenceIf specified, use a signal to turn the light on and off.
offsettypes.float3-
radiusnumberThe radius of the light, defaults to 10.
strengthnumberThe 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} />

PointLight


SpotLight()

function SpotLight(
   color, 
   dir, 
   lightOnSignal, 
   offset, 
   openingAngleDegs, 
   radius, 
   strength): HDK React Component

Add a spotlight to the scene.

Parameters

ParameterTypeDescription
colorColorThe color of the spotlight, defaults to yellow [255, 213, 97]. Warm white
dirtypes.float3The direction of the spotlight, defaults is down [0, -1.0, 0].
lightOnSignalSignalListenerReferenceUse a signal to turn the light on and off, defaults to undefined.
offsettypes.float3The offset of the spotlight, defaults to [0, 0, 0].
openingAngleDegsnumberThe opening angle of the spotlight, defaults to 130.
radiusnumberThe radius of the spotlight, defaults to 10.
strengthnumberThe 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>

SpotLight

Media

GLB()

function GLB(
   collider, 
   material, 
   render, 
   src): HDK React Component

Adds an external GLB Mesh to the scene. Supports GLB format.

Parameters

ParameterTypeDescription
colliderbooleanfalse means the object will be non-physical.
materialMaterialIdOverride the built in material to use for the mesh.
renderboolean-
srcAudioSourceUrl 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>

GFL


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

ParameterTypeDescription
autoOpenOverlayboolean-
bodytypes.str80The body of the info panel, max 80 characters.
headerstringThe header of the info panel.
imageIDtypes.TextureIDThe icon that should be shown the info panel.
isOpenInNewTabEnabledbooleantrue if interacting withthe info panel should open the url in a new tab.
isOpenInOverlayEnabledbooleantrue if opening the url should be in an overlay, if applicable.
isOpenInOverlayOnTouchbooleantrue if the overlay should be available on touch.
isSidebarOverlaybooleanfalse if the overlay should be shown as a sidebar.
maxShowDistancenumberThe max distance at which the info panel should be shown.
minShowDistancenumberThe min distance at which the info panel should be shown.
openUrlInNewTabbooleantrue if the url should be opened in a new tab rather than the current.
preBodytypes.str80The ingress of the info panel, max 80 characters.
showOpenBindingbooleantrue if the 'open' binding key should be shown in the panel.
urlstringThe 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

MemberType
childrenReact.ReactNode
keystring | number | null
namestring
tagstring | string[]

MetadataProps

type MetadataProps: object;

Base metadata props for all HDK React components

Type declaration

MemberType
metadataDeepPartial<Metadata>

GameplaySettings()

function GameplaySettings(
   gameplayMatchSettings, 
   gameplayRequestRespawnSetting, 
   gameplayRules, 
   gameplaySpawnStrategy, 
   id): HDK React Component

Registers gameplay settings for the world

Parameters

ParameterTypeDescription
gameplayMatchSettingsGameplayMatchSettings-
gameplayRequestRespawnSettingGameplayRequestRespawnSetting-
gameplayRulesGameplayRule[]-
gameplaySpawnStrategyGameplaySpawnStrategy-
idstringThe 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

ParameterTypeDescription
inputSignalIdThe signal to listen to
urlstringThe 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

ParameterTypeDescription
outputSignalIdThe output signal
pollEnabledbooleanEnable polling for an updated status code. Defaults to true
pollIntervalnumberThe interval to poll in seconds. Defaults to 10.
urlstringThe 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

ParameterTypeDescription
inputSignalIdThe input signal
outputSignalIdThe output signal that will be toggled
resetInputSignalIdAn 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

ParameterTypeDescription
outputSignalIdThe output signal
stateSignalMatchStateThe state to listen for
turnSignalOffNextTickbooleanIf 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

ParameterTypeDescription
collisionGroupPhysicsFilterThe collision group of the raycast. Defaults to PhysicsFilter.Default.
collisionMaskPhysicsFilterThe collision mask of the raycast. This specifies which objects groups the raycast will hit. Defaults to PhysicsFilter.All.
directionfloat3The direction of the raycast. Defaults to [0, 0, 1].
filterTagsstring[]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.
maxDistancenumberThe maximum distance the raycast can travel. Defaults to 10.
outputSignalIdThe signal to output when the raycast hits something.
showRaybooleanIf true, shows the raycast in the scene.

Returns

HDK React Component

See

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

ParameterTypeDescription
inputSignalIdThe signal to listen to
resetPlayersfalse | "RESTART" | "RESPAWN"Whether to reset or respawn the players. Defaults to 'RESTART'
restartLevelbooleanWhether to restart the level state. This will reset all animations / signals etc. Defaults to true

Returns

HDK React Component


SetMatchStateOnSignal()

function SetMatchStateOnSignal(input, state): HDK React Component

Set the match state when a signal is activated

Parameters

ParameterTypeDescription
inputSignalIdThe signal to listen to
stateSignalMatchStateThe 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

ParameterTypeDescription
outputSignalIdThe output signal
sensorTagstring \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

ParameterTypeDescription
inputsSignalId[]A list of input signals. At least 2
outputSignalIdThe 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

ParameterTypeDescription
cooldownInSecondsnumberThe cooldown in seconds after which the button can be pressed again. Defaults to undefined, which means the button can be pressed again immediately.
durationInSecondsnumberThe duration in seconds after which the button will turn off again. Defaults to undefined, which means the button will stay on forever.
materialOffMaterialIdThe material to use when the output signal is OFF. Defaults to a red material
materialOnMaterialIdThe material to use when the output signal is ON. Defaults to a green material
maxDistancenumberThe maximum distance at which the button can be pressed. Defaults to 10.
meshIdMeshIdThe mesh to use for the button. Defaults to a button mesh
onPressSignalIdA 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.
onPressAudioIdAudioId \false
outputSignalIdThe output signal that will be toggled by pressing the button
resetInputSignalIdA 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.
textstringThe 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

ParameterTypeDescription
delayInSecondsnumberThe delay in seconds. Defaults to 1 second.
inputSignalIdThe input signal to listen to
outputSignalIdThe 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

ParameterTypeDescription
inputSignalIdThe 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

ParameterTypeDescription
input1SignalIdAn input signal
input2SignalIdAnother input signal
outputSignalIdThe output signal. Must be unique
typeLogicGateType-

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

ParameterTypeDescription
maxDistancenumberThe maximum distance at which the sensor will activate its output signal. Defaults to 1000
meshMeshIdThe mesh to use for the sensor. Defaults to sphere
minDistancenumberThe minimum distance at which the sensor will activate its output signal. Defaults to 0
outputSignalIdThe output signal that will be activated when looked at
showMeshbooleantrue 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

ParameterTypeDescription
maxDistancenumberThe maximum distance at which the sensor will activate its output signal. Defaults to 1000
minDistancenumberThe minimum distance at which the sensor will activate its output signal. Defaults to 0
outputSignalIdThe output signal that will be activated when looked at
showSphereboolean-

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

ParameterTypeDescription
inputSignalIdThe input signal to listen to
materialOffMaterialIdThe material to apply when the signal is false
materialOnMaterialIdThe 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

ParameterTypeDescription
inputsSignalId[]A list of input signals. At least 2
outputSignalIdThe output signal. Must be unique
renderGateLogic gate factory functionfunction 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

ParameterTypeDescription
inputsSignalId[]A list of input signals. At least 2
outputSignalIdThe 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

ParameterTypeDescription
inputsSignalId[]A list of input signals. At least 2
outputSignalIdThe 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

ParameterTypeDescription
inputSignalIdAn input signal to invert
outputSignalIdThe 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

ParameterTypeDescription
inputsSignalId[]A list of input signals. At least 2
outputSignalIdThe 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

ParameterTypeDescription
maxDistancenumberThe maximum distance at which the sensor will activate its output signal. Defaults to 1000
minDistancenumberThe minimum distance at which the sensor will activate its output signal. Defaults to 0
outputSignalIdThe output signal that will be activated when looked at
showMaxDistancebooleantrue 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

ParameterTypeDescription
delayInSecondsnumberThe delay in seconds. Defaults to 1 second.
inputSignalIdThe input signal to listen to
outputSignalIdThe 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

ParameterTypeDescription
inputSignalIdThe 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

ParameterTypeDescription
idstringThe prefab ID to spawn
inputSignalIdThe input signal to listen to
networkSyncedboolean-

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

ParameterTypeDescription
inputSignalIdThe 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

ParameterTypeDescription
inputsSignalId[]A list of input signals. At least 2
outputSignalIdThe 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

ParameterTypeDescription
inputsSignalId[]A list of input signals. At least 2
outputSignalIdThe 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>