User Interface Controls
rooomSpaces Viewer API UI controls for virtual environments. Manage modals, chat interfaces, and user interface elements in 3D virtual spaces.
Are you an LLM? You can read better optimized documentation at /docs/rooom-spaces/viewer/viewer-api/ui.md for this page in Markdown format
openModal
openModal(url: string, [callback: Function])
Opens a modal dialog with the specified URL.
Parameters:
url: string- The URL of the modal content to opencallback: Function- Optional callback function that receives the modal ID as an argument
js
// Open a modal based on an external URL.
// You can use the modalName to close the modal later.
api.openModal('https://example.com', function (modalName) {
console.log('Modal opened', modalName);
});closeModal
closeModal(modalName: string, [callback: Function])
Closes a specific modal dialog by name.
Parameters:
modalName: string- The name/identifier of the modal to close
js
api.closeModal('product-details', function () {
console.log('Product details modal closed');
api.setCanvasFocus();
});openTextChat
openTextChat([callback: Function])
Opens the text chat interface in multiplayer virtual spaces.
js
api.openTextChat(function () {
console.log('Text chat opened');
});closeTextChat
closeTextChat([callback: Function])
Closes the text chat interface.
js
api.closeTextChat(function () {
console.log('Text chat closed');
api.setCanvasFocus();
});Best Practices
User Experience:
- Provide clear visual feedback for UI state changes
- Use consistent modal naming conventions
- Always return focus to the 3D environment when appropriate
Performance:
- Close unused modals to free memory
- Limit the number of simultaneously open interfaces
- Use event delegation for dynamic UI elements
Accessibility:
- Support keyboard navigation for all UI controls
- Provide alternative ways to access chat and modal functions
- Ensure UI elements are properly labeled for screen readers