@babylonjs-toolkit/next 9.34.10 → 9.35.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.
Files changed (109) hide show
  1. package/lib/index.d.ts +80 -14
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js +80 -14
  4. package/lib/leaderboardaroundpage.d.ts +5 -0
  5. package/lib/leaderboardaroundpage.d.ts.map +1 -0
  6. package/lib/leaderboardaroundpage.js +1 -0
  7. package/lib/leaderboardcallresult.d.ts +13 -0
  8. package/lib/leaderboardcallresult.d.ts.map +1 -0
  9. package/lib/leaderboardcallresult.js +1 -0
  10. package/lib/leaderboardclient.d.ts +95 -0
  11. package/lib/leaderboardclient.d.ts.map +1 -0
  12. package/lib/leaderboardclient.js +448 -0
  13. package/lib/leaderboardclientoptions.d.ts +12 -0
  14. package/lib/leaderboardclientoptions.d.ts.map +1 -0
  15. package/lib/leaderboardclientoptions.js +1 -0
  16. package/lib/leaderboardentriespage.d.ts +10 -0
  17. package/lib/leaderboardentriespage.d.ts.map +1 -0
  18. package/lib/leaderboardentriespage.js +1 -0
  19. package/lib/leaderboardentryview.d.ts +14 -0
  20. package/lib/leaderboardentryview.d.ts.map +1 -0
  21. package/lib/leaderboardentryview.js +1 -0
  22. package/lib/leaderboarderrorbody.d.ts +6 -0
  23. package/lib/leaderboarderrorbody.d.ts.map +1 -0
  24. package/lib/leaderboarderrorbody.js +1 -0
  25. package/lib/leaderboardfetch.d.ts +2 -0
  26. package/lib/leaderboardfetch.d.ts.map +1 -0
  27. package/lib/leaderboardfetch.js +1 -0
  28. package/lib/leaderboardkeeppolicy.d.ts +2 -0
  29. package/lib/leaderboardkeeppolicy.d.ts.map +1 -0
  30. package/lib/leaderboardkeeppolicy.js +1 -0
  31. package/lib/leaderboardmetadata.d.ts +5 -0
  32. package/lib/leaderboardmetadata.d.ts.map +1 -0
  33. package/lib/leaderboardmetadata.js +1 -0
  34. package/lib/leaderboardmetadatavalue.d.ts +4 -0
  35. package/lib/leaderboardmetadatavalue.d.ts.map +1 -0
  36. package/lib/leaderboardmetadatavalue.js +1 -0
  37. package/lib/leaderboardplayersession.d.ts +6 -0
  38. package/lib/leaderboardplayersession.d.ts.map +1 -0
  39. package/lib/leaderboardplayersession.js +1 -0
  40. package/lib/leaderboardplayerview.d.ts +7 -0
  41. package/lib/leaderboardplayerview.d.ts.map +1 -0
  42. package/lib/leaderboardplayerview.js +1 -0
  43. package/lib/leaderboardpostattempt.d.ts +6 -0
  44. package/lib/leaderboardpostattempt.d.ts.map +1 -0
  45. package/lib/leaderboardpostattempt.js +1 -0
  46. package/lib/leaderboardpublicboardview.d.ts +17 -0
  47. package/lib/leaderboardpublicboardview.d.ts.map +1 -0
  48. package/lib/leaderboardpublicboardview.js +1 -0
  49. package/lib/leaderboardrangequery.d.ts +7 -0
  50. package/lib/leaderboardrangequery.d.ts.map +1 -0
  51. package/lib/leaderboardrangequery.js +1 -0
  52. package/lib/leaderboardrefusalreason.d.ts +2 -0
  53. package/lib/leaderboardrefusalreason.d.ts.map +1 -0
  54. package/lib/leaderboardrefusalreason.js +1 -0
  55. package/lib/leaderboardscoreformat.d.ts +2 -0
  56. package/lib/leaderboardscoreformat.d.ts.map +1 -0
  57. package/lib/leaderboardscoreformat.js +1 -0
  58. package/lib/leaderboardscoreresult.d.ts +18 -0
  59. package/lib/leaderboardscoreresult.d.ts.map +1 -0
  60. package/lib/leaderboardscoreresult.js +1 -0
  61. package/lib/leaderboardscoresubmission.d.ts +8 -0
  62. package/lib/leaderboardscoresubmission.d.ts.map +1 -0
  63. package/lib/leaderboardscoresubmission.js +1 -0
  64. package/lib/leaderboardseasonview.d.ts +7 -0
  65. package/lib/leaderboardseasonview.d.ts.map +1 -0
  66. package/lib/leaderboardseasonview.js +1 -0
  67. package/lib/leaderboardsortorder.d.ts +2 -0
  68. package/lib/leaderboardsortorder.d.ts.map +1 -0
  69. package/lib/leaderboardsortorder.js +1 -0
  70. package/lib/leaderboardstorage.d.ts +6 -0
  71. package/lib/leaderboardstorage.d.ts.map +1 -0
  72. package/lib/leaderboardstorage.js +1 -0
  73. package/lib/leaderboardstoredplayer.d.ts +5 -0
  74. package/lib/leaderboardstoredplayer.d.ts.map +1 -0
  75. package/lib/leaderboardstoredplayer.js +1 -0
  76. package/lib/leaderboardsubmission.d.ts +8 -0
  77. package/lib/leaderboardsubmission.d.ts.map +1 -0
  78. package/lib/leaderboardsubmission.js +1 -0
  79. package/lib/leaderboardsubmissionrequest.d.ts +12 -0
  80. package/lib/leaderboardsubmissionrequest.d.ts.map +1 -0
  81. package/lib/leaderboardsubmissionrequest.js +1 -0
  82. package/lib/leaderboardsubmissionresponse.d.ts +7 -0
  83. package/lib/leaderboardsubmissionresponse.d.ts.map +1 -0
  84. package/lib/leaderboardsubmissionresponse.js +1 -0
  85. package/lib/leaderboardsubmitresult.d.ts +15 -0
  86. package/lib/leaderboardsubmitresult.d.ts.map +1 -0
  87. package/lib/leaderboardsubmitresult.js +1 -0
  88. package/lib/leaderboardtarget.d.ts +6 -0
  89. package/lib/leaderboardtarget.d.ts.map +1 -0
  90. package/lib/leaderboardtarget.js +1 -0
  91. package/lib/leaderboardtargetentry.d.ts +9 -0
  92. package/lib/leaderboardtargetentry.d.ts.map +1 -0
  93. package/lib/leaderboardtargetentry.js +1 -0
  94. package/lib/leaderboardtrustlevel.d.ts +2 -0
  95. package/lib/leaderboardtrustlevel.d.ts.map +1 -0
  96. package/lib/leaderboardtrustlevel.js +1 -0
  97. package/lib/leaderboardvariantdimension.d.ts +6 -0
  98. package/lib/leaderboardvariantdimension.d.ts.map +1 -0
  99. package/lib/leaderboardvariantdimension.js +1 -0
  100. package/lib/leaderboardwriteoutcome.d.ts +2 -0
  101. package/lib/leaderboardwriteoutcome.d.ts.map +1 -0
  102. package/lib/leaderboardwriteoutcome.js +1 -0
  103. package/lib/project.d.ts +16 -732
  104. package/lib/project.d.ts.map +1 -1
  105. package/lib/project.js +76 -3226
  106. package/lib/scenemanager.d.ts +424 -6
  107. package/lib/scenemanager.d.ts.map +1 -1
  108. package/lib/scenemanager.js +2633 -258
  109. package/package.json +17 -13
package/lib/project.js CHANGED
@@ -5,13 +5,12 @@ const TOOLKIT = (typeof window !== "undefined" && window.TOOLKIT) || _ToolkitRef
5
5
  if (typeof window !== "undefined" && !window.PROJECT)
6
6
  window.PROJECT = {};
7
7
  const PROJECT = (typeof window !== "undefined" && window.PROJECT) || {};
8
- import { ScriptComponent, Animator, SceneManager, RigidbodyPhysics, SearchType, AnimatorControllerParameterType, CustomShaderMaterial, AudioSource, Utilities, AudioRolloff, InputController, ShurikenParticles, UserInterface, RaycastVehicle, System, SceneShaderWarmup, PlayerNumber, UserInputKey, WindowManager, UserInputAxis, UserInputOptions, CustomShaderMaterialPlugin } from './scenemanager';
8
+ import { ScriptComponent, Animator, SceneManager, RigidbodyPhysics, SearchType, AnimatorControllerParameterType, CustomShaderMaterial, Utilities, AudioRolloff, InputController, ShurikenParticles, UserInterface, RaycastVehicle, System, SceneShaderWarmup, PlayerNumber, UserInputKey, WindowManager, UserInputAxis, UserInputOptions, CustomShaderMaterialPlugin } from './scenemanager';
9
9
  import { LocalMessageBus } from './localmessagebus';
10
10
  import { SimplexNoise } from './simplexnoise';
11
11
  import { LinesMeshRenderer } from './linesmeshrenderer';
12
12
  import { Xbox360Trigger } from './xbox360trigger';
13
13
  import { TouchJoystickHandler } from './touchjoystickhandler';
14
- import { CollisionFilters } from './collisionfilters';
15
14
  export class KartBumpTarget extends ScriptComponent {
16
15
  constructor(transform, scene, properties = {}, alias = "TOOLKIT.KartBumpTarget") {
17
16
  super(transform, scene, properties, alias);
@@ -40,6 +39,7 @@ export const DRIVER_TURN_LEFT_PARAMETER = "TurnLeft";
40
39
  export const DRIVER_TURN_RIGHT_PARAMETER = "TurnRight";
41
40
  export const DRIVER_HAS_ITEM_PARAMETER = "hasItem";
42
41
  export const DRIVER_REVERSE_PARAMETER = "Reverse";
42
+ export const DRIVER_TRICK_TRIGGERS = ["JumpTrick1", "JumpTrick2", "GliderTrick"];
43
43
  export class KartDriverAnimation {
44
44
  constructor(kartRoot, driverAnimator, headNode) {
45
45
  this.pathError = Number.NaN;
@@ -50,6 +50,7 @@ export class KartDriverAnimation {
50
50
  this.headWrittenRotation = new BABYLON.Quaternion();
51
51
  this.hasWrittenHead = false;
52
52
  this.reverseWritten = false;
53
+ this.trickAnimationIndex = 0;
53
54
  this.lookRotation = new BABYLON.Quaternion();
54
55
  this.localAxis = new BABYLON.Vector3();
55
56
  this.inverseKartMatrix = new BABYLON.Matrix();
@@ -133,6 +134,12 @@ export class KartDriverAnimation {
133
134
  if (receiverCount > 0)
134
135
  this.reverseWritten = reversing;
135
136
  }
137
+ playTrick(animators) {
138
+ const triggerName = DRIVER_TRICK_TRIGGERS[this.trickAnimationIndex];
139
+ KartRigLookup.setTrigger(animators, triggerName);
140
+ this.trickAnimationIndex = (this.trickAnimationIndex + 1) % DRIVER_TRICK_TRIGGERS.length;
141
+ return triggerName;
142
+ }
136
143
  applySteeringWheel(wheel, restRotation) {
137
144
  if (wheel == null)
138
145
  return;
@@ -2261,6 +2268,7 @@ const PLAYER_ENGINE_VOLUME = 0.45;
2261
2268
  const PLAYER_ENGINE_GLIDING_VOLUME = 0.3;
2262
2269
  const OPPONENT_ENGINE_VOLUME = 1;
2263
2270
  const OPPONENT_ENGINE_GLIDING_VOLUME = 0.5;
2271
+ const ENGINE_RACE_END_FADE_PER_SECOND = 0.6;
2264
2272
  const OPPONENT_ENGINE_RECORDED_LEVEL_FACTOR = 0.54;
2265
2273
  const UNITY_LISTENER_BEHIND_METERS = 6.25;
2266
2274
  const UNITY_LISTENER_ABOVE_METERS = 2.3;
@@ -2777,6 +2785,7 @@ export class StandardKartAudio extends ScriptComponent {
2777
2785
  this.voiceSet = "player";
2778
2786
  this.driftAudioEnabled = true;
2779
2787
  this.engineAudioEnabled = true;
2788
+ this.raceCompleted = false;
2780
2789
  this.boostAudioEnabled = true;
2781
2790
  this.hopAudioEnabled = true;
2782
2791
  this.trickAudioEnabled = true;
@@ -2838,6 +2847,7 @@ export class StandardKartAudio extends ScriptComponent {
2838
2847
  this.engineTime = 0;
2839
2848
  this.enginePlayhead = new KartEnginePlayhead();
2840
2849
  this.enginePitch = 1;
2850
+ this.raceEndEngineVolume = null;
2841
2851
  this.idleLevel = 0;
2842
2852
  this.sceneEntryFinished = false;
2843
2853
  this.chargeRetriggerCount = 0;
@@ -3455,6 +3465,7 @@ export class StandardKartAudio extends ScriptComponent {
3455
3465
  }
3456
3466
  const speed = this.kart.getCurrentSpeed();
3457
3467
  const gliding = this.kart.isGliding();
3468
+ const engineLevel = this.stepEngineLevel(gliding, dt);
3458
3469
  this.tickIdleLevel(dt);
3459
3470
  if (this.idleVoice != null)
3460
3471
  this.idleVoice.setVolume(this.masterVolume * this.idleLevel);
@@ -3467,7 +3478,7 @@ export class StandardKartAudio extends ScriptComponent {
3467
3478
  this.idleVoice.stop();
3468
3479
  if (speed >= 5 && gliding !== true) {
3469
3480
  if (this.engineVoice != null && this.engineVoice.isPlaying() !== true && this.isVoiceAllowed("engine") === true) {
3470
- this.engineVoice.setVolume(this.masterVolume * this.engineVolume(gliding));
3481
+ this.engineVoice.setVolume(this.masterVolume * engineLevel);
3471
3482
  this.engineVoice.play();
3472
3483
  this.enginePlayhead.restart();
3473
3484
  }
@@ -3480,7 +3491,7 @@ export class StandardKartAudio extends ScriptComponent {
3480
3491
  this.applyEngineBand(dt, band, rate);
3481
3492
  }
3482
3493
  if (this.engineVoice != null) {
3483
- this.engineVoice.setVolume(this.masterVolume * this.engineVolume(gliding));
3494
+ this.engineVoice.setVolume(this.masterVolume * engineLevel);
3484
3495
  }
3485
3496
  if (speed < 10 && this.engineVoice != null)
3486
3497
  this.engineVoice.stop();
@@ -3580,6 +3591,20 @@ export class StandardKartAudio extends ScriptComponent {
3580
3591
  return (gliding === true) ? OPPONENT_ENGINE_GLIDING_VOLUME : OPPONENT_ENGINE_VOLUME;
3581
3592
  return (gliding === true) ? PLAYER_ENGINE_GLIDING_VOLUME : PLAYER_ENGINE_VOLUME;
3582
3593
  }
3594
+ stepEngineLevel(gliding, deltaSeconds) {
3595
+ if (this.isEngineRaceCompleted() !== true) {
3596
+ this.raceEndEngineVolume = null;
3597
+ return this.engineVolume(gliding);
3598
+ }
3599
+ const fadeStart = this.raceEndEngineVolume ?? this.engineVolume(gliding);
3600
+ this.raceEndEngineVolume = Math.max(0, fadeStart - ENGINE_RACE_END_FADE_PER_SECOND * deltaSeconds);
3601
+ return this.raceEndEngineVolume;
3602
+ }
3603
+ isEngineRaceCompleted() {
3604
+ if (this.raceCompleted === true)
3605
+ return true;
3606
+ return typeof this.kart.isRaceCompleted === "function" && this.kart.isRaceCompleted() === true;
3607
+ }
3583
3608
  applyVoiceSetSpatial() {
3584
3609
  const isOpponent = (this.voiceSet === "opponent");
3585
3610
  this.applySpatialRole(this.engineVoice, isOpponent ? OPPONENT_ENGINE_SPATIAL_BLEND : PLAYER_ENGINE_SPATIAL_BLEND);
@@ -4161,14 +4186,14 @@ export const COMPUTER_JUMP_PANEL_THRUST = 80000;
4161
4186
  export const COMPUTER_DRIFT_SPEED_LOSS = 15;
4162
4187
  export const JUMP_PANEL_ROTATE_SECONDS = 0.6;
4163
4188
  export const JUMP_PANEL_ROTATE_RATE = 1;
4164
- export const TRICK_MIN_SPEED = 40;
4189
+ export const TRICK_MIN_SPEED = 30;
4165
4190
  export const TRICK_SECONDS = 0.3;
4166
4191
  export const TRICK_FORCE_START = 6500;
4167
4192
  export const TRICK_FORCE_DECAY = 300;
4168
4193
  export const TRICK_DECAY_STEP = 0.01;
4169
4194
  export const TRICK_FORCE_FLOOR = 300;
4170
4195
  export const TRICK_LANDING_BOOST = 0.9;
4171
- export const GLIDER_TRICK_SPEED = 60;
4196
+ export const GLIDER_TRICK_SPEED = 50;
4172
4197
  export const GLIDER_TRICK_OPEN_DELAY = 0.45;
4173
4198
  export const FALL_RESCUE_MIN_SINK_SPEED = 12;
4174
4199
  export const ANTI_GRAVITY_LOST_SECONDS = 0.3;
@@ -4537,7 +4562,11 @@ export class StandardKartController extends ScriptComponent {
4537
4562
  this.trickTime = -1;
4538
4563
  this.trickArmed = false;
4539
4564
  this.trickPerformed = false;
4565
+ this.trickLeftGround = false;
4566
+ this.trickGroundContact = false;
4540
4567
  this.trickPressed = false;
4568
+ this.trickPressQueued = false;
4569
+ this.lastTrickTrigger = null;
4541
4570
  this.verticalAccumulates = false;
4542
4571
  this.inputPitch = 0;
4543
4572
  this.chassisBody = null;
@@ -5342,10 +5371,6 @@ export class StandardKartController extends ScriptComponent {
5342
5371
  return false;
5343
5372
  if (this.trickTime >= 0)
5344
5373
  return false;
5345
- if (this.trickPerformed === true)
5346
- return false;
5347
- if (this.probeGrounded === true)
5348
- return false;
5349
5374
  if (this.trickArmed !== true)
5350
5375
  return false;
5351
5376
  if (this.REALCURRENTSPEED <= TRICK_MIN_SPEED)
@@ -5354,13 +5379,25 @@ export class StandardKartController extends ScriptComponent {
5354
5379
  return false;
5355
5380
  this.trickTime = 0;
5356
5381
  this.trickPerformed = true;
5382
+ this.trickLeftGround = false;
5383
+ this.trickArmed = false;
5357
5384
  return true;
5358
5385
  }
5386
+ trackTrickGroundContact() {
5387
+ const touchedGround = this.trickGroundContact;
5388
+ this.trickGroundContact = false;
5389
+ if (this.trickPerformed !== true || this.trickLeftGround === true)
5390
+ return;
5391
+ if (touchedGround !== true || this.probeGrounded !== true)
5392
+ this.trickLeftGround = true;
5393
+ }
5359
5394
  tickTrick(dt) {
5360
5395
  if (this.trickTime < 0)
5361
5396
  return;
5362
5397
  if (this.trickTime >= TRICK_SECONDS) {
5363
5398
  this.trickTime = -1;
5399
+ if (this.trickLeftGround !== true)
5400
+ this.clearTrickState();
5364
5401
  return;
5365
5402
  }
5366
5403
  const force = Math.max(TRICK_FORCE_FLOOR, TRICK_FORCE_START - TRICK_FORCE_DECAY * (this.trickTime / TRICK_DECAY_STEP));
@@ -5368,10 +5405,20 @@ export class StandardKartController extends ScriptComponent {
5368
5405
  this.trickTime += dt;
5369
5406
  }
5370
5407
  landTrick() {
5371
- if (this.trickPerformed === true)
5372
- this.floorBoost(TRICK_LANDING_BOOST, EKartBoostSource.TrickLanding);
5408
+ if (this.trickPerformed !== true || this.trickLeftGround !== true)
5409
+ return;
5410
+ this.floorBoost(TRICK_LANDING_BOOST, EKartBoostSource.TrickLanding);
5411
+ this.clearTrickState();
5412
+ }
5413
+ playTrickAnimation() {
5414
+ if (this.driverAnimation == null)
5415
+ return;
5416
+ this.lastTrickTrigger = this.driverAnimation.playTrick(this.getRigAnimators());
5417
+ }
5418
+ clearTrickState() {
5373
5419
  this.trickPerformed = false;
5374
5420
  this.trickTime = -1;
5421
+ this.trickLeftGround = false;
5375
5422
  }
5376
5423
  enterGliderSection(volume) {
5377
5424
  if (this.gliderEnabled !== true)
@@ -5714,9 +5761,12 @@ export class StandardKartController extends ScriptComponent {
5714
5761
  if (tag === "Ground" || tag === "Dirt") {
5715
5762
  this.FellInWater = false;
5716
5763
  this.outOfBounds = false;
5717
- this.landTrick();
5718
5764
  this.closeGlider();
5719
5765
  }
5766
+ if (tag === "Ground" || tag === "Dirt" || tag === "AntiGravity") {
5767
+ this.trickGroundContact = true;
5768
+ this.landTrick();
5769
+ }
5720
5770
  if (tag === "Ground" || tag === "AntiGravity") {
5721
5771
  this.grounded = true;
5722
5772
  if (tag === "Ground" && this.JUMP_PANEL === true) {
@@ -5885,9 +5935,11 @@ export class StandardKartController extends ScriptComponent {
5885
5935
  : this.assignedVelocity.y * 0.98;
5886
5936
  }
5887
5937
  this.tickJumpPanel(dt);
5888
- if (this.inputTrick === true && this.trickPressed !== true)
5889
- this.tryTrick();
5890
- this.trickPressed = this.inputTrick;
5938
+ this.trackTrickGroundContact();
5939
+ const trickPress = this.trickPressQueued;
5940
+ this.trickPressQueued = false;
5941
+ if (trickPress === true && this.tryTrick() === true)
5942
+ this.playTrickAnimation();
5891
5943
  this.tickTrick(dt);
5892
5944
  this.tickGliderImpulse(dt);
5893
5945
  this.applyAirForce(dt);
@@ -6726,6 +6778,7 @@ export class StandardKartController extends ScriptComponent {
6726
6778
  this.pendingAcceleration.setAll(0);
6727
6779
  this.clearWallContacts();
6728
6780
  this.resetDepthWater();
6781
+ this.clearTrickState();
6729
6782
  this.PlayerBeingMoved = false;
6730
6783
  this.respawnStage = 2;
6731
6784
  this.respawnTimer = 0.5;
@@ -6970,6 +7023,7 @@ export class StandardKartController extends ScriptComponent {
6970
7023
  }
6971
7024
  else {
6972
7025
  this.assignedVelocity.setAll(0);
7026
+ this.trickPressQueued = false;
6973
7027
  }
6974
7028
  this.applyDriftDownforce();
6975
7029
  this.probeGround();
@@ -7031,6 +7085,9 @@ export class StandardKartController extends ScriptComponent {
7031
7085
  this.inputBraking = braking;
7032
7086
  this.inputSteering = steering;
7033
7087
  this.inputDrifting = drifting;
7088
+ if (trick === true && this.trickPressed !== true)
7089
+ this.trickPressQueued = true;
7090
+ this.trickPressed = trick;
7034
7091
  this.inputTrick = trick;
7035
7092
  this.inputPitch = pitch;
7036
7093
  }
@@ -7102,6 +7159,7 @@ export class StandardKartController extends ScriptComponent {
7102
7159
  this.inputBraking = false;
7103
7160
  this.inputDrifting = false;
7104
7161
  this.inputTrick = false;
7162
+ this.trickPressQueued = false;
7105
7163
  this.currentspeed = this.autoDrive.speed;
7106
7164
  const target = this.autoDrive.targetProvider();
7107
7165
  if (target == null) {
@@ -7542,6 +7600,7 @@ export class StandardKartController extends ScriptComponent {
7542
7600
  getJumpPanelRotateTime() { return this.jumpPanelRotateTime; }
7543
7601
  isTricking() { return this.trickTime >= 0; }
7544
7602
  getTrickTime() { return this.trickTime; }
7603
+ getLastTrickTrigger() { return this.lastTrickTrigger; }
7545
7604
  isTrickArmed() { return this.trickArmed; }
7546
7605
  isTrickPending() { return this.trickPerformed; }
7547
7606
  getWheelSteer() { return this.wheelSteer; }
@@ -13492,779 +13551,6 @@ export class VertexSplatPlugin extends CustomShaderMaterialPlugin {
13492
13551
  this.getCustomShaderMaterial().updateCustomBindings(uniformBuffer);
13493
13552
  }
13494
13553
  }
13495
- export class DefaultCameraSystem extends ScriptComponent {
13496
- static IsCameraSystemReady() { return DefaultCameraSystem.cameraReady; }
13497
- isMainCamera() { return this.mainCamera; }
13498
- getCameraType() { return this.cameraType; }
13499
- getTargetTransform() { return this.setCameraTarget; }
13500
- setTargetTransform(target) { this.setCameraTarget = target; }
13501
- enableSpatialAudio(value) { this.setSpatialAudio = value; }
13502
- constructor(transform, scene, properties = {}, alias = "PROJECT.DefaultCameraSystem") {
13503
- super(transform, scene, properties, alias);
13504
- this.mainCamera = false;
13505
- this.cameraType = 0;
13506
- this.cameraInertia = 0.9;
13507
- this.cameraController = null;
13508
- this.immersiveOptions = null;
13509
- this.arcRotateConfig = null;
13510
- this.multiPlayerSetup = null;
13511
- this.fullScreenToggle = 0;
13512
- this.setPointerLock = false;
13513
- this.setCameraTarget = null;
13514
- this.setSpatialAudio = true;
13515
- this.m_cameraRig = null;
13516
- this.targetCameraOffset = new BABYLON.Vector3(0, 0, 0);
13517
- this.cameraNode = null;
13518
- this.cameraPivot = null;
13519
- this.cameraDistance = 0;
13520
- this.cameraPivotOffset = new BABYLON.Vector3(0, 0, 0);
13521
- this.cameraBoomPosition = new BABYLON.Vector3(0, 0, 0);
13522
- this.dollyDirection = new BABYLON.Vector3(0, 0, 0);
13523
- this.rotationEulers = new BABYLON.Vector3(0, 0, 0);
13524
- this.scaledCamDirection = new BABYLON.Vector3(0, 0, 0);
13525
- this.scaledMaxDirection = new BABYLON.Vector3(0, 0, 0);
13526
- this.parentNodePosition = new BABYLON.Vector3(0, 0, 0);
13527
- this.maximumCameraPos = new BABYLON.Vector3(0, 0, 0);
13528
- this.cameraRaycastShape = null;
13529
- this.targetRotationVector = BABYLON.Vector2.Zero();
13530
- this.smoothBoomArmLength = null;
13531
- this.smoothBoomArmSpeed = null;
13532
- DefaultCameraSystem.cameraInstance = this;
13533
- }
13534
- awake() { this.awakeCameraSystemState(); }
13535
- start() { this.startCameraSystemState(); }
13536
- update() { this.updateCameraSystemState(); }
13537
- destroy() { this.destroyCameraSystemState(); }
13538
- awakeCameraSystemState() {
13539
- this.mainCamera = (this.getTransformTag() === "MainCamera");
13540
- this.cameraType = this.getProperty("mainCameraType", this.cameraType);
13541
- this.cameraInertia = this.getProperty("setCameraInertia", this.cameraInertia);
13542
- this.fullScreenToggle = this.getProperty("fullScreenToggle", this.fullScreenToggle);
13543
- this.setSpatialAudio = this.getProperty("setSpatialAudio", this.setSpatialAudio);
13544
- this.setPointerLock = this.getProperty("setPointerLock", this.setPointerLock);
13545
- this.immersiveOptions = this.getProperty("immersiveOptions", this.immersiveOptions);
13546
- this.arcRotateConfig = this.getProperty("arcRotateConfig", this.arcRotateConfig);
13547
- this.multiPlayerSetup = this.getProperty("multiPlayerSetup", this.multiPlayerSetup);
13548
- this.cameraController = this.getProperty("cameraController", this.cameraController);
13549
- this.cleanCameraSystemState();
13550
- if (this.fullScreenToggle === 0) {
13551
- InputController.OnKeyboardPress(UserInputKey.F, () => {
13552
- SceneManager.EnterFullscreenMode(this.scene, this.setPointerLock);
13553
- });
13554
- }
13555
- }
13556
- async startCameraSystemState() {
13557
- Utilities.ValidateTransformQuaternion(this.transform);
13558
- if (this.multiPlayerSetup != null) {
13559
- DefaultCameraSystem.startupMode = this.multiPlayerSetup.playerStartupMode;
13560
- DefaultCameraSystem.stereoCameras = this.multiPlayerSetup.stereoSideBySide;
13561
- }
13562
- this.m_cameraRig = this.getCameraRig();
13563
- if (this.m_cameraRig != null) {
13564
- this.m_cameraRig.inertia = this.cameraInertia;
13565
- this.m_cameraRig.layerMask = ~SceneManager.HiddenLayerMask;
13566
- if (this.setSpatialAudio === true && !AudioSource.IsLegacyEngine()) {
13567
- try {
13568
- AudioSource.AttachSpatialCamera(this.m_cameraRig);
13569
- }
13570
- catch (e) {
13571
- SceneManager.LogError("Failed to attach spatial audio to camera rig: " + e.message);
13572
- }
13573
- }
13574
- if (this.cameraController != null) {
13575
- this.m_cameraRig.speed = this.cameraController.cameraSpeed;
13576
- this.m_cameraRig.inverseRotationSpeed = this.cameraController.invRotationSpeed;
13577
- if (this.m_cameraRig instanceof BABYLON.UniversalCamera) {
13578
- this.m_cameraRig.gamepadAngularSensibility = this.cameraController.gamepadRotation;
13579
- this.m_cameraRig.gamepadMoveSensibility = this.cameraController.gamepadMovement;
13580
- this.m_cameraRig.touchAngularSensibility = this.cameraController.touchRotation;
13581
- this.m_cameraRig.touchMoveSensibility = this.cameraController.touchMovement;
13582
- }
13583
- if (this.cameraController.keyboardWASD === true) {
13584
- if (this.m_cameraRig.inputs != null && this.m_cameraRig.inputs.attached != null && this.m_cameraRig.inputs.attached.keyboard != null) {
13585
- if (this.m_cameraRig.inputs.attached.keyboard instanceof BABYLON.FreeCameraKeyboardMoveInput) {
13586
- const cinput = this.m_cameraRig.inputs.attached.keyboard;
13587
- cinput.keysUp.push(UserInputKey.W);
13588
- cinput.keysLeft.push(UserInputKey.A);
13589
- cinput.keysDown.push(UserInputKey.S);
13590
- cinput.keysRight.push(UserInputKey.D);
13591
- cinput.rotationSpeed = this.cameraController.rotationSpeed;
13592
- if (this.cameraController.arrowKeyRotation === true) {
13593
- cinput.keysLeft = [UserInputKey.A];
13594
- cinput.keysRight = [UserInputKey.D];
13595
- cinput.keysRotateLeft = [UserInputKey.LeftArrow];
13596
- cinput.keysRotateRight = [UserInputKey.RightArrow];
13597
- }
13598
- }
13599
- }
13600
- }
13601
- }
13602
- if (this.m_cameraRig.inputs != null && this.m_cameraRig.inputs.attached != null && this.m_cameraRig.inputs.attached.mouse != null) {
13603
- const mouseInput = this.m_cameraRig.inputs.attached.mouse;
13604
- if (Utilities.HasOwnProperty(mouseInput, "touchEnabled")) {
13605
- mouseInput.touchEnabled = true;
13606
- }
13607
- }
13608
- if (this.cameraType === 0 || this.cameraType === 4) {
13609
- DefaultCameraSystem.PlayerOneCamera = this.m_cameraRig;
13610
- DefaultCameraSystem.PlayerOneCamera.inertia = this.cameraInertia;
13611
- DefaultCameraSystem.PlayerOneCamera.transform = this.transform;
13612
- }
13613
- else if (this.cameraType === 1 || this.cameraType === 2) {
13614
- DefaultCameraSystem.PlayerOneCamera = this.m_cameraRig;
13615
- DefaultCameraSystem.PlayerOneCamera.inertia = this.cameraInertia;
13616
- DefaultCameraSystem.PlayerOneCamera.transform = this.transform;
13617
- if (this.immersiveOptions != null) {
13618
- const localStorageRequired = (this.immersiveOptions.localStorageOption === true);
13619
- if (localStorageRequired === false || (localStorageRequired === true && WindowManager.GetVirtualRealityEnabled())) {
13620
- let webvrFloorMeshes = null;
13621
- let webvrHelperOptions = null;
13622
- let webvrImmersiveMode = (this.cameraType === 1) ? "immersive-ar" : "immersive-vr";
13623
- let webvrReferenceType = "local-floor";
13624
- switch (this.immersiveOptions.referenceSpaceType) {
13625
- case 0:
13626
- webvrReferenceType = "viewer";
13627
- break;
13628
- case 1:
13629
- webvrReferenceType = "local";
13630
- break;
13631
- case 2:
13632
- webvrReferenceType = "local-floor";
13633
- break;
13634
- case 4:
13635
- webvrReferenceType = "unbounded";
13636
- break;
13637
- default:
13638
- webvrReferenceType = "local-floor";
13639
- break;
13640
- }
13641
- if (this.immersiveOptions.setFloorMeshesTags == null || this.immersiveOptions.setFloorMeshesTags === "")
13642
- this.immersiveOptions.setFloorMeshesTags = "Navigation";
13643
- if (this.immersiveOptions.defaultTeleportationSetup.useTeleportation === true)
13644
- webvrFloorMeshes = this.scene.getMeshesByTags(this.immersiveOptions.setFloorMeshesTags);
13645
- if (this.immersiveOptions.defaultTeleportationSetup.useTeleportation === true && webvrFloorMeshes != null && webvrFloorMeshes.length > 0) {
13646
- webvrHelperOptions = {
13647
- floorMeshes: webvrFloorMeshes,
13648
- optionalFeatures: this.immersiveOptions.optionalFeatures,
13649
- useStablePlugins: this.immersiveOptions.useStablePlugins,
13650
- renderingGroupId: this.immersiveOptions.renderingGroupNum,
13651
- disableDefaultUI: this.immersiveOptions.disableUserInterface,
13652
- disableTeleportation: (this.immersiveOptions.defaultTeleportationSetup.useTeleportation === false),
13653
- disablePointerSelection: this.immersiveOptions.disablePointerSelect,
13654
- ignoreNativeCameraTransformation: this.immersiveOptions.ignoreNativeCamera,
13655
- inputOptions: {
13656
- doNotLoadControllerMeshes: this.immersiveOptions.experienceInputOptions.disableMeshLoad,
13657
- forceInputProfile: this.immersiveOptions.experienceInputOptions.forceInputProfile,
13658
- disableOnlineControllerRepository: this.immersiveOptions.experienceInputOptions.disableRepository,
13659
- customControllersRepositoryURL: this.immersiveOptions.experienceInputOptions.customRepository,
13660
- disableControllerAnimation: this.immersiveOptions.experienceInputOptions.disableModelAnim,
13661
- controllerOptions: {
13662
- disableMotionControllerAnimation: this.immersiveOptions.experienceInputOptions.controllerOptions.disableCtrlAnim,
13663
- doNotLoadControllerMesh: this.immersiveOptions.experienceInputOptions.controllerOptions.disableCtrlMesh,
13664
- forceControllerProfile: this.immersiveOptions.experienceInputOptions.controllerOptions.forceCtrlProfile,
13665
- renderingGroupId: this.immersiveOptions.experienceInputOptions.controllerOptions.renderingGroup
13666
- }
13667
- },
13668
- uiOptions: {
13669
- sessionMode: webvrImmersiveMode,
13670
- referenceSpaceType: webvrReferenceType
13671
- }
13672
- };
13673
- }
13674
- else {
13675
- webvrHelperOptions = {
13676
- optionalFeatures: this.immersiveOptions.optionalFeatures,
13677
- useStablePlugins: this.immersiveOptions.useStablePlugins,
13678
- renderingGroupId: this.immersiveOptions.renderingGroupNum,
13679
- disableDefaultUI: this.immersiveOptions.disableUserInterface,
13680
- disableTeleportation: (this.immersiveOptions.defaultTeleportationSetup.useTeleportation === false),
13681
- disablePointerSelection: this.immersiveOptions.disablePointerSelect,
13682
- ignoreNativeCameraTransformation: this.immersiveOptions.ignoreNativeCamera,
13683
- inputOptions: {
13684
- doNotLoadControllerMeshes: this.immersiveOptions.experienceInputOptions.disableMeshLoad,
13685
- forceInputProfile: this.immersiveOptions.experienceInputOptions.forceInputProfile,
13686
- disableOnlineControllerRepository: this.immersiveOptions.experienceInputOptions.disableRepository,
13687
- customControllersRepositoryURL: this.immersiveOptions.experienceInputOptions.customRepository,
13688
- disableControllerAnimation: this.immersiveOptions.experienceInputOptions.disableModelAnim,
13689
- controllerOptions: {
13690
- disableMotionControllerAnimation: this.immersiveOptions.experienceInputOptions.controllerOptions.disableCtrlAnim,
13691
- doNotLoadControllerMesh: this.immersiveOptions.experienceInputOptions.controllerOptions.disableCtrlMesh,
13692
- forceControllerProfile: this.immersiveOptions.experienceInputOptions.controllerOptions.forceCtrlProfile,
13693
- renderingGroupId: this.immersiveOptions.renderingGroupNum
13694
- }
13695
- },
13696
- uiOptions: {
13697
- sessionMode: webvrImmersiveMode,
13698
- referenceSpaceType: webvrReferenceType
13699
- }
13700
- };
13701
- }
13702
- DefaultCameraSystem.XRExperienceHelper = await this.scene.createDefaultXRExperienceAsync(webvrHelperOptions);
13703
- if (DefaultCameraSystem.XRExperienceHelper != null && DefaultCameraSystem.XRExperienceHelper.baseExperience != null) {
13704
- if (DefaultCameraSystem.XRExperienceHelper.teleportation != null) {
13705
- DefaultCameraSystem.XRExperienceHelper.teleportation.rotationAngle = BABYLON.Tools.ToRadians(this.immersiveOptions.defaultTeleportationSetup.turningAxisAngle);
13706
- DefaultCameraSystem.XRExperienceHelper.teleportation.rotationEnabled = this.immersiveOptions.defaultTeleportationSetup.rotationsEnabled;
13707
- DefaultCameraSystem.XRExperienceHelper.teleportation.backwardsMovementEnabled = this.immersiveOptions.defaultTeleportationSetup.backwardsEnabled;
13708
- DefaultCameraSystem.XRExperienceHelper.teleportation.backwardsTeleportationDistance = this.immersiveOptions.defaultTeleportationSetup.backwardsDistance;
13709
- DefaultCameraSystem.XRExperienceHelper.teleportation.parabolicCheckRadius = this.immersiveOptions.defaultTeleportationSetup.parabolicRadius;
13710
- }
13711
- if (DefaultCameraSystem.OnXRExperienceHelperObservable && DefaultCameraSystem.OnXRExperienceHelperObservable.hasObservers()) {
13712
- DefaultCameraSystem.OnXRExperienceHelperObservable.notifyObservers(DefaultCameraSystem.XRExperienceHelper);
13713
- }
13714
- if (SceneManager.HasNavigationData()) {
13715
- const navmesh = SceneManager.GetNavigationMesh();
13716
- DefaultCameraSystem.SetupNavigationWebXR(navmesh, this.immersiveOptions.setFloorMeshesTags);
13717
- }
13718
- else {
13719
- SceneManager.OnNavMeshReadyObservable.addOnce((navmesh) => {
13720
- DefaultCameraSystem.SetupNavigationWebXR(navmesh, this.immersiveOptions.setFloorMeshesTags);
13721
- });
13722
- }
13723
- }
13724
- else {
13725
- SceneManager.LogWarning("WebXR not supported in current browser.");
13726
- }
13727
- }
13728
- }
13729
- }
13730
- else if (this.cameraType === 3) {
13731
- const cameraName = this.m_cameraRig.name;
13732
- const playerOneTransform = new BABYLON.TransformNode("Player Camera 1", this.scene);
13733
- playerOneTransform.rotationQuaternion = this.transform.rotationQuaternion.clone();
13734
- playerOneTransform.position = this.transform.position.clone();
13735
- playerOneTransform.parent = this.transform.parent;
13736
- const playerOneName = cameraName + ".1";
13737
- const playerOneCamerax = this.m_cameraRig.clone(playerOneName);
13738
- playerOneCamerax.name = playerOneName;
13739
- playerOneCamerax.parent = playerOneTransform;
13740
- playerOneCamerax.position = new BABYLON.Vector3(0, 0, 0);
13741
- playerOneCamerax.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
13742
- playerOneCamerax.viewport = new BABYLON.Viewport(0, 0, 0, 0);
13743
- playerOneCamerax.setEnabled(false);
13744
- DefaultCameraSystem.PlayerOneCamera = playerOneCamerax;
13745
- DefaultCameraSystem.PlayerOneCamera.inertia = this.cameraInertia;
13746
- DefaultCameraSystem.PlayerOneCamera.transform = playerOneTransform;
13747
- playerOneTransform.cameraRig = DefaultCameraSystem.PlayerOneCamera;
13748
- const playerTwoTransform = new BABYLON.TransformNode("Player Camera 2", this.scene);
13749
- playerTwoTransform.rotationQuaternion = this.transform.rotationQuaternion.clone();
13750
- playerTwoTransform.position = this.transform.position.clone();
13751
- playerTwoTransform.parent = this.transform.parent;
13752
- const playerTwoName = cameraName + ".2";
13753
- const playerTwoCamerax = this.m_cameraRig.clone(playerTwoName);
13754
- playerTwoCamerax.name = playerTwoName;
13755
- playerTwoCamerax.parent = playerTwoTransform;
13756
- playerTwoCamerax.position = new BABYLON.Vector3(0, 0, 0);
13757
- playerTwoCamerax.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
13758
- playerTwoCamerax.viewport = new BABYLON.Viewport(0, 0, 0, 0);
13759
- playerTwoCamerax.setEnabled(false);
13760
- DefaultCameraSystem.PlayerTwoCamera = playerTwoCamerax;
13761
- DefaultCameraSystem.PlayerTwoCamera.inertia = this.cameraInertia;
13762
- DefaultCameraSystem.PlayerTwoCamera.transform = playerTwoTransform;
13763
- playerTwoTransform.cameraRig = DefaultCameraSystem.PlayerTwoCamera;
13764
- const playerThreeTransform = new BABYLON.TransformNode("Player Camera 3", this.scene);
13765
- playerThreeTransform.rotationQuaternion = this.transform.rotationQuaternion.clone();
13766
- playerThreeTransform.position = this.transform.position.clone();
13767
- playerThreeTransform.parent = this.transform.parent;
13768
- const playerThreeName = cameraName + ".3";
13769
- const playerThreeCamerax = this.m_cameraRig.clone(playerThreeName);
13770
- playerThreeCamerax.name = playerThreeName;
13771
- playerThreeCamerax.parent = playerThreeTransform;
13772
- playerThreeCamerax.position = new BABYLON.Vector3(0, 0, 0);
13773
- playerThreeCamerax.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
13774
- playerThreeCamerax.viewport = new BABYLON.Viewport(0, 0, 0, 0);
13775
- playerThreeCamerax.setEnabled(false);
13776
- DefaultCameraSystem.PlayerThreeCamera = playerThreeCamerax;
13777
- DefaultCameraSystem.PlayerThreeCamera.inertia = this.cameraInertia;
13778
- DefaultCameraSystem.PlayerThreeCamera.transform = playerThreeTransform;
13779
- playerThreeTransform.cameraRig = DefaultCameraSystem.PlayerThreeCamera;
13780
- const playerFourTransform = new BABYLON.TransformNode("Player Camera 4", this.scene);
13781
- playerFourTransform.rotationQuaternion = this.transform.rotationQuaternion.clone();
13782
- playerFourTransform.position = this.transform.position.clone();
13783
- playerFourTransform.parent = this.transform.parent;
13784
- const playerFourName = cameraName + ".4";
13785
- const playerFourCamerax = this.m_cameraRig.clone(playerFourName);
13786
- playerFourCamerax.name = playerFourName;
13787
- playerFourCamerax.parent = playerFourTransform;
13788
- playerFourCamerax.position = new BABYLON.Vector3(0, 0, 0);
13789
- playerFourCamerax.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
13790
- playerFourCamerax.viewport = new BABYLON.Viewport(0, 0, 0, 0);
13791
- playerFourCamerax.setEnabled(false);
13792
- DefaultCameraSystem.PlayerFourCamera = playerFourCamerax;
13793
- DefaultCameraSystem.PlayerFourCamera.inertia = this.cameraInertia;
13794
- DefaultCameraSystem.PlayerFourCamera.transform = playerFourTransform;
13795
- playerFourTransform.cameraRig = DefaultCameraSystem.PlayerFourCamera;
13796
- DefaultCameraSystem.multiPlayerView = true;
13797
- DefaultCameraSystem.SetMultiPlayerViewLayout(this.scene, DefaultCameraSystem.startupMode);
13798
- }
13799
- if (this.cameraController.cameraControl === 1 || this.cameraController.cameraControl === 2) {
13800
- this.m_cameraRig.parent = null;
13801
- this.m_cameraRig.position.copyFrom(this.transform.position);
13802
- this.m_cameraRig.rotationQuaternion = (this.transform.rotationQuaternion != null) ? this.transform.rotationQuaternion.clone() : BABYLON.Quaternion.FromEulerAngles(this.transform.rotation.x, this.transform.rotation.y, this.transform.rotation.z);
13803
- const children = this.transform.getChildren(null, true);
13804
- if (children != null) {
13805
- children.forEach((child) => { child.parent = this.m_cameraRig; });
13806
- }
13807
- if (this.m_cameraRig instanceof BABYLON.FreeCamera) {
13808
- this.m_cameraRig.checkCollisions = this.cameraController.checkCollisions;
13809
- this.m_cameraRig.applyGravity = this.cameraController.setApplyGravity;
13810
- }
13811
- if (this.cameraController.cameraControl === 1) {
13812
- this.m_cameraRig.attachControl(this.cameraController.preventDefault);
13813
- }
13814
- }
13815
- }
13816
- DefaultCameraSystem.cameraReady = true;
13817
- }
13818
- updateCameraSystemState() {
13819
- if (this.m_cameraRig != null) {
13820
- if (this.cameraType === 0) {
13821
- }
13822
- else if (this.cameraType === 1) {
13823
- }
13824
- else if (this.cameraType === 2) {
13825
- }
13826
- else if (this.cameraType === 3) {
13827
- }
13828
- }
13829
- if (this.cameraController.cameraControl === 3) {
13830
- const deltaTime = this.getDeltaSeconds();
13831
- const userMouseX = InputController.GetUserInput(UserInputAxis.MouseX, this.cameraController.playerNumber);
13832
- const userMouseY = InputController.GetUserInput(UserInputAxis.MouseY, this.cameraController.playerNumber);
13833
- this.targetRotationVector.y += (userMouseX * this.cameraController.rotateSpeed * deltaTime);
13834
- this.targetRotationVector.x += (-userMouseY * this.cameraController.rotateSpeed * deltaTime);
13835
- this.targetRotationVector.x = BABYLON.Scalar.Clamp(this.targetRotationVector.x, -BABYLON.Tools.ToRadians(this.cameraController.downLookLimit), BABYLON.Tools.ToRadians(this.cameraController.topLookLimit));
13836
- if (this.cameraController.autoUpdate === true) {
13837
- DefaultCameraSystem.UpdateFollowTarget();
13838
- }
13839
- }
13840
- }
13841
- cleanCameraSystemState() {
13842
- if (DefaultCameraSystem.PlayerOneCamera != null) {
13843
- DefaultCameraSystem.PlayerOneCamera = null;
13844
- }
13845
- if (DefaultCameraSystem.PlayerTwoCamera != null) {
13846
- DefaultCameraSystem.PlayerTwoCamera = null;
13847
- }
13848
- if (DefaultCameraSystem.PlayerThreeCamera != null) {
13849
- DefaultCameraSystem.PlayerThreeCamera = null;
13850
- }
13851
- if (DefaultCameraSystem.PlayerFourCamera != null) {
13852
- DefaultCameraSystem.PlayerFourCamera = null;
13853
- }
13854
- }
13855
- destroyCameraSystemState() {
13856
- this.immersiveOptions = null;
13857
- this.cameraPivot = null;
13858
- this.cameraNode = null;
13859
- const owner = this.scene;
13860
- const owned = (camera) => (camera != null && owner != null && camera.getScene() === owner);
13861
- if (owned(DefaultCameraSystem.PlayerOneCamera))
13862
- DefaultCameraSystem.PlayerOneCamera = null;
13863
- if (owned(DefaultCameraSystem.PlayerTwoCamera))
13864
- DefaultCameraSystem.PlayerTwoCamera = null;
13865
- if (owned(DefaultCameraSystem.PlayerThreeCamera))
13866
- DefaultCameraSystem.PlayerThreeCamera = null;
13867
- if (owned(DefaultCameraSystem.PlayerFourCamera))
13868
- DefaultCameraSystem.PlayerFourCamera = null;
13869
- if (DefaultCameraSystem.multiPlayerCameras != null && DefaultCameraSystem.multiPlayerCameras.some(owned))
13870
- DefaultCameraSystem.multiPlayerCameras = null;
13871
- const xr = DefaultCameraSystem.XRExperienceHelper;
13872
- if (xr != null && xr.baseExperience != null && xr.baseExperience.sessionManager != null && xr.baseExperience.sessionManager.scene === owner)
13873
- DefaultCameraSystem.XRExperienceHelper = null;
13874
- if (DefaultCameraSystem.cameraInstance === this)
13875
- DefaultCameraSystem.cameraInstance = null;
13876
- }
13877
- getCameraPivotPosition() { return (this.cameraPivot != null) ? this.cameraPivot.position : null; }
13878
- getCameraPivotRotation() { return (this.cameraPivot != null) ? this.cameraPivot.rotationQuaternion : null; }
13879
- getCameraBoomNode() { return this.cameraNode; }
13880
- getCameraTransform() { return this.cameraPivot; }
13881
- resetCameraRotation() {
13882
- if (this.setCameraTarget == null)
13883
- return;
13884
- this.setCameraTarget.rotationQuaternion.toEulerAnglesToRef(this.rotationEulers);
13885
- this.targetRotationVector.x = this.rotationEulers.x;
13886
- this.targetRotationVector.y = this.rotationEulers.y;
13887
- }
13888
- updateCameraController() {
13889
- const deltaTime = this.getDeltaSeconds();
13890
- if (this.cameraController.targetTracking === false || this.setCameraTarget == null)
13891
- return;
13892
- if (this.cameraRaycastShape == null) {
13893
- this.cameraRaycastShape = new BABYLON.PhysicsShapeSphere(new BABYLON.Vector3(0, 0, 0), this.cameraController.sphereRadius, this.scene);
13894
- }
13895
- if (this.cameraPivot == null) {
13896
- this.resetCameraRotation();
13897
- this.cameraPivot = new BABYLON.Mesh(this.setCameraTarget.name + ".CameraPivot", this.scene);
13898
- this.cameraPivot.parent = null;
13899
- this.cameraPivot.position = this.setCameraTarget.position.clone();
13900
- this.cameraPivot.rotationQuaternion = this.setCameraTarget.rotationQuaternion.clone();
13901
- this.cameraPivot.checkCollisions = false;
13902
- this.cameraPivot.isPickable = false;
13903
- if (Utilities.ShowDebugColliders()) {
13904
- const testPivot = BABYLON.MeshBuilder.CreateBox("TestPivot", { width: 0.25, height: 0.25, depth: 0.75 }, this.scene);
13905
- testPivot.parent = this.cameraPivot;
13906
- testPivot.position.set(0, 0, 0);
13907
- testPivot.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
13908
- testPivot.visibility = 1.0;
13909
- testPivot.renderingGroupId = Utilities.ColliderRenderGroup();
13910
- testPivot.checkCollisions = false;
13911
- testPivot.isPickable = false;
13912
- }
13913
- }
13914
- if (this.cameraNode == null) {
13915
- const player = (this.cameraController.playerNumber != null) ? this.cameraController.playerNumber : 1;
13916
- const playerCamera = (player <= 0 || player > 4) ? 1 : player;
13917
- const playerCameraNode = DefaultCameraSystem.GetCameraTransform(this.scene, playerCamera);
13918
- const playerFreeCamera = DefaultCameraSystem.GetMainCamera(this.scene, false);
13919
- if (playerCameraNode != null && playerFreeCamera != null) {
13920
- playerFreeCamera.detachControl();
13921
- this.cameraNode = playerCameraNode;
13922
- this.cameraNode.parent = this.cameraPivot;
13923
- this.cameraNode.position.set(this.cameraController.boomPosition.x, this.cameraController.boomPosition.y, this.cameraController.boomPosition.z);
13924
- this.cameraNode.rotationQuaternion = BABYLON.Quaternion.FromEulerAngles(BABYLON.Tools.ToRadians(this.cameraController.maxTiltAngle), 0, 0);
13925
- this.cameraDistance = this.cameraNode.position.length();
13926
- this.dollyDirection.copyFrom(this.cameraNode.position);
13927
- this.dollyDirection.normalize();
13928
- }
13929
- else {
13930
- }
13931
- }
13932
- if (this.cameraPivot != null) {
13933
- if (this.targetCameraOffset.x !== 0 || this.targetCameraOffset.y !== 0 || this.targetCameraOffset.z !== 0) {
13934
- this.cameraPivotOffset.copyFrom(this.targetCameraOffset);
13935
- }
13936
- else {
13937
- this.cameraPivotOffset.set(0, this.cameraController.pivotHeight, 0);
13938
- }
13939
- Utilities.GetAbsolutePositionToRef(this.setCameraTarget, this.cameraPivot.position, this.cameraPivotOffset);
13940
- if (this.cameraController.rotateCamera === true) {
13941
- BABYLON.Quaternion.FromEulerAnglesToRef(this.targetRotationVector.x, this.targetRotationVector.y, 0, this.cameraPivot.rotationQuaternion);
13942
- }
13943
- }
13944
- if (this.cameraController.rotateCamera === true && this.cameraNode != null) {
13945
- if (this.cameraController.cameraSmoothing <= 0)
13946
- this.cameraController.cameraSmoothing = 5.0;
13947
- if (this.cameraController.cameraCollisions === true) {
13948
- const maxDistance = Math.abs(this.cameraController.boomPosition.z);
13949
- const parentNode = this.cameraNode.parent;
13950
- this.dollyDirection.scaleToRef(maxDistance, this.scaledMaxDirection);
13951
- this.dollyDirection.scaleToRef(this.cameraDistance, this.scaledCamDirection);
13952
- Utilities.GetAbsolutePositionToRef(parentNode, this.parentNodePosition);
13953
- Utilities.TransformPointToRef(parentNode, this.scaledMaxDirection, this.maximumCameraPos);
13954
- let contact = false;
13955
- let distance = 0;
13956
- if (this.cameraRaycastShape != null) {
13957
- const query = {
13958
- shape: this.cameraRaycastShape,
13959
- rotation: this.cameraNode.rotationQuaternion,
13960
- startPosition: this.parentNodePosition,
13961
- endPosition: this.maximumCameraPos,
13962
- ignoreBody: this.setCameraTarget.physicsBody,
13963
- shouldHitTriggers: false
13964
- };
13965
- const result = RigidbodyPhysics.Shapecast(query);
13966
- contact = (result != null && result.world != null && result.world.hasHit === true && result.world.body != null);
13967
- distance = (contact === true) ? BABYLON.Vector3.Distance(this.parentNodePosition, result.world.hitPoint) : 0;
13968
- }
13969
- if (contact === true) {
13970
- this.cameraDistance = BABYLON.Scalar.Clamp((distance * this.cameraController.distanceFactor), this.cameraController.minDistance, this.cameraController.maxDistance);
13971
- this.dollyDirection.scaleToRef(this.cameraDistance, this.scaledCamDirection);
13972
- if (this.cameraNode.position.x !== this.scaledCamDirection.x || this.cameraNode.position.y !== this.scaledCamDirection.y || this.cameraNode.position.z !== this.scaledCamDirection.z) {
13973
- const cameraDelta = this.cameraNode.position.subtract(this.scaledCamDirection);
13974
- const deltaLength = cameraDelta.length();
13975
- const adaptiveSmoothingFactor = deltaLength > 0.3 ? this.cameraController.cameraSmoothing * 0.8 : this.cameraController.cameraSmoothing;
13976
- BABYLON.Vector3.LerpToRef(this.cameraNode.position, this.scaledCamDirection, (deltaTime * adaptiveSmoothingFactor), this.cameraNode.position);
13977
- }
13978
- }
13979
- else {
13980
- if (this.cameraController.mouseWheel === true) {
13981
- if (InputController.IsWheelScrolling()) {
13982
- const wheel = InputController.GetUserInput(UserInputAxis.Wheel);
13983
- if (wheel < 0) {
13984
- const zoomOutSpeed = (this.cameraController.scrollSpeed * deltaTime);
13985
- this.cameraController.boomPosition.z = BABYLON.Scalar.MoveTowards(this.cameraController.boomPosition.z, -this.cameraController.maxDistance, zoomOutSpeed);
13986
- }
13987
- else if (wheel > 0) {
13988
- const zoomInSpeed = (this.cameraController.scrollSpeed * deltaTime);
13989
- this.cameraController.boomPosition.z = BABYLON.Scalar.MoveTowards(this.cameraController.boomPosition.z, -this.cameraController.minDistance, zoomInSpeed);
13990
- }
13991
- }
13992
- }
13993
- if (this.cameraNode.position.x !== this.cameraBoomPosition.x || this.cameraNode.position.y !== this.cameraBoomPosition.y || this.cameraNode.position.z !== this.cameraBoomPosition.z) {
13994
- this.cameraBoomPosition.set(this.cameraController.boomPosition.x, this.cameraController.boomPosition.y, this.cameraController.boomPosition.z);
13995
- const cameraDelta = this.cameraNode.position.subtract(this.cameraBoomPosition);
13996
- const deltaLength = cameraDelta.length();
13997
- const adaptiveSmoothingFactor = deltaLength > 0.3 ? this.cameraController.cameraSmoothing * 0.8 : this.cameraController.cameraSmoothing;
13998
- BABYLON.Vector3.LerpToRef(this.cameraNode.position, this.cameraBoomPosition, (deltaTime * adaptiveSmoothingFactor), this.cameraNode.position);
13999
- }
14000
- }
14001
- }
14002
- else {
14003
- if (this.cameraController.mouseWheel === true) {
14004
- if (InputController.IsWheelScrolling()) {
14005
- const wheel = InputController.GetUserInput(UserInputAxis.Wheel);
14006
- if (wheel < 0) {
14007
- const zoomOutSpeed = (this.cameraController.scrollSpeed * deltaTime);
14008
- this.cameraController.boomPosition.z = BABYLON.Scalar.MoveTowards(this.cameraController.boomPosition.z, -this.cameraController.maxDistance, zoomOutSpeed);
14009
- }
14010
- else if (wheel > 0) {
14011
- const zoomInSpeed = (this.cameraController.scrollSpeed * deltaTime);
14012
- this.cameraController.boomPosition.z = BABYLON.Scalar.MoveTowards(this.cameraController.boomPosition.z, -this.cameraController.minDistance, zoomInSpeed);
14013
- }
14014
- }
14015
- }
14016
- if (this.cameraNode.position.x !== this.cameraController.boomPosition.x || this.cameraNode.position.y !== this.cameraController.boomPosition.y || this.cameraNode.position.z !== this.cameraController.boomPosition.z) {
14017
- this.cameraBoomPosition.set(this.cameraController.boomPosition.x, this.cameraController.boomPosition.y, this.cameraController.boomPosition.z);
14018
- BABYLON.Vector3.LerpToRef(this.cameraNode.position, this.cameraBoomPosition, (deltaTime * this.cameraController.cameraSmoothing), this.cameraNode.position);
14019
- }
14020
- }
14021
- }
14022
- this.updateSmoothBoomArmLength();
14023
- }
14024
- getBoomArmMaxDistance() { return this.cameraController.maxDistance; }
14025
- setBoomArmMaxDistance(distance) { this.cameraController.maxDistance = Math.abs(distance); }
14026
- setSmoothBoomArmLength(length, speed, updateMaxDistance = true) {
14027
- const absoluteLength = Math.abs(length);
14028
- this.smoothBoomArmLength = -absoluteLength;
14029
- this.smoothBoomArmSpeed = speed;
14030
- if (updateMaxDistance === true) {
14031
- const absoluteDistance = Math.abs(this.cameraController.maxDistance);
14032
- if (absoluteLength > absoluteDistance) {
14033
- this.setBoomArmMaxDistance(absoluteLength);
14034
- }
14035
- }
14036
- }
14037
- updateSmoothBoomArmLength() {
14038
- if (this.smoothBoomArmLength != null && this.smoothBoomArmSpeed != null) {
14039
- if (this.cameraController.boomPosition.z !== this.smoothBoomArmLength) {
14040
- this.cameraController.boomPosition.z = BABYLON.Scalar.MoveTowards(this.cameraController.boomPosition.z, this.smoothBoomArmLength, (this.smoothBoomArmSpeed * this.getDeltaSeconds()));
14041
- }
14042
- else {
14043
- this.smoothBoomArmLength = null;
14044
- this.smoothBoomArmSpeed = null;
14045
- }
14046
- }
14047
- }
14048
- static EnableTracking(value) {
14049
- if (DefaultCameraSystem.cameraInstance != null && DefaultCameraSystem.cameraInstance.cameraController != null) {
14050
- DefaultCameraSystem.cameraInstance.cameraController.targetTracking = value;
14051
- }
14052
- }
14053
- static IsTrackingEnabled() {
14054
- let result = false;
14055
- if (DefaultCameraSystem.cameraInstance != null && DefaultCameraSystem.cameraInstance.cameraController != null) {
14056
- result = DefaultCameraSystem.cameraInstance.cameraController.targetTracking;
14057
- }
14058
- return result;
14059
- }
14060
- static SetAutoUpdate(value) {
14061
- if (DefaultCameraSystem.cameraInstance != null && DefaultCameraSystem.cameraInstance.cameraController != null) {
14062
- DefaultCameraSystem.cameraInstance.cameraController.autoUpdate = value;
14063
- }
14064
- }
14065
- static IsAutoUpdateEnabled() {
14066
- let result = false;
14067
- if (DefaultCameraSystem.cameraInstance != null && DefaultCameraSystem.cameraInstance.cameraController != null) {
14068
- result = DefaultCameraSystem.cameraInstance.cameraController.autoUpdate;
14069
- }
14070
- return result;
14071
- }
14072
- static GetFollowTarget() {
14073
- return (DefaultCameraSystem.cameraInstance != null) ? DefaultCameraSystem.cameraInstance.setCameraTarget : null;
14074
- }
14075
- static SetFollowTarget(target) {
14076
- if (DefaultCameraSystem.cameraInstance != null) {
14077
- DefaultCameraSystem.cameraInstance.setCameraTarget = target;
14078
- }
14079
- }
14080
- static ResetFollowTarget() {
14081
- if (DefaultCameraSystem.cameraInstance != null) {
14082
- DefaultCameraSystem.cameraInstance.resetCameraRotation();
14083
- }
14084
- }
14085
- static UpdateFollowTarget() {
14086
- if (DefaultCameraSystem.cameraInstance != null) {
14087
- DefaultCameraSystem.cameraInstance.updateCameraController();
14088
- }
14089
- }
14090
- static GetWebXR() { return DefaultCameraSystem.XRExperienceHelper; }
14091
- static IsInWebXR() { return (DefaultCameraSystem.XRExperienceHelper != null && DefaultCameraSystem.XRExperienceHelper.baseExperience != null && DefaultCameraSystem.XRExperienceHelper.baseExperience.state === BABYLON.WebXRState.IN_XR); }
14092
- static SetupNavigationWebXR(mesh, tag) {
14093
- const webxr = DefaultCameraSystem.XRExperienceHelper;
14094
- if (webxr != null && webxr.teleportation != null && mesh != null && tag != null && tag != "") {
14095
- const hastag = BABYLON.Tags.MatchesQuery(mesh, tag);
14096
- if (hastag === true)
14097
- webxr.teleportation.addFloorMesh(mesh);
14098
- }
14099
- }
14100
- static GetMainCamera(scene, detach = false) {
14101
- return DefaultCameraSystem.GetPlayerCamera(scene, PlayerNumber.One, detach);
14102
- }
14103
- static GetPlayerCamera(scene, player = PlayerNumber.One, detach = false) {
14104
- let result = null;
14105
- let transform = DefaultCameraSystem.GetCameraTransform(scene, player);
14106
- if (DefaultCameraSystem.IsCameraSystemReady()) {
14107
- if (player === PlayerNumber.One && DefaultCameraSystem.PlayerOneCamera != null)
14108
- result = DefaultCameraSystem.PlayerOneCamera;
14109
- else if (player === PlayerNumber.Two && DefaultCameraSystem.PlayerTwoCamera != null)
14110
- result = DefaultCameraSystem.PlayerTwoCamera;
14111
- else if (player === PlayerNumber.Three && DefaultCameraSystem.PlayerThreeCamera != null)
14112
- result = DefaultCameraSystem.PlayerThreeCamera;
14113
- else if (player === PlayerNumber.Four && DefaultCameraSystem.PlayerFourCamera != null)
14114
- result = DefaultCameraSystem.PlayerFourCamera;
14115
- if (result != null && detach === true && parent != null) {
14116
- result.parent = null;
14117
- if (transform != null) {
14118
- result.position.copyFrom(transform.position);
14119
- result.rotationQuaternion = (transform.rotationQuaternion != null) ? transform.rotationQuaternion.clone() : BABYLON.Quaternion.FromEulerAngles(transform.rotation.x, transform.rotation.y, transform.rotation.z);
14120
- const children = transform.getChildren(null, true);
14121
- if (children != null) {
14122
- children.forEach((child) => { child.parent = result; });
14123
- }
14124
- }
14125
- }
14126
- }
14127
- return result;
14128
- }
14129
- static GetCameraTransform(scene, player = PlayerNumber.One) {
14130
- let result = null;
14131
- if (DefaultCameraSystem.IsCameraSystemReady()) {
14132
- if (player === PlayerNumber.One && DefaultCameraSystem.PlayerOneCamera != null && DefaultCameraSystem.PlayerOneCamera.transform != null)
14133
- result = DefaultCameraSystem.PlayerOneCamera.transform;
14134
- else if (player === PlayerNumber.Two && DefaultCameraSystem.PlayerTwoCamera != null && DefaultCameraSystem.PlayerTwoCamera.transform != null)
14135
- result = DefaultCameraSystem.PlayerTwoCamera.transform;
14136
- else if (player === PlayerNumber.Three && DefaultCameraSystem.PlayerThreeCamera != null && DefaultCameraSystem.PlayerThreeCamera.transform != null)
14137
- result = DefaultCameraSystem.PlayerThreeCamera.transform;
14138
- else if (player === PlayerNumber.Four && DefaultCameraSystem.PlayerFourCamera != null && DefaultCameraSystem.PlayerFourCamera.transform != null)
14139
- result = DefaultCameraSystem.PlayerFourCamera.transform;
14140
- }
14141
- return result;
14142
- }
14143
- static IsStereoCameras() {
14144
- return DefaultCameraSystem.stereoCameras;
14145
- }
14146
- static IsMultiPlayerView() {
14147
- return DefaultCameraSystem.multiPlayerView;
14148
- }
14149
- static GetMultiPlayerCount() {
14150
- return DefaultCameraSystem.multiPlayerCount;
14151
- }
14152
- static ActivateMultiPlayerCameras(scene) {
14153
- let result = false;
14154
- if (DefaultCameraSystem.multiPlayerCameras != null && DefaultCameraSystem.multiPlayerCameras.length > 0) {
14155
- scene.activeCameras = DefaultCameraSystem.multiPlayerCameras;
14156
- result = true;
14157
- }
14158
- return result;
14159
- }
14160
- static DisposeMultiPlayerCameras() {
14161
- if (DefaultCameraSystem.PlayerOneCamera != null) {
14162
- DefaultCameraSystem.PlayerOneCamera.dispose();
14163
- DefaultCameraSystem.PlayerOneCamera = null;
14164
- }
14165
- if (DefaultCameraSystem.PlayerTwoCamera != null) {
14166
- DefaultCameraSystem.PlayerTwoCamera.dispose();
14167
- DefaultCameraSystem.PlayerTwoCamera = null;
14168
- }
14169
- if (DefaultCameraSystem.PlayerThreeCamera != null) {
14170
- DefaultCameraSystem.PlayerThreeCamera.dispose();
14171
- DefaultCameraSystem.PlayerThreeCamera = null;
14172
- }
14173
- if (DefaultCameraSystem.PlayerFourCamera != null) {
14174
- DefaultCameraSystem.PlayerFourCamera.dispose();
14175
- DefaultCameraSystem.PlayerFourCamera = null;
14176
- }
14177
- }
14178
- static SetMultiPlayerViewLayout(scene, totalNumPlayers) {
14179
- let result = false;
14180
- let players = BABYLON.Scalar.Clamp(totalNumPlayers, 1, 4);
14181
- if (DefaultCameraSystem.IsMultiPlayerView()) {
14182
- if (DefaultCameraSystem.PlayerOneCamera != null && DefaultCameraSystem.PlayerTwoCamera != null && DefaultCameraSystem.PlayerThreeCamera != null && DefaultCameraSystem.PlayerFourCamera != null) {
14183
- DefaultCameraSystem.multiPlayerCameras = [];
14184
- if (players === 1) {
14185
- DefaultCameraSystem.PlayerOneCamera.viewport = new BABYLON.Viewport(0, 0, 1, 1);
14186
- DefaultCameraSystem.PlayerTwoCamera.viewport = new BABYLON.Viewport(0, 0, 0, 0);
14187
- DefaultCameraSystem.PlayerTwoCamera.setEnabled(false);
14188
- DefaultCameraSystem.PlayerThreeCamera.viewport = new BABYLON.Viewport(0, 0, 0, 0);
14189
- DefaultCameraSystem.PlayerThreeCamera.setEnabled(false);
14190
- DefaultCameraSystem.PlayerFourCamera.viewport = new BABYLON.Viewport(0, 0, 0, 0);
14191
- DefaultCameraSystem.PlayerFourCamera.setEnabled(false);
14192
- DefaultCameraSystem.multiPlayerCameras.push(DefaultCameraSystem.PlayerOneCamera);
14193
- }
14194
- else if (players === 2) {
14195
- if (DefaultCameraSystem.stereoCameras === true) {
14196
- DefaultCameraSystem.PlayerOneCamera.viewport = new BABYLON.Viewport(0, 0, 0.5, 1);
14197
- DefaultCameraSystem.PlayerTwoCamera.viewport = new BABYLON.Viewport(0.5, 0, 0.5, 1);
14198
- }
14199
- else {
14200
- DefaultCameraSystem.PlayerOneCamera.viewport = new BABYLON.Viewport(0, 0.5, 1, 0.5);
14201
- DefaultCameraSystem.PlayerTwoCamera.viewport = new BABYLON.Viewport(0, 0, 1, 0.5);
14202
- }
14203
- DefaultCameraSystem.PlayerTwoCamera.setEnabled(true);
14204
- DefaultCameraSystem.PlayerThreeCamera.viewport = new BABYLON.Viewport(0, 0, 0, 0);
14205
- DefaultCameraSystem.PlayerThreeCamera.setEnabled(false);
14206
- DefaultCameraSystem.PlayerFourCamera.viewport = new BABYLON.Viewport(0, 0, 0, 0);
14207
- DefaultCameraSystem.PlayerFourCamera.setEnabled(false);
14208
- DefaultCameraSystem.multiPlayerCameras.push(DefaultCameraSystem.PlayerOneCamera);
14209
- DefaultCameraSystem.multiPlayerCameras.push(DefaultCameraSystem.PlayerTwoCamera);
14210
- }
14211
- else if (players === 3) {
14212
- DefaultCameraSystem.PlayerOneCamera.viewport = new BABYLON.Viewport(0, 0, 0.5, 1);
14213
- DefaultCameraSystem.PlayerTwoCamera.viewport = new BABYLON.Viewport(0.5, 0.5, 0.5, 0.5);
14214
- DefaultCameraSystem.PlayerTwoCamera.setEnabled(true);
14215
- DefaultCameraSystem.PlayerThreeCamera.viewport = new BABYLON.Viewport(0.5, 0, 0.5, 0.5);
14216
- DefaultCameraSystem.PlayerThreeCamera.setEnabled(true);
14217
- DefaultCameraSystem.PlayerFourCamera.viewport = new BABYLON.Viewport(0, 0, 0, 0);
14218
- DefaultCameraSystem.PlayerFourCamera.setEnabled(false);
14219
- DefaultCameraSystem.multiPlayerCameras.push(DefaultCameraSystem.PlayerOneCamera);
14220
- DefaultCameraSystem.multiPlayerCameras.push(DefaultCameraSystem.PlayerTwoCamera);
14221
- DefaultCameraSystem.multiPlayerCameras.push(DefaultCameraSystem.PlayerThreeCamera);
14222
- }
14223
- else if (players === 4) {
14224
- DefaultCameraSystem.PlayerOneCamera.viewport = new BABYLON.Viewport(0, 0.5, 0.5, 0.5);
14225
- DefaultCameraSystem.PlayerTwoCamera.viewport = new BABYLON.Viewport(0, 0, 0.5, 0.5);
14226
- DefaultCameraSystem.PlayerTwoCamera.setEnabled(true);
14227
- DefaultCameraSystem.PlayerThreeCamera.viewport = new BABYLON.Viewport(0.5, 0.5, 0.5, 0.5);
14228
- DefaultCameraSystem.PlayerThreeCamera.setEnabled(true);
14229
- DefaultCameraSystem.PlayerFourCamera.viewport = new BABYLON.Viewport(0.5, 0, 0.5, 0.5);
14230
- DefaultCameraSystem.PlayerFourCamera.setEnabled(true);
14231
- DefaultCameraSystem.multiPlayerCameras.push(DefaultCameraSystem.PlayerOneCamera);
14232
- DefaultCameraSystem.multiPlayerCameras.push(DefaultCameraSystem.PlayerTwoCamera);
14233
- DefaultCameraSystem.multiPlayerCameras.push(DefaultCameraSystem.PlayerThreeCamera);
14234
- DefaultCameraSystem.multiPlayerCameras.push(DefaultCameraSystem.PlayerFourCamera);
14235
- }
14236
- else {
14237
- SceneManager.LogWarning("Babylon.js camera rig invalid player count specified: " + players);
14238
- }
14239
- }
14240
- else {
14241
- SceneManager.LogWarning("Babylon.js camera rig failed to initialize multi player cameras");
14242
- }
14243
- DefaultCameraSystem.multiPlayerCount = players;
14244
- result = DefaultCameraSystem.ActivateMultiPlayerCameras(scene);
14245
- if (result === false)
14246
- SceneManager.LogWarning("Babylon.js camera rig failed to initialize multi player views");
14247
- }
14248
- else {
14249
- SceneManager.LogWarning("Babylon.js camera rig multi player view option not enabled");
14250
- }
14251
- return result;
14252
- }
14253
- }
14254
- DefaultCameraSystem.PlayerOneCamera = null;
14255
- DefaultCameraSystem.PlayerTwoCamera = null;
14256
- DefaultCameraSystem.PlayerThreeCamera = null;
14257
- DefaultCameraSystem.PlayerFourCamera = null;
14258
- DefaultCameraSystem.XRExperienceHelper = null;
14259
- DefaultCameraSystem.multiPlayerView = false;
14260
- DefaultCameraSystem.multiPlayerCount = 1;
14261
- DefaultCameraSystem.multiPlayerCameras = null;
14262
- DefaultCameraSystem.stereoCameras = true;
14263
- DefaultCameraSystem.startupMode = 1;
14264
- DefaultCameraSystem.cameraReady = false;
14265
- DefaultCameraSystem.cameraInstance = null;
14266
- DefaultCameraSystem.OnXRExperienceHelperObservable = new BABYLON.Observable();
14267
- DefaultCameraSystem.FOLLOW_SPEED = 1.0;
14268
13554
  export class DebugInformation extends ScriptComponent {
14269
13555
  static GetVersion() { return SceneManager.Version; }
14270
13556
  constructor(transform, scene, properties = {}, alias = "PROJECT.DebugInformation") {
@@ -14757,2438 +14043,6 @@ export class MobileShadowMaterial extends ScriptComponent {
14757
14043
  }
14758
14044
  }
14759
14045
  }
14760
- export class RemotePlayerController extends ScriptComponent {
14761
- constructor(transform, scene, properties = {}, alias = "PROJECT.RemotePlayerController") {
14762
- super(transform, scene, properties, alias);
14763
- this.updateStateParams = true;
14764
- this.smoothMotionTime = 0;
14765
- this.smoothInputVectors = false;
14766
- this.animator = null;
14767
- this.animationStateParams = null;
14768
- }
14769
- awake() {
14770
- this.updateStateParams = this.getProperty("updateStateParams", this.updateStateParams);
14771
- this.smoothMotionTime = this.getProperty("smoothMotionTime", this.smoothMotionTime);
14772
- this.smoothInputVectors = this.getProperty("smoothInputVectors", this.smoothInputVectors);
14773
- this.animationStateParams = this.getProperty("animationStateParams", this.animationStateParams);
14774
- }
14775
- update() {
14776
- const deltaTime = this.getDeltaSeconds();
14777
- if (this.animator == null) {
14778
- this.attachAnimationController();
14779
- }
14780
- }
14781
- destroy() {
14782
- this.animator = null;
14783
- this.animationStateParams = null;
14784
- }
14785
- attachAnimationController() {
14786
- const animatorClass = Animator.ClassName;
14787
- this.animator = this.getComponent(animatorClass);
14788
- if (this.animator != null)
14789
- return;
14790
- const animationNode = this.getChildWithScript(animatorClass);
14791
- if (animationNode != null)
14792
- this.animator = SceneManager.FindScriptComponent(animationNode, animatorClass);
14793
- }
14794
- validateAnimationStateParams() {
14795
- if (this.animationStateParams == null) {
14796
- this.animationStateParams = {
14797
- moveDirection: "Direction",
14798
- inputMagnitude: "Magnitude",
14799
- horizontalInput: "Horizontal",
14800
- verticalInput: "Vertical",
14801
- mouseXInput: "MouseX",
14802
- mouseYInput: "MouseY",
14803
- heightInput: "Height",
14804
- speedInput: "Speed",
14805
- jumpFrame: "Jumped",
14806
- jumpState: "Jump",
14807
- actionState: "Action",
14808
- fallingState: "FreeFall",
14809
- slidingState: "Sliding",
14810
- groundedState: "Grounded"
14811
- };
14812
- }
14813
- }
14814
- }
14815
- export class StandardPlayerController extends ScriptComponent {
14816
- isAnimationEnabled() { return this.updateStateParams; }
14817
- isRunButtonPressed() { return this.isRunPressed; }
14818
- isJumpButtonPressed() { return this.isJumpPressed; }
14819
- getPlayerJumped() { return this.isCharacterJumpFrame; }
14820
- getPlayerJumping() { return this.isCharacterJumping; }
14821
- getPlayerFalling() { return this.isCharacterFalling; }
14822
- getPlayerSliding() { return this.isCharacterSliding; }
14823
- getPlayerGrounded() { return this.isCharacterGrounded; }
14824
- getFallTriggered() { return this.isCharacterFallTriggered; }
14825
- getMovementSpeed() { return this.movementSpeed; }
14826
- getCameraBoomNode() { return this.cameraNode; }
14827
- getCameraTransform() { return this.cameraPivot; }
14828
- getAnimator() { return this.animator; }
14829
- getVerticalVelocity() { return this.getCheckedVerticalVelocity(); }
14830
- getCharacterController() { return this.characterController; }
14831
- getPlayerLookRotation() { return this.playerLookRotation; }
14832
- getPlayerMoveDirection() { return this.playerMoveDirection; }
14833
- getInputMovementVector() { return this.inputMovementVector; }
14834
- getInputMagnitudeValue() { return this.inputMagnitude; }
14835
- getCameraPivotPosition() { return (this.cameraPivot != null) ? this.cameraPivot.position : null; }
14836
- getCameraPivotRotation() { return (this.cameraPivot != null) ? this.cameraPivot.rotationQuaternion : null; }
14837
- getClimbContact() { return this.climbContact; }
14838
- getClimbContactNode() { return this.climbContactNode; }
14839
- getClimbContactPoint() { return this.climbContactPoint; }
14840
- getClimbContactAngle() { return this.climbContactAngle; }
14841
- getClimbContactNormal() { return this.climbContactNormal; }
14842
- getClimbContactDistance() { return this.climbContactDistance; }
14843
- ;
14844
- getHeightContact() { return this.heightContact; }
14845
- getHeightContactNode() { return this.heightContactNode; }
14846
- getHeightContactPoint() { return this.heightContactPoint; }
14847
- getHeightContactAngle() { return this.heightContactAngle; }
14848
- getHeightContactNormal() { return this.heightContactNormal; }
14849
- getHeightContactDistance() { return this.heightContactDistance; }
14850
- ;
14851
- constructor(transform, scene, properties, alias = "PROJECT.StandardPlayerController") {
14852
- super(transform, scene, properties, alias);
14853
- this.enableInput = false;
14854
- this.attachCamera = false;
14855
- this.rotateCamera = true;
14856
- this.mouseWheel = true;
14857
- this.toggleView = true;
14858
- this.freeLooking = false;
14859
- this.requireSprintButton = false;
14860
- this.gravitationalForce = 3.0;
14861
- this.minFallVelocity = 1.0;
14862
- this.verticalStepSpeed = 1.0;
14863
- this.minStepUpHeight = 0.15;
14864
- this.rigidBodyMass = 85.0;
14865
- this.airbornTimeout = 0.5;
14866
- this.maxAngle = 45;
14867
- this.speedFactor = 1.0;
14868
- this.rootMotion = false;
14869
- this.moveSpeed = 5.335;
14870
- this.walkSpeed = 2.0;
14871
- this.lookSpeed = 2.0;
14872
- this.jumpSpeed = 10.0;
14873
- this.jumpDelay = 0.25;
14874
- this.eyesHeight = 1.55;
14875
- this.pivotHeight = 1.35;
14876
- this.maxDistance = 5.0;
14877
- this.scrollSpeed = 25;
14878
- this.topLookLimit = 60.0;
14879
- this.downLookLimit = 30.0;
14880
- this.lowTurnSpeed = 15.0;
14881
- this.highTurnSpeed = 25.0;
14882
- this.smoothDampTime = 0;
14883
- this.smoothInputVectors = false;
14884
- this.smoothAcceleration = false;
14885
- this.accelerationSpeed = 0.1;
14886
- this.decelerationSpeed = 0.1;
14887
- this.avatarSkinTag = "Skin";
14888
- this.climbVolumeTag = "Climb";
14889
- this.vaultVolumeTag = "Vault";
14890
- this.maxHeightRanges = null;
14891
- this.useClimbSystem = false;
14892
- this.distanceFactor = 0.85;
14893
- this.cameraSmoothing = 8;
14894
- this.cameraCollisions = true;
14895
- this.inputMagnitude = 0;
14896
- this.analogMovement = false;
14897
- this.landingEpsilon = 0.1;
14898
- this.minimumDistance = 0.5;
14899
- this.movementAllowed = true;
14900
- this.playerInputX = 0;
14901
- this.playerInputZ = 0;
14902
- this.playerMouseX = 0;
14903
- this.playerMouseY = 0;
14904
- this.runKeyRequired = true;
14905
- this.buttonRun = BABYLON.Xbox360Button.LeftStick;
14906
- this.keyboardRun = UserInputKey.Shift;
14907
- this.buttonJump = BABYLON.Xbox360Button.A;
14908
- this.keyboardJump = UserInputKey.SpaceBar;
14909
- this.buttonCamera = BABYLON.Xbox360Button.Y;
14910
- this.keyboardCamera = UserInputKey.P;
14911
- this.postNetworkAttributes = false;
14912
- this.playerNumber = PlayerNumber.One;
14913
- this.boomPosition = new BABYLON.Vector3(0, 0, 0);
14914
- this.airbornVelocity = new BABYLON.Vector3(0, 0, 0);
14915
- this.movementVelocity = new BABYLON.Vector3(0, 0, 0);
14916
- this.targetCameraOffset = new BABYLON.Vector3(0, 0, 0);
14917
- this.rayClimbOffset = 0.35;
14918
- this.rayClimbLength = 0.85;
14919
- this.canClimbObstaclePredicate = null;
14920
- this.rayHeightOffset = 5.0;
14921
- this.rayHeightLength = 6.0;
14922
- this.abstractMesh = null;
14923
- this.cameraDistance = 0;
14924
- this.forwardCamera = true;
14925
- this.avatarRadius = 0.5;
14926
- this.groundingObject = null;
14927
- this.groundingCallback = null;
14928
- this.dollyDirection = new BABYLON.Vector3(0, 0, 0);
14929
- this.cameraEulers = new BABYLON.Vector3(0, 0, 0);
14930
- this.rotationEulers = new BABYLON.Vector3(0, 0, 0);
14931
- this.cameraPivotOffset = new BABYLON.Vector3(0, 0, 0);
14932
- this.cameraForwardVector = new BABYLON.Vector3(0, 0, 0);
14933
- this.cameraRightVector = new BABYLON.Vector3(0, 0, 0);
14934
- this.desiredForwardVector = new BABYLON.Vector3(0, 0, 0);
14935
- this.desiredRightVector = new BABYLON.Vector3(0, 0, 0);
14936
- this.lastRotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
14937
- this.scaledCamDirection = new BABYLON.Vector3(0, 0, 0);
14938
- this.scaledMaxDirection = new BABYLON.Vector3(0, 0, 0);
14939
- this.parentNodePosition = new BABYLON.Vector3(0, 0, 0);
14940
- this.maximumCameraPos = new BABYLON.Vector3(0, 0, 0);
14941
- this.tempWorldPosition = new BABYLON.Vector3(0, 0, 0);
14942
- this.cameraRaycastShape = null;
14943
- this.defaultRaycastGroup = CollisionFilters.DefaultFilter;
14944
- this.defaultRaycastMask = CollisionFilters.StaticFilter;
14945
- this.cameraRaycastMask = (CollisionFilters.DefaultFilter | CollisionFilters.StaticFilter | CollisionFilters.KinematicFilter);
14946
- this.avatarSkins = null;
14947
- this.cameraNode = null;
14948
- this.cameraPivot = null;
14949
- this.navigationAgent = null;
14950
- this.characterController = null;
14951
- this.verticalVelocity = 0;
14952
- this.smoothMotionSpeed = false;
14953
- this.movementSpeed = 0;
14954
- this.isRunPressed = false;
14955
- this.isJumpPressed = false;
14956
- this.isCharacterSliding = false;
14957
- this.isCharacterFalling = false;
14958
- this.isCharacterGrounded = false;
14959
- this.isCharacterFallTriggered = false;
14960
- this.isCharacterJumpFrame = false;
14961
- this.isCharacterJumping = false;
14962
- this.isCharacterLanding = false;
14963
- this.isCharacterRising = false;
14964
- this.isCharacterNavigating = false;
14965
- this.navigationAngularSpeed = 0;
14966
- this.updateStateParams = true;
14967
- this.animationStateParams = null;
14968
- this.sphereCollisionShape = null;
14969
- this.hasGroundedContact = false;
14970
- this.showDebugColliders = false;
14971
- this.colliderVisibility = 0;
14972
- this.colliderRenderGroup = 0;
14973
- this.groundCheckDistance = 0.25;
14974
- this.deltaTime = 0;
14975
- this.minJumpTimer = 0;
14976
- this.delayJumpTimer = 0;
14977
- this.playerControl = 0;
14978
- this.canPlayerJump = true;
14979
- this.animator = null;
14980
- this.lastJumpVelocity = new BABYLON.Vector3(0, 0, 0);
14981
- this.inputMovementVector = new BABYLON.Vector3(0, 0, 0);
14982
- this.playerLookRotation = new BABYLON.Vector3(0, 0, 0);
14983
- this.playerRotationVector = BABYLON.Vector2.Zero();
14984
- this.playerMovementVelocity = new BABYLON.Vector3(0, 0, 0);
14985
- this.playerRotationQuaternion = BABYLON.Quaternion.Zero();
14986
- this.playerMoveDirection = PlayerMoveDirection.Stationary;
14987
- this.forwardDirection = new BABYLON.Vector3(0, 0, 1);
14988
- this.downDirection = new BABYLON.Vector3(0, -1, 0);
14989
- this.climbContact = false;
14990
- this.climbContactNode = null;
14991
- this.climbContactAngle = 0;
14992
- this.climbContactPoint = new BABYLON.Vector3(0, 0, 0);
14993
- this.climbContactNormal = new BABYLON.Vector3(0, 0, 0);
14994
- this.climbContactDistance = 0;
14995
- this.climbSensorLine = null;
14996
- this.offsetClimbRaycastPosition = new BABYLON.Vector3(0, 0, 0);
14997
- this.startClimbRaycastPosition = new BABYLON.Vector3(0, 0, 0);
14998
- this.endClimbRaycastPosition = new BABYLON.Vector3(0, 0, 0);
14999
- this.heightContact = false;
15000
- this.heightContactNode = null;
15001
- this.heightContactAngle = 0;
15002
- this.heightContactPoint = new BABYLON.Vector3(0, 0, 0);
15003
- this.heightContactNormal = new BABYLON.Vector3(0, 0, 0);
15004
- this.heightContactDistance = 0;
15005
- this.heightSensorLine = null;
15006
- this.offsetHeightRaycastPosition = new BABYLON.Vector3(0, 0, 0);
15007
- this.startHeightRaycastPosition = new BABYLON.Vector3(0, 0, 0);
15008
- this.endHeightRaycastPosition = new BABYLON.Vector3(0, 0, 0);
15009
- this.m_velocityOffset = new BABYLON.Vector3(0, 0, 0);
15010
- this.m_actualVelocity = new BABYLON.Vector3(0, 0, 0);
15011
- this.m_linearVelocity = new BABYLON.Vector3(0, 0, 0);
15012
- this.m_lastPosition = new BABYLON.Vector3(0, 0, 0);
15013
- this.m_positionCenter = new BABYLON.Vector3(0, 0, 0);
15014
- this.m_scaledVelocity = 0;
15015
- this.playerDrawVelocity = 0;
15016
- this.onPreUpdateObservable = new BABYLON.Observable();
15017
- this.onBeforeMoveObservable = new BABYLON.Observable();
15018
- this.onPostUpdateObservable = new BABYLON.Observable();
15019
- this.onPlayerInputObservable = new BABYLON.Observable();
15020
- this.onPlayerPositionObservable = new BABYLON.Observable();
15021
- this.onUpdateActionObservable = new BABYLON.Observable();
15022
- this.animatorMoveObserver = null;
15023
- this.exportedApplyRootMotion = false;
15024
- this.rootMotionVelocity = new BABYLON.Vector3(0, 0, 0);
15025
- this.isPerformingAction = false;
15026
- this.isRootMotionAction = false;
15027
- this.isActionInterruptable = false;
15028
- this.afterActionHandler = null;
15029
- this.performActionTimer = 0;
15030
- this.performActionNumber = 0;
15031
- this.playerRotationSpeed = 10;
15032
- this.rotatePlayerTowards = false;
15033
- this.matchStartTime = 0;
15034
- this.matchTargetTime = 0;
15035
- this.matchTargetOffset = 0;
15036
- this.matchTargetHeight = false;
15037
- this.lockTargetHeight = false;
15038
- this.lastStartHeight = null;
15039
- this.lastTargetHeight = null;
15040
- this.lastTargetNormal = new BABYLON.Vector3(0, 0, 0);
15041
- this.lastTargetRotation = new BABYLON.Quaternion(0, 0, 0, 1);
15042
- this.lastDeltaPosition = new BABYLON.Vector3(0, 0, 0);
15043
- this.lastDeltaRotation = new BABYLON.Quaternion(0, 0, 0, 1);
15044
- this.smoothedPlayerHeight = 0;
15045
- this.playerHeightVelocity = new BABYLON.Vector2(0, 0);
15046
- this.actionStateHash = 0;
15047
- this.actionStateEntered = false;
15048
- this.ikLeftFootTarget = null;
15049
- this.ikLeftPoleTarget = null;
15050
- this.ikRightFootTarget = null;
15051
- this.ikRightPoleTarget = null;
15052
- this.abstractSkinMesh = null;
15053
- this.rootBoneTransform = null;
15054
- this.leftFootTransform = null;
15055
- this.leftFootPoleOffset = new BABYLON.Vector3(-0.1, 0.5, 0.5);
15056
- this.leftFootMaxAngle = 90;
15057
- this.rightFootTransform = null;
15058
- this.rightFootPoleOffset = new BABYLON.Vector3(0.1, 0.5, 0.5);
15059
- this.rightFootMaxAngle = 90;
15060
- this.ikLeftController = null;
15061
- this.ikRightController = null;
15062
- this.onAnimatorIK = null;
15063
- this.smoothBoomArmLength = null;
15064
- this.smoothBoomArmSpeed = null;
15065
- }
15066
- awake() { this.awakePlayerController(); }
15067
- start() { this.startPlayerController(); }
15068
- after() { this.afterPlayerController(); }
15069
- update() { this.updatePlayerController(); }
15070
- destroy() { this.destroyPlayerController(); }
15071
- syncAnimatorMoveTaker() {
15072
- if (this.animator == null)
15073
- return;
15074
- const takesRootMotion = this.rootMotion === true || this.isRootMotionAction === true;
15075
- this.animator.applyRootMotion = takesRootMotion || this.exportedApplyRootMotion;
15076
- if (takesRootMotion && this.animatorMoveObserver == null) {
15077
- this.animatorMoveObserver = this.animator.onAnimatorMoveObservable.add((animator) => this.onAnimatorMove(animator));
15078
- return;
15079
- }
15080
- if (!takesRootMotion && this.animatorMoveObserver != null) {
15081
- this.animator.onAnimatorMoveObservable.remove(this.animatorMoveObserver);
15082
- this.animatorMoveObserver = null;
15083
- }
15084
- }
15085
- onAnimatorMove(animator) {
15086
- if (this.isPerformingAction === true && this.isRootMotionAction === true) {
15087
- this.applyActionRootMotion(animator);
15088
- return;
15089
- }
15090
- const velocity = animator.velocity;
15091
- this.rootMotionVelocity.set(velocity.x, 0, velocity.z);
15092
- }
15093
- getIsPerformingAction() { return this.isPerformingAction; }
15094
- getIsRootMotionAction() { return this.isRootMotionAction; }
15095
- getIsActionInterruptable() { return this.isActionInterruptable; }
15096
- playActionAnimation(action, interruptableAction = true, enableRootMotion = false, afterActionComplete = null) {
15097
- if (this.isPerformingAction === false && this.animator != null && action >= 0) {
15098
- this.isPerformingAction = true;
15099
- this.performActionTimer = 0;
15100
- this.performActionNumber = action;
15101
- this.afterActionHandler = afterActionComplete;
15102
- this.isActionInterruptable = interruptableAction;
15103
- this.isRootMotionAction = enableRootMotion;
15104
- this.playerRotationSpeed = 10;
15105
- this.rotatePlayerTowards = false;
15106
- this.matchStartTime = 0;
15107
- this.matchTargetTime = 0;
15108
- this.matchTargetOffset = 0;
15109
- this.matchTargetHeight = false;
15110
- this.lockTargetHeight = false;
15111
- this.lastStartHeight = null;
15112
- this.lastTargetHeight = null;
15113
- this.lastTargetNormal.set(0, 0, 0);
15114
- this.lastTargetRotation.set(0, 0, 0, 1);
15115
- this.actionStateEntered = false;
15116
- this.syncAnimatorMoveTaker();
15117
- if (this.isRootMotionAction === true) {
15118
- this.enableCharacterController(false);
15119
- }
15120
- }
15121
- }
15122
- resetActionAnimationState() {
15123
- if (this.afterActionHandler != null) {
15124
- try {
15125
- this.afterActionHandler();
15126
- }
15127
- catch { }
15128
- }
15129
- if (this.isRootMotionAction === true) {
15130
- this.enableCharacterController(true);
15131
- }
15132
- this.performActionTimer = 0;
15133
- this.performActionNumber = 0;
15134
- this.isPerformingAction = false;
15135
- this.isRootMotionAction = false;
15136
- this.isActionInterruptable = false;
15137
- this.afterActionHandler = null;
15138
- this.playerRotationSpeed = 10;
15139
- this.rotatePlayerTowards = false;
15140
- this.matchStartTime = 0;
15141
- this.matchTargetTime = 0;
15142
- this.matchTargetOffset = 0;
15143
- this.matchTargetHeight = false;
15144
- this.lockTargetHeight = false;
15145
- this.lastStartHeight = null;
15146
- this.lastTargetHeight = null;
15147
- this.lastTargetNormal.set(0, 0, 0);
15148
- this.lastTargetRotation.set(0, 0, 0, 1);
15149
- this.actionStateEntered = false;
15150
- this.syncAnimatorMoveTaker();
15151
- }
15152
- updateAnimationActionState() {
15153
- this.performActionTimer += this.getDeltaSeconds();
15154
- }
15155
- applyActionRootMotion(animator) {
15156
- const deltaTime = this.getDeltaSeconds();
15157
- this.lastDeltaPosition.copyFrom(animator.deltaPosition);
15158
- if (this.matchTargetHeight === true)
15159
- this.applyHeightMatch(deltaTime);
15160
- this.transform.position.addInPlace(this.lastDeltaPosition);
15161
- if (this.rotatePlayerTowards === true) {
15162
- this.rotateTowardsClimbSurface(deltaTime);
15163
- return;
15164
- }
15165
- this.lastDeltaRotation.copyFrom(animator.deltaRotation);
15166
- this.transform.rotationQuaternion.multiplyInPlace(this.lastDeltaRotation);
15167
- }
15168
- applyHeightMatch(deltaTime) {
15169
- const playerGlobalHeight = this.transform.absolutePosition.y;
15170
- if (this.lastStartHeight == null && this.performActionTimer >= this.matchStartTime) {
15171
- this.lastStartHeight = playerGlobalHeight;
15172
- this.smoothedPlayerHeight = playerGlobalHeight;
15173
- this.playerHeightVelocity.set(0, 0);
15174
- }
15175
- if (this.lastStartHeight == null || this.lastTargetHeight == null)
15176
- return;
15177
- this.lastDeltaPosition.y = 0;
15178
- const fixedTargetHeight = this.lastTargetHeight + this.matchTargetOffset;
15179
- if (this.performActionTimer < this.matchTargetTime) {
15180
- const dampTime = this.matchTargetTime - this.matchStartTime;
15181
- this.smoothedPlayerHeight = Utilities.SmoothDamp(this.smoothedPlayerHeight, fixedTargetHeight, dampTime, Number.POSITIVE_INFINITY, deltaTime, this.playerHeightVelocity);
15182
- this.lastDeltaPosition.y = this.smoothedPlayerHeight - playerGlobalHeight;
15183
- return;
15184
- }
15185
- if (this.lockTargetHeight === false) {
15186
- this.lastDeltaPosition.y = fixedTargetHeight - playerGlobalHeight;
15187
- this.lockTargetHeight = true;
15188
- }
15189
- }
15190
- rotateTowardsClimbSurface(deltaTime) {
15191
- if (this.climbContact !== true)
15192
- return;
15193
- this.lastTargetNormal.set(-this.climbContactNormal.x, -this.climbContactNormal.y, -this.climbContactNormal.z);
15194
- Utilities.LookRotationToRef(this.lastTargetNormal, this.lastTargetRotation);
15195
- const lerpAmount = BABYLON.Scalar.Clamp(this.playerRotationSpeed * deltaTime);
15196
- BABYLON.Quaternion.SlerpToRef(this.transform.rotationQuaternion, this.lastTargetRotation, lerpAmount, this.transform.rotationQuaternion);
15197
- }
15198
- setWorldPosition(x, y, z) {
15199
- if (this.characterController != null) {
15200
- this.characterController.set(x, y, z);
15201
- }
15202
- }
15203
- setPlayerControl(mode) {
15204
- this.playerControl = mode;
15205
- if (this.playerControl === PlayerInputControl.ThirdPersonStrafing) {
15206
- this.showAvatarSkins(true);
15207
- }
15208
- else {
15209
- this.showAvatarSkins(false);
15210
- }
15211
- this.forwardCamera = false;
15212
- }
15213
- togglePlayerControl() {
15214
- if (this.toggleView === true) {
15215
- if (this.playerControl === PlayerInputControl.FirstPersonStrafing) {
15216
- this.setPlayerControl(PlayerInputControl.ThirdPersonStrafing);
15217
- }
15218
- else {
15219
- this.setPlayerControl(PlayerInputControl.FirstPersonStrafing);
15220
- }
15221
- }
15222
- }
15223
- showAvatarSkins(show) {
15224
- if (this.avatarSkins != null) {
15225
- this.avatarSkins.forEach((skin) => { skin.isVisible = show; });
15226
- }
15227
- }
15228
- attachPlayerCamera(player) {
15229
- if (this.cameraNode == null) {
15230
- const playerCamera = (player <= 0 || player > 4) ? 1 : player;
15231
- this.cameraNode = DefaultCameraSystem.GetCameraTransform(this.scene, playerCamera);
15232
- if (this.cameraNode != null) {
15233
- this.cameraNode.parent = this.cameraPivot;
15234
- this.cameraNode.position.copyFrom(this.boomPosition);
15235
- this.cameraNode.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
15236
- this.cameraDistance = this.cameraNode.position.length();
15237
- this.dollyDirection.copyFrom(this.cameraNode.position);
15238
- this.dollyDirection.normalize();
15239
- }
15240
- else {
15241
- }
15242
- }
15243
- }
15244
- getPlayerMesh() { return this.abstractSkinMesh; }
15245
- getRootHipBone() { return (this.rootBoneTransform != null) ? this.rootBoneTransform._linkedBone : null; }
15246
- getLeftFootBone() { return (this.leftFootTransform != null) ? this.leftFootTransform._linkedBone : null; }
15247
- getRightFootBone() { return (this.rightFootTransform != null) ? this.rightFootTransform._linkedBone : null; }
15248
- getLeftFootTarget() { return this.ikLeftFootTarget; }
15249
- getRightFootTarget() { return this.ikRightFootTarget; }
15250
- getLeftFootPoleTarget() { return this.ikLeftPoleTarget; }
15251
- getRightFootPoleTarget() { return this.ikRightPoleTarget; }
15252
- getRootBoneTransform() { return this.rootBoneTransform; }
15253
- getLeftFootTransform() { return this.leftFootTransform; }
15254
- getRightFootTransform() { return this.rightFootTransform; }
15255
- getLeftFootController() { return this.ikLeftController; }
15256
- getRightFootController() { return this.ikRightController; }
15257
- isGroundedFootIKActive() { return (this.isCharacterGrounded === true && this.animator != null && this.animator.hasIKPassLayer()); }
15258
- setupBoneControllers() {
15259
- const createFootIKRig = this.getProperty("createFootIKRig");
15260
- if (createFootIKRig === true) {
15261
- const displayHandles = this.getProperty("displayHandles");
15262
- const abstractSkinMeshData = this.getProperty("abstractSkinMesh");
15263
- if (abstractSkinMeshData != null)
15264
- this.abstractSkinMesh = this.getChildNode(abstractSkinMeshData.name, SearchType.ExactMatch, false);
15265
- const rootBoneTransformData = this.getProperty("rootBoneTransform");
15266
- if (rootBoneTransformData != null)
15267
- this.rootBoneTransform = this.getChildNode(rootBoneTransformData.name, SearchType.ExactMatch, false);
15268
- const leftFootTransformData = this.getProperty("leftFootTransform");
15269
- if (leftFootTransformData != null)
15270
- this.leftFootTransform = this.getChildNode(leftFootTransformData.name, SearchType.ExactMatch, false);
15271
- const leftPoleHandleData = this.getProperty("leftFootPoleOffset");
15272
- if (leftPoleHandleData != null)
15273
- this.leftFootPoleOffset.copyFrom(Utilities.ParseVector3(leftPoleHandleData));
15274
- this.leftFootMaxAngle = this.getProperty("leftFootMaxAngle", this.leftFootMaxAngle);
15275
- const rightFootTransformData = this.getProperty("rightFootTransform");
15276
- if (rightFootTransformData != null)
15277
- this.rightFootTransform = this.getChildNode(rightFootTransformData.name, SearchType.ExactMatch, false);
15278
- const rightPoleHandleData = this.getProperty("rightFootPoleOffset");
15279
- if (rightPoleHandleData != null)
15280
- this.rightFootPoleOffset.copyFrom(Utilities.ParseVector3(rightPoleHandleData));
15281
- this.rightFootMaxAngle = this.getProperty("rightFootMaxAngle", this.rightFootMaxAngle);
15282
- if (this.abstractSkinMesh != null && this.rootBoneTransform != null) {
15283
- let materialName = "M_TARGET_MESH";
15284
- let targetMaterial = this.scene.getMaterialByName(materialName);
15285
- if (targetMaterial == null) {
15286
- targetMaterial = new BABYLON.StandardMaterial("M_TARGET_MESH", this.scene);
15287
- targetMaterial.diffuseColor = new BABYLON.Color3(1.0, 0.5, 0.25);
15288
- }
15289
- if (this.leftFootTransform != null && this.leftFootTransform._linkedBone != null) {
15290
- this.ikLeftFootTarget = BABYLON.MeshBuilder.CreateBox(this.transform.name + ".LeftFootTarget", { width: 0.1, height: 0.1, depth: 0.1 }, this.scene);
15291
- this.ikLeftFootTarget.parent = this.leftFootTransform;
15292
- this.ikLeftFootTarget.position.set(0, 0, 0);
15293
- this.ikLeftFootTarget.material = targetMaterial;
15294
- this.ikLeftFootTarget.isVisible = displayHandles;
15295
- this.ikLeftPoleTarget = BABYLON.MeshBuilder.CreateSphere(this.transform.name + ".LeftFootPole", { diameter: 0.1 }, this.scene);
15296
- this.ikLeftPoleTarget.parent = this.abstractSkinMesh;
15297
- this.ikLeftPoleTarget.position.copyFrom(this.leftFootPoleOffset);
15298
- this.ikLeftPoleTarget.isVisible = displayHandles;
15299
- }
15300
- if (this.rightFootTransform != null && this.rightFootTransform._linkedBone != null) {
15301
- this.ikRightFootTarget = BABYLON.MeshBuilder.CreateBox(this.transform.name + ".RightFootTarget", { width: 0.1, height: 0.1, depth: 0.1 }, this.scene);
15302
- this.ikRightFootTarget.parent = this.rightFootTransform;
15303
- this.ikRightFootTarget.position.set(0, 0, 0);
15304
- this.ikRightFootTarget.material = targetMaterial;
15305
- this.ikRightFootTarget.isVisible = displayHandles;
15306
- this.ikRightPoleTarget = BABYLON.MeshBuilder.CreateSphere(this.transform.name + ".RightFootPole", { diameter: 0.1 }, this.scene);
15307
- this.ikRightPoleTarget.parent = this.abstractSkinMesh;
15308
- this.ikRightPoleTarget.position.copyFrom(this.rightFootPoleOffset);
15309
- this.ikRightPoleTarget.isVisible = displayHandles;
15310
- }
15311
- }
15312
- }
15313
- }
15314
- attachAnimationController() {
15315
- if (this.animator == null)
15316
- this.animator = this.getComponent(Animator.ClassName, true);
15317
- if (this.animator == null)
15318
- return;
15319
- this.exportedApplyRootMotion = this.animator.applyRootMotion;
15320
- this.animator.onStateEnterObservable.add((change) => this.onAnimatorStateEnter(change));
15321
- this.animator.onStateExitObservable.add((change) => this.onAnimatorStateExit(change));
15322
- this.animator.onAnimatorIKObservable.add(() => this.onAnimatorIKPass());
15323
- this.syncAnimatorMoveTaker();
15324
- }
15325
- onAnimatorStateEnter(change) {
15326
- if (this.isPerformingAction !== true || this.actionStateEntered === true || change.layerIndex !== 0)
15327
- return;
15328
- this.actionStateHash = change.stateInfo.fullPathHash;
15329
- this.actionStateEntered = true;
15330
- }
15331
- onAnimatorStateExit(change) {
15332
- if (this.isPerformingAction !== true || this.actionStateEntered !== true)
15333
- return;
15334
- if (change.layerIndex !== 0 || change.stateInfo.fullPathHash !== this.actionStateHash)
15335
- return;
15336
- this.resetActionAnimationState();
15337
- }
15338
- onAnimatorIKPass() {
15339
- if (this.onAnimatorIK != null) {
15340
- this.onAnimatorIK();
15341
- return;
15342
- }
15343
- this.updateAnimatorTargetMeshes();
15344
- if (this.ikLeftController != null)
15345
- this.ikLeftController.update();
15346
- if (this.ikRightController != null)
15347
- this.ikRightController.update();
15348
- }
15349
- updateAnimatorTargetMeshes() {
15350
- }
15351
- enableCharacterController(state) {
15352
- if (state === true) {
15353
- this.movementAllowed = true;
15354
- this.resetPlayerJumpingState();
15355
- if (this.characterController != null) {
15356
- this.characterController.setGravityFactor(this.gravitationalForce);
15357
- this.characterController.setCollisionState(true);
15358
- }
15359
- }
15360
- else {
15361
- this.movementAllowed = false;
15362
- this.resetPlayerJumpingState();
15363
- if (this.characterController != null) {
15364
- this.characterController.setGravityFactor(0);
15365
- this.characterController.setCollisionState(false);
15366
- }
15367
- }
15368
- }
15369
- resetPlayerRotation() {
15370
- this.transform.rotationQuaternion.toEulerAnglesToRef(this.rotationEulers);
15371
- this.playerRotationVector.x = this.rotationEulers.x;
15372
- this.playerRotationVector.y = this.rotationEulers.y;
15373
- }
15374
- resetPlayerJumpingState() {
15375
- this.minJumpTimer = 0;
15376
- this.isCharacterJumping = false;
15377
- this.isCharacterLanding = false;
15378
- this.isCharacterRising = false;
15379
- this.isCharacterJumpFrame = false;
15380
- if (this.characterController != null) {
15381
- this.characterController.jump(0);
15382
- }
15383
- }
15384
- awakePlayerController() {
15385
- this.gravitationalForce = this.getProperty("gravityMultiplier", this.gravitationalForce);
15386
- this.verticalStepSpeed = this.getProperty("stepUpVelocity", this.verticalStepSpeed);
15387
- this.minStepUpHeight = this.getProperty("minStepHeight", this.minStepUpHeight);
15388
- this.rigidBodyMass = this.getProperty("rigidBodyMass", this.rigidBodyMass);
15389
- this.rotateCamera = this.getProperty("rotateCamera", this.rotateCamera);
15390
- this.mouseWheel = this.getProperty("mouseWheel", this.mouseWheel);
15391
- this.rayClimbLength = this.getProperty("rayClimbLength", this.rayClimbLength);
15392
- this.rayClimbOffset = this.getProperty("rayClimbOffset", this.rayClimbOffset);
15393
- this.rayHeightLength = this.getProperty("rayHeightLength", this.rayHeightLength);
15394
- this.rayHeightOffset = this.getProperty("rayHeightOffset", this.rayHeightOffset);
15395
- this.maxAngle = this.getProperty("maxAngle", this.maxAngle);
15396
- this.landingEpsilon = this.getProperty("landingEpsilon", this.landingEpsilon);
15397
- this.minFallVelocity = this.getProperty("minFallVelocity", this.minFallVelocity);
15398
- this.airbornTimeout = this.getProperty("airbornTimeout", this.airbornTimeout);
15399
- this.rootMotion = this.getProperty("rootMotion", this.rootMotion);
15400
- this.moveSpeed = this.getProperty("moveSpeed", this.moveSpeed);
15401
- this.walkSpeed = this.getProperty("walkSpeed", this.walkSpeed);
15402
- this.lookSpeed = this.getProperty("lookSpeed", this.lookSpeed);
15403
- this.jumpSpeed = this.getProperty("jumpSpeed", this.jumpSpeed);
15404
- this.jumpDelay = this.getProperty("jumpDelay", this.jumpDelay);
15405
- this.eyesHeight = this.getProperty("eyesHeight", this.eyesHeight);
15406
- this.pivotHeight = this.getProperty("pivotHeight", this.pivotHeight);
15407
- this.maxDistance = this.getProperty("maxDistance", this.maxDistance);
15408
- this.scrollSpeed = this.getProperty("scrollSpeed", this.scrollSpeed);
15409
- this.topLookLimit = this.getProperty("topLookLimit", this.topLookLimit);
15410
- this.downLookLimit = this.getProperty("downLookLimit", this.downLookLimit);
15411
- this.lowTurnSpeed = this.getProperty("lowTurnSpeed", this.lowTurnSpeed);
15412
- this.highTurnSpeed = this.getProperty("highTurnSpeed", this.highTurnSpeed);
15413
- this.enableInput = this.getProperty("enableInput", this.enableInput);
15414
- this.playerNumber = this.getProperty("playerNumber", this.playerNumber);
15415
- this.attachCamera = this.getProperty("attachCamera", this.attachCamera);
15416
- this.freeLooking = this.getProperty("freeLooking", this.freeLooking);
15417
- this.toggleView = this.getProperty("toggleView", this.toggleView);
15418
- this.avatarSkinTag = this.getProperty("avatarSkinTag", this.avatarSkinTag);
15419
- this.runKeyRequired = this.getProperty("runKeyRequired", this.runKeyRequired);
15420
- this.cameraCollisions = this.getProperty("cameraCollisions", this.cameraCollisions);
15421
- this.cameraSmoothing = this.getProperty("cameraSmoothing", this.cameraSmoothing);
15422
- this.distanceFactor = this.getProperty("distanceFactor", this.distanceFactor);
15423
- this.minimumDistance = this.getProperty("minimumDistance", this.minimumDistance);
15424
- this.smoothDampTime = this.getProperty("smoothDampTime", this.smoothDampTime);
15425
- this.smoothInputVectors = this.getProperty("smoothInputVectors", this.smoothInputVectors);
15426
- this.smoothAcceleration = this.getProperty("smoothAcceleration", this.smoothAcceleration);
15427
- this.accelerationSpeed = this.getProperty("accelerationSpeed", this.accelerationSpeed);
15428
- this.decelerationSpeed = this.getProperty("decelerationSpeed", this.decelerationSpeed);
15429
- this.climbVolumeTag = this.getProperty("climbVolumeTag", this.climbVolumeTag);
15430
- this.vaultVolumeTag = this.getProperty("vaultVolumeTag", this.vaultVolumeTag);
15431
- this.useClimbSystem = this.getProperty("useClimbSystem", this.useClimbSystem);
15432
- this.maxHeightRanges = this.getProperty("maxHeightRanges", this.maxHeightRanges);
15433
- this.smoothMotionSpeed = this.getProperty("smoothMotionSpeed", this.smoothMotionSpeed);
15434
- this.updateStateParams = this.getProperty("updateStateParams", this.updateStateParams);
15435
- this.animationStateParams = this.getProperty("animationStateParams", this.animationStateParams);
15436
- this.analogMovement = this.getProperty("analogMovement", this.analogMovement);
15437
- this.postNetworkAttributes = this.getProperty("postNetworkAttribs", this.postNetworkAttributes);
15438
- this.groundCheckDistance = this.getProperty("groundCheckDist", this.groundCheckDistance);
15439
- const arrowKeyRotation = this.getProperty("arrowKeyRotation");
15440
- if (arrowKeyRotation === true)
15441
- UserInputOptions.UseArrowKeyRotation = true;
15442
- const boomPositionData = this.getProperty("boomPosition");
15443
- if (boomPositionData != null)
15444
- this.boomPosition = Utilities.ParseVector3(boomPositionData);
15445
- const sphereRadius = this.getProperty("sphereRadius", 0.65);
15446
- this.cameraRaycastShape = new BABYLON.PhysicsShapeSphere(new BABYLON.Vector3(0, 0, 0), sphereRadius, this.scene);
15447
- this.abstractMesh = this.getAbstractMesh();
15448
- this.showDebugColliders = Utilities.ShowDebugColliders();
15449
- this.colliderVisibility = Utilities.ColliderVisibility();
15450
- this.colliderRenderGroup = Utilities.ColliderRenderGroup();
15451
- if (this.avatarSkinTag != null && this.avatarSkinTag !== "") {
15452
- this.avatarSkins = this.getChildrenWithTags(this.avatarSkinTag, false);
15453
- }
15454
- const pcontrol = this.getProperty("playerControl", this.playerControl);
15455
- this.setPlayerControl(pcontrol);
15456
- this.resetPlayerRotation();
15457
- this.cameraPivot = new BABYLON.Mesh(this.transform.name + ".CameraPivot", this.scene);
15458
- this.cameraPivot.parent = null;
15459
- this.cameraPivot.position = this.transform.position.clone();
15460
- this.cameraPivot.rotationQuaternion = this.transform.rotationQuaternion.clone();
15461
- this.cameraPivot.checkCollisions = false;
15462
- this.cameraPivot.isPickable = false;
15463
- if (this.showDebugColliders === true) {
15464
- const testPivot = BABYLON.MeshBuilder.CreateBox("TestPivot", { width: 0.25, height: 0.25, depth: 0.5 }, this.scene);
15465
- testPivot.parent = this.cameraPivot;
15466
- testPivot.position.set(0, 0, 0);
15467
- testPivot.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
15468
- testPivot.visibility = 0.5;
15469
- testPivot.renderingGroupId = this.colliderRenderGroup;
15470
- testPivot.checkCollisions = false;
15471
- testPivot.isPickable = false;
15472
- }
15473
- const configController = this.getComponent("TOOLKIT.CharacterController");
15474
- this.setupBoneControllers();
15475
- InputController.OnKeyboardPress(this.keyboardCamera, () => { this.togglePlayerControl(); });
15476
- InputController.OnGamepadButtonPress(this.buttonCamera, () => { this.togglePlayerControl(); });
15477
- }
15478
- startPlayerController() {
15479
- if (this.attachCamera === true) {
15480
- this.attachPlayerCamera(this.playerNumber);
15481
- }
15482
- this.navigationAgent = this.getComponent("TOOLKIT.NavigationAgent");
15483
- this.characterController = this.getComponent("TOOLKIT.CharacterController");
15484
- if (this.characterController != null) {
15485
- this.avatarRadius = this.characterController.getAvatarRadius();
15486
- this.characterController.enableGravity = true;
15487
- this.characterController.enableStepOffset = true;
15488
- this.characterController.useMultiRaycast = true;
15489
- this.characterController.multiRaycastCount = 5;
15490
- this.characterController.stepUpVelocityFactor = 0.5;
15491
- this.characterController.groundCheckDistance = this.groundCheckDistance;
15492
- this.characterController.setRigidBodyMass(this.rigidBodyMass);
15493
- this.characterController.setGravityFactor(this.gravitationalForce);
15494
- this.characterController.onUpdatePositionObservable.add(() => {
15495
- this.updatePlayerPosition();
15496
- this.updateCameraController();
15497
- });
15498
- SceneManager.LogWarning("Starting player controller in physic engine mode for: " + this.transform.name);
15499
- }
15500
- else {
15501
- SceneManager.LogWarning("No character controller found for: " + this.transform.name);
15502
- }
15503
- }
15504
- updatePlayerPosition() {
15505
- if (this.onPlayerPositionObservable && this.onPlayerPositionObservable.hasObservers()) {
15506
- this.onPlayerPositionObservable.notifyObservers(this.transform);
15507
- }
15508
- }
15509
- updatePlayerController() {
15510
- this.deltaTime = this.getDeltaSeconds();
15511
- this.m_actualVelocity = this.transform.absolutePosition.subtract(this.m_lastPosition);
15512
- this.m_linearVelocity.copyFrom(this.m_actualVelocity);
15513
- this.m_scaledVelocity = (this.m_linearVelocity.length() / this.deltaTime);
15514
- this.m_linearVelocity.normalize();
15515
- this.m_linearVelocity.scaleInPlace(this.m_scaledVelocity);
15516
- if (this.playerDrawVelocity > 0) {
15517
- this.m_velocityOffset.copyFrom(this.m_linearVelocity);
15518
- this.m_velocityOffset.scaleInPlace(this.playerDrawVelocity);
15519
- }
15520
- else {
15521
- this.m_velocityOffset.set(0, 0, 0);
15522
- }
15523
- this.m_lastPosition.copyFrom(this.transform.absolutePosition);
15524
- if (this.updateStateParams === true && this.animator == null) {
15525
- this.attachAnimationController();
15526
- }
15527
- if (this.minJumpTimer > 0) {
15528
- this.minJumpTimer -= this.deltaTime;
15529
- if (this.minJumpTimer < 0)
15530
- this.minJumpTimer = 0;
15531
- }
15532
- if (this.isCharacterGrounded === true && this.delayJumpTimer > 0) {
15533
- this.delayJumpTimer -= this.deltaTime;
15534
- if (this.delayJumpTimer < 0)
15535
- this.delayJumpTimer = 0;
15536
- }
15537
- this.canPlayerJump = true;
15538
- if (this.isPerformingAction === true) {
15539
- this.updateAnimationActionState();
15540
- if (this.onUpdateActionObservable && this.onUpdateActionObservable.hasObservers()) {
15541
- this.onUpdateActionObservable.notifyObservers(this.transform);
15542
- }
15543
- }
15544
- if (this.enableInput === false)
15545
- return;
15546
- const userInputX = InputController.GetUserInput(UserInputAxis.Horizontal, this.playerNumber);
15547
- const userInputZ = InputController.GetUserInput(UserInputAxis.Vertical, this.playerNumber);
15548
- const userMouseX = InputController.GetUserInput(UserInputAxis.MouseX, this.playerNumber);
15549
- const userMouseY = InputController.GetUserInput(UserInputAxis.MouseY, this.playerNumber);
15550
- if (this.smoothAcceleration === true) {
15551
- if (userInputX > 0) {
15552
- this.playerInputX += (this.accelerationSpeed * this.deltaTime);
15553
- if (this.playerInputX > 1)
15554
- this.playerInputX = 1;
15555
- }
15556
- else if (userInputX < 0) {
15557
- this.playerInputX -= (this.accelerationSpeed * this.deltaTime);
15558
- if (this.playerInputX < -1)
15559
- this.playerInputX = -1;
15560
- }
15561
- else {
15562
- if (this.playerInputX < 0) {
15563
- this.playerInputX += (this.decelerationSpeed * this.deltaTime);
15564
- if (this.playerInputX > 0)
15565
- this.playerInputX = 0;
15566
- }
15567
- else if (this.playerInputX > 0) {
15568
- this.playerInputX -= (this.decelerationSpeed * this.deltaTime);
15569
- if (this.playerInputX < 0)
15570
- this.playerInputX = 0;
15571
- }
15572
- }
15573
- if (userInputZ > 0) {
15574
- this.playerInputZ += (this.accelerationSpeed * this.deltaTime);
15575
- if (this.playerInputZ > 1)
15576
- this.playerInputZ = 1;
15577
- }
15578
- else if (userInputZ < 0) {
15579
- this.playerInputZ -= (this.accelerationSpeed * this.deltaTime);
15580
- if (this.playerInputZ < -1)
15581
- this.playerInputZ = -1;
15582
- }
15583
- else {
15584
- if (this.playerInputZ < 0) {
15585
- this.playerInputZ += (this.decelerationSpeed * this.deltaTime);
15586
- if (this.playerInputZ > 0)
15587
- this.playerInputZ = 0;
15588
- }
15589
- else if (this.playerInputZ > 0) {
15590
- this.playerInputZ -= (this.decelerationSpeed * this.deltaTime);
15591
- if (this.playerInputZ < 0)
15592
- this.playerInputZ = 0;
15593
- }
15594
- }
15595
- }
15596
- else {
15597
- this.playerInputX = userInputX;
15598
- this.playerInputZ = userInputZ;
15599
- }
15600
- this.playerMouseX = userMouseX;
15601
- this.playerMouseY = userMouseY;
15602
- if (this.isPerformingAction === true && this.isActionInterruptable === true) {
15603
- if (this.playerInputX !== 0 || this.playerInputZ !== 0) {
15604
- this.resetActionAnimationState();
15605
- }
15606
- }
15607
- if (this.isPerformingAction === true) {
15608
- this.canPlayerJump = false;
15609
- this.playerInputX = 0;
15610
- this.playerInputZ = 0;
15611
- }
15612
- if (this.onPlayerInputObservable && this.onPlayerInputObservable.hasObservers()) {
15613
- this.onPlayerInputObservable.notifyObservers(this.transform);
15614
- }
15615
- this.inputMovementVector.set(this.playerInputX, 0, this.playerInputZ);
15616
- if (this.inputMovementVector.length() > 1.0)
15617
- this.inputMovementVector.normalize();
15618
- this.inputMagnitude = this.inputMovementVector.length();
15619
- const moveForward = (this.playerInputZ > 0);
15620
- const moveBackward = (this.playerInputZ < 0);
15621
- const moveRight = (this.playerInputX > 0);
15622
- const moveLeft = (this.playerInputX < 0);
15623
- if (moveForward === true) {
15624
- if (moveLeft === true) {
15625
- this.playerMoveDirection = PlayerMoveDirection.ForwardLeft;
15626
- }
15627
- else if (moveRight === true) {
15628
- this.playerMoveDirection = PlayerMoveDirection.ForwardRight;
15629
- }
15630
- else {
15631
- this.playerMoveDirection = PlayerMoveDirection.Forward;
15632
- }
15633
- }
15634
- else if (moveBackward === true) {
15635
- if (moveLeft === true) {
15636
- this.playerMoveDirection = PlayerMoveDirection.BackwardLeft;
15637
- }
15638
- else if (moveRight === true) {
15639
- this.playerMoveDirection = PlayerMoveDirection.BackwardRight;
15640
- }
15641
- else {
15642
- this.playerMoveDirection = PlayerMoveDirection.Backward;
15643
- }
15644
- }
15645
- else if (moveLeft === true) {
15646
- this.playerMoveDirection = PlayerMoveDirection.StrafingLeft;
15647
- }
15648
- else if (moveRight === true) {
15649
- this.playerMoveDirection = PlayerMoveDirection.StrafingRight;
15650
- }
15651
- else {
15652
- this.playerMoveDirection = PlayerMoveDirection.Stationary;
15653
- }
15654
- if (this.onPreUpdateObservable && this.onPreUpdateObservable.hasObservers()) {
15655
- this.onPreUpdateObservable.notifyObservers(this.transform);
15656
- }
15657
- this.cameraForwardVector = this.scene.activeCamera.getForwardRay().direction;
15658
- this.cameraForwardVector.y = 0;
15659
- this.cameraForwardVector.normalize();
15660
- this.cameraForwardVector.scaleToRef(this.playerInputZ, this.desiredForwardVector);
15661
- this.cameraRightVector = BABYLON.Vector3.Cross(this.cameraForwardVector, BABYLON.Vector3.Up());
15662
- this.cameraRightVector.y = 0;
15663
- this.cameraRightVector.normalize();
15664
- this.cameraRightVector.scaleToRef(this.playerInputX, this.desiredRightVector);
15665
- this.playerRotationVector.y += (this.playerMouseX * this.lookSpeed * this.deltaTime);
15666
- this.playerRotationVector.x += (-this.playerMouseY * this.lookSpeed * this.deltaTime);
15667
- this.playerRotationVector.x = BABYLON.Scalar.Clamp(this.playerRotationVector.x, -BABYLON.Tools.ToRadians(this.downLookLimit), BABYLON.Tools.ToRadians(this.topLookLimit));
15668
- if (this.movementAllowed === false) {
15669
- this.canPlayerJump = false;
15670
- this.playerInputX = 0;
15671
- this.playerInputZ = 0;
15672
- }
15673
- this.isRunPressed = (InputController.GetKeyboardInput(this.keyboardRun) || InputController.GetGamepadButtonInput(this.buttonRun));
15674
- this.isJumpPressed = (InputController.GetKeyboardInput(this.keyboardJump) || InputController.GetGamepadButtonInput(this.buttonJump));
15675
- this.movementSpeed = (this.inputMagnitude * this.moveSpeed * this.speedFactor);
15676
- if (this.runKeyRequired === true && this.isRunPressed === false) {
15677
- this.movementSpeed = BABYLON.Scalar.Clamp(this.movementSpeed, 0, this.walkSpeed);
15678
- }
15679
- this.desiredForwardVector.addToRef(this.desiredRightVector, this.playerMovementVelocity);
15680
- this.playerMovementVelocity.scaleInPlace(this.movementSpeed);
15681
- if (this.movementAllowed === true) {
15682
- if (this.playerControl === PlayerInputControl.FirstPersonStrafing) {
15683
- BABYLON.Quaternion.FromEulerAnglesToRef(0, this.playerRotationVector.y, 0, this.transform.rotationQuaternion);
15684
- }
15685
- else if (this.playerControl === PlayerInputControl.ThirdPersonStrafing) {
15686
- if (this.freeLooking === true) {
15687
- if (this.inputMagnitude > 0) {
15688
- const strafingTurnRatio = (this.playerMovementVelocity.length() / this.moveSpeed);
15689
- const strafingTurnSpeed = BABYLON.Scalar.Lerp(this.highTurnSpeed, this.lowTurnSpeed, strafingTurnRatio);
15690
- BABYLON.Quaternion.FromEulerAnglesToRef(0, this.playerRotationVector.y, 0, this.playerRotationQuaternion);
15691
- BABYLON.Quaternion.SlerpToRef(this.transform.rotationQuaternion, this.playerRotationQuaternion, (strafingTurnSpeed * this.deltaTime), this.transform.rotationQuaternion);
15692
- }
15693
- }
15694
- else {
15695
- BABYLON.Quaternion.FromEulerAnglesToRef(0, this.playerRotationVector.y, 0, this.transform.rotationQuaternion);
15696
- }
15697
- }
15698
- }
15699
- this.verticalVelocity = this.getVerticalVelocity();
15700
- this.movementVelocity.copyFrom(this.playerMovementVelocity);
15701
- this.hasGroundedContact = false;
15702
- this.isCharacterGrounded = false;
15703
- this.isCharacterSliding = false;
15704
- this.isCharacterFalling = false;
15705
- this.isCharacterJumpFrame = false;
15706
- this.isCharacterNavigating = (this.navigationAgent != null && this.navigationAgent.isNavigating());
15707
- this.navigationAngularSpeed = (this.navigationAgent != null) ? this.navigationAgent.angularSpeed : 0;
15708
- this.updateCharacterController();
15709
- if (this.animator != null && this.updateStateParams === true) {
15710
- this.validateAnimationStateParams();
15711
- this.animator.setInteger(this.animationStateParams.moveDirection, this.playerMoveDirection);
15712
- this.animator.setFloat(this.animationStateParams.heightInput, this.verticalVelocity);
15713
- this.animator.setBool(this.animationStateParams.jumpFrame, this.isCharacterJumpFrame);
15714
- this.animator.setBool(this.animationStateParams.jumpState, this.isCharacterJumping);
15715
- this.animator.setInteger(this.animationStateParams.actionState, this.performActionNumber);
15716
- this.animator.setBool(this.animationStateParams.fallingState, this.isCharacterFalling);
15717
- this.animator.setBool(this.animationStateParams.slidingState, this.isCharacterSliding);
15718
- this.animator.setBool(this.animationStateParams.groundedState, this.isCharacterGrounded);
15719
- if (this.smoothMotionSpeed === true && this.smoothDampTime > 0) {
15720
- if (this.smoothInputVectors === true) {
15721
- this.animator.setFloat(this.animationStateParams.horizontalInput, this.playerInputX, this.smoothDampTime, this.deltaTime);
15722
- this.animator.setFloat(this.animationStateParams.verticalInput, this.playerInputZ, this.smoothDampTime, this.deltaTime);
15723
- this.animator.setFloat(this.animationStateParams.mouseXInput, this.playerMouseX, this.smoothDampTime, this.deltaTime);
15724
- this.animator.setFloat(this.animationStateParams.mouseYInput, this.playerMouseY, this.smoothDampTime, this.deltaTime);
15725
- this.animator.setFloat(this.animationStateParams.inputMagnitude, this.inputMagnitude, this.smoothDampTime, this.deltaTime);
15726
- }
15727
- else {
15728
- this.animator.setFloat(this.animationStateParams.horizontalInput, this.playerInputX);
15729
- this.animator.setFloat(this.animationStateParams.verticalInput, this.playerInputZ);
15730
- this.animator.setFloat(this.animationStateParams.mouseXInput, this.playerMouseX);
15731
- this.animator.setFloat(this.animationStateParams.mouseYInput, this.playerMouseY);
15732
- this.animator.setFloat(this.animationStateParams.inputMagnitude, this.inputMagnitude);
15733
- }
15734
- this.animator.setFloat(this.animationStateParams.speedInput, this.movementSpeed, this.smoothDampTime, this.deltaTime);
15735
- this.animator.setFloat(this.animationStateParams.motionSpeed, (this.analogMovement === true) ? this.inputMagnitude : 1);
15736
- }
15737
- else {
15738
- this.animator.setFloat(this.animationStateParams.horizontalInput, this.playerInputX);
15739
- this.animator.setFloat(this.animationStateParams.verticalInput, this.playerInputZ);
15740
- this.animator.setFloat(this.animationStateParams.mouseXInput, this.playerMouseX);
15741
- this.animator.setFloat(this.animationStateParams.mouseYInput, this.playerMouseY);
15742
- this.animator.setFloat(this.animationStateParams.inputMagnitude, this.inputMagnitude);
15743
- this.animator.setFloat(this.animationStateParams.speedInput, this.movementSpeed);
15744
- this.animator.setFloat(this.animationStateParams.motionSpeed, (this.analogMovement === true) ? this.inputMagnitude : 1);
15745
- }
15746
- if (this.isCharacterNavigating === true) {
15747
- }
15748
- }
15749
- if (this.onPostUpdateObservable && this.onPostUpdateObservable.hasObservers()) {
15750
- this.onPostUpdateObservable.notifyObservers(this.transform);
15751
- }
15752
- }
15753
- afterPlayerController() {
15754
- }
15755
- updateCharacterController() {
15756
- if (this.characterController != null) {
15757
- this.isCharacterRising = (this.isCharacterJumping == true && this.verticalVelocity > 0);
15758
- this.isCharacterLanding = (this.isCharacterJumping == true && this.verticalVelocity < 0);
15759
- if (this.isCharacterRising == true) {
15760
- this.hasGroundedContact = false;
15761
- }
15762
- if (this.hasGroundedContact === true && this.minJumpTimer <= 0) {
15763
- this.isCharacterSliding = false;
15764
- this.isCharacterGrounded = true;
15765
- }
15766
- if (this.isCharacterGrounded === true)
15767
- this.isCharacterJumping = false;
15768
- this.isCharacterFalling = (this.isCharacterGrounded === false && this.isCharacterSliding == false && this.isCharacterJumping == false && this.verticalVelocity < 0 && Math.abs(this.verticalVelocity) >= this.minFallVelocity);
15769
- if (this.isCharacterFalling === true && this.isCharacterFallTriggered === false) {
15770
- this.isCharacterFallTriggered = true;
15771
- if (this.jumpDelay > 0)
15772
- this.delayJumpTimer = this.jumpDelay;
15773
- }
15774
- if (this.isCharacterGrounded === true)
15775
- this.isCharacterFallTriggered = false;
15776
- if (this.useClimbSystem === true) {
15777
- this.castPhysicsClimbingVolumeRay();
15778
- this.castPhysicsHeightCheckVolumeRay();
15779
- }
15780
- if (this.isCharacterNavigating === false && this.movementAllowed === true) {
15781
- if (this.isCharacterGrounded === true) {
15782
- if (this.delayJumpTimer <= 0)
15783
- this.isCharacterJumpFrame = (this.canPlayerJump === true && this.isJumpPressed === true);
15784
- if (this.isPerformingAction === false && this.isCharacterJumpFrame === true && this.useClimbSystem === true && this.climbContact === true && this.heightContact === true) {
15785
- let climbAction = -1;
15786
- let rotateSpeed = 1;
15787
- let rotateTowards = false;
15788
- let matchHeight = false;
15789
- let startTime = 0;
15790
- let targetTime = 0;
15791
- let targetOffset = 0;
15792
- const hitHeight = parseFloat(this.heightContactPoint.y.toFixed(2));
15793
- const playerHeight = parseFloat(this.transform.position.y.toFixed(2));
15794
- const obstacleHeight = parseFloat((hitHeight - playerHeight).toFixed(2));
15795
- if (obstacleHeight >= this.maxHeightRanges.stepUpRange.minimumHeight && obstacleHeight <= this.maxHeightRanges.stepUpRange.maximumHeight) {
15796
- climbAction = ActionAnimationType.StepUp;
15797
- rotateSpeed = this.maxHeightRanges.stepUpRange.rotationSpeed;
15798
- rotateTowards = this.maxHeightRanges.stepUpRange.rotateTowards;
15799
- matchHeight = this.maxHeightRanges.stepUpRange.matchHeight;
15800
- startTime = this.maxHeightRanges.stepUpRange.startTime;
15801
- targetTime = this.maxHeightRanges.stepUpRange.targetTime;
15802
- targetOffset = this.maxHeightRanges.stepUpRange.targetOffset;
15803
- }
15804
- else if (obstacleHeight >= this.maxHeightRanges.jumpUpRange.minimumHeight && obstacleHeight <= this.maxHeightRanges.jumpUpRange.maximumHeight) {
15805
- climbAction = ActionAnimationType.JumpUp;
15806
- rotateSpeed = this.maxHeightRanges.jumpUpRange.rotationSpeed;
15807
- rotateTowards = this.maxHeightRanges.jumpUpRange.rotateTowards;
15808
- matchHeight = this.maxHeightRanges.jumpUpRange.matchHeight;
15809
- startTime = this.maxHeightRanges.jumpUpRange.startTime;
15810
- targetTime = this.maxHeightRanges.jumpUpRange.targetTime;
15811
- targetOffset = this.maxHeightRanges.jumpUpRange.targetOffset;
15812
- }
15813
- else if (obstacleHeight >= this.maxHeightRanges.climbUpRange.minimumHeight && obstacleHeight <= this.maxHeightRanges.climbUpRange.maximumHeight) {
15814
- climbAction = ActionAnimationType.ClimbUp;
15815
- rotateSpeed = this.maxHeightRanges.climbUpRange.rotationSpeed;
15816
- rotateTowards = this.maxHeightRanges.climbUpRange.rotateTowards;
15817
- matchHeight = this.maxHeightRanges.climbUpRange.matchHeight;
15818
- startTime = this.maxHeightRanges.climbUpRange.startTime;
15819
- targetTime = this.maxHeightRanges.climbUpRange.targetTime;
15820
- targetOffset = this.maxHeightRanges.climbUpRange.targetOffset;
15821
- }
15822
- if (climbAction >= 0) {
15823
- if (this.canClimbObstaclePredicate == null || this.canClimbObstaclePredicate(climbAction) === true) {
15824
- this.isCharacterJumpFrame = false;
15825
- this.isCharacterJumping = false;
15826
- this.isCharacterLanding = false;
15827
- this.isCharacterRising = false;
15828
- this.playActionAnimation(climbAction, false, true);
15829
- this.playerRotationSpeed = rotateSpeed;
15830
- this.rotatePlayerTowards = rotateTowards;
15831
- this.matchTargetHeight = matchHeight;
15832
- this.matchStartTime = (startTime - ThirdPersonPlayerController.MIN_TIMER_OFFSET);
15833
- this.matchTargetTime = (targetTime - ThirdPersonPlayerController.MIN_TIMER_OFFSET);
15834
- this.matchTargetOffset = targetOffset;
15835
- this.lastTargetHeight = hitHeight;
15836
- this.lastStartHeight = null;
15837
- this.lockTargetHeight = false;
15838
- }
15839
- }
15840
- }
15841
- if (this.isCharacterJumpFrame === true && this.jumpSpeed > 0) {
15842
- this.isCharacterJumping = true;
15843
- this.characterController.jump(this.jumpSpeed);
15844
- if (this.jumpDelay > 0)
15845
- this.delayJumpTimer = this.jumpDelay;
15846
- if (this.airbornTimeout > 0)
15847
- this.minJumpTimer = (this.airbornTimeout + this.deltaTime);
15848
- this.lastJumpVelocity.set(this.movementVelocity.x, 0, this.movementVelocity.z);
15849
- }
15850
- if (this.onBeforeMoveObservable && this.onBeforeMoveObservable.hasObservers()) {
15851
- this.onBeforeMoveObservable.notifyObservers(this.transform);
15852
- }
15853
- if (this.animator != null && this.rootMotion === true) {
15854
- this.movementVelocity.set(this.rootMotionVelocity.x, 0, this.rootMotionVelocity.z);
15855
- this.characterController.move(this.movementVelocity);
15856
- }
15857
- else {
15858
- this.characterController.move(this.movementVelocity);
15859
- }
15860
- }
15861
- }
15862
- else {
15863
- }
15864
- }
15865
- }
15866
- updateCameraController() {
15867
- if (this.enableInput === false)
15868
- return;
15869
- if (this.cameraPivot != null) {
15870
- if (this.targetCameraOffset.x !== 0 || this.targetCameraOffset.y !== 0 || this.targetCameraOffset.z !== 0) {
15871
- this.cameraPivotOffset.copyFrom(this.targetCameraOffset);
15872
- }
15873
- else {
15874
- if (this.playerControl === PlayerInputControl.ThirdPersonStrafing) {
15875
- this.cameraPivotOffset.set(0, this.pivotHeight, 0);
15876
- }
15877
- else {
15878
- this.cameraPivotOffset.set(0, this.eyesHeight, 0);
15879
- }
15880
- }
15881
- Utilities.GetAbsolutePositionToRef(this.transform, this.cameraPivot.position, this.cameraPivotOffset);
15882
- if (this.rotateCamera === true) {
15883
- BABYLON.Quaternion.FromEulerAnglesToRef(this.playerRotationVector.x, this.playerRotationVector.y, 0, this.cameraPivot.rotationQuaternion);
15884
- }
15885
- }
15886
- if (this.rotateCamera === true && this.cameraNode != null) {
15887
- if (this.cameraSmoothing <= 0)
15888
- this.cameraSmoothing = 5.0;
15889
- if (this.playerControl === PlayerInputControl.ThirdPersonStrafing) {
15890
- if (this.cameraCollisions === true) {
15891
- const parentNode = this.cameraNode.parent;
15892
- this.dollyDirection.scaleToRef(this.maxDistance, this.scaledMaxDirection);
15893
- this.dollyDirection.scaleToRef(this.cameraDistance, this.scaledCamDirection);
15894
- Utilities.GetAbsolutePositionToRef(parentNode, this.parentNodePosition);
15895
- Utilities.TransformPointToRef(parentNode, this.scaledMaxDirection, this.maximumCameraPos);
15896
- let contact = false;
15897
- let distance = 0;
15898
- if (this.characterController != null) {
15899
- if (this.cameraRaycastShape != null) {
15900
- const query = {
15901
- shape: this.cameraRaycastShape,
15902
- rotation: this.cameraNode.rotationQuaternion,
15903
- startPosition: this.parentNodePosition,
15904
- endPosition: this.maximumCameraPos,
15905
- ignoreBody: this.transform.physicsBody,
15906
- shouldHitTriggers: false
15907
- };
15908
- const result = RigidbodyPhysics.Shapecast(query);
15909
- contact = (result != null && result.world != null && result.world.hasHit === true && result.world.body != null);
15910
- distance = (contact === true) ? BABYLON.Vector3.Distance(this.parentNodePosition, result.world.hitPoint) : 0;
15911
- }
15912
- }
15913
- if (contact === true) {
15914
- this.cameraDistance = BABYLON.Scalar.Clamp((distance * this.distanceFactor), this.minimumDistance, this.maxDistance);
15915
- if (this.cameraNode.position.x !== this.scaledCamDirection.x || this.cameraNode.position.y !== this.scaledCamDirection.y || this.cameraNode.position.z !== this.scaledCamDirection.z) {
15916
- BABYLON.Vector3.LerpToRef(this.cameraNode.position, this.scaledCamDirection, (this.deltaTime * this.cameraSmoothing), this.cameraNode.position);
15917
- }
15918
- }
15919
- else {
15920
- if (this.mouseWheel === true) {
15921
- if (InputController.IsWheelScrolling()) {
15922
- const wheel = InputController.GetUserInput(UserInputAxis.Wheel);
15923
- if (wheel < 0) {
15924
- const zoomOutSpeed = (this.scrollSpeed * this.deltaTime);
15925
- this.boomPosition.z = BABYLON.Scalar.MoveTowards(this.boomPosition.z, -this.maxDistance, zoomOutSpeed);
15926
- }
15927
- else if (wheel > 0) {
15928
- const zoomInSpeed = (this.scrollSpeed * this.deltaTime);
15929
- this.boomPosition.z = BABYLON.Scalar.MoveTowards(this.boomPosition.z, -this.minimumDistance, zoomInSpeed);
15930
- }
15931
- }
15932
- }
15933
- if (this.cameraNode.position.x !== this.boomPosition.x || this.cameraNode.position.y !== this.boomPosition.y || this.cameraNode.position.z !== this.boomPosition.z) {
15934
- BABYLON.Vector3.LerpToRef(this.cameraNode.position, this.boomPosition, (this.deltaTime * this.cameraSmoothing), this.cameraNode.position);
15935
- }
15936
- }
15937
- }
15938
- else {
15939
- if (this.cameraNode.position.x !== this.boomPosition.x || this.cameraNode.position.y !== this.boomPosition.y || this.cameraNode.position.z !== this.boomPosition.z) {
15940
- BABYLON.Vector3.LerpToRef(this.cameraNode.position, this.boomPosition, (this.deltaTime * this.cameraSmoothing), this.cameraNode.position);
15941
- }
15942
- }
15943
- }
15944
- else {
15945
- if (this.cameraNode.position.x !== 0 || this.cameraNode.position.y !== 0 || this.cameraNode.position.z !== 0) {
15946
- this.cameraNode.position.set(0, 0, 0);
15947
- }
15948
- }
15949
- }
15950
- this.updateSmoothBoomArmLength();
15951
- }
15952
- getBoomArmMaxDistance() { return this.maxDistance; }
15953
- setBoomArmMaxDistance(distance) { this.maxDistance = Math.abs(distance); }
15954
- setSmoothBoomArmLength(length, speed, updateMaxDistance = true) {
15955
- const absoluteLength = Math.abs(length);
15956
- this.smoothBoomArmLength = -absoluteLength;
15957
- this.smoothBoomArmSpeed = speed;
15958
- if (updateMaxDistance === true) {
15959
- const absoluteDistance = Math.abs(this.maxDistance);
15960
- if (absoluteLength > absoluteDistance) {
15961
- this.setBoomArmMaxDistance(absoluteLength);
15962
- }
15963
- }
15964
- }
15965
- updateSmoothBoomArmLength() {
15966
- if (this.smoothBoomArmLength != null && this.smoothBoomArmSpeed != null) {
15967
- if (this.boomPosition.z !== this.smoothBoomArmLength) {
15968
- this.boomPosition.z = BABYLON.Scalar.MoveTowards(this.boomPosition.z, this.smoothBoomArmLength, (this.smoothBoomArmSpeed * this.getDeltaSeconds()));
15969
- }
15970
- else {
15971
- this.smoothBoomArmLength = null;
15972
- this.smoothBoomArmSpeed = null;
15973
- }
15974
- }
15975
- }
15976
- castPhysicsClimbingVolumeRay() {
15977
- let raycast = null;
15978
- this.climbContact = false;
15979
- this.climbContactNode = null;
15980
- this.climbContactPoint.set(0, 0, 0);
15981
- this.climbContactNormal.set(0, 0, 0);
15982
- this.climbContactAngle = 0;
15983
- this.climbContactDistance = 0;
15984
- const playerTransformForwardDirection = Utilities.TransformDirection(this.transform, this.forwardDirection);
15985
- this.offsetClimbRaycastPosition.set(0, this.rayClimbOffset, 0);
15986
- Utilities.GetAbsolutePositionToRef(this.transform, this.startClimbRaycastPosition, this.offsetClimbRaycastPosition);
15987
- Utilities.GetAbsolutePositionToRef(this.transform, this.endClimbRaycastPosition, this.forwardDirection.scale(this.rayClimbLength));
15988
- this.endClimbRaycastPosition.y += this.rayClimbOffset;
15989
- if (raycast.hasHit === true && raycast.collisionObject != null && raycast.collisionObject.entity != null) {
15990
- const checkTag = SceneManager.GetTransformTag(raycast.collisionObject.entity);
15991
- if (checkTag === this.climbVolumeTag) {
15992
- this.climbContact = true;
15993
- this.climbContactNode = raycast.collisionObject.entity;
15994
- if (raycast.hitPoint != null)
15995
- this.climbContactPoint.copyFrom(raycast.hitPoint);
15996
- if (raycast.hitNormal != null)
15997
- this.climbContactNormal.copyFrom(raycast.hitNormal);
15998
- this.climbContactAngle = (this.climbContactNormal != null) ? Math.abs(Utilities.GetAngle(this.climbContactNormal, BABYLON.Vector3.UpReadOnly)) : 0;
15999
- this.climbContactDistance = raycast.hitDistance;
16000
- }
16001
- }
16002
- if (this.showDebugColliders === true) {
16003
- if (this.climbSensorLine == null)
16004
- this.climbSensorLine = new LinesMeshRenderer(this.transform.name + ".ClimbingSensorLine", this.scene);
16005
- if (this.climbContact === true) {
16006
- this.climbSensorLine.drawLine([this.startClimbRaycastPosition, raycast.hitPoint], BABYLON.Color3.Red());
16007
- }
16008
- else {
16009
- this.climbSensorLine.drawLine([this.startClimbRaycastPosition, this.endClimbRaycastPosition], BABYLON.Color3.Green());
16010
- }
16011
- }
16012
- }
16013
- castPhysicsHeightCheckVolumeRay() {
16014
- let raycast = null;
16015
- this.heightContact = false;
16016
- this.heightContactNode = null;
16017
- this.heightContactPoint.set(0, 0, 0);
16018
- this.heightContactNormal.set(0, 0, 0);
16019
- this.heightContactAngle = 0;
16020
- this.heightContactDistance = 0;
16021
- const playerTransformHeightDirection = Utilities.TransformDirection(this.transform, this.downDirection);
16022
- if (this.climbContact === true) {
16023
- this.endHeightRaycastPosition.copyFrom(this.climbContactPoint);
16024
- this.startHeightRaycastPosition.copyFrom(this.climbContactPoint);
16025
- this.startHeightRaycastPosition.addInPlace(BABYLON.Vector3.UpReadOnly.scale(this.rayHeightLength));
16026
- }
16027
- else {
16028
- this.offsetHeightRaycastPosition.set(0, this.rayHeightOffset, this.rayClimbLength);
16029
- Utilities.GetAbsolutePositionToRef(this.transform, this.startHeightRaycastPosition, this.offsetHeightRaycastPosition);
16030
- this.endHeightRaycastPosition.copyFrom(this.startHeightRaycastPosition);
16031
- this.endHeightRaycastPosition.addInPlace(this.downDirection.scale(this.rayHeightLength));
16032
- }
16033
- if (raycast != null && raycast.hasHit === true && raycast.collisionObject != null && raycast.collisionObject.entity != null) {
16034
- const checkTag = SceneManager.GetTransformTag(raycast.collisionObject.entity);
16035
- if (checkTag === this.climbVolumeTag) {
16036
- this.heightContact = true;
16037
- this.heightContactNode = raycast.collisionObject.entity;
16038
- if (raycast.hitPoint != null)
16039
- this.heightContactPoint.copyFrom(raycast.hitPoint);
16040
- if (raycast.hitNormal != null)
16041
- this.heightContactNormal.copyFrom(raycast.hitNormal);
16042
- this.heightContactAngle = (this.heightContactNormal != null) ? Math.abs(Utilities.GetAngle(this.heightContactNormal, BABYLON.Vector3.UpReadOnly)) : 0;
16043
- this.heightContactDistance = raycast.hitDistance;
16044
- }
16045
- }
16046
- if (this.showDebugColliders === true) {
16047
- if (this.heightSensorLine == null)
16048
- this.heightSensorLine = new LinesMeshRenderer(this.transform.name + ".HeightCheckSensorLine", this.scene);
16049
- if (raycast != null && this.heightContact === true) {
16050
- this.heightSensorLine.drawLine([this.startHeightRaycastPosition, raycast.hitPoint], BABYLON.Color3.Red());
16051
- }
16052
- else {
16053
- this.heightSensorLine.drawLine([this.startHeightRaycastPosition, this.endHeightRaycastPosition], BABYLON.Color3.Green());
16054
- }
16055
- }
16056
- }
16057
- getCheckedVerticalVelocity() {
16058
- const currentVelocity = (this.characterController != null) ? this.characterController.getVerticalVelocity() : 0;
16059
- return (Math.abs(currentVelocity) >= StandardPlayerController.MIN_VERTICAL_VELOCITY) ? currentVelocity : 0;
16060
- }
16061
- destroyPlayerController() {
16062
- this.cameraPivot = null;
16063
- this.cameraNode = null;
16064
- if (this.animator != null && this.animatorMoveObserver != null)
16065
- this.animator.onAnimatorMoveObservable.remove(this.animatorMoveObserver);
16066
- this.animatorMoveObserver = null;
16067
- this.animator = null;
16068
- this.characterController = null;
16069
- this.onPreUpdateObservable.clear();
16070
- this.onPreUpdateObservable = null;
16071
- this.onBeforeMoveObservable.clear();
16072
- this.onBeforeMoveObservable = null;
16073
- this.onPostUpdateObservable.clear();
16074
- this.onPostUpdateObservable = null;
16075
- }
16076
- validateAnimationStateParams() {
16077
- this.animationStateParams = StandardPlayerController.ApplyAnimationStateParamDefaults(this.animationStateParams);
16078
- }
16079
- static ApplyAnimationStateParamDefaults(params) {
16080
- if (params == null) {
16081
- return {
16082
- moveDirection: "Direction",
16083
- inputMagnitude: "Magnitude",
16084
- horizontalInput: "Horizontal",
16085
- verticalInput: "Vertical",
16086
- mouseXInput: "MouseX",
16087
- mouseYInput: "MouseY",
16088
- heightInput: "Height",
16089
- speedInput: "Speed",
16090
- motionSpeed: "MotionSpeed",
16091
- jumpFrame: "Jumped",
16092
- jumpState: "Jump",
16093
- actionState: "Action",
16094
- fallingState: "FreeFall",
16095
- slidingState: "Sliding",
16096
- groundedState: "Grounded",
16097
- };
16098
- }
16099
- if (params.motionSpeed == null || params.motionSpeed === "")
16100
- params.motionSpeed = "MotionSpeed";
16101
- return params;
16102
- }
16103
- }
16104
- StandardPlayerController.MIN_VERTICAL_VELOCITY = 0.01;
16105
- StandardPlayerController.MIN_GROUND_DISTANCE = 0.15;
16106
- StandardPlayerController.MIN_MOVE_EPSILON = 0.001;
16107
- StandardPlayerController.MIN_TIMER_OFFSET = 0;
16108
- StandardPlayerController.MIN_SLOPE_LIMIT = 0;
16109
- StandardPlayerController.PLAYER_HEIGHT = "playerHeight";
16110
- export var PlayerInputControl;
16111
- (function (PlayerInputControl) {
16112
- PlayerInputControl[PlayerInputControl["FirstPersonStrafing"] = 0] = "FirstPersonStrafing";
16113
- PlayerInputControl[PlayerInputControl["ThirdPersonStrafing"] = 1] = "ThirdPersonStrafing";
16114
- })(PlayerInputControl || (PlayerInputControl = {}));
16115
- export var PlayerMoveDirection;
16116
- (function (PlayerMoveDirection) {
16117
- PlayerMoveDirection[PlayerMoveDirection["Stationary"] = 0] = "Stationary";
16118
- PlayerMoveDirection[PlayerMoveDirection["Forward"] = 1] = "Forward";
16119
- PlayerMoveDirection[PlayerMoveDirection["ForwardLeft"] = 2] = "ForwardLeft";
16120
- PlayerMoveDirection[PlayerMoveDirection["ForwardRight"] = 3] = "ForwardRight";
16121
- PlayerMoveDirection[PlayerMoveDirection["Backward"] = 4] = "Backward";
16122
- PlayerMoveDirection[PlayerMoveDirection["BackwardLeft"] = 5] = "BackwardLeft";
16123
- PlayerMoveDirection[PlayerMoveDirection["BackwardRight"] = 6] = "BackwardRight";
16124
- PlayerMoveDirection[PlayerMoveDirection["StrafingLeft"] = 7] = "StrafingLeft";
16125
- PlayerMoveDirection[PlayerMoveDirection["StrafingRight"] = 8] = "StrafingRight";
16126
- })(PlayerMoveDirection || (PlayerMoveDirection = {}));
16127
- export var ActionAnimationType;
16128
- (function (ActionAnimationType) {
16129
- ActionAnimationType[ActionAnimationType["Neutral"] = 0] = "Neutral";
16130
- ActionAnimationType[ActionAnimationType["StepUp"] = 1] = "StepUp";
16131
- ActionAnimationType[ActionAnimationType["JumpUp"] = 2] = "JumpUp";
16132
- ActionAnimationType[ActionAnimationType["ClimbUp"] = 3] = "ClimbUp";
16133
- ActionAnimationType[ActionAnimationType["VaultOver"] = 4] = "VaultOver";
16134
- })(ActionAnimationType || (ActionAnimationType = {}));
16135
- export class ThirdPersonPlayerController extends ScriptComponent {
16136
- isAnimationEnabled() { return this.updateStateParams; }
16137
- isRunButtonPressed() { return this.isRunPressed; }
16138
- isJumpButtonPressed() { return this.isJumpPressed; }
16139
- getPlayerJumped() { return this.isCharacterJumpFrame; }
16140
- getPlayerJumping() { return this.isCharacterJumping; }
16141
- getPlayerFalling() { return this.isCharacterFalling; }
16142
- getPlayerSliding() { return this.isCharacterSliding; }
16143
- getPlayerGrounded() { return this.isCharacterGrounded; }
16144
- getFallTriggered() { return this.isCharacterFallTriggered; }
16145
- getMovementSpeed() { return this.movementSpeed; }
16146
- getAnimator() { return this.animator; }
16147
- getVerticalVelocity() { return this.getCheckedVerticalVelocity(); }
16148
- getCharacterController() { return this.characterController; }
16149
- getPlayerLookRotation() { return this.playerLookRotation; }
16150
- getPlayerMoveDirection() { return this.playerMoveDirection; }
16151
- getInputMovementVector() { return this.inputMovementVector; }
16152
- getInputMagnitudeValue() { return this.inputMagnitude; }
16153
- getClimbContact() { return this.climbContact; }
16154
- getClimbContactNode() { return this.climbContactNode; }
16155
- getClimbContactPoint() { return this.climbContactPoint; }
16156
- getClimbContactAngle() { return this.climbContactAngle; }
16157
- getClimbContactNormal() { return this.climbContactNormal; }
16158
- getClimbContactDistance() { return this.climbContactDistance; }
16159
- ;
16160
- getHeightContact() { return this.heightContact; }
16161
- getHeightContactNode() { return this.heightContactNode; }
16162
- getHeightContactPoint() { return this.heightContactPoint; }
16163
- getHeightContactAngle() { return this.heightContactAngle; }
16164
- getHeightContactNormal() { return this.heightContactNormal; }
16165
- getHeightContactDistance() { return this.heightContactDistance; }
16166
- ;
16167
- constructor(transform, scene, properties, alias = "PROJECT.ThirdPersonPlayerController") {
16168
- super(transform, scene, properties, alias);
16169
- this.enableInput = false;
16170
- this.attachCamera = false;
16171
- this.mouseWheel = true;
16172
- this.requireSprintButton = false;
16173
- this.gravitationalForce = 3.0;
16174
- this.minFallVelocity = 2.5;
16175
- this.verticalStepSpeed = 1.0;
16176
- this.minStepUpHeight = 0.15;
16177
- this.rigidBodyMass = 85.0;
16178
- this.airbornTimeout = 0.5;
16179
- this.maxAngle = 45;
16180
- this.speedFactor = 1.0;
16181
- this.rootMotion = false;
16182
- this.moveSpeed = 5.335;
16183
- this.walkSpeed = 2.0;
16184
- this.jumpSpeed = 10.0;
16185
- this.jumpDelay = 0.25;
16186
- this.lowTurnSpeed = 15.0;
16187
- this.highTurnSpeed = 25.0;
16188
- this.smoothDampTime = 0.1;
16189
- this.smoothInputVectors = false;
16190
- this.smoothAcceleration = false;
16191
- this.accelerationSpeed = 0.1;
16192
- this.decelerationSpeed = 0.1;
16193
- this.climbVolumeTag = "Climb";
16194
- this.vaultVolumeTag = "Vault";
16195
- this.maxHeightRanges = null;
16196
- this.useClimbSystem = false;
16197
- this.distanceFactor = 0.85;
16198
- this.inputMagnitude = 0;
16199
- this.analogMovement = false;
16200
- this.landingEpsilon = 0.1;
16201
- this.minimumDistance = 0.5;
16202
- this.movementAllowed = true;
16203
- this.playerInputX = 0;
16204
- this.playerInputZ = 0;
16205
- this.playerMouseX = 0;
16206
- this.playerMouseY = 0;
16207
- this.runKeyRequired = true;
16208
- this.buttonRun = BABYLON.Xbox360Button.LeftStick;
16209
- this.keyboardRun = UserInputKey.Shift;
16210
- this.buttonJump = BABYLON.Xbox360Button.A;
16211
- this.keyboardJump = UserInputKey.SpaceBar;
16212
- this.buttonCamera = BABYLON.Xbox360Button.Y;
16213
- this.keyboardCamera = UserInputKey.P;
16214
- this.postNetworkAttributes = false;
16215
- this.playerNumber = PlayerNumber.One;
16216
- this.airbornVelocity = new BABYLON.Vector3(0, 0, 0);
16217
- this.movementVelocity = new BABYLON.Vector3(0, 0, 0);
16218
- this.rayClimbOffset = 0.35;
16219
- this.rayClimbLength = 0.85;
16220
- this.canClimbObstaclePredicate = null;
16221
- this.rayHeightOffset = 5.0;
16222
- this.rayHeightLength = 6.0;
16223
- this.freeCamera = null;
16224
- this.cameraForwardVector = new BABYLON.Vector3(0, 0, 0);
16225
- this.cameraRightVector = new BABYLON.Vector3(0, 0, 0);
16226
- this.desiredForwardVector = new BABYLON.Vector3(0, 0, 0);
16227
- this.desiredRightVector = new BABYLON.Vector3(0, 0, 0);
16228
- this.lastRotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
16229
- this.avatarSkins = null;
16230
- this.avatarRadius = 0.5;
16231
- this.navigationAgent = null;
16232
- this.characterController = null;
16233
- this.verticalVelocity = 0;
16234
- this.smoothMotionSpeed = false;
16235
- this.movementSpeed = 0;
16236
- this.isRunPressed = false;
16237
- this.isJumpPressed = false;
16238
- this.isCharacterSliding = false;
16239
- this.isCharacterFalling = false;
16240
- this.isCharacterGrounded = false;
16241
- this.isCharacterFallTriggered = false;
16242
- this.isCharacterJumpFrame = false;
16243
- this.isCharacterJumping = false;
16244
- this.isCharacterRising = false;
16245
- this.isCharacterLanding = false;
16246
- this.isCharacterNavigating = false;
16247
- this.navigationAngularSpeed = 0;
16248
- this.updateStateParams = true;
16249
- this.animationStateParams = null;
16250
- this.sphereCollisionShape = null;
16251
- this.hasGroundedContact = false;
16252
- this.showDebugColliders = false;
16253
- this.colliderVisibility = 0;
16254
- this.colliderRenderGroup = 0;
16255
- this.groundCheckDistance = 0.25;
16256
- this.deltaTime = 0;
16257
- this.delayJumpTimer = 0;
16258
- this.canPlayerJump = true;
16259
- this.animator = null;
16260
- this.lastJumpVelocity = new BABYLON.Vector3(0, 0, 0);
16261
- this.inputMovementVector = new BABYLON.Vector3(0, 0, 0);
16262
- this.playerLookRotation = new BABYLON.Vector3(0, 0, 0);
16263
- this.playerMovementVelocity = new BABYLON.Vector3(0, 0, 0);
16264
- this.playerRotationQuaternion = BABYLON.Quaternion.Zero();
16265
- this.playerMoveDirection = PlayerMoveDirection.Stationary;
16266
- this.forwardDirection = new BABYLON.Vector3(0, 0, 1);
16267
- this.downDirection = new BABYLON.Vector3(0, -1, 0);
16268
- this.climbContact = false;
16269
- this.climbContactNode = null;
16270
- this.climbContactAngle = 0;
16271
- this.climbContactPoint = new BABYLON.Vector3(0, 0, 0);
16272
- this.climbContactNormal = new BABYLON.Vector3(0, 0, 0);
16273
- this.climbContactDistance = 0;
16274
- this.climbSensorLine = null;
16275
- this.offsetClimbRaycastPosition = new BABYLON.Vector3(0, 0, 0);
16276
- this.startClimbRaycastPosition = new BABYLON.Vector3(0, 0, 0);
16277
- this.endClimbRaycastPosition = new BABYLON.Vector3(0, 0, 0);
16278
- this.heightContact = false;
16279
- this.heightContactNode = null;
16280
- this.heightContactAngle = 0;
16281
- this.heightContactPoint = new BABYLON.Vector3(0, 0, 0);
16282
- this.heightContactNormal = new BABYLON.Vector3(0, 0, 0);
16283
- this.heightContactDistance = 0;
16284
- this.heightSensorLine = null;
16285
- this.offsetHeightRaycastPosition = new BABYLON.Vector3(0, 0, 0);
16286
- this.startHeightRaycastPosition = new BABYLON.Vector3(0, 0, 0);
16287
- this.endHeightRaycastPosition = new BABYLON.Vector3(0, 0, 0);
16288
- this.m_velocityOffset = new BABYLON.Vector3(0, 0, 0);
16289
- this.m_actualVelocity = new BABYLON.Vector3(0, 0, 0);
16290
- this.m_linearVelocity = new BABYLON.Vector3(0, 0, 0);
16291
- this.m_lastPosition = new BABYLON.Vector3(0, 0, 0);
16292
- this.m_positionCenter = new BABYLON.Vector3(0, 0, 0);
16293
- this.m_scaledVelocity = 0;
16294
- this.playerDrawVelocity = 0;
16295
- this.boomPosition = new BABYLON.Vector3(0, 0, -5);
16296
- this.onPreUpdateObservable = new BABYLON.Observable();
16297
- this.onBeforeMoveObservable = new BABYLON.Observable();
16298
- this.onPostUpdateObservable = new BABYLON.Observable();
16299
- this.onPlayerInputObservable = new BABYLON.Observable();
16300
- this.onPlayerPositionObservable = new BABYLON.Observable();
16301
- this.onUpdateActionObservable = new BABYLON.Observable();
16302
- this.onAnimationStateObservable = new BABYLON.Observable();
16303
- this.animatorMoveObserver = null;
16304
- this.exportedApplyRootMotion = false;
16305
- this.rootMotionVelocity = new BABYLON.Vector3(0, 0, 0);
16306
- this.isPerformingAction = false;
16307
- this.isRootMotionAction = false;
16308
- this.isActionInterruptable = false;
16309
- this.afterActionHandler = null;
16310
- this.performActionTimer = 0;
16311
- this.performActionNumber = 0;
16312
- this.playerRotationSpeed = 10;
16313
- this.rotatePlayerTowards = false;
16314
- this.matchStartTime = 0;
16315
- this.matchTargetTime = 0;
16316
- this.matchTargetOffset = 0;
16317
- this.matchTargetHeight = false;
16318
- this.lockTargetHeight = false;
16319
- this.lastStartHeight = null;
16320
- this.lastTargetHeight = null;
16321
- this.lastTargetNormal = new BABYLON.Vector3(0, 0, 0);
16322
- this.lastTargetRotation = new BABYLON.Quaternion(0, 0, 0, 1);
16323
- this.lastDeltaPosition = new BABYLON.Vector3(0, 0, 0);
16324
- this.lastDeltaRotation = new BABYLON.Quaternion(0, 0, 0, 1);
16325
- this.smoothedPlayerHeight = 0;
16326
- this.playerHeightVelocity = new BABYLON.Vector2(0, 0);
16327
- this.actionStateHash = 0;
16328
- this.actionStateEntered = false;
16329
- this.ikLeftFootTarget = null;
16330
- this.ikLeftPoleTarget = null;
16331
- this.ikRightFootTarget = null;
16332
- this.ikRightPoleTarget = null;
16333
- this.abstractSkinMesh = null;
16334
- this.rootBoneTransform = null;
16335
- this.leftFootTransform = null;
16336
- this.leftFootPoleOffset = new BABYLON.Vector3(-0.1, 0.5, 0.5);
16337
- this.leftFootMaxAngle = 90;
16338
- this.rightFootTransform = null;
16339
- this.rightFootPoleOffset = new BABYLON.Vector3(0.1, 0.5, 0.5);
16340
- this.rightFootMaxAngle = 90;
16341
- this.ikLeftController = null;
16342
- this.ikRightController = null;
16343
- this.onAnimatorIK = null;
16344
- }
16345
- awake() { this.awakePlayerController(); }
16346
- start() { this.startPlayerController(); }
16347
- after() { this.afterPlayerController(); }
16348
- update() { this.updatePlayerController(); }
16349
- destroy() { this.destroyPlayerController(); }
16350
- syncAnimatorMoveTaker() {
16351
- if (this.animator == null)
16352
- return;
16353
- const takesRootMotion = this.rootMotion === true || this.isRootMotionAction === true;
16354
- this.animator.applyRootMotion = takesRootMotion || this.exportedApplyRootMotion;
16355
- if (takesRootMotion && this.animatorMoveObserver == null) {
16356
- this.animatorMoveObserver = this.animator.onAnimatorMoveObservable.add((animator) => this.onAnimatorMove(animator));
16357
- return;
16358
- }
16359
- if (!takesRootMotion && this.animatorMoveObserver != null) {
16360
- this.animator.onAnimatorMoveObservable.remove(this.animatorMoveObserver);
16361
- this.animatorMoveObserver = null;
16362
- }
16363
- }
16364
- onAnimatorMove(animator) {
16365
- if (this.isPerformingAction === true && this.isRootMotionAction === true) {
16366
- this.applyActionRootMotion(animator);
16367
- return;
16368
- }
16369
- const velocity = animator.velocity;
16370
- this.rootMotionVelocity.set(velocity.x, 0, velocity.z);
16371
- }
16372
- getIsPerformingAction() { return this.isPerformingAction; }
16373
- getIsRootMotionAction() { return this.isRootMotionAction; }
16374
- getIsActionInterruptable() { return this.isActionInterruptable; }
16375
- playActionAnimation(action, interruptableAction = true, enableRootMotion = false, afterActionComplete = null) {
16376
- if (this.isPerformingAction === false && this.animator != null && action >= 0) {
16377
- this.isPerformingAction = true;
16378
- this.performActionTimer = 0;
16379
- this.performActionNumber = action;
16380
- this.afterActionHandler = afterActionComplete;
16381
- this.isActionInterruptable = interruptableAction;
16382
- this.isRootMotionAction = enableRootMotion;
16383
- this.playerRotationSpeed = 10;
16384
- this.rotatePlayerTowards = false;
16385
- this.matchStartTime = 0;
16386
- this.matchTargetTime = 0;
16387
- this.matchTargetOffset = 0;
16388
- this.matchTargetHeight = false;
16389
- this.lockTargetHeight = false;
16390
- this.lastStartHeight = null;
16391
- this.lastTargetHeight = null;
16392
- this.lastTargetNormal.set(0, 0, 0);
16393
- this.lastTargetRotation.set(0, 0, 0, 1);
16394
- this.actionStateEntered = false;
16395
- this.syncAnimatorMoveTaker();
16396
- if (this.isRootMotionAction === true) {
16397
- this.enableCharacterController(false);
16398
- }
16399
- }
16400
- }
16401
- resetActionAnimationState() {
16402
- if (this.afterActionHandler != null) {
16403
- try {
16404
- this.afterActionHandler();
16405
- }
16406
- catch { }
16407
- }
16408
- if (this.isRootMotionAction === true) {
16409
- this.enableCharacterController(true);
16410
- }
16411
- this.performActionTimer = 0;
16412
- this.performActionNumber = 0;
16413
- this.isPerformingAction = false;
16414
- this.isRootMotionAction = false;
16415
- this.isActionInterruptable = false;
16416
- this.afterActionHandler = null;
16417
- this.playerRotationSpeed = 10;
16418
- this.rotatePlayerTowards = false;
16419
- this.matchStartTime = 0;
16420
- this.matchTargetTime = 0;
16421
- this.matchTargetOffset = 0;
16422
- this.matchTargetHeight = false;
16423
- this.lockTargetHeight = false;
16424
- this.lastStartHeight = null;
16425
- this.lastTargetHeight = null;
16426
- this.lastTargetNormal.set(0, 0, 0);
16427
- this.lastTargetRotation.set(0, 0, 0, 1);
16428
- this.actionStateEntered = false;
16429
- this.syncAnimatorMoveTaker();
16430
- }
16431
- updateAnimationActionState() {
16432
- this.performActionTimer += this.getDeltaSeconds();
16433
- }
16434
- applyActionRootMotion(animator) {
16435
- const deltaTime = this.getDeltaSeconds();
16436
- this.lastDeltaPosition.copyFrom(animator.deltaPosition);
16437
- if (this.matchTargetHeight === true)
16438
- this.applyHeightMatch(deltaTime);
16439
- this.transform.position.addInPlace(this.lastDeltaPosition);
16440
- if (this.rotatePlayerTowards === true) {
16441
- this.rotateTowardsClimbSurface(deltaTime);
16442
- return;
16443
- }
16444
- this.lastDeltaRotation.copyFrom(animator.deltaRotation);
16445
- this.transform.rotationQuaternion.multiplyInPlace(this.lastDeltaRotation);
16446
- }
16447
- applyHeightMatch(deltaTime) {
16448
- const playerGlobalHeight = this.transform.absolutePosition.y;
16449
- if (this.lastStartHeight == null && this.performActionTimer >= this.matchStartTime) {
16450
- this.lastStartHeight = playerGlobalHeight;
16451
- this.smoothedPlayerHeight = playerGlobalHeight;
16452
- this.playerHeightVelocity.set(0, 0);
16453
- }
16454
- if (this.lastStartHeight == null || this.lastTargetHeight == null)
16455
- return;
16456
- this.lastDeltaPosition.y = 0;
16457
- const fixedTargetHeight = this.lastTargetHeight + this.matchTargetOffset;
16458
- if (this.performActionTimer < this.matchTargetTime) {
16459
- const dampTime = this.matchTargetTime - this.matchStartTime;
16460
- this.smoothedPlayerHeight = Utilities.SmoothDamp(this.smoothedPlayerHeight, fixedTargetHeight, dampTime, Number.POSITIVE_INFINITY, deltaTime, this.playerHeightVelocity);
16461
- this.lastDeltaPosition.y = this.smoothedPlayerHeight - playerGlobalHeight;
16462
- return;
16463
- }
16464
- if (this.lockTargetHeight === false) {
16465
- this.lastDeltaPosition.y = fixedTargetHeight - playerGlobalHeight;
16466
- this.lockTargetHeight = true;
16467
- }
16468
- }
16469
- rotateTowardsClimbSurface(deltaTime) {
16470
- if (this.climbContact !== true)
16471
- return;
16472
- this.lastTargetNormal.set(-this.climbContactNormal.x, -this.climbContactNormal.y, -this.climbContactNormal.z);
16473
- Utilities.LookRotationToRef(this.lastTargetNormal, this.lastTargetRotation);
16474
- const lerpAmount = BABYLON.Scalar.Clamp(this.playerRotationSpeed * deltaTime);
16475
- BABYLON.Quaternion.SlerpToRef(this.transform.rotationQuaternion, this.lastTargetRotation, lerpAmount, this.transform.rotationQuaternion);
16476
- }
16477
- setWorldPosition(x, y, z) {
16478
- if (this.characterController != null) {
16479
- this.characterController.set(x, y, z);
16480
- }
16481
- }
16482
- getPlayerMesh() { return this.abstractSkinMesh; }
16483
- getRootHipBone() { return (this.rootBoneTransform != null) ? this.rootBoneTransform._linkedBone : null; }
16484
- getLeftFootBone() { return (this.leftFootTransform != null) ? this.leftFootTransform._linkedBone : null; }
16485
- getRightFootBone() { return (this.rightFootTransform != null) ? this.rightFootTransform._linkedBone : null; }
16486
- getLeftFootTarget() { return this.ikLeftFootTarget; }
16487
- getRightFootTarget() { return this.ikRightFootTarget; }
16488
- getLeftFootPoleTarget() { return this.ikLeftPoleTarget; }
16489
- getRightFootPoleTarget() { return this.ikRightPoleTarget; }
16490
- getRootBoneTransform() { return this.rootBoneTransform; }
16491
- getLeftFootTransform() { return this.leftFootTransform; }
16492
- getRightFootTransform() { return this.rightFootTransform; }
16493
- getLeftFootController() { return this.ikLeftController; }
16494
- getRightFootController() { return this.ikRightController; }
16495
- isGroundedFootIKActive() { return (this.isCharacterGrounded === true && this.animator != null && this.animator.hasIKPassLayer()); }
16496
- setupBoneControllers() {
16497
- const createFootIKRig = this.getProperty("createFootIKRig");
16498
- if (createFootIKRig === true) {
16499
- const displayHandles = this.getProperty("displayHandles");
16500
- const abstractSkinMeshData = this.getProperty("abstractSkinMesh");
16501
- if (abstractSkinMeshData != null)
16502
- this.abstractSkinMesh = this.getChildNode(abstractSkinMeshData.name, SearchType.ExactMatch, false);
16503
- const rootBoneTransformData = this.getProperty("rootBoneTransform");
16504
- if (rootBoneTransformData != null)
16505
- this.rootBoneTransform = this.getChildNode(rootBoneTransformData.name, SearchType.ExactMatch, false);
16506
- const leftFootTransformData = this.getProperty("leftFootTransform");
16507
- if (leftFootTransformData != null)
16508
- this.leftFootTransform = this.getChildNode(leftFootTransformData.name, SearchType.ExactMatch, false);
16509
- const leftPoleHandleData = this.getProperty("leftFootPoleOffset");
16510
- if (leftPoleHandleData != null)
16511
- this.leftFootPoleOffset.copyFrom(Utilities.ParseVector3(leftPoleHandleData));
16512
- this.leftFootMaxAngle = this.getProperty("leftFootMaxAngle", this.leftFootMaxAngle);
16513
- const rightFootTransformData = this.getProperty("rightFootTransform");
16514
- if (rightFootTransformData != null)
16515
- this.rightFootTransform = this.getChildNode(rightFootTransformData.name, SearchType.ExactMatch, false);
16516
- const rightPoleHandleData = this.getProperty("rightFootPoleOffset");
16517
- if (rightPoleHandleData != null)
16518
- this.rightFootPoleOffset.copyFrom(Utilities.ParseVector3(rightPoleHandleData));
16519
- this.rightFootMaxAngle = this.getProperty("rightFootMaxAngle", this.rightFootMaxAngle);
16520
- if (this.abstractSkinMesh != null && this.rootBoneTransform != null) {
16521
- let materialName = "M_TARGET_MESH";
16522
- let targetMaterial = this.scene.getMaterialByName(materialName);
16523
- if (targetMaterial == null) {
16524
- targetMaterial = new BABYLON.StandardMaterial("M_TARGET_MESH", this.scene);
16525
- targetMaterial.diffuseColor = new BABYLON.Color3(1.0, 0.5, 0.25);
16526
- }
16527
- if (this.leftFootTransform != null && this.leftFootTransform._linkedBone != null) {
16528
- this.ikLeftFootTarget = BABYLON.MeshBuilder.CreateBox(this.transform.name + ".LeftFootTarget", { width: 0.1, height: 0.1, depth: 0.1 }, this.scene);
16529
- this.ikLeftFootTarget.parent = this.leftFootTransform;
16530
- this.ikLeftFootTarget.position.set(0, 0, 0);
16531
- this.ikLeftFootTarget.material = targetMaterial;
16532
- this.ikLeftFootTarget.isVisible = displayHandles;
16533
- this.ikLeftPoleTarget = BABYLON.MeshBuilder.CreateSphere(this.transform.name + ".LeftFootPole", { diameter: 0.1 }, this.scene);
16534
- this.ikLeftPoleTarget.parent = this.abstractSkinMesh;
16535
- this.ikLeftPoleTarget.position.copyFrom(this.leftFootPoleOffset);
16536
- this.ikLeftPoleTarget.isVisible = displayHandles;
16537
- }
16538
- if (this.rightFootTransform != null && this.rightFootTransform._linkedBone != null) {
16539
- this.ikRightFootTarget = BABYLON.MeshBuilder.CreateBox(this.transform.name + ".RightFootTarget", { width: 0.1, height: 0.1, depth: 0.1 }, this.scene);
16540
- this.ikRightFootTarget.parent = this.rightFootTransform;
16541
- this.ikRightFootTarget.position.set(0, 0, 0);
16542
- this.ikRightFootTarget.material = targetMaterial;
16543
- this.ikRightFootTarget.isVisible = displayHandles;
16544
- this.ikRightPoleTarget = BABYLON.MeshBuilder.CreateSphere(this.transform.name + ".RightFootPole", { diameter: 0.1 }, this.scene);
16545
- this.ikRightPoleTarget.parent = this.abstractSkinMesh;
16546
- this.ikRightPoleTarget.position.copyFrom(this.rightFootPoleOffset);
16547
- this.ikRightPoleTarget.isVisible = displayHandles;
16548
- }
16549
- }
16550
- }
16551
- }
16552
- attachAnimationController() {
16553
- if (this.animator == null)
16554
- this.animator = this.getComponent(Animator.ClassName, true);
16555
- if (this.animator == null)
16556
- return;
16557
- this.exportedApplyRootMotion = this.animator.applyRootMotion;
16558
- this.animator.onStateEnterObservable.add((change) => this.onAnimatorStateEnter(change));
16559
- this.animator.onStateExitObservable.add((change) => this.onAnimatorStateExit(change));
16560
- this.animator.onAnimatorIKObservable.add(() => this.onAnimatorIKPass());
16561
- this.syncAnimatorMoveTaker();
16562
- }
16563
- onAnimatorStateEnter(change) {
16564
- if (this.isPerformingAction !== true || this.actionStateEntered === true || change.layerIndex !== 0)
16565
- return;
16566
- this.actionStateHash = change.stateInfo.fullPathHash;
16567
- this.actionStateEntered = true;
16568
- }
16569
- onAnimatorStateExit(change) {
16570
- if (this.isPerformingAction !== true || this.actionStateEntered !== true)
16571
- return;
16572
- if (change.layerIndex !== 0 || change.stateInfo.fullPathHash !== this.actionStateHash)
16573
- return;
16574
- this.resetActionAnimationState();
16575
- }
16576
- onAnimatorIKPass() {
16577
- if (this.onAnimatorIK != null) {
16578
- this.onAnimatorIK();
16579
- return;
16580
- }
16581
- this.updateAnimatorTargetMeshes();
16582
- if (this.ikLeftController != null)
16583
- this.ikLeftController.update();
16584
- if (this.ikRightController != null)
16585
- this.ikRightController.update();
16586
- }
16587
- updateAnimatorTargetMeshes() {
16588
- }
16589
- enableCharacterController(state) {
16590
- if (state === true) {
16591
- this.movementAllowed = true;
16592
- this.resetPlayerJumpingState();
16593
- if (this.characterController != null) {
16594
- this.characterController.setGravityFactor(this.gravitationalForce);
16595
- this.characterController.setCollisionState(true);
16596
- }
16597
- }
16598
- else {
16599
- this.movementAllowed = false;
16600
- this.resetPlayerJumpingState();
16601
- if (this.characterController != null) {
16602
- this.characterController.setGravityFactor(0);
16603
- this.characterController.setCollisionState(false);
16604
- }
16605
- }
16606
- }
16607
- resetPlayerJumpingState() {
16608
- this.isCharacterJumping = false;
16609
- this.isCharacterLanding = false;
16610
- this.isCharacterRising = false;
16611
- this.isCharacterJumpFrame = false;
16612
- if (this.characterController != null) {
16613
- this.characterController.jump(0);
16614
- }
16615
- }
16616
- awakePlayerController() {
16617
- this.gravitationalForce = this.getProperty("gravityMultiplier", this.gravitationalForce);
16618
- this.verticalStepSpeed = this.getProperty("stepUpVelocity", this.verticalStepSpeed);
16619
- this.minStepUpHeight = this.getProperty("minStepHeight", this.minStepUpHeight);
16620
- this.rigidBodyMass = this.getProperty("rigidBodyMass", this.rigidBodyMass);
16621
- this.mouseWheel = this.getProperty("mouseWheel", this.mouseWheel);
16622
- this.rayClimbLength = this.getProperty("rayClimbLength", this.rayClimbLength);
16623
- this.rayClimbOffset = this.getProperty("rayClimbOffset", this.rayClimbOffset);
16624
- this.rayHeightLength = this.getProperty("rayHeightLength", this.rayHeightLength);
16625
- this.rayHeightOffset = this.getProperty("rayHeightOffset", this.rayHeightOffset);
16626
- this.maxAngle = this.getProperty("maxAngle", this.maxAngle);
16627
- this.landingEpsilon = this.getProperty("landingEpsilon", this.landingEpsilon);
16628
- this.minFallVelocity = this.getProperty("minFallVelocity", this.minFallVelocity);
16629
- this.airbornTimeout = this.getProperty("airbornTimeout", this.airbornTimeout);
16630
- this.rootMotion = this.getProperty("rootMotion", this.rootMotion);
16631
- this.moveSpeed = this.getProperty("moveSpeed", this.moveSpeed);
16632
- this.walkSpeed = this.getProperty("walkSpeed", this.walkSpeed);
16633
- this.jumpSpeed = this.getProperty("jumpSpeed", this.jumpSpeed);
16634
- this.jumpDelay = this.getProperty("jumpDelay", this.jumpDelay);
16635
- this.lowTurnSpeed = this.getProperty("lowTurnSpeed", this.lowTurnSpeed);
16636
- this.highTurnSpeed = this.getProperty("highTurnSpeed", this.highTurnSpeed);
16637
- this.enableInput = this.getProperty("enableInput", this.enableInput);
16638
- this.attachCamera = this.getProperty("attachCamera", this.attachCamera);
16639
- this.playerNumber = this.getProperty("playerNumber", this.playerNumber);
16640
- this.runKeyRequired = this.getProperty("runKeyRequired", this.runKeyRequired);
16641
- this.distanceFactor = this.getProperty("distanceFactor", this.distanceFactor);
16642
- this.minimumDistance = this.getProperty("minimumDistance", this.minimumDistance);
16643
- this.smoothDampTime = this.getProperty("smoothDampTime", this.smoothDampTime);
16644
- this.smoothInputVectors = this.getProperty("smoothInputVectors", this.smoothInputVectors);
16645
- this.smoothAcceleration = this.getProperty("smoothAcceleration", this.smoothAcceleration);
16646
- this.accelerationSpeed = this.getProperty("accelerationSpeed", this.accelerationSpeed);
16647
- this.decelerationSpeed = this.getProperty("decelerationSpeed", this.decelerationSpeed);
16648
- this.climbVolumeTag = this.getProperty("climbVolumeTag", this.climbVolumeTag);
16649
- this.vaultVolumeTag = this.getProperty("vaultVolumeTag", this.vaultVolumeTag);
16650
- this.useClimbSystem = this.getProperty("useClimbSystem", this.useClimbSystem);
16651
- this.maxHeightRanges = this.getProperty("maxHeightRanges", this.maxHeightRanges);
16652
- this.smoothMotionSpeed = this.getProperty("smoothMotionSpeed", this.smoothMotionSpeed);
16653
- this.updateStateParams = this.getProperty("updateStateParams", this.updateStateParams);
16654
- this.animationStateParams = this.getProperty("animationStateParams", this.animationStateParams);
16655
- this.analogMovement = this.getProperty("analogMovement", this.analogMovement);
16656
- this.postNetworkAttributes = this.getProperty("postNetworkAttribs", this.postNetworkAttributes);
16657
- this.groundCheckDistance = this.getProperty("groundCheckDist", this.groundCheckDistance);
16658
- const arrowKeyRotation = this.getProperty("arrowKeyRotation");
16659
- if (arrowKeyRotation === true)
16660
- UserInputOptions.UseArrowKeyRotation = true;
16661
- this.setupBoneControllers();
16662
- }
16663
- startPlayerController() {
16664
- if (this.attachCamera === true) {
16665
- DefaultCameraSystem.SetAutoUpdate(false);
16666
- DefaultCameraSystem.SetFollowTarget(this.transform);
16667
- console.log("Attaching Player Camera: " + this.transform.name);
16668
- }
16669
- this.navigationAgent = this.getComponent("TOOLKIT.NavigationAgent");
16670
- this.characterController = this.getComponent("TOOLKIT.CharacterController");
16671
- if (this.characterController != null) {
16672
- this.avatarRadius = this.characterController.getAvatarRadius();
16673
- this.characterController.enableGravity = true;
16674
- this.characterController.enableStepOffset = true;
16675
- this.characterController.useMultiRaycast = true;
16676
- this.characterController.multiRaycastCount = 5;
16677
- this.characterController.stepUpVelocityFactor = 0.5;
16678
- this.characterController.groundCheckDistance = this.groundCheckDistance;
16679
- this.characterController.setRigidBodyMass(this.rigidBodyMass);
16680
- this.characterController.setGravityFactor(this.gravitationalForce);
16681
- this.characterController.onUpdatePositionObservable.add(() => {
16682
- this.updatePlayerPosition();
16683
- if (this.attachCamera === true) {
16684
- DefaultCameraSystem.UpdateFollowTarget();
16685
- }
16686
- });
16687
- SceneManager.LogWarning("Starting player controller in physic engine mode for: " + this.transform.name);
16688
- }
16689
- else {
16690
- SceneManager.LogWarning("No character controller found for: " + this.transform.name);
16691
- }
16692
- }
16693
- updatePlayerPosition() {
16694
- if (this.onPlayerPositionObservable && this.onPlayerPositionObservable.hasObservers()) {
16695
- this.onPlayerPositionObservable.notifyObservers(this.transform);
16696
- }
16697
- }
16698
- updatePlayerController() {
16699
- this.deltaTime = this.getDeltaSeconds();
16700
- if (!this.isReady())
16701
- return;
16702
- this.m_actualVelocity = this.transform.absolutePosition.subtract(this.m_lastPosition);
16703
- this.m_linearVelocity.copyFrom(this.m_actualVelocity);
16704
- this.m_scaledVelocity = (this.m_linearVelocity.length() / this.deltaTime);
16705
- this.m_linearVelocity.normalize();
16706
- this.m_linearVelocity.scaleInPlace(this.m_scaledVelocity);
16707
- if (this.playerDrawVelocity > 0) {
16708
- this.m_velocityOffset.copyFrom(this.m_linearVelocity);
16709
- this.m_velocityOffset.scaleInPlace(this.playerDrawVelocity);
16710
- }
16711
- else {
16712
- this.m_velocityOffset.set(0, 0, 0);
16713
- }
16714
- this.m_lastPosition.copyFrom(this.transform.absolutePosition);
16715
- if (this.updateStateParams === true && this.animator == null) {
16716
- this.attachAnimationController();
16717
- }
16718
- if (this.isCharacterGrounded === true && this.delayJumpTimer > 0) {
16719
- this.delayJumpTimer -= this.deltaTime;
16720
- if (this.delayJumpTimer < 0)
16721
- this.delayJumpTimer = 0;
16722
- }
16723
- this.canPlayerJump = true;
16724
- if (this.isPerformingAction === true) {
16725
- this.updateAnimationActionState();
16726
- if (this.onUpdateActionObservable && this.onUpdateActionObservable.hasObservers()) {
16727
- this.onUpdateActionObservable.notifyObservers(this.transform);
16728
- }
16729
- }
16730
- if (this.enableInput === false) {
16731
- return;
16732
- }
16733
- const userInputX = InputController.GetUserInput(UserInputAxis.Horizontal, this.playerNumber);
16734
- const userInputZ = InputController.GetUserInput(UserInputAxis.Vertical, this.playerNumber);
16735
- const userMouseX = InputController.GetUserInput(UserInputAxis.MouseX, this.playerNumber);
16736
- const userMouseY = InputController.GetUserInput(UserInputAxis.MouseY, this.playerNumber);
16737
- if (this.smoothAcceleration === true) {
16738
- if (userInputX > 0) {
16739
- this.playerInputX += (this.accelerationSpeed * this.deltaTime);
16740
- if (this.playerInputX > 1)
16741
- this.playerInputX = 1;
16742
- }
16743
- else if (userInputX < 0) {
16744
- this.playerInputX -= (this.accelerationSpeed * this.deltaTime);
16745
- if (this.playerInputX < -1)
16746
- this.playerInputX = -1;
16747
- }
16748
- else {
16749
- if (this.playerInputX < 0) {
16750
- this.playerInputX += (this.decelerationSpeed * this.deltaTime);
16751
- if (this.playerInputX > 0)
16752
- this.playerInputX = 0;
16753
- }
16754
- else if (this.playerInputX > 0) {
16755
- this.playerInputX -= (this.decelerationSpeed * this.deltaTime);
16756
- if (this.playerInputX < 0)
16757
- this.playerInputX = 0;
16758
- }
16759
- }
16760
- if (userInputZ > 0) {
16761
- this.playerInputZ += (this.accelerationSpeed * this.deltaTime);
16762
- if (this.playerInputZ > 1)
16763
- this.playerInputZ = 1;
16764
- }
16765
- else if (userInputZ < 0) {
16766
- this.playerInputZ -= (this.accelerationSpeed * this.deltaTime);
16767
- if (this.playerInputZ < -1)
16768
- this.playerInputZ = -1;
16769
- }
16770
- else {
16771
- if (this.playerInputZ < 0) {
16772
- this.playerInputZ += (this.decelerationSpeed * this.deltaTime);
16773
- if (this.playerInputZ > 0)
16774
- this.playerInputZ = 0;
16775
- }
16776
- else if (this.playerInputZ > 0) {
16777
- this.playerInputZ -= (this.decelerationSpeed * this.deltaTime);
16778
- if (this.playerInputZ < 0)
16779
- this.playerInputZ = 0;
16780
- }
16781
- }
16782
- }
16783
- else {
16784
- this.playerInputX = userInputX;
16785
- this.playerInputZ = userInputZ;
16786
- }
16787
- this.playerMouseX = userMouseX;
16788
- this.playerMouseY = userMouseY;
16789
- if (this.isPerformingAction === true && this.isActionInterruptable === true) {
16790
- if (this.playerInputX !== 0 || this.playerInputZ !== 0) {
16791
- this.resetActionAnimationState();
16792
- }
16793
- }
16794
- if (this.isPerformingAction === true) {
16795
- this.canPlayerJump = false;
16796
- this.playerInputX = 0;
16797
- this.playerInputZ = 0;
16798
- }
16799
- if (this.onPlayerInputObservable && this.onPlayerInputObservable.hasObservers()) {
16800
- this.onPlayerInputObservable.notifyObservers(this.transform);
16801
- }
16802
- this.inputMovementVector.set(this.playerInputX, 0, this.playerInputZ);
16803
- if (this.inputMovementVector.length() > 1.0)
16804
- this.inputMovementVector.normalize();
16805
- this.inputMagnitude = this.inputMovementVector.length();
16806
- const moveForward = (this.playerInputZ > 0);
16807
- const moveBackward = (this.playerInputZ < 0);
16808
- const moveRight = (this.playerInputX > 0);
16809
- const moveLeft = (this.playerInputX < 0);
16810
- if (moveForward === true) {
16811
- if (moveLeft === true) {
16812
- this.playerMoveDirection = PlayerMoveDirection.ForwardLeft;
16813
- }
16814
- else if (moveRight === true) {
16815
- this.playerMoveDirection = PlayerMoveDirection.ForwardRight;
16816
- }
16817
- else {
16818
- this.playerMoveDirection = PlayerMoveDirection.Forward;
16819
- }
16820
- }
16821
- else if (moveBackward === true) {
16822
- if (moveLeft === true) {
16823
- this.playerMoveDirection = PlayerMoveDirection.BackwardLeft;
16824
- }
16825
- else if (moveRight === true) {
16826
- this.playerMoveDirection = PlayerMoveDirection.BackwardRight;
16827
- }
16828
- else {
16829
- this.playerMoveDirection = PlayerMoveDirection.Backward;
16830
- }
16831
- }
16832
- else if (moveLeft === true) {
16833
- this.playerMoveDirection = PlayerMoveDirection.StrafingLeft;
16834
- }
16835
- else if (moveRight === true) {
16836
- this.playerMoveDirection = PlayerMoveDirection.StrafingRight;
16837
- }
16838
- else {
16839
- this.playerMoveDirection = PlayerMoveDirection.Stationary;
16840
- }
16841
- if (this.onPreUpdateObservable && this.onPreUpdateObservable.hasObservers()) {
16842
- this.onPreUpdateObservable.notifyObservers(this.transform);
16843
- }
16844
- if (this.freeCamera == null)
16845
- this.freeCamera = DefaultCameraSystem.GetMainCamera(this.scene, false);
16846
- if (this.freeCamera == null)
16847
- this.freeCamera = this.scene.activeCamera;
16848
- this.cameraForwardVector = this.freeCamera.getForwardRay().direction;
16849
- this.cameraForwardVector.y = 0;
16850
- this.cameraForwardVector.normalize();
16851
- this.cameraForwardVector.scaleToRef(this.inputMovementVector.z, this.desiredForwardVector);
16852
- this.cameraRightVector = BABYLON.Vector3.Cross(this.cameraForwardVector, BABYLON.Vector3.Up());
16853
- this.cameraRightVector.y = 0;
16854
- this.cameraRightVector.normalize();
16855
- this.cameraRightVector.scaleToRef(-this.inputMovementVector.x, this.desiredRightVector);
16856
- if (this.movementAllowed === false) {
16857
- this.canPlayerJump = false;
16858
- this.playerInputX = 0;
16859
- this.playerInputZ = 0;
16860
- }
16861
- this.isRunPressed = (InputController.GetKeyboardInput(this.keyboardRun) || InputController.GetGamepadButtonInput(this.buttonRun));
16862
- this.isJumpPressed = (InputController.GetKeyboardInput(this.keyboardJump) || InputController.GetGamepadButtonInput(this.buttonJump));
16863
- this.movementSpeed = (this.inputMagnitude * this.moveSpeed * this.speedFactor);
16864
- if (this.runKeyRequired === true && this.isRunPressed === false) {
16865
- this.movementSpeed = BABYLON.Scalar.Clamp(this.movementSpeed, 0, this.walkSpeed);
16866
- }
16867
- this.desiredForwardVector.addToRef(this.desiredRightVector, this.playerMovementVelocity);
16868
- this.playerLookRotation.copyFrom(this.playerMovementVelocity);
16869
- this.playerMovementVelocity.scaleInPlace(this.movementSpeed);
16870
- this.transform.rotationQuaternion.copyFrom(this.lastRotationQuaternion);
16871
- if (this.movementAllowed == true) {
16872
- if (this.inputMagnitude > 0) {
16873
- Utilities.LookRotationToRef(this.playerLookRotation, this.playerRotationQuaternion);
16874
- const forwardTurnRatio = (this.playerLookRotation.length() / this.moveSpeed);
16875
- const forwardTurnSpeed = BABYLON.Scalar.Lerp(this.highTurnSpeed, this.lowTurnSpeed, forwardTurnRatio);
16876
- const rotationDelta = Math.abs(BABYLON.Quaternion.Dot(this.transform.rotationQuaternion, this.playerRotationQuaternion));
16877
- const adaptiveRotationSpeed = rotationDelta < 0.85 ? forwardTurnSpeed * 0.85 : forwardTurnSpeed;
16878
- BABYLON.Quaternion.SlerpToRef(this.transform.rotationQuaternion, this.playerRotationQuaternion, (adaptiveRotationSpeed * this.deltaTime), this.transform.rotationQuaternion);
16879
- this.lastRotationQuaternion.copyFrom(this.transform.rotationQuaternion);
16880
- }
16881
- }
16882
- this.verticalVelocity = this.getVerticalVelocity();
16883
- this.movementVelocity.copyFrom(this.playerMovementVelocity);
16884
- this.hasGroundedContact = (this.characterController != null) ? this.characterController.isGrounded() : false;
16885
- this.isCharacterGrounded = false;
16886
- this.isCharacterSliding = false;
16887
- this.isCharacterFalling = false;
16888
- this.isCharacterJumpFrame = false;
16889
- this.isCharacterNavigating = (this.navigationAgent != null && this.navigationAgent.isNavigating());
16890
- this.navigationAngularSpeed = (this.navigationAgent != null) ? this.navigationAgent.angularSpeed : 0;
16891
- this.updateCharacterController();
16892
- if (this.animator != null && this.updateStateParams === true) {
16893
- this.validateAnimationStateParams();
16894
- this.animator.setInteger(this.animationStateParams.moveDirection, this.playerMoveDirection);
16895
- this.animator.setFloat(this.animationStateParams.heightInput, this.verticalVelocity);
16896
- this.animator.setBool(this.animationStateParams.jumpFrame, this.isCharacterJumpFrame);
16897
- this.animator.setBool(this.animationStateParams.jumpState, this.isCharacterJumping);
16898
- this.animator.setInteger(this.animationStateParams.actionState, this.performActionNumber);
16899
- this.animator.setBool(this.animationStateParams.fallingState, this.isCharacterFalling);
16900
- this.animator.setBool(this.animationStateParams.slidingState, this.isCharacterSliding);
16901
- this.animator.setBool(this.animationStateParams.groundedState, this.isCharacterGrounded);
16902
- if (this.smoothMotionSpeed === true && this.smoothDampTime > 0) {
16903
- if (this.smoothInputVectors === true) {
16904
- this.animator.setFloat(this.animationStateParams.horizontalInput, this.playerInputX, this.smoothDampTime, this.deltaTime);
16905
- this.animator.setFloat(this.animationStateParams.verticalInput, this.playerInputZ, this.smoothDampTime, this.deltaTime);
16906
- this.animator.setFloat(this.animationStateParams.mouseXInput, this.playerMouseX, this.smoothDampTime, this.deltaTime);
16907
- this.animator.setFloat(this.animationStateParams.mouseYInput, this.playerMouseY, this.smoothDampTime, this.deltaTime);
16908
- this.animator.setFloat(this.animationStateParams.inputMagnitude, this.inputMagnitude, this.smoothDampTime, this.deltaTime);
16909
- }
16910
- else {
16911
- this.animator.setFloat(this.animationStateParams.horizontalInput, this.playerInputX);
16912
- this.animator.setFloat(this.animationStateParams.verticalInput, this.playerInputZ);
16913
- this.animator.setFloat(this.animationStateParams.mouseXInput, this.playerMouseX);
16914
- this.animator.setFloat(this.animationStateParams.mouseYInput, this.playerMouseY);
16915
- this.animator.setFloat(this.animationStateParams.inputMagnitude, this.inputMagnitude);
16916
- }
16917
- this.animator.setFloat(this.animationStateParams.speedInput, this.movementSpeed, this.smoothDampTime, this.deltaTime);
16918
- this.animator.setFloat(this.animationStateParams.motionSpeed, (this.analogMovement === true) ? this.inputMagnitude : 1);
16919
- }
16920
- else {
16921
- this.animator.setFloat(this.animationStateParams.horizontalInput, this.playerInputX);
16922
- this.animator.setFloat(this.animationStateParams.verticalInput, this.playerInputZ);
16923
- this.animator.setFloat(this.animationStateParams.mouseXInput, this.playerMouseX);
16924
- this.animator.setFloat(this.animationStateParams.mouseYInput, this.playerMouseY);
16925
- this.animator.setFloat(this.animationStateParams.inputMagnitude, this.inputMagnitude);
16926
- this.animator.setFloat(this.animationStateParams.speedInput, this.movementSpeed);
16927
- this.animator.setFloat(this.animationStateParams.motionSpeed, (this.analogMovement === true) ? this.inputMagnitude : 1);
16928
- }
16929
- if (this.isCharacterNavigating === true) {
16930
- }
16931
- if (this.onAnimationStateObservable && this.onAnimationStateObservable.hasObservers()) {
16932
- this.onAnimationStateObservable.notifyObservers(this.transform);
16933
- }
16934
- }
16935
- if (this.onPostUpdateObservable && this.onPostUpdateObservable.hasObservers()) {
16936
- this.onPostUpdateObservable.notifyObservers(this.transform);
16937
- }
16938
- }
16939
- afterPlayerController() {
16940
- }
16941
- updateCharacterController() {
16942
- if (this.characterController != null) {
16943
- this.isCharacterRising = (this.isCharacterJumping == true && this.verticalVelocity > 0);
16944
- this.isCharacterLanding = (this.isCharacterJumping == true && this.verticalVelocity < 0);
16945
- if (this.isCharacterRising == true) {
16946
- this.hasGroundedContact = false;
16947
- }
16948
- const minJumpTimer = this.characterController.getMinJumpTimer();
16949
- if (this.hasGroundedContact === true && minJumpTimer <= 0) {
16950
- this.isCharacterSliding = false;
16951
- this.isCharacterGrounded = true;
16952
- }
16953
- if (this.isCharacterGrounded === true)
16954
- this.isCharacterJumping = false;
16955
- this.isCharacterFalling = (this.isCharacterGrounded === false && this.isCharacterSliding == false && this.isCharacterJumping == false && this.verticalVelocity < 0 && Math.abs(this.verticalVelocity) >= this.minFallVelocity);
16956
- if (this.isCharacterFalling === true && this.isCharacterFallTriggered === false) {
16957
- this.isCharacterFallTriggered = true;
16958
- if (this.jumpDelay > 0)
16959
- this.delayJumpTimer = this.jumpDelay;
16960
- }
16961
- if (this.isCharacterGrounded === true)
16962
- this.isCharacterFallTriggered = false;
16963
- if (this.useClimbSystem === true) {
16964
- this.castPhysicsClimbingVolumeRay();
16965
- this.castPhysicsHeightCheckVolumeRay();
16966
- }
16967
- if (this.isCharacterNavigating === false && this.movementAllowed === true) {
16968
- if (this.isCharacterGrounded === true) {
16969
- if (this.delayJumpTimer <= 0)
16970
- this.isCharacterJumpFrame = (this.canPlayerJump === true && this.isJumpPressed === true);
16971
- if (this.isPerformingAction === false && this.isCharacterJumpFrame === true && this.useClimbSystem === true && this.climbContact === true && this.heightContact === true) {
16972
- let climbAction = -1;
16973
- let rotateSpeed = 1;
16974
- let rotateTowards = false;
16975
- let matchHeight = false;
16976
- let startTime = 0;
16977
- let targetTime = 0;
16978
- let targetOffset = 0;
16979
- const hitHeight = parseFloat(this.heightContactPoint.y.toFixed(2));
16980
- const playerHeight = parseFloat(this.transform.position.y.toFixed(2));
16981
- const obstacleHeight = parseFloat((hitHeight - playerHeight).toFixed(2));
16982
- if (obstacleHeight >= this.maxHeightRanges.stepUpRange.minimumHeight && obstacleHeight <= this.maxHeightRanges.stepUpRange.maximumHeight) {
16983
- climbAction = ActionAnimationType.StepUp;
16984
- rotateSpeed = this.maxHeightRanges.stepUpRange.rotationSpeed;
16985
- rotateTowards = this.maxHeightRanges.stepUpRange.rotateTowards;
16986
- matchHeight = this.maxHeightRanges.stepUpRange.matchHeight;
16987
- startTime = this.maxHeightRanges.stepUpRange.startTime;
16988
- targetTime = this.maxHeightRanges.stepUpRange.targetTime;
16989
- targetOffset = this.maxHeightRanges.stepUpRange.targetOffset;
16990
- }
16991
- else if (obstacleHeight >= this.maxHeightRanges.jumpUpRange.minimumHeight && obstacleHeight <= this.maxHeightRanges.jumpUpRange.maximumHeight) {
16992
- climbAction = ActionAnimationType.JumpUp;
16993
- rotateSpeed = this.maxHeightRanges.jumpUpRange.rotationSpeed;
16994
- rotateTowards = this.maxHeightRanges.jumpUpRange.rotateTowards;
16995
- matchHeight = this.maxHeightRanges.jumpUpRange.matchHeight;
16996
- startTime = this.maxHeightRanges.jumpUpRange.startTime;
16997
- targetTime = this.maxHeightRanges.jumpUpRange.targetTime;
16998
- targetOffset = this.maxHeightRanges.jumpUpRange.targetOffset;
16999
- }
17000
- else if (obstacleHeight >= this.maxHeightRanges.climbUpRange.minimumHeight && obstacleHeight <= this.maxHeightRanges.climbUpRange.maximumHeight) {
17001
- climbAction = ActionAnimationType.ClimbUp;
17002
- rotateSpeed = this.maxHeightRanges.climbUpRange.rotationSpeed;
17003
- rotateTowards = this.maxHeightRanges.climbUpRange.rotateTowards;
17004
- matchHeight = this.maxHeightRanges.climbUpRange.matchHeight;
17005
- startTime = this.maxHeightRanges.climbUpRange.startTime;
17006
- targetTime = this.maxHeightRanges.climbUpRange.targetTime;
17007
- targetOffset = this.maxHeightRanges.climbUpRange.targetOffset;
17008
- }
17009
- if (climbAction >= 0) {
17010
- if (this.canClimbObstaclePredicate == null || this.canClimbObstaclePredicate(climbAction) === true) {
17011
- this.isCharacterJumpFrame = false;
17012
- this.isCharacterJumping = false;
17013
- this.isCharacterLanding = false;
17014
- this.isCharacterRising = false;
17015
- this.playActionAnimation(climbAction, false, true);
17016
- this.playerRotationSpeed = rotateSpeed;
17017
- this.rotatePlayerTowards = rotateTowards;
17018
- this.matchTargetHeight = matchHeight;
17019
- this.matchStartTime = (startTime - ThirdPersonPlayerController.MIN_TIMER_OFFSET);
17020
- this.matchTargetTime = (targetTime - ThirdPersonPlayerController.MIN_TIMER_OFFSET);
17021
- this.matchTargetOffset = targetOffset;
17022
- this.lastTargetHeight = hitHeight;
17023
- this.lastStartHeight = null;
17024
- this.lockTargetHeight = false;
17025
- }
17026
- }
17027
- }
17028
- if (this.isCharacterJumpFrame === true && this.jumpSpeed > 0) {
17029
- if (this.airbornTimeout > 0)
17030
- this.characterController.defaultJumpingTimer = (this.airbornTimeout + this.deltaTime);
17031
- this.isCharacterJumping = true;
17032
- this.characterController.jump(this.jumpSpeed);
17033
- if (this.jumpDelay > 0)
17034
- this.delayJumpTimer = this.jumpDelay;
17035
- this.lastJumpVelocity.set(this.movementVelocity.x, 0, this.movementVelocity.z);
17036
- }
17037
- if (this.onBeforeMoveObservable && this.onBeforeMoveObservable.hasObservers()) {
17038
- this.onBeforeMoveObservable.notifyObservers(this.transform);
17039
- }
17040
- if (this.animator != null && this.rootMotion === true) {
17041
- this.movementVelocity.set(this.rootMotionVelocity.x, 0, this.rootMotionVelocity.z);
17042
- this.characterController.move(this.movementVelocity);
17043
- }
17044
- else {
17045
- this.characterController.move(this.movementVelocity);
17046
- }
17047
- }
17048
- else {
17049
- }
17050
- }
17051
- else {
17052
- }
17053
- }
17054
- }
17055
- castPhysicsClimbingVolumeRay() {
17056
- let raycast = null;
17057
- this.climbContact = false;
17058
- this.climbContactNode = null;
17059
- this.climbContactPoint.set(0, 0, 0);
17060
- this.climbContactNormal.set(0, 0, 0);
17061
- this.climbContactAngle = 0;
17062
- this.climbContactDistance = 0;
17063
- const playerTransformForwardDirection = Utilities.TransformDirection(this.transform, this.forwardDirection);
17064
- this.offsetClimbRaycastPosition.set(0, this.rayClimbOffset, 0);
17065
- Utilities.GetAbsolutePositionToRef(this.transform, this.startClimbRaycastPosition, this.offsetClimbRaycastPosition);
17066
- Utilities.GetAbsolutePositionToRef(this.transform, this.endClimbRaycastPosition, this.forwardDirection.scale(this.rayClimbLength));
17067
- this.endClimbRaycastPosition.y += this.rayClimbOffset;
17068
- if (raycast != null && raycast.hasHit === true && raycast.collisionObject != null && raycast.collisionObject.entity != null) {
17069
- const checkTag = SceneManager.GetTransformTag(raycast.collisionObject.entity);
17070
- if (checkTag === this.climbVolumeTag) {
17071
- this.climbContact = true;
17072
- this.climbContactNode = raycast.collisionObject.entity;
17073
- if (raycast.hitPoint != null)
17074
- this.climbContactPoint.copyFrom(raycast.hitPoint);
17075
- if (raycast.hitNormal != null)
17076
- this.climbContactNormal.copyFrom(raycast.hitNormal);
17077
- this.climbContactAngle = (this.climbContactNormal != null) ? Math.abs(Utilities.GetAngle(this.climbContactNormal, BABYLON.Vector3.UpReadOnly)) : 0;
17078
- this.climbContactDistance = raycast.hitDistance;
17079
- }
17080
- }
17081
- if (this.showDebugColliders === true) {
17082
- if (this.climbSensorLine == null)
17083
- this.climbSensorLine = new LinesMeshRenderer(this.transform.name + ".ClimbingSensorLine", this.scene);
17084
- if (raycast != null && this.climbContact === true) {
17085
- this.climbSensorLine.drawLine([this.startClimbRaycastPosition, raycast.hitPoint], BABYLON.Color3.Red());
17086
- }
17087
- else {
17088
- this.climbSensorLine.drawLine([this.startClimbRaycastPosition, this.endClimbRaycastPosition], BABYLON.Color3.Green());
17089
- }
17090
- }
17091
- }
17092
- castPhysicsHeightCheckVolumeRay() {
17093
- let raycast = null;
17094
- this.heightContact = false;
17095
- this.heightContactNode = null;
17096
- this.heightContactPoint.set(0, 0, 0);
17097
- this.heightContactNormal.set(0, 0, 0);
17098
- this.heightContactAngle = 0;
17099
- this.heightContactDistance = 0;
17100
- const playerTransformHeightDirection = Utilities.TransformDirection(this.transform, this.downDirection);
17101
- if (this.climbContact === true) {
17102
- this.endHeightRaycastPosition.copyFrom(this.climbContactPoint);
17103
- this.startHeightRaycastPosition.copyFrom(this.climbContactPoint);
17104
- this.startHeightRaycastPosition.addInPlace(BABYLON.Vector3.UpReadOnly.scale(this.rayHeightLength));
17105
- }
17106
- else {
17107
- this.offsetHeightRaycastPosition.set(0, this.rayHeightOffset, this.rayClimbLength);
17108
- Utilities.GetAbsolutePositionToRef(this.transform, this.startHeightRaycastPosition, this.offsetHeightRaycastPosition);
17109
- this.endHeightRaycastPosition.copyFrom(this.startHeightRaycastPosition);
17110
- this.endHeightRaycastPosition.addInPlace(this.downDirection.scale(this.rayHeightLength));
17111
- }
17112
- if (raycast != null && raycast.hasHit === true && raycast.collisionObject != null && raycast.collisionObject.entity != null) {
17113
- const checkTag = SceneManager.GetTransformTag(raycast.collisionObject.entity);
17114
- if (checkTag === this.climbVolumeTag) {
17115
- this.heightContact = true;
17116
- this.heightContactNode = raycast.collisionObject.entity;
17117
- if (raycast.hitPoint != null)
17118
- this.heightContactPoint.copyFrom(raycast.hitPoint);
17119
- if (raycast.hitNormal != null)
17120
- this.heightContactNormal.copyFrom(raycast.hitNormal);
17121
- this.heightContactAngle = (this.heightContactNormal != null) ? Math.abs(Utilities.GetAngle(this.heightContactNormal, BABYLON.Vector3.UpReadOnly)) : 0;
17122
- this.heightContactDistance = raycast.hitDistance;
17123
- }
17124
- }
17125
- if (this.showDebugColliders === true) {
17126
- if (this.heightSensorLine == null)
17127
- this.heightSensorLine = new LinesMeshRenderer(this.transform.name + ".HeightCheckSensorLine", this.scene);
17128
- if (raycast != null && this.heightContact === true) {
17129
- this.heightSensorLine.drawLine([this.startHeightRaycastPosition, raycast.hitPoint], BABYLON.Color3.Red());
17130
- }
17131
- else {
17132
- this.heightSensorLine.drawLine([this.startHeightRaycastPosition, this.endHeightRaycastPosition], BABYLON.Color3.Green());
17133
- }
17134
- }
17135
- }
17136
- getCheckedVerticalVelocity() {
17137
- const currentVelocity = (this.characterController != null) ? this.characterController.getVerticalVelocity() : 0;
17138
- return (Math.abs(currentVelocity) >= ThirdPersonPlayerController.MIN_VERTICAL_VELOCITY) ? currentVelocity : 0;
17139
- }
17140
- destroyPlayerController() {
17141
- if (this.animator != null && this.animatorMoveObserver != null)
17142
- this.animator.onAnimatorMoveObservable.remove(this.animatorMoveObserver);
17143
- this.animatorMoveObserver = null;
17144
- this.animator = null;
17145
- this.characterController = null;
17146
- this.onPreUpdateObservable.clear();
17147
- this.onPreUpdateObservable = null;
17148
- this.onBeforeMoveObservable.clear();
17149
- this.onBeforeMoveObservable = null;
17150
- this.onPostUpdateObservable.clear();
17151
- this.onPostUpdateObservable = null;
17152
- }
17153
- validateAnimationStateParams() {
17154
- this.animationStateParams = ThirdPersonPlayerController.ApplyAnimationStateParamDefaults(this.animationStateParams);
17155
- }
17156
- static ApplyAnimationStateParamDefaults(params) {
17157
- if (params == null) {
17158
- return {
17159
- moveDirection: "Direction",
17160
- inputMagnitude: "Magnitude",
17161
- horizontalInput: "Horizontal",
17162
- verticalInput: "Vertical",
17163
- mouseXInput: "MouseX",
17164
- mouseYInput: "MouseY",
17165
- heightInput: "Height",
17166
- speedInput: "Speed",
17167
- motionSpeed: "MotionSpeed",
17168
- jumpFrame: "Jumped",
17169
- jumpState: "Jump",
17170
- actionState: "Action",
17171
- fallingState: "FreeFall",
17172
- slidingState: "Sliding",
17173
- groundedState: "Grounded",
17174
- };
17175
- }
17176
- if (params.motionSpeed == null || params.motionSpeed === "")
17177
- params.motionSpeed = "MotionSpeed";
17178
- return params;
17179
- }
17180
- }
17181
- ThirdPersonPlayerController.MIN_VERTICAL_VELOCITY = 0.01;
17182
- ThirdPersonPlayerController.MIN_GROUND_DISTANCE = 0.15;
17183
- ThirdPersonPlayerController.MIN_MOVE_EPSILON = 0.001;
17184
- ThirdPersonPlayerController.MIN_TIMER_OFFSET = 0;
17185
- ThirdPersonPlayerController.MIN_SLOPE_LIMIT = 0;
17186
- ThirdPersonPlayerController.PLAYER_HEIGHT = "playerHeight";
17187
- export var ThirdPersonControl;
17188
- (function (ThirdPersonControl) {
17189
- ThirdPersonControl[ThirdPersonControl["ThirdPersonTurning"] = 0] = "ThirdPersonTurning";
17190
- ThirdPersonControl[ThirdPersonControl["ThirdPersonForward"] = 1] = "ThirdPersonForward";
17191
- })(ThirdPersonControl || (ThirdPersonControl = {}));
17192
14046
  export class SnapshotManager extends ScriptComponent {
17193
14047
  static IsSnapshotRenderingEnabled() { return SnapshotManager._HelperEnabled; }
17194
14048
  static EnableSnapshotRendering() {
@@ -17665,7 +14519,6 @@ SceneManager.RegisterClass("PROJECT.VehicleInputController", VehicleInputControl
17665
14519
  SceneManager.RegisterClass("PROJECT.DoubleSided", DoubleSided);
17666
14520
  SceneManager.RegisterClass("PROJECT.VertexSplat", VertexSplat);
17667
14521
  SceneManager.RegisterClass("PROJECT.VertexSplatPlugin", VertexSplatPlugin);
17668
- SceneManager.RegisterClass("PROJECT.DefaultCameraSystem", DefaultCameraSystem);
17669
14522
  SceneManager.RegisterClass("PROJECT.DebugInformation", DebugInformation);
17670
14523
  SceneManager.RegisterClass("PROJECT.AssetExporter", AssetExporter);
17671
14524
  SceneManager.RegisterClass("PROJECT.AssetPreloader", AssetPreloader);
@@ -17673,9 +14526,6 @@ BABYLON.CameraInputTypes["FreeCameraTouchJoystickInput"] = FreeCameraTouchJoysti
17673
14526
  SceneManager.RegisterClass("PROJECT.MobileInputController", MobileInputController);
17674
14527
  SceneManager.RegisterClass("PROJECT.MobileOccludeMaterial", MobileOccludeMaterial);
17675
14528
  SceneManager.RegisterClass("PROJECT.MobileShadowMaterial", MobileShadowMaterial);
17676
- SceneManager.RegisterClass("PROJECT.RemotePlayerController", RemotePlayerController);
17677
- SceneManager.RegisterClass("PROJECT.StandardPlayerController", StandardPlayerController);
17678
- SceneManager.RegisterClass("PROJECT.ThirdPersonPlayerController", ThirdPersonPlayerController);
17679
14529
  SceneManager.RegisterClass("PROJECT.SnapshotManager", SnapshotManager);
17680
14530
  SceneManager.RegisterClass("PROJECT.SnapshotRenderer", SnapshotRenderer);
17681
14531
  SceneManager.RegisterClass("PROJECT.DefaultMuteButton", DefaultMuteButton);
@@ -17685,5 +14535,5 @@ if (typeof window !== 'undefined') {
17685
14535
  if (!window.TOOLKIT)
17686
14536
  window.TOOLKIT = Object.assign({}, _ToolkitRef);
17687
14537
  Object.assign(window.TOOLKIT, { KartBumpTarget, KartDriverAnimation, EKartHitKind, KartHitState, EKartContactKind, KartImpacts, KartSurfaceContacts, KartLapCounter, KartOutOfBounds, KartPathSteering, EKartCountdownEvent, KartRaceManager, EKartRescueReason, isKartStalled, shouldFallRescue, isKartFlipped, nearestEquivalentAngle, isAtOrPastLoopIndex, indexBeforeFinishLine, pointBeforeFinishLine, KartCourseMemory, rescueAntiGravityState, isSmoothBankOntoAntiGravityRoad, KartAntiGravityRoadWatch, isTurnedOverOntoWall, KartAntiGravityInvertedWatch, KartRecoveryWatch, KartRescuePlacer, KartRigLookup, isKartGlowMaterial, KartTireGlow, KartTrackInfo, KartAntiGravityVolume, KartAntiGravityExitVolume, KartGliderVolume, KartGliderPanel, KartJumpPanel, KartJumpPanelRotate, KartTrickVolume, KartAirForceVolume, KartBoostPad, KartCancelDownForce, KartDirtSurface, KartWaypointDriver, buildKartVoiceSlots, KartSynthVoice, KartClipVoice, KartClipLoopPoints, KartEnginePlayhead, KartManagedVoice, KartMutedVoice, StandardKartAudio, StandardKartCamera, approachRate, approachPerStep, dampPerStep, driftBrakeSpeed, wrapAngle, approachAngle, sampleTrack, sampleStartTurboPose, rocketStartLaunchSpeed, driftDustWindowSeconds, propellerStepDegrees, selectMaxSpeed, clampAssignedVerticalVelocity, selectSpeedRotateRate, computeYawRate, EKartBoostSource, EKartDriftState, StandardKartController, StandardKartEffects, WindowsPlatform });
17688
- window.PROJECT = Object.assign(window.PROJECT || {}, { CheckpointManager, RoutePoint, PlayerRaceStats, RaceTrackManager, SideCameraController, SkidMarkSection, SkidMarkManager, StandardCarController, VehicleCameraManager, VehicleInputController, DoubleSided, VertexSplat, VertexSplatPlugin, DefaultCameraSystem, DebugInformation, AssetExporter, AssetPreloader, MobileInputController, FreeCameraTouchJoystickInput, MobileOccludeMaterial, MobileShadowMaterial, RemotePlayerController, StandardPlayerController, PlayerInputControl, PlayerMoveDirection, ActionAnimationType, ThirdPersonPlayerController, ThirdPersonControl, SnapshotManager, SnapshotRenderer, DefaultMuteButton, SceneSoundSystem, SoundManager });
14538
+ window.PROJECT = Object.assign(window.PROJECT || {}, { CheckpointManager, RoutePoint, PlayerRaceStats, RaceTrackManager, SideCameraController, SkidMarkSection, SkidMarkManager, StandardCarController, VehicleCameraManager, VehicleInputController, DoubleSided, VertexSplat, VertexSplatPlugin, DebugInformation, AssetExporter, AssetPreloader, MobileInputController, FreeCameraTouchJoystickInput, MobileOccludeMaterial, MobileShadowMaterial, SnapshotManager, SnapshotRenderer, DefaultMuteButton, SceneSoundSystem, SoundManager });
17689
14539
  }