@wework/floormap-utils
Advanced tools
Comparing version 0.10.0 to 1.0.0-rc1
@@ -54,2 +54,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
var centroid = params.centroid; | ||
var instancingId = params.instancingId; | ||
@@ -164,41 +165,11 @@ var objects = []; | ||
if (!_shapes || _shapes.length === 0) { | ||
if (instancingId) { | ||
if (centroid) { | ||
switch (subType) { | ||
case 'CHAIR': { | ||
_shapes = getChairGeometry(); | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = 'CHAIRS'; | ||
interactable = false; | ||
break | ||
} | ||
case 'TABLE': { | ||
_shapes = getTableGeometry(); | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = 'TABLES'; | ||
interactable = false; | ||
break | ||
} | ||
case 'HOTDESK_TABLE': { | ||
_shapes = getHotDeskTableGeometry(); | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = 'HOTDESK_TABLES'; | ||
interactable = false; | ||
break | ||
} | ||
default: | ||
break | ||
} | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = instancingId; | ||
interactable = false; | ||
} else { | ||
@@ -306,37 +277,2 @@ console.warn('centroid is not available', JSON.stringify(params)); | ||
var getChairGeometry = function () { | ||
var shapes = [ | ||
[ | ||
{ x: 1.0, y: 1.45 }, | ||
{ x: -1.0, y: 1.45 }, | ||
{ x: -1.0, y: -0.55 }, | ||
{ x: 1.0, y: -0.55 } | ||
] | ||
]; | ||
return shapes | ||
}; | ||
var getTableGeometry = function () { | ||
var shapes = [ | ||
[ | ||
{ x: 2.0, y: 2.3 }, | ||
{ x: -2.0, y: 2.3 }, | ||
{ x: -2.0, y: 0.3 }, | ||
{ x: 2.0, y: 0.3 } | ||
] | ||
]; | ||
return shapes | ||
}; | ||
var 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 } | ||
] | ||
] | ||
}; | ||
var getExtrude = function (programType, wallHeight) { | ||
@@ -343,0 +279,0 @@ switch (programType) { |
@@ -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,c=-1/0,s=-1/0,n=0;n<e.length;n++)t=Math.min(t,e[n].x),a=Math.min(a,e[n].y),c=Math.max(c,e[n].x),s=Math.max(s,e[n].y);return{x:(c+t)/2,y:(s+a)/2}},createRenderObjects=function(e){var s=e.id,t=e.shapes,a=e.type,c=e.subType,n=e.programType,r=e.roomNumber,o=e.hasWindow,i=e.locationAngle,p=e.centroid,g=[],l="BACK",E="#474747",h=1,m=!0,O=!1,T=getExtrude(n,6),b=getZed(n,6),d=getColor(n),R=getImage(n,c);if("object"===a)switch(c){case"CHAIR":d="rgb(206,206,206)",l="FRONT",b=-(6-(T=1))/2,E="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":d="rgb(246,241,241)",l="FRONT",T=.5,b=-1.5,h=.7,E="rgb(150,150,150)"}else"space"===a||"room"===a||console.warn("invalid type:",a);var u={only:!1,color:E};switch(c){case"HALLWAY":case"ELEV LOBBY":u=null}switch(n){case"MEET":switch(O=!0,c){case"NOOK":case"PHONE BOOTH":case"wt":O=!1}break;case"WORK":O=!0,o&&(d="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":u=null;break;default:n&&console.log("invalid programType:",n)}u&&(u.color=E);var y=t,A={z:b},x=null,M=null;if(!y||0===y.length)if(p)switch(c){case"CHAIR":y=getChairGeometry(),(A=p).z=b,x={z:i},m=!(M="CHAIRS");break;case"TABLE":y=getTableGeometry(),(A=p).z=b,x={z:i},m=!(M="TABLES");break;case"HOTDESK_TABLE":y=getHotDeskTableGeometry(),(A=p).z=b,x={z:i},m=!(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=s;0!==t&&(a=s+"/"+t);var c={id:a,type:"MESH",style:{color:d,side:l,outline:u,opacity:h},points:e,interactable:m,extrude:T,position:A,rotation:x,visible:!0};M&&(c.instancingId=M),g.push(c)}),O&&r){var S=getCenter(y[0]),I={x:.5,y:.5};R&&(I.y=1.25);var f=getSize(y[0]).width/2*.8;3<f&&(f=2.9),g.push({id:s+"_TEXT",type:"TEXT",text:r,position:S,scalar:f,center:I,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(R){var C=getCenter(y[0]),L={x:.5,y:.5};p&&((C=p).z=0),O&&r&&(L.y=.25);var N=3,k=getSize(y[0]);N>k.width?N=k.width-.1:N>k.height&&(N=k.height-.1),g.push({id:s+"_SPRITE",type:"SPRITE",position:C,scalar:1,center:L,style:{img:R,maxWidth:N},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.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,c=-1/0,s=-1/0,n=0;n<e.length;n++)t=Math.min(t,e[n].x),a=Math.min(a,e[n].y),c=Math.max(c,e[n].x),s=Math.max(s,e[n].y);return{width:c-t,height:s-a}},applyInstancing=function(c,s){var n=new Map,r=function(){for(var e=0;e<c.length;e++){var t=c[e];if(t.instancingId){var a=n.get(t.instancingId);a||(a=[]),a.push(t),n.set(t.instancingId,a),c.splice(e,1),r()}}};r(),n.forEach(function(e,t,a){toInstancedMesh(e,t,s)})},toInstancedMesh=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,visible:e.visible})}),a.drawInstancedMesh({id:t}),c.style.outline&&c.style.outline.color){var s=t+"_OUTLINE";a.createInstancedMesh({id:s,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:s,style:{color:e.style.color},position:e.position,rotation:e.rotation,visible:e.visible})}),a.drawInstancedMesh({id:s})}}};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,c=-1/0,s=-1/0,n=0;n<e.length;n++)t=Math.min(t,e[n].x),a=Math.min(a,e[n].y),c=Math.max(c,e[n].x),s=Math.max(s,e[n].y);return{x:(c+t)/2,y:(s+a)/2}},createRenderObjects=function(e){var s=e.id,t=e.shapes,a=e.type,c=e.subType,n=e.programType,r=e.roomNumber,o=e.hasWindow,i=e.locationAngle,p=e.centroid,g=e.instancingId,l=[],E="BACK",h="#474747",m=1,O=!0,d=!1,b=getExtrude(n,6),R=getZed(n,6),T=getColor(n),u=getImage(n,c);if("object"===a)switch(c){case"CHAIR":T="rgb(206,206,206)",E="FRONT",R=-(6-(b=1))/2,h="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":T="rgb(246,241,241)",E="FRONT",b=.5,R=-1.5,m=.7,h="rgb(150,150,150)"}else"space"===a||"room"===a||console.warn("invalid type:",a);var M={only:!1,color:h};switch(c){case"HALLWAY":case"ELEV LOBBY":M=null}switch(n){case"MEET":switch(d=!0,c){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":M=null;break;default:n&&console.log("invalid programType:",n)}M&&(M.color=h);var A=t,I={z:R},S=null,f=null;if(g&&(p?((I=p).z=R,f=g,O=!(S={z:i})):console.warn("centroid is not available",JSON.stringify(e))),A&&0!==A.length){if(A.forEach(function(e,t){var a=s;0!==t&&(a=s+"/"+t);var c={id:a,type:"MESH",style:{color:T,side:E,outline:M,opacity:m},points:e,interactable:O,extrude:b,position:I,rotation:S,visible:!0};f&&(c.instancingId=f),l.push(c)}),d&&r){var x=getCenter(A[0]),y={x:.5,y:.5};u&&(y.y=1.25);var C=getSize(A[0]).width/2*.8;3<C&&(C=2.9),l.push({id:s+"_TEXT",type:"TEXT",text:r,position:x,scalar:C,center:y,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(u){var N=getCenter(A[0]),L={x:.5,y:.5};p&&((N=p).z=0),d&&r&&(L.y=.25);var v=3,w=getSize(A[0]);v>w.width?v=w.width-.1:v>w.height&&(v=w.height-.1),l.push({id:s+"_SPRITE",type:"SPRITE",position:N,scalar:1,center:L,style:{img:u,maxWidth:v},interactable:!1})}return l}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,c=-1/0,s=-1/0,n=0;n<e.length;n++)t=Math.min(t,e[n].x),a=Math.min(a,e[n].y),c=Math.max(c,e[n].x),s=Math.max(s,e[n].y);return{width:c-t,height:s-a}},applyInstancing=function(c,s){var n=new Map,r=function(){for(var e=0;e<c.length;e++){var t=c[e];if(t.instancingId){var a=n.get(t.instancingId);a||(a=[]),a.push(t),n.set(t.instancingId,a),c.splice(e,1),r()}}};r(),n.forEach(function(e,t,a){toInstancedMesh(e,t,s)})},toInstancedMesh=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,visible:e.visible})}),a.drawInstancedMesh({id:t}),c.style.outline&&c.style.outline.color){var s=t+"_OUTLINE";a.createInstancedMesh({id:s,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:s,style:{color:e.style.color},position:e.position,rotation:e.rotation,visible:e.visible})}),a.drawInstancedMesh({id:s})}}};exports.createRenderObjects=createRenderObjects,exports.getCenter=getCenter,exports.getSize=getSize,exports.stringArrayToPoints=stringArrayToPoints,exports.applyInstancing=applyInstancing; | ||
//# sourceMappingURL=floormap-utils.cjs.min.js.map |
@@ -52,2 +52,3 @@ var nook = 'https://cdn.spacemob.co/img/nook@2x.png'; | ||
var centroid = params.centroid; | ||
var instancingId = params.instancingId; | ||
@@ -162,41 +163,11 @@ var objects = []; | ||
if (!_shapes || _shapes.length === 0) { | ||
if (instancingId) { | ||
if (centroid) { | ||
switch (subType) { | ||
case 'CHAIR': { | ||
_shapes = getChairGeometry(); | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = 'CHAIRS'; | ||
interactable = false; | ||
break | ||
} | ||
case 'TABLE': { | ||
_shapes = getTableGeometry(); | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = 'TABLES'; | ||
interactable = false; | ||
break | ||
} | ||
case 'HOTDESK_TABLE': { | ||
_shapes = getHotDeskTableGeometry(); | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = 'HOTDESK_TABLES'; | ||
interactable = false; | ||
break | ||
} | ||
default: | ||
break | ||
} | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = instancingId; | ||
interactable = false; | ||
} else { | ||
@@ -304,37 +275,2 @@ console.warn('centroid is not available', JSON.stringify(params)); | ||
var getChairGeometry = function () { | ||
var shapes = [ | ||
[ | ||
{ x: 1.0, y: 1.45 }, | ||
{ x: -1.0, y: 1.45 }, | ||
{ x: -1.0, y: -0.55 }, | ||
{ x: 1.0, y: -0.55 } | ||
] | ||
]; | ||
return shapes | ||
}; | ||
var getTableGeometry = function () { | ||
var shapes = [ | ||
[ | ||
{ x: 2.0, y: 2.3 }, | ||
{ x: -2.0, y: 2.3 }, | ||
{ x: -2.0, y: 0.3 }, | ||
{ x: 2.0, y: 0.3 } | ||
] | ||
]; | ||
return shapes | ||
}; | ||
var 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 } | ||
] | ||
] | ||
}; | ||
var getExtrude = function (programType, wallHeight) { | ||
@@ -341,0 +277,0 @@ switch (programType) { |
@@ -58,2 +58,3 @@ (function (global, factory) { | ||
var centroid = params.centroid; | ||
var instancingId = params.instancingId; | ||
@@ -168,41 +169,11 @@ var objects = []; | ||
if (!_shapes || _shapes.length === 0) { | ||
if (instancingId) { | ||
if (centroid) { | ||
switch (subType) { | ||
case 'CHAIR': { | ||
_shapes = getChairGeometry(); | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = 'CHAIRS'; | ||
interactable = false; | ||
break | ||
} | ||
case 'TABLE': { | ||
_shapes = getTableGeometry(); | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = 'TABLES'; | ||
interactable = false; | ||
break | ||
} | ||
case 'HOTDESK_TABLE': { | ||
_shapes = getHotDeskTableGeometry(); | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = 'HOTDESK_TABLES'; | ||
interactable = false; | ||
break | ||
} | ||
default: | ||
break | ||
} | ||
_pos = centroid; | ||
_pos.z = zed; | ||
_rotation = { | ||
z: locationAngle | ||
}; | ||
_instancingId = instancingId; | ||
interactable = false; | ||
} else { | ||
@@ -310,37 +281,2 @@ console.warn('centroid is not available', JSON.stringify(params)); | ||
var getChairGeometry = function () { | ||
var shapes = [ | ||
[ | ||
{ x: 1.0, y: 1.45 }, | ||
{ x: -1.0, y: 1.45 }, | ||
{ x: -1.0, y: -0.55 }, | ||
{ x: 1.0, y: -0.55 } | ||
] | ||
]; | ||
return shapes | ||
}; | ||
var getTableGeometry = function () { | ||
var shapes = [ | ||
[ | ||
{ x: 2.0, y: 2.3 }, | ||
{ x: -2.0, y: 2.3 }, | ||
{ x: -2.0, y: 0.3 }, | ||
{ x: 2.0, y: 0.3 } | ||
] | ||
]; | ||
return shapes | ||
}; | ||
var 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 } | ||
] | ||
] | ||
}; | ||
var getExtrude = function (programType, wallHeight) { | ||
@@ -347,0 +283,0 @@ switch (programType) { |
@@ -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 k(e){for(var a=1/0,c=1/0,t=-1/0,s=-1/0,n=0;n<e.length;n++)a=Math.min(a,e[n].x),c=Math.min(c,e[n].y),t=Math.max(t,e[n].x),s=Math.max(s,e[n].y);return{x:(t+a)/2,y:(s+c)/2}}var t="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",W=function(){return[[{x:1,y:1.45},{x:-1,y:1.45},{x:-1,y:-.55},{x:1,y:-.55}]]},H=function(){return[[{x:2,y:2.3},{x:-2,y:2.3},{x:-2,y:.3},{x:2,y:.3}]]},w=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}]]},B=function(e,a){switch(e){case"CIRCULATE":case"WE":return.1;default:return a}},P=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}},_=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)"}},K=function(e,a){var c=null;switch(a.toUpperCase()){case"PHONE BOOTH":c="https://cdn.spacemob.co/img/phone_booth@2x.png";break;case"WT":case"NOOK":case"BOOTH":case"BOOTHS":c="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":c=n;break;case"GAME RM":case"GAME ROOM":case"DART BOARD":c="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":c="https://cdn.spacemob.co/img/wc_f@2x.png";break;case"MEN WC":case"MENS WC":case"MALE WC":case"M RESTROOM":c="https://cdn.spacemob.co/img/wc_m@2x.png";break;case"IT":c=s;break;case"PRINTER":case"PRINT":case"PRINTER NOOK":case"PRINTING ALCOVE":c="https://cdn.spacemob.co/img/printer@2x.png";break;case"MECH":case"MECHANICAL CLOSET":c="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":c="https://cdn.spacemob.co/img/storage@2x.png";break;case"TRASH":case"TRASH ROOM":c="https://cdn.spacemob.co/img/trash@2x.png";break;case"MOTHER RM":case"MOTHERS ROOM":c="https://cdn.spacemob.co/img/motherroom@2x.png";break;case"F&B":c=n;break;case"MAIL":case"MAIL & PACKAGE ROOM":c="https://cdn.spacemob.co/img/mail_room@2x.png";break;case"SHOWER":case"SHOWERS":c="https://cdn.spacemob.co/img/shower@2x.png";break;case"SERVICE LIFT":case"ELEVATOR FOYER":c="https://cdn.spacemob.co/img/servicelift@2x.png";break;case"WELLNESS RM":case"WELLNESS ROOM":case"FITNESS RM":c="https://cdn.spacemob.co/img/wellnessroom@2x.png";break;case"ELEC":case"ELECTRICAL CLOSET":c="https://cdn.spacemob.co/img/electrical@2x.png";break;case"FIRE":case"FIRE COMMAND CENTER":c="https://cdn.spacemob.co/img/fire_extinguisher@2x.png";break;case"MOP":case"JC":case"JANITOR":case"MOP CLOSET":c="https://cdn.spacemob.co/img/maintenance@2x.png";break;case"CONV. BOOTH":c=t}if(a.startsWith("IT ")&&(c=s),!c)switch(e){case"MEET":c=t}return c},F=function(e){for(var a=1/0,c=1/0,t=-1/0,s=-1/0,n=0;n<e.length;n++)a=Math.min(a,e[n].x),c=Math.min(c,e[n].y),t=Math.max(t,e[n].x),s=Math.max(s,e[n].y);return{width:t-a,height:s-c}},o=function(e,a,c){if(0!==e.length){var t=e[0];if(c.createInstancedMesh({id:a,mesh:{points:t.points,extrude:t.extrude}}),e.forEach(function(e){c.addToInstancedMesh({id:e.id,instancingId:a,style:{color:e.style.color},position:e.position,rotation:e.rotation,interactable:e.interactable,visible:e.visible})}),c.drawInstancedMesh({id:a}),t.style.outline&&t.style.outline.color){var s=a+"_OUTLINE";c.createInstancedMesh({id:s,mesh:{style:{outline:{color:t.style.outline.color,only:!0}},points:t.points,extrude:t.extrude}}),e.forEach(function(e){c.addToInstancedMesh({id:e.id+"_outline",instancingId:s,style:{color:e.style.color},position:e.position,rotation:e.rotation,visible:e.visible})}),c.drawInstancedMesh({id:s})}}};e.createRenderObjects=function(e){var s=e.id,a=e.shapes,c=e.type,t=e.subType,n=e.programType,r=e.roomNumber,o=e.hasWindow,i=e.locationAngle,p=e.centroid,E=[],l="BACK",h="#474747",g=1,O=!0,d=!1,T=B(n,6),b=P(n,6),u=_(n),m=K(n,t);if("object"===c)switch(t){case"CHAIR":u="rgb(206,206,206)",l="FRONT",b=-(6-(T=1))/2,h="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":u="rgb(246,241,241)",l="FRONT",T=.5,b=-1.5,g=.7,h="rgb(150,150,150)"}else"space"===c||"room"===c||console.warn("invalid type:",c);var R={only:!1,color:h};switch(t){case"HALLWAY":case"ELEV LOBBY":R=null}switch(n){case"MEET":switch(d=!0,t){case"NOOK":case"PHONE BOOTH":case"wt":d=!1}break;case"WORK":d=!0,o&&(u="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":R=null;break;default:n&&console.log("invalid programType:",n)}R&&(R.color=h);var f=a,A={z:b},M=null,x=null;if(!f||0===f.length)if(p)switch(t){case"CHAIR":f=W(),(A=p).z=b,M={z:i},O=!(x="CHAIRS");break;case"TABLE":f=H(),(A=p).z=b,M={z:i},O=!(x="TABLES");break;case"HOTDESK_TABLE":f=w(),(A=p).z=b,M={z:i},O=!(x="HOTDESK_TABLES")}else console.warn("centroid is not available",JSON.stringify(e));if(f&&0!==f.length){if(f.forEach(function(e,a){var c=s;0!==a&&(c=s+"/"+a);var t={id:c,type:"MESH",style:{color:u,side:l,outline:R,opacity:g},points:e,interactable:O,extrude:T,position:A,rotation:M,visible:!0};x&&(t.instancingId=x),E.push(t)}),d&&r){var y=k(f[0]),S={x:.5,y:.5};m&&(S.y=1.25);var I=F(f[0]).width/2*.8;3<I&&(I=2.9),E.push({id:s+"_TEXT",type:"TEXT",text:r,position:y,scalar:I,center:S,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(m){var C=k(f[0]),N={x:.5,y:.5};p&&((C=p).z=0),d&&r&&(N.y=.25);var L=3,v=F(f[0]);L>v.width?L=v.width-.1:L>v.height&&(L=v.height-.1),E.push({id:s+"_SPRITE",type:"SPRITE",position:C,scalar:1,center:N,style:{img:m,maxWidth:L},interactable:!1})}return E}console.warn("Invalid shapes",JSON.stringify(e))},e.getCenter=k,e.getSize=F,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(t,s){var n=new Map,r=function(){for(var e=0;e<t.length;e++){var a=t[e];if(a.instancingId){var c=n.get(a.instancingId);c||(c=[]),c.push(a),n.set(a.instancingId,c),t.splice(e,1),r()}}};r(),n.forEach(function(e,a,c){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 k(e){for(var a=1/0,c=1/0,t=-1/0,s=-1/0,n=0;n<e.length;n++)a=Math.min(a,e[n].x),c=Math.min(c,e[n].y),t=Math.max(t,e[n].x),s=Math.max(s,e[n].y);return{x:(t+a)/2,y:(s+c)/2}}var t="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",w=function(e,a){switch(e){case"CIRCULATE":case"WE":return.1;default:return a}},H=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}},B=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)"}},P=function(e,a){var c=null;switch(a.toUpperCase()){case"PHONE BOOTH":c="https://cdn.spacemob.co/img/phone_booth@2x.png";break;case"WT":case"NOOK":case"BOOTH":case"BOOTHS":c="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":c=n;break;case"GAME RM":case"GAME ROOM":case"DART BOARD":c="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":c="https://cdn.spacemob.co/img/wc_f@2x.png";break;case"MEN WC":case"MENS WC":case"MALE WC":case"M RESTROOM":c="https://cdn.spacemob.co/img/wc_m@2x.png";break;case"IT":c=s;break;case"PRINTER":case"PRINT":case"PRINTER NOOK":case"PRINTING ALCOVE":c="https://cdn.spacemob.co/img/printer@2x.png";break;case"MECH":case"MECHANICAL CLOSET":c="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":c="https://cdn.spacemob.co/img/storage@2x.png";break;case"TRASH":case"TRASH ROOM":c="https://cdn.spacemob.co/img/trash@2x.png";break;case"MOTHER RM":case"MOTHERS ROOM":c="https://cdn.spacemob.co/img/motherroom@2x.png";break;case"F&B":c=n;break;case"MAIL":case"MAIL & PACKAGE ROOM":c="https://cdn.spacemob.co/img/mail_room@2x.png";break;case"SHOWER":case"SHOWERS":c="https://cdn.spacemob.co/img/shower@2x.png";break;case"SERVICE LIFT":case"ELEVATOR FOYER":c="https://cdn.spacemob.co/img/servicelift@2x.png";break;case"WELLNESS RM":case"WELLNESS ROOM":case"FITNESS RM":c="https://cdn.spacemob.co/img/wellnessroom@2x.png";break;case"ELEC":case"ELECTRICAL CLOSET":c="https://cdn.spacemob.co/img/electrical@2x.png";break;case"FIRE":case"FIRE COMMAND CENTER":c="https://cdn.spacemob.co/img/fire_extinguisher@2x.png";break;case"MOP":case"JC":case"JANITOR":case"MOP CLOSET":c="https://cdn.spacemob.co/img/maintenance@2x.png";break;case"CONV. BOOTH":c=t}if(a.startsWith("IT ")&&(c=s),!c)switch(e){case"MEET":c=t}return c},_=function(e){for(var a=1/0,c=1/0,t=-1/0,s=-1/0,n=0;n<e.length;n++)a=Math.min(a,e[n].x),c=Math.min(c,e[n].y),t=Math.max(t,e[n].x),s=Math.max(s,e[n].y);return{width:t-a,height:s-c}},o=function(e,a,c){if(0!==e.length){var t=e[0];if(c.createInstancedMesh({id:a,mesh:{points:t.points,extrude:t.extrude}}),e.forEach(function(e){c.addToInstancedMesh({id:e.id,instancingId:a,style:{color:e.style.color},position:e.position,rotation:e.rotation,interactable:e.interactable,visible:e.visible})}),c.drawInstancedMesh({id:a}),t.style.outline&&t.style.outline.color){var s=a+"_OUTLINE";c.createInstancedMesh({id:s,mesh:{style:{outline:{color:t.style.outline.color,only:!0}},points:t.points,extrude:t.extrude}}),e.forEach(function(e){c.addToInstancedMesh({id:e.id+"_outline",instancingId:s,style:{color:e.style.color},position:e.position,rotation:e.rotation,visible:e.visible})}),c.drawInstancedMesh({id:s})}}};e.createRenderObjects=function(e){var s=e.id,a=e.shapes,c=e.type,t=e.subType,n=e.programType,r=e.roomNumber,o=e.hasWindow,i=e.locationAngle,p=e.centroid,E=e.instancingId,l=[],g="BACK",h="#474747",d=1,O=!0,b=!1,T=w(n,6),u=H(n,6),m=B(n),R=P(n,t);if("object"===c)switch(t){case"CHAIR":m="rgb(206,206,206)",g="FRONT",u=-(6-(T=1))/2,h="rgb(150,150,150)";break;case"TABLE":case"HOTDESK_TABLE":m="rgb(246,241,241)",g="FRONT",T=.5,u=-1.5,d=.7,h="rgb(150,150,150)"}else"space"===c||"room"===c||console.warn("invalid type:",c);var M={only:!1,color:h};switch(t){case"HALLWAY":case"ELEV LOBBY":M=null}switch(n){case"MEET":switch(b=!0,t){case"NOOK":case"PHONE BOOTH":case"wt":b=!1}break;case"WORK":b=!0,o&&(m="rgb(228,243,247)");break;case"WASH":case"SERVE":break;case"OPERATE":case"WE":break;case"CIRCULATE":M=null;break;default:n&&console.log("invalid programType:",n)}M&&(M.color=h);var f=a,A={z:u},I=null,S=null;if(E&&(p?((A=p).z=u,S=E,I={z:i},O=!1):console.warn("centroid is not available",JSON.stringify(e))),f&&0!==f.length){if(f.forEach(function(e,a){var c=s;0!==a&&(c=s+"/"+a);var t={id:c,type:"MESH",style:{color:m,side:g,outline:M,opacity:d},points:e,interactable:O,extrude:T,position:A,rotation:I,visible:!0};S&&(t.instancingId=S),l.push(t)}),b&&r){var x=k(f[0]),y={x:.5,y:.5};R&&(y.y=1.25);var C=_(f[0]).width/2*.8;3<C&&(C=2.9),l.push({id:s+"_TEXT",type:"TEXT",text:r,position:x,scalar:C,center:y,style:{color:"black",fontWeight:"bold"},interactable:!1})}if(R){var N=k(f[0]),L={x:.5,y:.5};p&&((N=p).z=0),b&&r&&(L.y=.25);var v=3,W=_(f[0]);v>W.width?v=W.width-.1:v>W.height&&(v=W.height-.1),l.push({id:s+"_SPRITE",type:"SPRITE",position:N,scalar:1,center:L,style:{img:R,maxWidth:v},interactable:!1})}return l}console.warn("Invalid shapes",JSON.stringify(e))},e.getCenter=k,e.getSize=_,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(t,s){var n=new Map,r=function(){for(var e=0;e<t.length;e++){var a=t[e];if(a.instancingId){var c=n.get(a.instancingId);c||(c=[]),c.push(a),n.set(a.instancingId,c),t.splice(e,1),r()}}};r(),n.forEach(function(e,a,c){o(e,a,s)})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=floormap-utils.umd.min.js.map |
{ | ||
"name": "@wework/floormap-utils", | ||
"version": "0.10.0", | ||
"version": "1.0.0-rc1", | ||
"jsnext:main": "dist/floormap-utils.es.js", | ||
@@ -5,0 +5,0 @@ "module": "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
101817
1775