@mml-io/3d-web-client-core 0.0.0-experimental-8634a66-20240605 → 0.0.0-experimental-27180bc-20240609

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
@@ -2615,11 +2615,11 @@ var sunOptions = {
2615
2615
  sunIntensity: { min: 0, max: 10, step: 0.1 }
2616
2616
  };
2617
2617
  var envValues = {
2618
- hdrAzimuthalAngle: 0,
2619
- hdrPolarAngle: 0,
2620
- hdrEnvIntensity: 0.07,
2621
- hdrIntensity: 0.8,
2622
- hdrBlurriness: 0,
2618
+ skyboxAzimuthalAngle: 0,
2619
+ skyboxPolarAngle: 0,
2620
+ envMapIntensity: 0.07,
2621
+ skyboxIntensity: 0.8,
2622
+ skyboxBlurriness: 0,
2623
2623
  ambientLight: {
2624
2624
  ambientLightIntensity: 0.27,
2625
2625
  ambientLightColor: { r: 1, g: 1, b: 1 }
@@ -2631,10 +2631,10 @@ var envValues = {
2631
2631
  }
2632
2632
  };
2633
2633
  var envOptions = {
2634
- hdrAzimuthalAngle: { min: 0, max: 360, step: 1 },
2635
- hdrPolarAngle: { min: 0, max: 360, step: 1 },
2636
- hdrIntensity: { min: 0, max: 1.3, step: 0.01 },
2637
- hdrBlurriness: { min: 0, max: 0.1, step: 1e-3 },
2634
+ skyboxAzimuthalAngle: { min: 0, max: 360, step: 1 },
2635
+ skyboxPolarAngle: { min: 0, max: 360, step: 1 },
2636
+ skyboxIntensity: { min: 0, max: 1.3, step: 0.01 },
2637
+ skyboxBlurriness: { min: 0, max: 0.1, step: 1e-3 },
2638
2638
  ambientLight: {
2639
2639
  ambientLightIntensity: { min: 0, max: 1, step: 0.01 }
2640
2640
  },
@@ -2647,6 +2647,9 @@ var EnvironmentFolder = class {
2647
2647
  constructor(parentFolder, expand = false) {
2648
2648
  this.folder = parentFolder.addFolder({ title: "environment", expanded: expand });
2649
2649
  this.sun = this.folder.addFolder({ title: "sun", expanded: true });
2650
+ this.envMap = this.folder.addFolder({ title: "envMap", expanded: true });
2651
+ this.fog = this.folder.addFolder({ title: "fog", expanded: true });
2652
+ this.skybox = this.folder.addFolder({ title: "skybox", expanded: true });
2650
2653
  this.ambient = this.folder.addFolder({ title: "ambient", expanded: true });
2651
2654
  this.sun.addBinding(
2652
2655
  sunValues.sunPosition,
@@ -2662,11 +2665,12 @@ var EnvironmentFolder = class {
2662
2665
  this.sun.addBinding(sunValues, "sunColor", {
2663
2666
  color: { type: "float" }
2664
2667
  });
2665
- this.hdrButton = this.ambient.addButton({ title: "Set HDRI" });
2666
- this.ambient.addBinding(envValues, "hdrIntensity", envOptions.hdrIntensity);
2667
- this.ambient.addBinding(envValues, "hdrBlurriness", envOptions.hdrBlurriness);
2668
- this.ambient.addBinding(envValues, "hdrAzimuthalAngle", envOptions.hdrAzimuthalAngle);
2669
- this.ambient.addBinding(envValues, "hdrPolarAngle", envOptions.hdrPolarAngle);
2668
+ this.hdrButton = this.skybox.addButton({ title: "Set HDRI" });
2669
+ this.skybox.addBinding(envValues, "skyboxIntensity", envOptions.skyboxIntensity);
2670
+ this.skybox.addBinding(envValues, "skyboxBlurriness", envOptions.skyboxBlurriness);
2671
+ this.skybox.addBinding(envValues, "skyboxAzimuthalAngle", envOptions.skyboxAzimuthalAngle);
2672
+ this.skybox.addBinding(envValues, "skyboxPolarAngle", envOptions.skyboxPolarAngle);
2673
+ this.envMap.addBinding(envValues, "envMapIntensity", envOptions.skyboxIntensity);
2670
2674
  this.ambient.addBinding(
2671
2675
  envValues.ambientLight,
2672
2676
  "ambientLightIntensity",
@@ -2675,13 +2679,13 @@ var EnvironmentFolder = class {
2675
2679
  this.ambient.addBinding(envValues.ambientLight, "ambientLightColor", {
2676
2680
  color: { type: "float" }
2677
2681
  });
2678
- this.ambient.addBinding(envValues.fog, "fogNear", envOptions.fog.fogNear);
2679
- this.ambient.addBinding(envValues.fog, "fogFar", envOptions.fog.fogFar);
2680
- this.ambient.addBinding(envValues.fog, "fogColor", {
2682
+ this.fog.addBinding(envValues.fog, "fogNear", envOptions.fog.fogNear);
2683
+ this.fog.addBinding(envValues.fog, "fogFar", envOptions.fog.fogFar);
2684
+ this.fog.addBinding(envValues.fog, "fogColor", {
2681
2685
  color: { type: "float" }
2682
2686
  });
2683
2687
  }
2684
- setupChangeEvent(scene, setHDR, setHDRAzimuthalAngle, setHDRPolarAngle, setAmbientLight, setFog, sun) {
2688
+ setupChangeEvent(scene, setHDR, setSkyboxAzimuthalAngle, setSkyboxPolarAngle, setAmbientLight, setFog, sun) {
2685
2689
  this.sun.on("change", (e) => {
2686
2690
  const target = e.target.key;
2687
2691
  if (!target)
@@ -2719,27 +2723,45 @@ var EnvironmentFolder = class {
2719
2723
  this.hdrButton.on("click", () => {
2720
2724
  setHDR();
2721
2725
  });
2722
- this.ambient.on("change", (e) => {
2726
+ this.envMap.on("change", (e) => {
2727
+ const target = e.target.key;
2728
+ if (!target)
2729
+ return;
2730
+ switch (target) {
2731
+ case "envMapIntensity":
2732
+ scene.environmentIntensity = e.value;
2733
+ break;
2734
+ }
2735
+ });
2736
+ this.skybox.on("change", (e) => {
2723
2737
  const target = e.target.key;
2724
2738
  if (!target)
2725
2739
  return;
2726
2740
  switch (target) {
2727
- case "hdrAzimuthalAngle": {
2741
+ case "skyboxAzimuthalAngle": {
2728
2742
  const value = e.value;
2729
- setHDRAzimuthalAngle(value);
2743
+ setSkyboxAzimuthalAngle(value);
2730
2744
  break;
2731
2745
  }
2732
- case "hdrPolarAngle": {
2746
+ case "skyboxPolarAngle": {
2733
2747
  const value = e.value;
2734
- setHDRPolarAngle(value);
2748
+ envValues.skyboxPolarAngle = value;
2749
+ setSkyboxPolarAngle(value);
2735
2750
  break;
2736
2751
  }
2737
- case "hdrIntensity":
2752
+ case "skyboxIntensity":
2738
2753
  scene.backgroundIntensity = e.value;
2739
2754
  break;
2740
- case "hdrBlurriness":
2755
+ case "skyboxBlurriness":
2741
2756
  scene.backgroundBlurriness = e.value;
2742
2757
  break;
2758
+ }
2759
+ });
2760
+ this.ambient.on("change", (e) => {
2761
+ const target = e.target.key;
2762
+ if (!target)
2763
+ return;
2764
+ switch (target) {
2743
2765
  case "ambientLightIntensity": {
2744
2766
  envValues.ambientLight.ambientLightIntensity = e.value;
2745
2767
  setAmbientLight();
@@ -2755,6 +2777,13 @@ var EnvironmentFolder = class {
2755
2777
  setAmbientLight();
2756
2778
  break;
2757
2779
  }
2780
+ }
2781
+ });
2782
+ this.fog.on("change", (e) => {
2783
+ const target = e.target.key;
2784
+ if (!target)
2785
+ return;
2786
+ switch (target) {
2758
2787
  case "fogNear": {
2759
2788
  envValues.fog.fogNear = e.value;
2760
2789
  setFog();
@@ -2775,8 +2804,6 @@ var EnvironmentFolder = class {
2775
2804
  setFog();
2776
2805
  break;
2777
2806
  }
2778
- default:
2779
- break;
2780
2807
  }
2781
2808
  });
2782
2809
  }
@@ -3405,9 +3432,10 @@ var TweakPane = class {
3405
3432
  this.characterControls = new CharacterControlsFolder(this.gui, false);
3406
3433
  this.toneMappingFolder.folder.hidden = rendererValues.toneMapping === 5 ? false : true;
3407
3434
  this.export = this.gui.addFolder({ title: "import / export", expanded: false });
3408
- window.addEventListener("keydown", this.processKey.bind(this));
3409
- this.setupRenderPane = this.setupRenderPane.bind(this);
3410
- this.setupGUIListeners.bind(this)();
3435
+ window.addEventListener("keydown", (e) => {
3436
+ this.processKey(e);
3437
+ });
3438
+ this.setupGUIListeners();
3411
3439
  }
3412
3440
  setupGUIListeners() {
3413
3441
  const gui = this.gui;
@@ -3422,7 +3450,7 @@ var TweakPane = class {
3422
3450
  if (e.key === "p")
3423
3451
  this.toggleGUI();
3424
3452
  }
3425
- setupRenderPane(composer, normalPass, ppssaoEffect, ppssaoPass, n8aopass, toneMappingEffect, toneMappingPass, brightnessContrastSaturation, bloomEffect, gaussGrainEffect, hasLighting, sun, setHDR, setHDRAzimuthalAngle, setHDRPolarAngle, setAmbientLight, setFog) {
3453
+ setupRenderPane(composer, normalPass, ppssaoEffect, ppssaoPass, n8aopass, toneMappingEffect, toneMappingPass, brightnessContrastSaturation, bloomEffect, gaussGrainEffect, hasLighting, sun, setHDR, setSkyboxAzimuthalAngle, setSkyboxPolarAngle, setAmbientLight, setFog) {
3426
3454
  this.rendererFolder.setupChangeEvent(
3427
3455
  this.renderer,
3428
3456
  this.toneMappingFolder.folder,
@@ -3435,8 +3463,8 @@ var TweakPane = class {
3435
3463
  this.environment.setupChangeEvent(
3436
3464
  this.scene,
3437
3465
  setHDR,
3438
- setHDRAzimuthalAngle,
3439
- setHDRPolarAngle,
3466
+ setSkyboxAzimuthalAngle,
3467
+ setSkyboxPolarAngle,
3440
3468
  setAmbientLight,
3441
3469
  setFog,
3442
3470
  sun
@@ -5129,7 +5157,7 @@ var Composer = class {
5129
5157
  this.renderer.toneMapping = rendererValues.toneMapping;
5130
5158
  this.renderer.toneMappingExposure = rendererValues.exposure;
5131
5159
  this.environmentConfiguration = environmentConfiguration;
5132
- this.updateHDRValues();
5160
+ this.updateSkyboxAndEnvValues();
5133
5161
  this.updateAmbientLightValues();
5134
5162
  this.setFog();
5135
5163
  this.effectComposer = new EffectComposer2(this.renderer, {
@@ -5247,8 +5275,14 @@ var Composer = class {
5247
5275
  this.spawnSun,
5248
5276
  this.sun,
5249
5277
  this.setHDRIFromFile.bind(this),
5250
- this.setHDRAzimuthalAngle.bind(this),
5251
- this.setHDRPolarAngle.bind(this),
5278
+ (azimuthalAngle) => {
5279
+ envValues.skyboxAzimuthalAngle = azimuthalAngle;
5280
+ this.updateSkyboxRotation();
5281
+ },
5282
+ (polarAngle) => {
5283
+ envValues.skyboxPolarAngle = polarAngle;
5284
+ this.updateSkyboxRotation();
5285
+ },
5252
5286
  this.setAmbientLight.bind(this),
5253
5287
  this.setFog.bind(this)
5254
5288
  );
@@ -5303,17 +5337,15 @@ var Composer = class {
5303
5337
  this.renderer.clearDepth();
5304
5338
  this.renderer.render(this.postPostScene, this.camera);
5305
5339
  }
5306
- setHDRAzimuthalAngle(azimuthalAngle) {
5340
+ updateSkyboxRotation() {
5307
5341
  this.scene.backgroundRotation = new Euler3(
5308
- MathUtils.degToRad(envValues.hdrPolarAngle),
5309
- MathUtils.degToRad(azimuthalAngle),
5342
+ MathUtils.degToRad(envValues.skyboxPolarAngle),
5343
+ MathUtils.degToRad(envValues.skyboxAzimuthalAngle),
5310
5344
  0
5311
5345
  );
5312
- }
5313
- setHDRPolarAngle(polarAngle) {
5314
- this.scene.backgroundRotation = new Euler3(
5315
- MathUtils.degToRad(polarAngle),
5316
- MathUtils.degToRad(envValues.hdrAzimuthalAngle),
5346
+ this.scene.environmentRotation = new Euler3(
5347
+ MathUtils.degToRad(envValues.skyboxPolarAngle),
5348
+ MathUtils.degToRad(envValues.skyboxAzimuthalAngle),
5317
5349
  0
5318
5350
  );
5319
5351
  }
@@ -5328,18 +5360,18 @@ var Composer = class {
5328
5360
  envMap.colorSpace = LinearSRGBColorSpace;
5329
5361
  envMap.needsUpdate = true;
5330
5362
  this.scene.environment = envMap;
5331
- this.scene.environmentIntensity = envValues.hdrEnvIntensity;
5363
+ this.scene.environmentIntensity = envValues.envMapIntensity;
5332
5364
  this.scene.environmentRotation = new Euler3(
5333
- MathUtils.degToRad(envValues.hdrPolarAngle),
5334
- MathUtils.degToRad(envValues.hdrAzimuthalAngle),
5365
+ MathUtils.degToRad(envValues.skyboxPolarAngle),
5366
+ MathUtils.degToRad(envValues.skyboxAzimuthalAngle),
5335
5367
  0
5336
5368
  );
5337
5369
  this.scene.background = envMap;
5338
- this.scene.backgroundIntensity = envValues.hdrIntensity;
5339
- this.scene.backgroundBlurriness = envValues.hdrBlurriness;
5370
+ this.scene.backgroundIntensity = envValues.skyboxIntensity;
5371
+ this.scene.backgroundBlurriness = envValues.skyboxBlurriness;
5340
5372
  this.scene.backgroundRotation = new Euler3(
5341
- MathUtils.degToRad(envValues.hdrPolarAngle),
5342
- MathUtils.degToRad(envValues.hdrAzimuthalAngle),
5373
+ MathUtils.degToRad(envValues.skyboxPolarAngle),
5374
+ MathUtils.degToRad(envValues.skyboxAzimuthalAngle),
5343
5375
  0
5344
5376
  );
5345
5377
  this.isEnvHDRI = true;
@@ -5350,8 +5382,9 @@ var Composer = class {
5350
5382
  });
5351
5383
  }
5352
5384
  useHDRI(url, fromFile = false) {
5353
- if (this.isEnvHDRI && fromFile === false || !this.renderer)
5385
+ if (this.isEnvHDRI && fromFile === false || !this.renderer) {
5354
5386
  return;
5387
+ }
5355
5388
  const pmremGenerator = new PMREMGenerator(this.renderer);
5356
5389
  new RGBELoader(new LoadingManager()).load(
5357
5390
  url,
@@ -5361,15 +5394,15 @@ var Composer = class {
5361
5394
  envMap.colorSpace = LinearSRGBColorSpace;
5362
5395
  envMap.needsUpdate = true;
5363
5396
  this.scene.environment = envMap;
5364
- this.scene.environmentIntensity = envValues.hdrEnvIntensity;
5397
+ this.scene.environmentIntensity = envValues.envMapIntensity;
5365
5398
  this.scene.environmentRotation = new Euler3(
5366
- MathUtils.degToRad(envValues.hdrPolarAngle),
5367
- MathUtils.degToRad(envValues.hdrAzimuthalAngle),
5399
+ MathUtils.degToRad(envValues.skyboxPolarAngle),
5400
+ MathUtils.degToRad(envValues.skyboxAzimuthalAngle),
5368
5401
  0
5369
5402
  );
5370
5403
  this.scene.background = envMap;
5371
- this.scene.backgroundIntensity = envValues.hdrIntensity;
5372
- this.scene.backgroundBlurriness = envValues.hdrBlurriness;
5404
+ this.scene.backgroundIntensity = envValues.skyboxIntensity;
5405
+ this.scene.backgroundBlurriness = envValues.skyboxBlurriness;
5373
5406
  this.isEnvHDRI = true;
5374
5407
  texture.dispose();
5375
5408
  pmremGenerator.dispose();
@@ -5451,27 +5484,27 @@ var Composer = class {
5451
5484
  (_i = this.sun) == null ? void 0 : _i.setPolarAngle(this.environmentConfiguration.sun.polarAngle);
5452
5485
  }
5453
5486
  }
5454
- updateHDRValues() {
5455
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
5456
- if (typeof ((_b = (_a = this.environmentConfiguration) == null ? void 0 : _a.skybox) == null ? void 0 : _b.intensity) === "number") {
5457
- envValues.hdrIntensity = (_c = this.environmentConfiguration) == null ? void 0 : _c.skybox.intensity;
5487
+ updateSkyboxAndEnvValues() {
5488
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
5489
+ if (typeof ((_b = (_a = this.environmentConfiguration) == null ? void 0 : _a.envMap) == null ? void 0 : _b.intensity) === "number") {
5490
+ envValues.envMapIntensity = (_c = this.environmentConfiguration) == null ? void 0 : _c.envMap.intensity;
5458
5491
  }
5459
- this.scene.backgroundIntensity = envValues.hdrIntensity;
5460
- if (typeof ((_e = (_d = this.environmentConfiguration) == null ? void 0 : _d.envMap) == null ? void 0 : _e.intensity) === "number") {
5461
- envValues.hdrEnvIntensity = (_f = this.environmentConfiguration) == null ? void 0 : _f.envMap.intensity;
5492
+ this.scene.environmentIntensity = envValues.envMapIntensity;
5493
+ if (typeof ((_e = (_d = this.environmentConfiguration) == null ? void 0 : _d.skybox) == null ? void 0 : _e.intensity) === "number") {
5494
+ envValues.skyboxIntensity = (_f = this.environmentConfiguration) == null ? void 0 : _f.skybox.intensity;
5462
5495
  }
5463
- this.scene.backgroundIntensity = envValues.hdrEnvIntensity;
5496
+ this.scene.backgroundIntensity = envValues.skyboxIntensity;
5464
5497
  if (typeof ((_h = (_g = this.environmentConfiguration) == null ? void 0 : _g.skybox) == null ? void 0 : _h.blurriness) === "number") {
5465
- envValues.hdrBlurriness = (_i = this.environmentConfiguration) == null ? void 0 : _i.skybox.blurriness;
5498
+ envValues.skyboxBlurriness = (_i = this.environmentConfiguration) == null ? void 0 : _i.skybox.blurriness;
5466
5499
  }
5467
- this.scene.backgroundBlurriness = envValues.hdrBlurriness;
5500
+ this.scene.backgroundBlurriness = envValues.skyboxBlurriness;
5468
5501
  if (typeof ((_k = (_j = this.environmentConfiguration) == null ? void 0 : _j.skybox) == null ? void 0 : _k.azimuthalAngle) === "number") {
5469
- envValues.hdrAzimuthalAngle = (_l = this.environmentConfiguration) == null ? void 0 : _l.skybox.azimuthalAngle;
5470
- this.setHDRAzimuthalAngle((_m = this.environmentConfiguration) == null ? void 0 : _m.skybox.azimuthalAngle);
5502
+ envValues.skyboxAzimuthalAngle = (_l = this.environmentConfiguration) == null ? void 0 : _l.skybox.azimuthalAngle;
5503
+ this.updateSkyboxRotation();
5471
5504
  }
5472
- if (typeof ((_o = (_n = this.environmentConfiguration) == null ? void 0 : _n.skybox) == null ? void 0 : _o.polarAngle) === "number") {
5473
- envValues.hdrPolarAngle = (_p = this.environmentConfiguration) == null ? void 0 : _p.skybox.polarAngle;
5474
- this.setHDRPolarAngle((_q = this.environmentConfiguration) == null ? void 0 : _q.skybox.polarAngle);
5505
+ if (typeof ((_n = (_m = this.environmentConfiguration) == null ? void 0 : _m.skybox) == null ? void 0 : _n.polarAngle) === "number") {
5506
+ envValues.skyboxPolarAngle = (_o = this.environmentConfiguration) == null ? void 0 : _o.skybox.polarAngle;
5507
+ this.updateSkyboxRotation();
5475
5508
  }
5476
5509
  }
5477
5510
  updateAmbientLightValues() {