@mml-io/3d-web-client-core 0.17.0 → 0.18.0

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.
@@ -0,0 +1,7 @@
1
+ export declare class ErrorScreen {
2
+ readonly element: HTMLDivElement;
3
+ private titleBannerText;
4
+ private messageText;
5
+ constructor(title: string, message: string);
6
+ dispose(): void;
7
+ }
package/build/index.d.ts CHANGED
@@ -15,4 +15,5 @@ export { CollisionsManager } from "./collisions/CollisionsManager";
15
15
  export { Sun } from "./sun/Sun";
16
16
  export { GroundPlane } from "./ground-plane/GroundPlane";
17
17
  export { LoadingScreen } from "./loading-screen/LoadingScreen";
18
+ export { ErrorScreen } from "./error-screen/ErrorScreen";
18
19
  export { EnvironmentConfiguration } from "./rendering/composer";
package/build/index.js CHANGED
@@ -239,15 +239,15 @@ var VirtualJoystick = class _VirtualJoystick {
239
239
  var camValues = {
240
240
  initialDistance: 3.3,
241
241
  minDistance: 0.1,
242
- maxDistance: 8,
242
+ maxDistance: 5,
243
243
  initialFOV: 60,
244
- maxFOV: 85,
244
+ maxFOV: 70,
245
245
  minFOV: 60,
246
246
  invertFOVMapping: false,
247
- damping: 0.091,
248
- dampingScale: 0.01,
249
- zoomScale: 0.05,
250
- zoomDamping: 0.3
247
+ damping: 0.15,
248
+ dampingScale: 5e-3,
249
+ zoomScale: 0.088,
250
+ zoomDamping: 0.16
251
251
  };
252
252
  var camOptions = {
253
253
  initialDistance: { min: 1, max: 5, step: 0.1 },
@@ -481,8 +481,9 @@ var CameraManager = class {
481
481
  }
482
482
  }
483
483
  onMouseMove(event) {
484
- if (getTweakpaneActive())
484
+ if (getTweakpaneActive()) {
485
485
  return;
486
+ }
486
487
  if (this.dragging) {
487
488
  if (this.targetTheta === null || this.targetPhi === null)
488
489
  return;
@@ -493,6 +494,9 @@ var CameraManager = class {
493
494
  }
494
495
  }
495
496
  onMouseWheel(event) {
497
+ if (getTweakpaneActive()) {
498
+ return;
499
+ }
496
500
  const scrollAmount = event.deltaY * this.zoomScale * 0.1;
497
501
  this.targetDistance += scrollAmount;
498
502
  this.targetDistance = Math.max(
@@ -934,7 +938,7 @@ var _CharacterModel = class _CharacterModel {
934
938
  this.config.animationConfig.doubleJumpAnimationFileUrl,
935
939
  6 /* doubleJump */,
936
940
  false,
937
- 1.3
941
+ 1.45
938
942
  );
939
943
  this.applyCustomMaterials();
940
944
  }
@@ -1231,7 +1235,7 @@ import {
1231
1235
  } from "three";
1232
1236
 
1233
1237
  // src/character/CanvasText.ts
1234
- import { Texture as Texture2, LinearFilter, RGBAFormat, MeshBasicMaterial } from "three";
1238
+ import { Texture, LinearFilter, RGBAFormat, MeshBasicMaterial } from "three";
1235
1239
  function getTextAlignOffset(textAlign, width) {
1236
1240
  switch (textAlign) {
1237
1241
  case "center":
@@ -1332,7 +1336,7 @@ function CanvasText(message, options) {
1332
1336
  }
1333
1337
  function THREECanvasTextTexture(text, options) {
1334
1338
  const canvas2 = CanvasText(text, options);
1335
- const texture = new Texture2(canvas2);
1339
+ const texture = new Texture(canvas2);
1336
1340
  texture.minFilter = LinearFilter;
1337
1341
  texture.magFilter = LinearFilter;
1338
1342
  texture.format = RGBAFormat;
@@ -1529,7 +1533,7 @@ import { Euler, Line3, Matrix4, Quaternion as Quaternion2, Ray, Raycaster as Ray
1529
1533
 
1530
1534
  // src/tweakpane/blades/characterControlsFolder.ts
1531
1535
  var characterControllerValues = {
1532
- gravity: 28,
1536
+ gravity: 35.5,
1533
1537
  jumpForce: 18,
1534
1538
  doubleJumpForce: 17.7,
1535
1539
  coyoteJump: 120,
@@ -3323,9 +3327,6 @@ var tweakPaneStyle = `
3323
3327
  --tp-label-foreground-color: hsla(0, 0%, 100%, 0.6);
3324
3328
  --tp-monitor-background-color: hsla(0, 0%, 0%, 0.3);
3325
3329
  --tp-monitor-foreground-color: hsla(0, 0%, 100%, 0.3);
3326
- -webkit-user-select: none;
3327
- -ms-user-select: none;
3328
- user-select: none;
3329
3330
  }
3330
3331
 
3331
3332
  .tp-brkv {
@@ -3394,20 +3395,20 @@ var TweakPane = class {
3394
3395
  this.composer = composer;
3395
3396
  this.saveVisibilityInLocalStorage = true;
3396
3397
  this.guiVisible = false;
3397
- const tweakPaneWrapper = document.createElement("div");
3398
- tweakPaneWrapper.style.position = "fixed";
3399
- tweakPaneWrapper.style.width = "400px";
3400
- tweakPaneWrapper.style.height = "100%";
3401
- tweakPaneWrapper.style.top = "0px";
3402
- tweakPaneWrapper.style.right = "calc(-50vw)";
3403
- tweakPaneWrapper.style.zIndex = "99";
3404
- tweakPaneWrapper.style.overflow = "auto";
3405
- tweakPaneWrapper.style.backgroundColor = "rgba(0, 0, 0, 0.66)";
3406
- tweakPaneWrapper.style.paddingLeft = "5px";
3407
- tweakPaneWrapper.style.boxShadow = "-7px 0px 12px rgba(0, 0, 0, 0.5)";
3408
- tweakPaneWrapper.style.transition = "right cubic-bezier(0.83, 0, 0.17, 1) 0.7s";
3409
- holderElement.appendChild(tweakPaneWrapper);
3410
- this.gui = new Pane({ container: tweakPaneWrapper });
3398
+ this.tweakPaneWrapper = document.createElement("div");
3399
+ this.tweakPaneWrapper.style.position = "fixed";
3400
+ this.tweakPaneWrapper.style.width = "400px";
3401
+ this.tweakPaneWrapper.style.height = "100%";
3402
+ this.tweakPaneWrapper.style.top = "0px";
3403
+ this.tweakPaneWrapper.style.right = "calc(-50vw)";
3404
+ this.tweakPaneWrapper.style.zIndex = "99";
3405
+ this.tweakPaneWrapper.style.overflow = "auto";
3406
+ this.tweakPaneWrapper.style.backgroundColor = "rgba(0, 0, 0, 0.66)";
3407
+ this.tweakPaneWrapper.style.paddingLeft = "5px";
3408
+ this.tweakPaneWrapper.style.boxShadow = "-7px 0px 12px rgba(0, 0, 0, 0.5)";
3409
+ this.tweakPaneWrapper.style.transition = "right cubic-bezier(0.83, 0, 0.17, 1) 0.7s";
3410
+ holderElement.appendChild(this.tweakPaneWrapper);
3411
+ this.gui = new Pane({ container: this.tweakPaneWrapper });
3411
3412
  this.gui.registerPlugin(EssentialsPlugin);
3412
3413
  if (this.saveVisibilityInLocalStorage) {
3413
3414
  const localStorageGuiVisible = localStorage.getItem("guiVisible");
@@ -3435,19 +3436,20 @@ var TweakPane = class {
3435
3436
  this.characterControls = new CharacterControlsFolder(this.gui, false);
3436
3437
  this.toneMappingFolder.folder.hidden = rendererValues.toneMapping === 5 ? false : true;
3437
3438
  this.export = this.gui.addFolder({ title: "import / export", expanded: false });
3439
+ this.setupGUIListeners();
3438
3440
  window.addEventListener("keydown", (e) => {
3439
3441
  this.processKey(e);
3440
3442
  });
3441
- this.setupGUIListeners();
3442
3443
  }
3443
3444
  setupGUIListeners() {
3444
3445
  const gui = this.gui;
3445
3446
  const paneElement = gui.containerElem_;
3446
3447
  paneElement.style.right = this.guiVisible ? "0px" : "-450px";
3447
3448
  this.gui.element.addEventListener("mouseenter", () => setTweakpaneActive(true));
3449
+ this.gui.element.addEventListener("mousemove", () => setTweakpaneActive(true));
3448
3450
  this.gui.element.addEventListener("mousedown", () => setTweakpaneActive(true));
3449
- this.gui.element.addEventListener("mouseup", () => setTweakpaneActive(false));
3450
3451
  this.gui.element.addEventListener("mouseleave", () => setTweakpaneActive(false));
3452
+ this.gui.element.addEventListener("mouseup", () => setTweakpaneActive(false));
3451
3453
  }
3452
3454
  processKey(e) {
3453
3455
  if (e.key === "p")
@@ -3484,6 +3486,10 @@ var TweakPane = class {
3484
3486
  });
3485
3487
  });
3486
3488
  }
3489
+ dispose() {
3490
+ this.gui.dispose();
3491
+ this.tweakPaneWrapper.remove();
3492
+ }
3487
3493
  setupCamPane(cameraManager) {
3488
3494
  this.camera.setupChangeEvent(cameraManager);
3489
3495
  }
@@ -5292,6 +5298,7 @@ var Composer = class {
5292
5298
  }
5293
5299
  dispose() {
5294
5300
  window.removeEventListener("resize", this.resizeListener);
5301
+ this.renderer.dispose();
5295
5302
  }
5296
5303
  fitContainer() {
5297
5304
  if (!this) {
@@ -5514,8 +5521,8 @@ var Composer = class {
5514
5521
  var _a, _b;
5515
5522
  if (typeof ((_b = (_a = this.environmentConfiguration) == null ? void 0 : _a.ambientLight) == null ? void 0 : _b.intensity) === "number") {
5516
5523
  envValues.ambientLight.ambientLightIntensity = this.environmentConfiguration.ambientLight.intensity;
5517
- this.setAmbientLight();
5518
5524
  }
5525
+ this.setAmbientLight();
5519
5526
  }
5520
5527
  };
5521
5528
 
@@ -5804,13 +5811,13 @@ var CollisionsManager = class {
5804
5811
  // src/ground-plane/GroundPlane.ts
5805
5812
  import {
5806
5813
  CanvasTexture,
5807
- CircleGeometry as CircleGeometry2,
5808
5814
  FrontSide as FrontSide2,
5809
5815
  Group as Group6,
5810
5816
  LinearMipMapLinearFilter,
5811
5817
  Mesh as Mesh6,
5812
5818
  MeshStandardMaterial as MeshStandardMaterial3,
5813
5819
  NearestFilter as NearestFilter2,
5820
+ PlaneGeometry as PlaneGeometry2,
5814
5821
  RepeatWrapping as RepeatWrapping2
5815
5822
  } from "three";
5816
5823
  var canvas = document.createElement("canvas");
@@ -5827,7 +5834,7 @@ var GroundPlane = class extends Group6 {
5827
5834
  super();
5828
5835
  this.floorSize = 210;
5829
5836
  this.floorTexture = null;
5830
- this.floorGeometry = new CircleGeometry2(this.floorSize, this.floorSize);
5837
+ this.floorGeometry = new PlaneGeometry2(this.floorSize, this.floorSize, 1, 1);
5831
5838
  this.floorMesh = null;
5832
5839
  this.floorMaterial = new MeshStandardMaterial3({
5833
5840
  color: 16777215,
@@ -5856,6 +5863,7 @@ var LoadingScreen = class {
5856
5863
  constructor(loadingProgressManager) {
5857
5864
  this.loadingProgressManager = loadingProgressManager;
5858
5865
  this.hasCompleted = false;
5866
+ this.disposed = false;
5859
5867
  this.element = document.createElement("div");
5860
5868
  this.element.style.position = "absolute";
5861
5869
  this.element.style.top = "0";
@@ -5990,10 +5998,47 @@ var LoadingScreen = class {
5990
5998
  this.loadingProgressManager.addProgressCallback(this.loadingCallback);
5991
5999
  }
5992
6000
  dispose() {
6001
+ if (this.disposed) {
6002
+ return;
6003
+ }
6004
+ this.disposed = true;
5993
6005
  this.loadingProgressManager.removeProgressCallback(this.loadingCallback);
5994
6006
  this.element.remove();
5995
6007
  }
5996
6008
  };
6009
+
6010
+ // src/error-screen/ErrorScreen.ts
6011
+ var ErrorScreen = class {
6012
+ constructor(title, message) {
6013
+ this.element = document.createElement("div");
6014
+ this.element.style.position = "absolute";
6015
+ this.element.style.top = "0";
6016
+ this.element.style.left = "0";
6017
+ this.element.style.display = "flex";
6018
+ this.element.style.alignItems = "center";
6019
+ this.element.style.justifyContent = "center";
6020
+ this.element.style.flexDirection = "column";
6021
+ this.element.style.width = "100%";
6022
+ this.element.style.height = "100%";
6023
+ this.element.style.background = "linear-gradient(45deg, #111111 0%, #444444 100%)";
6024
+ this.element.style.color = "white";
6025
+ this.titleBannerText = document.createElement("div");
6026
+ this.titleBannerText.textContent = title;
6027
+ this.titleBannerText.style.fontSize = "40px";
6028
+ this.titleBannerText.style.fontWeight = "bold";
6029
+ this.titleBannerText.style.fontFamily = "sans-serif";
6030
+ this.element.append(this.titleBannerText);
6031
+ this.messageText = document.createElement("div");
6032
+ this.messageText.style.textAlign = "center";
6033
+ this.messageText.style.fontFamily = "sans-serif";
6034
+ this.messageText.style.fontWeight = "bold";
6035
+ this.messageText.textContent = message;
6036
+ this.element.append(this.messageText);
6037
+ }
6038
+ dispose() {
6039
+ this.element.remove();
6040
+ }
6041
+ };
5997
6042
  export {
5998
6043
  AnimationState,
5999
6044
  CameraManager,
@@ -6001,6 +6046,7 @@ export {
6001
6046
  CharacterModelLoader,
6002
6047
  CollisionsManager,
6003
6048
  Composer,
6049
+ ErrorScreen,
6004
6050
  GroundPlane,
6005
6051
  KeyInputManager,
6006
6052
  LoadingScreen,