Skip to content

Commit

Permalink
Update add dispose method
Browse files Browse the repository at this point in the history
  • Loading branch information
armomu committed Jul 2, 2024
1 parent 4d995a1 commit a57bec7
Show file tree
Hide file tree
Showing 12 changed files with 3,824 additions and 345 deletions.
111 changes: 92 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,101 @@
# Ergoudan


# Ergoudan

![version](https://img.shields.io/badge/Babylonjs-6.x-green.svg)
![version](https://img.shields.io/badge/Havok-1.x-blue.svg)
![version](https://img.shields.io/badge/Vite-4.x-green.svg)

### This is a simple Havok physics character controller demo using Babylon.js 6
### This is a simple Havok physics character controller demo using Babylon.js 6、7

原理很简单,使用 Havok 物理线性移动控制角色

The principle is very simple, use havok physics to move the character linearly, Control character using WSAD and space keys
#### Online Demo [https://armomu.github.io/ergoudan/](https://armomu.github.io/ergoudan/)

## TODO
- ✅ Havok Physics engine
- ✅ Contrl character using WASD
- ✅ Jump
- ✅ Climb stairs
- ✅ Uphill and downhill
- ❌ First person control
- ❌ Mobile device
- ❌ Npm package

## Screenshot

<img width="50%" src="https://github.com/armomu/ergoudan/raw/master/public/094246.png">

## Online Demo

[https://armomu.github.io/ergoudan/](https://armomu.github.io/ergoudan/)

[https://daisy-kaliman.vercel.app/#/index](https://daisy-kaliman.vercel.app/#/index)

## Use it

#### Clone the project and run it directly locally

```
git clone https://github.com/armomu/ergoudan.git
cd ergoudan
pnpm install
pnpm run dev
```

#### Use in your project

Copy `src/views/serves/thirdPersonController.ts` and `public/textures/x-bot.glb` to your project directory

Change

```typescript
// thirdPersonController.ts
// 503 line

/**
* Load a scene into an asset container
* @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
* @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
* @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
* @param onSuccess a callback with the scene when import succeeds
* @param onProgress a callback with a progress event for each file being loaded
* @param onError a callback with the scene, a message, and possibly an exception when import fails
* @param pluginExtension the extension used to determine the plugin
* @param name defines the filename, if the data is binary
* @returns The loaded plugin
*/
BABYLON.SceneLoader.LoadAssetContainer(
import.meta.env.BASE_URL + rootUrl, // Output /ergoudan/textures/ Change to your directory
sceneFilename // Output x-bot.glb
);
```

Use

```typescript
import { ThirdPersonController } from './thirdPersonController';

new ThirdPersonController(camera, scene);
```

## Parameter

> package.json dependencies `@babylonjs/havok: 1.1.4` Required
```typescript

export class ThirdPersonController {
/**
* Creates a new ThirdPersonController
* @param camera Required BABYLON.ArcRotateCamera
* @param scene Required BABYLON.Scene
*/
constructor(camera: BABYLON.ArcRotateCamera, scene: BABYLON.Scene) {
}

}

```

| Methods | desc |
| ------------------------------- | ----------------------- |
| dispose() | Destroy the current character controller |

## TODO

- ✅ Havok Physics engine
- ✅ Contrl character using WASD
- ✅ Jump
- ✅ Climb stairs
- ✅ Uphill and downhill
- ❌ First person control
- ❌ Mobile device
- ❌ Npm package
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,28 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"@babylonjs/core": "^6.18.0",
"@babylonjs/gui": "^6.18.0",
"@babylonjs/core": "^7.13.1",
"@babylonjs/gui": "^7.13.1",
"@babylonjs/havok": "^1.1.4",
"@babylonjs/loaders": "^6.18.0",
"@mdi/font": "^7.2.96",
"@babylonjs/loaders": "^7.13.1",
"pinia": "^2.1.6",
"vue": "^3.2.45",
"vue-router": "^4.1.6",
"vuetify": "^3.3.11"
"vue-router": "^4.1.6"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.1.4",
"@types/node": "^18.11.12",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^11.0.0",
"@vue/tsconfig": "^0.1.3",
"@vuetify/loader-shared": "^1.7.1",
"eslint": "^8.22.0",
"eslint-plugin-vue": "^9.3.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.7.1",
"sass": "^1.57.1",
"typescript": "~4.7.4",
"vite": "^4.5.2",
"vite-plugin-vuetify": "^1.0.2",
"vue-tsc": "^1.0.12"
}
}
Loading

0 comments on commit a57bec7

Please sign in to comment.