Skip to content

Commit 3540a1a

Browse files
author
Avaer Kazmer
committed
RTC ws sends cleanup
1 parent 3d2d0cc commit 3540a1a

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

app.html

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,16 +1638,14 @@
16381638

16391639
if (rtcWs) {
16401640
const index = _getChildNodeIndex(xrIframe);
1641-
const m = {
1641+
rtcWs.send(JSON.stringify({
16421642
method: 'editState',
16431643
spec: {
16441644
keyPath: [0],
16451645
method: 'removeChild',
16461646
key: index,
16471647
},
1648-
};
1649-
// console.log('send', m);
1650-
rtcWs.send(JSON.stringify(m));
1648+
}));
16511649
}
16521650

16531651
root.removeChild(xrIframe);
@@ -3629,7 +3627,7 @@
36293627
if (!live) return;
36303628
const xrIframes = _getChildXrIframes(xrIframe);
36313629

3632-
const _loadMoveMeshes = () => {
3630+
const _loadAssetMoveMeshes = () => {
36333631
xrIframes.forEach(async extentXrIframe => {
36343632
await new Promise((accept, reject) => {
36353633
if (extentXrIframe.loaded) {
@@ -3640,47 +3638,47 @@
36403638
}
36413639
});
36423640

3643-
const childXrIframes = _getChildXrIframes(extentXrIframe);
3644-
for (let i = 0; i < childXrIframes.length; i++) {
3645-
const childXrIframe = childXrIframes[i];
3641+
const assetXrIframes = _getChildXrIframes(extentXrIframe);
3642+
for (let i = 0; i < assetXrIframes.length; i++) {
3643+
const assetXrIframe = assetXrIframes[i];
36463644
const moveMesh = _makeMoveMesh('volume');
3647-
const {worldOffset} = childXrIframe;
3645+
const {worldOffset} = assetXrIframe;
36483646
moveMesh.position.fromArray(worldOffset.position);
36493647
moveMesh.quaternion.fromArray(worldOffset.orientation);
36503648
moveMesh.scale.fromArray(worldOffset.scale);
36513649
moveMesh.visible = screenMesh.visible;
3652-
moveMesh.xrIframe = childXrIframe;
3650+
moveMesh.xrIframe = assetXrIframe;
36533651
scene.add(moveMesh);
36543652
assetMeshes.push(moveMesh);
3655-
childXrIframe.moveMesh = moveMesh;
3653+
assetXrIframe.moveMesh = moveMesh;
36563654

3657-
const labelMesh = _makeLabelMesh(childXrIframe.name || childXrIframe.src, 'download');
3655+
const labelMesh = _makeLabelMesh(assetXrIframe.name || assetXrIframe.src, 'download');
36583656
labelMesh.visible = screenMesh.visible;
36593657
labelMesh.moveMesh = moveMesh;
3660-
labelMesh.xrIframe = childXrIframe;
3658+
labelMesh.xrIframe = assetXrIframe;
36613659
scene.add(labelMesh);
36623660
assetLabelMeshes.push(labelMesh);
36633661

3664-
new childXrIframe.ownerDocument.defaultView.MutationObserver(mutations => {
3662+
new assetXrIframe.ownerDocument.defaultView.MutationObserver(mutations => {
36653663
for (let i = 0; i < mutations.length; i++) {
36663664
const mutation = mutations[i];
36673665
const {attributeName} = mutation;
36683666
if (attributeName === 'position') {
3669-
moveMesh.position.fromArray(childXrIframe.worldOffset.position);
3667+
moveMesh.position.fromArray(assetXrIframe.worldOffset.position);
36703668
} else if (attributeName === 'orientation') {
3671-
moveMesh.quaternion.fromArray(childXrIframe.worldOffset.orientation);
3669+
moveMesh.quaternion.fromArray(assetXrIframe.worldOffset.orientation);
36723670
} else if (attributeName === 'scale') {
3673-
moveMesh.scale.fromArray(childXrIframe.worldOffset.scale);
3671+
moveMesh.scale.fromArray(assetXrIframe.worldOffset.scale);
36743672
}
36753673
}
3676-
}).observe(childXrIframe, {
3674+
}).observe(assetXrIframe, {
36773675
attributeFilter: ['position', 'orientation', 'scale'],
36783676
attributes: true,
36793677
});
36803678
}
36813679
});
36823680
};
3683-
_loadMoveMeshes();
3681+
_loadAssetMoveMeshes();
36843682

36853683
const _loadInventory = () => {
36863684
fetch(`${LAMBDA_URLS.inventory}?email=${encodeURIComponent(loginToken.email)}&token=${encodeURIComponent(loginToken.token)}`)
@@ -4278,16 +4276,14 @@
42784276
currentMoveMeshes[controllerIndex] = xrIframe.moveMesh;
42794277

42804278
if (rtcWs) {
4281-
const m = {
4279+
rtcWs.send(JSON.stringify({
42824280
method: 'editState',
42834281
spec: {
42844282
keyPath: [0],
42854283
method: 'appendChild',
42864284
value: xrIframe.outerHTML,
42874285
},
4288-
};
4289-
// console.log('send', m);
4290-
rtcWs.send(JSON.stringify(m));
4286+
}));
42914287
}
42924288
/* } else if (id && (match = id.match(/^playlist:(.+)$/))) {
42934289
console.log('click playlist', match[1]); // XXX */
@@ -5704,7 +5700,7 @@
57045700

57055701
if (rtcWs) {
57065702
const index = _getChildNodeIndex(moveMesh.xrIframe);
5707-
const m = {
5703+
rtcWs.send(JSON.stringify({
57085704
method: 'editState',
57095705
spec: {
57105706
keyPath: [0, index],
@@ -5720,9 +5716,7 @@
57205716
},
57215717
],
57225718
},
5723-
};
5724-
// console.log('send', m);
5725-
rtcWs.send(JSON.stringify(m));
5719+
}));
57265720
}
57275721
}
57285722
}
@@ -6142,15 +6136,14 @@
61426136

61436137
if (rtcWs) {
61446138
const index = _getChildNodeIndex(xrIframe);
6145-
const m = {
6139+
rtcWs.send(JSON.stringify({
61466140
method: 'editState',
61476141
spec: {
61486142
keyPath: [0],
61496143
method: 'removeChild',
61506144
key: index,
61516145
},
6152-
};
6153-
rtcWs.send(JSON.stringify(m));
6146+
}));
61546147
}
61556148

61566149
root.removeChild(xrIframe);

0 commit comments

Comments
 (0)