@mml-io/3d-web-client-core 0.21.2 → 0.21.3
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 +59 -71
- package/build/index.js.map +2 -2
- package/package.json +11 -11
package/build/index.js
CHANGED
@@ -19,8 +19,7 @@ var toArray = (origin, precision = 3) => {
|
|
19
19
|
return array;
|
20
20
|
};
|
21
21
|
var getSpawnPositionInsideCircle = (radius, positions, id, yPos = 0) => {
|
22
|
-
if (id > 0)
|
23
|
-
id += 3;
|
22
|
+
if (id > 0) id += 3;
|
24
23
|
const goldenAngle = Math.PI * (3 - Math.sqrt(5));
|
25
24
|
const theta = id * goldenAngle;
|
26
25
|
const scale = id / positions;
|
@@ -129,8 +128,7 @@ var CameraFolder = class {
|
|
129
128
|
setupChangeEvent(cameraManager) {
|
130
129
|
this.folder.on("change", (e) => {
|
131
130
|
const target = e.target.key;
|
132
|
-
if (!target)
|
133
|
-
return;
|
131
|
+
if (!target) return;
|
134
132
|
switch (target) {
|
135
133
|
case "initialDistance": {
|
136
134
|
const value = e.value;
|
@@ -628,8 +626,7 @@ var CharacterFolder = class {
|
|
628
626
|
setupChangeEvent() {
|
629
627
|
this.folder.on("change", (e) => {
|
630
628
|
const target = e.target.key;
|
631
|
-
if (!target)
|
632
|
-
return;
|
629
|
+
if (!target) return;
|
633
630
|
switch (target) {
|
634
631
|
case "emissive": {
|
635
632
|
const value = e.value;
|
@@ -828,8 +825,7 @@ var _CharacterModel = class _CharacterModel {
|
|
828
825
|
}
|
829
826
|
}
|
830
827
|
applyCustomMaterials() {
|
831
|
-
if (!this.mesh)
|
832
|
-
return;
|
828
|
+
if (!this.mesh) return;
|
833
829
|
const boundingBox = new Box3();
|
834
830
|
this.mesh.updateWorldMatrix(true, true);
|
835
831
|
boundingBox.expandByObject(this.mesh);
|
@@ -1162,8 +1158,7 @@ function printAtWordWrap(context, fullText, textAlign, y, lineHeight, fitWidth,
|
|
1162
1158
|
const substring = word.substring(0, charIndex);
|
1163
1159
|
const subWidth = context.measureText(substring).width;
|
1164
1160
|
if (subWidth + padding * 2 > fitWidth) {
|
1165
|
-
if (charIndex === 1)
|
1166
|
-
charIndex = 2;
|
1161
|
+
if (charIndex === 1) charIndex = 2;
|
1167
1162
|
context.fillText(
|
1168
1163
|
word.substring(0, charIndex - 1),
|
1169
1164
|
x + padding,
|
@@ -1495,8 +1490,7 @@ var Character = class extends Group {
|
|
1495
1490
|
}
|
1496
1491
|
update(time, deltaTime) {
|
1497
1492
|
var _a;
|
1498
|
-
if (!this.model)
|
1499
|
-
return;
|
1493
|
+
if (!this.model) return;
|
1500
1494
|
if (this.tooltip) {
|
1501
1495
|
this.tooltip.update();
|
1502
1496
|
}
|
@@ -1646,8 +1640,7 @@ var CharacterControlsFolder = class {
|
|
1646
1640
|
setupChangeEvent(localController) {
|
1647
1641
|
this.folder.on("change", (e) => {
|
1648
1642
|
const target = e.target.key;
|
1649
|
-
if (!target)
|
1650
|
-
return;
|
1643
|
+
if (!target) return;
|
1651
1644
|
switch (target) {
|
1652
1645
|
case "gravity": {
|
1653
1646
|
const value = e.value;
|
@@ -1818,8 +1811,7 @@ var LocalController = class {
|
|
1818
1811
|
this.updateNetworkState();
|
1819
1812
|
}
|
1820
1813
|
getTargetAnimation() {
|
1821
|
-
if (!this.config.character)
|
1822
|
-
return 0 /* idle */;
|
1814
|
+
if (!this.config.character) return 0 /* idle */;
|
1823
1815
|
const jumpHeight = this.characterVelocity.y > 0 ? 0.2 : 1.8;
|
1824
1816
|
if (this.currentHeight > jumpHeight && !this.characterOnGround) {
|
1825
1817
|
if (this.doubleJumpUsed) {
|
@@ -2842,8 +2834,7 @@ var BrightnessContrastSaturationFolder = class {
|
|
2842
2834
|
setupChangeEvent(brightnessContrastSaturation) {
|
2843
2835
|
this.folder.on("change", (e) => {
|
2844
2836
|
const target = e.target.key;
|
2845
|
-
if (!target)
|
2846
|
-
return;
|
2837
|
+
if (!target) return;
|
2847
2838
|
switch (target) {
|
2848
2839
|
case "brightness":
|
2849
2840
|
brightnessContrastSaturation.uniforms.brightness.value = e.value;
|
@@ -2949,8 +2940,7 @@ var EnvironmentFolder = class {
|
|
2949
2940
|
setupChangeEvent(scene, setHDR, setSkyboxAzimuthalAngle, setSkyboxPolarAngle, setAmbientLight, setFog, sun) {
|
2950
2941
|
this.sun.on("change", (e) => {
|
2951
2942
|
const target = e.target.key;
|
2952
|
-
if (!target)
|
2953
|
-
return;
|
2943
|
+
if (!target) return;
|
2954
2944
|
switch (target) {
|
2955
2945
|
case "sunAzimuthalAngle": {
|
2956
2946
|
const value = e.value;
|
@@ -2986,8 +2976,7 @@ var EnvironmentFolder = class {
|
|
2986
2976
|
});
|
2987
2977
|
this.envMap.on("change", (e) => {
|
2988
2978
|
const target = e.target.key;
|
2989
|
-
if (!target)
|
2990
|
-
return;
|
2979
|
+
if (!target) return;
|
2991
2980
|
switch (target) {
|
2992
2981
|
case "envMapIntensity":
|
2993
2982
|
scene.environmentIntensity = e.value;
|
@@ -2996,8 +2985,7 @@ var EnvironmentFolder = class {
|
|
2996
2985
|
});
|
2997
2986
|
this.skybox.on("change", (e) => {
|
2998
2987
|
const target = e.target.key;
|
2999
|
-
if (!target)
|
3000
|
-
return;
|
2988
|
+
if (!target) return;
|
3001
2989
|
switch (target) {
|
3002
2990
|
case "skyboxAzimuthalAngle": {
|
3003
2991
|
const value = e.value;
|
@@ -3020,8 +3008,7 @@ var EnvironmentFolder = class {
|
|
3020
3008
|
});
|
3021
3009
|
this.ambient.on("change", (e) => {
|
3022
3010
|
const target = e.target.key;
|
3023
|
-
if (!target)
|
3024
|
-
return;
|
3011
|
+
if (!target) return;
|
3025
3012
|
switch (target) {
|
3026
3013
|
case "ambientLightIntensity": {
|
3027
3014
|
envValues.ambientLight.ambientLightIntensity = e.value;
|
@@ -3042,8 +3029,7 @@ var EnvironmentFolder = class {
|
|
3042
3029
|
});
|
3043
3030
|
this.fog.on("change", (e) => {
|
3044
3031
|
const target = e.target.key;
|
3045
|
-
if (!target)
|
3046
|
-
return;
|
3032
|
+
if (!target) return;
|
3047
3033
|
switch (target) {
|
3048
3034
|
case "fogNear": {
|
3049
3035
|
envValues.fog.fogNear = e.value;
|
@@ -3092,8 +3078,7 @@ var PostExtrasFolder = class {
|
|
3092
3078
|
setupChangeEvent(bloomEffect, gaussGrainEffect) {
|
3093
3079
|
this.folder.on("change", (e) => {
|
3094
3080
|
const target = e.target.key;
|
3095
|
-
if (!target)
|
3096
|
-
return;
|
3081
|
+
if (!target) return;
|
3097
3082
|
switch (target) {
|
3098
3083
|
case "bloom":
|
3099
3084
|
bloomEffect.intensity = e.value;
|
@@ -3159,8 +3144,7 @@ var RendererFolder = class {
|
|
3159
3144
|
setupChangeEvent(renderer, toneMappingFolder, toneMappingPass) {
|
3160
3145
|
this.folder.on("change", (e) => {
|
3161
3146
|
const target = e.target.key;
|
3162
|
-
if (!target)
|
3163
|
-
return;
|
3147
|
+
if (!target) return;
|
3164
3148
|
switch (target) {
|
3165
3149
|
case "shadowMap": {
|
3166
3150
|
const value2 = e.value;
|
@@ -3388,8 +3372,7 @@ var SSAOFolder = class {
|
|
3388
3372
|
setupChangeEvent(composer, normalPass, ppssaoEffect, ppssaoPass, n8aopass) {
|
3389
3373
|
this.ppssao.on("change", (e) => {
|
3390
3374
|
const target = e.target.key;
|
3391
|
-
if (!target)
|
3392
|
-
return;
|
3375
|
+
if (!target) return;
|
3393
3376
|
switch (target) {
|
3394
3377
|
case "enabled": {
|
3395
3378
|
const value = e.value;
|
@@ -3433,8 +3416,7 @@ var SSAOFolder = class {
|
|
3433
3416
|
});
|
3434
3417
|
this.n8ssao.on("change", (e) => {
|
3435
3418
|
const target = e.target.key;
|
3436
|
-
if (!target)
|
3437
|
-
return;
|
3419
|
+
if (!target) return;
|
3438
3420
|
switch (target) {
|
3439
3421
|
case "enabled":
|
3440
3422
|
if (e.value === true) {
|
@@ -3546,8 +3528,7 @@ var ToneMappingFolder = class {
|
|
3546
3528
|
setupChangeEvent(toneMappingEffect) {
|
3547
3529
|
this.folder.on("change", (e) => {
|
3548
3530
|
const target = e.target.key;
|
3549
|
-
if (!target)
|
3550
|
-
return;
|
3531
|
+
if (!target) return;
|
3551
3532
|
if (target === "mode") {
|
3552
3533
|
setCustomToneMappingType(e.value);
|
3553
3534
|
}
|
@@ -3895,22 +3876,17 @@ var Sun = class extends Group4 {
|
|
3895
3876
|
}
|
3896
3877
|
}
|
3897
3878
|
updateCharacterPosition(position) {
|
3898
|
-
if (!position)
|
3899
|
-
return;
|
3879
|
+
if (!position) return;
|
3900
3880
|
this.target = position;
|
3901
3881
|
this.setSunPosition(this.sunOffset.x, this.sunOffset.y);
|
3902
3882
|
}
|
3903
3883
|
setAzimuthalAngle(angle) {
|
3904
|
-
if (this.sunOffset)
|
3905
|
-
|
3906
|
-
if (this.target)
|
3907
|
-
this.updateCharacterPosition(this.target);
|
3884
|
+
if (this.sunOffset) this.sunOffset.x = angle;
|
3885
|
+
if (this.target) this.updateCharacterPosition(this.target);
|
3908
3886
|
}
|
3909
3887
|
setPolarAngle(angle) {
|
3910
|
-
if (this.sunOffset)
|
3911
|
-
|
3912
|
-
if (this.target)
|
3913
|
-
this.updateCharacterPosition(this.target);
|
3888
|
+
if (this.sunOffset) this.sunOffset.y = angle;
|
3889
|
+
if (this.target) this.updateCharacterPosition(this.target);
|
3914
3890
|
}
|
3915
3891
|
setIntensity(intensity) {
|
3916
3892
|
this.directionalLight.intensity = intensity;
|
@@ -3923,8 +3899,7 @@ var Sun = class extends Group4 {
|
|
3923
3899
|
);
|
3924
3900
|
}
|
3925
3901
|
setSunPosition(azimuthalAngle, polarAngle) {
|
3926
|
-
if (!this.target)
|
3927
|
-
return;
|
3902
|
+
if (!this.target) return;
|
3928
3903
|
const distance = this.sunOffset.z;
|
3929
3904
|
const sphericalPosition = new Vector310(
|
3930
3905
|
distance * Math.sin(polarAngle) * Math.cos(azimuthalAngle),
|
@@ -5251,8 +5226,7 @@ var N8SSAOPass = class extends Pass {
|
|
5251
5226
|
depthDownsampleUniforms.logDepth.value = this.configuration.logarithmicDepthBuffer;
|
5252
5227
|
this.depthDownsampleQuad.render(renderer);
|
5253
5228
|
}
|
5254
|
-
if (!this.effectShaderQuad)
|
5255
|
-
return;
|
5229
|
+
if (!this.effectShaderQuad) return;
|
5256
5230
|
const effectShaderUniforms = this.effectShaderQuad.material.uniforms;
|
5257
5231
|
effectShaderUniforms.sceneDiffuse.value = inputBuffer.texture;
|
5258
5232
|
effectShaderUniforms.sceneDepth.value = this.configuration.halfRes ? this.depthDownsampleTarget.texture[0] : this.depthTexture;
|
@@ -5279,8 +5253,7 @@ var N8SSAOPass = class extends Pass {
|
|
5279
5253
|
this.effectShaderQuad.render(renderer);
|
5280
5254
|
const poissonBlurUniforms = this.poissonBlurQuad.material.uniforms;
|
5281
5255
|
for (let i = 0; i < this.configuration.denoiseIterations; i++) {
|
5282
|
-
if (!poissonBlurUniforms || !this.poissonBlurQuad)
|
5283
|
-
return;
|
5256
|
+
if (!poissonBlurUniforms || !this.poissonBlurQuad) return;
|
5284
5257
|
[this.writeTargetInternal, this.readTargetInternal] = [
|
5285
5258
|
this.readTargetInternal,
|
5286
5259
|
this.writeTargetInternal
|
@@ -5308,8 +5281,7 @@ var N8SSAOPass = class extends Pass {
|
|
5308
5281
|
this.poissonBlurQuad.render(renderer);
|
5309
5282
|
}
|
5310
5283
|
const effectCompositerUniforms = this.effectCompositerQuad.material.uniforms;
|
5311
|
-
if (!effectCompositerUniforms || !this.effectCompositerQuad)
|
5312
|
-
return;
|
5284
|
+
if (!effectCompositerUniforms || !this.effectCompositerQuad) return;
|
5313
5285
|
effectCompositerUniforms.sceneDiffuse.value = inputBuffer.texture;
|
5314
5286
|
effectCompositerUniforms.sceneDepth.value = this.depthTexture;
|
5315
5287
|
effectCompositerUniforms.near.value = this.camera.near;
|
@@ -5714,8 +5686,7 @@ var Composer = class {
|
|
5714
5686
|
});
|
5715
5687
|
}
|
5716
5688
|
setHDRIFromFile() {
|
5717
|
-
if (!this.renderer)
|
5718
|
-
return;
|
5689
|
+
if (!this.renderer) return;
|
5719
5690
|
const fileInput = document.createElement("input");
|
5720
5691
|
fileInput.type = "file";
|
5721
5692
|
fileInput.accept = ".hdr,.jpg";
|
@@ -5858,8 +5829,7 @@ var TimeManager = class {
|
|
5858
5829
|
this.frame++;
|
5859
5830
|
this.time += this.rawDeltaTime;
|
5860
5831
|
this.deltaTimes.push(this.rawDeltaTime);
|
5861
|
-
if (this.deltaTimes.length > this.maxAverageFrames)
|
5862
|
-
this.deltaTimes.shift();
|
5832
|
+
if (this.deltaTimes.length > this.maxAverageFrames) this.deltaTimes.shift();
|
5863
5833
|
this.targetAverageDeltaTime = this.deltaTimes.reduce((prev, curr) => prev + curr, 0) / this.deltaTimes.length;
|
5864
5834
|
this.lerpedAverageMagDelta += ease(
|
5865
5835
|
this.targetAverageDeltaTime * this.roundMagnitude,
|
@@ -5985,23 +5955,41 @@ var CollisionsManager = class {
|
|
5985
5955
|
group.traverse((child) => {
|
5986
5956
|
const asMesh = child;
|
5987
5957
|
if (asMesh.isMesh) {
|
5988
|
-
const
|
5989
|
-
if (
|
5958
|
+
const asInstancedMesh = asMesh;
|
5959
|
+
if (asInstancedMesh.isInstancedMesh) {
|
5960
|
+
for (let i = 0; i < asInstancedMesh.count; i++) {
|
5961
|
+
const clonedGeometry = asInstancedMesh.geometry.clone();
|
5962
|
+
for (const key in clonedGeometry.attributes) {
|
5963
|
+
if (key !== "position") {
|
5964
|
+
clonedGeometry.deleteAttribute(key);
|
5965
|
+
}
|
5966
|
+
}
|
5967
|
+
clonedGeometry.applyMatrix4(
|
5968
|
+
this.tempMatrix2.fromArray(asInstancedMesh.instanceMatrix.array, i * 16)
|
5969
|
+
);
|
5970
|
+
if (clonedGeometry.index) {
|
5971
|
+
geometries.push(clonedGeometry.toNonIndexed());
|
5972
|
+
} else {
|
5973
|
+
geometries.push(clonedGeometry);
|
5974
|
+
}
|
5975
|
+
}
|
5976
|
+
} else {
|
5977
|
+
const clonedGeometry = asMesh.geometry.clone();
|
5990
5978
|
asMesh.updateWorldMatrix(true, false);
|
5979
|
+
for (const key in clonedGeometry.attributes) {
|
5980
|
+
if (key !== "position") {
|
5981
|
+
clonedGeometry.deleteAttribute(key);
|
5982
|
+
}
|
5983
|
+
}
|
5991
5984
|
clonedGeometry.applyMatrix4(
|
5992
5985
|
this.tempMatrix2.multiplyMatrices(invertedRootMatrix, asMesh.matrixWorld)
|
5993
5986
|
);
|
5994
|
-
|
5995
|
-
|
5996
|
-
|
5997
|
-
|
5987
|
+
if (clonedGeometry.index) {
|
5988
|
+
geometries.push(clonedGeometry.toNonIndexed());
|
5989
|
+
} else {
|
5990
|
+
geometries.push(clonedGeometry);
|
5998
5991
|
}
|
5999
5992
|
}
|
6000
|
-
if (clonedGeometry.index) {
|
6001
|
-
geometries.push(clonedGeometry.toNonIndexed());
|
6002
|
-
} else {
|
6003
|
-
geometries.push(clonedGeometry);
|
6004
|
-
}
|
6005
5993
|
}
|
6006
5994
|
});
|
6007
5995
|
const newBufferGeometry = BufferGeometryUtils.mergeGeometries(geometries, false);
|