diff --git a/dist/aframe-street-component.js b/dist/aframe-street-component.js index c782e765a..3d7981865 100644 --- a/dist/aframe-street-component.js +++ b/dist/aframe-street-component.js @@ -1 +1 @@ -!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var a in i)("object"==typeof exports?exports:t)[a]=i[a]}}(self,(function(){return t={631:t=>{var e=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2,new THREE.Vector2];function i(t,i,a,r){const n=1/r,s=1/a;return e[0].set(n*i,s*t+s),e[1].set(n*i,s*t),e[2].set(n*i+n,s*t),e[3].set(n*i+n,s*t+s),e}AFRAME.registerComponent("atlas-uvs",{dependencies:["geometry"],schema:{totalColumns:{type:"int",default:1},totalRows:{type:"int",default:1},column:{type:"int",default:1},row:{type:"int",default:1}},update:function(){const t=this.data,e=i(t.row-1,t.column-1,t.totalRows,t.totalColumns),a=this.el.getObject3D("mesh").geometry;var r=new Float32Array([e[0].x,e[0].y,e[3].x,e[3].y,e[1].x,e[1].y,e[2].x,e[2].y]);a.setAttribute("uv",new THREE.BufferAttribute(r,2)),a.uvsNeedUpdate=!0}}),AFRAME.registerComponent("dynamic-texture-atlas",{schema:{canvasId:{default:"dynamicAtlas"},canvasHeight:{default:1024},canvasWidth:{default:1024},debug:{default:!1},numColumns:{default:8},numRows:{default:8}},multiple:!0,init:function(){const t=this.canvas=document.createElement("canvas");t.id=this.data.canvasId,t.height=this.data.canvasHeight,t.width=this.data.canvasWidth,this.ctx=t.getContext("2d"),document.body.appendChild(t),this.data.debug&&(t.style.left=0,t.style.top=0,t.style.position="fixed",t.style.zIndex=9999999999)},drawTexture:function(t,e,a,r,n){const s=this.canvas,o=this.data;t.complete||(t.onload=()=>{this.drawTexture(t,e,a)});const l=n||s.height/o.numRows,d=r||s.width/o.numColumns;return this.ctx.drawImage(t,d*e,d*a,d,l),i(e,a,o.numRows,o.numColumns)}}),t.exports.getGridUvs=i},844:(t,e,i)=>{var a=i(199),r=i(394),n={"bike-lane":1.8,"drive-lane":3,divider:.3,"parking-lane":3,sidewalk:3,"sidewalk-tree":3,"turn-lane":3,"bus-lane":3,"light-rail":3,streetcar:3,"sidewalk-wayfinding":3,"sidewalk-lamp":3,"sidewalk-bike-rack":3,"sidewalk-bench":3,"scooter-drop-zone":3,scooter:1.8,bikeshare:3,"flex-zone-curb":3,"transit-shelter":3,temporary:3,"food-truck":3,"flex-zone":3,"outdoor-dining":3,parklet:3,utilities:3,"magic-carpet":3};function s(t){for(var e=t.objectMixinId,i=void 0===e?"":e,a=t.parentEl,r=void 0===a?null:a,n=t.step,s=void 0===n?15:n,o=t.radius,l=void 0===o?60:o,d=t.rotation,c=void 0===d?"0 0 0":d,m=t.positionXYString,u=void 0===m?"0 0":m,p=t.randomY,h=void 0!==p&&p,b=-1*l;b<=l;b+=s){var g=document.createElement("a-entity");g.setAttribute("class",i),g.setAttribute("position",u+" "+b),g.setAttribute("mixin",i),h?g.setAttribute("rotation","0 "+Math.floor(361*Math.random())+" 0"):g.setAttribute("rotation",c),r.append(g)}}function o(t){var e=document.createElement("a-entity");return e.setAttribute("class","stencils-parent"),e.setAttribute("position",t),e}function l(t){var e=document.createElement("a-entity");return e.setAttribute("class","track-parent"),e.setAttribute("position",t+" -0.2 0"),e}function d(t){var e=document.createElement("a-entity");return e.setAttribute("class","safehit-parent"),e.setAttribute("position",t+" 0 0"),e}function c(t,e){var i=document.createElement("a-entity");return i.setAttribute("class",e),i.setAttribute("position",t+" 0 0"),i}function m(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2.25,r=c(e,"dividers-".concat(t,"-parent"));return s({objectMixinId:"dividers-".concat(t),parentEl:r,step:a,radius:i}),r}function u(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2.25,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"0 0 0",n=c(e,"".concat(t,"-parent"));return s({objectMixinId:t,parentEl:n,step:a,radius:i,rotation:r}),n}function p(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1)+t)}function h(t,e){return Math.random()*(e-t)+t}function b(t,e,i){var a=Math.floor((e-t)/i)+1;return Array(a).fill().map((function(e,a){return t+a*i})).sort((function(){return.5-Math.random()}))}function g(t,e,i,a){var r,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"random",s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=[-.37*e,.37*e],l=b(-.5*a,.5*a,1.5);r="sparse"===i?parseInt(.0625*a,10):"normal"===i?parseInt(.125*a,10):parseInt(.25*a,10);for(var d=c(t,"pedestrians-parent"),m=0;m4&&void 0!==arguments[4]&&arguments[4],n=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];if(n){var s,o=5,l=a/o*1e3,d=t[0];s=("outbound"===d?Math.abs(-a/2-0):Math.abs(a/2-0))/o*1e3;var c=document.createElement("a-entity"),m=document.createElement("a-entity"),u="inbound"===t[0]?0:180;if(m.setAttribute("position",e+" 0 0"),m.setAttribute("rotation","0 "+u+" 0"),"car"===t[1])m.setAttribute("mixin","sedan-rig"),m.setAttribute("wheel",{speed:o,wheelDiameter:.76});else if("microvan"===t[1])m.setAttribute("mixin","suv-rig"),m.setAttribute("wheel",{speed:o,wheelDiameter:.84});else if("truck"===t[1])m.setAttribute("mixin","box-truck-rig"),m.setAttribute("wheel",{speed:o,wheelDiameter:1.05});else if("pedestrian"===t[1])return g(e,i,"normal",a,t[0],r);return r&&(m.setAttribute("animation__1","property","position"),m.setAttribute("animation__1","easing","linear"),m.setAttribute("animation__1","loop","false"),m.setAttribute("animation__2","property","position"),m.setAttribute("animation__2","easing","linear"),m.setAttribute("animation__2","loop","true"),"outbound"===d?(m.setAttribute("animation__1","to",{z:-a/2}),m.setAttribute("animation__1","dur",s),m.setAttribute("animation__2","from",{x:e,y:0,z:a/2}),m.setAttribute("animation__2","to",{x:e,y:0,z:-a/2}),m.setAttribute("animation__2","delay",s),m.setAttribute("animation__2","dur",l)):(m.setAttribute("animation__1","to",{z:a/2}),m.setAttribute("animation__1","dur",s),m.setAttribute("animation__2","from",{x:e,y:0,z:-a/2}),m.setAttribute("animation__2","to",{x:e,y:0,z:a/2}),m.setAttribute("animation__2","delay",s),m.setAttribute("animation__2","dur",l))),c.append(m),c}}function A(t,e){var i=document.createElement("a-entity"),a=document.createElement("a-entity"),r="left"===t[0]?0:180;return a.setAttribute("position",e+" 0 0"),a.setAttribute("rotation","0 "+r+" 0"),a.setAttribute("mixin","food-trailer"),i.append(a),i}function _(t,e){if(e){var i=document.createElement("a-entity"),a=document.createElement("a-entity");a.setAttribute("position",t+" 1.75 0"),a.setAttribute("rotation","0 0 0"),a.setAttribute("mixin","magic-carpet"),i.append(a);var r=document.createElement("a-entity");return r.setAttribute("position",t+" 1.75 0"),r.setAttribute("rotation","0 0 0"),r.setAttribute("mixin","Character_1_M"),i.append(r),i}}function w(t){var e=document.createElement("a-entity"),i=document.createElement("a-entity");return i.setAttribute("position",t+" 0 0"),i.setAttribute("mixin","outdoor_dining"),e.append(i),e}function E(t,e,i,a){if(a){var r=document.createElement("a-entity"),n=document.createElement("a-entity"),s="inbound"===t[0]?0:180;return n.setAttribute("position",e+" 0 0"),n.setAttribute("rotation","0 "+s+" 0"),"bike-lane"===i?n.setAttribute("mixin","Bicycle_1"):n.setAttribute("mixin","ElectricScooter_1"),r.append(n),r}}function k(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(i){var a=document.createElement("a-entity"),r=document.createElement("a-entity"),n="inbound"===t[1]?0:180;return r.setAttribute("position",e+" 0 0"),r.setAttribute("rotation","0 "+n+" 0"),"taxi"===t[0]?r.setAttribute("mixin","sedan-taxi"):"rideshare"===t[0]&&r.setAttribute("mixin","sedan"),a.append(r),a}}function M(t){var e,i=document.createElement("a-entity");return(e=document.createElement("a-entity")).setAttribute("position",t+" 1 0"),e.setAttribute("mixin","wayfinding-box"),i.append(e),(e=document.createElement("a-entity")).setAttribute("position",t+" 1.2 0.06"),e.setAttribute("geometry","primitive: plane; width: 0.8; height: 1.6"),e.setAttribute("material","src:#wayfinding-map"),i.append(e),(e=document.createElement("a-entity")).setAttribute("position",t+" 1.2 -0.06"),e.setAttribute("rotation","0 180 0"),e.setAttribute("geometry","primitive: plane; width: 0.8; height: 1.6"),e.setAttribute("material","src:#wayfinding-map"),i.append(e),i}function C(t){var e=document.createElement("a-entity");return e.setAttribute("class","bench-parent"),e.setAttribute("position",t+" 0 3.5"),e}function j(t){var e=document.createElement("a-entity");return e.setAttribute("class","bikerack-parent"),e.setAttribute("position",t+" 0 -3.5"),e}function S(t,e){var i=document.createElement("a-entity");i.setAttribute("class","bikeshare"),i.setAttribute("position",t+" 0 0"),i.setAttribute("mixin","bikeshare");var a="left"===e[0]?90:270;return i.setAttribute("rotation","0 "+a+" 0"),i}function R(t,e){var i=document.createElement("a-entity");i.setAttribute("class","parklet"),i.setAttribute("position",t+" .02 0"),i.setAttribute("mixin","parklet");var a="left"===e[0]?90:270;return i.setAttribute("rotation","0 "+a+" 0"),i}function z(t){var e=document.createElement("a-entity");return e.setAttribute("class","tree-parent"),e.setAttribute("position",t+" 0 7"),e}function I(t){var e=document.createElement("a-entity");return e.setAttribute("class","lamp-parent"),e.setAttribute("position",t+" 0 0"),e}function B(t,e){var i=document.createElement("a-entity");return i.setAttribute("class","bus-stop"),i.setAttribute("position",t+" 0 0"),i.setAttribute("rotation","0 "+e+" 0"),i.setAttribute("mixin","bus-stop"),i}function L(t,e,i,a,r,n,s){var o=document.createElement("a-entity"),l=t+" "+n/150+" 1";return o.setAttribute("scale",l),o.setAttribute("position",e+" "+i+" 0"),s&&o.setAttribute("material","repeat: 1 ".concat(s)),o.setAttribute("rotation","270 "+a+" 0"),o.setAttribute("mixin",r),o}t.exports.processSegments=function(t,e,i,c,p){var h=i/2;i>12&&(h=(i-12)/2),e&&(t=function(t){function e(t){return"lane"===t.slice(t.length-4)||"light-rail"===t||"streetcar"===t||"flex-zone"===t}return t.reduce((function(t,i,a,r){if(0===a)return t.concat(i);var n=r[a-1];if(e(i.type)&&e(n.type)){var s="solid";i.type===n.type&&(s="dashed"),("drive-lane"===i.type&&"turn-lane"===n.type||"drive-lane"===n.type&&"turn-lane"===i.type)&&(s="dashed"),i.variantString.split("|")[0]!==n.variantString.split("|")[0]&&(s="doubleyellow","bike-lane"===i.type&&"bike-lane"===n.type&&(s="shortdashedyellow"),"flex-zone"!==i.type&&"flex-zone"!==n.type||(s="solid")),"turn-lane"===i.type&&"shared"===i.variantString.split("|")[1]?s="soliddashedyellow":"turn-lane"===n.type&&"shared"===n.variantString.split("|")[1]&&(s="soliddashedyellowinverted"),"parking-lane"!==i.type&&"parking-lane"!==n.type||(s="invisible"),t.push({type:"separator",variantString:s,width:0})}return(e(i.type)&&"divider"===n.type||e(n.type)&&"divider"===i.type)&&t.push({type:"separator",variantString:"solid",width:0}),t.push(i),t}),[])}(t));var b=function(t){var e=document.createElement("a-entity"),i=0-r.calcStreetWidth(t)/2;return e.setAttribute("position",i+" 0 0"),e}(t);b.classList.add("street-parent");for(var F,D=0,O=0;O{var t,e;t=!1,e=new THREE.FileLoader,window.AFRAME.registerElement("streetmix-assets",{prototype:Object.create(window.AFRAME.ANode.prototype,{createdCallback:{value:function(){this.setAttribute("src",""),this.isAssetItem=!0,this.isAssets=!0,this.fileLoader=e,this.timeout=null}},attachedCallback:{value:function(){if(!t){var e;this.parentNode&&this.parentNode.hasLoaded&&console.warn("Assets have already loaded. streetmix-assets may have problems"),t=!0,this.innerHTML=((e=this.getAttribute("url"))||(e="https://assets.3dstreet.app/"),console.log("[street]","Using street assets from",e),'\n \x3c!-- sidewalk props --\x3e\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \x3c!-- human characters --\x3e\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \x3c!-- vehicles --\x3e\n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \x3c!-- vehicles rigged --\x3e\n \n \n \n \n \n \n \n \n \n \n\n \x3c!-- micro mobility vehicles --\x3e\n \n \n \n\n \x3c!-- blocks --\x3e\n \n \n\n \x3c!-- buildings and blocks --\x3e\n \n \n\n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \x3c!-- optimized textures - used by default --\x3e\n \n \n \n \n \n \n \n \n \n \n \n \n\n \x3c!-- lane separator markings atlas --\x3e\n \n \n \n \n \n \n \n \n \x3c!-- color modifier mixins --\x3e\n \n \n \n \n \x3c!-- stencils atlas --\x3e\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \x3c!-- vehicles --\x3e\n \n \n \n \n \x3c!-- street props --\x3e\n \n \n \n \n\n \x3c!-- dividers --\x3e\n \n \n \n \n \n \n \n \n \n \n\n \x3c!-- sky --\x3e\n \n \n\n \x3c!-- grounds --\x3e\n \n \n \n\n \n \n \n \n \x3c!-- ui / future use --\x3e\n \n '));var i=this.parentNode;this.setAttribute("timeout",i.getAttribute("timeout")),this.parentNode.isScene=!0,Object.getPrototypeOf(i).attachedCallback.call(this),this.parentNode.isScene=!1}}},load:{value:function(){AFRAME.ANode.prototype.load.call(this,null,(function(t){return t.isAssetItem&&t.hasAttribute("src")}))}}})}),window.addEventListener("DOMContentLoaded",(function(e){if(!t){var i=document.querySelector("a-assets");i||(i=document.createElement("a-assets")),i.hasLoaded&&console.warn("Assets already loaded. May lead to bugs");var a=document.createElement("streetmix-assets");i.append(a),document.querySelector("a-scene").append(i)}})),document.addEventListener("DOMSubtreeModified",(function t(e){if("A-SCENE"===e.target.nodeName){var i=e.target.querySelector("a-assets");if(i||(i=document.createElement("a-assets"),e.target.append(i)),i.querySelector("streetmix-assets"))document.removeEventListener("DOMSubtreeModified",t);else{var a=document.createElement("streetmix-assets");i.append(a),document.removeEventListener("DOMSubtreeModified",t)}}}),!1)},391:(t,e,i)=>{var a=i(334);AFRAME.registerComponent("create-from-json",{schema:{jsonString:{type:"string",default:""}},update:function(t){var e=this.data,i=this.el;if(t.string&&e.string!==t.string)for(;i.firstChild;)i.removeChild(i.lastChild);a.appendChildElementsFromArray(JSON.parse(e.jsonString),i)}})},579:(t,e,i)=>{var a=i(844),r=i(394);i(234),i(391),i(631),i(172),AFRAME.registerComponent("street",{schema:{JSON:{type:"string"},type:{default:"streetmixSegmentsFeet"},left:{default:""},right:{default:""},showGround:{default:!0},showStriping:{default:!0},showVehicles:{default:!0},globalAnimated:{default:!1},length:{default:150}},update:function(t){var e=this.data;if(0!==e.JSON.length){var i=JSON.parse(e.JSON),n=a.processSegments(i.streetmixSegmentsFeet,e.showStriping,e.length,e.globalAnimated,e.showVehicles);if(this.el.append(n),e.left||e.right){var s=r.calcStreetWidth(i.streetmixSegmentsFeet,e.autoStriping),o=a.processBuildings(e.left,e.right,s,e.showGround,e.length);this.el.append(o)}}else{if(void 0!==t.JSON&&0===t.JSON.length)return;console.log("[street]","No JSON provided yet, but it might be set at runtime")}}}),AFRAME.registerComponent("streetmix-loader",{dependencies:["street"],schema:{streetmixStreetURL:{type:"string"},streetmixAPIURL:{type:"string"},showBuildings:{default:!0},name:{default:""}},update:function(t){var e=this.data,i=this.el;if(t.streetmixStreetURL!==e.streetmixStreetURL||t.streetmixAPIURL!==e.streetmixAPIURL)if(0!==e.streetmixAPIURL.length){var a=new XMLHttpRequest;console.log("[streetmix-loader]","GET "+e.streetmixAPIURL),a.open("GET",e.streetmixAPIURL,!0),a.onload=function(){if(this.status>=200&&this.status<400){var t=JSON.parse(this.response),a=t.data.street.segments,r=t.name;i.setAttribute("streetmix-loader","name",r),e.showBuildings&&(i.setAttribute("street","right",t.data.street.rightBuildingVariant),i.setAttribute("street","left",t.data.street.leftBuildingVariant)),i.setAttribute("street","type","streetmixSegmentsFeet"),i.setAttribute("street","JSON",JSON.stringify({streetmixSegmentsFeet:a})),i.emit("streetmix-loader-street-loaded")}else console.log("[streetmix-loader]","Loading Error: We reached the target server, but it returned an error")},a.onerror=function(){console.log("[streetmix-loader]","Loading Error: There was a connection error of some sort")},a.send()}else{if(e.streetmixStreetURL.length>0){var n=r.streetmixUserToAPI(e.streetmixStreetURL);return console.log("[streetmix-loader]","setting `streetmixAPIURL` to",n),void i.setAttribute("streetmix-loader","streetmixAPIURL",n)}console.log("[streetmix-loader]","Neither `streetmixAPIURL` nor `streetmixStreetURL` properties provided, please provide at least one.")}}}),AFRAME.registerComponent("intersection",{schema:{dimensions:{type:"string",default:"20 20"},sidewalk:{type:"string",default:"0 0 0 0"},northeastcurb:{type:"string",default:"0 0"},southwestcurb:{type:"string",default:"0 0"},southeastcurb:{type:"string",default:"0 0"},northwestcurb:{type:"string",default:"0 0"},stopsign:{type:"string",default:"0 0 0 0"},trafficsignal:{type:"string",default:"0 0 0 0"},crosswalk:{type:"string",default:"0 0 0 0"}},init:function(){var t=this.data,e=this.el,i=t.dimensions.split(" ").map((function(t){return Number(t)})),a=[this.el.getAttribute("position").x,this.el.getAttribute("position").y,this.el.getAttribute("position").z],r=t.sidewalk.split(" ").map((function(t){return Number(t)})),n=t.northeastcurb.split(" ").map((function(t){return Number(t)})),s=t.southwestcurb.split(" ").map((function(t){return Number(t)})),o=t.southeastcurb.split(" ").map((function(t){return Number(t)})),l=t.northwestcurb.split(" ").map((function(t){return Number(t)})),d=t.stopsign.split(" ").map((function(t){return Number(t)})),c=t.trafficsignal.split(" ").map((function(t){return Number(t)})),m=t.crosswalk.split(" ").map((function(t){return Number(t)}));this.geometry=new THREE.PlaneGeometry(i[0],i[1],1,1),this.material=new THREE.MeshStandardMaterial({color:"#FF0000"}),this.mesh=new THREE.Mesh(this.geometry,this.material),e.setObject3D("mesh",this.mesh),this.el.setAttribute("position",{x:a[0],y:a[1],z:a[2]}),this.el.setAttribute("rotation","-90 0 0"),this.el.setAttribute("material","src: #asphalt-texture; repeat:5 5; roughness:1");var u=document.createElement("a-entity");u.setAttribute("position",{x:i[0]/2-r[0]/2,z:.04}),u.setAttribute("scale","x",r[0]/3),u.setAttribute("scale","y",i[1]/150),u.setAttribute("rotation",{x:0,y:0,z:0}),u.setAttribute("mixin","sidewalk"),e.appendChild(u);var p=document.createElement("a-entity");p.setAttribute("position",{x:-i[0]/2+r[1]/2,z:.05}),p.setAttribute("scale","x",r[1]/3),p.setAttribute("scale","y",i[1]/150),p.setAttribute("rotation",{x:0,y:0,z:0}),p.setAttribute("mixin","sidewalk"),e.appendChild(p);var h=document.createElement("a-entity");h.setAttribute("position",{y:-i[1]/2+r[2]/2,z:.03}),h.setAttribute("scale","x",r[2]/3),h.setAttribute("scale","y",i[0]/150),h.setAttribute("rotation",{x:0,y:0,z:-90}),h.setAttribute("mixin","sidewalk"),e.appendChild(h);var b=document.createElement("a-entity");b.setAttribute("position",{y:i[1]/2-r[3]/2,z:.03}),b.setAttribute("scale","x",r[3]/3),b.setAttribute("scale","y",i[0]/150),b.setAttribute("rotation",{x:0,y:0,z:-90}),b.setAttribute("mixin","sidewalk"),e.appendChild(b);var g=document.createElement("a-entity");g.setAttribute("position",{x:i[0]/2-n[0]/2,y:i[1]/2-n[1]/2,z:.022}),g.setAttribute("scale","x",n[0]/3),g.setAttribute("scale","y",n[1]/150),g.setAttribute("mixin","sidewalk"),e.appendChild(g);var x=document.createElement("a-entity");x.setAttribute("position",{x:-i[0]/2+s[0]/2,y:-i[1]/2+s[1]/2,z:.022}),x.setAttribute("scale","x",s[0]/3),x.setAttribute("scale","y",s[1]/150),x.setAttribute("mixin","sidewalk"),e.appendChild(x);var f=document.createElement("a-entity");f.setAttribute("position",{x:i[0]/2-o[0]/2,y:-i[1]/2+o[1]/2,z:.022}),f.setAttribute("scale","x",o[0]/3),f.setAttribute("scale","y",o[1]/150),f.setAttribute("mixin","sidewalk"),e.appendChild(f);var y=document.createElement("a-entity");if(y.setAttribute("position",{x:-i[0]/2+l[0]/2,y:i[1]/2-l[1]/2,z:.022}),y.setAttribute("scale","x",l[0]/3),y.setAttribute("scale","y",l[1]/150),y.setAttribute("mixin","sidewalk"),e.appendChild(y),d[0]){var v=document.createElement("a-entity");v.setAttribute("position",{x:i[0]/2,y:i[1]/3,z:.03}),v.setAttribute("rotation",{x:0,y:90,z:90}),v.setAttribute("mixin","stop_sign"),e.appendChild(v)}if(d[1]){var A=document.createElement("a-entity");A.setAttribute("position",{x:-i[0]/2,y:-i[1]/3,z:.03}),A.setAttribute("rotation",{x:0,y:-90,z:-90}),A.setAttribute("mixin","stop_sign"),e.appendChild(A)}if(d[2]){var _=document.createElement("a-entity");_.setAttribute("position",{x:-i[0]/3,y:i[1]/2,z:.03}),_.setAttribute("rotation",{x:-90,y:90,z:90}),_.setAttribute("mixin","stop_sign"),e.appendChild(_)}if(d[3]){var w=document.createElement("a-entity");w.setAttribute("position",{x:i[0]/3,y:-i[1]/2,z:.03}),w.setAttribute("rotation",{x:90,y:-90,z:-90}),w.setAttribute("mixin","stop_sign"),e.appendChild(w)}if(c[0]){var E=document.createElement("a-entity");E.setAttribute("position",{x:i[0]/2,y:i[1]/3,z:.03}),E.setAttribute("rotation",{x:210,y:90,z:90}),E.setAttribute("mixin","signal_left"),e.appendChild(E);var k=document.createElement("a-entity");k.setAttribute("position",{x:i[0]/2,y:-i[1]/3,z:.03}),k.setAttribute("rotation",{x:180,y:90,z:90}),k.setAttribute("mixin","signal_right"),e.appendChild(k)}if(c[1]){var M=document.createElement("a-entity");M.setAttribute("position",{x:-i[0]/2,y:-i[1]/3,z:.03}),M.setAttribute("rotation",{x:30,y:90,z:90}),M.setAttribute("mixin","signal_left"),e.appendChild(M);var C=document.createElement("a-entity");C.setAttribute("position",{x:-i[0]/2,y:i[1]/3,z:.03}),C.setAttribute("rotation",{x:0,y:90,z:90}),C.setAttribute("mixin","signal_right"),e.appendChild(C)}if(c[2]){var j=document.createElement("a-entity");j.setAttribute("position",{x:-i[0]/3,y:i[1]/2,z:.03}),j.setAttribute("rotation",{x:120,y:90,z:90}),j.setAttribute("mixin","signal_left"),e.appendChild(j);var S=document.createElement("a-entity");S.setAttribute("position",{x:i[0]/3,y:i[1]/2,z:.03}),S.setAttribute("rotation",{x:90,y:90,z:90}),S.setAttribute("mixin","signal_right"),e.appendChild(S)}if(c[3]){var R=document.createElement("a-entity");R.setAttribute("position",{x:i[0]/3,y:-i[1]/2,z:.03}),R.setAttribute("rotation",{x:-60,y:90,z:90}),R.setAttribute("mixin","signal_left"),e.appendChild(R);var z=document.createElement("a-entity");z.setAttribute("position",{x:-i[0]/3,y:-i[1]/2,z:.03}),z.setAttribute("rotation",{x:-90,y:90,z:90}),z.setAttribute("mixin","signal_right"),e.appendChild(z)}if(m[0]){var I=document.createElement("a-entity");I.setAttribute("position",{x:i[0]/2-2,z:.013}),I.setAttribute("rotation",{x:0,y:0,z:180}),I.setAttribute("scale",{y:i[1]/12}),I.setAttribute("mixin","markings crosswalk-zebra"),e.appendChild(I)}if(m[1]){var B=document.createElement("a-entity");B.setAttribute("position",{x:-i[0]/2+2,z:.012}),B.setAttribute("rotation",{x:0,y:0,z:180}),B.setAttribute("scale",{y:i[1]/12}),B.setAttribute("mixin","markings crosswalk-zebra"),e.appendChild(B)}if(m[2]){var L=document.createElement("a-entity");L.setAttribute("position",{y:-i[1]/2+2,z:.011}),L.setAttribute("rotation",{x:0,y:0,z:90}),L.setAttribute("scale",{y:i[0]/12}),L.setAttribute("mixin","markings crosswalk-zebra"),e.appendChild(L)}if(m[3]){var F=document.createElement("a-entity");F.setAttribute("position",{y:i[1]/2-2,z:.01}),F.setAttribute("rotation",{x:0,y:0,z:90}),F.setAttribute("scale",{y:i[0]/12}),F.setAttribute("mixin","markings crosswalk-zebra"),e.appendChild(F)}}}),AFRAME.registerComponent("street-environment",{schema:{preset:{type:"string",default:"day",oneOf:["day","night"]}},init:function(){var t=this.data,e=this.el;if("night"===t.preset){var i=document.createElement("a-entity");i.setAttribute("id","light"),i.setAttribute("light",{type:"ambient",color:"#FFF",intensity:.5}),e.appendChild(i);var a=document.createElement("a-entity");a.setAttribute("id","light"),a.setAttribute("position",{x:.5,y:1,z:-1}),a.setAttribute("light",{type:"directional",color:"#FFF",intensity:.15}),e.appendChild(a);var r=document.createElement("a-sky");r.setAttribute("id","sky"),r.setAttribute("color","#444"),r.setAttribute("src","#sky-night"),e.appendChild(r)}else{var n=document.createElement("a-entity");n.setAttribute("id","light"),n.setAttribute("light",{type:"ambient",color:"#FFF",intensity:2}),e.appendChild(n);var s=document.createElement("a-entity");s.setAttribute("id","light"),s.setAttribute("position",{x:.5,y:1,z:-1}),s.setAttribute("light",{type:"directional",color:"#FFF",intensity:.6}),e.appendChild(s);var o=document.createElement("a-sky");o.setAttribute("id","sky"),o.setAttribute("src","#sky"),o.setAttribute("rotation","0 255 0"),e.appendChild(o)}}}),AFRAME.registerComponent("wheel",{schema:{speed:{type:"number",default:1},wheelDiameter:{type:"number",default:1}},init:function(){var t=this.el,e=this;t.addEventListener("model-loaded",(function(i){var a=t.getObject3D("mesh");a&&(e.wheel_F_L=a.getObjectByName("wheel_F_L"),e.wheel_F_R=a.getObjectByName("wheel_F_R"),e.wheel_B_L=a.getObjectByName("wheel_B_L"),e.wheel_B_R=a.getObjectByName("wheel_B_R"),e.wheel_B_L_2=a.getObjectByName("wheel_B_L_2"),e.wheel_B_R_2=a.getObjectByName("wheel_B_R_2"),e.main_bone=a.getObjectByName("main_bone"))}))},tick:function(){var t=this.data.speed,e=this.data.wheelDiameter,i=.003*t/(Math.PI*e)*(2*Math.PI);this.wheel_F_L&&this.wheel_F_L.rotateY(i),this.wheel_F_R&&this.wheel_F_R.rotateY(i),this.wheel_B_L&&this.wheel_B_L.rotateY(i),this.wheel_B_L_2&&this.wheel_B_L_2.rotateY(i),this.wheel_B_R_2&&this.wheel_B_R_2.rotateY(i),this.wheel_B_R&&this.wheel_B_R.rotateY(i)}})},172:()=>{function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=new Array(e);i=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){a=e[Symbol.iterator]()},n:function(){var t=a.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==a.return||a.return()}finally{if(l)throw s}}}}(l);try{for(m.s();!(n=m.n()).done;)n.value,d+=1}catch(t){m.e(t)}finally{m.f()}var u=this.el.getObject3D("mesh");if(u){var p=u.material.clone(),h=null;u.traverse((function(t){!0===t.isMesh&&(h=t.geometry)}));for(var b=new THREE.InstancedMesh(h,p,d),g=0;g{t.exports.isSidewalk=function(t){return t.startsWith("sidewalk")||["utilities","scooter-drop-zone","bikeshare","flex-zone-curb","transit-shelter"].includes(t)},t.exports.createBuildingsArray=function(){var t,e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:150,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"narrow";"narrow"===a||"wide"===a?(t=[{id:"SM3D_Bld_Mixed_4fl",width:5.25221},{id:"SM3D_Bld_Mixed_Double_5fl",width:10.9041},{id:"SM3D_Bld_Mixed_4fl_2",width:5.58889},{id:"SM3D_Bld_Mixed_5fl",width:6.47593},{id:"SM3D_Bld_Mixed_Corner_4fl",width:6.94809}],e="41431323432402434130303230234102402341"):"residential"===a&&(t=[{id:"SM_Bld_House_Preset_03_1800",width:20},{id:"SM_Bld_House_Preset_08_1809",width:20},{id:"SM_Bld_House_Preset_09_1845",width:20}],e="12021201210101212021201012012021201210");for(var r=0,n=0,s=[];n{function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var i=[],a=!0,r=!1,n=void 0;try{for(var s,o=t[Symbol.iterator]();!(a=(s=o.next()).done)&&(i.push(s.value),!e||i.length!==e);a=!0);}catch(t){r=!0,n=t}finally{try{a||null==o.return||o.return()}finally{if(r)throw n}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=new Array(e);i0&&void 0!==arguments[0]?arguments[0]:{},i=document.createElement(t.tag);delete t.tag;for(var a=0,r=Object.entries(t);a0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0;return t.forEach((function(t,i){e.appendChild(a(t))})),e}},394:t=>{t.exports.streetmixUserToAPI=function(t){var e=new URL(t).pathname.split("/"),i=e[1],a=e[2];return"-"===i?"https://streetmix.net/api/v1/streets?namespacedId="+a:"https://streetmix.net/api/v1/streets?namespacedId="+a+"&creatorId="+i},t.exports.pathStartsWithAPI=function(t){var e=document.createElement("a");return e.href=t,"api"===e.pathname.split("/")[1]},t.exports.streetmixAPIToUser=function(t){function e(t,e){for(var i=t.split("&"),a=0;a{var e=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2,new THREE.Vector2];function i(t,i,a,r){const n=1/r,s=1/a;return e[0].set(n*i,s*t+s),e[1].set(n*i,s*t),e[2].set(n*i+n,s*t),e[3].set(n*i+n,s*t+s),e}AFRAME.registerComponent("atlas-uvs",{dependencies:["geometry"],schema:{totalColumns:{type:"int",default:1},totalRows:{type:"int",default:1},column:{type:"int",default:1},row:{type:"int",default:1}},update:function(){const t=this.data,e=i(t.row-1,t.column-1,t.totalRows,t.totalColumns),a=this.el.getObject3D("mesh").geometry;var r=new Float32Array([e[0].x,e[0].y,e[3].x,e[3].y,e[1].x,e[1].y,e[2].x,e[2].y]);a.setAttribute("uv",new THREE.BufferAttribute(r,2)),a.uvsNeedUpdate=!0}}),AFRAME.registerComponent("dynamic-texture-atlas",{schema:{canvasId:{default:"dynamicAtlas"},canvasHeight:{default:1024},canvasWidth:{default:1024},debug:{default:!1},numColumns:{default:8},numRows:{default:8}},multiple:!0,init:function(){const t=this.canvas=document.createElement("canvas");t.id=this.data.canvasId,t.height=this.data.canvasHeight,t.width=this.data.canvasWidth,this.ctx=t.getContext("2d"),document.body.appendChild(t),this.data.debug&&(t.style.left=0,t.style.top=0,t.style.position="fixed",t.style.zIndex=9999999999)},drawTexture:function(t,e,a,r,n){const s=this.canvas,o=this.data;t.complete||(t.onload=()=>{this.drawTexture(t,e,a)});const l=n||s.height/o.numRows,d=r||s.width/o.numColumns;return this.ctx.drawImage(t,d*e,d*a,d,l),i(e,a,o.numRows,o.numColumns)}}),t.exports.getGridUvs=i},844:(t,e,i)=>{var a=i(199),r=i(394),n={"bike-lane":1.8,"drive-lane":3,divider:.3,"parking-lane":3,sidewalk:3,"sidewalk-tree":3,"turn-lane":3,"bus-lane":3,"light-rail":3,streetcar:3,"sidewalk-wayfinding":3,"sidewalk-lamp":3,"sidewalk-bike-rack":3,"sidewalk-bench":3,"scooter-drop-zone":3,scooter:1.8,bikeshare:3,"flex-zone-curb":3,"transit-shelter":3,temporary:3,"food-truck":3,"flex-zone":3,"outdoor-dining":3,parklet:3,utilities:3,"magic-carpet":3};function s(t){for(var e=t.objectMixinId,i=void 0===e?"":e,a=t.parentEl,r=void 0===a?null:a,n=t.step,s=void 0===n?15:n,o=t.radius,l=void 0===o?60:o,d=t.rotation,c=void 0===d?"0 0 0":d,m=t.positionXYString,u=void 0===m?"0 0":m,p=t.randomY,h=void 0!==p&&p,b=-1*l;b<=l;b+=s){var g=document.createElement("a-entity");g.setAttribute("class",i),g.setAttribute("position",u+" "+b),g.setAttribute("mixin",i),h?g.setAttribute("rotation","0 "+Math.floor(361*Math.random())+" 0"):g.setAttribute("rotation",c),r.append(g)}}function o(t){var e=document.createElement("a-entity");return e.setAttribute("class","stencils-parent"),e.setAttribute("position",t),e}function l(t){var e=document.createElement("a-entity");return e.setAttribute("class","track-parent"),e.setAttribute("position",t+" -0.2 0"),e}function d(t){var e=document.createElement("a-entity");return e.setAttribute("class","safehit-parent"),e.setAttribute("position",t+" 0 0"),e}function c(t,e){var i=document.createElement("a-entity");return i.setAttribute("class",e),i.setAttribute("position",t+" 0 0"),i}function m(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2.25,r=c(e,"dividers-".concat(t,"-parent"));return s({objectMixinId:"dividers-".concat(t),parentEl:r,step:a,radius:i}),r}function u(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2.25,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"0 0 0",n=c(e,"".concat(t,"-parent"));return s({objectMixinId:t,parentEl:n,step:a,radius:i,rotation:r}),n}function p(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1)+t)}function h(t,e){return Math.random()*(e-t)+t}function b(t,e,i){var a=Math.floor((e-t)/i)+1;return Array(a).fill().map((function(e,a){return t+a*i})).sort((function(){return.5-Math.random()}))}function g(t,e,i,a){var r,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"random",s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=[-.37*e,.37*e],l=b(-.5*a,.5*a,1.5);r="sparse"===i?parseInt(.0625*a,10):"normal"===i?parseInt(.125*a,10):parseInt(.25*a,10);for(var d=c(t,"pedestrians-parent"),m=0;m4&&void 0!==arguments[4]&&arguments[4],n=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];if(n){var s,o=.5,l=a/o*1e3,d=t[0];s=("outbound"===d?Math.abs(-a/2-0):Math.abs(a/2-0))/o*1e3;var c=document.createElement("a-entity"),m=document.createElement("a-entity"),u="inbound"===t[0]?0:180;if(m.setAttribute("position",e+" 0 0"),m.setAttribute("rotation","0 "+u+" 0"),"car"===t[1])m.setAttribute("mixin","sedan-rig"),m.setAttribute("wheel",{speed:o,wheelDiameter:.76});else if("microvan"===t[1])m.setAttribute("mixin","suv-rig"),m.setAttribute("wheel",{speed:o,wheelDiameter:.84});else if("truck"===t[1])m.setAttribute("mixin","box-truck-rig"),m.setAttribute("wheel",{speed:o,wheelDiameter:1.05});else if("pedestrian"===t[1])return g(e,i,"normal",a,t[0],r);return r&&(m.setAttribute("animation__1","property","position"),m.setAttribute("animation__1","easing","linear"),m.setAttribute("animation__1","loop","false"),m.setAttribute("animation__2","property","position"),m.setAttribute("animation__2","easing","linear"),m.setAttribute("animation__2","loop","true"),"outbound"===d?(m.setAttribute("animation__1","to",{z:-a/2}),m.setAttribute("animation__1","dur",s),m.setAttribute("animation__2","from",{x:e,y:0,z:a/2}),m.setAttribute("animation__2","to",{x:e,y:0,z:-a/2}),m.setAttribute("animation__2","delay",s),m.setAttribute("animation__2","dur",l)):(m.setAttribute("animation__1","to",{z:a/2}),m.setAttribute("animation__1","dur",s),m.setAttribute("animation__2","from",{x:e,y:0,z:-a/2}),m.setAttribute("animation__2","to",{x:e,y:0,z:a/2}),m.setAttribute("animation__2","delay",s),m.setAttribute("animation__2","dur",l))),c.append(m),c}}function A(t,e){var i=document.createElement("a-entity"),a=document.createElement("a-entity"),r="left"===t[0]?0:180;return a.setAttribute("position",e+" 0 0"),a.setAttribute("rotation","0 "+r+" 0"),a.setAttribute("mixin","food-trailer"),i.append(a),i}function _(t,e){if(e){var i=document.createElement("a-entity"),a=document.createElement("a-entity");a.setAttribute("position",t+" 1.75 0"),a.setAttribute("rotation","0 0 0"),a.setAttribute("mixin","magic-carpet"),i.append(a);var r=document.createElement("a-entity");return r.setAttribute("position",t+" 1.75 0"),r.setAttribute("rotation","0 0 0"),r.setAttribute("mixin","Character_1_M"),i.append(r),i}}function w(t){var e=document.createElement("a-entity"),i=document.createElement("a-entity");return i.setAttribute("position",t+" 0 0"),i.setAttribute("mixin","outdoor_dining"),e.append(i),e}function E(t,e,i,a){if(a){var r=document.createElement("a-entity"),n=document.createElement("a-entity"),s="inbound"===t[0]?0:180;return n.setAttribute("position",e+" 0 0"),n.setAttribute("rotation","0 "+s+" 0"),"bike-lane"===i?n.setAttribute("mixin","Bicycle_1"):n.setAttribute("mixin","ElectricScooter_1"),r.append(n),r}}function k(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(i){var a=document.createElement("a-entity"),r=document.createElement("a-entity"),n="inbound"===t[1]?0:180;return r.setAttribute("position",e+" 0 0"),r.setAttribute("rotation","0 "+n+" 0"),"taxi"===t[0]?r.setAttribute("mixin","sedan-taxi"):"rideshare"===t[0]&&r.setAttribute("mixin","sedan"),a.append(r),a}}function M(t){var e,i=document.createElement("a-entity");return(e=document.createElement("a-entity")).setAttribute("position",t+" 1 0"),e.setAttribute("mixin","wayfinding-box"),i.append(e),(e=document.createElement("a-entity")).setAttribute("position",t+" 1.2 0.06"),e.setAttribute("geometry","primitive: plane; width: 0.8; height: 1.6"),e.setAttribute("material","src:#wayfinding-map"),i.append(e),(e=document.createElement("a-entity")).setAttribute("position",t+" 1.2 -0.06"),e.setAttribute("rotation","0 180 0"),e.setAttribute("geometry","primitive: plane; width: 0.8; height: 1.6"),e.setAttribute("material","src:#wayfinding-map"),i.append(e),i}function C(t){var e=document.createElement("a-entity");return e.setAttribute("class","bench-parent"),e.setAttribute("position",t+" 0 3.5"),e}function j(t){var e=document.createElement("a-entity");return e.setAttribute("class","bikerack-parent"),e.setAttribute("position",t+" 0 -3.5"),e}function S(t,e){var i=document.createElement("a-entity");i.setAttribute("class","bikeshare"),i.setAttribute("position",t+" 0 0"),i.setAttribute("mixin","bikeshare");var a="left"===e[0]?90:270;return i.setAttribute("rotation","0 "+a+" 0"),i}function R(t,e){var i=document.createElement("a-entity");i.setAttribute("class","parklet"),i.setAttribute("position",t+" .02 0"),i.setAttribute("mixin","parklet");var a="left"===e[0]?90:270;return i.setAttribute("rotation","0 "+a+" 0"),i}function z(t){var e=document.createElement("a-entity");return e.setAttribute("class","tree-parent"),e.setAttribute("position",t+" 0 7"),e}function I(t){var e=document.createElement("a-entity");return e.setAttribute("class","lamp-parent"),e.setAttribute("position",t+" 0 0"),e}function B(t,e){var i=document.createElement("a-entity");return i.setAttribute("class","bus-stop"),i.setAttribute("position",t+" 0 0"),i.setAttribute("rotation","0 "+e+" 0"),i.setAttribute("mixin","bus-stop"),i}function L(t,e,i,a,r,n,s){var o=document.createElement("a-entity"),l=t+" "+n/150+" 1";return o.setAttribute("scale",l),o.setAttribute("position",e+" "+i+" 0"),0!==s.length&&o.setAttribute("material","repeat: ".concat(s[0]," ").concat(s[1])),o.setAttribute("rotation","270 "+a+" 0"),o.setAttribute("mixin",r),o}t.exports.processSegments=function(t,e,i,c,p){var h=i/2;i>12&&(h=(i-12)/2),e&&(t=function(t){function e(t){return"lane"===t.slice(t.length-4)||"light-rail"===t||"streetcar"===t||"flex-zone"===t}return t.reduce((function(t,i,a,r){if(0===a)return t.concat(i);var n=r[a-1];if(e(i.type)&&e(n.type)){var s="solid";i.type===n.type&&(s="dashed"),("drive-lane"===i.type&&"turn-lane"===n.type||"drive-lane"===n.type&&"turn-lane"===i.type)&&(s="dashed"),i.variantString.split("|")[0]!==n.variantString.split("|")[0]&&(s="doubleyellow","bike-lane"===i.type&&"bike-lane"===n.type&&(s="shortdashedyellow"),"flex-zone"!==i.type&&"flex-zone"!==n.type||(s="solid")),"turn-lane"===i.type&&"shared"===i.variantString.split("|")[1]?s="soliddashedyellow":"turn-lane"===n.type&&"shared"===n.variantString.split("|")[1]&&(s="soliddashedyellowinverted"),"parking-lane"!==i.type&&"parking-lane"!==n.type||(s="invisible"),t.push({type:"separator",variantString:s,width:0})}return(e(i.type)&&"divider"===n.type||e(n.type)&&"divider"===i.type)&&t.push({type:"separator",variantString:"solid",width:0}),t.push(i),t}),[])}(t));var b=function(t){var e=document.createElement("a-entity"),i=0-r.calcStreetWidth(t)/2;return e.setAttribute("position",i+" 0 0"),e}(t);b.classList.add("street-parent");for(var F,D=0,O=0;O{var t,e;t=!1,e=new THREE.FileLoader,window.AFRAME.registerElement("streetmix-assets",{prototype:Object.create(window.AFRAME.ANode.prototype,{createdCallback:{value:function(){this.setAttribute("src",""),this.isAssetItem=!0,this.isAssets=!0,this.fileLoader=e,this.timeout=null}},attachedCallback:{value:function(){if(!t){var e;this.parentNode&&this.parentNode.hasLoaded&&console.warn("Assets have already loaded. streetmix-assets may have problems"),t=!0,this.innerHTML=((e=this.getAttribute("url"))||(e="https://assets.3dstreet.app/"),console.log("[street]","Using street assets from",e),'\n \x3c!-- sidewalk props --\x3e\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \x3c!-- human characters --\x3e\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \x3c!-- vehicles --\x3e\n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \x3c!-- vehicles rigged --\x3e\n \n \n \n \n \n \n \n \n \n \n\n \x3c!-- micro mobility vehicles --\x3e\n \n \n \n\n \x3c!-- blocks --\x3e\n \n \n\n \x3c!-- buildings and blocks --\x3e\n \n \n\n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \x3c!-- optimized textures - used by default --\x3e\n \n \n \n \n \n \n \n \n \n \n \n \n\n \x3c!-- lane separator markings atlas --\x3e\n \n \n \n \n \n \n \n \n \x3c!-- color modifier mixins --\x3e\n \n \n \n \n \x3c!-- stencils atlas --\x3e\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \x3c!-- vehicles --\x3e\n \n \n \n \n \x3c!-- street props --\x3e\n \n \n \n \n\n \x3c!-- dividers --\x3e\n \n \n \n \n \n \n \n \n \n \n\n \x3c!-- sky --\x3e\n \n \n\n \x3c!-- grounds --\x3e\n \n \n \n\n \n \n \n \n \x3c!-- ui / future use --\x3e\n \n '));var i=this.parentNode;this.setAttribute("timeout",i.getAttribute("timeout")),this.parentNode.isScene=!0,Object.getPrototypeOf(i).attachedCallback.call(this),this.parentNode.isScene=!1}}},load:{value:function(){AFRAME.ANode.prototype.load.call(this,null,(function(t){return t.isAssetItem&&t.hasAttribute("src")}))}}})}),window.addEventListener("DOMContentLoaded",(function(e){if(!t){var i=document.querySelector("a-assets");i||(i=document.createElement("a-assets")),i.hasLoaded&&console.warn("Assets already loaded. May lead to bugs");var a=document.createElement("streetmix-assets");i.append(a),document.querySelector("a-scene").append(i)}})),document.addEventListener("DOMSubtreeModified",(function t(e){if("A-SCENE"===e.target.nodeName){var i=e.target.querySelector("a-assets");if(i||(i=document.createElement("a-assets"),e.target.append(i)),i.querySelector("streetmix-assets"))document.removeEventListener("DOMSubtreeModified",t);else{var a=document.createElement("streetmix-assets");i.append(a),document.removeEventListener("DOMSubtreeModified",t)}}}),!1)},391:(t,e,i)=>{var a=i(334);AFRAME.registerComponent("create-from-json",{schema:{jsonString:{type:"string",default:""}},update:function(t){var e=this.data,i=this.el;if(t.string&&e.string!==t.string)for(;i.firstChild;)i.removeChild(i.lastChild);a.appendChildElementsFromArray(JSON.parse(e.jsonString),i)}})},579:(t,e,i)=>{var a=i(844),r=i(394);i(234),i(391),i(631),i(172),AFRAME.registerComponent("street",{schema:{JSON:{type:"string"},type:{default:"streetmixSegmentsFeet"},left:{default:""},right:{default:""},showGround:{default:!0},showStriping:{default:!0},showVehicles:{default:!0},globalAnimated:{default:!1},length:{default:150}},update:function(t){var e=this.data;if(0!==e.JSON.length){var i=JSON.parse(e.JSON),n=a.processSegments(i.streetmixSegmentsFeet,e.showStriping,e.length,e.globalAnimated,e.showVehicles);if(this.el.append(n),e.left||e.right){var s=r.calcStreetWidth(i.streetmixSegmentsFeet,e.autoStriping),o=a.processBuildings(e.left,e.right,s,e.showGround,e.length);this.el.append(o)}}else{if(void 0!==t.JSON&&0===t.JSON.length)return;console.log("[street]","No JSON provided yet, but it might be set at runtime")}}}),AFRAME.registerComponent("streetmix-loader",{dependencies:["street"],schema:{streetmixStreetURL:{type:"string"},streetmixAPIURL:{type:"string"},showBuildings:{default:!0},name:{default:""}},update:function(t){var e=this.data,i=this.el;if(t.streetmixStreetURL!==e.streetmixStreetURL||t.streetmixAPIURL!==e.streetmixAPIURL)if(0!==e.streetmixAPIURL.length){var a=new XMLHttpRequest;console.log("[streetmix-loader]","GET "+e.streetmixAPIURL),a.open("GET",e.streetmixAPIURL,!0),a.onload=function(){if(this.status>=200&&this.status<400){var t=JSON.parse(this.response),a=t.data.street.segments,r=t.name;i.setAttribute("streetmix-loader","name",r),e.showBuildings&&(i.setAttribute("street","right",t.data.street.rightBuildingVariant),i.setAttribute("street","left",t.data.street.leftBuildingVariant)),i.setAttribute("street","type","streetmixSegmentsFeet"),i.setAttribute("street","JSON",JSON.stringify({streetmixSegmentsFeet:a})),i.emit("streetmix-loader-street-loaded")}else console.log("[streetmix-loader]","Loading Error: We reached the target server, but it returned an error")},a.onerror=function(){console.log("[streetmix-loader]","Loading Error: There was a connection error of some sort")},a.send()}else{if(e.streetmixStreetURL.length>0){var n=r.streetmixUserToAPI(e.streetmixStreetURL);return console.log("[streetmix-loader]","setting `streetmixAPIURL` to",n),void i.setAttribute("streetmix-loader","streetmixAPIURL",n)}console.log("[streetmix-loader]","Neither `streetmixAPIURL` nor `streetmixStreetURL` properties provided, please provide at least one.")}}}),AFRAME.registerComponent("intersection",{schema:{dimensions:{type:"string",default:"20 20"},sidewalk:{type:"string",default:"0 0 0 0"},northeastcurb:{type:"string",default:"0 0"},southwestcurb:{type:"string",default:"0 0"},southeastcurb:{type:"string",default:"0 0"},northwestcurb:{type:"string",default:"0 0"},stopsign:{type:"string",default:"0 0 0 0"},trafficsignal:{type:"string",default:"0 0 0 0"},crosswalk:{type:"string",default:"0 0 0 0"}},init:function(){var t=this.data,e=this.el,i=t.dimensions.split(" ").map((function(t){return Number(t)})),a=[this.el.getAttribute("position").x,this.el.getAttribute("position").y,this.el.getAttribute("position").z],r=t.sidewalk.split(" ").map((function(t){return Number(t)})),n=t.northeastcurb.split(" ").map((function(t){return Number(t)})),s=t.southwestcurb.split(" ").map((function(t){return Number(t)})),o=t.southeastcurb.split(" ").map((function(t){return Number(t)})),l=t.northwestcurb.split(" ").map((function(t){return Number(t)})),d=t.stopsign.split(" ").map((function(t){return Number(t)})),c=t.trafficsignal.split(" ").map((function(t){return Number(t)})),m=t.crosswalk.split(" ").map((function(t){return Number(t)}));this.geometry=new THREE.PlaneGeometry(i[0],i[1],1,1),this.material=new THREE.MeshStandardMaterial({color:"#FF0000"}),this.mesh=new THREE.Mesh(this.geometry,this.material),e.setObject3D("mesh",this.mesh),this.el.setAttribute("position",{x:a[0],y:a[1],z:a[2]}),this.el.setAttribute("rotation","-90 0 0"),this.el.setAttribute("material","src: #asphalt-texture; repeat:5 5; roughness:1");var u=document.createElement("a-entity");u.setAttribute("position",{x:i[0]/2-r[0]/2,z:.04}),u.setAttribute("scale","x",r[0]/3),u.setAttribute("scale","y",i[1]/150),u.setAttribute("rotation",{x:0,y:0,z:0}),u.setAttribute("mixin","sidewalk"),e.appendChild(u);var p=document.createElement("a-entity");p.setAttribute("position",{x:-i[0]/2+r[1]/2,z:.05}),p.setAttribute("scale","x",r[1]/3),p.setAttribute("scale","y",i[1]/150),p.setAttribute("rotation",{x:0,y:0,z:0}),p.setAttribute("mixin","sidewalk"),e.appendChild(p);var h=document.createElement("a-entity");h.setAttribute("position",{y:-i[1]/2+r[2]/2,z:.03}),h.setAttribute("scale","x",r[2]/3),h.setAttribute("scale","y",i[0]/150),h.setAttribute("rotation",{x:0,y:0,z:-90}),h.setAttribute("mixin","sidewalk"),e.appendChild(h);var b=document.createElement("a-entity");b.setAttribute("position",{y:i[1]/2-r[3]/2,z:.03}),b.setAttribute("scale","x",r[3]/3),b.setAttribute("scale","y",i[0]/150),b.setAttribute("rotation",{x:0,y:0,z:-90}),b.setAttribute("mixin","sidewalk"),e.appendChild(b);var g=document.createElement("a-entity");g.setAttribute("position",{x:i[0]/2-n[0]/2,y:i[1]/2-n[1]/2,z:.022}),g.setAttribute("scale","x",n[0]/3),g.setAttribute("scale","y",n[1]/150),g.setAttribute("mixin","sidewalk"),e.appendChild(g);var x=document.createElement("a-entity");x.setAttribute("position",{x:-i[0]/2+s[0]/2,y:-i[1]/2+s[1]/2,z:.022}),x.setAttribute("scale","x",s[0]/3),x.setAttribute("scale","y",s[1]/150),x.setAttribute("mixin","sidewalk"),e.appendChild(x);var f=document.createElement("a-entity");f.setAttribute("position",{x:i[0]/2-o[0]/2,y:-i[1]/2+o[1]/2,z:.022}),f.setAttribute("scale","x",o[0]/3),f.setAttribute("scale","y",o[1]/150),f.setAttribute("mixin","sidewalk"),e.appendChild(f);var y=document.createElement("a-entity");if(y.setAttribute("position",{x:-i[0]/2+l[0]/2,y:i[1]/2-l[1]/2,z:.022}),y.setAttribute("scale","x",l[0]/3),y.setAttribute("scale","y",l[1]/150),y.setAttribute("mixin","sidewalk"),e.appendChild(y),d[0]){var v=document.createElement("a-entity");v.setAttribute("position",{x:i[0]/2,y:i[1]/3,z:.03}),v.setAttribute("rotation",{x:0,y:90,z:90}),v.setAttribute("mixin","stop_sign"),e.appendChild(v)}if(d[1]){var A=document.createElement("a-entity");A.setAttribute("position",{x:-i[0]/2,y:-i[1]/3,z:.03}),A.setAttribute("rotation",{x:0,y:-90,z:-90}),A.setAttribute("mixin","stop_sign"),e.appendChild(A)}if(d[2]){var _=document.createElement("a-entity");_.setAttribute("position",{x:-i[0]/3,y:i[1]/2,z:.03}),_.setAttribute("rotation",{x:-90,y:90,z:90}),_.setAttribute("mixin","stop_sign"),e.appendChild(_)}if(d[3]){var w=document.createElement("a-entity");w.setAttribute("position",{x:i[0]/3,y:-i[1]/2,z:.03}),w.setAttribute("rotation",{x:90,y:-90,z:-90}),w.setAttribute("mixin","stop_sign"),e.appendChild(w)}if(c[0]){var E=document.createElement("a-entity");E.setAttribute("position",{x:i[0]/2,y:i[1]/3,z:.03}),E.setAttribute("rotation",{x:210,y:90,z:90}),E.setAttribute("mixin","signal_left"),e.appendChild(E);var k=document.createElement("a-entity");k.setAttribute("position",{x:i[0]/2,y:-i[1]/3,z:.03}),k.setAttribute("rotation",{x:180,y:90,z:90}),k.setAttribute("mixin","signal_right"),e.appendChild(k)}if(c[1]){var M=document.createElement("a-entity");M.setAttribute("position",{x:-i[0]/2,y:-i[1]/3,z:.03}),M.setAttribute("rotation",{x:30,y:90,z:90}),M.setAttribute("mixin","signal_left"),e.appendChild(M);var C=document.createElement("a-entity");C.setAttribute("position",{x:-i[0]/2,y:i[1]/3,z:.03}),C.setAttribute("rotation",{x:0,y:90,z:90}),C.setAttribute("mixin","signal_right"),e.appendChild(C)}if(c[2]){var j=document.createElement("a-entity");j.setAttribute("position",{x:-i[0]/3,y:i[1]/2,z:.03}),j.setAttribute("rotation",{x:120,y:90,z:90}),j.setAttribute("mixin","signal_left"),e.appendChild(j);var S=document.createElement("a-entity");S.setAttribute("position",{x:i[0]/3,y:i[1]/2,z:.03}),S.setAttribute("rotation",{x:90,y:90,z:90}),S.setAttribute("mixin","signal_right"),e.appendChild(S)}if(c[3]){var R=document.createElement("a-entity");R.setAttribute("position",{x:i[0]/3,y:-i[1]/2,z:.03}),R.setAttribute("rotation",{x:-60,y:90,z:90}),R.setAttribute("mixin","signal_left"),e.appendChild(R);var z=document.createElement("a-entity");z.setAttribute("position",{x:-i[0]/3,y:-i[1]/2,z:.03}),z.setAttribute("rotation",{x:-90,y:90,z:90}),z.setAttribute("mixin","signal_right"),e.appendChild(z)}if(m[0]){var I=document.createElement("a-entity");I.setAttribute("position",{x:i[0]/2-2,z:.013}),I.setAttribute("rotation",{x:0,y:0,z:180}),I.setAttribute("scale",{y:i[1]/12}),I.setAttribute("mixin","markings crosswalk-zebra"),e.appendChild(I)}if(m[1]){var B=document.createElement("a-entity");B.setAttribute("position",{x:-i[0]/2+2,z:.012}),B.setAttribute("rotation",{x:0,y:0,z:180}),B.setAttribute("scale",{y:i[1]/12}),B.setAttribute("mixin","markings crosswalk-zebra"),e.appendChild(B)}if(m[2]){var L=document.createElement("a-entity");L.setAttribute("position",{y:-i[1]/2+2,z:.011}),L.setAttribute("rotation",{x:0,y:0,z:90}),L.setAttribute("scale",{y:i[0]/12}),L.setAttribute("mixin","markings crosswalk-zebra"),e.appendChild(L)}if(m[3]){var F=document.createElement("a-entity");F.setAttribute("position",{y:i[1]/2-2,z:.01}),F.setAttribute("rotation",{x:0,y:0,z:90}),F.setAttribute("scale",{y:i[0]/12}),F.setAttribute("mixin","markings crosswalk-zebra"),e.appendChild(F)}}}),AFRAME.registerComponent("street-environment",{schema:{preset:{type:"string",default:"day",oneOf:["day","night"]}},init:function(){var t=this.data,e=this.el;if("night"===t.preset){var i=document.createElement("a-entity");i.setAttribute("id","light"),i.setAttribute("light",{type:"ambient",color:"#FFF",intensity:.5}),e.appendChild(i);var a=document.createElement("a-entity");a.setAttribute("id","light"),a.setAttribute("position",{x:.5,y:1,z:-1}),a.setAttribute("light",{type:"directional",color:"#FFF",intensity:.15}),e.appendChild(a);var r=document.createElement("a-sky");r.setAttribute("id","sky"),r.setAttribute("color","#444"),r.setAttribute("src","#sky-night"),e.appendChild(r)}else{var n=document.createElement("a-entity");n.setAttribute("id","light"),n.setAttribute("light",{type:"ambient",color:"#FFF",intensity:2}),e.appendChild(n);var s=document.createElement("a-entity");s.setAttribute("id","light"),s.setAttribute("position",{x:.5,y:1,z:-1}),s.setAttribute("light",{type:"directional",color:"#FFF",intensity:.6}),e.appendChild(s);var o=document.createElement("a-sky");o.setAttribute("id","sky"),o.setAttribute("src","#sky"),o.setAttribute("rotation","0 255 0"),e.appendChild(o)}}}),AFRAME.registerComponent("wheel",{schema:{speed:{type:"number",default:1},wheelDiameter:{type:"number",default:1}},init:function(){var t=this.el,e=this;t.addEventListener("model-loaded",(function(i){var a=t.getObject3D("mesh");a&&(e.wheel_F_L=a.getObjectByName("wheel_F_L"),e.wheel_F_R=a.getObjectByName("wheel_F_R"),e.wheel_B_L=a.getObjectByName("wheel_B_L"),e.wheel_B_R=a.getObjectByName("wheel_B_R"),e.wheel_B_L_2=a.getObjectByName("wheel_B_L_2"),e.wheel_B_R_2=a.getObjectByName("wheel_B_R_2"))}))},tick:function(t,e){var i=this.data.speed/1e3/this.data.wheelDiameter*2*e;this.wheel_F_L&&this.wheel_F_L.rotateY(i),this.wheel_F_R&&this.wheel_F_R.rotateY(i),this.wheel_B_L&&this.wheel_B_L.rotateY(i),this.wheel_B_L_2&&this.wheel_B_L_2.rotateY(i),this.wheel_B_R_2&&this.wheel_B_R_2.rotateY(i),this.wheel_B_R&&this.wheel_B_R.rotateY(i)}})},172:()=>{function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=new Array(e);i=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){a=e[Symbol.iterator]()},n:function(){var t=a.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==a.return||a.return()}finally{if(l)throw s}}}}(l);try{for(m.s();!(n=m.n()).done;)n.value,d+=1}catch(t){m.e(t)}finally{m.f()}var u=this.el.getObject3D("mesh");if(u){var p=u.material.clone(),h=null;u.traverse((function(t){!0===t.isMesh&&(h=t.geometry)}));for(var b=new THREE.InstancedMesh(h,p,d),g=0;g{t.exports.isSidewalk=function(t){return t.startsWith("sidewalk")||["utilities","scooter-drop-zone","bikeshare","flex-zone-curb","transit-shelter"].includes(t)},t.exports.createBuildingsArray=function(){var t,e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:150,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"narrow";"narrow"===a||"wide"===a?(t=[{id:"SM3D_Bld_Mixed_4fl",width:5.25221},{id:"SM3D_Bld_Mixed_Double_5fl",width:10.9041},{id:"SM3D_Bld_Mixed_4fl_2",width:5.58889},{id:"SM3D_Bld_Mixed_5fl",width:6.47593},{id:"SM3D_Bld_Mixed_Corner_4fl",width:6.94809}],e="41431323432402434130303230234102402341"):"residential"===a&&(t=[{id:"SM_Bld_House_Preset_03_1800",width:20},{id:"SM_Bld_House_Preset_08_1809",width:20},{id:"SM_Bld_House_Preset_09_1845",width:20}],e="12021201210101212021201012012021201210");for(var r=0,n=0,s=[];n{function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var i=[],a=!0,r=!1,n=void 0;try{for(var s,o=t[Symbol.iterator]();!(a=(s=o.next()).done)&&(i.push(s.value),!e||i.length!==e);a=!0);}catch(t){r=!0,n=t}finally{try{a||null==o.return||o.return()}finally{if(r)throw n}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=new Array(e);i0&&void 0!==arguments[0]?arguments[0]:{},i=document.createElement(t.tag);delete t.tag;for(var a=0,r=Object.entries(t);a0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0;return t.forEach((function(t,i){e.appendChild(a(t))})),e}},394:t=>{t.exports.streetmixUserToAPI=function(t){var e=new URL(t).pathname.split("/"),i=e[1],a=e[2];return"-"===i?"https://streetmix.net/api/v1/streets?namespacedId="+a:"https://streetmix.net/api/v1/streets?namespacedId="+a+"&creatorId="+i},t.exports.pathStartsWithAPI=function(t){var e=document.createElement("a");return e.href=t,"api"===e.pathname.split("/")[1]},t.exports.streetmixAPIToUser=function(t){function e(t,e){for(var i=t.split("&"),a=0;a - + + @@ -20,13 +49,13 @@ - - - - - + + + + + - +