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

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
@@ -1895,6 +1895,7 @@
1895
1895
  constructor() {
1896
1896
  super();
1897
1897
  this.mElementGraphics = null;
1898
+ this.isMElement = true;
1898
1899
  }
1899
1900
  // This allows switching which document this HTMLElement subclass extends so that it can be placed into iframes
1900
1901
  static overwriteSuperclass(newSuperclass) {
@@ -1903,6 +1904,9 @@
1903
1904
  static get observedAttributes() {
1904
1905
  return [];
1905
1906
  }
1907
+ static isMElement(element) {
1908
+ return element.isMElement;
1909
+ }
1906
1910
  static getMElementFromObject(object) {
1907
1911
  return object[MELEMENT_PROPERTY_NAME] || null;
1908
1912
  }
@@ -2076,7 +2080,7 @@
2076
2080
  getMElementParent() {
2077
2081
  let parentNode = this.parentNode;
2078
2082
  while (parentNode != null) {
2079
- if (parentNode instanceof _MElement) {
2083
+ if (_MElement.isMElement(parentNode)) {
2080
2084
  return parentNode;
2081
2085
  }
2082
2086
  parentNode = parentNode.parentNode;
@@ -2123,6 +2127,10 @@
2123
2127
  animDuration: defaultAnimDuration
2124
2128
  };
2125
2129
  this.registeredParentAttachment = null;
2130
+ this.isAttributeAnimation = true;
2131
+ }
2132
+ static isAttributeAnimation(element) {
2133
+ return element.isAttributeAnimation;
2126
2134
  }
2127
2135
  static get observedAttributes() {
2128
2136
  return [..._AttributeAnimation2.attributeHandler.getAttributes()];
@@ -2148,7 +2156,7 @@
2148
2156
  }
2149
2157
  connectedCallback() {
2150
2158
  super.connectedCallback();
2151
- if (this.parentElement && this.parentElement instanceof MElement) {
2159
+ if (this.parentElement && MElement.isMElement(this.parentElement)) {
2152
2160
  this.registeredParentAttachment = this.parentElement;
2153
2161
  if (this.props.attr) {
2154
2162
  this.registeredParentAttachment.addSideEffectChild(this);
@@ -2259,6 +2267,10 @@
2259
2267
  lerpDuration: defaultLerpDuration
2260
2268
  };
2261
2269
  this.registeredParentAttachment = null;
2270
+ this.isAttributeLerp = true;
2271
+ }
2272
+ static isAttributeLerp(element) {
2273
+ return element.isAttributeLerp;
2262
2274
  }
2263
2275
  static get observedAttributes() {
2264
2276
  return [..._AttributeLerp2.attributeHandler.getAttributes()];
@@ -2284,7 +2296,7 @@
2284
2296
  }
2285
2297
  connectedCallback() {
2286
2298
  super.connectedCallback();
2287
- if (this.parentElement && this.parentElement instanceof MElement) {
2299
+ if (this.parentElement && MElement.isMElement(this.parentElement)) {
2288
2300
  this.registeredParentAttachment = this.parentElement;
2289
2301
  this.registeredParentAttachment.addSideEffectChild(this);
2290
2302
  }
@@ -2385,12 +2397,12 @@
2385
2397
  this.reset();
2386
2398
  }
2387
2399
  addSideEffectChild(child) {
2388
- if (child instanceof AttributeAnimation) {
2400
+ if (AttributeAnimation.isAttributeAnimation(child)) {
2389
2401
  const attr = child.getAnimatedAttributeName();
2390
2402
  if (attr) {
2391
2403
  this.addAnimation(child, attr);
2392
2404
  }
2393
- } else if (child instanceof AttributeLerp) {
2405
+ } else if (AttributeLerp.isAttributeLerp(child)) {
2394
2406
  const attr = child.getAnimatedAttributeName();
2395
2407
  if (attr) {
2396
2408
  this.addLerp(child, attr);
@@ -2398,12 +2410,12 @@
2398
2410
  }
2399
2411
  }
2400
2412
  removeSideEffectChild(child) {
2401
- if (child instanceof AttributeAnimation) {
2413
+ if (AttributeAnimation.isAttributeAnimation(child)) {
2402
2414
  const attr = child.getAnimatedAttributeName();
2403
2415
  if (attr) {
2404
2416
  this.removeAnimation(child, attr);
2405
2417
  }
2406
- } else if (child instanceof AttributeLerp) {
2418
+ } else if (AttributeLerp.isAttributeLerp(child)) {
2407
2419
  const attr = child.getAnimatedAttributeName();
2408
2420
  if (attr) {
2409
2421
  this.removeLerp(child, attr);
@@ -3530,6 +3542,7 @@
3530
3542
  var _TransformableElement = class _TransformableElement2 extends MElement {
3531
3543
  constructor() {
3532
3544
  super(...arguments);
3545
+ this.isTransformableElement = true;
3533
3546
  this.transformableElementProps = {
3534
3547
  socket: null,
3535
3548
  x: 0,
@@ -3650,10 +3663,13 @@
3650
3663
  });
3651
3664
  this.debugHelper = new DebugHelper(this);
3652
3665
  }
3666
+ static isTransformableElement(element) {
3667
+ return element.isTransformableElement;
3668
+ }
3653
3669
  getTransformableElementParent() {
3654
3670
  let parentNode = this.parentNode;
3655
3671
  while (parentNode != null) {
3656
- if (parentNode instanceof _TransformableElement2) {
3672
+ if (_TransformableElement2.isTransformableElement(parentNode)) {
3657
3673
  return parentNode;
3658
3674
  }
3659
3675
  parentNode = parentNode.parentNode;
@@ -3906,7 +3922,7 @@
3906
3922
  var TransformableElement = _TransformableElement;
3907
3923
  function traverseImmediateTransformableElementChildren(element, callback) {
3908
3924
  element.childNodes.forEach((child) => {
3909
- if (child instanceof TransformableElement) {
3925
+ if (TransformableElement.isTransformableElement(child)) {
3910
3926
  callback(child);
3911
3927
  } else {
3912
3928
  traverseImmediateTransformableElementChildren(child, callback);
@@ -4116,9 +4132,12 @@
4116
4132
  castShadows: defaultModelCastShadows,
4117
4133
  debug: defaultModelDebug
4118
4134
  };
4119
- this.isModel = true;
4120
4135
  this.collideableHelper = new CollideableHelper(this);
4121
4136
  this.modelGraphics = null;
4137
+ this.isModel = true;
4138
+ }
4139
+ static isModel(element) {
4140
+ return element.isModel;
4122
4141
  }
4123
4142
  enable() {
4124
4143
  this.collideableHelper.enable();
@@ -4269,7 +4288,7 @@
4269
4288
  tempContainerMatrix.identity();
4270
4289
  const tempMatr4 = new Matr4();
4271
4290
  for (let obj = container; obj; obj = obj.parentNode) {
4272
- if (obj instanceof TransformableElement) {
4291
+ if (TransformableElement.isTransformableElement(obj)) {
4273
4292
  obj.calculateLocalMatrix(tempMatr4);
4274
4293
  tempContainerMatrix.premultiply(tempMatr4);
4275
4294
  }
@@ -6278,7 +6297,7 @@
6278
6297
  return OrientedBoundingBox.fromMatrixWorld(this.transformableElementGraphics.getWorldMatrix());
6279
6298
  }
6280
6299
  addSideEffectChild(child) {
6281
- if (child instanceof AttributeAnimation) {
6300
+ if (AttributeAnimation.isAttributeAnimation(child)) {
6282
6301
  const attr = child.getAnimatedAttributeName();
6283
6302
  if (attr) {
6284
6303
  this.lightAnimatedAttributeHelper.addAnimation(child, attr);
@@ -6287,7 +6306,7 @@
6287
6306
  super.addSideEffectChild(child);
6288
6307
  }
6289
6308
  removeSideEffectChild(child) {
6290
- if (child instanceof AttributeAnimation) {
6309
+ if (AttributeAnimation.isAttributeAnimation(child)) {
6291
6310
  const attr = child.getAnimatedAttributeName();
6292
6311
  if (attr) {
6293
6312
  this.lightAnimatedAttributeHelper.removeAnimation(child, attr);
@@ -8186,7 +8205,7 @@
8186
8205
  var _a2;
8187
8206
  for (const i in element.children) {
8188
8207
  const child = element.children[i];
8189
- if (child instanceof MElement) {
8208
+ if (MElement.isMElement(child)) {
8190
8209
  (_a2 = child.connectedCallback) == null ? void 0 : _a2.call(child);
8191
8210
  }
8192
8211
  traverse(child);
@@ -63477,7 +63496,7 @@ ${DracoWorker.toString()}
63477
63496
  break;
63478
63497
  }
63479
63498
  }
63480
- if (mElement && mElement instanceof TransformableElement && mElement.isClickable()) {
63499
+ if (mElement && TransformableElement.isTransformableElement(mElement) && mElement.isClickable()) {
63481
63500
  const elementRelative = getRelativePositionAndRotationRelativeToObject(
63482
63501
  {
63483
63502
  position: result.point,
@@ -64914,7 +64933,7 @@ ${DracoWorker.toString()}
64914
64933
  this.latestAnimPromise = null;
64915
64934
  if (this.loadedState && !this.registeredParentAttachment) {
64916
64935
  const parent = this.model.parentElement;
64917
- if (parent instanceof Model) {
64936
+ if (parent && Model.isModel(parent)) {
64918
64937
  this.registeredParentAttachment = parent;
64919
64938
  parent.modelGraphics.registerAttachment(this.model);
64920
64939
  }
@@ -65111,7 +65130,7 @@ ${DracoWorker.toString()}
65111
65130
  this.connectAnimationToModel();
65112
65131
  this.updateMeshCallback();
65113
65132
  const parent = this.model.parentElement;
65114
- if (parent instanceof Model) {
65133
+ if (parent && Model.isModel(parent)) {
65115
65134
  if (!this.latestAnimPromise && !this.animState) {
65116
65135
  this.registeredParentAttachment = parent;
65117
65136
  parent.modelGraphics.registerAttachment(this.model);
@@ -65210,7 +65229,7 @@ ${DracoWorker.toString()}
65210
65229
  triggerSocketedChildrenTransformed() {
65211
65230
  this.socketChildrenByBone.forEach((children) => {
65212
65231
  children.forEach((child) => {
65213
- if (child instanceof TransformableElement) {
65232
+ if (TransformableElement.isTransformableElement(child)) {
65214
65233
  child.didUpdateTransformation();
65215
65234
  }
65216
65235
  });
@@ -66534,7 +66553,7 @@ ${DracoWorker.toString()}
66534
66553
  return this.playcanvasApp.root;
66535
66554
  }
66536
66555
  getBoundingBoxForElement(element) {
66537
- if (!(element instanceof TransformableElement)) {
66556
+ if (!TransformableElement.isTransformableElement(element)) {
66538
66557
  return null;
66539
66558
  }
66540
66559
  const bounds = element.getContentBounds();
@@ -97610,7 +97629,7 @@ void main() {
97610
97629
  this.threeLight.castShadow = this.light.props.castShadows;
97611
97630
  this.threeLight.shadow.mapSize.width = 512;
97612
97631
  this.threeLight.shadow.mapSize.height = 512;
97613
- if (this.threeLight.shadow.camera instanceof PerspectiveCamera) {
97632
+ if (this.threeLight.shadow.camera.isPerspectiveCamera) {
97614
97633
  this.threeLight.shadow.camera.near = 0.5;
97615
97634
  this.threeLight.shadow.camera.far = 500;
97616
97635
  }
@@ -97665,7 +97684,7 @@ void main() {
97665
97684
  this.threeLight.castShadow = castShadows;
97666
97685
  }
97667
97686
  setAngle(angle) {
97668
- if (this.threeLight instanceof SpotLight) {
97687
+ if (this.threeLight.isSpotLight) {
97669
97688
  this.threeLight.angle = MathUtils.degToRad(angle);
97670
97689
  }
97671
97690
  }
@@ -97816,7 +97835,7 @@ void main() {
97816
97835
  this.animLoadingInstanceManager.abortIfLoading();
97817
97836
  if (this.loadedState && !this.registeredParentAttachment) {
97818
97837
  const parent = this.model.parentElement;
97819
- if (parent instanceof Model) {
97838
+ if (parent && Model.isModel(parent)) {
97820
97839
  this.registeredParentAttachment = parent;
97821
97840
  parent.modelGraphics.registerAttachment(this.model);
97822
97841
  }
@@ -97933,7 +97952,7 @@ void main() {
97933
97952
  }
97934
97953
  this.updateMeshCallback();
97935
97954
  const parent = this.model.parentElement;
97936
- if (parent instanceof Model) {
97955
+ if (parent && Model.isModel(parent)) {
97937
97956
  if (!this.latestAnimPromise && !this.animState) {
97938
97957
  this.registeredParentAttachment = parent;
97939
97958
  parent.modelGraphics.registerAttachment(this.model);
@@ -98053,7 +98072,7 @@ void main() {
98053
98072
  triggerSocketedChildrenTransformed() {
98054
98073
  this.socketChildrenByBone.forEach((children) => {
98055
98074
  children.forEach((child) => {
98056
- if (child instanceof TransformableElement) {
98075
+ if (TransformableElement.isTransformableElement(child)) {
98057
98076
  child.didUpdateTransformation();
98058
98077
  }
98059
98078
  });
@@ -98764,7 +98783,7 @@ void main() {
98764
98783
  break;
98765
98784
  }
98766
98785
  const mElement = MElement.getMElementFromObject(obj);
98767
- if (mElement && mElement instanceof TransformableElement && mElement.isClickable()) {
98786
+ if (mElement && TransformableElement.isTransformableElement(mElement) && mElement.isClickable()) {
98768
98787
  const elementRelative = getRelativePositionAndRotationRelativeToObject(
98769
98788
  {
98770
98789
  position: intersection.point,
@@ -99395,7 +99414,7 @@ void main() {
99395
99414
  getBoundingBoxForElement(element) {
99396
99415
  const camera = this.camera;
99397
99416
  const renderer = this.renderer;
99398
- if (!(element instanceof MElement)) {
99417
+ if (!MElement.isMElement(element)) {
99399
99418
  return null;
99400
99419
  }
99401
99420
  const object = element.getContainer();