@wework/floormap-utils
Advanced tools
Comparing version 1.0.1 to 1.0.2
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
## <small>1.0.2 (2019-06-14)</small> | ||
* fix: 🐛 MAke change to fix circleci publish ([536bc7d](https://github.com/WeConnect/floormap-monorepo/commit/536bc7d)) | ||
## <small>1.0.1 (2019-06-14)</small> | ||
* fix: 🐛 LBE-1865 fix checking of programType (#9) ([36be733](https://github.com/WeConnect/floormap-monorepo/commit/36be733)), closes [#9](https://github.com/WeConnect/floormap-monorepo/issues/9) | ||
* chore: 💡 MW-1745 updated latest code base for all packages ([ee2660f](https://github.com/WeConnect/floormap-monorepo/commit/ee2660f)) | ||
* chore: 🤖 Fix test script on utils and add `yarn test` ([eaf3a5a](https://github.com/WeConnect/floormap-monorepo/commit/eaf3a5a)) | ||
* chore: 🤖 LBE-1747 Fix build script in utils ([b17b406](https://github.com/WeConnect/floormap-monorepo/commit/b17b406)) | ||
* chore: 🤖 LBE-1747 Test should be run in ci mode ([4059e16](https://github.com/WeConnect/floormap-monorepo/commit/4059e16)) | ||
* chore: 🤖 MW-1655 Setup Lerna ([5a25539](https://github.com/WeConnect/floormap-monorepo/commit/5a25539)) | ||
* chore: 🤖 MW-1746 configure prettier and eslint ([7f19481](https://github.com/WeConnect/floormap-monorepo/commit/7f19481)) | ||
# Change Log | ||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
@@ -4,0 +31,0 @@ |
@@ -559,4 +559,4 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
extrude: obj.extrude, | ||
opacity: obj.style ? obj.style.opacity : 1.0 | ||
} | ||
opacity: obj.style ? obj.style.opacity : 1.0, | ||
}, | ||
}); | ||
@@ -568,3 +568,3 @@ objs.forEach(function (o) { | ||
style: { | ||
color: o.style.color | ||
color: o.style.color, | ||
}, | ||
@@ -574,3 +574,3 @@ position: o.position, | ||
interactable: o.interactable, | ||
visible: o.visible | ||
visible: o.visible, | ||
}); | ||
@@ -588,9 +588,9 @@ }); | ||
color: obj.style.outline.color, | ||
only: true | ||
} | ||
only: true, | ||
}, | ||
}, | ||
points: obj.points, | ||
extrude: obj.extrude, | ||
zOrder: obj.zOrder | ||
} | ||
zOrder: obj.zOrder, | ||
}, | ||
}); | ||
@@ -602,7 +602,7 @@ objs.forEach(function (o) { | ||
style: { | ||
color: o.style.color | ||
color: o.style.color, | ||
}, | ||
position: o.position, | ||
rotation: o.rotation, | ||
visible: o.visible | ||
visible: o.visible, | ||
}); | ||
@@ -609,0 +609,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,s=-1/0,c=-1/0,n=0;n<e.length;n++)t=Math.min(t,e[n].x),a=Math.min(a,e[n].y),s=Math.max(s,e[n].x),c=Math.max(c,e[n].y);return{x:(s+t)/2,y:(c+a)/2}},createRenderObjects=function(e){var t,a,c=e.id,s=e.shapes,n=e.type,r=e.subType,o=e.programType,i=e.roomNumber,p=e.hasWindow,g=e.locationAngle,l=e.centroid,E=e.instancingId,h=[];"string"==typeof o&&(t=o.toUpperCase()),"string"==typeof r&&(a=r.toUpperCase());var m="BACK",O="#474747",d=1,b=!0,R=!1,T=getExtrude(t,6),u=getZed(t,6),M=getColor(t),A=getImage(t,a),y=0;if("object"===n)switch(a){case"CHAIR":M="rgb(206,206,206)",m="FRONT",u=-(6-(T=1))/2,O="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":M="rgb(246,241,241)",m="FRONT",T=.5,u=-1.5,d=.8,O="rgb(150,150,150)",y=1}else"space"===n||"room"===n||console.warn("invalid type:",n);var I={only:!1,color:O};switch(a){case"HALLWAY":case"ELEV LOBBY":I=null}switch(t){case"MEET":switch(R=!0,a){case"NOOK":case"PHONE BOOTH":case"wt":R=!1}break;case"WORK":R=!0,p&&(M="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":I=null;break;default:t&&console.log("invalid programType:",t)}I&&(I.color=O);var S=s,f={z:u},x=null,C=null;if(E&&(l?((f=l).z=u,C=E,b=!(x={z:g})):console.warn("centroid is not available",JSON.stringify(e))),S&&0!==S.length){if(S.forEach(function(e,t){var a=c;0!==t&&(a=c+"/"+t);var s={id:a,type:"MESH",style:{color:M,side:m,outline:I,opacity:d},points:e,interactable:b,extrude:T,position:f,rotation:x,visible:!0,zOrder:y};C&&(s.instancingId=C),h.push(s)}),R&&i){var N=getCenter(S[0]),v={x:.5,y:.5};A&&(v.y=1.25);var L=getSize(S[0]).width/2*.8;3<L&&(L=2.9),h.push({id:c+"_TEXT",type:"TEXT",text:i,position:N,scalar:L,center:v,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(A){var w=getCenter(S[0]),k={x:.5,y:.5};l&&((w=l).z=0),R&&i&&(k.y=.25);var W=3,H=getSize(S[0]);W>H.width?W=H.width-.1:W>H.height&&(W=H.height-.1),h.push({id:c+"_SPRITE",type:"SPRITE",position:w,scalar:1,center:k,style:{img:A,maxWidth:W},interactable:!1})}return h}console.warn("Invalid shapes",JSON.stringify(e))},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.toUpperCase()){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":case"BAR":case"BEER ISLAND":case"COMMUNITY BAR":a=pantry;break;case"GAME RM":case"GAME ROOM":case"DART BOARD":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":case"PRINTING ALCOVE":a=printer;break;case"MECH":case"MECHANICAL CLOSET":a=mechanical;break;case"STOR":case"STORE":case"STORAGE":case"BIKE STORAGE":case"F&B STORAGE":case"CLEANING STORAGE":case"COAT CLOSET":a=storage;break;case"TRASH":case"TRASH ROOM":a=trash;break;case"MOTHER RM":case"MOTHERS ROOM":a=motherRoom;break;case"F&B":a=pantry;break;case"MAIL":case"MAIL & PACKAGE ROOM":a=mail;break;case"SHOWER":case"SHOWERS":a=shower;break;case"SERVICE LIFT":case"ELEVATOR FOYER":a=serviceLift;break;case"WELLNESS RM":case"WELLNESS ROOM":case"FITNESS RM":a=wellness;break;case"ELEC":case"ELECTRICAL CLOSET":a=electrical;break;case"FIRE":case"FIRE COMMAND CENTER":a=fire;break;case"MOP":case"JC":case"JANITOR":case"MOP CLOSET":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,s=-1/0,c=-1/0,n=0;n<e.length;n++)t=Math.min(t,e[n].x),a=Math.min(a,e[n].y),s=Math.max(s,e[n].x),c=Math.max(c,e[n].y);return{width:s-t,height:c-a}},applyInstancing=function(s,c){var n=new Map,r=function(){for(var e=0;e<s.length;e++){var t=s[e];if(t.instancingId){var a=n.get(t.instancingId);(a=a||[]).push(t),n.set(t.instancingId,a),s.splice(e,1),r()}}};r(),n.forEach(function(e,t,a){toInstancedMesh(e,t,c)})},toInstancedMesh=function(e,t,a){if(0!==e.length){var s=e[0];if(a.createInstancedMesh({id:t,mesh:{points:s.points,extrude:s.extrude,opacity:s.style?s.style.opacity:1}}),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,visible:e.visible})}),a.drawInstancedMesh({id:t}),s.style.outline&&s.style.outline.color){var c=t+"_OUTLINE";a.createInstancedMesh({id:c,mesh:{style:{outline:{color:s.style.outline.color,only:!0}},points:s.points,extrude:s.extrude,zOrder:s.zOrder}}),e.forEach(function(e){a.addToInstancedMesh({id:e.id+"_outline",instancingId:c,style:{color:e.style.color},position:e.position,rotation:e.rotation,visible:e.visible})}),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,s=-1/0,c=-1/0,n=0;n<e.length;n++)t=Math.min(t,e[n].x),a=Math.min(a,e[n].y),s=Math.max(s,e[n].x),c=Math.max(c,e[n].y);return{x:(s+t)/2,y:(c+a)/2}},createRenderObjects=function(e){var t,a,c=e.id,s=e.shapes,n=e.type,r=e.subType,o=e.programType,i=e.roomNumber,p=e.hasWindow,g=e.locationAngle,l=e.centroid,E=e.instancingId,h=[];"string"==typeof o&&(t=o.toUpperCase()),"string"==typeof r&&(a=r.toUpperCase());var m="BACK",O="#474747",d=1,b=!0,R=!1,T=getExtrude(t,6),u=getZed(t,6),M=getColor(t),A=getImage(t,a),y=0;if("object"===n)switch(a){case"CHAIR":M="rgb(206,206,206)",m="FRONT",u=-(6-(T=1))/2,O="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":M="rgb(246,241,241)",m="FRONT",T=.5,u=-1.5,d=.8,O="rgb(150,150,150)",y=1}else"space"===n||"room"===n||console.warn("invalid type:",n);var I={only:!1,color:O};switch(a){case"HALLWAY":case"ELEV LOBBY":I=null}switch(t){case"MEET":switch(R=!0,a){case"NOOK":case"PHONE BOOTH":case"wt":R=!1}break;case"WORK":R=!0,p&&(M="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":I=null;break;default:t&&console.log("invalid programType:",t)}I&&(I.color=O);var S=s,f={z:u},x=null,C=null;if(E&&(l?((f=l).z=u,C=E,b=!(x={z:g})):console.warn("centroid is not available",JSON.stringify(e))),S&&0!==S.length){if(S.forEach(function(e,t){var a=c;0!==t&&(a=c+"/"+t);var s={id:a,type:"MESH",style:{color:M,side:m,outline:I,opacity:d},points:e,interactable:b,extrude:T,position:f,rotation:x,visible:!0,zOrder:y};C&&(s.instancingId=C),h.push(s)}),R&&i){var N=getCenter(S[0]),v={x:.5,y:.5};A&&(v.y=1.25);var L=getSize(S[0]).width/2*.8;3<L&&(L=2.9),h.push({id:c+"_TEXT",type:"TEXT",text:i,position:N,scalar:L,center:v,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(A){var w=getCenter(S[0]),k={x:.5,y:.5};l&&((w=l).z=0),R&&i&&(k.y=.25);var W=3,H=getSize(S[0]);W>H.width?W=H.width-.1:W>H.height&&(W=H.height-.1),h.push({id:c+"_SPRITE",type:"SPRITE",position:w,scalar:1,center:k,style:{img:A,maxWidth:W},interactable:!1})}return h}console.warn("Invalid shapes",JSON.stringify(e))},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.toUpperCase()){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":case"BAR":case"BEER ISLAND":case"COMMUNITY BAR":a=pantry;break;case"GAME RM":case"GAME ROOM":case"DART BOARD":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":case"PRINTING ALCOVE":a=printer;break;case"MECH":case"MECHANICAL CLOSET":a=mechanical;break;case"STOR":case"STORE":case"STORAGE":case"BIKE STORAGE":case"F&B STORAGE":case"CLEANING STORAGE":case"COAT CLOSET":a=storage;break;case"TRASH":case"TRASH ROOM":a=trash;break;case"MOTHER RM":case"MOTHERS ROOM":a=motherRoom;break;case"F&B":a=pantry;break;case"MAIL":case"MAIL & PACKAGE ROOM":a=mail;break;case"SHOWER":case"SHOWERS":a=shower;break;case"SERVICE LIFT":case"ELEVATOR FOYER":a=serviceLift;break;case"WELLNESS RM":case"WELLNESS ROOM":case"FITNESS RM":a=wellness;break;case"ELEC":case"ELECTRICAL CLOSET":a=electrical;break;case"FIRE":case"FIRE COMMAND CENTER":a=fire;break;case"MOP":case"JC":case"JANITOR":case"MOP CLOSET":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,s=-1/0,c=-1/0,n=0;n<e.length;n++)t=Math.min(t,e[n].x),a=Math.min(a,e[n].y),s=Math.max(s,e[n].x),c=Math.max(c,e[n].y);return{width:s-t,height:c-a}},applyInstancing=function(s,c){var n=new Map,r=function(){for(var e=0;e<s.length;e++){var t=s[e];if(t.instancingId){var a=n.get(t.instancingId);a||(a=[]),a.push(t),n.set(t.instancingId,a),s.splice(e,1),r()}}};r(),n.forEach(function(e,t,a){toInstancedMesh(e,t,c)})},toInstancedMesh=function(e,t,a){if(0!==e.length){var s=e[0];if(a.createInstancedMesh({id:t,mesh:{points:s.points,extrude:s.extrude,opacity:s.style?s.style.opacity:1}}),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,visible:e.visible})}),a.drawInstancedMesh({id:t}),s.style.outline&&s.style.outline.color){var c=t+"_OUTLINE";a.createInstancedMesh({id:c,mesh:{style:{outline:{color:s.style.outline.color,only:!0}},points:s.points,extrude:s.extrude,zOrder:s.zOrder}}),e.forEach(function(e){a.addToInstancedMesh({id:e.id+"_outline",instancingId:c,style:{color:e.style.color},position:e.position,rotation:e.rotation,visible:e.visible})}),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 |
@@ -557,4 +557,4 @@ var nook = 'https://cdn.spacemob.co/img/nook@2x.png'; | ||
extrude: obj.extrude, | ||
opacity: obj.style ? obj.style.opacity : 1.0 | ||
} | ||
opacity: obj.style ? obj.style.opacity : 1.0, | ||
}, | ||
}); | ||
@@ -566,3 +566,3 @@ objs.forEach(function (o) { | ||
style: { | ||
color: o.style.color | ||
color: o.style.color, | ||
}, | ||
@@ -572,3 +572,3 @@ position: o.position, | ||
interactable: o.interactable, | ||
visible: o.visible | ||
visible: o.visible, | ||
}); | ||
@@ -586,9 +586,9 @@ }); | ||
color: obj.style.outline.color, | ||
only: true | ||
} | ||
only: true, | ||
}, | ||
}, | ||
points: obj.points, | ||
extrude: obj.extrude, | ||
zOrder: obj.zOrder | ||
} | ||
zOrder: obj.zOrder, | ||
}, | ||
}); | ||
@@ -600,7 +600,7 @@ objs.forEach(function (o) { | ||
style: { | ||
color: o.style.color | ||
color: o.style.color, | ||
}, | ||
position: o.position, | ||
rotation: o.rotation, | ||
visible: o.visible | ||
visible: o.visible, | ||
}); | ||
@@ -607,0 +607,0 @@ }); |
@@ -563,4 +563,4 @@ (function (global, factory) { | ||
extrude: obj.extrude, | ||
opacity: obj.style ? obj.style.opacity : 1.0 | ||
} | ||
opacity: obj.style ? obj.style.opacity : 1.0, | ||
}, | ||
}); | ||
@@ -572,3 +572,3 @@ objs.forEach(function (o) { | ||
style: { | ||
color: o.style.color | ||
color: o.style.color, | ||
}, | ||
@@ -578,3 +578,3 @@ position: o.position, | ||
interactable: o.interactable, | ||
visible: o.visible | ||
visible: o.visible, | ||
}); | ||
@@ -592,9 +592,9 @@ }); | ||
color: obj.style.outline.color, | ||
only: true | ||
} | ||
only: true, | ||
}, | ||
}, | ||
points: obj.points, | ||
extrude: obj.extrude, | ||
zOrder: obj.zOrder | ||
} | ||
zOrder: obj.zOrder, | ||
}, | ||
}); | ||
@@ -606,7 +606,7 @@ objs.forEach(function (o) { | ||
style: { | ||
color: o.style.color | ||
color: o.style.color, | ||
}, | ||
position: o.position, | ||
rotation: o.rotation, | ||
visible: o.visible | ||
visible: o.visible, | ||
}); | ||
@@ -613,0 +613,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
!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){function B(e){for(var a=1/0,t=1/0,c=-1/0,s=-1/0,n=0;n<e.length;n++)a=Math.min(a,e[n].x),t=Math.min(t,e[n].y),c=Math.max(c,e[n].x),s=Math.max(s,e[n].y);return{x:(c+a)/2,y:(s+t)/2}}var c="https://cdn.spacemob.co/img/meeting_room@2x.png",s="https://cdn.spacemob.co/img/IT_room@2x.png",n="https://cdn.spacemob.co/img/pantry@2x.png",P=function(e,a){switch(e){case"CIRCULATE":case"WE":return.1;default:return a}},_=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}},F=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)"}},U=function(e,a){var t=null;switch(a.toUpperCase()){case"PHONE BOOTH":t="https://cdn.spacemob.co/img/phone_booth@2x.png";break;case"WT":case"NOOK":case"BOOTH":case"BOOTHS":t="https://cdn.spacemob.co/img/nook@2x.png";break;case"LOUNGE":case"HONESTY MKT":case"HONESTY MARKET":case"PANTRY":case"BAR":case"BEER ISLAND":case"COMMUNITY BAR":t=n;break;case"GAME RM":case"GAME ROOM":case"DART BOARD":t="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":t="https://cdn.spacemob.co/img/wc_f@2x.png";break;case"MEN WC":case"MENS WC":case"MALE WC":case"M RESTROOM":t="https://cdn.spacemob.co/img/wc_m@2x.png";break;case"IT":t=s;break;case"PRINTER":case"PRINT":case"PRINTER NOOK":case"PRINTING ALCOVE":t="https://cdn.spacemob.co/img/printer@2x.png";break;case"MECH":case"MECHANICAL CLOSET":t="https://cdn.spacemob.co/img/mechanical@2x.png";break;case"STOR":case"STORE":case"STORAGE":case"BIKE STORAGE":case"F&B STORAGE":case"CLEANING STORAGE":case"COAT CLOSET":t="https://cdn.spacemob.co/img/storage@2x.png";break;case"TRASH":case"TRASH ROOM":t="https://cdn.spacemob.co/img/trash@2x.png";break;case"MOTHER RM":case"MOTHERS ROOM":t="https://cdn.spacemob.co/img/motherroom@2x.png";break;case"F&B":t=n;break;case"MAIL":case"MAIL & PACKAGE ROOM":t="https://cdn.spacemob.co/img/mail_room@2x.png";break;case"SHOWER":case"SHOWERS":t="https://cdn.spacemob.co/img/shower@2x.png";break;case"SERVICE LIFT":case"ELEVATOR FOYER":t="https://cdn.spacemob.co/img/servicelift@2x.png";break;case"WELLNESS RM":case"WELLNESS ROOM":case"FITNESS RM":t="https://cdn.spacemob.co/img/wellnessroom@2x.png";break;case"ELEC":case"ELECTRICAL CLOSET":t="https://cdn.spacemob.co/img/electrical@2x.png";break;case"FIRE":case"FIRE COMMAND CENTER":t="https://cdn.spacemob.co/img/fire_extinguisher@2x.png";break;case"MOP":case"JC":case"JANITOR":case"MOP CLOSET":t="https://cdn.spacemob.co/img/maintenance@2x.png";break;case"CONV. BOOTH":t=c}if(a.startsWith("IT ")&&(t=s),!t)switch(e){case"MEET":t=c}return t},K=function(e){for(var a=1/0,t=1/0,c=-1/0,s=-1/0,n=0;n<e.length;n++)a=Math.min(a,e[n].x),t=Math.min(t,e[n].y),c=Math.max(c,e[n].x),s=Math.max(s,e[n].y);return{width:c-a,height:s-t}},o=function(e,a,t){if(0!==e.length){var c=e[0];if(t.createInstancedMesh({id:a,mesh:{points:c.points,extrude:c.extrude,opacity:c.style?c.style.opacity:1}}),e.forEach(function(e){t.addToInstancedMesh({id:e.id,instancingId:a,style:{color:e.style.color},position:e.position,rotation:e.rotation,interactable:e.interactable,visible:e.visible})}),t.drawInstancedMesh({id:a}),c.style.outline&&c.style.outline.color){var s=a+"_OUTLINE";t.createInstancedMesh({id:s,mesh:{style:{outline:{color:c.style.outline.color,only:!0}},points:c.points,extrude:c.extrude,zOrder:c.zOrder}}),e.forEach(function(e){t.addToInstancedMesh({id:e.id+"_outline",instancingId:s,style:{color:e.style.color},position:e.position,rotation:e.rotation,visible:e.visible})}),t.drawInstancedMesh({id:s})}}};e.createRenderObjects=function(e){var a,t,s=e.id,c=e.shapes,n=e.type,r=e.subType,o=e.programType,i=e.roomNumber,p=e.hasWindow,E=e.locationAngle,l=e.centroid,g=e.instancingId,d=[];"string"==typeof o&&(a=o.toUpperCase()),"string"==typeof r&&(t=r.toUpperCase());var O="BACK",h="#474747",b=1,T=!0,u=!1,m=P(a,6),R=_(a,6),M=F(a),f=U(a,t),A=0;if("object"===n)switch(t){case"CHAIR":M="rgb(206,206,206)",O="FRONT",R=-(6-(m=1))/2,h="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":M="rgb(246,241,241)",O="FRONT",m=.5,R=-1.5,b=.8,h="rgb(150,150,150)",A=1}else"space"===n||"room"===n||console.warn("invalid type:",n);var y={only:!1,color:h};switch(t){case"HALLWAY":case"ELEV LOBBY":y=null}switch(a){case"MEET":switch(u=!0,t){case"NOOK":case"PHONE BOOTH":case"wt":u=!1}break;case"WORK":u=!0,p&&(M="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":y=null;break;default:a&&console.log("invalid programType:",a)}y&&(y.color=h);var I=c,S={z:R},x=null,C=null;if(g&&(l?((S=l).z=R,C=g,T=!(x={z:E})):console.warn("centroid is not available",JSON.stringify(e))),I&&0!==I.length){if(I.forEach(function(e,a){var t=s;0!==a&&(t=s+"/"+a);var c={id:t,type:"MESH",style:{color:M,side:O,outline:y,opacity:b},points:e,interactable:T,extrude:m,position:S,rotation:x,visible:!0,zOrder:A};C&&(c.instancingId=C),d.push(c)}),u&&i){var N=B(I[0]),v={x:.5,y:.5};f&&(v.y=1.25);var L=K(I[0]).width/2*.8;3<L&&(L=2.9),d.push({id:s+"_TEXT",type:"TEXT",text:i,position:N,scalar:L,center:v,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(f){var W=B(I[0]),k={x:.5,y:.5};l&&((W=l).z=0),u&&i&&(k.y=.25);var w=3,H=K(I[0]);w>H.width?w=H.width-.1:w>H.height&&(w=H.height-.1),d.push({id:s+"_SPRITE",type:"SPRITE",position:W,scalar:1,center:k,style:{img:f,maxWidth:w},interactable:!1})}return d}console.warn("Invalid shapes",JSON.stringify(e))},e.getCenter=B,e.getSize=K,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}},e.applyInstancing=function(c,s){var n=new Map,r=function(){for(var e=0;e<c.length;e++){var a=c[e];if(a.instancingId){var t=n.get(a.instancingId);(t=t||[]).push(a),n.set(a.instancingId,t),c.splice(e,1),r()}}};r(),n.forEach(function(e,a,t){o(e,a,s)})},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){function B(e){for(var a=1/0,t=1/0,c=-1/0,s=-1/0,n=0;n<e.length;n++)a=Math.min(a,e[n].x),t=Math.min(t,e[n].y),c=Math.max(c,e[n].x),s=Math.max(s,e[n].y);return{x:(c+a)/2,y:(s+t)/2}}var c="https://cdn.spacemob.co/img/meeting_room@2x.png",s="https://cdn.spacemob.co/img/IT_room@2x.png",n="https://cdn.spacemob.co/img/pantry@2x.png",P=function(e,a){switch(e){case"CIRCULATE":case"WE":return.1;default:return a}},_=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}},F=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)"}},U=function(e,a){var t=null;switch(a.toUpperCase()){case"PHONE BOOTH":t="https://cdn.spacemob.co/img/phone_booth@2x.png";break;case"WT":case"NOOK":case"BOOTH":case"BOOTHS":t="https://cdn.spacemob.co/img/nook@2x.png";break;case"LOUNGE":case"HONESTY MKT":case"HONESTY MARKET":case"PANTRY":case"BAR":case"BEER ISLAND":case"COMMUNITY BAR":t=n;break;case"GAME RM":case"GAME ROOM":case"DART BOARD":t="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":t="https://cdn.spacemob.co/img/wc_f@2x.png";break;case"MEN WC":case"MENS WC":case"MALE WC":case"M RESTROOM":t="https://cdn.spacemob.co/img/wc_m@2x.png";break;case"IT":t=s;break;case"PRINTER":case"PRINT":case"PRINTER NOOK":case"PRINTING ALCOVE":t="https://cdn.spacemob.co/img/printer@2x.png";break;case"MECH":case"MECHANICAL CLOSET":t="https://cdn.spacemob.co/img/mechanical@2x.png";break;case"STOR":case"STORE":case"STORAGE":case"BIKE STORAGE":case"F&B STORAGE":case"CLEANING STORAGE":case"COAT CLOSET":t="https://cdn.spacemob.co/img/storage@2x.png";break;case"TRASH":case"TRASH ROOM":t="https://cdn.spacemob.co/img/trash@2x.png";break;case"MOTHER RM":case"MOTHERS ROOM":t="https://cdn.spacemob.co/img/motherroom@2x.png";break;case"F&B":t=n;break;case"MAIL":case"MAIL & PACKAGE ROOM":t="https://cdn.spacemob.co/img/mail_room@2x.png";break;case"SHOWER":case"SHOWERS":t="https://cdn.spacemob.co/img/shower@2x.png";break;case"SERVICE LIFT":case"ELEVATOR FOYER":t="https://cdn.spacemob.co/img/servicelift@2x.png";break;case"WELLNESS RM":case"WELLNESS ROOM":case"FITNESS RM":t="https://cdn.spacemob.co/img/wellnessroom@2x.png";break;case"ELEC":case"ELECTRICAL CLOSET":t="https://cdn.spacemob.co/img/electrical@2x.png";break;case"FIRE":case"FIRE COMMAND CENTER":t="https://cdn.spacemob.co/img/fire_extinguisher@2x.png";break;case"MOP":case"JC":case"JANITOR":case"MOP CLOSET":t="https://cdn.spacemob.co/img/maintenance@2x.png";break;case"CONV. BOOTH":t=c}if(a.startsWith("IT ")&&(t=s),!t)switch(e){case"MEET":t=c}return t},K=function(e){for(var a=1/0,t=1/0,c=-1/0,s=-1/0,n=0;n<e.length;n++)a=Math.min(a,e[n].x),t=Math.min(t,e[n].y),c=Math.max(c,e[n].x),s=Math.max(s,e[n].y);return{width:c-a,height:s-t}},o=function(e,a,t){if(0!==e.length){var c=e[0];if(t.createInstancedMesh({id:a,mesh:{points:c.points,extrude:c.extrude,opacity:c.style?c.style.opacity:1}}),e.forEach(function(e){t.addToInstancedMesh({id:e.id,instancingId:a,style:{color:e.style.color},position:e.position,rotation:e.rotation,interactable:e.interactable,visible:e.visible})}),t.drawInstancedMesh({id:a}),c.style.outline&&c.style.outline.color){var s=a+"_OUTLINE";t.createInstancedMesh({id:s,mesh:{style:{outline:{color:c.style.outline.color,only:!0}},points:c.points,extrude:c.extrude,zOrder:c.zOrder}}),e.forEach(function(e){t.addToInstancedMesh({id:e.id+"_outline",instancingId:s,style:{color:e.style.color},position:e.position,rotation:e.rotation,visible:e.visible})}),t.drawInstancedMesh({id:s})}}};e.createRenderObjects=function(e){var a,t,s=e.id,c=e.shapes,n=e.type,r=e.subType,o=e.programType,i=e.roomNumber,p=e.hasWindow,E=e.locationAngle,l=e.centroid,g=e.instancingId,d=[];"string"==typeof o&&(a=o.toUpperCase()),"string"==typeof r&&(t=r.toUpperCase());var O="BACK",h="#474747",b=1,T=!0,u=!1,m=P(a,6),R=_(a,6),M=F(a),f=U(a,t),A=0;if("object"===n)switch(t){case"CHAIR":M="rgb(206,206,206)",O="FRONT",R=-(6-(m=1))/2,h="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":M="rgb(246,241,241)",O="FRONT",m=.5,R=-1.5,b=.8,h="rgb(150,150,150)",A=1}else"space"===n||"room"===n||console.warn("invalid type:",n);var y={only:!1,color:h};switch(t){case"HALLWAY":case"ELEV LOBBY":y=null}switch(a){case"MEET":switch(u=!0,t){case"NOOK":case"PHONE BOOTH":case"wt":u=!1}break;case"WORK":u=!0,p&&(M="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":y=null;break;default:a&&console.log("invalid programType:",a)}y&&(y.color=h);var I=c,S={z:R},x=null,C=null;if(g&&(l?((S=l).z=R,C=g,T=!(x={z:E})):console.warn("centroid is not available",JSON.stringify(e))),I&&0!==I.length){if(I.forEach(function(e,a){var t=s;0!==a&&(t=s+"/"+a);var c={id:t,type:"MESH",style:{color:M,side:O,outline:y,opacity:b},points:e,interactable:T,extrude:m,position:S,rotation:x,visible:!0,zOrder:A};C&&(c.instancingId=C),d.push(c)}),u&&i){var N=B(I[0]),v={x:.5,y:.5};f&&(v.y=1.25);var L=K(I[0]).width/2*.8;3<L&&(L=2.9),d.push({id:s+"_TEXT",type:"TEXT",text:i,position:N,scalar:L,center:v,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(f){var W=B(I[0]),k={x:.5,y:.5};l&&((W=l).z=0),u&&i&&(k.y=.25);var w=3,H=K(I[0]);w>H.width?w=H.width-.1:w>H.height&&(w=H.height-.1),d.push({id:s+"_SPRITE",type:"SPRITE",position:W,scalar:1,center:k,style:{img:f,maxWidth:w},interactable:!1})}return d}console.warn("Invalid shapes",JSON.stringify(e))},e.getCenter=B,e.getSize=K,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}},e.applyInstancing=function(c,s){var n=new Map,r=function(){for(var e=0;e<c.length;e++){var a=c[e];if(a.instancingId){var t=n.get(a.instancingId);t||(t=[]),t.push(a),n.set(a.instancingId,t),c.splice(e,1),r()}}};r(),n.forEach(function(e,a,t){o(e,a,s)})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=floormap-utils.umd.min.js.map |
export { | ||
createRenderObjects, | ||
getCenter, | ||
getSize, | ||
stringArrayToPoints | ||
} from './src/spatial-service.js' | ||
createRenderObjects, getCenter, getSize, stringArrayToPoints, | ||
} from './src/spatial-service' | ||
export { applyInstancing } from './src/instancing.js' | ||
export { applyInstancing } from './src/instancing' |
{ | ||
"name": "@wework/floormap-utils", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"jsnext:main": "dist/floormap-utils.es.js", | ||
@@ -14,4 +14,6 @@ "module": "dist/floormap-utils.es.js", | ||
"format": "prettier --write --semi false '*.js' 'src/*.js' && standard --fix", | ||
"test": "npm run lint && npm run testonly", | ||
"build": "npm-run-all test clean rollup rollup:min size", | ||
"test": "jest", | ||
"test:cover": "jest --coverage", | ||
"test:ci": "jest --ci --coverage", | ||
"build": "npm-run-all rollup rollup:min size", | ||
"clean": "rimraf dist", | ||
@@ -21,3 +23,4 @@ "rollup": "rollup -c", | ||
"size": "echo \"Gzipped Size: $(cat dist/floormap-utils.umd.min.js | gzip-size)\"", | ||
"precommit": "lint-staged" | ||
"precommit": "lint-staged", | ||
"dev": "rollup -c -w" | ||
}, | ||
@@ -45,2 +48,3 @@ "author": "", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"rollup-watch": "^4.3.1", | ||
"standard": "^10.0.2", | ||
@@ -71,3 +75,4 @@ "standard-version": "^4.0.0" | ||
} | ||
} | ||
}, | ||
"gitHead": "272a81bd024d25a2835e9d92ff3415c129bd7232" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
105881
17
1812