# Getting started

### Initial commit <a href="#initial-commit" id="initial-commit"></a>

First of all we need to add `@roomle/web-sdk` to our npm dependencies and setup a build process. To finally load something you will need to do the following:

```typescript
    import RoomleSdk from "@roomle/web-sdk";
    // set the URL from where you want to load
    // the data, normally that's api.roomle.com/v2
    RoomleSdk.setGlobalInitData({
        customApiUrl: "https://api.roomle.com/v2",
    });

    const glbViewerawait = RoomleSdk.getGlbViewer();
    glbViewer.boot();
    glbViewerApi = await glbViewer.getApi();
    const scene = document.querySelector(".scene");
    await glbViewerApi.init(scene);
    // Load a static item by the id
    await glbViewerApi.loadStaticItem("roomle_content_demo:kitchenware003");
```

### Loading different items <a href="#loading-different-items" id="loading-different-items"></a>

If you finished step one you where already able to load a static item. You only need to bind the method `loadStaticItem` to a click event. We suggest something like:

```typescript
const loadObject = async (id: string) => {
  await glbViewerApi.loadStaticItem(id);
}
```

### Opening AR <a href="#opening-ar" id="opening-ar"></a>

To open AR you can use the quick-look features of Android and iOS. For Android a [GLB ](https://en.wikipedia.org/wiki/GlTF#GLB)is needed and for iOS a [USDZ ](https://en.wikipedia.org/wiki/Universal_Scene_Description)file.

To fetch the URL of the GLB you can use the module Rapi Access. This works as follows:

```typescript
const rapiAccess = await RoomleSdk.getRapiAccess();
const itemData = await rapiAccess.getItem(initialId);
const { assets } = await rapiAccess.getItem(id);
const arUrl = isIOs() ? assets.usdz.url : createAndroidARUrl(assets.glb.url);
```

For platform specific details please visit one of the following links:

* Android: <https://developers.google.com/ar/develop/java/scene-viewer>
* iOS <https://developer.apple.com/augmented-reality/quick-look/>

### Code Sandbox <a href="#code-sandbox" id="code-sandbox"></a>

Since we only showed the relevant code in the snippets it's time to have a look on the working example. You can find it [here in our CodeSandbox](https://codesandbox.io/s/roomlewebsdkglbviewer-t3rme) example.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roomle.com/rubens/rubens-sdk/rubens-glb-viewer/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
