3.10.0 • Published 2 months ago

@shapediver/viewer.shared.demo-helper v3.10.0

Weekly downloads
-
License
polyform-noncomme...
Repository
github
Last release
2 months ago

@shapediver/viewer.utils.demo-helper

This package can be used with the @shapediver/viewer to easily create UIs for testing.

Additionally, this package includes logic that can be used to create simple demo-helpers with multiple stages.

Install

npm install @shapediver/viewer.utils.demo-helper

Usage

Initial Setup

We are using Flowbite for the styling so first, please add

<link
	rel="stylesheet"
	href="https://unpkg.com/flowbite@1.4.7/dist/flowbite.min.css"
/>

in the head of your html-file and

<script src="https://unpkg.com/flowbite@1.4.7/dist/flowbite.js"></script>

at the end of the body.

Dark Mode

If you want to use the dark mode, simply add the class dark to the html root element.

Code Usage

After creating a viewport and a session, you can simply call createUI to create an UI in the specified element. This will read out all visible parameters of the scene and add them to the div.

import {createViewport, createSession} from "@shapediver/viewer";
import {createUi} from "@shapediver/viewer.utils.demo-helper";

// create a viewport
const viewport = await createViewport({
	canvas: document.getElementById("canvas") as HTMLCanvasElement,
});

// create a session
const session = await createSession({
	ticket: INSERT_YOUR_TICKET_HERE,
	modelViewUrl: INSERT_YOUR_MODELVIEWURL_HERE,
});

// create the UI
createUi(session, document.getElementById("menu") as HTMLDivElement);

To create a custom UI, this can be done as follows:

createCustomUi(
	[
		<ISliderElement>{
			name: "slider test",
			type: "slider",
			min: 0,
			max: 10,
			step: 0.01,
			value: 2,
			onInputCallback: (value: any) => {
				console.log(value);
			},
			onChangeCallback: (value: any) => {
				console.log(value);
			},
		},
		<IDropdownElement>{
			name: "dropdown test",
			type: "dropdown",
			choices: ["A", "B", "C"],
			value: 1,
			onInputCallback: (value: any) => {
				console.log(value);
			},
			onChangeCallback: (value: any) => {
				console.log(value);
			},
		},
		<IBooleanElement>{
			name: "bool test",
			type: "boolean",
			value: false,
			onInputCallback: (value: any) => {
				console.log(value);
			},
			onChangeCallback: (value: any) => {
				console.log(value);
			},
		},
		<IStringElement>{
			name: "string test",
			type: "string",
			value: "my default",
			onInputCallback: (value: any) => {
				console.log(value);
			},
			onChangeCallback: (value: any) => {
				console.log(value);
			},
		},
	],
	document.getElementById("menu") as HTMLDivElement,
);
3.9.9

2 months ago

3.9.8

3 months ago

3.9.3

4 months ago

3.7.5

5 months ago

3.5.7

8 months ago

3.9.10

2 months ago

3.9.2

4 months ago

3.7.4

5 months ago

3.5.6

8 months ago

3.9.1

4 months ago

3.7.3

6 months ago

3.5.5

8 months ago

3.9.0

4 months ago

3.7.2

6 months ago

3.5.4

8 months ago

3.9.7

3 months ago

3.9.6

3 months ago

3.9.5

3 months ago

3.9.4

4 months ago

3.8.14

4 months ago

3.8.15

4 months ago

3.8.12

4 months ago

3.8.0

5 months ago

3.10.0

2 months ago

3.8.13

4 months ago

3.8.10

4 months ago

3.6.0

8 months ago

3.8.11

4 months ago

3.8.9

4 months ago

3.8.4

5 months ago

3.8.3

5 months ago

3.8.2

5 months ago

3.8.1

5 months ago

3.8.8

4 months ago

3.8.7

5 months ago

3.8.6

5 months ago

3.8.5

5 months ago

3.7.1

6 months ago

3.5.3

8 months ago

3.7.0

7 months ago

3.5.2

8 months ago

3.5.1

8 months ago

3.5.0

8 months ago

3.4.3

9 months ago

3.4.2

9 months ago

3.4.1

9 months ago

3.4.0

9 months ago

3.3.10

9 months ago

3.3.9

9 months ago

3.3.8

9 months ago

3.3.7

9 months ago

3.3.6

9 months ago

3.3.4

9 months ago

3.3.3

10 months ago

3.3.2

10 months ago

3.3.1

10 months ago

3.2.8

10 months ago

3.2.7

11 months ago

3.2.2

11 months ago

3.0.4

1 year ago

3.3.0

10 months ago

3.2.1

11 months ago

3.1.2

12 months ago

3.0.3

1 year ago

3.2.0

11 months ago

3.1.1

12 months ago

3.0.2

1 year ago

3.1.0

1 year ago

3.2.6

11 months ago

3.2.5

11 months ago

3.2.4

11 months ago

3.0.6

1 year ago

2.12.9

1 year ago

3.2.3

11 months ago

3.0.5

1 year ago

2.12.10

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.12.8

1 year ago

2.12.7

1 year ago

2.12.6

1 year ago

2.12.5

1 year ago

2.12.4

1 year ago

2.12.3

1 year ago

2.12.2

1 year ago

2.12.1

2 years ago

2.12.0

2 years ago

2.11.0

2 years ago