@mml-io/3d-web-client-core 0.0.0-experimental-a000246-20230825 → 0.0.0-experimental-0b919eb-20230904
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/build/index.js
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3
|
-
var __publicField = (obj, key, value) => {
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
5
|
-
return value;
|
6
|
-
};
|
7
|
-
|
8
1
|
// src/camera/CameraManager.ts
|
9
2
|
import { PerspectiveCamera, Raycaster, Vector3 as Vector32 } from "three";
|
10
3
|
|
@@ -47,28 +40,26 @@ function getTweakpaneActive() {
|
|
47
40
|
var CameraManager = class {
|
48
41
|
constructor(collisionsManager) {
|
49
42
|
this.collisionsManager = collisionsManager;
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
__publicField(this, "hadTarget", false);
|
71
|
-
__publicField(this, "rayCaster");
|
43
|
+
this.initialDistance = 3.3;
|
44
|
+
this.minDistance = 0.1;
|
45
|
+
this.maxDistance = 8;
|
46
|
+
this.initialFOV = 60;
|
47
|
+
this.fov = this.initialFOV;
|
48
|
+
this.minFOV = 50;
|
49
|
+
this.maxFOV = 70;
|
50
|
+
this.targetFOV = this.initialFOV;
|
51
|
+
this.minPolarAngle = Math.PI * 0.25;
|
52
|
+
this.maxPolarAngle = Math.PI * 0.95;
|
53
|
+
this.dampingFactor = 0.091;
|
54
|
+
this.targetDistance = this.initialDistance;
|
55
|
+
this.distance = this.initialDistance;
|
56
|
+
this.targetPhi = Math.PI / 2;
|
57
|
+
this.phi = Math.PI / 2;
|
58
|
+
this.targetTheta = -Math.PI / 2;
|
59
|
+
this.theta = -Math.PI / 2;
|
60
|
+
this.dragging = false;
|
61
|
+
this.target = new Vector32(0, 1.55, 0);
|
62
|
+
this.hadTarget = false;
|
72
63
|
this.camera = new PerspectiveCamera(this.fov, window.innerWidth / window.innerHeight, 0.1, 400);
|
73
64
|
this.camera.position.set(0, 1.4, -this.initialDistance);
|
74
65
|
this.rayCaster = new Raycaster();
|
@@ -311,8 +302,8 @@ var characterOptions = {
|
|
311
302
|
var CharacterMaterial = class extends MeshPhysicalMaterial {
|
312
303
|
constructor() {
|
313
304
|
super();
|
314
|
-
|
315
|
-
|
305
|
+
this.uniforms = {};
|
306
|
+
this.colorsCube216 = [];
|
316
307
|
this.color = new Color(16777215);
|
317
308
|
this.transmission = characterValues.material.transmission;
|
318
309
|
this.metalness = characterValues.material.metalness;
|
@@ -485,7 +476,6 @@ import { GLTFLoader as ThreeGLTFLoader } from "three/examples/jsm/loaders/GLTFLo
|
|
485
476
|
var CachedGLTFLoader = class extends ThreeGLTFLoader {
|
486
477
|
constructor(manager) {
|
487
478
|
super(manager);
|
488
|
-
__publicField(this, "blobCache");
|
489
479
|
this.blobCache = /* @__PURE__ */ new Map();
|
490
480
|
}
|
491
481
|
setBlobUrl(originalUrl, blobUrl) {
|
@@ -506,8 +496,6 @@ var CachedGLTFLoader = class extends ThreeGLTFLoader {
|
|
506
496
|
};
|
507
497
|
var LRUCache = class {
|
508
498
|
constructor(maxSize = 100) {
|
509
|
-
__publicField(this, "maxSize");
|
510
|
-
__publicField(this, "cache");
|
511
499
|
this.maxSize = maxSize;
|
512
500
|
this.cache = /* @__PURE__ */ new Map();
|
513
501
|
}
|
@@ -527,12 +515,9 @@ var LRUCache = class {
|
|
527
515
|
this.cache.set(key, value);
|
528
516
|
}
|
529
517
|
};
|
530
|
-
var _ModelLoader = class {
|
518
|
+
var _ModelLoader = class _ModelLoader {
|
531
519
|
constructor(maxCacheSize = 100) {
|
532
|
-
|
533
|
-
__publicField(this, "gltfLoader");
|
534
|
-
__publicField(this, "modelCache");
|
535
|
-
__publicField(this, "ongoingLoads", /* @__PURE__ */ new Map());
|
520
|
+
this.ongoingLoads = /* @__PURE__ */ new Map();
|
536
521
|
this.loadingManager = new LoadingManager();
|
537
522
|
this.gltfLoader = new CachedGLTFLoader(this.loadingManager);
|
538
523
|
this.modelCache = new LRUCache(maxCacheSize);
|
@@ -594,8 +579,8 @@ var _ModelLoader = class {
|
|
594
579
|
}
|
595
580
|
}
|
596
581
|
};
|
582
|
+
_ModelLoader.instance = null;
|
597
583
|
var ModelLoader = _ModelLoader;
|
598
|
-
__publicField(ModelLoader, "instance", null);
|
599
584
|
var MODEL_LOADER = ModelLoader.getInstance();
|
600
585
|
var ModelLoader_default = MODEL_LOADER;
|
601
586
|
|
@@ -604,12 +589,12 @@ var CharacterModel = class {
|
|
604
589
|
constructor(characterDescription) {
|
605
590
|
this.characterDescription = characterDescription;
|
606
591
|
/* TODO: pick between below eager instantiation or ModelLoader.getInstance() lazy one */
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
592
|
+
this.modelLoader = ModelLoader_default;
|
593
|
+
this.mesh = null;
|
594
|
+
this.material = new CharacterMaterial();
|
595
|
+
this.animations = {};
|
596
|
+
this.animationMixer = null;
|
597
|
+
this.currentAnimation = 0 /* idle */;
|
613
598
|
}
|
614
599
|
async init() {
|
615
600
|
await this.loadMainMesh();
|
@@ -632,10 +617,11 @@ var CharacterModel = class {
|
|
632
617
|
this.applyMaterialToAllSkinnedMeshes(this.material);
|
633
618
|
}
|
634
619
|
updateAnimation(targetAnimation, deltaTime) {
|
620
|
+
var _a;
|
635
621
|
if (this.currentAnimation !== targetAnimation) {
|
636
622
|
this.transitionToAnimation(targetAnimation);
|
637
623
|
}
|
638
|
-
this.animationMixer
|
624
|
+
(_a = this.animationMixer) == null ? void 0 : _a.update(deltaTime);
|
639
625
|
}
|
640
626
|
hideMaterialByMeshName(meshName) {
|
641
627
|
if (!this.mesh)
|
@@ -735,7 +721,7 @@ import {
|
|
735
721
|
} from "three";
|
736
722
|
|
737
723
|
// src/character/CanvasText.ts
|
738
|
-
import
|
724
|
+
import { Texture, LinearFilter, RGBAFormat, MeshBasicMaterial } from "three";
|
739
725
|
function getTextAlignOffset(textAlign, width) {
|
740
726
|
switch (textAlign) {
|
741
727
|
case "center":
|
@@ -836,10 +822,10 @@ function CanvasText(message, options) {
|
|
836
822
|
}
|
837
823
|
function THREECanvasTextTexture(text, options) {
|
838
824
|
const canvas = CanvasText(text, options);
|
839
|
-
const texture = new
|
840
|
-
texture.minFilter =
|
841
|
-
texture.magFilter =
|
842
|
-
texture.format =
|
825
|
+
const texture = new Texture(canvas);
|
826
|
+
texture.minFilter = LinearFilter;
|
827
|
+
texture.magFilter = LinearFilter;
|
828
|
+
texture.format = RGBAFormat;
|
843
829
|
texture.needsUpdate = true;
|
844
830
|
return { texture, width: canvas.width, height: canvas.height };
|
845
831
|
}
|
@@ -856,14 +842,11 @@ var defaultLabelHeight = 0.125;
|
|
856
842
|
var defaultLabelCastShadows = true;
|
857
843
|
var CharacterTooltip = class {
|
858
844
|
constructor(parentModel) {
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
__publicField(this, "fadingSpeed", 0.02);
|
865
|
-
__publicField(this, "secondsToFadeOut", 15);
|
866
|
-
__publicField(this, "props", {
|
845
|
+
this.visibleOpacity = 0.85;
|
846
|
+
this.targetOpacity = 0;
|
847
|
+
this.fadingSpeed = 0.02;
|
848
|
+
this.secondsToFadeOut = 15;
|
849
|
+
this.props = {
|
867
850
|
content: "",
|
868
851
|
alignment: defaultLabelAlignment,
|
869
852
|
width: defaultLabelWidth,
|
@@ -873,7 +856,7 @@ var CharacterTooltip = class {
|
|
873
856
|
color: defaultLabelColor,
|
874
857
|
fontColor: defaultFontColor,
|
875
858
|
castShadows: defaultLabelCastShadows
|
876
|
-
}
|
859
|
+
};
|
877
860
|
this.setText = this.setText.bind(this);
|
878
861
|
this.material = new MeshBasicMaterial2({
|
879
862
|
map: null,
|
@@ -965,7 +948,7 @@ var CharacterTooltip = class {
|
|
965
948
|
};
|
966
949
|
|
967
950
|
// src/character/LocalController.ts
|
968
|
-
import {
|
951
|
+
import { Line3, Matrix4, Quaternion, Raycaster as Raycaster2, Vector3 as Vector33 } from "three";
|
969
952
|
var LocalController = class {
|
970
953
|
constructor(model, id, collisionsManager, keyInputManager, cameraManager, timeManager) {
|
971
954
|
this.model = model;
|
@@ -974,45 +957,35 @@ var LocalController = class {
|
|
974
957
|
this.keyInputManager = keyInputManager;
|
975
958
|
this.cameraManager = cameraManager;
|
976
959
|
this.timeManager = timeManager;
|
977
|
-
|
978
|
-
|
960
|
+
this.collisionDetectionSteps = 15;
|
961
|
+
this.capsuleInfo = {
|
979
962
|
radius: 0.4,
|
980
963
|
segment: new Line3(new Vector33(), new Vector33(0, 1.05, 0))
|
981
|
-
}
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
__publicField(this, "left");
|
1007
|
-
__publicField(this, "right");
|
1008
|
-
__publicField(this, "run");
|
1009
|
-
__publicField(this, "jump");
|
1010
|
-
__publicField(this, "anyDirection");
|
1011
|
-
__publicField(this, "conflictingDirections");
|
1012
|
-
__publicField(this, "thirdPersonCamera", null);
|
1013
|
-
__publicField(this, "speed", 0);
|
1014
|
-
__publicField(this, "targetSpeed", 0);
|
1015
|
-
__publicField(this, "networkState");
|
964
|
+
};
|
965
|
+
this.maxWalkSpeed = 6;
|
966
|
+
this.maxRunSpeed = 8.5;
|
967
|
+
this.gravity = -42;
|
968
|
+
this.jumpForce = 16;
|
969
|
+
this.coyoteTimeThreshold = 70;
|
970
|
+
this.coyoteTime = false;
|
971
|
+
this.canJump = true;
|
972
|
+
this.characterOnGround = false;
|
973
|
+
this.characterWasOnGround = false;
|
974
|
+
this.characterAirborneSince = 0;
|
975
|
+
this.currentHeight = 0;
|
976
|
+
this.characterVelocity = new Vector33();
|
977
|
+
this.vectorUp = new Vector33(0, 1, 0);
|
978
|
+
this.vectorDown = new Vector33(0, -1, 0);
|
979
|
+
this.rotationOffset = 0;
|
980
|
+
this.azimuthalAngle = 0;
|
981
|
+
this.tempMatrix = new Matrix4();
|
982
|
+
this.tempSegment = new Line3();
|
983
|
+
this.tempVector = new Vector33();
|
984
|
+
this.tempVector2 = new Vector33();
|
985
|
+
this.rayCaster = new Raycaster2();
|
986
|
+
this.thirdPersonCamera = null;
|
987
|
+
this.speed = 0;
|
988
|
+
this.targetSpeed = 0;
|
1016
989
|
this.networkState = {
|
1017
990
|
id: this.id,
|
1018
991
|
position: { x: 0, y: 0, z: 0 },
|
@@ -1021,7 +994,8 @@ var LocalController = class {
|
|
1021
994
|
};
|
1022
995
|
}
|
1023
996
|
update() {
|
1024
|
-
|
997
|
+
var _a, _b;
|
998
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh) || !((_b = this.model) == null ? void 0 : _b.animationMixer))
|
1025
999
|
return;
|
1026
1000
|
if (!this.thirdPersonCamera)
|
1027
1001
|
this.thirdPersonCamera = this.cameraManager.camera;
|
@@ -1089,7 +1063,8 @@ var LocalController = class {
|
|
1089
1063
|
}
|
1090
1064
|
}
|
1091
1065
|
updateAzimuthalAngle() {
|
1092
|
-
|
1066
|
+
var _a;
|
1067
|
+
if (!this.thirdPersonCamera || !((_a = this.model) == null ? void 0 : _a.mesh))
|
1093
1068
|
return;
|
1094
1069
|
const camToModelDistance = this.thirdPersonCamera.position.distanceTo(this.model.mesh.position);
|
1095
1070
|
const isCameraFirstPerson = camToModelDistance < 2;
|
@@ -1104,12 +1079,14 @@ var LocalController = class {
|
|
1104
1079
|
}
|
1105
1080
|
}
|
1106
1081
|
computeAngularDifference(rotationQuaternion) {
|
1107
|
-
|
1082
|
+
var _a;
|
1083
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh))
|
1108
1084
|
return 0;
|
1109
1085
|
return 2 * Math.acos(Math.abs(this.model.mesh.quaternion.dot(rotationQuaternion)));
|
1110
1086
|
}
|
1111
1087
|
updateRotation() {
|
1112
|
-
|
1088
|
+
var _a;
|
1089
|
+
if (!this.thirdPersonCamera || !((_a = this.model) == null ? void 0 : _a.mesh))
|
1113
1090
|
return;
|
1114
1091
|
this.updateRotationOffset();
|
1115
1092
|
this.updateAzimuthalAngle();
|
@@ -1122,12 +1099,14 @@ var LocalController = class {
|
|
1122
1099
|
this.model.mesh.quaternion.rotateTowards(rotationQuaternion, frameRotation);
|
1123
1100
|
}
|
1124
1101
|
addScaledVectorToCharacter(deltaTime) {
|
1125
|
-
|
1102
|
+
var _a;
|
1103
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh))
|
1126
1104
|
return;
|
1127
1105
|
this.model.mesh.position.addScaledVector(this.tempVector, this.speed * deltaTime);
|
1128
1106
|
}
|
1129
1107
|
updatePosition(deltaTime, _iter) {
|
1130
|
-
|
1108
|
+
var _a;
|
1109
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh))
|
1131
1110
|
return;
|
1132
1111
|
if (this.characterOnGround) {
|
1133
1112
|
if (!this.jump)
|
@@ -1169,15 +1148,10 @@ var LocalController = class {
|
|
1169
1148
|
this.addScaledVectorToCharacter(deltaTime);
|
1170
1149
|
}
|
1171
1150
|
this.model.mesh.updateMatrixWorld();
|
1172
|
-
this.tempBox.makeEmpty();
|
1173
1151
|
this.tempSegment.copy(this.capsuleInfo.segment);
|
1174
1152
|
this.tempSegment.start.applyMatrix4(this.model.mesh.matrixWorld).applyMatrix4(this.tempMatrix);
|
1175
1153
|
this.tempSegment.end.applyMatrix4(this.model.mesh.matrixWorld).applyMatrix4(this.tempMatrix);
|
1176
|
-
this.
|
1177
|
-
this.tempBox.expandByPoint(this.tempSegment.end);
|
1178
|
-
this.tempBox.min.subScalar(this.capsuleInfo.radius);
|
1179
|
-
this.tempBox.max.addScalar(this.capsuleInfo.radius);
|
1180
|
-
this.collisionsManager.applyColliders(this.tempSegment, this.capsuleInfo.radius, this.tempBox);
|
1154
|
+
this.collisionsManager.applyColliders(this.tempSegment, this.capsuleInfo.radius);
|
1181
1155
|
const newPosition = this.tempVector;
|
1182
1156
|
newPosition.copy(this.tempSegment.start);
|
1183
1157
|
const deltaVector = this.tempVector2;
|
@@ -1199,7 +1173,8 @@ var LocalController = class {
|
|
1199
1173
|
}
|
1200
1174
|
}
|
1201
1175
|
updateNetworkState() {
|
1202
|
-
|
1176
|
+
var _a;
|
1177
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh)) {
|
1203
1178
|
this.networkState = {
|
1204
1179
|
id: this.id,
|
1205
1180
|
position: new Vector33(),
|
@@ -1222,7 +1197,8 @@ var LocalController = class {
|
|
1222
1197
|
}
|
1223
1198
|
}
|
1224
1199
|
resetPosition() {
|
1225
|
-
|
1200
|
+
var _a;
|
1201
|
+
if (!((_a = this.model) == null ? void 0 : _a.mesh))
|
1226
1202
|
return;
|
1227
1203
|
this.characterVelocity.y = 0;
|
1228
1204
|
this.model.mesh.position.y = 3;
|
@@ -1241,12 +1217,12 @@ var Character = class {
|
|
1241
1217
|
this.keyInputManager = keyInputManager;
|
1242
1218
|
this.cameraManager = cameraManager;
|
1243
1219
|
this.timeManager = timeManager;
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1220
|
+
this.controller = null;
|
1221
|
+
this.name = null;
|
1222
|
+
this.model = null;
|
1223
|
+
this.color = new Color3();
|
1224
|
+
this.position = new Vector34();
|
1225
|
+
this.tooltip = null;
|
1250
1226
|
this.load();
|
1251
1227
|
}
|
1252
1228
|
async load() {
|
@@ -1297,12 +1273,11 @@ var RemoteController = class {
|
|
1297
1273
|
constructor(character, id) {
|
1298
1274
|
this.character = character;
|
1299
1275
|
this.id = id;
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
__publicField(this, "networkState");
|
1276
|
+
this.modelLoader = ModelLoader_default;
|
1277
|
+
this.characterModel = null;
|
1278
|
+
this.animationMixer = new AnimationMixer2(new Object3D4());
|
1279
|
+
this.animations = /* @__PURE__ */ new Map();
|
1280
|
+
this.currentAnimation = 0 /* idle */;
|
1306
1281
|
this.characterModel = this.character.model.mesh;
|
1307
1282
|
this.characterModel.updateMatrixWorld();
|
1308
1283
|
this.animationMixer = new AnimationMixer2(this.characterModel);
|
@@ -1386,15 +1361,14 @@ var CharacterManager = class {
|
|
1386
1361
|
character was standing on a model and the page is reloaded the character falls into the model before it loads and
|
1387
1362
|
can be trapped).
|
1388
1363
|
*/
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
__publicField(this, "group");
|
1364
|
+
this.updateLocationHash = false;
|
1365
|
+
this.loadingCharacters = /* @__PURE__ */ new Map();
|
1366
|
+
this.remoteCharacters = /* @__PURE__ */ new Map();
|
1367
|
+
this.remoteCharacterControllers = /* @__PURE__ */ new Map();
|
1368
|
+
this.characterDescription = null;
|
1369
|
+
this.character = null;
|
1370
|
+
this.cameraOffsetTarget = 0;
|
1371
|
+
this.cameraOffset = 0;
|
1398
1372
|
this.group = new Group();
|
1399
1373
|
}
|
1400
1374
|
/* TODO:
|
@@ -1411,6 +1385,7 @@ var CharacterManager = class {
|
|
1411
1385
|
id,
|
1412
1386
|
isLocal,
|
1413
1387
|
() => {
|
1388
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
1414
1389
|
if (window.location.hash && window.location.hash.length > 1) {
|
1415
1390
|
decodeCharacterAndCamera(
|
1416
1391
|
window.location.hash.substring(1),
|
@@ -1434,14 +1409,14 @@ var CharacterManager = class {
|
|
1434
1409
|
}
|
1435
1410
|
character.model.hideMaterialByMeshName("SK_Mannequin_2");
|
1436
1411
|
if (!isLocal) {
|
1437
|
-
character.model
|
1438
|
-
character.model
|
1412
|
+
(_b = (_a = character.model) == null ? void 0 : _a.mesh) == null ? void 0 : _b.position.set(spawnPosition.x, spawnPosition.y, spawnPosition.z);
|
1413
|
+
(_d = (_c = character.model) == null ? void 0 : _c.mesh) == null ? void 0 : _d.updateMatrixWorld();
|
1439
1414
|
character.position.set(spawnPosition.x, spawnPosition.y, spawnPosition.z);
|
1440
1415
|
}
|
1441
1416
|
this.group.add(character.model.mesh);
|
1442
1417
|
if (isLocal) {
|
1443
1418
|
this.character = character;
|
1444
|
-
this.character.tooltip
|
1419
|
+
(_e = this.character.tooltip) == null ? void 0 : _e.setText(`${id}`);
|
1445
1420
|
} else {
|
1446
1421
|
this.remoteCharacters.set(id, character);
|
1447
1422
|
const remoteController = new RemoteController(character, id);
|
@@ -1461,13 +1436,13 @@ var CharacterManager = class {
|
|
1461
1436
|
4 /* air */,
|
1462
1437
|
characterDescription.airAnimationFileUrl
|
1463
1438
|
);
|
1464
|
-
remoteController.characterModel
|
1439
|
+
(_f = remoteController.characterModel) == null ? void 0 : _f.position.set(
|
1465
1440
|
spawnPosition.x,
|
1466
1441
|
spawnPosition.y,
|
1467
1442
|
spawnPosition.z
|
1468
1443
|
);
|
1469
1444
|
this.remoteCharacterControllers.set(id, remoteController);
|
1470
|
-
character.tooltip
|
1445
|
+
(_g = character.tooltip) == null ? void 0 : _g.setText(`${id}`);
|
1471
1446
|
}
|
1472
1447
|
resolve(character);
|
1473
1448
|
},
|
@@ -1505,9 +1480,10 @@ var CharacterManager = class {
|
|
1505
1480
|
this.loadingCharacters.clear();
|
1506
1481
|
}
|
1507
1482
|
update() {
|
1483
|
+
var _a;
|
1508
1484
|
if (this.character) {
|
1509
1485
|
this.character.update(this.timeManager.time);
|
1510
|
-
if (this.character.model
|
1486
|
+
if ((_a = this.character.model) == null ? void 0 : _a.mesh) {
|
1511
1487
|
this.cameraOffsetTarget = this.cameraManager.targetDistance <= 0.4 ? 0.6 : 0;
|
1512
1488
|
this.cameraOffset += ease(this.cameraOffsetTarget, this.cameraOffset, 0.1);
|
1513
1489
|
const targetOffset = new Vector36(0, 1.3, this.cameraOffset);
|
@@ -1557,7 +1533,7 @@ var CharacterManager = class {
|
|
1557
1533
|
// src/input/KeyInputManager.ts
|
1558
1534
|
var KeyInputManager = class {
|
1559
1535
|
constructor() {
|
1560
|
-
|
1536
|
+
this.keys = /* @__PURE__ */ new Map();
|
1561
1537
|
document.addEventListener("keydown", this.onKeyDown.bind(this));
|
1562
1538
|
document.addEventListener("keyup", this.onKeyUp.bind(this));
|
1563
1539
|
window.addEventListener("blur", this.handleUnfocus.bind(this));
|
@@ -1625,12 +1601,7 @@ var MMLCompositionScene = class {
|
|
1625
1601
|
this.audioListener = audioListener;
|
1626
1602
|
this.collisionsManager = collisionsManager;
|
1627
1603
|
this.getUserPositionAndRotation = getUserPositionAndRotation;
|
1628
|
-
|
1629
|
-
__publicField(this, "debug", false);
|
1630
|
-
__publicField(this, "mmlScene");
|
1631
|
-
__publicField(this, "promptManager");
|
1632
|
-
__publicField(this, "interactionListener");
|
1633
|
-
__publicField(this, "clickTrigger");
|
1604
|
+
this.debug = false;
|
1634
1605
|
this.group = new Group2();
|
1635
1606
|
this.promptManager = PromptManager.init(document.body);
|
1636
1607
|
const { interactionListener } = InteractionManager.init(document.body, this.camera, this.scene);
|
@@ -1733,18 +1704,16 @@ var sunOptions = {
|
|
1733
1704
|
var Sun = class extends Group3 {
|
1734
1705
|
constructor() {
|
1735
1706
|
super();
|
1736
|
-
|
1737
|
-
|
1707
|
+
this.debug = false;
|
1708
|
+
this.sunOffset = new Vector37(
|
1738
1709
|
39 * (Math.PI / 180),
|
1739
1710
|
50 * (Math.PI / 180),
|
1740
1711
|
100
|
1741
|
-
)
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
__publicField(this, "directionalLight");
|
1747
|
-
__publicField(this, "target", null);
|
1712
|
+
);
|
1713
|
+
this.shadowResolution = 8192;
|
1714
|
+
this.shadowCamFrustum = 50;
|
1715
|
+
this.camHelper = null;
|
1716
|
+
this.target = null;
|
1748
1717
|
this.shadowCamera = new OrthographicCamera(
|
1749
1718
|
-this.shadowCamFrustum,
|
1750
1719
|
this.shadowCamFrustum,
|
@@ -1989,10 +1958,7 @@ import { Color as Color5 } from "three";
|
|
1989
1958
|
import { Pane } from "tweakpane";
|
1990
1959
|
var TweakPane = class {
|
1991
1960
|
constructor(renderer, scene, composer) {
|
1992
|
-
|
1993
|
-
__publicField(this, "scene");
|
1994
|
-
__publicField(this, "composer");
|
1995
|
-
__publicField(this, "guiStyle", `
|
1961
|
+
this.guiStyle = `
|
1996
1962
|
:root {
|
1997
1963
|
--tp-base-background-color: hsla(0, 0%, 10%, 0.8);
|
1998
1964
|
--tp-base-shadow-color: hsla(0, 0%, 0%, 0.2);
|
@@ -2033,22 +1999,10 @@ var TweakPane = class {
|
|
2033
1999
|
padding-left: 0px !important;
|
2034
2000
|
padding-right: 0px !important;
|
2035
2001
|
}
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
__publicField(this, "renderOptions");
|
2041
|
-
__publicField(this, "ssao");
|
2042
|
-
__publicField(this, "toneMapping");
|
2043
|
-
__publicField(this, "post");
|
2044
|
-
__publicField(this, "export");
|
2045
|
-
__publicField(this, "characterMaterial");
|
2046
|
-
__publicField(this, "environment");
|
2047
|
-
__publicField(this, "sun");
|
2048
|
-
__publicField(this, "sunButton");
|
2049
|
-
__publicField(this, "ambient");
|
2050
|
-
__publicField(this, "saveVisibilityInLocalStorage", true);
|
2051
|
-
__publicField(this, "guiVisible", false);
|
2002
|
+
`;
|
2003
|
+
this.gui = new Pane();
|
2004
|
+
this.saveVisibilityInLocalStorage = true;
|
2005
|
+
this.guiVisible = false;
|
2052
2006
|
if (this.saveVisibilityInLocalStorage) {
|
2053
2007
|
const localStorageGuiVisible = localStorage.getItem("guiVisible");
|
2054
2008
|
if (localStorageGuiVisible !== null) {
|
@@ -2422,13 +2376,13 @@ var TweakPane = class {
|
|
2422
2376
|
const target = e.presetKey;
|
2423
2377
|
switch (target) {
|
2424
2378
|
case "sunAzimuthalAngle":
|
2425
|
-
sun
|
2379
|
+
sun == null ? void 0 : sun.setAzimuthalAngle(e.value * (Math.PI / 180));
|
2426
2380
|
break;
|
2427
2381
|
case "sunPolarAngle":
|
2428
|
-
sun
|
2382
|
+
sun == null ? void 0 : sun.setPolarAngle(e.value * (Math.PI / 180));
|
2429
2383
|
break;
|
2430
2384
|
case "sunIntensity":
|
2431
|
-
sun
|
2385
|
+
sun == null ? void 0 : sun.setIntensity(e.value);
|
2432
2386
|
break;
|
2433
2387
|
case "sunColor":
|
2434
2388
|
sunValues.sunColor = {
|
@@ -2436,7 +2390,7 @@ var TweakPane = class {
|
|
2436
2390
|
g: e.value.g,
|
2437
2391
|
b: e.value.b
|
2438
2392
|
};
|
2439
|
-
sun
|
2393
|
+
sun == null ? void 0 : sun.setColor();
|
2440
2394
|
break;
|
2441
2395
|
default:
|
2442
2396
|
break;
|
@@ -2527,12 +2481,14 @@ var TweakPane = class {
|
|
2527
2481
|
input.type = "file";
|
2528
2482
|
input.accept = ".json";
|
2529
2483
|
input.addEventListener("change", (event) => {
|
2530
|
-
|
2484
|
+
var _a;
|
2485
|
+
const file = (_a = event.target.files) == null ? void 0 : _a[0];
|
2531
2486
|
if (file) {
|
2532
2487
|
const reader = new FileReader();
|
2533
2488
|
reader.onload = (loadEvent) => {
|
2489
|
+
var _a2;
|
2534
2490
|
try {
|
2535
|
-
const settings = JSON.parse(loadEvent.target
|
2491
|
+
const settings = JSON.parse((_a2 = loadEvent.target) == null ? void 0 : _a2.result);
|
2536
2492
|
callback(settings);
|
2537
2493
|
} catch (err) {
|
2538
2494
|
console.error("Error parsing JSON:", err);
|
@@ -2714,35 +2670,14 @@ var GaussGrainEffect = new ShaderMaterial2({
|
|
2714
2670
|
// src/rendering/composer.ts
|
2715
2671
|
var Composer = class {
|
2716
2672
|
constructor(scene, camera, spawnSun = false) {
|
2717
|
-
|
2718
|
-
|
2719
|
-
|
2720
|
-
|
2721
|
-
|
2722
|
-
|
2723
|
-
|
2724
|
-
|
2725
|
-
__publicField(this, "renderPass");
|
2726
|
-
__publicField(this, "fxaaEffect");
|
2727
|
-
__publicField(this, "fxaaPass");
|
2728
|
-
__publicField(this, "bloomEffect");
|
2729
|
-
__publicField(this, "bloomPass");
|
2730
|
-
__publicField(this, "toneMappingEffect");
|
2731
|
-
__publicField(this, "smaaEffect");
|
2732
|
-
__publicField(this, "normalPass");
|
2733
|
-
__publicField(this, "normalTextureEffect");
|
2734
|
-
__publicField(this, "ssaoEffect");
|
2735
|
-
__publicField(this, "ssaoPass");
|
2736
|
-
__publicField(this, "toneMappingPass");
|
2737
|
-
__publicField(this, "smaaPass");
|
2738
|
-
__publicField(this, "bcs", BrightnessContrastSaturation);
|
2739
|
-
__publicField(this, "bcsPass");
|
2740
|
-
__publicField(this, "gaussGrainEffect", GaussGrainEffect);
|
2741
|
-
__publicField(this, "gaussGrainPass");
|
2742
|
-
__publicField(this, "ambientLight", null);
|
2743
|
-
__publicField(this, "sun", null);
|
2744
|
-
__publicField(this, "spawnSun");
|
2745
|
-
__publicField(this, "tweakPane");
|
2673
|
+
this.width = window.innerWidth;
|
2674
|
+
this.height = window.innerHeight;
|
2675
|
+
this.resolution = new Vector22(this.width, this.height);
|
2676
|
+
this.isEnvHDRI = false;
|
2677
|
+
this.bcs = BrightnessContrastSaturation;
|
2678
|
+
this.gaussGrainEffect = GaussGrainEffect;
|
2679
|
+
this.ambientLight = null;
|
2680
|
+
this.sun = null;
|
2746
2681
|
this.scene = scene;
|
2747
2682
|
this.camera = camera;
|
2748
2683
|
this.spawnSun = spawnSun;
|
@@ -2909,7 +2844,8 @@ var Composer = class {
|
|
2909
2844
|
fileInput.type = "file";
|
2910
2845
|
fileInput.accept = ".hdr";
|
2911
2846
|
fileInput.addEventListener("change", () => {
|
2912
|
-
|
2847
|
+
var _a;
|
2848
|
+
const file = (_a = fileInput.files) == null ? void 0 : _a[0];
|
2913
2849
|
if (!file) {
|
2914
2850
|
console.log("no file");
|
2915
2851
|
return;
|
@@ -2954,21 +2890,21 @@ var Composer = class {
|
|
2954
2890
|
import { Clock } from "three";
|
2955
2891
|
var TimeManager = class {
|
2956
2892
|
constructor() {
|
2957
|
-
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
2893
|
+
this.clock = new Clock();
|
2894
|
+
this.roundMagnitude = 2e5;
|
2895
|
+
this.maxAverageFrames = 150;
|
2896
|
+
this.deltaTimes = [];
|
2897
|
+
this.targetAverageDeltaTime = 0;
|
2898
|
+
this.lerpedAverageMagDelta = 0;
|
2899
|
+
this.fpsUpdateTime = 0;
|
2900
|
+
this.framesSinceLastFPSUpdate = 0;
|
2901
|
+
this.time = 0;
|
2902
|
+
this.deltaTime = 0;
|
2903
|
+
this.rawDeltaTime = 0;
|
2904
|
+
this.smoothDeltaTime = 0;
|
2905
|
+
this.frame = 0;
|
2906
|
+
this.fps = 0;
|
2907
|
+
this.averageFPS = 0;
|
2972
2908
|
}
|
2973
2909
|
update() {
|
2974
2910
|
this.rawDeltaTime = this.clock.getDelta();
|
@@ -2998,52 +2934,72 @@ var TimeManager = class {
|
|
2998
2934
|
|
2999
2935
|
// src/collisions/CollisionsManager.ts
|
3000
2936
|
import {
|
3001
|
-
|
3002
|
-
|
2937
|
+
getRelativePositionAndRotationRelativeToObject,
|
2938
|
+
MMLCollisionTrigger
|
3003
2939
|
} from "mml-web";
|
3004
2940
|
import {
|
2941
|
+
Box3 as Box32,
|
3005
2942
|
Color as Color7,
|
3006
2943
|
DoubleSide,
|
3007
2944
|
Euler,
|
3008
|
-
|
2945
|
+
Group as Group4,
|
2946
|
+
Line3 as Line32,
|
2947
|
+
Matrix4 as Matrix42,
|
3009
2948
|
Mesh as Mesh3,
|
3010
|
-
|
2949
|
+
MeshBasicMaterial as MeshBasicMaterial3,
|
2950
|
+
Ray,
|
3011
2951
|
Vector3 as Vector38
|
3012
2952
|
} from "three";
|
2953
|
+
import { VertexNormalsHelper } from "three/examples/jsm/helpers/VertexNormalsHelper.js";
|
3013
2954
|
import * as BufferGeometryUtils from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
3014
2955
|
import { MeshBVH, MeshBVHVisualizer } from "three-mesh-bvh";
|
3015
2956
|
var CollisionsManager = class {
|
3016
2957
|
constructor(scene) {
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
2958
|
+
this.debug = false;
|
2959
|
+
this.tempVector = new Vector38();
|
2960
|
+
this.tempVector2 = new Vector38();
|
2961
|
+
this.tempRay = new Ray();
|
2962
|
+
this.tempMatrix = new Matrix42();
|
2963
|
+
this.tempMatrix2 = new Matrix42();
|
2964
|
+
this.tempBox = new Box32();
|
2965
|
+
this.tempEuler = new Euler();
|
2966
|
+
this.tempSegment = new Line32();
|
2967
|
+
this.tempSegment2 = new Line32();
|
2968
|
+
this.collisionMeshState = /* @__PURE__ */ new Map();
|
3023
2969
|
this.scene = scene;
|
3024
2970
|
this.collisionTrigger = MMLCollisionTrigger.init();
|
3025
2971
|
}
|
3026
2972
|
raycastFirstDistance(ray) {
|
3027
2973
|
let minimumDistance = null;
|
3028
2974
|
for (const [, value] of this.collisionMeshState) {
|
3029
|
-
|
2975
|
+
this.tempRay.copy(ray).applyMatrix4(this.tempMatrix.copy(value.matrix).invert());
|
2976
|
+
const hit = value.meshBVH.raycastFirst(this.tempRay, DoubleSide);
|
3030
2977
|
if (hit) {
|
3031
|
-
|
3032
|
-
|
2978
|
+
this.tempSegment.start.copy(this.tempRay.origin);
|
2979
|
+
this.tempSegment.end.copy(hit.point);
|
2980
|
+
this.tempSegment.applyMatrix4(value.matrix);
|
2981
|
+
const dist = this.tempSegment.distance();
|
2982
|
+
if (minimumDistance === null || dist < minimumDistance) {
|
2983
|
+
minimumDistance = dist;
|
3033
2984
|
}
|
3034
2985
|
}
|
3035
2986
|
}
|
3036
2987
|
return minimumDistance;
|
3037
2988
|
}
|
3038
|
-
createCollisionMeshState(group) {
|
2989
|
+
createCollisionMeshState(group, trackCollisions) {
|
3039
2990
|
const geometries = [];
|
2991
|
+
group.updateWorldMatrix(true, false);
|
2992
|
+
const invertedRootMatrix = this.tempMatrix.copy(group.matrixWorld).invert();
|
3040
2993
|
group.traverse((child) => {
|
3041
2994
|
if (child.type === "Mesh") {
|
3042
2995
|
const mesh = child;
|
3043
|
-
mesh.localToWorld(new Vector38());
|
3044
|
-
mesh.updateMatrixWorld();
|
3045
2996
|
const clonedGeometry = mesh.geometry.clone();
|
3046
|
-
|
2997
|
+
if (child !== group) {
|
2998
|
+
mesh.updateWorldMatrix(true, false);
|
2999
|
+
clonedGeometry.applyMatrix4(
|
3000
|
+
this.tempMatrix2.multiplyMatrices(invertedRootMatrix, mesh.matrixWorld)
|
3001
|
+
);
|
3002
|
+
}
|
3047
3003
|
for (const key in clonedGeometry.attributes) {
|
3048
3004
|
if (key !== "position") {
|
3049
3005
|
clonedGeometry.deleteAttribute(key);
|
@@ -3056,85 +3012,125 @@ var CollisionsManager = class {
|
|
3056
3012
|
}
|
3057
3013
|
}
|
3058
3014
|
});
|
3059
|
-
const newBufferGeometry = BufferGeometryUtils.mergeGeometries(geometries);
|
3015
|
+
const newBufferGeometry = BufferGeometryUtils.mergeGeometries(geometries, false);
|
3016
|
+
newBufferGeometry.computeVertexNormals();
|
3060
3017
|
const meshBVH = new MeshBVH(newBufferGeometry);
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
|
3066
|
-
|
3067
|
-
)
|
3068
|
-
|
3069
|
-
|
3070
|
-
|
3071
|
-
|
3072
|
-
|
3018
|
+
const meshState = {
|
3019
|
+
source: group,
|
3020
|
+
meshBVH,
|
3021
|
+
matrix: group.matrixWorld.clone(),
|
3022
|
+
trackCollisions
|
3023
|
+
};
|
3024
|
+
if (this.debug) {
|
3025
|
+
newBufferGeometry.boundsTree = meshBVH;
|
3026
|
+
const wireframeMesh = new Mesh3(newBufferGeometry, new MeshBasicMaterial3({ wireframe: true }));
|
3027
|
+
const normalsHelper = new VertexNormalsHelper(wireframeMesh, 0.25, 65280);
|
3028
|
+
const visualizer = new MeshBVHVisualizer(wireframeMesh, 4);
|
3029
|
+
visualizer.edgeMaterial.color = new Color7("blue");
|
3030
|
+
const debugGroup = new Group4();
|
3031
|
+
debugGroup.add(wireframeMesh, normalsHelper, visualizer);
|
3032
|
+
group.matrixWorld.decompose(debugGroup.position, debugGroup.quaternion, debugGroup.scale);
|
3033
|
+
visualizer.update();
|
3034
|
+
meshState.debugGroup = debugGroup;
|
3035
|
+
}
|
3036
|
+
return meshState;
|
3073
3037
|
}
|
3074
3038
|
addMeshesGroup(group, mElement) {
|
3075
3039
|
if (mElement) {
|
3076
3040
|
this.collisionTrigger.addCollider(group, mElement);
|
3077
3041
|
}
|
3078
|
-
const meshState = this.createCollisionMeshState(group);
|
3079
|
-
if (meshState.
|
3080
|
-
this.scene.add(meshState.
|
3042
|
+
const meshState = this.createCollisionMeshState(group, mElement !== void 0);
|
3043
|
+
if (meshState.debugGroup) {
|
3044
|
+
this.scene.add(meshState.debugGroup);
|
3081
3045
|
}
|
3082
3046
|
this.collisionMeshState.set(group, meshState);
|
3083
3047
|
}
|
3084
3048
|
updateMeshesGroup(group) {
|
3085
3049
|
const meshState = this.collisionMeshState.get(group);
|
3086
3050
|
if (meshState) {
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3092
|
-
|
3051
|
+
group.updateWorldMatrix(true, false);
|
3052
|
+
meshState.matrix.copy(group.matrixWorld);
|
3053
|
+
if (meshState.debugGroup) {
|
3054
|
+
group.matrixWorld.decompose(
|
3055
|
+
meshState.debugGroup.position,
|
3056
|
+
meshState.debugGroup.quaternion,
|
3057
|
+
meshState.debugGroup.scale
|
3058
|
+
);
|
3093
3059
|
}
|
3094
|
-
this.collisionMeshState.set(group, newMeshState);
|
3095
3060
|
}
|
3096
3061
|
}
|
3097
3062
|
removeMeshesGroup(group) {
|
3098
3063
|
this.collisionTrigger.removeCollider(group);
|
3099
3064
|
const meshState = this.collisionMeshState.get(group);
|
3100
3065
|
if (meshState) {
|
3101
|
-
if (meshState.
|
3102
|
-
this.scene.remove(meshState.
|
3066
|
+
if (meshState.debugGroup) {
|
3067
|
+
this.scene.remove(meshState.debugGroup);
|
3103
3068
|
}
|
3104
3069
|
this.collisionMeshState.delete(group);
|
3105
3070
|
}
|
3106
3071
|
}
|
3107
|
-
applyCollider(
|
3072
|
+
applyCollider(worldBasedCapsuleSegment, capsuleRadius, meshState) {
|
3073
|
+
const meshMatrix = this.tempMatrix.copy(meshState.matrix).invert();
|
3074
|
+
const meshRelativeCapsuleBoundingBox = this.tempBox;
|
3075
|
+
meshRelativeCapsuleBoundingBox.makeEmpty();
|
3076
|
+
meshRelativeCapsuleBoundingBox.expandByPoint(worldBasedCapsuleSegment.start);
|
3077
|
+
meshRelativeCapsuleBoundingBox.expandByPoint(worldBasedCapsuleSegment.end);
|
3078
|
+
meshRelativeCapsuleBoundingBox.min.subScalar(capsuleRadius);
|
3079
|
+
meshRelativeCapsuleBoundingBox.max.addScalar(capsuleRadius);
|
3080
|
+
meshRelativeCapsuleBoundingBox.applyMatrix4(meshMatrix);
|
3081
|
+
const meshRelativeCapsuleSegment = this.tempSegment;
|
3082
|
+
meshRelativeCapsuleSegment.start.copy(worldBasedCapsuleSegment.start);
|
3083
|
+
meshRelativeCapsuleSegment.end.copy(worldBasedCapsuleSegment.end);
|
3084
|
+
meshRelativeCapsuleSegment.applyMatrix4(meshMatrix);
|
3108
3085
|
let collisionPosition = null;
|
3109
3086
|
meshState.meshBVH.shapecast({
|
3110
|
-
intersectsBounds: (
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3114
|
-
const
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3087
|
+
intersectsBounds: (meshBox) => {
|
3088
|
+
return meshBox.intersectsBox(meshRelativeCapsuleBoundingBox);
|
3089
|
+
},
|
3090
|
+
intersectsTriangle: (meshTriangle) => {
|
3091
|
+
const closestPointOnTriangle = this.tempVector;
|
3092
|
+
const closestPointOnSegment = this.tempVector2;
|
3093
|
+
meshTriangle.closestPointToSegment(
|
3094
|
+
meshRelativeCapsuleSegment,
|
3095
|
+
closestPointOnTriangle,
|
3096
|
+
closestPointOnSegment
|
3097
|
+
);
|
3098
|
+
const intersectionSegment = this.tempSegment2;
|
3099
|
+
intersectionSegment.start.copy(closestPointOnTriangle);
|
3100
|
+
intersectionSegment.end.copy(closestPointOnSegment);
|
3101
|
+
const modelReferenceDistance = intersectionSegment.distance();
|
3102
|
+
intersectionSegment.applyMatrix4(meshState.matrix);
|
3103
|
+
const realDistance = intersectionSegment.distance();
|
3104
|
+
if (realDistance < capsuleRadius) {
|
3105
|
+
if (!collisionPosition) {
|
3106
|
+
collisionPosition = new Vector38().copy(closestPointOnSegment);
|
3107
|
+
}
|
3108
|
+
const ratio = realDistance / modelReferenceDistance;
|
3109
|
+
const realDepth = capsuleRadius - realDistance;
|
3110
|
+
const modelDepth = realDepth / ratio;
|
3111
|
+
const direction = closestPointOnSegment.sub(closestPointOnTriangle).normalize();
|
3112
|
+
meshRelativeCapsuleSegment.start.addScaledVector(direction, modelDepth);
|
3113
|
+
meshRelativeCapsuleSegment.end.addScaledVector(direction, modelDepth);
|
3121
3114
|
}
|
3122
3115
|
}
|
3123
3116
|
});
|
3117
|
+
worldBasedCapsuleSegment.start.copy(meshRelativeCapsuleSegment.start);
|
3118
|
+
worldBasedCapsuleSegment.end.copy(meshRelativeCapsuleSegment.end);
|
3119
|
+
worldBasedCapsuleSegment.applyMatrix4(meshState.matrix);
|
3124
3120
|
return collisionPosition;
|
3125
3121
|
}
|
3126
|
-
applyColliders(tempSegment, radius
|
3122
|
+
applyColliders(tempSegment, radius) {
|
3127
3123
|
let collidedElements = null;
|
3128
3124
|
for (const meshState of this.collisionMeshState.values()) {
|
3129
|
-
const collisionPosition = this.applyCollider(tempSegment, radius,
|
3130
|
-
if (collisionPosition) {
|
3125
|
+
const collisionPosition = this.applyCollider(tempSegment, radius, meshState);
|
3126
|
+
if (collisionPosition && meshState.trackCollisions) {
|
3131
3127
|
if (collidedElements === null) {
|
3132
3128
|
collidedElements = /* @__PURE__ */ new Map();
|
3133
3129
|
}
|
3134
3130
|
const relativePosition = getRelativePositionAndRotationRelativeToObject(
|
3135
3131
|
{
|
3136
3132
|
position: collisionPosition,
|
3137
|
-
rotation:
|
3133
|
+
rotation: this.tempEuler.set(0, 0, 0)
|
3138
3134
|
},
|
3139
3135
|
meshState.source
|
3140
3136
|
);
|