-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
13 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,23 @@ | ||
import * as dataJsApi from "@novorender/data-js-api"; | ||
import { createAPI, type SceneData } from "@novorender/data-js-api"; | ||
import { type View } from "@novorender/api"; | ||
import { type ReadonlyVec3 } from "gl-matrix"; | ||
|
||
const DATA_API_SERVICE_URL = "https://data.novorender.com/api"; | ||
export async function main(view: View): Promise<void> { | ||
// Initialize the data API with the Novorender data server service | ||
const dataApi = dataJsApi.createAPI({ | ||
serviceUrl: DATA_API_SERVICE_URL, | ||
const dataApi = createAPI({ | ||
serviceUrl: "https://data.novorender.com/api", | ||
}); | ||
|
||
try { | ||
// Load scene metadata | ||
// Condos scene ID, but can be changed to any public scene ID | ||
const sceneData = await dataApi.loadScene("95a89d20dd084d9486e383e131242c4c"); | ||
// Destructure relevant properties into variables | ||
const { url, camera } = sceneData as dataJsApi.SceneData; | ||
// Destructure relevant camera properties | ||
const { position, fieldOfView: fov } = camera as any; | ||
const { url } = sceneData as SceneData; | ||
// load the scene using URL gotten from `sceneData` | ||
await view.loadSceneFromURL(new URL(url)); | ||
// Assign a camera controller | ||
await view.switchCameraController(camera?.kind as any, { position: flip(position as ReadonlyVec3), fov }); | ||
const config = await view.loadSceneFromURL(new URL(url)); | ||
const { center, radius } = config.boundingSphere; | ||
view.activeController.autoFit(center, radius); | ||
} catch (error) { | ||
console.log("Error while loading scene from URL ", error); | ||
} | ||
} | ||
// HiddenRangeStarted | ||
/** | ||
* helper function to flip the coordinate system | ||
*/ | ||
function flip(v: ReadonlyVec3): ReadonlyVec3 { | ||
const flipped: [number, number, number] = [v[0], -v[2], v[1]]; | ||
return flipped; | ||
} | ||
// HiddenRangeEnded |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.