Skip to content

Viewer SDK

Welcome to the documentation for floorfySDK—a powerful JavaScript library designed to facilitate communication with an iframe-based SDK. floorfySDK provides a seamless way to interact with iframe content by enabling message-based communication, managing pose data, and configuring user interactivity.

  • Initialization: Easily set up the SDK with a specific iframe by providing its ID.
  • Pose Management: Retrieve, set, and subscribe to pose updates, making it simple to interact with pose-related data.
  • User Interactivity: Configure interactivity settings to control how users interact with the iframe content.
  • Event Handling: Automatically handle incoming messages from the iframe, ensuring your application reacts to relevant changes and actions.

floorfySDK is designed to bridge the gap between your main application and an iframe-based content provider. Whether you’re building a sophisticated visualization tool, a custom interactive experience, or integrating external content, floorfySDK helps manage communication and interaction efficiently.

To get started with floorfySDK, you need to initialize the SDK with the iframe ID and configure it to handle pose data and interactivity according to your needs. Refer to the detailed method descriptions and example usage in this documentation to integrate floorfySDK into your project effectively.

  • iframeId: Stores the ID of the iframe element that the SDK interacts with.
  • eventMethod: The method used to add event listeners (addEventListener or attachEvent).
  • eventer: Reference to the method used to add event listeners.
  • messageEvent: The event type used for message events (message or onmessage).
  • posesubsriber: A function to be called when a pose-related message is received.
  • poseresolver: A function to be called when a pose is requested.

Initializes the SDK with the provided iframe ID.

Parameters:

  • iframeId (String): The ID of the iframe element.

Usage:

floorfySDK.init('myIframe');

Requests the current pose from the iframe.

Returns:

  • A Promise that resolves with the pose data.

Usage:

floorfySDK.pose.get().then(function(pose) {
console.log(pose);
});

Subscribes to pose updates. The provided function will be called whenever a pose-related message is received.

Parameters:

subscriberFunction (Function): A callback function to handle pose updates.

Usage:

floorfySDK.pose.subscribe(function(poseMessage) {
console.log(poseMessage);
});

Sends a new pose to the iframe.

Parameters:

pose (Object): The pose data to set.

Usage:

floorfySDK.pose.set({ x: 10, y: 20, z: 30 });

Sets the interactivity mode for the iframe.

Parameters:

interactivity (Object): The interactivity settings.

Usage:

floorfySDK.user.setInteractivity({ enabled: true });

Returns the contentWindow of the iframe with the ID stored in iframeId.

Returns:

Window (Object): The content window of the iframe.

Usage:

var iframeWindow = floorfySDK.getIframe();

The SDK listens for message events from the iframe. It parses incoming messages and triggers appropriate functions based on the message action:

  • changeScene and cameraOrientation actions trigger posesubsriber if defined.
  • getPose and synchCurrentPosition actions trigger poseresolver if defined.

Here’s a full example of how to use floorfySDK:

// Initialize SDK with iframe ID
floorfySDK.init('myIframe');
// Subscribe to pose updates
floorfySDK.pose.subscribe(function(poseMessage) {
console.log('Pose updated:', poseMessage);
});
// Get the current pose
floorfySDK.pose.get().then(function(pose) {
console.log('Current pose:', pose);
});
// Set a new pose
floorfySDK.pose.set({ x: 10, y: 20, z: 30 });
// Set interactivity
floorfySDK.user.setInteractivity({ enabled: true });