@wework/floormap-utils
Advanced tools
Comparing version 0.8.0 to 0.8.1
@@ -587,3 +587,4 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
position: o.position, | ||
rotation: o.rotation | ||
rotation: o.rotation, | ||
interactable: o.interactable | ||
}); | ||
@@ -590,0 +591,0 @@ }); |
@@ -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,n=-1/0,c=-1/0,r=0;r<e.length;r++)t=Math.min(t,e[r].x),a=Math.min(a,e[r].y),n=Math.max(n,e[r].x),c=Math.max(c,e[r].y);return{x:(n+t)/2,y:(c+a)/2}},createRenderObjects=function(e){var c=e.id,t=e.shapes,a=e.type,n=e.subType,r=e.programType,s=e.roomNumber,o=e.hasWindow,i=e.locationAngle,g=e.centroid,p=[],l="BACK",m="#474747",h=1,E=!0,d=!1,b=getExtrude(r,6),u=getZed(r,6),T=getColor(r),y=getImage(r,n);if("object"===a)switch(n){case"CHAIR":T="rgb(206,206,206)",l="FRONT",u=-(6-(b=1))/2,m="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":T="rgb(246,241,241)",l="FRONT",b=.5,u=-1.5,h=.7,m="rgb(150,150,150)"}else"space"===a||"room"===a||console.warn("invalid type:",a);var O={only:!1,color:m};switch(n){case"HALLWAY":case"ELEV LOBBY":O=null}switch(r){case"MEET":switch(d=!0,n){case"NOOK":case"PHONE BOOTH":case"wt":d=!1}break;case"WORK":d=!0,o&&(T="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":O=null;break;default:r&&console.log("invalid programType:",r)}O&&(O.color=m);var x=t,R={z:u},f=null,M=null;if(!x||0===x.length)if(g)switch(n){case"CHAIR":x=getChairGeometry(),(R=g).z=u,f={z:i},E=!(M="CHAIRS");break;case"TABLE":x=getTableGeometry(),(R=g).z=u,f={z:i},E=!(M="TABLES");break;case"HOTDESK_TABLE":x=getHotDeskTableGeometry(),(R=g).z=u,f={z:i},E=!(M="HOTDESK_TABLES")}else console.warn("centroid is not available",JSON.stringify(e));if(x&&0!==x.length){if(x.forEach(function(e,t){var a=c;0!==t&&(a=c+"/"+t);var n={id:a,type:"MESH",style:{color:T,side:l,outline:O,opacity:h},points:e,interactable:E,extrude:b,position:R,rotation:f};M&&(n.instancingId=M),p.push(n)}),d&&s){var I=getCenter(x[0]);y&&(I.y=I.y-2),p.push({id:c+"_TEXT",type:"TEXT",text:s,position:I,scalar:1.7,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(y){var S=getCenter(x[0]);g&&((S=g).z=0),d&&s&&(S.y=S.y+1);var A=3,k=getSize(x[0]);A>k.width?A=k.width-.1:A>k.height&&(A=k.height-.1),p.push({id:c+"_SPRITE",type:"SPRITE",position:S,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":case"BOOTHS":a=nook;break;case"LOUNGE":case"HONESTY MKT":case"HONESTY MARKET":case"PANTRY":a=pantry;break;case"GAME RM":a=gameRoom;break;case"WOMEN WC":case"WOMENS WC":case"W RESTROOM":case"RESTROOM":case"UNISEX RESTROOM":case"UNISEX":case"ADA RESTROOM":case"ADA WC":a=women;break;case"MEN WC":case"MENS WC":case"MALE WC":case"M RESTROOM":a=men;break;case"IT":a=itRoom;break;case"PRINTER":case"PRINT":case"PRINTER NOOK":a=printer;break;case"MECH":a=mechanical;break;case"STOR":case"STORE":case"STORAGE":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":case"WELLNESS ROOM":a=wellness;break;case"ELEC":a=electrical;break;case"FIRE":a=fire;break;case"MOP":case"JC":case"JANITOR":a=maintenance;break;case"CONV. BOOTH":a=meeting}if(t.startsWith("IT ")&&(a=itRoom),!a)switch(e){case"MEET":a=meeting}return a},getSize=function(e){for(var t=1/0,a=1/0,n=-1/0,c=-1/0,r=0;r<e.length;r++)t=Math.min(t,e[r].x),a=Math.min(a,e[r].y),n=Math.max(n,e[r].x),c=Math.max(c,e[r].y);return{width:n-t,height:c-a}},applyInstancing=function(n,c){var r=new Map,s=function(){for(var e=0;e<n.length;e++){var t=n[e];if(t.instancingId){var a=r.get(t.instancingId);a||(a=[]),a.push(t),r.set(t.instancingId,a),n.splice(e,1),s()}}};s(),r.forEach(function(e,t,a){toInstancedMesh(e,t,c)})},toInstancedMesh=function(e,t,a){if(0!==e.length){var n=e[0];if(a.createInstancedMesh({id:t,mesh:{points:n.points,extrude:n.extrude}}),e.forEach(function(e){a.addToInstancedMesh({id:e.id,instancingId:t,style:{color:e.style.color},position:e.position,rotation:e.rotation})}),a.drawInstancedMesh({id:t}),n.style.outline&&n.style.outline.color){var c=t+"_OUTLINE";a.createInstancedMesh({id:c,mesh:{style:{outline:{color:n.style.outline.color,only:!0}},points:n.points,extrude:n.extrude}}),e.forEach(function(e){a.addToInstancedMesh({id:e.id+"_outline",instancingId:c,style:{color:e.style.color},position:e.position,rotation:e.rotation})}),a.drawInstancedMesh({id:c})}}};exports.createRenderObjects=createRenderObjects,exports.getCenter=getCenter,exports.getSize=getSize,exports.stringArrayToPoints=stringArrayToPoints,exports.applyInstancing=applyInstancing; | ||
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,n=-1/0,c=-1/0,r=0;r<e.length;r++)t=Math.min(t,e[r].x),a=Math.min(a,e[r].y),n=Math.max(n,e[r].x),c=Math.max(c,e[r].y);return{x:(n+t)/2,y:(c+a)/2}},createRenderObjects=function(e){var c=e.id,t=e.shapes,a=e.type,n=e.subType,r=e.programType,s=e.roomNumber,o=e.hasWindow,i=e.locationAngle,g=e.centroid,p=[],l="BACK",m="#474747",h=1,E=!0,d=!1,b=getExtrude(r,6),u=getZed(r,6),T=getColor(r),y=getImage(r,n);if("object"===a)switch(n){case"CHAIR":T="rgb(206,206,206)",l="FRONT",u=-(6-(b=1))/2,m="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":T="rgb(246,241,241)",l="FRONT",b=.5,u=-1.5,h=.7,m="rgb(150,150,150)"}else"space"===a||"room"===a||console.warn("invalid type:",a);var O={only:!1,color:m};switch(n){case"HALLWAY":case"ELEV LOBBY":O=null}switch(r){case"MEET":switch(d=!0,n){case"NOOK":case"PHONE BOOTH":case"wt":d=!1}break;case"WORK":d=!0,o&&(T="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":O=null;break;default:r&&console.log("invalid programType:",r)}O&&(O.color=m);var x=t,R={z:u},f=null,M=null;if(!x||0===x.length)if(g)switch(n){case"CHAIR":x=getChairGeometry(),(R=g).z=u,f={z:i},E=!(M="CHAIRS");break;case"TABLE":x=getTableGeometry(),(R=g).z=u,f={z:i},E=!(M="TABLES");break;case"HOTDESK_TABLE":x=getHotDeskTableGeometry(),(R=g).z=u,f={z:i},E=!(M="HOTDESK_TABLES")}else console.warn("centroid is not available",JSON.stringify(e));if(x&&0!==x.length){if(x.forEach(function(e,t){var a=c;0!==t&&(a=c+"/"+t);var n={id:a,type:"MESH",style:{color:T,side:l,outline:O,opacity:h},points:e,interactable:E,extrude:b,position:R,rotation:f};M&&(n.instancingId=M),p.push(n)}),d&&s){var I=getCenter(x[0]);y&&(I.y=I.y-2),p.push({id:c+"_TEXT",type:"TEXT",text:s,position:I,scalar:1.7,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(y){var S=getCenter(x[0]);g&&((S=g).z=0),d&&s&&(S.y=S.y+1);var A=3,k=getSize(x[0]);A>k.width?A=k.width-.1:A>k.height&&(A=k.height-.1),p.push({id:c+"_SPRITE",type:"SPRITE",position:S,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":case"BOOTHS":a=nook;break;case"LOUNGE":case"HONESTY MKT":case"HONESTY MARKET":case"PANTRY":a=pantry;break;case"GAME RM":a=gameRoom;break;case"WOMEN WC":case"WOMENS WC":case"W RESTROOM":case"RESTROOM":case"UNISEX RESTROOM":case"UNISEX":case"ADA RESTROOM":case"ADA WC":a=women;break;case"MEN WC":case"MENS WC":case"MALE WC":case"M RESTROOM":a=men;break;case"IT":a=itRoom;break;case"PRINTER":case"PRINT":case"PRINTER NOOK":a=printer;break;case"MECH":a=mechanical;break;case"STOR":case"STORE":case"STORAGE":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":case"WELLNESS ROOM":a=wellness;break;case"ELEC":a=electrical;break;case"FIRE":a=fire;break;case"MOP":case"JC":case"JANITOR":a=maintenance;break;case"CONV. BOOTH":a=meeting}if(t.startsWith("IT ")&&(a=itRoom),!a)switch(e){case"MEET":a=meeting}return a},getSize=function(e){for(var t=1/0,a=1/0,n=-1/0,c=-1/0,r=0;r<e.length;r++)t=Math.min(t,e[r].x),a=Math.min(a,e[r].y),n=Math.max(n,e[r].x),c=Math.max(c,e[r].y);return{width:n-t,height:c-a}},applyInstancing=function(n,c){var r=new Map,s=function(){for(var e=0;e<n.length;e++){var t=n[e];if(t.instancingId){var a=r.get(t.instancingId);a||(a=[]),a.push(t),r.set(t.instancingId,a),n.splice(e,1),s()}}};s(),r.forEach(function(e,t,a){toInstancedMesh(e,t,c)})},toInstancedMesh=function(e,t,a){if(0!==e.length){var n=e[0];if(a.createInstancedMesh({id:t,mesh:{points:n.points,extrude:n.extrude}}),e.forEach(function(e){a.addToInstancedMesh({id:e.id,instancingId:t,style:{color:e.style.color},position:e.position,rotation:e.rotation,interactable:e.interactable})}),a.drawInstancedMesh({id:t}),n.style.outline&&n.style.outline.color){var c=t+"_OUTLINE";a.createInstancedMesh({id:c,mesh:{style:{outline:{color:n.style.outline.color,only:!0}},points:n.points,extrude:n.extrude}}),e.forEach(function(e){a.addToInstancedMesh({id:e.id+"_outline",instancingId:c,style:{color:e.style.color},position:e.position,rotation:e.rotation})}),a.drawInstancedMesh({id:c})}}};exports.createRenderObjects=createRenderObjects,exports.getCenter=getCenter,exports.getSize=getSize,exports.stringArrayToPoints=stringArrayToPoints,exports.applyInstancing=applyInstancing; | ||
//# sourceMappingURL=floormap-utils.cjs.min.js.map |
@@ -585,3 +585,4 @@ var nook = 'https://cdn.spacemob.co/img/nook@2x.png'; | ||
position: o.position, | ||
rotation: o.rotation | ||
rotation: o.rotation, | ||
interactable: o.interactable | ||
}); | ||
@@ -588,0 +589,0 @@ }); |
@@ -591,3 +591,4 @@ (function (global, factory) { | ||
position: o.position, | ||
rotation: o.rotation | ||
rotation: o.rotation, | ||
interactable: o.interactable | ||
}); | ||
@@ -594,0 +595,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.FloormapUtils={})}(this,function(e){var c="https://cdn.spacemob.co/img/meeting_room@2x.png",n="https://cdn.spacemob.co/img/IT_room@2x.png",s="https://cdn.spacemob.co/img/pantry@2x.png",N=function(e){for(var t=1/0,a=1/0,c=-1/0,n=-1/0,s=0;s<e.length;s++)t=Math.min(t,e[s].x),a=Math.min(a,e[s].y),c=Math.max(c,e[s].x),n=Math.max(n,e[s].y);return{x:(c+t)/2,y:(n+a)/2}},W=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}]]},v=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}]]},C=function(e,t){switch(e){case"CIRCULATE":case"WE":return.1;default:return t}},H=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}},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)"}},_=function(e,t){var a=null;switch(t){case"PHONE BOOTH":a="https://cdn.spacemob.co/img/phone_booth@2x.png";break;case"wt":case"NOOK":case"BOOTH":case"BOOTHS":a="https://cdn.spacemob.co/img/nook@2x.png";break;case"LOUNGE":case"HONESTY MKT":case"HONESTY MARKET":case"PANTRY":a=s;break;case"GAME RM":a="https://cdn.spacemob.co/img/gameroom@2x.png";break;case"WOMEN WC":case"WOMENS WC":case"W RESTROOM":case"RESTROOM":case"UNISEX RESTROOM":case"UNISEX":case"ADA RESTROOM":case"ADA WC":a="https://cdn.spacemob.co/img/wc_f@2x.png";break;case"MEN WC":case"MENS WC":case"MALE WC":case"M RESTROOM":a="https://cdn.spacemob.co/img/wc_m@2x.png";break;case"IT":a=n;break;case"PRINTER":case"PRINT":case"PRINTER NOOK":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":case"STORAGE":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="https://cdn.spacemob.co/img/shower@2x.png";break;case"SERVICE LIFT":a="https://cdn.spacemob.co/img/servicelift@2x.png";break;case"WELLNESS RM":case"WELLNESS ROOM":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":case"JANITOR":a="https://cdn.spacemob.co/img/maintenance@2x.png";break;case"CONV. BOOTH":a=c}if(t.startsWith("IT ")&&(a=n),!a)switch(e){case"MEET":a=c}return a},B=function(e){for(var t=1/0,a=1/0,c=-1/0,n=-1/0,s=0;s<e.length;s++)t=Math.min(t,e[s].x),a=Math.min(a,e[s].y),c=Math.max(c,e[s].x),n=Math.max(n,e[s].y);return{width:c-t,height:n-a}},o=function(e,t,a){if(0!==e.length){var c=e[0];if(a.createInstancedMesh({id:t,mesh:{points:c.points,extrude:c.extrude}}),e.forEach(function(e){a.addToInstancedMesh({id:e.id,instancingId:t,style:{color:e.style.color},position:e.position,rotation:e.rotation})}),a.drawInstancedMesh({id:t}),c.style.outline&&c.style.outline.color){var n=t+"_OUTLINE";a.createInstancedMesh({id:n,mesh:{style:{outline:{color:c.style.outline.color,only:!0}},points:c.points,extrude:c.extrude}}),e.forEach(function(e){a.addToInstancedMesh({id:e.id+"_outline",instancingId:n,style:{color:e.style.color},position:e.position,rotation:e.rotation})}),a.drawInstancedMesh({id:n})}}};e.createRenderObjects=function(e){var n=e.id,t=e.shapes,a=e.type,c=e.subType,s=e.programType,r=e.roomNumber,o=e.hasWindow,i=e.locationAngle,p=e.centroid,l=[],h="BACK",g="#474747",d=1,E=!0,u=!1,b=C(s,6),m=H(s,6),T=L(s),O=_(s,c);if("object"===a)switch(c){case"CHAIR":T="rgb(206,206,206)",h="FRONT",m=-(6-(b=1))/2,g="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":T="rgb(246,241,241)",h="FRONT",b=.5,m=-1.5,d=.7,g="rgb(150,150,150)"}else"space"===a||"room"===a||console.warn("invalid type:",a);var f={only:!1,color:g};switch(c){case"HALLWAY":case"ELEV LOBBY":f=null}switch(s){case"MEET":switch(u=!0,c){case"NOOK":case"PHONE BOOTH":case"wt":u=!1}break;case"WORK":u=!0,o&&(T="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":f=null;break;default:s&&console.log("invalid programType:",s)}f&&(f.color=g);var y=t,x={z:m},R=null,M=null;if(!y||0===y.length)if(p)switch(c){case"CHAIR":y=W(),(x=p).z=m,R={z:i},E=!(M="CHAIRS");break;case"TABLE":y=w(),(x=p).z=m,R={z:i},E=!(M="TABLES");break;case"HOTDESK_TABLE":y=v(),(x=p).z=m,R={z:i},E=!(M="HOTDESK_TABLES")}else console.warn("centroid is not available",JSON.stringify(e));if(y&&0!==y.length){if(y.forEach(function(e,t){var a=n;0!==t&&(a=n+"/"+t);var c={id:a,type:"MESH",style:{color:T,side:h,outline:f,opacity:d},points:e,interactable:E,extrude:b,position:x,rotation:R};M&&(c.instancingId=M),l.push(c)}),u&&r){var A=N(y[0]);O&&(A.y=A.y-2),l.push({id:n+"_TEXT",type:"TEXT",text:r,position:A,scalar:1.7,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(O){var S=N(y[0]);p&&((S=p).z=0),u&&r&&(S.y=S.y+1);var I=3,k=B(y[0]);I>k.width?I=k.width-.1:I>k.height&&(I=k.height-.1),l.push({id:n+"_SPRITE",type:"SPRITE",position:S,scalar:1,style:{img:O,maxWidth:I},interactable:!1})}return l}console.warn("Invalid shapes",JSON.stringify(e))},e.getCenter=N,e.getSize=B,e.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}},e.applyInstancing=function(c,n){var s=new Map,r=function(){for(var e=0;e<c.length;e++){var t=c[e];if(t.instancingId){var a=s.get(t.instancingId);a||(a=[]),a.push(t),s.set(t.instancingId,a),c.splice(e,1),r()}}};r(),s.forEach(function(e,t,a){o(e,t,n)})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.FloormapUtils={})}(this,function(e){var c="https://cdn.spacemob.co/img/meeting_room@2x.png",n="https://cdn.spacemob.co/img/IT_room@2x.png",s="https://cdn.spacemob.co/img/pantry@2x.png",N=function(e){for(var t=1/0,a=1/0,c=-1/0,n=-1/0,s=0;s<e.length;s++)t=Math.min(t,e[s].x),a=Math.min(a,e[s].y),c=Math.max(c,e[s].x),n=Math.max(n,e[s].y);return{x:(c+t)/2,y:(n+a)/2}},W=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}]]},v=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}]]},C=function(e,t){switch(e){case"CIRCULATE":case"WE":return.1;default:return t}},H=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}},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)"}},_=function(e,t){var a=null;switch(t){case"PHONE BOOTH":a="https://cdn.spacemob.co/img/phone_booth@2x.png";break;case"wt":case"NOOK":case"BOOTH":case"BOOTHS":a="https://cdn.spacemob.co/img/nook@2x.png";break;case"LOUNGE":case"HONESTY MKT":case"HONESTY MARKET":case"PANTRY":a=s;break;case"GAME RM":a="https://cdn.spacemob.co/img/gameroom@2x.png";break;case"WOMEN WC":case"WOMENS WC":case"W RESTROOM":case"RESTROOM":case"UNISEX RESTROOM":case"UNISEX":case"ADA RESTROOM":case"ADA WC":a="https://cdn.spacemob.co/img/wc_f@2x.png";break;case"MEN WC":case"MENS WC":case"MALE WC":case"M RESTROOM":a="https://cdn.spacemob.co/img/wc_m@2x.png";break;case"IT":a=n;break;case"PRINTER":case"PRINT":case"PRINTER NOOK":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":case"STORAGE":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="https://cdn.spacemob.co/img/shower@2x.png";break;case"SERVICE LIFT":a="https://cdn.spacemob.co/img/servicelift@2x.png";break;case"WELLNESS RM":case"WELLNESS ROOM":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":case"JANITOR":a="https://cdn.spacemob.co/img/maintenance@2x.png";break;case"CONV. BOOTH":a=c}if(t.startsWith("IT ")&&(a=n),!a)switch(e){case"MEET":a=c}return a},B=function(e){for(var t=1/0,a=1/0,c=-1/0,n=-1/0,s=0;s<e.length;s++)t=Math.min(t,e[s].x),a=Math.min(a,e[s].y),c=Math.max(c,e[s].x),n=Math.max(n,e[s].y);return{width:c-t,height:n-a}},o=function(e,t,a){if(0!==e.length){var c=e[0];if(a.createInstancedMesh({id:t,mesh:{points:c.points,extrude:c.extrude}}),e.forEach(function(e){a.addToInstancedMesh({id:e.id,instancingId:t,style:{color:e.style.color},position:e.position,rotation:e.rotation,interactable:e.interactable})}),a.drawInstancedMesh({id:t}),c.style.outline&&c.style.outline.color){var n=t+"_OUTLINE";a.createInstancedMesh({id:n,mesh:{style:{outline:{color:c.style.outline.color,only:!0}},points:c.points,extrude:c.extrude}}),e.forEach(function(e){a.addToInstancedMesh({id:e.id+"_outline",instancingId:n,style:{color:e.style.color},position:e.position,rotation:e.rotation})}),a.drawInstancedMesh({id:n})}}};e.createRenderObjects=function(e){var n=e.id,t=e.shapes,a=e.type,c=e.subType,s=e.programType,r=e.roomNumber,o=e.hasWindow,i=e.locationAngle,p=e.centroid,l=[],h="BACK",g="#474747",d=1,E=!0,u=!1,b=C(s,6),m=H(s,6),T=L(s),O=_(s,c);if("object"===a)switch(c){case"CHAIR":T="rgb(206,206,206)",h="FRONT",m=-(6-(b=1))/2,g="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":T="rgb(246,241,241)",h="FRONT",b=.5,m=-1.5,d=.7,g="rgb(150,150,150)"}else"space"===a||"room"===a||console.warn("invalid type:",a);var f={only:!1,color:g};switch(c){case"HALLWAY":case"ELEV LOBBY":f=null}switch(s){case"MEET":switch(u=!0,c){case"NOOK":case"PHONE BOOTH":case"wt":u=!1}break;case"WORK":u=!0,o&&(T="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":f=null;break;default:s&&console.log("invalid programType:",s)}f&&(f.color=g);var y=t,x={z:m},R=null,M=null;if(!y||0===y.length)if(p)switch(c){case"CHAIR":y=W(),(x=p).z=m,R={z:i},E=!(M="CHAIRS");break;case"TABLE":y=w(),(x=p).z=m,R={z:i},E=!(M="TABLES");break;case"HOTDESK_TABLE":y=v(),(x=p).z=m,R={z:i},E=!(M="HOTDESK_TABLES")}else console.warn("centroid is not available",JSON.stringify(e));if(y&&0!==y.length){if(y.forEach(function(e,t){var a=n;0!==t&&(a=n+"/"+t);var c={id:a,type:"MESH",style:{color:T,side:h,outline:f,opacity:d},points:e,interactable:E,extrude:b,position:x,rotation:R};M&&(c.instancingId=M),l.push(c)}),u&&r){var A=N(y[0]);O&&(A.y=A.y-2),l.push({id:n+"_TEXT",type:"TEXT",text:r,position:A,scalar:1.7,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(O){var S=N(y[0]);p&&((S=p).z=0),u&&r&&(S.y=S.y+1);var I=3,k=B(y[0]);I>k.width?I=k.width-.1:I>k.height&&(I=k.height-.1),l.push({id:n+"_SPRITE",type:"SPRITE",position:S,scalar:1,style:{img:O,maxWidth:I},interactable:!1})}return l}console.warn("Invalid shapes",JSON.stringify(e))},e.getCenter=N,e.getSize=B,e.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}},e.applyInstancing=function(c,n){var s=new Map,r=function(){for(var e=0;e<c.length;e++){var t=c[e];if(t.instancingId){var a=s.get(t.instancingId);a||(a=[]),a.push(t),s.set(t.instancingId,a),c.splice(e,1),r()}}};r(),s.forEach(function(e,t,a){o(e,t,n)})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=floormap-utils.umd.min.js.map |
{ | ||
"name": "@wework/floormap-utils", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"jsnext:main": "dist/floormap-utils.es.js", | ||
@@ -62,3 +62,9 @@ "module": "dist/floormap-utils.es.js", | ||
] | ||
}, | ||
"standard-version": { | ||
"skip": { | ||
"tag": true, | ||
"commit": true | ||
} | ||
} | ||
} |
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
104227
1853