Skip to content

Commit

Permalink
renames and reorg.++
Browse files Browse the repository at this point in the history
  • Loading branch information
torelode committed Sep 11, 2023
1 parent 6ef19c4 commit 50cb45b
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 41 deletions.
14 changes: 14 additions & 0 deletions demo-snippets/guides/camera_controllers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { demo } from "../../demo";
import { ViewDemoHost, ControllerDemoHost } from "../../hosts";
/** Here goes code demo code that you can see in the playground */
import cameraState from "./cameraState.ts?raw";
import controllerParams from "./controllerParams.ts?raw";
import controllerProperties from "./controllerProperties.ts?raw";

const dirName = "getting_started";

export const cameraControllers = {
...demo(dirName, "cameraState", "Camera state", cameraState, ViewDemoHost, {}, "Camera state example."),
...demo(dirName, "controllerParams", "Controller params", controllerParams, ControllerDemoHost, {}, "Camera controller parameters example."),
...demo(dirName, "controllerProperties", "Controller properties", controllerProperties, ControllerDemoHost, {}, "Camera controller properties example."),
};
22 changes: 0 additions & 22 deletions demo-snippets/guides/getting_started/index.ts

This file was deleted.

8 changes: 0 additions & 8 deletions demo-snippets/guides/getting_started/spheres.ts

This file was deleted.

4 changes: 3 additions & 1 deletion demo-snippets/guides/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from "./getting_started";
export * from "./interactive_examples";
export * from "./render_state";
export * from "./camera_controllers";
export * from "./loading_scenes";
export * from "./clipping";
export * from "./dynamic";
Expand Down
12 changes: 12 additions & 0 deletions demo-snippets/guides/interactive_examples/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { demo } from "../../demo";
import { StateDemoHost, BareboneDemoHost } from "../../hosts";
/** Here goes code demo code that you can see in the playground */
import basic from "./basic.ts?raw";
import renderState from "./renderState.ts?raw";

const dirName = "getting_started";

export const interactiveExamples = {
...demo(dirName, "basic", "Basic app", basic, BareboneDemoHost, { contentHeight: 150 }, "A minimal example."),
...demo(dirName, "renderState", "Render state edit", renderState, StateDemoHost, {}, "Render state editing example."),
};
2 changes: 1 addition & 1 deletion demo-snippets/guides/object_selection/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createColorSetHighlight, type RenderStateChanges } from "@novorender/ap

export function main(): RenderStateChanges {
const highlight = createColorSetHighlight([0, 1, 0]);
const objectIds = [2221]; // list of objects that we want to highlight
const objectIds = [2, 2221]; // list of objects that we want to highlight
return {
highlights: {
groups: [{ action: highlight, objectIds }],
Expand Down
10 changes: 10 additions & 0 deletions demo-snippets/guides/render_state/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { demo } from "../../demo";
import { StateDemoHost } from "../../hosts";
/** Here goes code demo code that you can see in the playground */
import validation from "./validation.ts?raw";

const dirName = "render_state";

export const renderState = {
...demo(dirName, "validation", "Render state validation", validation, StateDemoHost, {}, "Render state validation example."),
};
6 changes: 3 additions & 3 deletions docs/guides/camera_controllers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To help with this, the <CodeLink type="class" name="View"/> class introduces cam
These will overwrite the camera related render state on every frame, so setting it directly like in the example above usually won't work.
For the sake of understanding, we select the inert <CodeLink type="class" name="NullController"/> so we can play around with the camera state ourselves.

<PlaygroundComponent {...snippets.gettingStarted.cameraState} />
<PlaygroundComponent {...snippets.cameraControllers.cameraState} />

## Active controller

Expand Down Expand Up @@ -105,7 +105,7 @@ OrbitController.assert(activeController);
activeController.updateParams({ rotationalVelocity: 2 });
```

<PlaygroundComponent {...snippets.gettingStarted.controllerParams} />
<PlaygroundComponent {...snippets.cameraControllers.controllerParams} />

## Properties

Expand All @@ -130,7 +130,7 @@ activeController.pivot = [x, y, z];
The same applies to rotation, which is expressed as two angles, `yaw` and `pitch`.
One reason for this is to restrain the orientation to have zero roll angle, which is often confusing and rarely useful.

<PlaygroundComponent {...snippets.gettingStarted.controllerProperties} />
<PlaygroundComponent {...snippets.cameraControllers.controllerProperties} />

## Zoom to and fly to

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Getting started"
title: "Using interactive examples"
sidebar_position: 1
description: "Setting up instructions for the various Novorender packages."
keywords: ["novorender api docs", "getting started"]
description: "How to use the interacive code examples."
keywords: ["novorender api docs", "examples"]
---

import Link from "@docusaurus/Link";
Expand All @@ -28,7 +28,7 @@ This is why we include plenty of interactive examples.
Click the "run demo" button below to activate the example!
Once active, you should be able to navigate the 3D view by moving the cursor with the left mouse button pressed to rotate, or mouse wheel to zoom in/out.

<PlaygroundComponent {...snippets.gettingStarted.basic} />
<PlaygroundComponent {...snippets.interactiveExamples.basic} />
<br />

The above example shows a minimalistic implementation to get anything on screen.
Expand All @@ -48,7 +48,7 @@ The context in which is runs applies those changes to the view's render state be

Click to activate and then try changing the the values in the code in the example below!

<PlaygroundComponent {...snippets.gettingStarted.renderState} />
<PlaygroundComponent {...snippets.interactiveExamples.renderState} />
<br />

We use Microsoft's [Monaco editor](https://microsoft.github.io/monaco-editor/), which is quite powerful and helpful for editing typescript code.
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/render_state.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ It will only perform basic range checks and values that could result in a run-ti

Some examples will do validation and report back validation errors, like the one below:

<PlaygroundComponent {...snippets.gettingStarted.validation} />
<PlaygroundComponent {...snippets.renderState.validation} />

Change the `grid.distance` to `100` instead of `-100` to rectify the problem.

Expand Down

0 comments on commit 50cb45b

Please sign in to comment.