better fix

This commit is contained in:
Dante Ruiz 2018-07-10 11:05:41 -07:00
parent df4d81277f
commit 1cc95fbf76
2 changed files with 14 additions and 7 deletions

View file

@ -82,19 +82,17 @@ function calcSpawnInfo(hand, landscape) {
} }
function cleanUpOldMaterialEntities() { cleanUpOldMaterialEntities = function() {
var avatarEntityData = MyAvatar.getAvatarEntityData(); var avatarEntityData = MyAvatar.getAvatarEntityData();
for (var entityID in avatarEntityData) { for (var entityID in avatarEntityData) {
var entityName = Entities.getEntityProperties(entityID, ["name"]).name; var entityName = Entities.getEntityProperties(entityID, ["name"]).name;
if (entityName === TABLET_MATERIAL_ENTITY_NAME) { if (entityName === TABLET_MATERIAL_ENTITY_NAME && entityID !== HMD.homeButtonHighlightMaterialID &&
entityID !== HMD.homeButtonUnhighlightMaterialID) {
Entities.deleteEntity(entityID); Entities.deleteEntity(entityID);
} }
} }
} };
cleanUpOldMaterialEntities();
/** /**
* WebTablet * WebTablet

View file

@ -13,7 +13,7 @@
// //
/* global Script, HMD, WebTablet, UIWebTablet, UserActivityLogger, Settings, Entities, Messages, Tablet, Overlays, /* global Script, HMD, WebTablet, UIWebTablet, UserActivityLogger, Settings, Entities, Messages, Tablet, Overlays,
MyAvatar, Menu, AvatarInputs, Vec3 */ MyAvatar, Menu, AvatarInputs, Vec3, cleanUpOldMaterialEntities */
(function() { // BEGIN LOCAL_SCOPE (function() { // BEGIN LOCAL_SCOPE
var tabletRezzed = false; var tabletRezzed = false;
@ -31,6 +31,14 @@
Script.include("../libraries/WebTablet.js"); Script.include("../libraries/WebTablet.js");
function cleanupMaterialEntities() {
if (Window.isPhysicsEnabled()) {
cleanUpOldMaterialEntities();
return;
}
Script.setTimeout(cleanupMaterialEntities, 100);
}
function checkTablet() { function checkTablet() {
if (gTablet === null) { if (gTablet === null) {
gTablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); gTablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
@ -327,4 +335,5 @@
HMD.homeButtonHighlightMaterialID = null; HMD.homeButtonHighlightMaterialID = null;
HMD.homeButtonUnhighlightMaterialID = null; HMD.homeButtonUnhighlightMaterialID = null;
}); });
Script.setTimeout(cleanupMaterialEntities, 100);
}()); // END LOCAL_SCOPE }()); // END LOCAL_SCOPE