three-player-controller 0.2.51 → 0.2.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -44
  3. package/package.json +7 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 three-player-controller author
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  # three-player-controller
4
4
 
5
+ [![NPM Package][npm]][npm-url]
6
+
5
7
  轻量的第三人称 / 第一人称玩家控制器,开箱即用,基于 three.js 和 three-mesh-bvh 实现人物胶囊体碰撞、BVH 碰撞检测、人物动画、第一/三人称切换与相机避障。
6
8
 
7
9
  # 安装
@@ -12,8 +14,11 @@ npm install three-player-controller
12
14
 
13
15
  # 示例
14
16
 
15
- [glb 场景](https://hh-hang.github.io/three-player-controller/index.html)
16
- [3dtiles 场景](https://hh-hang.github.io/three-player-controller/3dtilesScene.html)
17
+ - [glb 场景](https://hh-hang.github.io/three-player-controller/index.html)
18
+
19
+ - [3dtiles 场景](https://hh-hang.github.io/three-player-controller/3dtilesScene.html)
20
+
21
+ - [3dtiles 自定义](https://hh-hang.github.io/three-player-controller/3dtilesCustomize.html)
17
22
 
18
23
  ### 普通控制
19
24
 
@@ -37,18 +42,18 @@ const player = playerController();
37
42
 
38
43
  // 初始化玩家控制器
39
44
  player.init({
40
- scene, // three.js 场景
41
- camera, // three.js 相机
42
- controls, // three.js 控制器
43
- playerModel: {
44
- url: "./glb/person.glb", // 模型路径
45
- scale: 0.001, // 模型缩放
46
- idleAnim: "Idle_2", // 默认 Idle 动画名字
47
- walkAnim: "Walking_11", // 默认 Walk 动画名字
48
- runAnim: "Running_9", // 默认 Run 动画名字
49
- jumpAnim: "Jump_3", // 默认 Jump 动画名字
50
- },
51
- initPos: pos, // 初始位置
45
+ scene, // three.js 场景
46
+ camera, // three.js 相机
47
+ controls, // three.js 控制器
48
+ playerModel: {
49
+ url: "./glb/person.glb", // 模型路径
50
+ scale: 0.001, // 模型缩放
51
+ idleAnim: "Idle_2", // 默认 Idle 动画名字
52
+ walkAnim: "Walking_11", // 默认 Walk 动画名字
53
+ runAnim: "Running_9", // 默认 Run 动画名字
54
+ jumpAnim: "Jump_3", // 默认 Jump 动画名字
55
+ },
56
+ initPos: pos, // 初始位置
52
57
  });
53
58
 
54
59
  // 渲染循环调用
@@ -63,11 +68,11 @@ player.update();
63
68
 
64
69
  ```ts
65
70
  export function playerController(): {
66
- init: (opts: PlayerControllerOptions, callback?: () => void) => void;
67
- changeView: () => void;
68
- reset: (pos?: THREE.Vector3) => void;
69
- update: (dt?: number) => void;
70
- destroy: () => void;
71
+ init: (opts: PlayerControllerOptions, callback?: () => void) => void;
72
+ changeView: () => void;
73
+ reset: (pos?: THREE.Vector3) => void;
74
+ update: (dt?: number) => void;
75
+ destroy: () => void;
71
76
  };
72
77
  ```
73
78
 
@@ -100,7 +105,7 @@ export function offAllEvent(): void; // 关闭所有输入事件
100
105
  - `onAllEvent()`:确保控制器存在并打开输入监听。
101
106
  - `offAllEvent()`:关闭输入监听(用于显示 UI 或暂停时禁止玩家输入)。
102
107
 
103
- 默认处理包括:WASD 移动、奔跑、跳跃、鼠标视角等。
108
+ 默认处理包括:WASD 移动、奔跑、跳跃、鼠标视角等。
104
109
 
105
110
  ---
106
111
 
@@ -110,30 +115,30 @@ export function offAllEvent(): void; // 关闭所有输入事件
110
115
 
111
116
  ```ts
112
117
  type PlayerControllerOptions = {
113
- scene: THREE.Scene;
114
- camera: THREE.PerspectiveCamera;
115
- controls: OrbitControls;
116
- playerModel: {
117
- url: string;
118
- idleAnim: string;
119
- walkAnim: string;
120
- runAnim: string;
121
- jumpAnim: string;
122
- leftWalkAnim?: string;
123
- rightWalkAnim?: string;
124
- backwardAnim?: string;
125
- flyAnim?: string;
126
- flyIdleAnim?: string;
127
- scale: number;
128
- gravity?: number;
129
- jumpHeight?: number;
130
- speed?: number;
131
- };
132
- initPos?: THREE.Vector3;
133
- mouseSensity?: number;
134
- minCamDistance?: number;
135
- maxCamDistance?: number;
136
- colliderMeshUrl?: string;
118
+ scene: THREE.Scene;
119
+ camera: THREE.PerspectiveCamera;
120
+ controls: OrbitControls;
121
+ playerModel: {
122
+ url: string;
123
+ idleAnim: string;
124
+ walkAnim: string;
125
+ runAnim: string;
126
+ jumpAnim: string;
127
+ leftWalkAnim?: string;
128
+ rightWalkAnim?: string;
129
+ backwardAnim?: string;
130
+ flyAnim?: string;
131
+ flyIdleAnim?: string;
132
+ scale: number;
133
+ gravity?: number;
134
+ jumpHeight?: number;
135
+ speed?: number;
136
+ };
137
+ initPos?: THREE.Vector3;
138
+ mouseSensity?: number;
139
+ minCamDistance?: number;
140
+ maxCamDistance?: number;
141
+ colliderMeshUrl?: string;
137
142
  };
138
143
  ```
139
144
 
@@ -164,3 +169,6 @@ type PlayerControllerOptions = {
164
169
  [three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh)
165
170
 
166
171
  [three](https://github.com/mrdoob/three.js)
172
+
173
+ [npm]: https://img.shields.io/npm/v/three-player-controller
174
+ [npm-url]: https://www.npmjs.com/package/three-player-controller
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-player-controller",
3
- "version": "0.2.51",
3
+ "version": "0.2.52",
4
4
  "description": "Third-person / first-person player controller for three.js (three-mesh-bvh based)",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -39,5 +39,10 @@
39
39
  "dependencies": {
40
40
  "3d-tiles-renderer": "^0.4.19",
41
41
  "nipplejs": "^0.10.2"
42
- }
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "https://github.com/hh-hang/three-player-controller"
46
+ },
47
+ "homepage": "https://github.com/hh-hang/three-player-controller"
43
48
  }