@wework/floormap-utils
Advanced tools
Comparing version 0.4.4 to 0.4.5
@@ -246,2 +246,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
} | ||
var maxWidth = 3; | ||
var s = getSize(_shapes[0]); | ||
if ((s.width < maxWidth) || (s.height < maxWidth)) { | ||
maxWidth = s.width - 0.1; | ||
} | ||
objects.push({ | ||
@@ -254,3 +259,3 @@ id: id + '_img', | ||
img: img, | ||
maxWidth: 3 | ||
maxWidth: maxWidth | ||
}, | ||
@@ -419,2 +424,3 @@ interactable: false | ||
case 'RESTROOM': | ||
case 'UNISEX RESTROOM': | ||
img = women; | ||
@@ -489,4 +495,22 @@ break | ||
/** | ||
* Returns { width, height } | ||
*/ | ||
var getSize = function (points) { | ||
var minX = +Infinity; | ||
var minY = +Infinity; | ||
var maxX = -Infinity; | ||
var maxY = -Infinity; | ||
for (var i = 0; i < points.length; i++) { | ||
minX = Math.min(minX, points[i].x); | ||
minY = Math.min(minY, points[i].y); | ||
maxX = Math.max(maxX, points[i].x); | ||
maxY = Math.max(maxY, points[i].y); | ||
} | ||
return { width: (maxX - minX), height: (maxY - minY) } | ||
}; | ||
exports.createRenderObjects = createRenderObjects; | ||
exports.getCenter = getCenter; | ||
exports.getSize = getSize; | ||
exports.stringArrayToPoints = stringArrayToPoints; |
@@ -1,2 +0,2 @@ | ||
Object.defineProperty(exports,"__esModule",{value:!0});var nook="https://cdn.spacemob.co/img/nook@2x.png",meeting="https://cdn.spacemob.co/img/meeting_room@2x.png",gameRoom="https://cdn.spacemob.co/img/gameroom@2x.png",women="https://cdn.spacemob.co/img/wc_f@2x.png",men="https://cdn.spacemob.co/img/wc_m@2x.png",shower="https://cdn.spacemob.co/img/shower@2x.png",itRoom="https://cdn.spacemob.co/img/IT_room@2x.png",printer="https://cdn.spacemob.co/img/printer@2x.png",phoneBooth="https://cdn.spacemob.co/img/phone_booth@2x.png",mechanical="https://cdn.spacemob.co/img/mechanical@2x.png",storage="https://cdn.spacemob.co/img/storage@2x.png",trash="https://cdn.spacemob.co/img/trash@2x.png",pantry="https://cdn.spacemob.co/img/pantry@2x.png",motherRoom="https://cdn.spacemob.co/img/motherroom@2x.png",mail="https://cdn.spacemob.co/img/mail_room@2x.png",serviceLift="https://cdn.spacemob.co/img/servicelift@2x.png",wellness="https://cdn.spacemob.co/img/wellnessroom@2x.png",electrical="https://cdn.spacemob.co/img/electrical@2x.png",fire="https://cdn.spacemob.co/img/fire_extinguisher@2x.png",maintenance="https://cdn.spacemob.co/img/maintenance@2x.png",getCenter=function(e){for(var t=1/0,a=1/0,r=-1/0,c=-1/0,s=0;s<e.length;s++)t=Math.min(t,e[s].x),a=Math.min(a,e[s].y),r=Math.max(r,e[s].x),c=Math.max(c,e[s].y);return{x:(r+t)/2,y:(c+a)/2}},createRenderObjects=function(e){var r=e.id,t=e.shapes,a=e.type,c=e.subType,s=e.programType,o=e.roomNumber,n=e.hasWindow,i=e.locationAngle,p=e.centroid,g=[],m="BACK",b="black",l=1,h=!1,E=getExtrude(s,6),u=getZed(s,6),y=getColor(s),T=getImage(s,c);if("object"===a)switch(c){case"CHAIR":y="rgb(206,206,206)",m="FRONT",u=-(6-(E=1))/2,b="black";break;case"TABLE":case"HOTDESK_TABLE":y="rgb(246,241,241)",m="FRONT",E=.5,u=-1.5,l=.7}else"space"===a||"room"===a||console.warn("invalid type:",a);var x={only:!1,color:b};switch(c){case"HALLWAY":case"ELEV LOBBY":x=null;break;case"PHONE BOOTH":case"PRINTER":b="#474747"}switch(s){case"MEET":switch(b="#474747",h=!0,c){case"NOOK":case"PHONE BOOTH":case"wt":h=!1}break;case"WORK":b="#EEB4B2",h=!0,n&&(y="rgb(228,243,247)");break;case"WASH":case"SERVE":b="#979797";break;case"OPERATE":case"WE":break;case"CIRCULATE":x=null;break;default:s&&console.log("invalid programType:",s)}x&&(x.color=b);var d=t,R={z:u},O=null;if(!d||0===d.length)switch(c){case"CHAIR":d=getChairGeometry(),(R=p).z=u,O={z:i};break;case"TABLE":d=getTableGeometry(),(R=p).z=u,O={z:i};break;case"HOTDESK_TABLE":d=getHotDeskTableGeometry(),(R=p).z=u,O={z:i}}if(d&&0!==d.length){if(d.forEach(function(e,t){var a=r;0!==t&&(a=r+"/"+t),g.push({id:a,type:"MESH",style:{color:y,side:m,outline:x,opacity:l},points:e,interactable:!0,extrude:E,position:R,rotation:O})}),h&&o){var k=getCenter(d[0]);T&&(k.y=k.y-2),g.push({id:o,type:"TEXT",text:o,position:k,scalar:1.7,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(T){var f=getCenter(d[0]);h&&o&&(f.y=f.y+1),g.push({id:r+"_img",type:"SPRITE",position:f,scalar:1,style:{img:T,maxWidth:3},interactable:!1})}return g}console.warn("Invalid shapes",JSON.stringify(e))},getChairGeometry=function(){return[[{x:1,y:1.45},{x:-1,y:1.45},{x:-1,y:-.55},{x:1,y:-.55}]]},getTableGeometry=function(){return[[{x:2,y:2.3},{x:-2,y:2.3},{x:-2,y:.3},{x:2,y:.3}]]},getHotDeskTableGeometry=function(){return[[{x:1.97,y:1.97},{x:-1.97,y:1.97},{x:-1.97,y:-1.97},{x:1.97,y:-1.97}]]},getExtrude=function(e,t){switch(e){case"CIRCULATE":case"WE":return.1;default:return t}},getZed=function(e,t){switch(e){case"WORK":return 0;case"MEET":return-.01;case"WASH":return-.02;case"OPERATE":return-.03;case"WE":return-(t/2+.01);case"CIRCULATE":return-(t/2+.02);default:return 0}},getColor=function(e){switch(e){case"WORK":return"rgb(171,221,231)";case"CIRCULATE":return"rgb(255,247,223)";case"MEET":return"rgb(183,240,217)";case"WE":return"rgb(255,210,106)";case"OPERATE":return"rgb(226,226,226)";case"WASH":return"rgb(195,195,195)";default:return"rgb(253,235,236)"}},stringArrayToPoints=function(e){if(e&&e.constructor===Array){var t=[];return e.forEach(function(e){e&&e.constructor===Array&&3===e.length&&t.push({x:parseFloat(e[0]),y:parseFloat(e[1]),z:parseFloat(e[2])})}),t}},getImage=function(e,t){var a=null;switch(t){case"PHONE BOOTH":a=phoneBooth;break;case"wt":case"NOOK":case"BOOTH":a=nook;break;case"LOUNGE":case"PANTRY":a=pantry;break;case"GAME RM":a=gameRoom;break;case"WOMEN WC":case"W RESTROOM":case"RESTROOM":a=women;break;case"MEN WC":case"MALE WC":case"M RESTROOM":a=men;break;case"ADA WC":a=shower;break;case"IT":a=itRoom;break;case"PRINTER":a=printer;break;case"MECH":a=mechanical;break;case"STOR":case"STORE":a=storage;break;case"TRASH":a=trash;break;case"MOTHER RM":a=motherRoom;break;case"F&B":a=pantry;break;case"MAIL":a=mail;break;case"SHOWER":a=shower;break;case"SERVICE LIFT":a=serviceLift;break;case"WELLNESS RM":a=wellness;break;case"ELEC":a=electrical;break;case"FIRE":a=fire;break;case"MOP":case"JC":a=maintenance}if(!a)switch(e){case"MEET":a=meeting}return a};exports.createRenderObjects=createRenderObjects,exports.getCenter=getCenter,exports.stringArrayToPoints=stringArrayToPoints; | ||
Object.defineProperty(exports,"__esModule",{value:!0});var nook="https://cdn.spacemob.co/img/nook@2x.png",meeting="https://cdn.spacemob.co/img/meeting_room@2x.png",gameRoom="https://cdn.spacemob.co/img/gameroom@2x.png",women="https://cdn.spacemob.co/img/wc_f@2x.png",men="https://cdn.spacemob.co/img/wc_m@2x.png",shower="https://cdn.spacemob.co/img/shower@2x.png",itRoom="https://cdn.spacemob.co/img/IT_room@2x.png",printer="https://cdn.spacemob.co/img/printer@2x.png",phoneBooth="https://cdn.spacemob.co/img/phone_booth@2x.png",mechanical="https://cdn.spacemob.co/img/mechanical@2x.png",storage="https://cdn.spacemob.co/img/storage@2x.png",trash="https://cdn.spacemob.co/img/trash@2x.png",pantry="https://cdn.spacemob.co/img/pantry@2x.png",motherRoom="https://cdn.spacemob.co/img/motherroom@2x.png",mail="https://cdn.spacemob.co/img/mail_room@2x.png",serviceLift="https://cdn.spacemob.co/img/servicelift@2x.png",wellness="https://cdn.spacemob.co/img/wellnessroom@2x.png",electrical="https://cdn.spacemob.co/img/electrical@2x.png",fire="https://cdn.spacemob.co/img/fire_extinguisher@2x.png",maintenance="https://cdn.spacemob.co/img/maintenance@2x.png",getCenter=function(e){for(var t=1/0,a=1/0,r=-1/0,c=-1/0,s=0;s<e.length;s++)t=Math.min(t,e[s].x),a=Math.min(a,e[s].y),r=Math.max(r,e[s].x),c=Math.max(c,e[s].y);return{x:(r+t)/2,y:(c+a)/2}},createRenderObjects=function(e){var r=e.id,t=e.shapes,a=e.type,c=e.subType,s=e.programType,n=e.roomNumber,o=e.hasWindow,i=e.locationAngle,g=e.centroid,p=[],m="BACK",h="black",b=1,l=!1,E=getExtrude(s,6),u=getZed(s,6),x=getColor(s),y=getImage(s,c);if("object"===a)switch(c){case"CHAIR":x="rgb(206,206,206)",m="FRONT",u=-(6-(E=1))/2,h="black";break;case"TABLE":case"HOTDESK_TABLE":x="rgb(246,241,241)",m="FRONT",E=.5,u=-1.5,b=.7}else"space"===a||"room"===a||console.warn("invalid type:",a);var T={only:!1,color:h};switch(c){case"HALLWAY":case"ELEV LOBBY":T=null;break;case"PHONE BOOTH":case"PRINTER":h="#474747"}switch(s){case"MEET":switch(h="#474747",l=!0,c){case"NOOK":case"PHONE BOOTH":case"wt":l=!1}break;case"WORK":h="#EEB4B2",l=!0,o&&(x="rgb(228,243,247)");break;case"WASH":case"SERVE":h="#979797";break;case"OPERATE":case"WE":break;case"CIRCULATE":T=null;break;default:s&&console.log("invalid programType:",s)}T&&(T.color=h);var d=t,R={z:u},O=null;if(!d||0===d.length)switch(c){case"CHAIR":d=getChairGeometry(),(R=g).z=u,O={z:i};break;case"TABLE":d=getTableGeometry(),(R=g).z=u,O={z:i};break;case"HOTDESK_TABLE":d=getHotDeskTableGeometry(),(R=g).z=u,O={z:i}}if(d&&0!==d.length){if(d.forEach(function(e,t){var a=r;0!==t&&(a=r+"/"+t),p.push({id:a,type:"MESH",style:{color:x,side:m,outline:T,opacity:b},points:e,interactable:!0,extrude:E,position:R,rotation:O})}),l&&n){var f=getCenter(d[0]);y&&(f.y=f.y-2),p.push({id:n,type:"TEXT",text:n,position:f,scalar:1.7,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(y){var k=getCenter(d[0]);l&&n&&(k.y=k.y+1);var A=3,M=getSize(d[0]);(M.width<A||M.height<A)&&(A=M.width-.1),p.push({id:r+"_img",type:"SPRITE",position:k,scalar:1,style:{img:y,maxWidth:A},interactable:!1})}return p}console.warn("Invalid shapes",JSON.stringify(e))},getChairGeometry=function(){return[[{x:1,y:1.45},{x:-1,y:1.45},{x:-1,y:-.55},{x:1,y:-.55}]]},getTableGeometry=function(){return[[{x:2,y:2.3},{x:-2,y:2.3},{x:-2,y:.3},{x:2,y:.3}]]},getHotDeskTableGeometry=function(){return[[{x:1.97,y:1.97},{x:-1.97,y:1.97},{x:-1.97,y:-1.97},{x:1.97,y:-1.97}]]},getExtrude=function(e,t){switch(e){case"CIRCULATE":case"WE":return.1;default:return t}},getZed=function(e,t){switch(e){case"WORK":return 0;case"MEET":return-.01;case"WASH":return-.02;case"OPERATE":return-.03;case"WE":return-(t/2+.01);case"CIRCULATE":return-(t/2+.02);default:return 0}},getColor=function(e){switch(e){case"WORK":return"rgb(171,221,231)";case"CIRCULATE":return"rgb(255,247,223)";case"MEET":return"rgb(183,240,217)";case"WE":return"rgb(255,210,106)";case"OPERATE":return"rgb(226,226,226)";case"WASH":return"rgb(195,195,195)";default:return"rgb(253,235,236)"}},stringArrayToPoints=function(e){if(e&&e.constructor===Array){var t=[];return e.forEach(function(e){e&&e.constructor===Array&&3===e.length&&t.push({x:parseFloat(e[0]),y:parseFloat(e[1]),z:parseFloat(e[2])})}),t}},getImage=function(e,t){var a=null;switch(t){case"PHONE BOOTH":a=phoneBooth;break;case"wt":case"NOOK":case"BOOTH":a=nook;break;case"LOUNGE":case"PANTRY":a=pantry;break;case"GAME RM":a=gameRoom;break;case"WOMEN WC":case"W RESTROOM":case"RESTROOM":case"UNISEX RESTROOM":a=women;break;case"MEN WC":case"MALE WC":case"M RESTROOM":a=men;break;case"ADA WC":a=shower;break;case"IT":a=itRoom;break;case"PRINTER":a=printer;break;case"MECH":a=mechanical;break;case"STOR":case"STORE":a=storage;break;case"TRASH":a=trash;break;case"MOTHER RM":a=motherRoom;break;case"F&B":a=pantry;break;case"MAIL":a=mail;break;case"SHOWER":a=shower;break;case"SERVICE LIFT":a=serviceLift;break;case"WELLNESS RM":a=wellness;break;case"ELEC":a=electrical;break;case"FIRE":a=fire;break;case"MOP":case"JC":a=maintenance}if(!a)switch(e){case"MEET":a=meeting}return a},getSize=function(e){for(var t=1/0,a=1/0,r=-1/0,c=-1/0,s=0;s<e.length;s++)t=Math.min(t,e[s].x),a=Math.min(a,e[s].y),r=Math.max(r,e[s].x),c=Math.max(c,e[s].y);return{width:r-t,height:c-a}};exports.createRenderObjects=createRenderObjects,exports.getCenter=getCenter,exports.getSize=getSize,exports.stringArrayToPoints=stringArrayToPoints; | ||
//# sourceMappingURL=floormap-utils.cjs.min.js.map |
@@ -244,2 +244,7 @@ var nook = 'https://cdn.spacemob.co/img/nook@2x.png'; | ||
} | ||
var maxWidth = 3; | ||
var s = getSize(_shapes[0]); | ||
if ((s.width < maxWidth) || (s.height < maxWidth)) { | ||
maxWidth = s.width - 0.1; | ||
} | ||
objects.push({ | ||
@@ -252,3 +257,3 @@ id: id + '_img', | ||
img: img, | ||
maxWidth: 3 | ||
maxWidth: maxWidth | ||
}, | ||
@@ -417,2 +422,3 @@ interactable: false | ||
case 'RESTROOM': | ||
case 'UNISEX RESTROOM': | ||
img = women; | ||
@@ -487,2 +493,19 @@ break | ||
export { createRenderObjects, getCenter, stringArrayToPoints }; | ||
/** | ||
* Returns { width, height } | ||
*/ | ||
var getSize = function (points) { | ||
var minX = +Infinity; | ||
var minY = +Infinity; | ||
var maxX = -Infinity; | ||
var maxY = -Infinity; | ||
for (var i = 0; i < points.length; i++) { | ||
minX = Math.min(minX, points[i].x); | ||
minY = Math.min(minY, points[i].y); | ||
maxX = Math.max(maxX, points[i].x); | ||
maxY = Math.max(maxY, points[i].y); | ||
} | ||
return { width: (maxX - minX), height: (maxY - minY) } | ||
}; | ||
export { createRenderObjects, getCenter, getSize, stringArrayToPoints }; |
@@ -250,2 +250,7 @@ (function (global, factory) { | ||
} | ||
var maxWidth = 3; | ||
var s = getSize(_shapes[0]); | ||
if ((s.width < maxWidth) || (s.height < maxWidth)) { | ||
maxWidth = s.width - 0.1; | ||
} | ||
objects.push({ | ||
@@ -258,3 +263,3 @@ id: id + '_img', | ||
img: img, | ||
maxWidth: 3 | ||
maxWidth: maxWidth | ||
}, | ||
@@ -423,2 +428,3 @@ interactable: false | ||
case 'RESTROOM': | ||
case 'UNISEX RESTROOM': | ||
img = women; | ||
@@ -493,4 +499,22 @@ break | ||
/** | ||
* Returns { width, height } | ||
*/ | ||
var getSize = function (points) { | ||
var minX = +Infinity; | ||
var minY = +Infinity; | ||
var maxX = -Infinity; | ||
var maxY = -Infinity; | ||
for (var i = 0; i < points.length; i++) { | ||
minX = Math.min(minX, points[i].x); | ||
minY = Math.min(minY, points[i].y); | ||
maxX = Math.max(maxX, points[i].x); | ||
maxY = Math.max(maxY, points[i].y); | ||
} | ||
return { width: (maxX - minX), height: (maxY - minY) } | ||
}; | ||
exports.createRenderObjects = createRenderObjects; | ||
exports.getCenter = getCenter; | ||
exports.getSize = getSize; | ||
exports.stringArrayToPoints = stringArrayToPoints; | ||
@@ -497,0 +521,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,c){"object"==typeof exports&&"undefined"!=typeof module?c(exports):"function"==typeof define&&define.amd?define(["exports"],c):c(e.FloormapUtils={})}(this,function(e){var t="https://cdn.spacemob.co/img/shower@2x.png",s="https://cdn.spacemob.co/img/pantry@2x.png",A=function(e){for(var c=1/0,a=1/0,t=-1/0,s=-1/0,r=0;r<e.length;r++)c=Math.min(c,e[r].x),a=Math.min(a,e[r].y),t=Math.max(t,e[r].x),s=Math.max(s,e[r].y);return{x:(t+c)/2,y:(s+a)/2}},M=function(){return[[{x:1,y:1.45},{x:-1,y:1.45},{x:-1,y:-.55},{x:1,y:-.55}]]},W=function(){return[[{x:2,y:2.3},{x:-2,y:2.3},{x:-2,y:.3},{x:2,y:.3}]]},C=function(){return[[{x:1.97,y:1.97},{x:-1.97,y:1.97},{x:-1.97,y:-1.97},{x:1.97,y:-1.97}]]},H=function(e,c){switch(e){case"CIRCULATE":case"WE":return.1;default:return c}},w=function(e,c){switch(e){case"WORK":return 0;case"MEET":return-.01;case"WASH":return-.02;case"OPERATE":return-.03;case"WE":return-(c/2+.01);case"CIRCULATE":return-(c/2+.02);default:return 0}},L=function(e){switch(e){case"WORK":return"rgb(171,221,231)";case"CIRCULATE":return"rgb(255,247,223)";case"MEET":return"rgb(183,240,217)";case"WE":return"rgb(255,210,106)";case"OPERATE":return"rgb(226,226,226)";case"WASH":return"rgb(195,195,195)";default:return"rgb(253,235,236)"}},S=function(e,c){var a=null;switch(c){case"PHONE BOOTH":a="https://cdn.spacemob.co/img/phone_booth@2x.png";break;case"wt":case"NOOK":case"BOOTH":a="https://cdn.spacemob.co/img/nook@2x.png";break;case"LOUNGE":case"PANTRY":a=s;break;case"GAME RM":a="https://cdn.spacemob.co/img/gameroom@2x.png";break;case"WOMEN WC":case"W RESTROOM":case"RESTROOM":a="https://cdn.spacemob.co/img/wc_f@2x.png";break;case"MEN WC":case"MALE WC":case"M RESTROOM":a="https://cdn.spacemob.co/img/wc_m@2x.png";break;case"ADA WC":a=t;break;case"IT":a="https://cdn.spacemob.co/img/IT_room@2x.png";break;case"PRINTER":a="https://cdn.spacemob.co/img/printer@2x.png";break;case"MECH":a="https://cdn.spacemob.co/img/mechanical@2x.png";break;case"STOR":case"STORE":a="https://cdn.spacemob.co/img/storage@2x.png";break;case"TRASH":a="https://cdn.spacemob.co/img/trash@2x.png";break;case"MOTHER RM":a="https://cdn.spacemob.co/img/motherroom@2x.png";break;case"F&B":a=s;break;case"MAIL":a="https://cdn.spacemob.co/img/mail_room@2x.png";break;case"SHOWER":a=t;break;case"SERVICE LIFT":a="https://cdn.spacemob.co/img/servicelift@2x.png";break;case"WELLNESS RM":a="https://cdn.spacemob.co/img/wellnessroom@2x.png";break;case"ELEC":a="https://cdn.spacemob.co/img/electrical@2x.png";break;case"FIRE":a="https://cdn.spacemob.co/img/fire_extinguisher@2x.png";break;case"MOP":case"JC":a="https://cdn.spacemob.co/img/maintenance@2x.png"}if(!a)switch(e){case"MEET":a="https://cdn.spacemob.co/img/meeting_room@2x.png"}return a};e.createRenderObjects=function(e){var t=e.id,c=e.shapes,a=e.type,s=e.subType,r=e.programType,n=e.roomNumber,o=e.hasWindow,i=e.locationAngle,p=e.centroid,b=[],g="BACK",m="black",E=1,u=!1,l=H(r,6),h=w(r,6),d=L(r),x=S(r,s);if("object"===a)switch(s){case"CHAIR":d="rgb(206,206,206)",g="FRONT",h=-(6-(l=1))/2,m="black";break;case"TABLE":case"HOTDESK_TABLE":d="rgb(246,241,241)",g="FRONT",l=.5,h=-1.5,E=.7}else"space"===a||"room"===a||console.warn("invalid type:",a);var T={only:!1,color:m};switch(s){case"HALLWAY":case"ELEV LOBBY":T=null;break;case"PHONE BOOTH":case"PRINTER":m="#474747"}switch(r){case"MEET":switch(m="#474747",u=!0,s){case"NOOK":case"PHONE BOOTH":case"wt":u=!1}break;case"WORK":m="#EEB4B2",u=!0,o&&(d="rgb(228,243,247)");break;case"WASH":case"SERVE":m="#979797";break;case"OPERATE":case"WE":break;case"CIRCULATE":T=null;break;default:r&&console.log("invalid programType:",r)}T&&(T.color=m);var f=c,y={z:h},O=null;if(!f||0===f.length)switch(s){case"CHAIR":f=M(),(y=p).z=h,O={z:i};break;case"TABLE":f=W(),(y=p).z=h,O={z:i};break;case"HOTDESK_TABLE":f=C(),(y=p).z=h,O={z:i}}if(f&&0!==f.length){if(f.forEach(function(e,c){var a=t;0!==c&&(a=t+"/"+c),b.push({id:a,type:"MESH",style:{color:d,side:g,outline:T,opacity:E},points:e,interactable:!0,extrude:l,position:y,rotation:O})}),u&&n){var R=A(f[0]);x&&(R.y=R.y-2),b.push({id:n,type:"TEXT",text:n,position:R,scalar:1.7,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(x){var k=A(f[0]);u&&n&&(k.y=k.y+1),b.push({id:t+"_img",type:"SPRITE",position:k,scalar:1,style:{img:x,maxWidth:3},interactable:!1})}return b}console.warn("Invalid shapes",JSON.stringify(e))},e.getCenter=A,e.stringArrayToPoints=function(e){if(e&&e.constructor===Array){var c=[];return e.forEach(function(e){e&&e.constructor===Array&&3===e.length&&c.push({x:parseFloat(e[0]),y:parseFloat(e[1]),z:parseFloat(e[2])})}),c}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports):"function"==typeof define&&define.amd?define(["exports"],a):a(e.FloormapUtils={})}(this,function(e){var t="https://cdn.spacemob.co/img/shower@2x.png",r="https://cdn.spacemob.co/img/pantry@2x.png",w=function(e){for(var a=1/0,c=1/0,t=-1/0,r=-1/0,s=0;s<e.length;s++)a=Math.min(a,e[s].x),c=Math.min(c,e[s].y),t=Math.max(t,e[s].x),r=Math.max(r,e[s].y);return{x:(t+a)/2,y:(r+c)/2}},S=function(){return[[{x:1,y:1.45},{x:-1,y:1.45},{x:-1,y:-.55},{x:1,y:-.55}]]},W=function(){return[[{x:2,y:2.3},{x:-2,y:2.3},{x:-2,y:.3},{x:2,y:.3}]]},C=function(){return[[{x:1.97,y:1.97},{x:-1.97,y:1.97},{x:-1.97,y:-1.97},{x:1.97,y:-1.97}]]},H=function(e,a){switch(e){case"CIRCULATE":case"WE":return.1;default:return a}},L=function(e,a){switch(e){case"WORK":return 0;case"MEET":return-.01;case"WASH":return-.02;case"OPERATE":return-.03;case"WE":return-(a/2+.01);case"CIRCULATE":return-(a/2+.02);default:return 0}},v=function(e){switch(e){case"WORK":return"rgb(171,221,231)";case"CIRCULATE":return"rgb(255,247,223)";case"MEET":return"rgb(183,240,217)";case"WE":return"rgb(255,210,106)";case"OPERATE":return"rgb(226,226,226)";case"WASH":return"rgb(195,195,195)";default:return"rgb(253,235,236)"}},I=function(e,a){var c=null;switch(a){case"PHONE BOOTH":c="https://cdn.spacemob.co/img/phone_booth@2x.png";break;case"wt":case"NOOK":case"BOOTH":c="https://cdn.spacemob.co/img/nook@2x.png";break;case"LOUNGE":case"PANTRY":c=r;break;case"GAME RM":c="https://cdn.spacemob.co/img/gameroom@2x.png";break;case"WOMEN WC":case"W RESTROOM":case"RESTROOM":case"UNISEX RESTROOM":c="https://cdn.spacemob.co/img/wc_f@2x.png";break;case"MEN WC":case"MALE WC":case"M RESTROOM":c="https://cdn.spacemob.co/img/wc_m@2x.png";break;case"ADA WC":c=t;break;case"IT":c="https://cdn.spacemob.co/img/IT_room@2x.png";break;case"PRINTER":c="https://cdn.spacemob.co/img/printer@2x.png";break;case"MECH":c="https://cdn.spacemob.co/img/mechanical@2x.png";break;case"STOR":case"STORE":c="https://cdn.spacemob.co/img/storage@2x.png";break;case"TRASH":c="https://cdn.spacemob.co/img/trash@2x.png";break;case"MOTHER RM":c="https://cdn.spacemob.co/img/motherroom@2x.png";break;case"F&B":c=r;break;case"MAIL":c="https://cdn.spacemob.co/img/mail_room@2x.png";break;case"SHOWER":c=t;break;case"SERVICE LIFT":c="https://cdn.spacemob.co/img/servicelift@2x.png";break;case"WELLNESS RM":c="https://cdn.spacemob.co/img/wellnessroom@2x.png";break;case"ELEC":c="https://cdn.spacemob.co/img/electrical@2x.png";break;case"FIRE":c="https://cdn.spacemob.co/img/fire_extinguisher@2x.png";break;case"MOP":case"JC":c="https://cdn.spacemob.co/img/maintenance@2x.png"}if(!c)switch(e){case"MEET":c="https://cdn.spacemob.co/img/meeting_room@2x.png"}return c},N=function(e){for(var a=1/0,c=1/0,t=-1/0,r=-1/0,s=0;s<e.length;s++)a=Math.min(a,e[s].x),c=Math.min(c,e[s].y),t=Math.max(t,e[s].x),r=Math.max(r,e[s].y);return{width:t-a,height:r-c}};e.createRenderObjects=function(e){var t=e.id,a=e.shapes,c=e.type,r=e.subType,s=e.programType,n=e.roomNumber,o=e.hasWindow,i=e.locationAngle,p=e.centroid,b=[],g="BACK",m="black",h=1,E=!1,u=H(s,6),l=L(s,6),d=v(s),x=I(s,r);if("object"===c)switch(r){case"CHAIR":d="rgb(206,206,206)",g="FRONT",l=-(6-(u=1))/2,m="black";break;case"TABLE":case"HOTDESK_TABLE":d="rgb(246,241,241)",g="FRONT",u=.5,l=-1.5,h=.7}else"space"===c||"room"===c||console.warn("invalid type:",c);var f={only:!1,color:m};switch(r){case"HALLWAY":case"ELEV LOBBY":f=null;break;case"PHONE BOOTH":case"PRINTER":m="#474747"}switch(s){case"MEET":switch(m="#474747",E=!0,r){case"NOOK":case"PHONE BOOTH":case"wt":E=!1}break;case"WORK":m="#EEB4B2",E=!0,o&&(d="rgb(228,243,247)");break;case"WASH":case"SERVE":m="#979797";break;case"OPERATE":case"WE":break;case"CIRCULATE":f=null;break;default:s&&console.log("invalid programType:",s)}f&&(f.color=m);var y=a,O={z:l},T=null;if(!y||0===y.length)switch(r){case"CHAIR":y=S(),(O=p).z=l,T={z:i};break;case"TABLE":y=W(),(O=p).z=l,T={z:i};break;case"HOTDESK_TABLE":y=C(),(O=p).z=l,T={z:i}}if(y&&0!==y.length){if(y.forEach(function(e,a){var c=t;0!==a&&(c=t+"/"+a),b.push({id:c,type:"MESH",style:{color:d,side:g,outline:f,opacity:h},points:e,interactable:!0,extrude:u,position:O,rotation:T})}),E&&n){var R=w(y[0]);x&&(R.y=R.y-2),b.push({id:n,type:"TEXT",text:n,position:R,scalar:1.7,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(x){var k=w(y[0]);E&&n&&(k.y=k.y+1);var A=3,M=N(y[0]);(M.width<A||M.height<A)&&(A=M.width-.1),b.push({id:t+"_img",type:"SPRITE",position:k,scalar:1,style:{img:x,maxWidth:A},interactable:!1})}return b}console.warn("Invalid shapes",JSON.stringify(e))},e.getCenter=w,e.getSize=N,e.stringArrayToPoints=function(e){if(e&&e.constructor===Array){var a=[];return e.forEach(function(e){e&&e.constructor===Array&&3===e.length&&a.push({x:parseFloat(e[0]),y:parseFloat(e[1]),z:parseFloat(e[2])})}),a}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=floormap-utils.umd.min.js.map |
export { | ||
createRenderObjects, | ||
getCenter, | ||
getSize, | ||
stringArrayToPoints | ||
} from './src/spatial-service.js' |
{ | ||
"name": "@wework/floormap-utils", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"browser": "dist/floormap-utils.min.js", | ||
@@ -5,0 +5,0 @@ "jsnext:main": "dist/floormap-utils.es.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81501
1506