@mml-io/3d-web-client-core 0.21.5 → 0.21.6
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.
@@ -26,7 +26,7 @@ export declare class CollisionsManager {
|
|
26
26
|
private collisionTrigger;
|
27
27
|
private previouslyCollidingElements;
|
28
28
|
constructor(scene: Scene);
|
29
|
-
raycastFirst(ray: Ray): [number, Vector3, CollisionMeshState] | null;
|
29
|
+
raycastFirst(ray: Ray, maximumDistance?: number | null): [number, Vector3, CollisionMeshState, Vector3] | null;
|
30
30
|
private createCollisionMeshState;
|
31
31
|
addMeshesGroup(group: Group, mElement?: MElement): void;
|
32
32
|
updateMeshesGroup(group: Group): void;
|
package/build/index.js
CHANGED
@@ -1533,7 +1533,7 @@ var Character = class extends Group {
|
|
1533
1533
|
import { Euler as Euler2, Group as Group2, Quaternion as Quaternion5, Vector3 as Vector39 } from "three";
|
1534
1534
|
|
1535
1535
|
// src/character/LocalController.ts
|
1536
|
-
import { Euler, Line3,
|
1536
|
+
import { Euler, Line3, Quaternion as Quaternion2, Ray, Raycaster as Raycaster2, Vector3 as Vector36 } from "three";
|
1537
1537
|
|
1538
1538
|
// src/tweakpane/blades/characterControlsFolder.ts
|
1539
1539
|
var characterControllerValues = {
|
@@ -1752,7 +1752,6 @@ var LocalController = class {
|
|
1752
1752
|
this.vectorDown = new Vector36(0, -1, 0);
|
1753
1753
|
this.rotationOffset = 0;
|
1754
1754
|
this.azimuthalAngle = 0;
|
1755
|
-
this.tempMatrix = new Matrix4();
|
1756
1755
|
this.tempSegment = new Line3();
|
1757
1756
|
this.tempQuaternion = new Quaternion2();
|
1758
1757
|
this.tempEuler = new Euler();
|
@@ -1949,13 +1948,25 @@ var LocalController = class {
|
|
1949
1948
|
this.config.character.rotation.setFromQuaternion(asQuaternion);
|
1950
1949
|
}
|
1951
1950
|
}
|
1952
|
-
this.config.character.updateMatrixWorld();
|
1953
1951
|
const avatarSegment = this.tempSegment;
|
1954
1952
|
avatarSegment.copy(this.capsuleInfo.segment);
|
1955
|
-
avatarSegment.start.
|
1956
|
-
avatarSegment.end.
|
1953
|
+
avatarSegment.start.add(this.config.character.position);
|
1954
|
+
avatarSegment.end.add(this.config.character.position);
|
1957
1955
|
const positionBeforeCollisions = this.tempVector.copy(avatarSegment.start);
|
1958
1956
|
this.config.collisionsManager.applyColliders(avatarSegment, this.capsuleInfo.radius);
|
1957
|
+
const capsuleLength = this.capsuleInfo.segment.end.y - this.capsuleInfo.segment.start.y + this.capsuleInfo.radius * 2;
|
1958
|
+
this.rayCaster.set(avatarSegment.start, this.vectorDown);
|
1959
|
+
const endIgnoreLength = 0.1;
|
1960
|
+
this.rayCaster.ray.origin.y += -this.capsuleInfo.radius + capsuleLength - endIgnoreLength;
|
1961
|
+
const withinCapsuleRayHit = this.config.collisionsManager.raycastFirst(
|
1962
|
+
this.rayCaster.ray,
|
1963
|
+
capsuleLength - endIgnoreLength * 2
|
1964
|
+
);
|
1965
|
+
if (withinCapsuleRayHit !== null) {
|
1966
|
+
const rayHitPosition = withinCapsuleRayHit[3];
|
1967
|
+
avatarSegment.start.copy(rayHitPosition);
|
1968
|
+
avatarSegment.start.y += this.capsuleInfo.radius;
|
1969
|
+
}
|
1959
1970
|
this.config.character.position.copy(avatarSegment.start);
|
1960
1971
|
const deltaCollisionPosition = avatarSegment.start.sub(positionBeforeCollisions);
|
1961
1972
|
this.characterOnGround = deltaCollisionPosition.y > 0;
|
@@ -5395,9 +5406,6 @@ var Composer = class {
|
|
5395
5406
|
this.renderer.toneMapping = rendererValues.toneMapping;
|
5396
5407
|
this.renderer.toneMappingExposure = rendererValues.exposure;
|
5397
5408
|
this.environmentConfiguration = environmentConfiguration;
|
5398
|
-
this.updateSkyboxAndEnvValues();
|
5399
|
-
this.updateAmbientLightValues();
|
5400
|
-
this.setFog();
|
5401
5409
|
this.effectComposer = new EffectComposer2(this.renderer, {
|
5402
5410
|
frameBufferType: HalfFloatType2
|
5403
5411
|
});
|
@@ -5436,6 +5444,9 @@ var Composer = class {
|
|
5436
5444
|
if ((_a = environmentConfiguration == null ? void 0 : environmentConfiguration.postProcessing) == null ? void 0 : _a.bloomIntensity) {
|
5437
5445
|
extrasValues.bloom = environmentConfiguration.postProcessing.bloomIntensity;
|
5438
5446
|
}
|
5447
|
+
this.updateSkyboxAndEnvValues();
|
5448
|
+
this.updateAmbientLightValues();
|
5449
|
+
this.updateFogValues();
|
5439
5450
|
this.bloomEffect = new BloomEffect({
|
5440
5451
|
intensity: extrasValues.bloom
|
5441
5452
|
});
|
@@ -5526,6 +5537,7 @@ var Composer = class {
|
|
5526
5537
|
this.updateSkyboxAndEnvValues();
|
5527
5538
|
this.updateAmbientLightValues();
|
5528
5539
|
this.updateSunValues();
|
5540
|
+
this.updateFogValues();
|
5529
5541
|
}
|
5530
5542
|
setupTweakPane(tweakPane) {
|
5531
5543
|
tweakPane.setupRenderPane(
|
@@ -5758,6 +5770,21 @@ var Composer = class {
|
|
5758
5770
|
(_i = this.sun) == null ? void 0 : _i.setPolarAngle(this.environmentConfiguration.sun.polarAngle * (Math.PI / 180));
|
5759
5771
|
}
|
5760
5772
|
}
|
5773
|
+
updateFogValues() {
|
5774
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
5775
|
+
if (typeof ((_b = (_a = this.environmentConfiguration) == null ? void 0 : _a.fog) == null ? void 0 : _b.fogNear) === "number") {
|
5776
|
+
envValues.fog.fogNear = this.environmentConfiguration.fog.fogNear;
|
5777
|
+
}
|
5778
|
+
if (typeof ((_d = (_c = this.environmentConfiguration) == null ? void 0 : _c.fog) == null ? void 0 : _d.fogFar) === "number") {
|
5779
|
+
envValues.fog.fogFar = this.environmentConfiguration.fog.fogFar;
|
5780
|
+
}
|
5781
|
+
if (typeof ((_g = (_f = (_e = this.environmentConfiguration) == null ? void 0 : _e.fog) == null ? void 0 : _f.fogColor) == null ? void 0 : _g.r) === "number" && typeof ((_j = (_i = (_h = this.environmentConfiguration) == null ? void 0 : _h.fog) == null ? void 0 : _i.fogColor) == null ? void 0 : _j.g) === "number" && typeof ((_m = (_l = (_k = this.environmentConfiguration) == null ? void 0 : _k.fog) == null ? void 0 : _l.fogColor) == null ? void 0 : _m.b) === "number") {
|
5782
|
+
envValues.fog.fogColor.r = this.environmentConfiguration.fog.fogColor.r;
|
5783
|
+
envValues.fog.fogColor.g = this.environmentConfiguration.fog.fogColor.g;
|
5784
|
+
envValues.fog.fogColor.b = this.environmentConfiguration.fog.fogColor.b;
|
5785
|
+
}
|
5786
|
+
this.setFog();
|
5787
|
+
}
|
5761
5788
|
updateSkyboxAndEnvValues() {
|
5762
5789
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
5763
5790
|
if (typeof ((_b = (_a = this.environmentConfiguration) == null ? void 0 : _a.envMap) == null ? void 0 : _b.intensity) === "number") {
|
@@ -5809,7 +5836,7 @@ var Composer = class {
|
|
5809
5836
|
|
5810
5837
|
// src/time/TimeManager.ts
|
5811
5838
|
import { Clock } from "three";
|
5812
|
-
var
|
5839
|
+
var _TimeManager = class _TimeManager {
|
5813
5840
|
constructor() {
|
5814
5841
|
this.clock = new Clock();
|
5815
5842
|
this.roundMagnitude = 2e5;
|
@@ -5827,8 +5854,12 @@ var TimeManager = class {
|
|
5827
5854
|
this.fps = 0;
|
5828
5855
|
this.averageFPS = 0;
|
5829
5856
|
}
|
5857
|
+
// 100ms
|
5830
5858
|
update() {
|
5831
5859
|
this.rawDeltaTime = this.clock.getDelta();
|
5860
|
+
if (this.rawDeltaTime > _TimeManager.maxDeltaTime) {
|
5861
|
+
this.rawDeltaTime = _TimeManager.maxDeltaTime;
|
5862
|
+
}
|
5832
5863
|
this.frame++;
|
5833
5864
|
this.time += this.rawDeltaTime;
|
5834
5865
|
this.deltaTimes.push(this.rawDeltaTime);
|
@@ -5851,6 +5882,8 @@ var TimeManager = class {
|
|
5851
5882
|
}
|
5852
5883
|
}
|
5853
5884
|
};
|
5885
|
+
_TimeManager.maxDeltaTime = 0.1;
|
5886
|
+
var TimeManager = _TimeManager;
|
5854
5887
|
|
5855
5888
|
// src/collisions/CollisionsManager.ts
|
5856
5889
|
import { MMLCollisionTrigger } from "@mml-io/mml-web";
|
@@ -5927,10 +5960,11 @@ var CollisionsManager = class {
|
|
5927
5960
|
this.scene = scene;
|
5928
5961
|
this.collisionTrigger = MMLCollisionTrigger.init();
|
5929
5962
|
}
|
5930
|
-
raycastFirst(ray) {
|
5963
|
+
raycastFirst(ray, maximumDistance = null) {
|
5931
5964
|
let minimumDistance = null;
|
5932
5965
|
let minimumHit = null;
|
5933
|
-
let minimumNormal =
|
5966
|
+
let minimumNormal = null;
|
5967
|
+
let minimumPoint = null;
|
5934
5968
|
for (const [, collisionMeshState] of this.collisionMeshState) {
|
5935
5969
|
this.tempRay.copy(ray).applyMatrix4(this.tempMatrix.copy(collisionMeshState.matrix).invert());
|
5936
5970
|
const hit = collisionMeshState.meshBVH.raycastFirst(this.tempRay, DoubleSide);
|
@@ -5939,17 +5973,24 @@ var CollisionsManager = class {
|
|
5939
5973
|
this.tempSegment.end.copy(hit.point);
|
5940
5974
|
this.tempSegment.applyMatrix4(collisionMeshState.matrix);
|
5941
5975
|
const dist = this.tempSegment.distance();
|
5942
|
-
if (minimumDistance === null || dist < minimumDistance) {
|
5976
|
+
if ((maximumDistance === null || dist < maximumDistance) && (minimumDistance === null || dist < minimumDistance)) {
|
5943
5977
|
minimumDistance = dist;
|
5944
5978
|
minimumHit = collisionMeshState;
|
5979
|
+
if (minimumNormal === null) {
|
5980
|
+
minimumNormal = new Vector316();
|
5981
|
+
}
|
5982
|
+
if (minimumPoint === null) {
|
5983
|
+
minimumPoint = new Vector316();
|
5984
|
+
}
|
5945
5985
|
minimumNormal = (hit.normal ? minimumNormal.copy(hit.normal) : minimumNormal).applyQuaternion(this.tempQuaternion.setFromRotationMatrix(collisionMeshState.matrix)).normalize();
|
5986
|
+
minimumPoint = minimumPoint.copy(hit.point).applyMatrix4(collisionMeshState.matrix);
|
5946
5987
|
}
|
5947
5988
|
}
|
5948
5989
|
}
|
5949
|
-
if (minimumDistance === null || minimumNormal === null || minimumHit === null) {
|
5990
|
+
if (minimumDistance === null || minimumNormal === null || minimumHit === null || minimumPoint === null) {
|
5950
5991
|
return null;
|
5951
5992
|
}
|
5952
|
-
return [minimumDistance, minimumNormal, minimumHit];
|
5993
|
+
return [minimumDistance, minimumNormal, minimumHit, minimumPoint];
|
5953
5994
|
}
|
5954
5995
|
createCollisionMeshState(group, trackCollisions) {
|
5955
5996
|
const geometries = [];
|