From 74ef82f800b3fe3b409e6f8c327f058c25c21312 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Wed, 6 Jul 2016 16:15:02 -0700 Subject: [PATCH] add 'dynamic' property as a load --- scripts/developer/tests/loadedMachine.js | 39 +++++++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/scripts/developer/tests/loadedMachine.js b/scripts/developer/tests/loadedMachine.js index c222eb7379..375e3d8004 100644 --- a/scripts/developer/tests/loadedMachine.js +++ b/scripts/developer/tests/loadedMachine.js @@ -40,7 +40,9 @@ var numberLeftRunning = scriptData.length - otherScripts.length; print('initially running', otherScripts.length, 'scripts. Leaving', numberLeftRunning, 'and stopping', otherScripts); var typedEntities = {Light: [], ParticleEffect: []}; var interestingTypes = Object.keys(typedEntities); -var loads = ['ignore', 'baseline'].concat(otherScripts, interestingTypes); +var propertiedEntities = {dynamic: []}; +var interestingProperties = Object.keys(propertiedEntities); +var loads = ['ignore', 'baseline'].concat(otherScripts, interestingTypes, interestingProperties); var loadIndex = 0, nLoads = loads.length, load; var results = []; var initialLodIsAutomatic = LODManager.getAutomaticLODAdjust(); @@ -51,21 +53,42 @@ LODManager.setOctreeSizeScale(DEFAULT_LOD); // Fill the typedEnties with the entityIDs that are already visible. It would be nice if this were more efficient. var allEntities = Entities.findEntities(MyAvatar.position, SEARCH_RADIUS); -print('Searching', allEntities.length, 'entities for', interestingTypes); +print('Searching', allEntities.length, 'entities for', interestingTypes, 'and', interestingProperties); +var propertiesToGet = ['type', 'visible'].concat(interestingProperties); allEntities.forEach(function (entityID) { - var properties = Entities.getEntityProperties(entityID, ['type', 'visible']); - if (properties.visible && (interestingTypes.indexOf(properties.type) >= 0)) { - typedEntities[properties.type].push(entityID); + var properties = Entities.getEntityProperties(entityID, propertiesToGet); + if (properties.visible) { + if (interestingTypes.indexOf(properties.type) >= 0) { + typedEntities[properties.type].push(entityID); + } else { + interestingProperties.forEach(function (property) { + if (entityID && properties[property]) { + propertiedEntities[property].push(entityID); + entityID = false; // Put in only one bin + } + }); + } } }); +allEntities = undefined; // free them interestingTypes.forEach(function (type) { print('There are', typedEntities[type].length, type, 'entities.'); }); +interestingProperties.forEach(function (property) { + print('There are', propertiedEntities[property].length, property, 'entities.'); +}); function toggleVisibility(type, on) { typedEntities[type].forEach(function (entityID) { Entities.editEntity(entityID, {visible: on}); }); } +function toggleProperty(property, on) { + propertiedEntities[property].forEach(function (entityID) { + var properties = {}; + properties[property] = on; + Entities.editEntity(entityID, properties); + }); +} function restoreOneTest(load) { print('restore', load); switch (load) { @@ -76,6 +99,9 @@ function restoreOneTest(load) { case 'ParticleEffect': toggleVisibility(load, true); break; + case 'dynamic': + toggleProperty(load, 1); + break; default: Script.load(load); } @@ -90,6 +116,9 @@ function undoOneTest(load) { case 'ParticleEffect': toggleVisibility(load, false); break; + case 'dynamic': + toggleProperty(load, 0); + break; default: ScriptDiscoveryService.stopScript(load); }