Skip to content

Commit

Permalink
feat: 3 character controllers + update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Gugustinette committed Aug 22, 2024
1 parent cb7d92d commit 769f1e9
Show file tree
Hide file tree
Showing 55 changed files with 8,184 additions and 1,286 deletions.
2 changes: 1 addition & 1 deletion apps/playground-3d/pages/rainbowls/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FCube, FOrbitCamera, FScene3d, FSphere } from '@fibbojs/3d'
import * as THREE from 'three'

(async () => {
const scene = new FScene3d({ debug: false })
const scene = new FScene3d()
scene.init()

// Define the radius for the rainbow effect
Expand Down
4 changes: 2 additions & 2 deletions apps/playground-3d/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { F3dShapes, FCapsule, FCharacter3dKinematic, FCube, FGameCamera, FScene3d, FSphere } from '@fibbojs/3d'
import { F3dShapes, FCapsule, FCharacter3dKV, FCube, FGameCamera, FScene3d, FSphere } from '@fibbojs/3d'
import { fDebug } from '@fibbojs/devtools'
import Duck from './classes/Duck'
import GltfCube from './classes/GltfCube'
Expand Down Expand Up @@ -43,7 +43,7 @@ import MyCustomCube from './classes/MyCustomCube'
scene.addComponent(ground2)

// Create a character
const character = new FCharacter3dKinematic(scene)
const character = new FCharacter3dKV(scene)
scene.addComponent(character)

// Attach a camera to the character
Expand Down
31 changes: 31 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export default defineConfig({
{ text: 'Quick Start', link: '/getting-started/installation' },
],

search: {
provider: 'local',
},

sidebar: [
{
text: 'Getting Started',
Expand All @@ -33,6 +37,12 @@ export default defineConfig({
{ text: 'Index', link: '/api/index.md' },
{ text: 'Modules', items: [
{ text: '2d', link: '/api/2d/index.md', collapsed: true, items: [
{ text: 'Camera Classes', items: [
{ text: 'FAttachedCamera', link: '/api/2d/classes/FAttachedCamera' },
{ text: 'FCamera2d', link: '/api/2d/classes/FCamera2d' },
{ text: 'FFixedCamera', link: '/api/3d/classes/FFixedCamera' },
{ text: 'FFreeCamera', link: '/api/3d/classes/FFreeCamera' },
] },
{ text: 'Core Classes', items: [
{ text: 'FComponent2d', link: '/api/2d/classes/FComponent2d' },
{ text: 'FScene2d', link: '/api/2d/classes/FScene2d' },
Expand All @@ -47,6 +57,11 @@ export default defineConfig({
{ text: 'Enumerations', items: [
{ text: 'F2dShapes', link: '/api/2d/enumerations/F2dShapes' },
] },
{ text: 'Interfaces', items: [
{ text: 'FCamera2dOptions', link: '/api/2d/interfaces/FCamera2dOptions' },
{ text: 'FComponent2dOptions', link: '/api/2d/interfaces/FComponent2dOptions' },
{ text: 'FScene2dOptions', link: '/api/2d/interfaces/FScene2dOptions' },
] },
] },
{ text: '3d', link: '/api/3d/index.md', collapsed: true, items: [
{ text: 'Camera Classes', items: [
Expand All @@ -56,11 +71,19 @@ export default defineConfig({
{ text: 'FGameCamera', link: '/api/3d/classes/FGameCamera' },
{ text: 'FOrbitCamera', link: '/api/3d/classes/FOrbitCamera' },
] },
{ text: 'Character Classes', items: [
{ text: 'FCharacter3d', link: '/api/3d/classes/FCharacter3d' },
{ text: 'FCharacter3dDynamic', link: '/api/3d/classes/FCharacter3dDynamic' },
{ text: 'FCharacter3dKinematic', link: '/api/3d/classes/FCharacter3dKinematic' },
{ text: 'FCharacter3dKP', link: '/api/3d/classes/FCharacter3dKP' },
{ text: 'FCharacter3dKV', link: '/api/3d/classes/FCharacter3dKV' },
] },
{ text: 'Core Classes', items: [
{ text: 'FComponent3d', link: '/api/3d/classes/FComponent3d' },
{ text: 'FScene3d', link: '/api/3d/classes/FScene3d' },
] },
{ text: 'Model Classes', items: [
{ text: 'FCapsule', link: '/api/3d/classes/FCapsule' },
{ text: 'FCube', link: '/api/3d/classes/FCube' },
{ text: 'FGLTF', link: '/api/3d/classes/FGLTF' },
{ text: 'FPolyhedron', link: '/api/3d/classes/FPolyhedron' },
Expand All @@ -69,6 +92,13 @@ export default defineConfig({
{ text: 'Enumerations', items: [
{ text: 'F3dShapes', link: '/api/3d/enumerations/F3dShapes' },
] },
{ text: 'Interfaces', items: [
{ text: 'FCharacter3dOptions', link: '/api/3d/interfaces/FCharacter3dOptions' },
{ text: 'FComponent3dOptions__initCollider', link: '/api/3d/interfaces/FComponent3dOptions__initCollider' },
{ text: 'FComponent3dOptions__initRigidBody', link: '/api/3d/interfaces/FComponent3dOptions__initRigidBody' },
{ text: 'FComponent3dOptions', link: '/api/3d/interfaces/FComponent3dOptions' },
{ text: 'FScene3dOptions', link: '/api/3d/interfaces/FScene3dOptions' },
] },
] },
{ text: 'core', link: '/api/core/index.md', collapsed: true, items: [
{ text: 'FCamera', link: '/api/core/classes/FCamera' },
Expand All @@ -78,6 +108,7 @@ export default defineConfig({
] },
{ text: 'devtools', link: '/api/devtools/index.md', collapsed: true, items: [
{ text: 'FDebug', link: '/api/devtools/classes/FDebug' },
{ text: 'fDebug', link: '/api/devtools/functions/fDebug' },
] },
{ text: 'event', link: '/api/event/index.md', collapsed: true, items: [
{ text: 'FKeyboard', link: '/api/event/classes/FKeyboard' },
Expand Down
262 changes: 262 additions & 0 deletions docs/api/2d/classes/FAttachedCamera.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
[@fibbojs](/api/index) / [2d](/api/2d) / FAttachedCamera

# Class: FAttachedCamera

## Description

A camera attached to a given target.

## Extends

- [`FCamera2d`](FCamera2d.md)

## Constructors

### new FAttachedCamera()

> **new FAttachedCamera**(`scene`, `options`): [`FAttachedCamera`](FAttachedCamera.md)
#### Parameters

**scene**: [`FScene2d`](FScene2d.md)

**options**: `FAttachedCameraOptions`

#### Returns

[`FAttachedCamera`](FAttachedCamera.md)

#### Overrides

[`FCamera2d`](FCamera2d.md).[`constructor`](FCamera2d.md#constructors)

#### Defined in

[packages/2d/src/cameras/FAttachedCamera.ts:20](https://github.com/fibbojs/fibbo/blob/cb7d92d6e3e9106d66f5bb89ed29f3d87739ca2e/packages/2d/src/cameras/FAttachedCamera.ts#L20)

## Methods

### \_\_ON\_CAMERA\_ADDED\_TO\_SCENE\_PLEASE\_DO\_NOT\_CALL\_THIS\_BY\_HAND\_\_()

> **\_\_ON\_CAMERA\_ADDED\_TO\_SCENE\_PLEASE\_DO\_NOT\_CALL\_THIS\_BY\_HAND\_\_**(): `void`
#### Returns

`void`

#### Overrides

[`FCamera2d`](FCamera2d.md).[`__ON_CAMERA_ADDED_TO_SCENE_PLEASE_DO_NOT_CALL_THIS_BY_HAND__`](FCamera2d.md#__on_camera_added_to_scene_please_do_not_call_this_by_hand__)

#### Defined in

[packages/2d/src/cameras/FAttachedCamera.ts:33](https://github.com/fibbojs/fibbo/blob/cb7d92d6e3e9106d66f5bb89ed29f3d87739ca2e/packages/2d/src/cameras/FAttachedCamera.ts#L33)

***

### emitCollisionWith()

> **emitCollisionWith**(`classOrObject`): `void`
#### Parameters

**classOrObject**: `any`

The class or object to emit the collision event with.

#### Returns

`void`

#### Description

Emit a collision event with a given class.

#### Examples

```typescript
const player = new Player()
const enemy = new Enemy()
player.emitCollisionWith(Enemy)
```

```typescript
const player = new Player()
const enemy = new Enemy()
player.emitCollisionWith(enemy)
```

#### Inherited from

[`FCamera2d`](FCamera2d.md).[`emitCollisionWith`](FCamera2d.md#emitcollisionwith)

#### Defined in

packages/core/dist/index.d.ts:65

***

### onCollisionWith()

> **onCollisionWith**(`classOrObject`, `callback`): `void`
#### Parameters

**classOrObject**: `any`

The class or object to add the callback to.

**callback**

The callback to add.

#### Returns

`void`

#### Description

Add a callback to be called when a collision occurs.

#### Examples

```typescript
const player = new Player()
const enemy = new Enemy()
player.onCollisionWith(Enemy, () => {
console.log('Player collided with an Enemy!')
})
```

```typescript
const player = new Player()
const enemy = new Enemy()
player.onCollisionWith(enemy, () => {
console.log('Player collided with the enemy!')
})
```

#### Inherited from

[`FCamera2d`](FCamera2d.md).[`onCollisionWith`](FCamera2d.md#oncollisionwith)

#### Defined in

packages/core/dist/index.d.ts:48

***

### onFrame()

> **onFrame**(`_delta`): `void`
#### Parameters

**\_delta**: `number`

#### Returns

`void`

#### Description

Update the component.
Should be called every frame.

#### Overrides

[`FCamera2d`](FCamera2d.md).[`onFrame`](FCamera2d.md#onframe)

#### Defined in

[packages/2d/src/cameras/FAttachedCamera.ts:25](https://github.com/fibbojs/fibbo/blob/cb7d92d6e3e9106d66f5bb89ed29f3d87739ca2e/packages/2d/src/cameras/FAttachedCamera.ts#L25)

## Properties

### \_\_CALLBACKS\_ON\_COLLISION\_\_

> **\_\_CALLBACKS\_ON\_COLLISION\_\_**: `object`
#### Index Signature

\[`key`: `string`\]: () => `void`[]

#### Description

Callbacks for when a collision occurs with a given class or object.
It is a dictionary where the key is the class name or object id and the value is an array of callbacks.

#### Inherited from

[`FCamera2d`](FCamera2d.md).[`__CALLBACKS_ON_COLLISION__`](FCamera2d.md#__callbacks_on_collision__)

#### Defined in

packages/core/dist/index.d.ts:17

***

### \_\_ID\_\_

> **\_\_ID\_\_**: `number`
#### Description

Unique identifier for the component.
It is generated automatically.

#### Inherited from

[`FCamera2d`](FCamera2d.md).[`__ID__`](FCamera2d.md#__id__)

#### Defined in

packages/core/dist/index.d.ts:12

***

### position

> **position**: `PointData`
Position of the camera.

#### Inherited from

[`FCamera2d`](FCamera2d.md).[`position`](FCamera2d.md#position)

#### Defined in

[packages/2d/src/cameras/FCamera2d.ts:23](https://github.com/fibbojs/fibbo/blob/cb7d92d6e3e9106d66f5bb89ed29f3d87739ca2e/packages/2d/src/cameras/FCamera2d.ts#L23)

***

### scene

> **scene**: [`FScene2d`](FScene2d.md)
#### Description

The scene the camera is in.

#### Inherited from

[`FCamera2d`](FCamera2d.md).[`scene`](FCamera2d.md#scene)

#### Defined in

[packages/2d/src/cameras/FCamera2d.ts:17](https://github.com/fibbojs/fibbo/blob/cb7d92d6e3e9106d66f5bb89ed29f3d87739ca2e/packages/2d/src/cameras/FCamera2d.ts#L17)

***

### target

> **target**: [`FComponent2d`](FComponent2d.md)
#### Description

The target to follow.

#### Defined in

[packages/2d/src/cameras/FAttachedCamera.ts:18](https://github.com/fibbojs/fibbo/blob/cb7d92d6e3e9106d66f5bb89ed29f3d87739ca2e/packages/2d/src/cameras/FAttachedCamera.ts#L18)
Loading

0 comments on commit 769f1e9

Please sign in to comment.