|
1638 | 1638 |
|
1639 | 1639 | if (rtcWs) { |
1640 | 1640 | const index = _getChildNodeIndex(xrIframe); |
1641 | | - const m = { |
| 1641 | + rtcWs.send(JSON.stringify({ |
1642 | 1642 | method: 'editState', |
1643 | 1643 | spec: { |
1644 | 1644 | keyPath: [0], |
1645 | 1645 | method: 'removeChild', |
1646 | 1646 | key: index, |
1647 | 1647 | }, |
1648 | | - }; |
1649 | | - // console.log('send', m); |
1650 | | - rtcWs.send(JSON.stringify(m)); |
| 1648 | + })); |
1651 | 1649 | } |
1652 | 1650 |
|
1653 | 1651 | root.removeChild(xrIframe); |
|
3629 | 3627 | if (!live) return; |
3630 | 3628 | const xrIframes = _getChildXrIframes(xrIframe); |
3631 | 3629 |
|
3632 | | - const _loadMoveMeshes = () => { |
| 3630 | + const _loadAssetMoveMeshes = () => { |
3633 | 3631 | xrIframes.forEach(async extentXrIframe => { |
3634 | 3632 | await new Promise((accept, reject) => { |
3635 | 3633 | if (extentXrIframe.loaded) { |
|
3640 | 3638 | } |
3641 | 3639 | }); |
3642 | 3640 |
|
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]; |
3646 | 3644 | const moveMesh = _makeMoveMesh('volume'); |
3647 | | - const {worldOffset} = childXrIframe; |
| 3645 | + const {worldOffset} = assetXrIframe; |
3648 | 3646 | moveMesh.position.fromArray(worldOffset.position); |
3649 | 3647 | moveMesh.quaternion.fromArray(worldOffset.orientation); |
3650 | 3648 | moveMesh.scale.fromArray(worldOffset.scale); |
3651 | 3649 | moveMesh.visible = screenMesh.visible; |
3652 | | - moveMesh.xrIframe = childXrIframe; |
| 3650 | + moveMesh.xrIframe = assetXrIframe; |
3653 | 3651 | scene.add(moveMesh); |
3654 | 3652 | assetMeshes.push(moveMesh); |
3655 | | - childXrIframe.moveMesh = moveMesh; |
| 3653 | + assetXrIframe.moveMesh = moveMesh; |
3656 | 3654 |
|
3657 | | - const labelMesh = _makeLabelMesh(childXrIframe.name || childXrIframe.src, 'download'); |
| 3655 | + const labelMesh = _makeLabelMesh(assetXrIframe.name || assetXrIframe.src, 'download'); |
3658 | 3656 | labelMesh.visible = screenMesh.visible; |
3659 | 3657 | labelMesh.moveMesh = moveMesh; |
3660 | | - labelMesh.xrIframe = childXrIframe; |
| 3658 | + labelMesh.xrIframe = assetXrIframe; |
3661 | 3659 | scene.add(labelMesh); |
3662 | 3660 | assetLabelMeshes.push(labelMesh); |
3663 | 3661 |
|
3664 | | - new childXrIframe.ownerDocument.defaultView.MutationObserver(mutations => { |
| 3662 | + new assetXrIframe.ownerDocument.defaultView.MutationObserver(mutations => { |
3665 | 3663 | for (let i = 0; i < mutations.length; i++) { |
3666 | 3664 | const mutation = mutations[i]; |
3667 | 3665 | const {attributeName} = mutation; |
3668 | 3666 | if (attributeName === 'position') { |
3669 | | - moveMesh.position.fromArray(childXrIframe.worldOffset.position); |
| 3667 | + moveMesh.position.fromArray(assetXrIframe.worldOffset.position); |
3670 | 3668 | } else if (attributeName === 'orientation') { |
3671 | | - moveMesh.quaternion.fromArray(childXrIframe.worldOffset.orientation); |
| 3669 | + moveMesh.quaternion.fromArray(assetXrIframe.worldOffset.orientation); |
3672 | 3670 | } else if (attributeName === 'scale') { |
3673 | | - moveMesh.scale.fromArray(childXrIframe.worldOffset.scale); |
| 3671 | + moveMesh.scale.fromArray(assetXrIframe.worldOffset.scale); |
3674 | 3672 | } |
3675 | 3673 | } |
3676 | | - }).observe(childXrIframe, { |
| 3674 | + }).observe(assetXrIframe, { |
3677 | 3675 | attributeFilter: ['position', 'orientation', 'scale'], |
3678 | 3676 | attributes: true, |
3679 | 3677 | }); |
3680 | 3678 | } |
3681 | 3679 | }); |
3682 | 3680 | }; |
3683 | | - _loadMoveMeshes(); |
| 3681 | + _loadAssetMoveMeshes(); |
3684 | 3682 |
|
3685 | 3683 | const _loadInventory = () => { |
3686 | 3684 | fetch(`${LAMBDA_URLS.inventory}?email=${encodeURIComponent(loginToken.email)}&token=${encodeURIComponent(loginToken.token)}`) |
|
4278 | 4276 | currentMoveMeshes[controllerIndex] = xrIframe.moveMesh; |
4279 | 4277 |
|
4280 | 4278 | if (rtcWs) { |
4281 | | - const m = { |
| 4279 | + rtcWs.send(JSON.stringify({ |
4282 | 4280 | method: 'editState', |
4283 | 4281 | spec: { |
4284 | 4282 | keyPath: [0], |
4285 | 4283 | method: 'appendChild', |
4286 | 4284 | value: xrIframe.outerHTML, |
4287 | 4285 | }, |
4288 | | - }; |
4289 | | - // console.log('send', m); |
4290 | | - rtcWs.send(JSON.stringify(m)); |
| 4286 | + })); |
4291 | 4287 | } |
4292 | 4288 | /* } else if (id && (match = id.match(/^playlist:(.+)$/))) { |
4293 | 4289 | console.log('click playlist', match[1]); // XXX */ |
|
5704 | 5700 |
|
5705 | 5701 | if (rtcWs) { |
5706 | 5702 | const index = _getChildNodeIndex(moveMesh.xrIframe); |
5707 | | - const m = { |
| 5703 | + rtcWs.send(JSON.stringify({ |
5708 | 5704 | method: 'editState', |
5709 | 5705 | spec: { |
5710 | 5706 | keyPath: [0, index], |
|
5720 | 5716 | }, |
5721 | 5717 | ], |
5722 | 5718 | }, |
5723 | | - }; |
5724 | | - // console.log('send', m); |
5725 | | - rtcWs.send(JSON.stringify(m)); |
| 5719 | + })); |
5726 | 5720 | } |
5727 | 5721 | } |
5728 | 5722 | } |
|
6142 | 6136 |
|
6143 | 6137 | if (rtcWs) { |
6144 | 6138 | const index = _getChildNodeIndex(xrIframe); |
6145 | | - const m = { |
| 6139 | + rtcWs.send(JSON.stringify({ |
6146 | 6140 | method: 'editState', |
6147 | 6141 | spec: { |
6148 | 6142 | keyPath: [0], |
6149 | 6143 | method: 'removeChild', |
6150 | 6144 | key: index, |
6151 | 6145 | }, |
6152 | | - }; |
6153 | | - rtcWs.send(JSON.stringify(m)); |
| 6146 | + })); |
6154 | 6147 | } |
6155 | 6148 |
|
6156 | 6149 | root.removeChild(xrIframe); |
|
0 commit comments