Skip to content

Commit 9969851

Browse files
committed
版本更新0.4.5
1 parent f419c7b commit 9969851

10 files changed

Lines changed: 197 additions & 182 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ animate();
151151
| `setGravity(v)` | 设置重力。 |
152152
| `setMinCamDistance(v)` | 设置第三人称最小镜头距离。 |
153153
| `setMaxCamDistance(v)` | 设置第三人称最大镜头距离。 |
154+
| `setCamLookAtHeightRatio(v)` | 设置第三人称相机看向点高度比例(0=底部,1=顶部)。 |
154155
| `setThirdMouseMode(v)` | 设置第三人称鼠标模式:[0 | 1 | 2 | 3]|
155156
| `setEnableZoom(v)` | 设置是否允许镜头缩放。 |
156157
| `setOverShoulderView(v)` | 开关过肩视角偏移。 |
@@ -288,6 +289,7 @@ type PlayerControllerOptions = {
288289
enableZoom?: boolean;
289290
enableOverShoulderView?: boolean;
290291
isFirstPerson?: boolean;
292+
camLookAtHeightRatio?: number;
291293
};
292294
```
293295

@@ -373,6 +375,7 @@ type VehicleOptions = {
373375
| `enableZoom` | `boolean` || `false` | 是否允许滚轮缩放。 |
374376
| `enableOverShoulderView` | `boolean` || `false` | 是否启用过肩视角。 |
375377
| `isFirstPerson` | `boolean` || `false` | 初始化时是否直接进入第一人称。 |
378+
| `camLookAtHeightRatio` | `number` || `0.8` | 第三人称相机看向点高度比例(0=胶囊底部,1=顶部)。 |
376379

377380
### `PlayerModelOptions`
378381

README_En.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ animate();
151151
| `setGravity(v)` | Set gravity. |
152152
| `setMinCamDistance(v)` | Set minimum third-person camera distance. |
153153
| `setMaxCamDistance(v)` | Set maximum third-person camera distance. |
154+
| `setCamLookAtHeightRatio(v)` | Set the third-person camera look-at height ratio (0 = bottom, 1 = top). |
154155
| `setThirdMouseMode(v)` | Set third-person mouse mode: [0 | 1 | 2 | 3]. |
155156
| `setEnableZoom(v)` | Enable or disable camera zoom. |
156157
| `setOverShoulderView(v)` | Enable or disable over-shoulder view offset. |
@@ -288,6 +289,7 @@ type PlayerControllerOptions = {
288289
enableZoom?: boolean;
289290
enableOverShoulderView?: boolean;
290291
isFirstPerson?: boolean;
292+
camLookAtHeightRatio?: number;
291293
};
292294
```
293295

@@ -372,6 +374,7 @@ type VehicleOptions = {
372374
| `enableZoom` | `boolean` | No | `false` | Whether wheel zoom is enabled. |
373375
| `enableOverShoulderView` | `boolean` | No | `false` | Whether over-shoulder view is enabled. |
374376
| `isFirstPerson` | `boolean` | No | `false` | Whether to start directly in first-person mode. |
377+
| `camLookAtHeightRatio` | `number` | No | `0.8` | Third-person camera look-at height ratio (0 = capsule bottom, 1 = top). |
375378

376379
### `PlayerModelOptions`
377380

example/3dgs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ async function init() {
122122
speed: 150,
123123
flySpeed: 1000,
124124
jumpHeight: 400,
125-
capsuleRadiusRatio: 0.5,
126125
},
127126
initPos: pos,
128127
minCamDistance: 50,
129128
maxCamDistance: 180,
129+
camLookAtHeightRatio: 0.9,
130130
staticCollider: colliderGltf.scene,
131131
enableOverShoulderView: true,
132132
});

example/OfficeBuilding.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,8 @@ async function initPlayer() {
343343
exitCarAnim: "exitCar",
344344
headBoneName: "mixamorigHead",
345345
rotateY: Math.PI,
346-
capsuleRadiusRatio: 0.9
347346
},
348-
initPos: new Vector3(1.27, -2.95, 11.524),
347+
initPos: new Vector3(1.27, 0, 11.524),
349348
minCamDistance: 50,
350349
maxCamDistance: 220,
351350
enableOverShoulderView: true,
@@ -628,7 +627,6 @@ function initClickPick() {
628627
const objects = [];
629628
tilesList.forEach((t) => t.group.traverse((c) => { if (c.isMesh) objects.push(c); }));
630629
const hits = _raycaster.intersectObjects(objects, false);
631-
console.log('hits', hits)
632630
if (hits.length > 0) {
633631
const mesh = hits[0].object;
634632
}

example/glTF.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ function initGUI() {
724724
flySpeed: 2100,
725725
minCamDistance: 50,
726726
maxCamDistance: 220,
727+
camLookAtHeightRatio: 0.8,
727728
thirdMouseMode: 1,
728729
enableZoom: false,
729730
debug: false,
@@ -824,6 +825,7 @@ function initGUI() {
824825
gui.add(params, "flySpeed", 0, 5000, 10).onChange((v) => player.setPlayerFlySpeed(v));
825826
gui.add(params, "minCamDistance", 0, 200, 1).onChange((v) => player.setMinCamDistance(v));
826827
gui.add(params, "maxCamDistance", 50, 1000, 1).onChange((v) => player.setMaxCamDistance(v));
828+
gui.add(params, "camLookAtHeightRatio", 0, 1, 0.01).onChange((v) => player.setCamLookAtHeightRatio(v));
827829
gui.add(params, "thirdMouseMode", { 0: 0, 1: 1, 2: 2, 3: 3 }).onChange((v) => player.setThirdMouseMode(Number(v)));
828830
gui.add(params, "enableZoom").onChange((v) => player.setEnableZoom(v));
829831
gui.add(params, "debug").onChange((v) => player.setDebug(v));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "three-player-controller",
3-
"version": "0.4.4",
3+
"version": "0.4.5",
44
"description": "Third-person / first-person player controller for three.js (three-mesh-bvh based)",
55
"author": "hh-hang",
66
"license": "MIT",

0 commit comments

Comments
 (0)