@mml-io/3d-web-client-core 0.21.4 → 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;
|
@@ -2892,7 +2903,7 @@ var envOptions = {
|
|
2892
2903
|
},
|
2893
2904
|
fog: {
|
2894
2905
|
fogNear: { min: 0, max: 80, step: 1 },
|
2895
|
-
fogFar: { min:
|
2906
|
+
fogFar: { min: 0, max: 300, step: 1 }
|
2896
2907
|
}
|
2897
2908
|
};
|
2898
2909
|
var EnvironmentFolder = class {
|
@@ -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(
|
@@ -5714,6 +5726,10 @@ var Composer = class {
|
|
5714
5726
|
fileInput.click();
|
5715
5727
|
}
|
5716
5728
|
setFog() {
|
5729
|
+
if (envValues.fog.fogFar === 0) {
|
5730
|
+
this.scene.fog = null;
|
5731
|
+
return;
|
5732
|
+
}
|
5717
5733
|
const fogColor = new Color7().setRGB(
|
5718
5734
|
envValues.fog.fogColor.r,
|
5719
5735
|
envValues.fog.fogColor.g,
|
@@ -5754,6 +5770,21 @@ var Composer = class {
|
|
5754
5770
|
(_i = this.sun) == null ? void 0 : _i.setPolarAngle(this.environmentConfiguration.sun.polarAngle * (Math.PI / 180));
|
5755
5771
|
}
|
5756
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
|
+
}
|
5757
5788
|
updateSkyboxAndEnvValues() {
|
5758
5789
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
5759
5790
|
if (typeof ((_b = (_a = this.environmentConfiguration) == null ? void 0 : _a.envMap) == null ? void 0 : _b.intensity) === "number") {
|
@@ -5805,7 +5836,7 @@ var Composer = class {
|
|
5805
5836
|
|
5806
5837
|
// src/time/TimeManager.ts
|
5807
5838
|
import { Clock } from "three";
|
5808
|
-
var
|
5839
|
+
var _TimeManager = class _TimeManager {
|
5809
5840
|
constructor() {
|
5810
5841
|
this.clock = new Clock();
|
5811
5842
|
this.roundMagnitude = 2e5;
|
@@ -5823,8 +5854,12 @@ var TimeManager = class {
|
|
5823
5854
|
this.fps = 0;
|
5824
5855
|
this.averageFPS = 0;
|
5825
5856
|
}
|
5857
|
+
// 100ms
|
5826
5858
|
update() {
|
5827
5859
|
this.rawDeltaTime = this.clock.getDelta();
|
5860
|
+
if (this.rawDeltaTime > _TimeManager.maxDeltaTime) {
|
5861
|
+
this.rawDeltaTime = _TimeManager.maxDeltaTime;
|
5862
|
+
}
|
5828
5863
|
this.frame++;
|
5829
5864
|
this.time += this.rawDeltaTime;
|
5830
5865
|
this.deltaTimes.push(this.rawDeltaTime);
|
@@ -5847,6 +5882,8 @@ var TimeManager = class {
|
|
5847
5882
|
}
|
5848
5883
|
}
|
5849
5884
|
};
|
5885
|
+
_TimeManager.maxDeltaTime = 0.1;
|
5886
|
+
var TimeManager = _TimeManager;
|
5850
5887
|
|
5851
5888
|
// src/collisions/CollisionsManager.ts
|
5852
5889
|
import { MMLCollisionTrigger } from "@mml-io/mml-web";
|
@@ -5923,10 +5960,11 @@ var CollisionsManager = class {
|
|
5923
5960
|
this.scene = scene;
|
5924
5961
|
this.collisionTrigger = MMLCollisionTrigger.init();
|
5925
5962
|
}
|
5926
|
-
raycastFirst(ray) {
|
5963
|
+
raycastFirst(ray, maximumDistance = null) {
|
5927
5964
|
let minimumDistance = null;
|
5928
5965
|
let minimumHit = null;
|
5929
|
-
let minimumNormal =
|
5966
|
+
let minimumNormal = null;
|
5967
|
+
let minimumPoint = null;
|
5930
5968
|
for (const [, collisionMeshState] of this.collisionMeshState) {
|
5931
5969
|
this.tempRay.copy(ray).applyMatrix4(this.tempMatrix.copy(collisionMeshState.matrix).invert());
|
5932
5970
|
const hit = collisionMeshState.meshBVH.raycastFirst(this.tempRay, DoubleSide);
|
@@ -5935,17 +5973,24 @@ var CollisionsManager = class {
|
|
5935
5973
|
this.tempSegment.end.copy(hit.point);
|
5936
5974
|
this.tempSegment.applyMatrix4(collisionMeshState.matrix);
|
5937
5975
|
const dist = this.tempSegment.distance();
|
5938
|
-
if (minimumDistance === null || dist < minimumDistance) {
|
5976
|
+
if ((maximumDistance === null || dist < maximumDistance) && (minimumDistance === null || dist < minimumDistance)) {
|
5939
5977
|
minimumDistance = dist;
|
5940
5978
|
minimumHit = collisionMeshState;
|
5979
|
+
if (minimumNormal === null) {
|
5980
|
+
minimumNormal = new Vector316();
|
5981
|
+
}
|
5982
|
+
if (minimumPoint === null) {
|
5983
|
+
minimumPoint = new Vector316();
|
5984
|
+
}
|
5941
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);
|
5942
5987
|
}
|
5943
5988
|
}
|
5944
5989
|
}
|
5945
|
-
if (minimumDistance === null || minimumNormal === null || minimumHit === null) {
|
5990
|
+
if (minimumDistance === null || minimumNormal === null || minimumHit === null || minimumPoint === null) {
|
5946
5991
|
return null;
|
5947
5992
|
}
|
5948
|
-
return [minimumDistance, minimumNormal, minimumHit];
|
5993
|
+
return [minimumDistance, minimumNormal, minimumHit, minimumPoint];
|
5949
5994
|
}
|
5950
5995
|
createCollisionMeshState(group, trackCollisions) {
|
5951
5996
|
const geometries = [];
|