three-player-controller 0.3.8 → 0.3.9
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.
- package/README.md +4 -8
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +9 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -8,11 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
# 示例
|
|
10
10
|
|
|
11
|
-
- [
|
|
12
|
-
|
|
13
|
-
- [3dtiles 场景](https://hh-hang.github.io/three-player-controller/3dtilesScene.html)
|
|
14
|
-
|
|
15
|
-
- [3dtiles 自定义](https://hh-hang.github.io/three-player-controller/3dtilesCustomize.html)
|
|
11
|
+
- [示例](https://hh-hang.github.io/three-player-controller/index.html)
|
|
16
12
|
|
|
17
13
|
### 普通控制
|
|
18
14
|
|
|
@@ -256,7 +252,7 @@ type PlayerControllerOptions = {
|
|
|
256
252
|
gravity?: number;
|
|
257
253
|
jumpHeight?: number;
|
|
258
254
|
speed?: number;
|
|
259
|
-
|
|
255
|
+
flySpeed?: number;
|
|
260
256
|
rotateY?: number;
|
|
261
257
|
headObjName?: string;
|
|
262
258
|
flyEnabled?: boolean;
|
|
@@ -299,7 +295,7 @@ type PlayerControllerOptions = {
|
|
|
299
295
|
| `playerModel.speed` | `number` | 否 | `300` | 移动速度基准值 |
|
|
300
296
|
| `playerModel.gravity` | `number` | 否 | `-2400` | 重力加速度基准值 |
|
|
301
297
|
| `playerModel.jumpHeight` | `number` | 否 | `600` | 跳跃高度基准值 |
|
|
302
|
-
| `playerModel.
|
|
298
|
+
| `playerModel.flySpeed` | `number` | 否 | `2100` | 飞行速度基准值 |
|
|
303
299
|
| `playerModel.flyEnabled` | `boolean` | 否 | `true` | 是否允许飞行模式 |
|
|
304
300
|
| `initPos` | `THREE.Vector3` | 否 | `(0,0,0)` | 初始位置 |
|
|
305
301
|
| `mouseSensity` | `number` | 否 | `5` | 鼠标灵敏度 |
|
|
@@ -416,4 +412,4 @@ player.playAnimation("attack", { force: true });
|
|
|
416
412
|
[three](https://github.com/mrdoob/three.js)
|
|
417
413
|
|
|
418
414
|
[npm]: https://img.shields.io/npm/v/three-player-controller
|
|
419
|
-
[npm-url]: https://www.npmjs.com/package/three-player-controller
|
|
415
|
+
[npm-url]: https://www.npmjs.com/package/three-player-controller
|
package/dist/index.d.mts
CHANGED
|
@@ -112,10 +112,10 @@ declare function playerController(): {
|
|
|
112
112
|
setInput: (i: any) => void;
|
|
113
113
|
changeView: () => void;
|
|
114
114
|
getPosition: () => THREE.Vector3;
|
|
115
|
-
getCenterScreenRaycastHit: () => THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap
|
|
116
|
-
getCurrentPersonAnimationName: () => string;
|
|
117
|
-
getPerson: () => THREE.Object3D<THREE.Object3DEventMap
|
|
118
|
-
getActiveVehicle: () => VehicleInstance;
|
|
115
|
+
getCenterScreenRaycastHit: () => THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>> | undefined;
|
|
116
|
+
getCurrentPersonAnimationName: () => string | null;
|
|
117
|
+
getPerson: () => THREE.Object3D<THREE.Object3DEventMap> | null;
|
|
118
|
+
getActiveVehicle: () => VehicleInstance | null;
|
|
119
119
|
getAllVehicles: () => VehicleInstance[];
|
|
120
120
|
switchPlayerModel: (model: PlayerModelOptions) => Promise<void>;
|
|
121
121
|
setPlayerScale: (scale: number) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -112,10 +112,10 @@ declare function playerController(): {
|
|
|
112
112
|
setInput: (i: any) => void;
|
|
113
113
|
changeView: () => void;
|
|
114
114
|
getPosition: () => THREE.Vector3;
|
|
115
|
-
getCenterScreenRaycastHit: () => THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap
|
|
116
|
-
getCurrentPersonAnimationName: () => string;
|
|
117
|
-
getPerson: () => THREE.Object3D<THREE.Object3DEventMap
|
|
118
|
-
getActiveVehicle: () => VehicleInstance;
|
|
115
|
+
getCenterScreenRaycastHit: () => THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>> | undefined;
|
|
116
|
+
getCurrentPersonAnimationName: () => string | null;
|
|
117
|
+
getPerson: () => THREE.Object3D<THREE.Object3DEventMap> | null;
|
|
118
|
+
getActiveVehicle: () => VehicleInstance | null;
|
|
119
119
|
getAllVehicles: () => VehicleInstance[];
|
|
120
120
|
switchPlayerModel: (model: PlayerModelOptions) => Promise<void>;
|
|
121
121
|
setPlayerScale: (scale: number) => void;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1042,8 +1043,7 @@ var PlayerController = class {
|
|
|
1042
1043
|
// 初始化加载器
|
|
1043
1044
|
async initLoader() {
|
|
1044
1045
|
const dracoLoader = new import_DRACOLoader.DRACOLoader();
|
|
1045
|
-
dracoLoader.setDecoderPath("https://unpkg.com/three@0.
|
|
1046
|
-
dracoLoader.setDecoderConfig({ type: "js" });
|
|
1046
|
+
dracoLoader.setDecoderPath("https://unpkg.com/three@0.182.0/examples/jsm/libs/draco/gltf/");
|
|
1047
1047
|
this.loader.setDRACOLoader(dracoLoader);
|
|
1048
1048
|
}
|
|
1049
1049
|
// 初始化物理引擎
|
|
@@ -1116,12 +1116,12 @@ var PlayerController = class {
|
|
|
1116
1116
|
action.setEffectiveWeight(0);
|
|
1117
1117
|
this.personActions.set(actionName, action);
|
|
1118
1118
|
}
|
|
1119
|
-
this.personActions.get("idle")
|
|
1120
|
-
this.personActions.get("idle")
|
|
1119
|
+
this.personActions.get("idle")?.setEffectiveWeight(1);
|
|
1120
|
+
this.personActions.get("idle")?.play();
|
|
1121
1121
|
this.actionState = this.personActions.get("idle");
|
|
1122
1122
|
this.personMixer.addEventListener("finished", (ev) => {
|
|
1123
1123
|
const done = ev.action;
|
|
1124
|
-
if (done === this.personActions
|
|
1124
|
+
if (done === this.personActions?.get("jumping")) {
|
|
1125
1125
|
if (this.fwdPressed) {
|
|
1126
1126
|
this.playPersonAnimationByName(this.shiftPressed ? "running" : "walking");
|
|
1127
1127
|
return;
|
|
@@ -1442,15 +1442,13 @@ var PlayerController = class {
|
|
|
1442
1442
|
changeView() {
|
|
1443
1443
|
this.isFirstPerson = !this.isFirstPerson;
|
|
1444
1444
|
if (this.isFirstPerson) {
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1447
|
-
const flatDir = new THREE4.Vector3(camWorldDir.x, 0, camWorldDir.z).normalize();
|
|
1445
|
+
const playerFwd = new THREE4.Vector3(0, 0, 1).applyQuaternion(this.player.quaternion);
|
|
1446
|
+
const flatDir = new THREE4.Vector3(playerFwd.x, 0, playerFwd.z).normalize();
|
|
1448
1447
|
if (flatDir.lengthSq() > 1e-3) {
|
|
1449
1448
|
const yAngle = Math.atan2(flatDir.x, flatDir.z);
|
|
1450
|
-
this.player.rotation.set(0, yAngle
|
|
1449
|
+
this.player.rotation.set(0, yAngle, 0);
|
|
1451
1450
|
}
|
|
1452
|
-
|
|
1453
|
-
this.setFirstPersonCamera(vertAngle);
|
|
1451
|
+
this.setFirstPersonCamera();
|
|
1454
1452
|
this.setOverShoulderView(false);
|
|
1455
1453
|
} else {
|
|
1456
1454
|
this.controls.enabled = true;
|