@mml-io/mml-web-client 0.19.5 → 0.19.7
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 +76 -69
- package/build/index.js.map +2 -2
- package/package.json +5 -5
package/build/index.js
CHANGED
|
@@ -909,7 +909,8 @@
|
|
|
909
909
|
handleEvent(element, event) {
|
|
910
910
|
const nodeId = this.elementToId.get(element);
|
|
911
911
|
if (nodeId === void 0 || nodeId === null) {
|
|
912
|
-
|
|
912
|
+
console.error("Element not found for event", { nodeId, element, event });
|
|
913
|
+
return;
|
|
913
914
|
}
|
|
914
915
|
const detailWithoutElement = {
|
|
915
916
|
...event.detail
|
|
@@ -1330,10 +1331,11 @@
|
|
|
1330
1331
|
}
|
|
1331
1332
|
createWebsocketWithTimeout(timeout) {
|
|
1332
1333
|
return new Promise((resolve, reject) => {
|
|
1334
|
+
const websocket = this.websocketFactory(this.url);
|
|
1333
1335
|
const timeoutId = setTimeout(() => {
|
|
1334
1336
|
reject(new Error("websocket connection timed out"));
|
|
1337
|
+
websocket.close();
|
|
1335
1338
|
}, timeout);
|
|
1336
|
-
const websocket = this.websocketFactory(this.url);
|
|
1337
1339
|
websocket.binaryType = "arraybuffer";
|
|
1338
1340
|
websocket.addEventListener("open", () => {
|
|
1339
1341
|
clearTimeout(timeoutId);
|
|
@@ -1722,9 +1724,53 @@
|
|
|
1722
1724
|
return false;
|
|
1723
1725
|
}
|
|
1724
1726
|
};
|
|
1727
|
+
function parseRGB(value) {
|
|
1728
|
+
value = value.trim();
|
|
1729
|
+
const validStart = value.startsWith("rgb(") || value.startsWith("rgba(");
|
|
1730
|
+
const validEnd = value.endsWith(")");
|
|
1731
|
+
if (!validStart || !validEnd) return null;
|
|
1732
|
+
const content = value.substring(value.indexOf("(") + 1, value.length - 1).split(",");
|
|
1733
|
+
if (content.length < 3 || content.length > 4) return null;
|
|
1734
|
+
if (value.startsWith("rgb(") && content.length !== 3) return null;
|
|
1735
|
+
if (value.startsWith("rgba(") && content.length !== 4) return null;
|
|
1736
|
+
const numbers = content.map((n) => parseFloat(n.trim()));
|
|
1737
|
+
if (numbers.some((n) => isNaN(n))) return null;
|
|
1738
|
+
return {
|
|
1739
|
+
r: Math.min(255, Math.max(0, numbers[0])) / 255,
|
|
1740
|
+
g: Math.min(255, Math.max(0, numbers[1])) / 255,
|
|
1741
|
+
b: Math.min(255, Math.max(0, numbers[2])) / 255,
|
|
1742
|
+
a: numbers.length === 4 ? Math.min(1, Math.max(0, numbers[3])) : void 0
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
function parseHSL(value) {
|
|
1746
|
+
value = value.trim();
|
|
1747
|
+
const validStart = value.startsWith("hsl(") || value.startsWith("hsla(");
|
|
1748
|
+
const validEnd = value.endsWith(")");
|
|
1749
|
+
if (!validStart || !validEnd) return null;
|
|
1750
|
+
const content = value.substring(value.indexOf("(") + 1, value.length - 1).split(",");
|
|
1751
|
+
if (content.length < 3 || content.length > 4) return null;
|
|
1752
|
+
if (value.startsWith("hsl(") && content.length !== 3) return null;
|
|
1753
|
+
if (value.startsWith("hsla(") && content.length !== 4) return null;
|
|
1754
|
+
const numbers = content.map((n) => parseFloat(n.trim()));
|
|
1755
|
+
if (numbers.some((n) => isNaN(n))) return null;
|
|
1756
|
+
let [h, s, l] = numbers;
|
|
1757
|
+
h = h / 360;
|
|
1758
|
+
h = h === 0 ? 1e-4 : h === 1 ? 0.9999 : h;
|
|
1759
|
+
s = s / 100;
|
|
1760
|
+
s = s === 0 ? 1e-4 : s === 1 ? 0.9999 : s;
|
|
1761
|
+
l = l / 100;
|
|
1762
|
+
l = l === 0 ? 1e-4 : l === 1 ? 0.9999 : l;
|
|
1763
|
+
const rgb = hslToRGB(h, s, l);
|
|
1764
|
+
return {
|
|
1765
|
+
r: rgb.r,
|
|
1766
|
+
g: rgb.g,
|
|
1767
|
+
b: rgb.b,
|
|
1768
|
+
a: numbers.length === 4 ? Math.min(1, Math.max(0, numbers[3])) : void 0
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1725
1771
|
function parseColorAttribute(value, defaultValue) {
|
|
1726
1772
|
return parseAttribute(value, defaultValue, (value2) => {
|
|
1727
|
-
const colorNameValues = colors[value2];
|
|
1773
|
+
const colorNameValues = colors[value2.trim()];
|
|
1728
1774
|
if (colorNameValues) {
|
|
1729
1775
|
return {
|
|
1730
1776
|
r: colorNameValues[0],
|
|
@@ -1753,75 +1799,16 @@
|
|
|
1753
1799
|
}
|
|
1754
1800
|
}
|
|
1755
1801
|
if (value2.indexOf("rgb(") === 0) {
|
|
1756
|
-
|
|
1757
|
-
if (rgb) {
|
|
1758
|
-
return {
|
|
1759
|
-
r: parseInt(rgb[1], 10) / 255,
|
|
1760
|
-
g: parseInt(rgb[2], 10) / 255,
|
|
1761
|
-
b: parseInt(rgb[3], 10) / 255
|
|
1762
|
-
};
|
|
1763
|
-
}
|
|
1802
|
+
return parseRGB(value2);
|
|
1764
1803
|
}
|
|
1765
1804
|
if (value2.indexOf("rgba(") === 0) {
|
|
1766
|
-
|
|
1767
|
-
if (rgba) {
|
|
1768
|
-
return {
|
|
1769
|
-
r: parseInt(rgba[1], 10) / 255,
|
|
1770
|
-
g: parseInt(rgba[2], 10) / 255,
|
|
1771
|
-
b: parseInt(rgba[3], 10) / 255,
|
|
1772
|
-
a: parseFloat(rgba[4])
|
|
1773
|
-
};
|
|
1774
|
-
}
|
|
1805
|
+
return parseRGB(value2);
|
|
1775
1806
|
}
|
|
1776
1807
|
if (value2.indexOf("hsl(") === 0) {
|
|
1777
|
-
|
|
1778
|
-
if (hsl) {
|
|
1779
|
-
let h = parseFloat(hsl[1]) / 360;
|
|
1780
|
-
if (h === 0) {
|
|
1781
|
-
h = 1e-4;
|
|
1782
|
-
} else if (h === 1) {
|
|
1783
|
-
h = 0.9999;
|
|
1784
|
-
}
|
|
1785
|
-
let s = parseFloat(hsl[2]) / 100;
|
|
1786
|
-
if (s === 0) {
|
|
1787
|
-
s = 1e-4;
|
|
1788
|
-
} else if (s === 1) {
|
|
1789
|
-
s = 0.9999;
|
|
1790
|
-
}
|
|
1791
|
-
let l = parseFloat(hsl[3]) / 100;
|
|
1792
|
-
if (l === 0) {
|
|
1793
|
-
l = 1e-4;
|
|
1794
|
-
} else if (l === 1) {
|
|
1795
|
-
l = 0.9999;
|
|
1796
|
-
}
|
|
1797
|
-
return hslToRGB(h, s, l);
|
|
1798
|
-
}
|
|
1808
|
+
return parseHSL(value2);
|
|
1799
1809
|
}
|
|
1800
1810
|
if (value2.indexOf("hsla(") === 0) {
|
|
1801
|
-
|
|
1802
|
-
value2
|
|
1803
|
-
);
|
|
1804
|
-
if (hsla) {
|
|
1805
|
-
let h = parseFloat(hsla[1]) / 360;
|
|
1806
|
-
if (h === 0) {
|
|
1807
|
-
h = 1e-4;
|
|
1808
|
-
} else if (h === 1) {
|
|
1809
|
-
h = 0.9999;
|
|
1810
|
-
}
|
|
1811
|
-
let s = parseFloat(hsla[2]) / 100;
|
|
1812
|
-
if (s === 0) {
|
|
1813
|
-
s = 1e-4;
|
|
1814
|
-
} else if (s === 1) {
|
|
1815
|
-
s = 0.9999;
|
|
1816
|
-
}
|
|
1817
|
-
let l = parseFloat(hsla[3]) / 100;
|
|
1818
|
-
if (l === 0) {
|
|
1819
|
-
l = 1e-4;
|
|
1820
|
-
} else if (l === 1) {
|
|
1821
|
-
l = 0.9999;
|
|
1822
|
-
}
|
|
1823
|
-
return hslToRGB(h, s, l);
|
|
1824
|
-
}
|
|
1811
|
+
return parseHSL(value2);
|
|
1825
1812
|
}
|
|
1826
1813
|
return null;
|
|
1827
1814
|
});
|
|
@@ -5431,6 +5418,7 @@
|
|
|
5431
5418
|
var _Frame = class _Frame2 extends TransformableElement {
|
|
5432
5419
|
constructor() {
|
|
5433
5420
|
super();
|
|
5421
|
+
this.hasInitialized = false;
|
|
5434
5422
|
this.frameContentsInstance = null;
|
|
5435
5423
|
this.isActivelyLoaded = false;
|
|
5436
5424
|
this.timer = null;
|
|
@@ -5469,6 +5457,9 @@
|
|
|
5469
5457
|
}
|
|
5470
5458
|
}
|
|
5471
5459
|
shouldBeLoaded() {
|
|
5460
|
+
if (!this.hasInitialized) {
|
|
5461
|
+
return false;
|
|
5462
|
+
}
|
|
5472
5463
|
if (!this.isConnected) {
|
|
5473
5464
|
return false;
|
|
5474
5465
|
}
|
|
@@ -5580,8 +5571,6 @@
|
|
|
5580
5571
|
return;
|
|
5581
5572
|
}
|
|
5582
5573
|
const graphicsAdapter = this.getScene().getGraphicsAdapter();
|
|
5583
|
-
this.startEmitting();
|
|
5584
|
-
this.syncLoadState();
|
|
5585
5574
|
this.frameGraphics = graphicsAdapter.getGraphicsAdapterFactory().MMLFrameGraphicsInterface(this);
|
|
5586
5575
|
for (const name of _Frame2.observedAttributes) {
|
|
5587
5576
|
const value = this.getAttribute(name);
|
|
@@ -5589,6 +5578,9 @@
|
|
|
5589
5578
|
this.attributeChangedCallback(name, null, value);
|
|
5590
5579
|
}
|
|
5591
5580
|
}
|
|
5581
|
+
this.hasInitialized = true;
|
|
5582
|
+
this.startEmitting();
|
|
5583
|
+
this.syncLoadState();
|
|
5592
5584
|
this.applyBounds();
|
|
5593
5585
|
}
|
|
5594
5586
|
disconnectedCallback() {
|
|
@@ -97901,6 +97893,22 @@ void main() {
|
|
|
97901
97893
|
});
|
|
97902
97894
|
}
|
|
97903
97895
|
setAnimEnabled() {
|
|
97896
|
+
if (this.model.props.animEnabled) {
|
|
97897
|
+
if (this.animState && !this.animState.appliedAnimation) {
|
|
97898
|
+
for (const [attachment] of this.attachments) {
|
|
97899
|
+
this.registerAttachment(attachment);
|
|
97900
|
+
}
|
|
97901
|
+
this.playAnimation(this.animState.currentAnimationClip);
|
|
97902
|
+
}
|
|
97903
|
+
} else if (!this.model.props.animEnabled) {
|
|
97904
|
+
for (const [attachment, animState] of this.attachments) {
|
|
97905
|
+
if (animState) {
|
|
97906
|
+
animState.animationMixer.stopAllAction();
|
|
97907
|
+
}
|
|
97908
|
+
this.attachments.set(attachment, null);
|
|
97909
|
+
this.model.getContainer().add(attachment.getContainer());
|
|
97910
|
+
}
|
|
97911
|
+
}
|
|
97904
97912
|
}
|
|
97905
97913
|
setAnimLoop() {
|
|
97906
97914
|
}
|
|
@@ -97995,7 +98003,6 @@ void main() {
|
|
|
97995
98003
|
if (this.animState) {
|
|
97996
98004
|
this.playAnimation(this.animState.currentAnimationClip);
|
|
97997
98005
|
}
|
|
97998
|
-
console.log("Loaded model", this.loadedState);
|
|
97999
98006
|
this.srcLoadingInstanceManager.finish();
|
|
98000
98007
|
this.updateDebugVisualisation();
|
|
98001
98008
|
}).catch((err2) => {
|