Skip to content

Commit

Permalink
fix(build3d): fix build3d auto-play scene, add green nav bar
Browse files Browse the repository at this point in the history
  • Loading branch information
mwfarb committed May 21, 2024
1 parent 27aa4c0 commit 7aeeeca
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/systems/build3d/build3d-mqtt-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function extractDataFullDOM(mutation) {
case 'text':
case 'thickline':
case 'threejs-scene':
case 'urdf-model':
data.object_type = attr.name;
break;
default:
Expand Down Expand Up @@ -107,6 +108,7 @@ function extractDataUpdates(mutation, attribute, changes) {
case 'text':
case 'thickline':
case 'threejs-scene':
case 'urdf-model':
data.object_type = mutation.attributeName;
break;
default:
Expand Down Expand Up @@ -203,6 +205,7 @@ AFRAME.registerComponent('build3d-mqtt-object', {
return; // no need to handle on/off mutations to our own component
}
if (mutation.target.id) {
// TODO (mwfarb): make name change occur only on focus loss, otherwise is too frequent
const attribute = mutation.target.getAttribute(mutation.attributeName);
// when 'id' changes, we have a new object, maybe a name change
const msg = {
Expand Down
4 changes: 2 additions & 2 deletions src/systems/build3d/build3d-mqtt-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @date 2020
*/

/* global AFRAME */
/* global AFRAME, ARENAAUTH */

/**
* Create an observer to listen for changes made locally in the A-Frame Inspector and publish them to MQTT.
Expand Down Expand Up @@ -181,7 +181,7 @@ AFRAME.registerComponent('build3d-mqtt-scene', {
inspectorMqttTitle.style.opacity = '.75';
inspectorMqttTitle.style.width = '100%';
inspectorMqttTitle.style.paddingLeft = '10px';
inspectorMqttTitle.textContent = "ARENA's Build3D MQTT Publish Log";
inspectorMqttTitle.textContent = `ARENA's Build3D MQTT Publish Log (user: ${ARENAAUTH.user_username})`;
inspectorMqttLogWrap.appendChild(inspectorMqttTitle);

// log
Expand Down
26 changes: 15 additions & 11 deletions src/systems/core/arena.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,29 +436,33 @@ AFRAME.registerSystem('arena-scene', {
sceneEl.components.inspector.openInspector(el || null);
console.log('build3d', 'A-Frame Inspector loaded');

function updateInspectorPanel(perm, jqSelect) {
// auto-start build3d scene when pause occurs, activate play
document.querySelector('a-scene').addEventListener('pause', (evt) => {
if (evt.target === sceneEl) {
document.querySelector('a-scene').play();
console.log('build3d', 'scene is playing...');
}
// TODO (mwfarb): would be nice to update play button visually to pause, to reflect current state
});

function updateInspectorPanel(perm, jqSelect, permColor = false) {
$(jqSelect).css('opacity', '.75');
if (permColor) {
$(jqSelect).css('background-color', perm ? 'darkgreen' : 'darkorange');
}
}

setTimeout(() => {
const perm = this.isUserSceneWriter();
updateInspectorPanel(perm, '#inspectorContainer #scenegraph');
updateInspectorPanel(perm, '#inspectorContainer #viewportBar');
updateInspectorPanel(perm, '#inspectorContainer #viewportBar', true);
updateInspectorPanel(perm, '#inspectorContainer #rightPanel');

const scene = document.querySelector('a-scene');
scene.play();
console.log('build3d', 'scene.play()');

// <a id="playPauseScene" class="button fa fa-pause" title="Pause scene"></a>
$('#playPauseScene').triggerHandler('click');
console.log('build3d', 'playPauseScene click');

// use "Back to Scene" to send to real ARENA scene
$('a.toggle-edit').click(() => {
this.removeBuild3d();
});
}, 2000);
}, 500);
},

/**
Expand Down

0 comments on commit 7aeeeca

Please sign in to comment.