@mml-io/3d-web-client-core 0.20.0 → 0.21.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.
package/build/index.js CHANGED
@@ -487,7 +487,7 @@ var CameraManager = class {
487
487
  };
488
488
 
489
489
  // src/character/Character.ts
490
- import { Color as Color3, Group, Vector3 as Vector34 } from "three";
490
+ import { Color as Color3, Group, Vector3 as Vector35 } from "three";
491
491
 
492
492
  // src/character/CharacterModel.ts
493
493
  import {
@@ -498,7 +498,9 @@ import { ModelLoader } from "@mml-io/model-loader";
498
498
  import {
499
499
  AnimationClip,
500
500
  AnimationMixer,
501
- LoopRepeat
501
+ Box3,
502
+ LoopRepeat,
503
+ Vector3 as Vector33
502
504
  } from "three";
503
505
 
504
506
  // src/character/CharacterMaterial.ts
@@ -786,6 +788,7 @@ var _CharacterModel = class _CharacterModel {
786
788
  this.config = config;
787
789
  this.mesh = null;
788
790
  this.headBone = null;
791
+ this.characterHeight = null;
789
792
  this.materials = /* @__PURE__ */ new Map();
790
793
  this.animations = {};
791
794
  this.animationMixer = null;
@@ -794,41 +797,49 @@ var _CharacterModel = class _CharacterModel {
794
797
  }
795
798
  async init() {
796
799
  await this.loadMainMesh();
797
- await this.setAnimationFromFile(
798
- this.config.animationConfig.idleAnimationFileUrl,
799
- 0 /* idle */,
800
- true
801
- );
802
- await this.setAnimationFromFile(
803
- this.config.animationConfig.jogAnimationFileUrl,
804
- 1 /* walking */,
805
- true
806
- );
807
- await this.setAnimationFromFile(
808
- this.config.animationConfig.sprintAnimationFileUrl,
809
- 2 /* running */,
810
- true
811
- );
812
- await this.setAnimationFromFile(
813
- this.config.animationConfig.airAnimationFileUrl,
814
- 4 /* air */,
815
- true
816
- );
817
- await this.setAnimationFromFile(
818
- this.config.animationConfig.doubleJumpAnimationFileUrl,
819
- 6 /* doubleJump */,
820
- false,
821
- 1.45
822
- );
823
- this.applyCustomMaterials();
800
+ if (this.mesh) {
801
+ await this.setAnimationFromFile(
802
+ this.config.animationConfig.idleAnimationFileUrl,
803
+ 0 /* idle */,
804
+ true
805
+ );
806
+ await this.setAnimationFromFile(
807
+ this.config.animationConfig.jogAnimationFileUrl,
808
+ 1 /* walking */,
809
+ true
810
+ );
811
+ await this.setAnimationFromFile(
812
+ this.config.animationConfig.sprintAnimationFileUrl,
813
+ 2 /* running */,
814
+ true
815
+ );
816
+ await this.setAnimationFromFile(
817
+ this.config.animationConfig.airAnimationFileUrl,
818
+ 4 /* air */,
819
+ true
820
+ );
821
+ await this.setAnimationFromFile(
822
+ this.config.animationConfig.doubleJumpAnimationFileUrl,
823
+ 6 /* doubleJump */,
824
+ false,
825
+ 1.45
826
+ );
827
+ this.applyCustomMaterials();
828
+ }
824
829
  }
825
830
  applyCustomMaterials() {
826
831
  if (!this.mesh)
827
832
  return;
833
+ const boundingBox = new Box3();
834
+ this.mesh.updateWorldMatrix(true, true);
835
+ boundingBox.expandByObject(this.mesh);
836
+ this.characterHeight = boundingBox.max.y - boundingBox.min.y;
828
837
  this.mesh.traverse((child) => {
829
838
  if (child.isBone) {
830
839
  if (child.name === "head") {
840
+ const worldPosition = new Vector33();
831
841
  this.headBone = child;
842
+ this.headBone.getWorldPosition(worldPosition);
832
843
  }
833
844
  }
834
845
  if (child.isMesh || child.isSkinnedMesh) {
@@ -931,23 +942,31 @@ var _CharacterModel = class _CharacterModel {
931
942
  return null;
932
943
  }
933
944
  async loadMainMesh() {
934
- const mainMesh = await this.loadCharacterFromDescription();
935
- if (typeof mainMesh !== "undefined") {
945
+ let mainMesh = null;
946
+ try {
947
+ mainMesh = await this.loadCharacterFromDescription();
948
+ } catch (error) {
949
+ console.error("Failed to load character from description", error);
950
+ }
951
+ if (mainMesh) {
936
952
  this.setMainMesh(mainMesh);
937
- } else {
938
- throw new Error("ERROR: No Character Model was loaded");
939
953
  }
940
954
  }
941
- cleanAnimationClips(skeletalMesh, animationClip) {
955
+ cleanAnimationClips(skeletalMesh, animationClip, keepRootBonePositionAnimation) {
942
956
  const availableBones = /* @__PURE__ */ new Set();
943
- skeletalMesh.traverse((child) => {
944
- const asBone = child;
945
- if (asBone.isBone) {
946
- availableBones.add(child.name);
947
- }
948
- });
957
+ if (skeletalMesh) {
958
+ skeletalMesh.traverse((child) => {
959
+ const asBone = child;
960
+ if (asBone.isBone) {
961
+ availableBones.add(child.name);
962
+ }
963
+ });
964
+ }
949
965
  animationClip.tracks = animationClip.tracks.filter((track) => {
950
966
  const [trackName, trackProperty] = track.name.split(".");
967
+ if (keepRootBonePositionAnimation && trackName === "root" && trackProperty === "position") {
968
+ return true;
969
+ }
951
970
  const shouldAnimate = availableBones.has(trackName) && trackProperty !== "position" && trackProperty !== "scale";
952
971
  return shouldAnimate;
953
972
  });
@@ -956,7 +975,7 @@ var _CharacterModel = class _CharacterModel {
956
975
  async setAnimationFromFile(animationFileUrl, animationType, loop = true, playbackSpeed = 1) {
957
976
  return new Promise(async (resolve, reject) => {
958
977
  const animation = await this.config.characterModelLoader.load(animationFileUrl, "animation");
959
- const cleanAnimation = this.cleanAnimationClips(this.mesh, animation);
978
+ const cleanAnimation = this.cleanAnimationClips(this.mesh, animation, true);
960
979
  if (typeof animation !== "undefined" && cleanAnimation instanceof AnimationClip) {
961
980
  this.animations[animationType] = this.animationMixer.clipAction(cleanAnimation);
962
981
  this.animations[animationType].stop();
@@ -1105,17 +1124,10 @@ var CharacterSpeakingIndicator = class {
1105
1124
  };
1106
1125
 
1107
1126
  // src/character/CharacterTooltip.ts
1108
- import {
1109
- Color as Color2,
1110
- FrontSide,
1111
- LinearFilter as LinearFilter2,
1112
- Mesh as Mesh3,
1113
- MeshBasicMaterial as MeshBasicMaterial2,
1114
- PlaneGeometry
1115
- } from "three";
1127
+ import { Color as Color2, FrontSide, LinearFilter as LinearFilter2, Sprite, SpriteMaterial } from "three";
1116
1128
 
1117
1129
  // src/character/CanvasText.ts
1118
- import { Texture, LinearFilter, RGBAFormat, MeshBasicMaterial } from "three";
1130
+ import { Texture, LinearFilter, RGBAFormat } from "three";
1119
1131
  function getTextAlignOffset(textAlign, width) {
1120
1132
  switch (textAlign) {
1121
1133
  case "center":
@@ -1126,7 +1138,8 @@ function getTextAlignOffset(textAlign, width) {
1126
1138
  return 0;
1127
1139
  }
1128
1140
  }
1129
- function printAtWordWrap(context, fullText, x, y, lineHeight, fitWidth, padding, alignment) {
1141
+ function printAtWordWrap(context, fullText, textAlign, y, lineHeight, fitWidth, padding) {
1142
+ const x = getTextAlignOffset(textAlign, fitWidth - padding * 2);
1130
1143
  const lines = fullText.split("\n");
1131
1144
  let currentLine = 0;
1132
1145
  for (const text of lines) {
@@ -1143,7 +1156,30 @@ function printAtWordWrap(context, fullText, x, y, lineHeight, fitWidth, padding,
1143
1156
  const textWidth = context.measureText(str).width;
1144
1157
  if (textWidth + padding * 2 > fitWidth) {
1145
1158
  if (lastWordIndex === 1) {
1146
- lastWordIndex = 2;
1159
+ const word = words[0];
1160
+ let charIndex = 1;
1161
+ while (charIndex < word.length) {
1162
+ const substring = word.substring(0, charIndex);
1163
+ const subWidth = context.measureText(substring).width;
1164
+ if (subWidth + padding * 2 > fitWidth) {
1165
+ if (charIndex === 1)
1166
+ charIndex = 2;
1167
+ context.fillText(
1168
+ word.substring(0, charIndex - 1),
1169
+ x + padding,
1170
+ y + lineHeight * currentLine + padding
1171
+ );
1172
+ currentLine++;
1173
+ words[0] = word.substring(charIndex - 1);
1174
+ break;
1175
+ }
1176
+ charIndex++;
1177
+ }
1178
+ if (charIndex >= word.length) {
1179
+ lastWordIndex = 2;
1180
+ } else {
1181
+ continue;
1182
+ }
1147
1183
  }
1148
1184
  context.fillText(
1149
1185
  words.slice(0, lastWordIndex - 1).join(" "),
@@ -1158,64 +1194,96 @@ function printAtWordWrap(context, fullText, x, y, lineHeight, fitWidth, padding,
1158
1194
  }
1159
1195
  }
1160
1196
  if (lastWordIndex > 0 && words.length > 0) {
1161
- const xOffset = alignment === "center" ? 0 : padding;
1162
- context.fillText(words.join(" "), x + xOffset, y + lineHeight * currentLine + padding);
1197
+ context.fillText(words.join(" "), x + padding, y + lineHeight * currentLine + padding);
1163
1198
  currentLine++;
1164
1199
  }
1165
1200
  }
1166
1201
  }
1167
- function CanvasText(message, options) {
1168
- const fontsize = options.fontSize;
1169
- const textColor = options.textColorRGB255A1;
1170
- const backgroundColor = options.backgroundColorRGB255A1 || { r: 255, g: 255, b: 255, a: 1 };
1171
- const padding = options.paddingPx || 0;
1172
- const font = options.font || "Arial";
1173
- const fontString = (options.bold ? "bold " : "") + fontsize + "px " + font;
1174
- const canvas2 = document.createElement("canvas");
1175
- const ct = canvas2.getContext("2d");
1176
- const textAlign = options.alignment ?? "left";
1177
- if (options.dimensions) {
1178
- canvas2.width = options.dimensions.width;
1179
- canvas2.height = options.dimensions.height;
1180
- ct.clearRect(0, 0, canvas2.width, canvas2.height);
1181
- ct.font = fontString;
1182
- ct.textAlign = textAlign;
1183
- ct.fillStyle = `rgba(${backgroundColor.r}, ${backgroundColor.g}, ${backgroundColor.b}, ${backgroundColor.a})`;
1184
- ct.lineWidth = 0;
1185
- ct.fillRect(0, 0, canvas2.width, canvas2.height);
1186
- ct.fillStyle = `rgba(${textColor.r}, ${textColor.g}, ${textColor.b}, ${textColor.a})`;
1187
- ct.font = fontString;
1188
- printAtWordWrap(
1189
- ct,
1190
- message,
1191
- getTextAlignOffset(textAlign, canvas2.width),
1192
- fontsize,
1193
- fontsize,
1194
- canvas2.width,
1195
- padding,
1196
- textAlign
1197
- );
1198
- } else {
1199
- ct.font = fontString;
1200
- const metrics = ct.measureText(message);
1201
- const textWidth = metrics.width;
1202
- const textHeight = metrics.fontBoundingBoxAscent + metrics.fontBoundingBoxDescent;
1203
- canvas2.width = textWidth + padding * 2;
1204
- canvas2.height = textHeight + padding;
1205
- ct.clearRect(0, 0, canvas2.width, canvas2.height);
1206
- ct.font = fontString;
1207
- ct.textAlign = textAlign;
1208
- ct.fillStyle = `rgba(${backgroundColor.r}, ${backgroundColor.g}, ${backgroundColor.b}, ${backgroundColor.a})`;
1209
- ct.lineWidth = 0;
1210
- ct.fillRect(0, 0, canvas2.width, canvas2.height);
1211
- ct.fillStyle = `rgba(${textColor.r}, ${textColor.g}, ${textColor.b}, ${textColor.a})`;
1212
- ct.font = fontString;
1213
- ct.fillText(message, padding + getTextAlignOffset(textAlign, textWidth), textHeight);
1214
- }
1215
- return canvas2;
1216
- }
1202
+ var CanvasText = class {
1203
+ constructor() {
1204
+ this.canvas = document.createElement("canvas");
1205
+ this.context = this.canvas.getContext("2d");
1206
+ }
1207
+ renderText(message, options) {
1208
+ const fontsize = options.fontSize;
1209
+ const textColor = options.textColorRGB255A1;
1210
+ const backgroundColor = options.backgroundColorRGB255A1 || { r: 255, g: 255, b: 255, a: 1 };
1211
+ const padding = options.paddingPx || 0;
1212
+ const font = options.font || "Arial";
1213
+ const fontString = (options.bold ? "bold " : "") + fontsize + "px " + font;
1214
+ const textAlign = options.alignment ?? "left";
1215
+ if (options.dimensions && options.dimensions.maxWidth === void 0) {
1216
+ this.canvas.width = options.dimensions.width;
1217
+ this.canvas.height = options.dimensions.height;
1218
+ this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
1219
+ this.context.font = fontString;
1220
+ this.context.textAlign = textAlign;
1221
+ this.context.fillStyle = `rgba(${backgroundColor.r}, ${backgroundColor.g}, ${backgroundColor.b}, ${backgroundColor.a})`;
1222
+ this.context.lineWidth = 0;
1223
+ this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
1224
+ this.context.fillStyle = `rgba(${textColor.r}, ${textColor.g}, ${textColor.b}, ${textColor.a})`;
1225
+ printAtWordWrap(
1226
+ this.context,
1227
+ message,
1228
+ textAlign,
1229
+ fontsize,
1230
+ fontsize,
1231
+ this.canvas.width,
1232
+ padding
1233
+ );
1234
+ return this.canvas;
1235
+ } else {
1236
+ this.context.font = fontString;
1237
+ this.context.textAlign = textAlign;
1238
+ const metrics = this.context.measureText(message);
1239
+ const textWidth = metrics.width;
1240
+ const textHeight = metrics.fontBoundingBoxAscent + metrics.fontBoundingBoxDescent;
1241
+ if (options.dimensions && options.dimensions.maxWidth !== void 0) {
1242
+ const maxWidthWithoutPadding = options.dimensions.maxWidth - padding * 2;
1243
+ if (textWidth > maxWidthWithoutPadding) {
1244
+ const lineCount = Math.ceil(textWidth / maxWidthWithoutPadding);
1245
+ this.canvas.width = options.dimensions.maxWidth;
1246
+ this.canvas.height = textHeight * lineCount + padding * 2;
1247
+ this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
1248
+ this.context.font = fontString;
1249
+ this.context.textAlign = textAlign;
1250
+ this.context.fillStyle = `rgba(${backgroundColor.r}, ${backgroundColor.g}, ${backgroundColor.b}, ${backgroundColor.a})`;
1251
+ this.context.lineWidth = 0;
1252
+ this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
1253
+ this.context.fillStyle = `rgba(${textColor.r}, ${textColor.g}, ${textColor.b}, ${textColor.a})`;
1254
+ printAtWordWrap(
1255
+ this.context,
1256
+ message,
1257
+ textAlign,
1258
+ fontsize,
1259
+ fontsize,
1260
+ this.canvas.width,
1261
+ padding
1262
+ );
1263
+ return this.canvas;
1264
+ } else {
1265
+ }
1266
+ }
1267
+ this.canvas.width = textWidth + padding * 2;
1268
+ this.canvas.height = textHeight + padding * 2;
1269
+ this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
1270
+ this.context.font = fontString;
1271
+ this.context.textAlign = textAlign;
1272
+ this.context.fillStyle = `rgba(${backgroundColor.r}, ${backgroundColor.g}, ${backgroundColor.b}, ${backgroundColor.a})`;
1273
+ this.context.lineWidth = 0;
1274
+ this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
1275
+ this.context.fillStyle = `rgba(${textColor.r}, ${textColor.g}, ${textColor.b}, ${textColor.a})`;
1276
+ this.context.fillText(
1277
+ message,
1278
+ padding + getTextAlignOffset(textAlign, textWidth),
1279
+ textHeight
1280
+ );
1281
+ }
1282
+ return this.canvas;
1283
+ }
1284
+ };
1217
1285
  function THREECanvasTextTexture(text, options) {
1218
- const canvas2 = CanvasText(text, options);
1286
+ const canvas2 = new CanvasText().renderText(text, options);
1219
1287
  const texture = new Texture(canvas2);
1220
1288
  texture.minFilter = LinearFilter;
1221
1289
  texture.magFilter = LinearFilter;
@@ -1229,46 +1297,46 @@ var fontScale = 5;
1229
1297
  var defaultLabelColor = new Color2(0);
1230
1298
  var defaultFontColor = new Color2(16777215);
1231
1299
  var defaultLabelAlignment = "center" /* center */;
1232
- var defaultLabelFontSize = 8;
1233
- var defaultLabelPadding = 8;
1234
- var defaultLabelWidth = 0.25;
1235
- var defaultLabelHeight = 0.1;
1236
- var defaultLabelCastShadows = true;
1237
- var tooltipGeometry = new PlaneGeometry(1, 1, 1, 1);
1238
- var CharacterTooltip = class extends Mesh3 {
1300
+ var defaultLabelFontSize = 10;
1301
+ var defaultLabelPadding = 10;
1302
+ var defaultVisibleOpacity = 0.85;
1303
+ var defaultSecondsToFadeOut = null;
1304
+ var CharacterTooltip = class extends Sprite {
1239
1305
  constructor(configArg) {
1240
- super(tooltipGeometry);
1241
- this.visibleOpacity = 0.85;
1306
+ super();
1242
1307
  this.targetOpacity = 0;
1243
1308
  this.fadingSpeed = 0.02;
1244
- this.secondsToFadeOut = 10;
1309
+ this.content = null;
1310
+ this.hideTimeout = null;
1245
1311
  this.config = {
1246
1312
  alignment: defaultLabelAlignment,
1247
- width: defaultLabelWidth,
1248
- height: defaultLabelHeight,
1249
1313
  fontSize: defaultLabelFontSize,
1250
1314
  padding: defaultLabelPadding,
1251
1315
  color: defaultLabelColor,
1252
1316
  fontColor: defaultFontColor,
1253
- castShadows: defaultLabelCastShadows,
1317
+ visibleOpacity: defaultVisibleOpacity,
1318
+ secondsToFadeOut: defaultSecondsToFadeOut,
1254
1319
  ...configArg
1255
1320
  };
1256
- this.tooltipMaterial = new MeshBasicMaterial2({
1321
+ this.material = new SpriteMaterial({
1257
1322
  map: null,
1258
1323
  transparent: true,
1259
- opacity: 0,
1324
+ opacity: this.config.visibleOpacity,
1260
1325
  side: FrontSide
1261
1326
  });
1262
- this.material = this.tooltipMaterial;
1263
1327
  this.position.set(0, 1.6, 0);
1264
1328
  this.visible = false;
1265
1329
  }
1330
+ setHeightOffset(height) {
1331
+ this.position.y = height + this.scale.y / 2;
1332
+ }
1266
1333
  redrawText(content) {
1267
- if (!this.tooltipMaterial) {
1334
+ if (content === this.content) {
1268
1335
  return;
1269
1336
  }
1270
- if (this.tooltipMaterial.map) {
1271
- this.tooltipMaterial.map.dispose();
1337
+ this.content = content;
1338
+ if (this.material.map) {
1339
+ this.material.map.dispose();
1272
1340
  }
1273
1341
  const { texture, width, height } = THREECanvasTextTexture(content, {
1274
1342
  bold: true,
@@ -1286,51 +1354,63 @@ var CharacterTooltip = class extends Mesh3 {
1286
1354
  b: this.config.color.b * 255,
1287
1355
  a: 1
1288
1356
  },
1289
- alignment: this.config.alignment
1357
+ alignment: this.config.alignment,
1358
+ dimensions: this.config.maxWidth !== void 0 ? {
1359
+ maxWidth: this.config.maxWidth
1360
+ } : void 0
1290
1361
  });
1291
- this.tooltipMaterial.map = texture;
1292
- this.tooltipMaterial.map.magFilter = LinearFilter2;
1293
- this.tooltipMaterial.map.minFilter = LinearFilter2;
1294
- this.tooltipMaterial.needsUpdate = true;
1362
+ this.material.map = texture;
1363
+ this.material.map.magFilter = LinearFilter2;
1364
+ this.material.map.minFilter = LinearFilter2;
1365
+ this.material.needsUpdate = true;
1295
1366
  this.scale.x = width / (100 * fontScale);
1296
1367
  this.scale.y = height / (100 * fontScale);
1297
- this.position.y = 1.4;
1298
1368
  }
1299
- setText(text, temporary = false) {
1369
+ setText(text, onRemove) {
1300
1370
  const sanitizedText = text.replace(/(\r\n|\n|\r)/gm, "");
1301
- this.redrawText(sanitizedText);
1302
1371
  this.visible = true;
1303
- this.targetOpacity = this.visibleOpacity;
1304
- if (temporary) {
1305
- setTimeout(() => {
1372
+ this.targetOpacity = this.config.visibleOpacity;
1373
+ if (this.hideTimeout) {
1374
+ clearTimeout(this.hideTimeout);
1375
+ this.hideTimeout = null;
1376
+ }
1377
+ if (this.config.secondsToFadeOut !== null) {
1378
+ this.hideTimeout = setTimeout(() => {
1379
+ this.hideTimeout = null;
1306
1380
  this.hide();
1307
- }, this.secondsToFadeOut * 1e3);
1381
+ if (onRemove) {
1382
+ onRemove();
1383
+ }
1384
+ }, this.config.secondsToFadeOut * 1e3);
1308
1385
  }
1386
+ this.redrawText(sanitizedText);
1309
1387
  }
1310
1388
  hide() {
1311
1389
  this.targetOpacity = 0;
1312
1390
  }
1313
- update(camera) {
1314
- this.lookAt(camera.position);
1315
- const opacity = this.tooltipMaterial.opacity;
1391
+ show() {
1392
+ this.setText(this.content || "");
1393
+ }
1394
+ update() {
1395
+ const opacity = this.material.opacity;
1316
1396
  if (opacity < this.targetOpacity) {
1317
- this.tooltipMaterial.opacity = Math.min(
1318
- this.tooltipMaterial.opacity + this.fadingSpeed,
1397
+ this.material.opacity = Math.min(
1398
+ this.material.opacity + this.fadingSpeed,
1319
1399
  this.targetOpacity
1320
1400
  );
1321
1401
  } else if (opacity > this.targetOpacity) {
1322
- this.tooltipMaterial.opacity = Math.max(
1323
- this.tooltipMaterial.opacity - this.fadingSpeed,
1402
+ this.material.opacity = Math.max(
1403
+ this.material.opacity - this.fadingSpeed,
1324
1404
  this.targetOpacity
1325
1405
  );
1326
- if (opacity >= 1 && this.tooltipMaterial.transparent) {
1327
- this.tooltipMaterial.transparent = false;
1328
- this.tooltipMaterial.needsUpdate = true;
1329
- } else if (opacity > 0 && opacity < 1 && !this.tooltipMaterial.transparent) {
1330
- this.tooltipMaterial.transparent = true;
1331
- this.tooltipMaterial.needsUpdate = true;
1406
+ if (opacity >= 1 && this.material.transparent) {
1407
+ this.material.transparent = false;
1408
+ this.material.needsUpdate = true;
1409
+ } else if (opacity > 0 && opacity < 1 && !this.material.transparent) {
1410
+ this.material.transparent = true;
1411
+ this.material.needsUpdate = true;
1332
1412
  }
1333
- if (this.tooltipMaterial.opacity <= 0) {
1413
+ if (this.material.opacity <= 0) {
1334
1414
  this.visible = false;
1335
1415
  }
1336
1416
  }
@@ -1338,6 +1418,12 @@ var CharacterTooltip = class extends Mesh3 {
1338
1418
  };
1339
1419
 
1340
1420
  // src/character/Character.ts
1421
+ function characterHeightToTooltipHeightOffset(characterHeight) {
1422
+ return characterHeight - 0.4 + 0.1;
1423
+ }
1424
+ function characterDescriptionMatches(a, b) {
1425
+ return a.meshFileUrl === b.meshFileUrl && a.mmlCharacterString === b.mmlCharacterString && a.mmlCharacterUrl === b.mmlCharacterUrl;
1426
+ }
1341
1427
  var Character = class extends Group {
1342
1428
  constructor(config) {
1343
1429
  super();
@@ -1345,18 +1431,42 @@ var Character = class extends Group {
1345
1431
  this.model = null;
1346
1432
  this.color = new Color3();
1347
1433
  this.speakingIndicator = null;
1348
- this.tooltip = new CharacterTooltip();
1349
- this.tooltip.setText(this.config.username, this.config.isLocal);
1434
+ this.chatTooltips = [];
1435
+ this.tooltip = new CharacterTooltip(
1436
+ this.config.isLocal ? {
1437
+ secondsToFadeOut: 10
1438
+ } : {}
1439
+ );
1440
+ this.tooltip.setText(this.config.username);
1350
1441
  this.add(this.tooltip);
1351
1442
  this.load().then(() => {
1352
1443
  this.config.modelLoadedCallback();
1444
+ this.setTooltipHeights();
1353
1445
  });
1354
1446
  }
1355
1447
  updateCharacter(username, characterDescription) {
1356
- this.config.username = username;
1357
- this.config.characterDescription = characterDescription;
1358
- this.load();
1359
- this.tooltip.setText(username, this.config.isLocal);
1448
+ if (!characterDescriptionMatches(this.config.characterDescription, characterDescription)) {
1449
+ this.config.characterDescription = characterDescription;
1450
+ this.load().then(() => {
1451
+ this.setTooltipHeights();
1452
+ });
1453
+ }
1454
+ if (this.config.username !== username) {
1455
+ this.config.username = username;
1456
+ this.tooltip.setText(username);
1457
+ this.tooltip.show();
1458
+ }
1459
+ }
1460
+ setTooltipHeights() {
1461
+ if (this.model && this.model.characterHeight) {
1462
+ let height = characterHeightToTooltipHeightOffset(this.model.characterHeight);
1463
+ this.tooltip.setHeightOffset(height);
1464
+ height += this.tooltip.scale.y;
1465
+ for (const chatTooltip of this.chatTooltips) {
1466
+ chatTooltip.setHeightOffset(height);
1467
+ height += chatTooltip.scale.y;
1468
+ }
1469
+ }
1360
1470
  }
1361
1471
  async load() {
1362
1472
  const previousModel = this.model;
@@ -1372,7 +1482,9 @@ var Character = class extends Group {
1372
1482
  isLocal: this.config.isLocal
1373
1483
  });
1374
1484
  await this.model.init();
1375
- this.add(this.model.mesh);
1485
+ if (this.model.mesh) {
1486
+ this.add(this.model.mesh);
1487
+ }
1376
1488
  if (this.speakingIndicator === null) {
1377
1489
  this.speakingIndicator = new CharacterSpeakingIndicator(this.config.composer.postPostScene);
1378
1490
  }
@@ -1386,13 +1498,13 @@ var Character = class extends Group {
1386
1498
  if (!this.model)
1387
1499
  return;
1388
1500
  if (this.tooltip) {
1389
- this.tooltip.update(this.config.cameraManager.camera);
1501
+ this.tooltip.update();
1390
1502
  }
1391
1503
  if (this.speakingIndicator) {
1392
1504
  this.speakingIndicator.setTime(time);
1393
1505
  if (this.model.mesh && this.model.headBone) {
1394
1506
  this.speakingIndicator.setBillboarding(
1395
- (_a = this.model.headBone) == null ? void 0 : _a.getWorldPosition(new Vector34()),
1507
+ (_a = this.model.headBone) == null ? void 0 : _a.getWorldPosition(new Vector35()),
1396
1508
  this.config.cameraManager.camera
1397
1509
  );
1398
1510
  }
@@ -1403,13 +1515,31 @@ var Character = class extends Group {
1403
1515
  var _a;
1404
1516
  return ((_a = this.model) == null ? void 0 : _a.currentAnimation) || 0 /* idle */;
1405
1517
  }
1518
+ addChatBubble(message) {
1519
+ const tooltip = new CharacterTooltip({
1520
+ maxWidth: 1e3,
1521
+ secondsToFadeOut: 10,
1522
+ color: new Color3(0.125, 0.125, 0.125)
1523
+ });
1524
+ this.add(tooltip);
1525
+ this.chatTooltips.push(tooltip);
1526
+ tooltip.setText(message, () => {
1527
+ this.chatTooltips = this.chatTooltips.filter((t) => t !== tooltip);
1528
+ this.remove(tooltip);
1529
+ this.setTooltipHeights();
1530
+ });
1531
+ if (this.config.isLocal) {
1532
+ this.tooltip.show();
1533
+ }
1534
+ this.setTooltipHeights();
1535
+ }
1406
1536
  };
1407
1537
 
1408
1538
  // src/character/CharacterManager.ts
1409
- import { Euler as Euler2, Group as Group2, Quaternion as Quaternion5, Vector3 as Vector38 } from "three";
1539
+ import { Euler as Euler2, Group as Group2, Quaternion as Quaternion5, Vector3 as Vector39 } from "three";
1410
1540
 
1411
1541
  // src/character/LocalController.ts
1412
- import { Euler, Line3, Matrix4, Quaternion as Quaternion2, Ray, Raycaster as Raycaster2, Vector3 as Vector35 } from "three";
1542
+ import { Euler, Line3, Matrix4, Quaternion as Quaternion2, Ray, Raycaster as Raycaster2, Vector3 as Vector36 } from "three";
1413
1543
 
1414
1544
  // src/tweakpane/blades/characterControlsFolder.ts
1415
1545
  var characterControllerValues = {
@@ -1592,13 +1722,13 @@ var CharacterControlsFolder = class {
1592
1722
  };
1593
1723
 
1594
1724
  // src/character/LocalController.ts
1595
- var downVector = new Vector35(0, -1, 0);
1725
+ var downVector = new Vector36(0, -1, 0);
1596
1726
  var LocalController = class {
1597
1727
  constructor(config) {
1598
1728
  this.config = config;
1599
1729
  this.capsuleInfo = {
1600
1730
  radius: 0.4,
1601
- segment: new Line3(new Vector35(), new Vector35(0, 1.05, 0))
1731
+ segment: new Line3(new Vector36(), new Vector36(0, 1.05, 0))
1602
1732
  };
1603
1733
  this.gravity = -characterControllerValues.gravity;
1604
1734
  this.jumpForce = characterControllerValues.jumpForce;
@@ -1616,34 +1746,34 @@ var LocalController = class {
1616
1746
  this.groundRunControl = characterControllerValues.groundRunControl;
1617
1747
  this.baseControl = characterControllerValues.baseControlMultiplier;
1618
1748
  this.minimumSurfaceAngle = characterControllerValues.minimumSurfaceAngle;
1619
- this.latestPosition = new Vector35();
1749
+ this.latestPosition = new Vector36();
1620
1750
  this.characterOnGround = false;
1621
1751
  this.coyoteTime = false;
1622
1752
  this.collisionDetectionSteps = 15;
1623
1753
  this.characterWasOnGround = false;
1624
1754
  this.characterAirborneSince = 0;
1625
1755
  this.currentHeight = 0;
1626
- this.currentSurfaceAngle = new Vector35();
1627
- this.characterVelocity = new Vector35();
1628
- this.vectorUp = new Vector35(0, 1, 0);
1629
- this.vectorDown = new Vector35(0, -1, 0);
1756
+ this.currentSurfaceAngle = new Vector36();
1757
+ this.characterVelocity = new Vector36();
1758
+ this.vectorUp = new Vector36(0, 1, 0);
1759
+ this.vectorDown = new Vector36(0, -1, 0);
1630
1760
  this.rotationOffset = 0;
1631
1761
  this.azimuthalAngle = 0;
1632
1762
  this.tempMatrix = new Matrix4();
1633
1763
  this.tempSegment = new Line3();
1634
1764
  this.tempQuaternion = new Quaternion2();
1635
1765
  this.tempEuler = new Euler();
1636
- this.tempVector = new Vector35();
1637
- this.tempVector2 = new Vector35();
1638
- this.tempVector3 = new Vector35();
1766
+ this.tempVector = new Vector36();
1767
+ this.tempVector2 = new Vector36();
1768
+ this.tempVector3 = new Vector36();
1639
1769
  this.rayCaster = new Raycaster2();
1640
1770
  this.surfaceTempQuaternion = new Quaternion2();
1641
1771
  this.surfaceTempQuaternion2 = new Quaternion2();
1642
- this.surfaceTempVector1 = new Vector35();
1643
- this.surfaceTempVector2 = new Vector35();
1644
- this.surfaceTempVector3 = new Vector35();
1645
- this.surfaceTempVector4 = new Vector35();
1646
- this.surfaceTempVector5 = new Vector35();
1772
+ this.surfaceTempVector1 = new Vector36();
1773
+ this.surfaceTempVector2 = new Vector36();
1774
+ this.surfaceTempVector3 = new Vector36();
1775
+ this.surfaceTempVector4 = new Vector36();
1776
+ this.surfaceTempVector5 = new Vector36();
1647
1777
  this.surfaceTempRay = new Ray();
1648
1778
  this.lastFrameSurfaceState = null;
1649
1779
  this.jumpPressed = false;
@@ -1940,7 +2070,7 @@ var LocalController = class {
1940
2070
  };
1941
2071
 
1942
2072
  // src/character/RemoteController.ts
1943
- import { Quaternion as Quaternion3, Vector3 as Vector36 } from "three";
2073
+ import { Quaternion as Quaternion3, Vector3 as Vector37 } from "three";
1944
2074
  var tempQuaternion = new Quaternion3();
1945
2075
  var RemoteController = class {
1946
2076
  constructor(config) {
@@ -1969,7 +2099,7 @@ var RemoteController = class {
1969
2099
  }
1970
2100
  updateFromNetwork(clientUpdate) {
1971
2101
  const { position, rotation, state } = clientUpdate;
1972
- this.config.character.position.lerp(new Vector36(position.x, position.y, position.z), 0.15);
2102
+ this.config.character.position.lerp(new Vector37(position.x, position.y, position.z), 0.15);
1973
2103
  const rotationQuaternion = new Quaternion3(0, rotation.quaternionY, 0, rotation.quaternionW);
1974
2104
  this.config.character.quaternion.slerp(rotationQuaternion, 0.6);
1975
2105
  if (state !== this.currentAnimation) {
@@ -1980,7 +2110,7 @@ var RemoteController = class {
1980
2110
  };
1981
2111
 
1982
2112
  // src/character/url-position.ts
1983
- import { Quaternion as Quaternion4, Vector3 as Vector37 } from "three";
2113
+ import { Quaternion as Quaternion4, Vector3 as Vector38 } from "three";
1984
2114
  function encodeCharacterAndCamera(character, camera) {
1985
2115
  return [
1986
2116
  ...toArray(character.position),
@@ -1993,11 +2123,11 @@ function decodeCharacterAndCamera(hash) {
1993
2123
  const values = hash.split(",").map(Number);
1994
2124
  return {
1995
2125
  character: {
1996
- position: new Vector37(values[0], values[1], values[2]),
2126
+ position: new Vector38(values[0], values[1], values[2]),
1997
2127
  quaternion: new Quaternion4(values[3], values[4], values[5], values[6])
1998
2128
  },
1999
2129
  camera: {
2000
- position: new Vector37(values[7], values[8], values[9]),
2130
+ position: new Vector38(values[7], values[8], values[9]),
2001
2131
  quaternion: new Quaternion4(values[10], values[11], values[12], values[13])
2002
2132
  }
2003
2133
  };
@@ -2007,16 +2137,17 @@ function decodeCharacterAndCamera(hash) {
2007
2137
  var CharacterManager = class {
2008
2138
  constructor(config) {
2009
2139
  this.config = config;
2010
- this.headTargetOffset = new Vector38(0, 1.3, 0);
2140
+ this.headTargetOffset = new Vector39(0, 1.3, 0);
2011
2141
  this.localClientId = 0;
2012
2142
  this.remoteCharacters = /* @__PURE__ */ new Map();
2013
2143
  this.remoteCharacterControllers = /* @__PURE__ */ new Map();
2014
2144
  this.localCharacterSpawned = false;
2015
2145
  this.localCharacter = null;
2016
2146
  this.speakingCharacters = /* @__PURE__ */ new Map();
2147
+ this.lastUpdateSentTime = 0;
2017
2148
  this.group = new Group2();
2018
2149
  }
2019
- spawnLocalCharacter(id, username, characterDescription, spawnPosition = new Vector38(), spawnRotation = new Euler2()) {
2150
+ spawnLocalCharacter(id, username, characterDescription, spawnPosition = new Vector39(), spawnRotation = new Euler2()) {
2020
2151
  const character = new Character({
2021
2152
  username,
2022
2153
  characterDescription,
@@ -2059,7 +2190,7 @@ var CharacterManager = class {
2059
2190
  setupTweakPane(tweakPane) {
2060
2191
  tweakPane.setupCharacterController(this.localController);
2061
2192
  }
2062
- spawnRemoteCharacter(id, username, characterDescription, spawnPosition = new Vector38(), spawnRotation = new Euler2()) {
2193
+ spawnRemoteCharacter(id, username, characterDescription, spawnPosition = new Vector39(), spawnRotation = new Euler2()) {
2063
2194
  const character = new Character({
2064
2195
  username,
2065
2196
  characterDescription,
@@ -2105,6 +2236,15 @@ var CharacterManager = class {
2105
2236
  setSpeakingCharacter(id, value) {
2106
2237
  this.speakingCharacters.set(id, value);
2107
2238
  }
2239
+ addSelfChatBubble(message) {
2240
+ if (this.localCharacter) {
2241
+ this.localCharacter.addChatBubble(message);
2242
+ }
2243
+ }
2244
+ addChatBubble(id, message) {
2245
+ var _a;
2246
+ (_a = this.remoteCharacters.get(id)) == null ? void 0 : _a.addChatBubble(message);
2247
+ }
2108
2248
  respawnIfPresent(id) {
2109
2249
  const characterInfo = this.config.characterResolve(id);
2110
2250
  if (this.localCharacter && this.localClientId == id) {
@@ -2128,10 +2268,13 @@ var CharacterManager = class {
2128
2268
  );
2129
2269
  }
2130
2270
  this.localController.update();
2131
- if (this.config.timeManager.frame % 2 === 0) {
2271
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
2272
+ const timeSinceLastUpdate = currentTime - this.lastUpdateSentTime;
2273
+ if (timeSinceLastUpdate > 30) {
2274
+ this.lastUpdateSentTime = currentTime;
2132
2275
  this.config.sendUpdate(this.localController.networkState);
2133
2276
  }
2134
- const targetOffset = new Vector38();
2277
+ const targetOffset = new Vector39();
2135
2278
  targetOffset.add(this.headTargetOffset).applyQuaternion(this.localCharacter.quaternion).add(this.localCharacter.position);
2136
2279
  this.config.cameraManager.setTarget(targetOffset);
2137
2280
  for (const [id, update] of this.config.remoteUserStates) {
@@ -2146,7 +2289,7 @@ var CharacterManager = class {
2146
2289
  id,
2147
2290
  characterInfo.username,
2148
2291
  characterInfo.characterDescription,
2149
- new Vector38(position.x, position.y, position.z)
2292
+ new Vector39(position.x, position.y, position.z)
2150
2293
  );
2151
2294
  }
2152
2295
  const characterController = this.remoteCharacterControllers.get(id);
@@ -2242,26 +2385,22 @@ var CharacterModelLoader = class {
2242
2385
  }
2243
2386
  }
2244
2387
  async loadFromUrl(url, fileType, extension) {
2245
- if (["gltf", "glb"].includes(extension)) {
2246
- return new Promise(async (resolve, reject) => {
2247
- const modelLoadResult = await this.modelLoader.load(
2248
- url,
2249
- (loaded, total) => {
2250
- }
2251
- );
2252
- if (fileType === "model") {
2253
- resolve(modelLoadResult.group);
2254
- } else if (fileType === "animation") {
2255
- resolve(modelLoadResult.animations[0]);
2256
- } else {
2257
- const error = `Trying to load unknown ${fileType} type of element from file ${url}`;
2258
- console.error(error);
2259
- reject(error);
2388
+ return new Promise(async (resolve, reject) => {
2389
+ const modelLoadResult = await this.modelLoader.load(
2390
+ url,
2391
+ (loaded, total) => {
2260
2392
  }
2261
- });
2262
- } else {
2263
- console.error(`Error: can't recognize ${url} extension: ${extension}`);
2264
- }
2393
+ );
2394
+ if (fileType === "model") {
2395
+ resolve(modelLoadResult.group);
2396
+ } else if (fileType === "animation") {
2397
+ resolve(modelLoadResult.animations[0]);
2398
+ } else {
2399
+ const error = `Trying to load unknown ${fileType} type of element from file ${url}`;
2400
+ console.error(error);
2401
+ reject(error);
2402
+ }
2403
+ });
2265
2404
  }
2266
2405
  };
2267
2406
 
@@ -2614,7 +2753,6 @@ var MMLCompositionScene = class {
2614
2753
  hasGraphicsAdapter() {
2615
2754
  return true;
2616
2755
  },
2617
- getRootContainer: () => this.group,
2618
2756
  addCollider: (object, mElement) => {
2619
2757
  this.config.collisionsManager.addMeshesGroup(object, mElement);
2620
2758
  },
@@ -3717,12 +3855,12 @@ import {
3717
3855
  import { RGBELoader } from "three/examples/jsm/loaders/RGBELoader.js";
3718
3856
 
3719
3857
  // src/sun/Sun.ts
3720
- import { CameraHelper, Color as Color5, DirectionalLight, Group as Group4, OrthographicCamera, Vector3 as Vector39 } from "three";
3858
+ import { CameraHelper, Color as Color5, DirectionalLight, Group as Group4, OrthographicCamera, Vector3 as Vector310 } from "three";
3721
3859
  var Sun = class extends Group4 {
3722
3860
  constructor() {
3723
3861
  super();
3724
3862
  this.debug = false;
3725
- this.sunOffset = new Vector39(
3863
+ this.sunOffset = new Vector310(
3726
3864
  sunValues.sunPosition.sunAzimuthalAngle * (Math.PI / 180),
3727
3865
  sunValues.sunPosition.sunPolarAngle * (Math.PI / 180),
3728
3866
  100
@@ -3750,7 +3888,7 @@ var Sun = class extends Group4 {
3750
3888
  this.directionalLight.shadow.mapSize.set(this.shadowResolution, this.shadowResolution);
3751
3889
  this.directionalLight.castShadow = true;
3752
3890
  this.setColor();
3753
- this.updateCharacterPosition(new Vector39(0, 0, 0));
3891
+ this.updateCharacterPosition(new Vector310(0, 0, 0));
3754
3892
  this.add(this.directionalLight);
3755
3893
  if (this.debug === true && this.camHelper instanceof CameraHelper) {
3756
3894
  this.add(this.camHelper);
@@ -3788,7 +3926,7 @@ var Sun = class extends Group4 {
3788
3926
  if (!this.target)
3789
3927
  return;
3790
3928
  const distance = this.sunOffset.z;
3791
- const sphericalPosition = new Vector39(
3929
+ const sphericalPosition = new Vector310(
3792
3930
  distance * Math.sin(polarAngle) * Math.cos(azimuthalAngle),
3793
3931
  distance * Math.cos(polarAngle),
3794
3932
  distance * Math.sin(polarAngle) * Math.sin(azimuthalAngle)
@@ -3963,7 +4101,7 @@ import {
3963
4101
  ShaderMaterial as ShaderMaterial4,
3964
4102
  Uniform as Uniform7,
3965
4103
  Vector2 as Vector26,
3966
- Vector3 as Vector313,
4104
+ Vector3 as Vector314,
3967
4105
  WebGLMultipleRenderTargets,
3968
4106
  WebGLRenderTarget
3969
4107
  } from "three";
@@ -4108,7 +4246,7 @@ var DepthDownSample = {
4108
4246
  };
4109
4247
 
4110
4248
  // src/rendering/post-effects/n8-ssao/EffectCompositer.ts
4111
- import { Matrix4 as Matrix43, Uniform as Uniform4, Vector2 as Vector23, Vector3 as Vector310 } from "three";
4249
+ import { Matrix4 as Matrix43, Uniform as Uniform4, Vector2 as Vector23, Vector3 as Vector311 } from "three";
4112
4250
  var EffectCompositer = {
4113
4251
  uniforms: {
4114
4252
  sceneDiffuse: new Uniform4(null),
@@ -4118,9 +4256,9 @@ var EffectCompositer = {
4118
4256
  viewMat: new Uniform4(new Matrix43()),
4119
4257
  projectionMatrixInv: new Uniform4(new Matrix43()),
4120
4258
  viewMatrixInv: new Uniform4(new Matrix43()),
4121
- cameraPos: new Uniform4(new Vector310()),
4259
+ cameraPos: new Uniform4(new Vector311()),
4122
4260
  resolution: new Uniform4(new Vector23()),
4123
- color: new Uniform4(new Vector310()),
4261
+ color: new Uniform4(new Vector311()),
4124
4262
  blueNoise: new Uniform4(null),
4125
4263
  downsampledDepth: new Uniform4(null),
4126
4264
  time: new Uniform4(0),
@@ -4371,7 +4509,7 @@ var EffectCompositer = {
4371
4509
  };
4372
4510
 
4373
4511
  // src/rendering/post-effects/n8-ssao/EffectShader.ts
4374
- import { Matrix4 as Matrix44, Uniform as Uniform5, Vector2 as Vector24, Vector3 as Vector311 } from "three";
4512
+ import { Matrix4 as Matrix44, Uniform as Uniform5, Vector2 as Vector24, Vector3 as Vector312 } from "three";
4375
4513
  var EffectShader = {
4376
4514
  uniforms: {
4377
4515
  sceneDiffuse: new Uniform5(null),
@@ -4382,7 +4520,7 @@ var EffectShader = {
4382
4520
  projViewMat: new Uniform5(new Matrix44()),
4383
4521
  projectionMatrixInv: new Uniform5(new Matrix44()),
4384
4522
  viewMatrixInv: new Uniform5(new Matrix44()),
4385
- cameraPos: new Uniform5(new Vector311()),
4523
+ cameraPos: new Uniform5(new Vector312()),
4386
4524
  resolution: new Uniform5(new Vector24()),
4387
4525
  time: new Uniform5(0),
4388
4526
  samples: new Uniform5([]),
@@ -4594,7 +4732,7 @@ var EffectShader = {
4594
4732
  import {
4595
4733
  BufferAttribute,
4596
4734
  BufferGeometry,
4597
- Mesh as Mesh4,
4735
+ Mesh as Mesh3,
4598
4736
  OrthographicCamera as OrthographicCamera2,
4599
4737
  Sphere
4600
4738
  } from "three";
@@ -4610,7 +4748,7 @@ var FullScreenTriangle = class {
4610
4748
  this.geometry.boundingSphere = new Sphere();
4611
4749
  this.geometry.computeBoundingSphere = function() {
4612
4750
  };
4613
- this.mesh = new Mesh4(this.geometry, material);
4751
+ this.mesh = new Mesh3(this.geometry, material);
4614
4752
  this.mesh.frustumCulled = false;
4615
4753
  }
4616
4754
  get material() {
@@ -4629,7 +4767,7 @@ var FullScreenTriangle = class {
4629
4767
  };
4630
4768
 
4631
4769
  // src/rendering/post-effects/n8-ssao/PoissionBlur.ts
4632
- import { Matrix4 as Matrix45, Uniform as Uniform6, Vector2 as Vector25, Vector3 as Vector312 } from "three";
4770
+ import { Matrix4 as Matrix45, Uniform as Uniform6, Vector2 as Vector25, Vector3 as Vector313 } from "three";
4633
4771
  var PoissionBlur = {
4634
4772
  uniforms: {
4635
4773
  sceneDiffuse: new Uniform6(null),
@@ -4639,7 +4777,7 @@ var PoissionBlur = {
4639
4777
  viewMat: new Uniform6(new Matrix45()),
4640
4778
  projectionMatrixInv: new Uniform6(new Matrix45()),
4641
4779
  viewMatrixInv: new Uniform6(new Matrix45()),
4642
- cameraPos: new Uniform6(new Vector312()),
4780
+ cameraPos: new Uniform6(new Vector313()),
4643
4781
  resolution: new Uniform6(new Vector25()),
4644
4782
  time: new Uniform6(0),
4645
4783
  r: new Uniform6(5),
@@ -5025,7 +5163,7 @@ var N8SSAOPass = class extends Pass {
5025
5163
  const x = r * Math.cos(theta);
5026
5164
  const y = r * Math.sin(theta);
5027
5165
  const z = Math.sqrt(1 - (x * x + y * y));
5028
- points.push(new Vector313(x, y, z));
5166
+ points.push(new Vector314(x, y, z));
5029
5167
  }
5030
5168
  return points;
5031
5169
  }
@@ -5124,7 +5262,7 @@ var N8SSAOPass = class extends Pass {
5124
5262
  effectShaderUniforms.projViewMat.value = this.camera.projectionMatrix.clone().multiply(this.camera.matrixWorldInverse.clone());
5125
5263
  effectShaderUniforms.projectionMatrixInv.value = this.camera.projectionMatrixInverse;
5126
5264
  effectShaderUniforms.viewMatrixInv.value = this.camera.matrixWorld;
5127
- effectShaderUniforms.cameraPos.value = this.camera.getWorldPosition(new Vector313());
5265
+ effectShaderUniforms.cameraPos.value = this.camera.getWorldPosition(new Vector314());
5128
5266
  effectShaderUniforms.resolution.value = this.configuration.halfRes ? this.r.clone().multiplyScalar(1 / 2).floor() : this.r;
5129
5267
  effectShaderUniforms.time.value = performance.now() / 1e3;
5130
5268
  effectShaderUniforms.samples.value = this.samples;
@@ -5153,7 +5291,7 @@ var N8SSAOPass = class extends Pass {
5153
5291
  poissonBlurUniforms.viewMat.value = this.camera.matrixWorldInverse;
5154
5292
  poissonBlurUniforms.projectionMatrixInv.value = this.camera.projectionMatrixInverse;
5155
5293
  poissonBlurUniforms.viewMatrixInv.value = this.camera.matrixWorld;
5156
- poissonBlurUniforms.cameraPos.value = this.camera.getWorldPosition(new Vector313());
5294
+ poissonBlurUniforms.cameraPos.value = this.camera.getWorldPosition(new Vector314());
5157
5295
  poissonBlurUniforms.resolution.value = this.configuration.halfRes ? this.r.clone().multiplyScalar(1 / 2).floor() : this.r;
5158
5296
  poissonBlurUniforms.time.value = performance.now() / 1e3;
5159
5297
  poissonBlurUniforms.blueNoise.value = this.bluenoise;
@@ -5192,7 +5330,7 @@ var N8SSAOPass = class extends Pass {
5192
5330
  effectCompositerUniforms.tDiffuse.value = this.writeTargetInternal.texture;
5193
5331
  effectCompositerUniforms.color.value = this.c.copy(this.configuration.color).convertSRGBToLinear();
5194
5332
  effectCompositerUniforms.colorMultiply.value = this.configuration.colorMultiply;
5195
- effectCompositerUniforms.cameraPos.value = this.camera.getWorldPosition(new Vector313());
5333
+ effectCompositerUniforms.cameraPos.value = this.camera.getWorldPosition(new Vector314());
5196
5334
  effectCompositerUniforms.fog.value = !!this.scene.fog;
5197
5335
  if (this.scene.fog) {
5198
5336
  if (this.scene.fog instanceof Fog && this.scene.fog.isFog === true) {
@@ -5744,31 +5882,31 @@ var TimeManager = class {
5744
5882
  // src/collisions/CollisionsManager.ts
5745
5883
  import { MMLCollisionTrigger } from "@mml-io/mml-web";
5746
5884
  import {
5747
- Box3,
5885
+ Box3 as Box32,
5748
5886
  Color as Color8,
5749
5887
  DoubleSide,
5750
5888
  Euler as Euler5,
5751
5889
  Group as Group5,
5752
5890
  Line3 as Line32,
5753
5891
  Matrix4 as Matrix47,
5754
- Mesh as Mesh5,
5755
- MeshBasicMaterial as MeshBasicMaterial3,
5892
+ Mesh as Mesh4,
5893
+ MeshBasicMaterial,
5756
5894
  Quaternion as Quaternion7,
5757
5895
  Ray as Ray2,
5758
- Vector3 as Vector315
5896
+ Vector3 as Vector316
5759
5897
  } from "three";
5760
5898
  import { VertexNormalsHelper } from "three/examples/jsm/helpers/VertexNormalsHelper.js";
5761
5899
  import * as BufferGeometryUtils from "three/examples/jsm/utils/BufferGeometryUtils.js";
5762
5900
  import { MeshBVH, MeshBVHHelper } from "three-mesh-bvh";
5763
5901
 
5764
5902
  // src/collisions/getRelativePositionAndRotationRelativeToObject.ts
5765
- import { Euler as Euler4, Matrix4 as Matrix46, Quaternion as Quaternion6, Vector3 as Vector314 } from "three";
5903
+ import { Euler as Euler4, Matrix4 as Matrix46, Quaternion as Quaternion6, Vector3 as Vector315 } from "three";
5766
5904
  var tempContainerMatrix = new Matrix46();
5767
5905
  var tempTargetMatrix = new Matrix46();
5768
- var tempPositionVector = new Vector314();
5906
+ var tempPositionVector = new Vector315();
5769
5907
  var tempRotationEuler = new Euler4();
5770
5908
  var tempRotationQuaternion = new Quaternion6();
5771
- var tempScaleVector = new Vector314();
5909
+ var tempScaleVector = new Vector315();
5772
5910
  function getRelativePositionAndRotationRelativeToObject(positionAndRotation, container) {
5773
5911
  const { x, y, z } = positionAndRotation.position;
5774
5912
  const { x: rx, y: ry, z: rz } = positionAndRotation.rotation;
@@ -5800,14 +5938,14 @@ function getRelativePositionAndRotationRelativeToObject(positionAndRotation, con
5800
5938
  var CollisionsManager = class {
5801
5939
  constructor(scene) {
5802
5940
  this.debug = false;
5803
- this.tempVector = new Vector315();
5804
- this.tempVector2 = new Vector315();
5805
- this.tempVector3 = new Vector315();
5941
+ this.tempVector = new Vector316();
5942
+ this.tempVector2 = new Vector316();
5943
+ this.tempVector3 = new Vector316();
5806
5944
  this.tempQuaternion = new Quaternion7();
5807
5945
  this.tempRay = new Ray2();
5808
5946
  this.tempMatrix = new Matrix47();
5809
5947
  this.tempMatrix2 = new Matrix47();
5810
- this.tempBox = new Box3();
5948
+ this.tempBox = new Box32();
5811
5949
  this.tempEuler = new Euler5();
5812
5950
  this.tempSegment = new Line32();
5813
5951
  this.tempSegment2 = new Line32();
@@ -5818,7 +5956,7 @@ var CollisionsManager = class {
5818
5956
  raycastFirst(ray) {
5819
5957
  let minimumDistance = null;
5820
5958
  let minimumHit = null;
5821
- let minimumNormal = new Vector315();
5959
+ let minimumNormal = new Vector316();
5822
5960
  for (const [, collisionMeshState] of this.collisionMeshState) {
5823
5961
  this.tempRay.copy(ray).applyMatrix4(this.tempMatrix.copy(collisionMeshState.matrix).invert());
5824
5962
  const hit = collisionMeshState.meshBVH.raycastFirst(this.tempRay, DoubleSide);
@@ -5876,7 +6014,7 @@ var CollisionsManager = class {
5876
6014
  };
5877
6015
  if (this.debug) {
5878
6016
  newBufferGeometry.boundsTree = meshBVH;
5879
- const wireframeMesh = new Mesh5(newBufferGeometry, new MeshBasicMaterial3({ wireframe: true }));
6017
+ const wireframeMesh = new Mesh4(newBufferGeometry, new MeshBasicMaterial({ wireframe: true }));
5880
6018
  const normalsHelper = new VertexNormalsHelper(wireframeMesh, 0.25, 65280);
5881
6019
  const visualizer = new MeshBVHHelper(wireframeMesh, 4);
5882
6020
  visualizer.edgeMaterial.color = new Color8("blue");
@@ -5959,7 +6097,7 @@ var CollisionsManager = class {
5959
6097
  const realDistance = intersectionSegment.distance();
5960
6098
  if (realDistance < capsuleRadius) {
5961
6099
  if (!collisionPosition) {
5962
- collisionPosition = new Vector315().copy(closestPointOnSegment).applyMatrix4(meshState.matrix);
6100
+ collisionPosition = new Vector316().copy(closestPointOnSegment).applyMatrix4(meshState.matrix);
5963
6101
  }
5964
6102
  const ratio = realDistance / modelReferenceDistance;
5965
6103
  const realDepth = capsuleRadius - realDistance;
@@ -6017,10 +6155,10 @@ import {
6017
6155
  FrontSide as FrontSide2,
6018
6156
  Group as Group6,
6019
6157
  LinearMipMapLinearFilter,
6020
- Mesh as Mesh6,
6158
+ Mesh as Mesh5,
6021
6159
  MeshStandardMaterial as MeshStandardMaterial3,
6022
6160
  NearestFilter as NearestFilter2,
6023
- PlaneGeometry as PlaneGeometry2,
6161
+ PlaneGeometry,
6024
6162
  RepeatWrapping as RepeatWrapping2
6025
6163
  } from "three";
6026
6164
  var canvas = document.createElement("canvas");
@@ -6037,7 +6175,7 @@ var GroundPlane = class extends Group6 {
6037
6175
  super();
6038
6176
  this.floorSize = 210;
6039
6177
  this.floorTexture = null;
6040
- this.floorGeometry = new PlaneGeometry2(this.floorSize, this.floorSize, 1, 1);
6178
+ this.floorGeometry = new PlaneGeometry(this.floorSize, this.floorSize, 1, 1);
6041
6179
  this.floorMesh = null;
6042
6180
  this.floorMaterial = new MeshStandardMaterial3({
6043
6181
  color: 16777215,
@@ -6045,7 +6183,7 @@ var GroundPlane = class extends Group6 {
6045
6183
  metalness: 0.05,
6046
6184
  roughness: 0.95
6047
6185
  });
6048
- this.floorMesh = new Mesh6(this.floorGeometry, this.floorMaterial);
6186
+ this.floorMesh = new Mesh5(this.floorGeometry, this.floorMaterial);
6049
6187
  this.floorMesh.receiveShadow = true;
6050
6188
  this.floorMesh.rotation.x = Math.PI * -0.5;
6051
6189
  this.add(this.floorMesh);