Available Functions
The HCS-3 Recursion SDK provides a variety of functions for handling different types of content. Here's a comprehensive guide to the available functions:
ConfigurationDirect link to Configuration
HTML ConfigurationDirect link to HTML Configuration
You can configure the SDK using HTML data attributes:
Loading ResourcesDirect link to Loading Resources
ScriptsDirect link to Scripts
<script data-src="hcs://1/0.0.12345" data-script-id="unique-id"></script>
StylesheetsDirect link to Stylesheets
<link data-src="hcs://1/0.0.12345" data-script-id="unique-id" rel="stylesheet">
ImagesDirect link to Images
<img data-src="hcs://1/0.0.12345" alt="Description">
VideoDirect link to Video
<video data-src="hcs://1/0.0.12345" controls></video>
AudioDirect link to Audio
<audio data-src="hcs://1/0.0.12345" controls></audio>
3D Models (GLB)Direct link to 3D Models (GLB)
<model-viewer data-src="hcs://1/0.0.12345" camera-controls auto-rotate ar></model-viewer>
Audio FunctionsDirect link to Audio Functions
Preload AudioDirect link to Preload Audio
await HCS.preloadAudio('0.0.12345');
Play AudioDirect link to Play Audio
await HCS.playAudio('0.0.12345', 0.5);
Pause AudioDirect link to Pause Audio
await HCS.pauseAudio('0.0.12345');
Load and Play AudioDirect link to Load and Play Audio
await HCS.loadAndPlayAudio('0.0.12345', true, 0.8);
Image FunctionsDirect link to Image Functions
Preload ImageDirect link to Preload Image
const imageUrl = await HCS.preloadImage('0.0.12345');
Loading OrderDirect link to Loading Order
You can control the loading order of resources using the data-load-order attribute:
<script data-src="hcs://1/0.0.12345" data-load-order="1"></script>
<script data-src="hcs://1/0.0.12346" data-load-order="2"></script>
Event HandlingDirect link to Event Handling
Ready EventDirect link to Ready Event
window.HCSReady = function() {
console.log('All HCS resources have been loaded');
};
Loading Status CallbackDirect link to Loading Status Callback
window.onHCSLoading = function(id, status) {
console.log(`Resource ${id} status: ${status}`);
};
Additional ExamplesDirect link to Additional Examples
For more examples and use cases, visit our GitHub repository.
Error HandlingDirect link to Error Handling
The SDK includes built-in retry logic for failed requests:
- Default retry attempts: 3
- Default backoff: 300ms (doubles after each retry)
- Required resources will throw errors if they fail to load
- Optional resources will log errors but continue loading other resources
You can customize these settings using the configuration options shown above.