Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset documentation #50

Merged
merged 3 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/tutorial/advanced/_category_.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
label: "Advanced"
position: 10
position: 13
2 changes: 1 addition & 1 deletion docs/docs/tutorial/animation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 3
sidebar_position: 5
---

# Animation
Expand Down
63 changes: 63 additions & 0 deletions docs/docs/tutorial/asset-management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
sidebar_position: 4
---

# Asset Management

The `Asset` class provides an efficient solution for loading and managing various resources, including 3D models, textures, and other assets in your applications.


## Resource Loading

To load a resource synchronously, use the **load** method.

```typescript
const audioBuffer = await Asset.load(AudioLoader, 'audio.mp3') as AudioBuffer;
// now the resource is also available using Asset.get('audio.mp3')
```

## Resource Preloading

Preloading resources is crucial before integrating them into your 3D scene to ensure they are readily available when needed. <br />
The `Asset` class enables you to define and preload resources, caching them for efficient use before proceeding with scene creation.

### Preloading in a single file

```typescript
await Asset.loadAll({
onProgress: (e) => console.log(e * 100 + '%'),
onError: (e) => console.error(e)
}, {
loader: TextureLoader,
paths: ['texture.jpg', 'texture2.jpg'],
}, {
loader: AudioLoader,
paths: ['assets/win.mp3'],
});
```

### Preloading in multiple files

**soldier.ts**
```typescript
Asset.preload(GLTFLoader, 'https://threejs.org/examples/models/gltf/Soldier.glb');

export class Soldier extends Group {
constructor() {
super();
const gltf = Asset.get<GLTF>('https://threejs.org/examples/models/gltf/Soldier.glb');
this.add(...gltf.scene.children);
}
}
```

**main.ts**
```typescript
await Asset.preloadAllPending({ onProgress: (e) => console.log(e * 100 + '%') });
// gltf and audio are now loaded
const main = new Main();
```

## Live Examples

[⚡ Stackblitz - Asset](https://stackblitz.com/edit/three-ez-asset?file=src%2Fmain.ts) <br />
2 changes: 1 addition & 1 deletion docs/docs/tutorial/binding.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 10
---

# Binding
Expand Down
7 changes: 7 additions & 0 deletions docs/docs/tutorial/drag-and-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_position: 7
---

# Drag and Drop

Work in progress...
2 changes: 0 additions & 2 deletions docs/docs/tutorial/drag-drop/_category_.yml

This file was deleted.

7 changes: 0 additions & 7 deletions docs/docs/tutorial/drag-drop/todo.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/docs/tutorial/events/_category_.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
label: "Events"
position: 5
position: 6
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
sidebar_position: 0
---

# Interaction Events
# Interaction

Work in progress...
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_position: 1
---

# Miscellaneous Events
# Miscellaneous

This category encompasses animation and resize events. <br />
It's important to note that unlike `interaction events`, misc events do not follow a propagation system.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_position: 2
---

# Update Events
# Update

Update events are triggered when the value of a property or a state changes. <br />
It's important to note that unlike `interaction events`, update events do not follow a propagation system.
Expand Down
7 changes: 7 additions & 0 deletions docs/docs/tutorial/focus-management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_position: 8
---

# Focus Management

Work in progress...
2 changes: 0 additions & 2 deletions docs/docs/tutorial/focus-management/_category_.yml

This file was deleted.

7 changes: 0 additions & 7 deletions docs/docs/tutorial/focus-management/todo.md

This file was deleted.

3 changes: 3 additions & 0 deletions docs/docs/tutorial/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ Create smooth animations effortlessly with built-in tweening.

### Simplified InstancedMesh
Manage `InstancedMesh` instances with the ease of working with `Object3D`, simplifying creation and manipulation.

## Asset Management
Efficiently load and manage external assets and resources for your 3D projects.
2 changes: 1 addition & 1 deletion docs/docs/tutorial/instancedMesh2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 9
sidebar_position: 12
---

# InstancedMesh2
Expand Down
7 changes: 7 additions & 0 deletions docs/docs/tutorial/migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_position: 14
---

# Migration

Work in progress..
2 changes: 1 addition & 1 deletion docs/docs/tutorial/raycasting.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 10
sidebar_position: 9
---

# Raycasting
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/tutorial/resizing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 9
sidebar_position: 3
---

# Resizing
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/tutorial/tweening.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 9
sidebar_position: 11
---

# Tweening
Expand Down
8 changes: 4 additions & 4 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ const config = {
{
title: 'Community',
items: [
{
label: 'Stack Overflow',
href: 'https://stackoverflow.com/questions/tagged/three.ez',
},
// {
// label: 'Stack Overflow',
// href: 'https://stackoverflow.com/questions/tagged/three.ez',
// },
{
label: 'Discord',
href: 'https://discord.gg/MVTwrdX3JM',
Expand Down
8 changes: 8 additions & 0 deletions docs/src/components/HomepageFeatures/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ const FeatureList: FeatureItem[] = [
Manage <code>InstancedMesh</code> instances as if they were <code>Object3D</code>, simplifying creation and manipulation.
</>
)
},
{
title: 'Asset Management',
description: (
<>
Efficiently load and manage external assets and resources for your 3D projects.
</>
)
}
];

Expand Down