@mml-io/mml-web-client 0.19.3 → 0.19.5

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
@@ -985,6 +985,8 @@
985
985
  case "changeHiddenFrom":
986
986
  this.handleChangeHiddenFrom(message);
987
987
  break;
988
+ case "changeVisibleTo":
989
+ break;
988
990
  case "childrenRemoved":
989
991
  this.handleChildrenRemoved(message);
990
992
  break;
@@ -2315,13 +2317,20 @@
2315
2317
  }
2316
2318
  return lerpHSL(previousValue, elementValue, ratio);
2317
2319
  }
2318
- getFloatValueForTime(windowTime, elementValueSetTime, elementValue, previousValue) {
2319
- const from = previousValue;
2320
+ getFloatValueForTime(windowTime, elementValueSetTime, elementValue, previousValue, isDegrees) {
2321
+ let from = previousValue;
2320
2322
  const to = elementValue;
2321
2323
  const ratio = this.getLerpRatio(windowTime, elementValueSetTime);
2322
2324
  if (ratio >= 1) {
2323
2325
  return to;
2324
2326
  }
2327
+ if (isDegrees) {
2328
+ if (to - from > 180) {
2329
+ from += 360;
2330
+ } else if (from - to > 180) {
2331
+ from -= 360;
2332
+ }
2333
+ }
2325
2334
  return from + (to - from) * ratio;
2326
2335
  }
2327
2336
  getLerpRatio(windowTime, elementValueSetTime) {
@@ -2379,6 +2388,9 @@
2379
2388
  }
2380
2389
  }
2381
2390
  function isColorAttribute(attributeState) {
2391
+ return attributeState.type === 2;
2392
+ }
2393
+ function isDegreesAttribute(attributeState) {
2382
2394
  return attributeState.type === 1;
2383
2395
  }
2384
2396
  function isNumberAttribute(attributeState) {
@@ -2537,7 +2549,7 @@
2537
2549
  let stale = null;
2538
2550
  const state = this.stateByAttribute[key];
2539
2551
  for (const animation of state.animationsInOrder) {
2540
- const [newValue, active] = state.attributeState.type === 1 ? animation.getColorValueForTime(documentTime) : animation.getFloatValueForTime(documentTime);
2552
+ const [newValue, active] = state.attributeState.type === 2 ? animation.getColorValueForTime(documentTime) : animation.getFloatValueForTime(documentTime);
2541
2553
  if (active === 0) {
2542
2554
  updateIfChangedValue(state, newValue);
2543
2555
  stale = null;
@@ -2573,6 +2585,17 @@
2573
2585
  config.previousValue
2574
2586
  )
2575
2587
  );
2588
+ } else if (isDegreesAttribute(config)) {
2589
+ updateIfChangedValue(
2590
+ state,
2591
+ lerp2.getFloatValueForTime(
2592
+ this.element.getWindowTime(),
2593
+ config.elementValueSetTime,
2594
+ config.elementValue,
2595
+ config.previousValue,
2596
+ true
2597
+ )
2598
+ );
2576
2599
  } else if (isNumberAttribute(config)) {
2577
2600
  updateIfChangedValue(
2578
2601
  state,
@@ -2580,7 +2603,8 @@
2580
2603
  this.element.getWindowTime(),
2581
2604
  config.elementValueSetTime,
2582
2605
  config.elementValue,
2583
- config.previousValue
2606
+ config.previousValue,
2607
+ false
2584
2608
  )
2585
2609
  );
2586
2610
  }
@@ -3592,7 +3616,7 @@
3592
3616
  }
3593
3617
  ],
3594
3618
  rx: [
3595
- 0,
3619
+ 1,
3596
3620
  0,
3597
3621
  (newValue) => {
3598
3622
  var _a2;
@@ -3602,7 +3626,7 @@
3602
3626
  }
3603
3627
  ],
3604
3628
  ry: [
3605
- 0,
3629
+ 1,
3606
3630
  0,
3607
3631
  (newValue) => {
3608
3632
  var _a2;
@@ -3612,7 +3636,7 @@
3612
3636
  }
3613
3637
  ],
3614
3638
  rz: [
3615
- 0,
3639
+ 1,
3616
3640
  0,
3617
3641
  (newValue) => {
3618
3642
  var _a2;
@@ -4474,7 +4498,7 @@
4474
4498
  };
4475
4499
  this.cubeAnimatedAttributeHelper = new AnimatedAttributeHelper(this, {
4476
4500
  color: [
4477
- 1,
4501
+ 2,
4478
4502
  defaultCubeColor,
4479
4503
  (newValue) => {
4480
4504
  var _a2;
@@ -4653,7 +4677,7 @@
4653
4677
  };
4654
4678
  this.cylinderAnimatedAttributeHelper = new AnimatedAttributeHelper(this, {
4655
4679
  color: [
4656
- 1,
4680
+ 2,
4657
4681
  defaultCylinderColor,
4658
4682
  (newValue) => {
4659
4683
  var _a2;
@@ -6024,7 +6048,7 @@
6024
6048
  this.collideableHelper = new CollideableHelper(this);
6025
6049
  this.labelAnimatedAttributeHelper = new AnimatedAttributeHelper(this, {
6026
6050
  color: [
6027
- 1,
6051
+ 2,
6028
6052
  defaultLabelColor,
6029
6053
  (newValue) => {
6030
6054
  var _a2;
@@ -6033,7 +6057,7 @@
6033
6057
  }
6034
6058
  ],
6035
6059
  "font-color": [
6036
- 1,
6060
+ 2,
6037
6061
  defaultFontColor,
6038
6062
  (newValue) => {
6039
6063
  var _a2;
@@ -6236,7 +6260,7 @@
6236
6260
  super();
6237
6261
  this.lightAnimatedAttributeHelper = new AnimatedAttributeHelper(this, {
6238
6262
  color: [
6239
- 1,
6263
+ 2,
6240
6264
  defaultLightColor,
6241
6265
  (newValue) => {
6242
6266
  var _a2;
@@ -6509,7 +6533,7 @@
6509
6533
  };
6510
6534
  this.planeAnimatedAttributeHelper = new AnimatedAttributeHelper(this, {
6511
6535
  color: [
6512
- 1,
6536
+ 2,
6513
6537
  defaultPlaneColor,
6514
6538
  (newValue) => {
6515
6539
  var _a2;
@@ -7091,7 +7115,7 @@
7091
7115
  };
7092
7116
  this.sphereAnimatedAttributeHelper = new AnimatedAttributeHelper(this, {
7093
7117
  color: [
7094
- 1,
7118
+ 2,
7095
7119
  defaultSphereColor,
7096
7120
  (newValue) => {
7097
7121
  var _a2;
@@ -65063,6 +65087,7 @@ ${DracoWorker.toString()}
65063
65087
  this.updateDebugVisualisation();
65064
65088
  }
65065
65089
  if (!src) {
65090
+ this.latestSrcModelPromise = null;
65066
65091
  this.srcLoadingInstanceManager.abortIfLoading();
65067
65092
  this.socketChildrenByBone.forEach((children) => {
65068
65093
  children.forEach((child) => {
@@ -65074,10 +65099,13 @@ ${DracoWorker.toString()}
65074
65099
  return;
65075
65100
  }
65076
65101
  const contentSrc = this.model.contentSrcToContentAddress(src);
65102
+ this.srcLoadingInstanceManager.start(this.model.getLoadingProgressManager(), contentSrc);
65077
65103
  const srcModelPromise = this.asyncLoadSourceAsset(contentSrc, (loaded, total) => {
65104
+ if (this.latestSrcModelPromise !== srcModelPromise) {
65105
+ return;
65106
+ }
65078
65107
  this.srcLoadingInstanceManager.setProgress(loaded / total);
65079
65108
  });
65080
- this.srcLoadingInstanceManager.start(this.model.getLoadingProgressManager(), contentSrc);
65081
65109
  this.latestSrcModelPromise = srcModelPromise;
65082
65110
  srcModelPromise.then((asset2) => {
65083
65111
  if (this.latestSrcModelPromise !== srcModelPromise || !this.model.isConnected) {
@@ -65223,6 +65251,8 @@ ${DracoWorker.toString()}
65223
65251
  this.loadedState = null;
65224
65252
  }
65225
65253
  this.clearDebugVisualisation();
65254
+ this.latestSrcModelPromise = null;
65255
+ this.latestAnimPromise = null;
65226
65256
  this.animLoadingInstanceManager.dispose();
65227
65257
  this.srcLoadingInstanceManager.dispose();
65228
65258
  }
@@ -97231,10 +97261,13 @@ void main() {
97231
97261
  this.mesh.castShadow = castShadows;
97232
97262
  }
97233
97263
  setOpacity(opacity) {
97234
- const needsUpdate = this.material.transparent === (opacity === 1);
97235
- this.material.transparent = opacity !== 1;
97236
- this.material.needsUpdate = needsUpdate;
97264
+ const shouldBeTransparent = opacity !== 1 || this.loadedImageHasTransparency;
97265
+ const needsUpdate = this.material.transparent !== shouldBeTransparent;
97266
+ this.material.transparent = shouldBeTransparent;
97237
97267
  this.material.opacity = opacity;
97268
+ if (needsUpdate) {
97269
+ this.material.needsUpdate = true;
97270
+ }
97238
97271
  }
97239
97272
  setEmissive() {
97240
97273
  this.updateMaterialEmissiveIntensity();
@@ -97327,15 +97360,9 @@ void main() {
97327
97360
  if (!this.material) {
97328
97361
  return;
97329
97362
  }
97330
- if (this.loadedImageHasTransparency) {
97331
- this.material.alphaMap = new CanvasTexture(this.loadedImage);
97332
- this.material.alphaTest = 0.01;
97333
- } else {
97334
- this.material.alphaMap = null;
97335
- this.material.alphaTest = 0;
97336
- }
97337
- this.material.transparent = this.image.props.opacity !== 1 || this.loadedImageHasTransparency;
97338
97363
  this.material.map = new CanvasTexture(this.loadedImage);
97364
+ this.material.transparent = this.image.props.opacity !== 1 || this.loadedImageHasTransparency;
97365
+ this.material.alphaTest = 0.01;
97339
97366
  this.material.needsUpdate = true;
97340
97367
  this.updateMaterialEmissiveIntensity();
97341
97368
  this.updateWidthAndHeight();
@@ -97849,10 +97876,13 @@ void main() {
97849
97876
  this.registeredParentAttachment = null;
97850
97877
  }
97851
97878
  const animSrc = this.model.contentSrcToContentAddress(anim2);
97879
+ this.animLoadingInstanceManager.start(this.model.getLoadingProgressManager(), animSrc);
97852
97880
  const animPromise = this.asyncLoadSourceAsset(animSrc, (loaded, total) => {
97881
+ if (this.latestAnimPromise !== animPromise) {
97882
+ return;
97883
+ }
97853
97884
  this.animLoadingInstanceManager.setProgress(loaded / total);
97854
97885
  });
97855
- this.animLoadingInstanceManager.start(this.model.getLoadingProgressManager(), animSrc);
97856
97886
  this.latestAnimPromise = animPromise;
97857
97887
  animPromise.then((result) => {
97858
97888
  if (this.latestAnimPromise !== animPromise || !this.model.isConnected) {
@@ -97895,6 +97925,7 @@ void main() {
97895
97925
  this.updateDebugVisualisation();
97896
97926
  }
97897
97927
  if (!src) {
97928
+ this.latestSrcModelPromise = null;
97898
97929
  this.srcLoadingInstanceManager.abortIfLoading();
97899
97930
  this.socketChildrenByBone.forEach((children) => {
97900
97931
  children.forEach((child) => {
@@ -97906,10 +97937,13 @@ void main() {
97906
97937
  return;
97907
97938
  }
97908
97939
  const contentSrc = this.model.contentSrcToContentAddress(src);
97940
+ this.srcLoadingInstanceManager.start(this.model.getLoadingProgressManager(), contentSrc);
97909
97941
  const srcModelPromise = this.asyncLoadSourceAsset(contentSrc, (loaded, total) => {
97942
+ if (this.latestSrcModelPromise !== srcModelPromise) {
97943
+ return;
97944
+ }
97910
97945
  this.srcLoadingInstanceManager.setProgress(loaded / total);
97911
97946
  });
97912
- this.srcLoadingInstanceManager.start(this.model.getLoadingProgressManager(), contentSrc);
97913
97947
  this.latestSrcModelPromise = srcModelPromise;
97914
97948
  srcModelPromise.then((result) => {
97915
97949
  if (this.latestSrcModelPromise !== srcModelPromise || !this.model.isConnected) {
@@ -97961,6 +97995,7 @@ void main() {
97961
97995
  if (this.animState) {
97962
97996
  this.playAnimation(this.animState.currentAnimationClip);
97963
97997
  }
97998
+ console.log("Loaded model", this.loadedState);
97964
97999
  this.srcLoadingInstanceManager.finish();
97965
98000
  this.updateDebugVisualisation();
97966
98001
  }).catch((err2) => {
@@ -98162,6 +98197,8 @@ void main() {
98162
98197
  this.loadedState = null;
98163
98198
  }
98164
98199
  this.clearDebugVisualisation();
98200
+ this.latestSrcModelPromise = null;
98201
+ this.latestAnimPromise = null;
98165
98202
  this.animLoadingInstanceManager.dispose();
98166
98203
  this.srcLoadingInstanceManager.dispose();
98167
98204
  }