|
1663 | 1663 |
|
1664 | 1664 | if (rtcWs) { |
1665 | 1665 | const index = _getChildNodeIndex(xrIframe); |
1666 | | - rtcWs.send(JSON.stringify({ |
| 1666 | + const m = { |
1667 | 1667 | method: 'editState', |
1668 | 1668 | spec: { |
1669 | 1669 | keyPath: [0], |
1670 | 1670 | method: 'removeChild', |
1671 | | - key: index, |
| 1671 | + key: landState ? ('#' + xrIframe.id) : index, |
1672 | 1672 | }, |
1673 | | - })); |
| 1673 | + }; |
| 1674 | + if (landState) { |
| 1675 | + for (let i = 0; i < peerConnections.length; i++) { |
| 1676 | + const peerConnection = peerConnections[i]; |
| 1677 | + peerConnection.sendChannel && peerConnection.sendChannel.send(JSON.stringify(m)); |
| 1678 | + } |
| 1679 | + } else { |
| 1680 | + rtcWs.send(JSON.stringify(m)); |
| 1681 | + } |
1674 | 1682 | } |
1675 | 1683 |
|
1676 | 1684 | root.removeChild(xrIframe); |
|
4330 | 4338 | const xrIframe = document.createElement('xr-iframe'); |
4331 | 4339 | xrIframe.src = href; |
4332 | 4340 | xrIframe.name = name; |
| 4341 | + if (landState) { |
| 4342 | + xrIframe.id = `${connectionId}-${_randomString()}`; |
| 4343 | + } |
4333 | 4344 | root.appendChild(xrIframe); |
4334 | 4345 | root.update(); // force mutation observer to run |
4335 | 4346 |
|
4336 | 4347 | currentMoveMeshes[controllerIndex] = xrIframe.moveMesh; |
4337 | 4348 |
|
4338 | 4349 | if (rtcWs) { |
4339 | | - rtcWs.send(JSON.stringify({ |
| 4350 | + const m = { |
4340 | 4351 | method: 'editState', |
4341 | 4352 | spec: { |
4342 | 4353 | keyPath: [0], |
4343 | 4354 | method: 'appendChild', |
4344 | 4355 | value: xrIframe.outerHTML, |
4345 | 4356 | }, |
4346 | | - })); |
| 4357 | + }; |
| 4358 | + if (landState) { |
| 4359 | + for (let i = 0; i < peerConnections.length; i++) { |
| 4360 | + const peerConnection = peerConnections[i]; |
| 4361 | + peerConnection.sendChannel && peerConnection.sendChannel.send(JSON.stringify(m)); |
| 4362 | + } |
| 4363 | + } else { |
| 4364 | + rtcWs.send(JSON.stringify(m)); |
| 4365 | + } |
4347 | 4366 | } |
4348 | 4367 | /* } else if (id && (match = id.match(/^playlist:(.+)$/))) { |
4349 | 4368 | console.log('click playlist', match[1]); // XXX */ |
|
5762 | 5781 | moveMesh.xrIframe.orientation = localQuaternion.toArray(); |
5763 | 5782 |
|
5764 | 5783 | if (rtcWs) { |
5765 | | - const index = _getChildNodeIndex(moveMesh.xrIframe); |
5766 | | - rtcWs.send(JSON.stringify({ |
| 5784 | + const {xrIframe} = moveMesh; |
| 5785 | + const index = _getChildNodeIndex(xrIframe); |
| 5786 | + const m = { |
5767 | 5787 | method: 'editState', |
5768 | 5788 | spec: { |
5769 | | - keyPath: [0, index], |
| 5789 | + keyPath: landState ? [0, '#' + xrIframe.id] : [0, index], |
5770 | 5790 | method: 'setAttributes', |
5771 | 5791 | values: [ |
5772 | 5792 | { |
|
5779 | 5799 | }, |
5780 | 5800 | ], |
5781 | 5801 | }, |
5782 | | - })); |
| 5802 | + }; |
| 5803 | + if (landState) { |
| 5804 | + for (let i = 0; i < peerConnections.length; i++) { |
| 5805 | + const peerConnection = peerConnections[i]; |
| 5806 | + peerConnection.sendChannel && peerConnection.sendChannel.send(JSON.stringify(m)); |
| 5807 | + } |
| 5808 | + } else { |
| 5809 | + rtcWs.send(JSON.stringify(m)); |
| 5810 | + } |
5783 | 5811 | } |
5784 | 5812 | } |
5785 | 5813 | } |
|
6227 | 6255 |
|
6228 | 6256 | if (rtcWs) { |
6229 | 6257 | const index = _getChildNodeIndex(xrIframe); |
6230 | | - rtcWs.send(JSON.stringify({ |
| 6258 | + const m = { |
6231 | 6259 | method: 'editState', |
6232 | 6260 | spec: { |
6233 | 6261 | keyPath: [0], |
6234 | 6262 | method: 'removeChild', |
6235 | | - key: index, |
| 6263 | + key: landState ? ('#' + xrIframe.id) : index, |
6236 | 6264 | }, |
6237 | | - })); |
| 6265 | + }; |
| 6266 | + if (landState) { |
| 6267 | + for (let i = 0; i < peerConnections.length; i++) { |
| 6268 | + const peerConnection = peerConnections[i]; |
| 6269 | + peerConnection.sendChannel && peerConnection.sendChannel.send(JSON.stringify(m)); |
| 6270 | + } |
| 6271 | + } else { |
| 6272 | + rtcWs.send(JSON.stringify(m)); |
| 6273 | + } |
6238 | 6274 | } |
6239 | 6275 |
|
6240 | 6276 | root.removeChild(xrIframe); |
|
0 commit comments