Skip to content

Commit ac471b2

Browse files
author
Avaer Kazmer
committed
Bugfix setAttribute data transfer in land assets case
1 parent 7ec3045 commit ac471b2

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

app.html

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,12 @@
542542
case 'setAttributes': {
543543
for (let i = 0; i < values.length; i++) {
544544
const {key, value} = values[i];
545-
el.setAttribute(key, value);
545+
(el.setAttributeRaw || el.setAttribute).call(el, key, value);
546546
}
547547
break;
548548
}
549549
case 'setAttribute': {
550-
el.setAttribute(key, value);
550+
(el.setAttributeRaw || el.setAttribute).call(el, key, value);
551551
break;
552552
}
553553
case 'removeAttribute': {
@@ -3874,6 +3874,35 @@
38743874
attributeFilter: ['position', 'orientation', 'scale', 'data'],
38753875
attributes: true,
38763876
});
3877+
3878+
assetXrIframe.setAttributeRaw = assetXrIframe.setAttribute;
3879+
assetXrIframe.setAttribute = (name, value) => {
3880+
assetXrIframe.setAttributeRaw(name, value);
3881+
3882+
if (rtcWs) {
3883+
rtcWs.send(JSON.stringify({
3884+
method: 'editState',
3885+
spec: {
3886+
keyPath: [0, '#' + assetXrIframe.id],
3887+
method: 'setAttributes',
3888+
values: [
3889+
{
3890+
key: 'position',
3891+
value: assetXrIframe.getAttribute('position'),
3892+
},
3893+
{
3894+
key: 'orientation',
3895+
value: assetXrIframe.getAttribute('orientation'),
3896+
},
3897+
{
3898+
key: 'data',
3899+
value: assetXrIframe.getAttribute('data'),
3900+
},
3901+
],
3902+
},
3903+
}));
3904+
}
3905+
};
38773906
}
38783907
})).then(() => {});
38793908
await _loadAssetMoveMeshes();
@@ -4370,12 +4399,12 @@
43704399
const idAttr = stateXrIframe.attrs.find(attr => attr.name === 'id');
43714400
if (idAttr) {
43724401
const id = idAttr.value;
4373-
const xrIframe = assetXrIframes.find(xrIframe => xrIframe.id === id);
4374-
if (xrIframe) {
4402+
const assetXrIframe = assetXrIframes.find(xrIframe => xrIframe.id === id);
4403+
if (assetXrIframe) {
43754404
for (let j = 0; j < stateXrIframe.attrs.length; j++) {
43764405
const attr = stateXrIframe.attrs[j];
43774406
const {name, value} = attr;
4378-
xrIframe.setAttribute(name, value);
4407+
assetXrIframe.setAttributeRaw(name, value);
43794408
}
43804409
}
43814410
}
@@ -5870,34 +5899,6 @@
58705899
}
58715900
}
58725901
}
5873-
5874-
if (rtcWs && landState && landState.loaded) {
5875-
for (let i = 0; i < assetMeshes.length; i++) {
5876-
const moveMesh = assetMeshes[i];
5877-
const {xrIframe} = moveMesh;
5878-
rtcWs.send(JSON.stringify({
5879-
method: 'editState',
5880-
spec: {
5881-
keyPath: [0, '#' + xrIframe.id],
5882-
method: 'setAttributes',
5883-
values: [
5884-
{
5885-
key: 'position',
5886-
value: xrIframe.getAttribute('position'),
5887-
},
5888-
{
5889-
key: 'orientation',
5890-
value: xrIframe.getAttribute('orientation'),
5891-
},
5892-
{
5893-
key: 'data',
5894-
value: xrIframe.getAttribute('data'),
5895-
},
5896-
],
5897-
},
5898-
}));
5899-
}
5900-
}
59015902
};
59025903
_updateCurrentMoveMeshes();
59035904

0 commit comments

Comments
 (0)