Skip to content

Commit

Permalink
Docusaurus v3 (#36)
Browse files Browse the repository at this point in the history
* v3: initial commit

* add data-js-api references

* add rest-api docs

* fix: broken rest api links

* add social card

* add description

* fix: broken link

* fix: broken demos
  • Loading branch information
aamir1995 authored Nov 1, 2024
1 parent c79d0ce commit 2fd5ba3
Show file tree
Hide file tree
Showing 185 changed files with 25,230 additions and 44,602 deletions.
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

# Production
/build
/docs/api
/docs/webgl-api
/docs/data-js-api
/docs/measure-api
/docs/web_api
/docs/web_api/api_reference
/docs/data_js_api/api_reference
/docs/data_rest_api/v2

# Generated files
.docusaurus
Expand Down
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run validate-snippets
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
2 changes: 1 addition & 1 deletion blog/authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ tl:
name: Tore Lode
title: Co-creator of Novorender WebGL API
url: https://github.com/torelode
image_url: https://docs.novorender.com/assets/blog/authors/T3UFE5GJH-U3UMB08Q4-4bb948ec5524-512.jpeg
image_url: /assets/blog/authors/T3UFE5GJH-U3UMB08Q4-4bb948ec5524-512.jpeg
email: [email protected]
4 changes: 2 additions & 2 deletions demo-snippets/guides/dynamic/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { createCubeObject, type RenderStateDynamicInstance, type RenderStateChan

const { mesh } = createCubeObject();

export function update(time: number): RenderStateChanges {
export function update(time: number) {
const angle = ((time / 1000) * Math.PI * 2) / 6; // 10 RPM
const instance: RenderStateDynamicInstance = {
position: [0, 0, 0],
rotation: [0, Math.sin(angle / 2), 0, Math.cos(angle / 2)],
};
return {
dynamic: { objects: [{ mesh, instances: [instance] }] },
};
} as RenderStateChanges;
}
4 changes: 2 additions & 2 deletions demo-snippets/guides/dynamic/instances.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createCubeObject, type RenderStateDynamicInstance, type RenderStateChanges, type RenderStateDynamicObject } from "@novorender/api";

export function main(): RenderStateChanges {
export function main() {
const cube = createCubeObject();
const instances: RenderStateDynamicInstance[] = [];
const dim = 10;
Expand All @@ -17,5 +17,5 @@ export function main(): RenderStateChanges {
mesh: cube.mesh,
instances, // generated instances
};
return { dynamic: { objects: [instancedCube] } };
return { dynamic: { objects: [instancedCube] } } as RenderStateChanges;
}
4 changes: 2 additions & 2 deletions demo-snippets/guides/dynamic/pick.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { View, createCubeObject, type RenderStateDynamicObject } from "@novorender/api";
import { RenderStateChanges, View, createCubeObject, type RenderStateDynamicObject } from "@novorender/api";

export function main(view: View) {
const { mesh } = createCubeObject();
Expand All @@ -14,7 +14,7 @@ export function main(view: View) {
view.modifyRenderState({
dynamic: { objects: [scaledCube] },
// tonemapping: { mode: TonemappingMode.normal },
});
} as RenderStateChanges);
}
update();

Expand Down
5 changes: 3 additions & 2 deletions demo-snippets/guides/dynamic/triangle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RenderStateDynamicGeometry, RenderStateChanges, RenderStateDynamicMesh, RenderStateDynamicMaterialUnlit, RenderStateDynamicObject } from "@novorender/api";

export function main(): RenderStateChanges {
export function main() {
const vertices = new Float32Array([
0, 2, 0, // xyz #0
-1, 0, 0, // xyz #1
Expand All @@ -23,8 +23,9 @@ export function main(): RenderStateChanges {
mesh,
instances: [{ position: [0, 0, 0] }],
};

return {
grid: { enabled: true },
dynamic: { objects: [triangleObject] },
};
} as RenderStateChanges;
}
2 changes: 1 addition & 1 deletion demo-snippets/guides/measure/drawing_2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function drawProduct(ctx: CanvasRenderingContext2D, camera: CameraSettings, prod
let startCol = "red";
let endCol = "lime";
const cylinderLine = obj.parts[0];
if (cylinderLine.elevation && cylinderLine.vertices2D) {
if (cylinderLine.elevation && cylinderLine.vertices2D && !Array.isArray(cylinderLine.elevation)) {
if (cylinderLine.elevation.from > cylinderLine.elevation.to) {
const tmp = startCol;
startCol = endCol;
Expand Down
2 changes: 1 addition & 1 deletion demo-snippets/guides/measure/measure_line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function drawProduct(ctx: CanvasRenderingContext2D, camera: CameraSettings, prod
let startCol = "red";
let endCol = "lime";
const cylinderLine = obj.parts[0];
if (cylinderLine.elevation && cylinderLine.vertices2D) {
if (cylinderLine.elevation && cylinderLine.vertices2D && !Array.isArray(cylinderLine.elevation)) {
if (cylinderLine.elevation.from > cylinderLine.elevation.to) {
const tmp = startCol;
startCol = endCol;
Expand Down
16 changes: 4 additions & 12 deletions demo-snippets/guides/object_metadata/fly_to.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createColorSetHighlight, type BoundingSphere, type View } from "@novorender/api";
import type { HierarcicalObjectReference } from "@novorender/webgl-api";
import type { SceneData } from "@novorender/data-js-api";
import { vec3, type ReadonlyVec3 } from "gl-matrix";
import type { SceneData, HierarcicalObjectReference } from "@novorender/data-js-api";
import { vec3 } from "gl-matrix";

export async function main(view: View, sceneData: SceneData) {
const { db } = sceneData;
Expand Down Expand Up @@ -61,7 +60,7 @@ export async function main(view: View, sceneData: SceneData) {
const objectData = await db?.getObjectMetdata(result.objectId);
// No calculation needed for single object
if (objectData.bounds?.sphere) {
const sphere = { ...objectData.bounds.sphere, center: flip(objectData.bounds.sphere.center) };
const sphere = { ...objectData.bounds.sphere, center: objectData.bounds.sphere.center };
view.activeController.zoomTo(sphere);
}
};
Expand All @@ -84,7 +83,7 @@ function getTotalBoundingSphere(nodes: HierarcicalObjectReference[]): BoundingSp
for (const node of nodes) {
const sphere = node.bounds?.sphere;
if (sphere) {
spheres.push({ ...sphere, center: flip(sphere.center) });
spheres.push({ ...sphere, center: sphere.center });
}
}

Expand All @@ -107,10 +106,3 @@ function getTotalBoundingSphere(nodes: HierarcicalObjectReference[]): BoundingSp
return { center, radius };
}

/**
* Utility function to flip the coordinate system
*/
function flip(v: ReadonlyVec3): ReadonlyVec3 {
const flipped: [number, number, number] = [v[0], -v[2], v[1]];
return flipped;
}
3 changes: 1 addition & 2 deletions demo-snippets/guides/object_metadata/metadata_from_search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createColorSetHighlight, type View } from "@novorender/api";
import type { SceneData } from "@novorender/data-js-api";
import type { ObjectData } from "@novorender/webgl-api";
import type { SceneData, ObjectData } from "@novorender/data-js-api";

export async function main(view: View, sceneData: SceneData) {
const { db } = sceneData;
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/camera_controllers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Both of them support an animated motion from the current position to the desired

<CodeLink type="class" name="BaseController.zoomTo" /> brings a bounding sphere into view in a sort of "zoom to fit" manner. This is useful for displaying an object or area with a known bounding sphere.

<CodeLink type="class" name="BaseController.flyTo" /> moves the camera to the desired position, and optionally rotation.
<CodeLink type="class" name="BaseController.moveTo" /> moves the camera to the desired position, and optionally rotation.

## Other kinds of camera controllers

Expand Down Expand Up @@ -180,4 +180,4 @@ The first controller in the list is initially active, i.e. the default.

Your camera controller must inherit from `BaseController` and at the very least implement the abstract methods.
Alternatively you can inherit from one of the existing concrete controller classes.
More details of how this works is covered in a separate guide: [Custom Camera Controller](custom-camera-controller.md).
More details of how this works is covered in a separate guide: [Custom Camera Controller](./custom-camera-controller).
2 changes: 1 addition & 1 deletion docs/guides/clipping_volumes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ The planes will have one of the object IDs in the <CodeLink type="enum" name="Cl
For more detail on object picking, please see the [Object selection](object_selection.mdx) guide!

### Picking and making plane from `normal`
In the demo below we'll show how can we pick any object and make a plane out of it by using <CodeLink type="interface" name="PickSample.normal"/>, you'll also notice that we're checking for <CodeLink type="interface" name="PickSample.sampleType"/> to pick the `surface` only, you can also check for other types which include `edge` and `corner`.
In the demo below we'll show how can we pick any object and make a plane out of it by using <CodeLink type="interface" name="PickSample.normal"/>, you'll also notice that we're checking for <CodeLink type="interface" name="PickSampleExt.sampleType"/> to pick the `surface` only, you can also check for other types which include `edge` and `corner`.

:::tip
Click anywhere on the model to see planes.
Expand Down
10 changes: 10 additions & 0 deletions docs/guides/custom-camera-controller.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "Custom Camera Controllers"
description: "Custom Camera Controllers"
keywords: ["novorender api docs", "webgl api", "custom camera controllers"]
pagination_next: null
pagination_prev: null
unlisted: true
---

## Coming Soon
12 changes: 6 additions & 6 deletions docs/guides/downloading-scenes-for-offline.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ In this guide, we'll explore how to use the offline module to download a scene f

:::caution Before We Begin
This guide assumes that you have a basic understanding of the Novorender Web API, including setting it up and loading scenes. If you are unfamiliar with these concepts, please check out the resources below first:
- [Getting Started](/docs/tutorial/getting_started)
- [Getting Started](/docs/web_api/tutorial/getting_started)
- [Loading Scenes](/docs/guides/loading_scenes)
:::

### Setting Up and Loading a Scene

We'll start with a basic TypeScript project using Vite. We assume you already have a basic TypeScript project in place with the Novorender Web API installed and ready to go. If you don't have a project yet, please refer to the [following guide](/docs/tutorial/vite_getting_started) to learn how to set up the Novorender Web API in a TypeScript project.
We'll start with a basic TypeScript project using Vite. We assume you already have a basic TypeScript project in place with the Novorender Web API installed and ready to go. If you don't have a project yet, please refer to the [following guide](/docs/web_api/tutorial/vite_getting_started) to learn how to set up the Novorender Web API in a TypeScript project.

#### Loading the Scene

First, we need to install the Novorender [Data JS API](https://docs.novorender.com/legacy/docs/data-js-api). This API is required to load the scene's metadata. Run the following command to install the package:
First, we need to install the Novorender [Data JS API](/docs/data_js_api/api_reference/). This API is required to load the scene's metadata. Run the following command to install the package:

```bash npm2yarn
npm install --save @novorender/data-js-api
```

:::tip
Since the [Data JS API](https://docs.novorender.com/legacy/docs/data-js-api) package is a wrapper around Novorender's [REST API](https://docs.novorender.com/legacy/docs/category/data-rest-api-v1), you can directly use the REST API to load scene metadata if you prefer.
Since the [Data JS API](/docs/data_js_api/api_reference/) package is a wrapper around Novorender's [REST API](/docs/category/data_rest_api/v2), you can directly use the REST API to load scene metadata if you prefer.
:::

To load a scene, use the code below. We'll download this demo scene for offline usage later in this guide.
Expand Down Expand Up @@ -85,7 +85,7 @@ view.dispose();

Running the above code should result in the scene being loaded in the view, as shown in the image below:

![Default condos scene loaded into the view](../../static/assets/condos-offline-1.png)
![Default condos scene loaded into the view](/assets/condos-offline-1.png)

### Downloading the Scene for Offline Usage

Expand All @@ -97,7 +97,7 @@ Let's proceed with downloading the loaded scene so it can be used offline. There
2. **Full Download/Sync**:
The Web API downloads the entire scene in one go, allowing you to use or view it offline without any delay.

To perform incremental syncing, we only need to add (<CodeLink type="class" name="OfflineViewState.addScene"/>) the scene to the <CodeLink type="class" name="OfflineViewState"/>. For a full download, use the <CodeLink type="class" name="OfflineScene.sync"/> method on that scene. To access the view, use <CodeLink type="class" name="view.manageOfflineStorage"/>. We'll see all these in action in the rest of the guide.
To perform incremental syncing, we only need to add (<CodeLink type="class" name="OfflineViewState.addScene"/>) the scene to the <CodeLink type="class" name="OfflineViewState"/>. For a full download, use the <CodeLink type="class" name="OfflineScene.sync"/> method on that scene. To access the view, use <CodeLink type="class" name="View.manageOfflineStorage"/>. We'll see all these in action in the rest of the guide.

:::info
Almost all the code you see in this guide is taken from the [Novorender Web App](https://github.com/novorender/novoweb), which is open source and available on GitHub. We encourage you to check out the [offline component code](https://github.com/novorender/novoweb/tree/develop/src/features/offline), which is much more robust and handles many other cases, such as checking for available storage size.
Expand Down
6 changes: 3 additions & 3 deletions docs/guides/extracting_properties_using_python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ To create a virtual environment, you can use the built-in `venv` module (availab

### Perform a Search

We'll start by initiating a search request using the [Search API](https://docs.novorender.com/legacy/docs/rest-api/2.0/search). The following Python snippet demonstrates how to perform a search within a scene:
We'll start by initiating a search request using the [Search API](/docs/data_rest_api/v2/search). The following Python snippet demonstrates how to perform a search within a scene:

```python title="index.py"
import requests
Expand Down Expand Up @@ -93,11 +93,11 @@ The example scene we're using is public and doesn't need an API key. However, fo

By default we search in all the models but if you want to narrow down search in certain models then add them in `modelsToSearchFor` list.

It is highly recommended to read our guide on [searching](./searching) and [object metadata](./object_metadata) to make yourself familiar with various search techniques, also take a look at the [REST API documentation](https://docs.novorender.com/legacy/docs/rest-api/2.0/search) of search endpoint.
It is highly recommended to read our guide on [searching](./searching) and [object metadata](./object_metadata) to make yourself familiar with various search techniques, also take a look at the [REST API documentation](/docs/data_rest_api/v2/search) of search endpoint.

### Output Data to Excel

Once we have obtained the search results which is based on the [following schema](https://docs.novorender.com/legacy/docs/rest-api/2.0/search#responses), we can output the data to an Excel spreadsheet. Here's a snippet from our Python script to accomplish this:
Once we have obtained the search results which is based on the [following schema](/docs/data_rest_api/v2/search#responses), we can output the data to an Excel spreadsheet. Here's a snippet from our Python script to accomplish this:

```python title="index.py"
import os
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/interactive_examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ All we can do is try to nudge you towards the [pit of success](https://blog.codi
## Reference documentation

Guides can only get you started. For more detailed information, please consult the [reference documentation](/docs/web_api/API/).
Guides can only get you started. For more detailed information, please consult the [reference documentation](/docs/web_api/api_reference/).

## Full examples

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/loading_scenes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pagination_prev: null
It is recommended to use the Novorender OAuth instead of using username+password authentication for getting access token, documentation for using OAuth can be found [here](./using_oauth)
:::

To load your own scenes we recommend that you use the [`@novorender/data-js-api`](https://docs.novorender.com/docs/data-js-api) package, but you can also use the [Novorender data REST API](https://docs.novorender.com/docs/category/data-rest-api-v1) directly if you prefer.
To load your own scenes we recommend that you use the [`@novorender/data-js-api`](https://docs.novorender.com/docs/data-js-api) package, but you can also use the [Data REST API](/docs/category/data_rest_api/v2) directly if you prefer.
We will be using the npm package in all our examples.

## Public scenes
Expand All @@ -27,4 +27,4 @@ Only scene related endpoints are covered by the NPM package, so for user / authe

<PlaygroundComponent demoKey="loadingScenes.private_scene" />

Once you have authenticated and acquired an access token you can follow the [example for username/password flow](#username--password), just use the access token you got from AD instead of <code>POST [/api/user/login](https://docs.novorender.com/docs/rest-api/login)</code>.
Once you have authenticated and acquired an access token you can follow the [example for username/password flow](#username--password), just use the access token you got from AD instead of `POST - /api/user/login`.
8 changes: 4 additions & 4 deletions docs/guides/managing_rules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pagination_prev: null

## Introduction

In the context of Building Information Modeling (BIM), maintaining data consistency and automating workflows are essential for effective project management. The Novorender platform allows users to upload their models and leverage our [REST API](https://docs.novorender.com/legacy/docs/category/data-rest-api-v2) to manage various aspects of these models, including the powerful rules system.
In the context of Building Information Modeling (BIM), maintaining data consistency and automating workflows are essential for effective project management. The Novorender platform allows users to upload their models and leverage our [REST API](/docs/category/data_rest_api/v2) to manage various aspects of these models, including the powerful rules system.

By utilizing rules within Novorender, users can significantly enhance how building information models are processed and refined. The rules system provides a robust framework for automating post-processing tasks, ensuring consistency, and streamlining workflows. Here are some key use cases demonstrating the capabilities of the rules system:

Expand All @@ -22,16 +22,16 @@ By utilizing rules within Novorender, users can significantly enhance how buildi

The rules system serves as a powerful post-processing tool, enabling users to modify properties, adjust the model structure, and refine geometry after the model has been uploaded. Rulesets, consisting of one or more rules, filters, and actions, are executed sequentially, allowing complex data manipulations based on earlier results.

In this guide, we will explore how to create, add, and modify rulesets using the Novorender [REST API](https://docs.novorender.com/legacy/docs/category/data-rest-api-v2), empowering you to leverage these features for effective management of your BIM projects.
In this guide, we will explore how to create, add, and modify rulesets using the Novorender [REST API](/docs/category/data_rest_api/v2), empowering you to leverage these features for effective management of your BIM projects.

## API Operations for Managing Rulesets

Novorender provides specific API endpoints for retrieving and modifying rulesets associated with your models. Below are the available operations for working with rulesets:

- [**Get Folder Rules**](https://docs.novorender.com/legacy/docs/rest-api/2.0/get-folders-rules)
- [**Get Folder Rules**](/docs/data_rest_api/v2/get-folders-rules)
Use this endpoint to retrieve the rulesets applied to a specific folder or project.

- [**Update Folder Rules**](https://docs.novorender.com/legacy/docs/rest-api/2.0/update-folders-rules)
- [**Update Folder Rules**](/docs/data_rest_api/v2/update-folders-rules)
This endpoint allows you to update the rulesets for a folder or project.

:::tip
Expand Down
Loading

0 comments on commit 2fd5ba3

Please sign in to comment.