From f099cd43cb6bfba3f06df8f129518b3c15d09852 Mon Sep 17 00:00:00 2001 From: Kieran Farr Date: Sun, 7 Jan 2024 15:24:17 -0800 Subject: [PATCH] dist bump --- dist/citybuilderjr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/citybuilderjr.js b/dist/citybuilderjr.js index 6ee803f..daf03c0 100644 --- a/dist/citybuilderjr.js +++ b/dist/citybuilderjr.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 s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(self,(()=>(()=>{var t={631:t=>{var e=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2,new THREE.Vector2];function i(t,i,s,n){const r=1/n,a=1/s;return e[0].set(r*i,a*t+a),e[1].set(r*i,a*t),e[2].set(r*i+r,a*t),e[3].set(r*i+r,a*t+a),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),s=this.el.getObject3D("mesh").geometry;var n=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]);s.setAttribute("uv",new THREE.BufferAttribute(n,2)),s.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,s,n,r){const a=this.canvas,o=this.data;t.complete||(t.onload=()=>{this.drawTexture(t,e,s)});const l=r||a.height/o.numRows,d=n||a.width/o.numColumns;return this.ctx.drawImage(t,d*e,d*s,d,l),i(e,s,o.numRows,o.numColumns)}}),t.exports.getGridUvs=i},1:()=>{if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.registerComponent("gridhelper",{schema:{size:{default:5},divisions:{default:10},colorCenterLine:{default:"red"},colorGrid:{default:"black"}},init:function(){var t=this.el.object3D,e=this.data,i=e.size,s=e.divisions,n=e.colorCenterLine,r=e.colorGrid,a=new THREE.GridHelper(i,s,n,r);a.name="gridHelper",t.add(a)},remove:function(){var t=this.el.object3D;t.remove(t.getObjectByName("gridHelper"))}})},174:()=>{var t,e=AFRAME.utils.debug,i=AFRAME.utils.coordinates,s=e("components:look-at:warn"),n=i.isCoordinates||i.isCoordinate;delete AFRAME.components["look-at"],AFRAME.registerComponent("look-at",{schema:{default:"0 0 0",parse:function(t){return n(t)||"object"==typeof t?i.parse(t):t},stringify:function(t){return"object"==typeof t?i.stringify(t):t}},init:function(){this.target3D=null,this.vector=new THREE.Vector3,this.cameraListener=AFRAME.utils.bind(this.cameraListener,this),this.el.addEventListener("componentinitialized",this.cameraListener),this.el.addEventListener("componentremoved",this.cameraListener)},update:function(){var t,e=this,i=e.data;return!i||"object"==typeof i&&!Object.keys(i).length?e.remove():"object"==typeof i?this.lookAt(new THREE.Vector3(i.x,i.y,i.z)):(t=e.el.sceneEl.querySelector(i))?t.hasLoaded?e.beginTracking(t):t.addEventListener("loaded",(function(){e.beginTracking(t)})):void s('"'+i+'" does not point to a valid entity to look-at')},tick:(t=new THREE.Vector3,function(e){var i=this.target3D;i&&(i.getWorldPosition(t),this.lookAt(t))}),remove:function(){this.el.removeEventListener("componentinitialized",this.cameraListener),this.el.removeEventListener("componentremoved",this.cameraListener)},beginTracking:function(t){this.target3D=t.object3D},cameraListener:function(t){t.detail&&"camera"===t.detail.name&&this.update()},lookAt:function(t){var e=this.vector,i=this.el.object3D;this.el.getObject3D("camera")?e.subVectors(i.position,t).add(i.position):e.copy(t),i.lookAt(e)}})},699:()=>{AFRAME.registerComponent("proxy-event",{schema:{captureBubbles:{default:!1},enabled:{default:!0},event:{type:"string"},from:{type:"string"},to:{type:"string"},as:{type:"string"},bubbles:{default:!1}},multiple:!0,init:function(){var t,e,i,s=this.data,n=this.el,r=this;if(s.from?t="PARENT"===s.from?[n.parentNode]:document.querySelectorAll(s.from):i="CHILDREN"===s.to?n.querySelectorAll("*"):"SELF"===s.to?[n]:document.querySelectorAll(s.to),s.from)for(e=0;e","<","<=",">="],u=/\s+/,p=/\(|\)|\!/g;function f(t){return-1===(t=function(t){return 0===t.indexOf("!!")?t.replace("!!",""):0===t.indexOf("!")?t.replace("!",""):t}(t.trim())).indexOf(".")?t:t.substring(0,t.indexOf("."))}t.exports.parseKeysToWatch=function(t,e,i){var s,n;for(n=y(e,u),s=0;s-1&&this.subscriptions.splice(e,1)},shouldUpdate:function(t,e,i){for(var s=0;s [data-bind-for-active="false"]'))(s=a.querySelector('[data-bind-for-active="false"]')).setAttribute("data-bind-for-key",l),s.setAttribute("data-bind-for-value",d),s.object3D.visible=!0,s.play(),s.setAttribute("data-bind-for-active","true"),s.emit("bindforupdateinplace",o,!1);else{var c=this.generateFromTemplate(o,i);c.addEventListener("loaded",(function(){c.emit("bindforupdateinplace",o,!1)})),a.appendChild(c)}this.renderedKeys.push(d)}else-1!==e.indexOf(d)&&(t.length&&t[0].constructor===String?(s=a.querySelector('[data-bind-for-value="'+d+'"]')).setAttribute("data-bind-for-key",i):s=a.querySelector('[data-bind-for-key="'+l+'"]'),s.emit("bindforupdateinplace",o,!1));t[i+1]&&(this.data.delay?setTimeout((function(){n.renderItemsInPlace(t,e,i+1)}),this.data.delay):this.renderItemsInPlace(t,e,i+1))},generateFromTemplate:function(t,e){var i=this.data;this.el.appendChild(this.system.renderTemplate(this.template,t));var s=this.el.children[this.el.children.length-1];if(!t)return s.setAttribute("data-bind-for-key",""),s.setAttribute("data-bind-for-active","false"),s;var n=this.getBindForKey(t,e);return s.setAttribute("data-bind-for-key",n),i.key||s.setAttribute("data-bind-for-value",t),s.setAttribute("data-bind-for-active","true"),s},getElsToRemove:(s=[],function(t,e){var i=this.data,n=this.el;s.length=0;for(var r=0;r{AFRAME.registerComponent("grid-cursor",{schema:{allowFrom:{default:"*"},cursor:{default:"#cursor"}},init:function(){this.helperVector=new THREE.Vector3,this.cursorEl=document.querySelector(this.data.cursor),this.oldPos=(new THREE.Vector3).copy(this.cursorEl.object3D.position),this.el.addEventListener("raycaster-intersected",(t=>{t.detail.el.matches(this.data.allowFrom)&&(this.raycaster=t.detail.el)})),this.el.addEventListener("raycaster-intersected-cleared",(t=>{t.detail.el.matches(this.data.allowFrom)&&(this.raycaster=null)})),this.tick=AFRAME.utils.throttleTick(this.tick,30,this)},tick:function(){if(!this.raycaster)return void this.cursorEl.setAttribute("visible",!1);let t=this.raycaster.components.raycaster.getIntersection(this.el);if(!t)return void this.cursorEl.setAttribute("visible",!1);this.cursorEl.setAttribute("visible",!0);const e=((t,e,i)=>{const s=this.helperVector;return s.copy(t),s.x=Math.floor(s.x/i)*i+e,s.y=Math.floor(s.y/i)*i+e,s.z=Math.floor(s.z/i)*i+e,s})((t=>{const e=this.helperVector;return e.copy(t),this.el.object3D.worldToLocal(e),e})(t.point),.125,.25),i=(t=>{const e=new THREE.Vector3;return e.copy(t),this.el.object3D.localToWorld(e),e})(e);this.oldPos.equals(e)||(this.cursorEl.object3D.position.copy(i),this.oldPos.copy(e),this.cursorEl.emit("cursormoved"))}})},216:()=>{AFRAME.registerComponent("intersection-spawn",{schema:{default:"",parse:AFRAME.utils.styleParser.parse},init:function(){const t=this.data,e=this.el;this.helperVector=new THREE.Vector3,e.addEventListener(t.event,(e=>{if(t.objects&&!e.detail.intersectedEl.classList.contains(t.objects))return;const i=document.createElement("a-entity");Object.keys(t).forEach((e=>{["event","objects","gridSize","gridDivisions"].includes(e)||AFRAME.utils.entity.setComponentProperty(i,e,t[e])}));const s=e.detail.intersection.object.el,n=((t,e)=>{const i=this.helperVector;return i.copy(t),e.object3D.worldToLocal(i),i})(e.detail.intersection.point,s);i.setAttribute("position",n),s.appendChild(i);const r=this.localToStateGrid(n,t.gridSize,t.gridDivisions);AFRAME.scenes[0].emit("addGridObject",{lon:r.x,lat:r.y})}))},localToStateGrid:function(t,e,i){const s=i/e,n=t.x*s,r=t.z*s*-1;return{x:Math.round(n+(n>=0?.5:-.5)),y:Math.round(r+(r>=0?.5:-.5))}}})},490:()=>{AFRAME.registerComponent("set-rotation-from-anchor",{schema:{anchorId:{type:"selector"}},init:function(){this.anchorEl=null,this.data.anchorId?this.anchorEl=document.querySelector(this.data.anchorId):this.anchorEl=document.querySelector("[anchored]")},tick:function(){this.anchorEl&&this.anchorEl.object3D&&this.el.object3D.quaternion.copy(this.anchorEl.object3D.quaternion)}})},133:()=>{AFRAME.registerComponent("snap",{dependencies:["position"],schema:{offset:{type:"number"},snap:{type:"number"},localId:{type:"selector"}},init:function(){var t=this;this.helperVector=new THREE.Vector3,this.originalPos=this.el.getAttribute("position"),this.el.addEventListener("componentchanged",(function(e){"position"===e.detail.name&&t.update()})),this.localEl=null,this.data.anchorId&&(this.localEl=document.querySelector(this.data.localId))},update:function(){this.data;const t=(t,e,i)=>{const s=this.helperVector;return s.copy(t),s.x=Math.floor(s.x/i)*i+e,s.y=Math.floor(s.y/i)*i+e,s.z=Math.floor(s.z/i)*i+e,s},e=t=>{const e=this.helperVector;return e.copy(t),this.el.object3D.worldToLocal(e),e},i=t=>{const e=new THREE.Vector3;return e.copy(t),this.el.object3D.localToWorld(e),e};let s;s=this.localEl&&this.localEl.object3D?i(t(e(this.localEl.object3D.position),this.data.offset,this.data.snap)):t(this.el.object3D.position,this.data.offset,this.data.snap),console.log("snapPos",s),this.el.object3D.position.copy(s),this.el.object3D.position.y=0}})},657:()=>{const t={};for(let e=-10;e<=10;e++)for(let i=-10;i<=10;i++)t[`${e},${i}`]=1!==e&&-1!==e||1!==i&&-1!==i?{}:{model:"cityhall",rotation:0,elevation:0};const e={color:{list:{Blue:"#6199D5",Red:"#E54661",Green:"#61D576",Yellow:"#E0D629",Purple:"#CA29E0"},index:0,name:"",hex:""},model:{list:{watertower:{dist:"dist/models/watertower.glb",img:"dist/img/watertower.jpg"},tree_E:{dist:"dist/models/tree_E.glb",img:"dist/img/tree_E.jpg"},road_junction:{dist:"dist/models/road_junction.glb",img:"dist/img/road_junction.jpg"},road_straight:{dist:"dist/models/road_straight.glb",img:"dist/img/road_straight.jpg"},building_F:{dist:"dist/models/building_F.glb",img:"dist/img/building_F.jpg"}},index:0,name:"",img:""},grid:t};function i(t){return Object.keys(t.color.list)[t.color.index]}function s(t){const e=i(t);return t.color.list[e]}function n(t){return Object.keys(t.model.list)[t.model.index]}function r(t){const e=n(t);return t.model.list[e].dist}AFRAME.registerState({initialState:e,handlers:{decreaseColorIndex:function(t){t.color.index-=1,t.color.index<0&&(t.color.index=0)},increaseColorIndex:function(t){t.color.index+=1,t.color.index>=Object.keys(t.color.list).length&&(t.color.index-=1)},decreaseModelIndex:function(t){t.model.index-=1,t.model.index<0&&(t.model.index=0)},increaseModelIndex:function(t){t.model.index+=1,t.model.index>=Object.keys(t.model.list).length&&(t.model.index-=1)},addModel:function(t,e){t.model.list[e.name]={dist:e.dist,img:e.img}},addGridObject:function(t,e){console.log("Adding Grid Object:",e);let{lon:i,lat:s,model:r,rotation:a,elevation:o}=e;const l=`${i},${s}`;r||(r=n(t)),a||(a=0),o||(o=0),console.log("model",r),["1,1","-1,1","-1,-1","1,-1"].includes(l)?console.log("Cannot place object on city hall"):t.grid[l]={model:r,rotation:a,elevation:o},console.log("Updated Grid State:",t.grid)},rotateOrElevateGridObject:function(t,e){const{lon:i,lat:s,rotation:n,elevation:r}=e,a=`${i},${s}`;t.grid[a]&&!["1,1","-1,1","-1,-1","1,-1"].includes(a)&&(t.grid[a].rotation+=n,t.grid[a].elevation+=r)},clearGridCell:function(t,e){const{lon:i,lat:s}=e,n=`${i},${s}`;["1,1","-1,1","-1,-1","1,-1"].includes(n)||(t.grid[n]=null)}},computeState:function(t,e){t.color.name=i(t),t.color.hex=s(t),t.model.name=n(t),t.model.img=function(t){const e=n(t);return t.model.list[e].img}(t),t.model.path=r(t)}}),AFRAME.registerComponent("load-catalog",{schema:{source:{type:"selector"}},init:function(){this.jsonCatalogData=JSON.parse(this.data.source.data),console.log(this.jsonCatalogData);for(let t=0;t{!function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={exports:{},id:s,loaded:!1};return t[s].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}i.m=t,i.c=e,i.p="",i(0)}([function(t,e){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.registerComponent("slice9",{schema:{alphaTest:{default:0},bottom:{default:0,min:0},color:{type:"color",default:"#fff"},debug:{default:!1},height:{default:1,min:0},left:{default:0,min:0},opacity:{default:1,min:0,max:1},padding:{default:.1,min:.01},right:{default:0,min:0},side:{default:"front",oneOf:["front","back","double"]},src:{type:"map"},top:{default:0,min:0},transparent:{default:!0},width:{default:1,min:0},usingCustomMaterial:{default:!1},usingAtlas:{default:!1},uvAtlasMin:{type:"vec2"},uvAtlasMax:{type:"vec2"}},init:function(){var t,e,i=this.data;this.textureSrc=null,t=this.geometry=new THREE.PlaneGeometry(i.width,i.height,3,3),i.usingCustomMaterial?this.plane=new THREE.Mesh(t):(e=this.material=new THREE.MeshBasicMaterial({alphaTest:i.alphaTest,color:i.color,opacity:i.opacity,transparent:i.transparent,wireframe:i.debug}),this.plane=new THREE.Mesh(t,e)),this.el.setObject3D("mesh",this.plane)},remove:function(){this.geometry&&this.geometry.dispose(),this.material&&this.material.dispose()},regenerateMesh:function(){var t,e,i,s=this.data,n=this.geometry.attributes.position.array,r=this.geometry.attributes.uv.array;if(!this.material||this.material.map){s.usingCustomMaterial?(t=1,i=1):(t=this.material.map.image.width,i=this.material.map.image.width),p(1,(e={left:s.left/i,right:s.right/i,top:s.top/t,bottom:s.bottom/t}).left,1),p(2,e.right,1),p(4,0,e.bottom),p(5,e.left,e.bottom),p(6,e.right,e.bottom),p(7,1,e.bottom),p(8,0,e.top),p(9,e.left,e.top),p(10,e.right,e.top),p(11,1,e.top),p(13,e.left,0),p(14,e.right,0),s.usingAtlas&&(p(0,0,1),p(3,1,1),p(12,0,0),p(15,1,0));var a=s.width/2,o=s.height/2,l=-a+s.padding,d=a-s.padding,c=o-s.padding,h=-o+s.padding;u(0,-a,o),u(1,l,o),u(2,d,o),u(3,a,o),u(4,-a,c),u(5,l,c),u(6,d,c),u(7,a,c),u(8,-a,h),u(9,l,h),u(10,d,h),u(11,a,h),u(13,l,-o),u(14,d,-o),u(12,-a,-o),u(15,a,-o),this.geometry.attributes.position.needsUpdate=!0,this.geometry.attributes.uv.needsUpdate=!0}function u(t,e,i){n[3*t]=e,n[3*t+1]=i}function p(t,e,i){s.usingAtlas&&(e=s.uvAtlasMin.x+e*(s.uvAtlasMax.x-s.uvAtlasMin.x),i=s.uvAtlasMin.y+i*(s.uvAtlasMax.y-s.uvAtlasMin.y)),r[2*t]=e,r[2*t+1]=i}},update:function(t){var e,i=this.data;e=AFRAME.utils.diff(i,t),i.usingCustomMaterial||(this.material.alphaTest=i.alphaTest,this.material.color.setStyle(i.color),this.material.opacity=i.opacity,this.material.transparent=i.transparent,this.material.wireframe=i.debug,this.material.side=function(t){switch(t){case"back":return THREE.BackSide;case"double":return THREE.DoubleSide;default:return THREE.FrontSide}}(i.side),"src"in e&&this.updateMap()),("width"in e||"height"in e)&&(this.geometry=new THREE.PlaneGeometry(i.width,i.height,3,3),this.plane.geometry=this.geometry),("width"in e||"height"in e||"padding"in e||"left"in e||"top"in e||"bottom"in e||"right"in e)&&this.regenerateMesh()},updateMap:function(){var t=this.data.src;if(t){if(t===this.textureSrc)return;return this.textureSrc=t,void this.el.sceneEl.systems.material.loadTexture(t,{src:t},e.bind(this))}function e(t){this.material.map=t,this.material.needsUpdate=!0,this.regenerateMesh()}this.material.map&&e(null)}})}])}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var r=e[s]={exports:{}};return t[s].call(r.exports,r,r.exports,i),r.exports}return i(699),i(858),i(174),i(631),i(699),i(1),i(430),i(613),i(216),i(133),i(490),i(657),{}})())); \ No newline at end of file +!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 s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(self,(()=>(()=>{var t={631:t=>{var e=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2,new THREE.Vector2];function i(t,i,s,n){const o=1/n,r=1/s;return e[0].set(o*i,r*t+r),e[1].set(o*i,r*t),e[2].set(o*i+o,r*t),e[3].set(o*i+o,r*t+r),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),s=this.el.getObject3D("mesh").geometry;var n=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]);s.setAttribute("uv",new THREE.BufferAttribute(n,2)),s.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,s,n,o){const r=this.canvas,a=this.data;t.complete||(t.onload=()=>{this.drawTexture(t,e,s)});const l=o||r.height/a.numRows,d=n||r.width/a.numColumns;return this.ctx.drawImage(t,d*e,d*s,d,l),i(e,s,a.numRows,a.numColumns)}}),t.exports.getGridUvs=i},1:()=>{if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.registerComponent("gridhelper",{schema:{size:{default:5},divisions:{default:10},colorCenterLine:{default:"red"},colorGrid:{default:"black"}},init:function(){var t=this.el.object3D,e=this.data,i=e.size,s=e.divisions,n=e.colorCenterLine,o=e.colorGrid,r=new THREE.GridHelper(i,s,n,o);r.name="gridHelper",t.add(r)},remove:function(){var t=this.el.object3D;t.remove(t.getObjectByName("gridHelper"))}})},174:()=>{var t,e=AFRAME.utils.debug,i=AFRAME.utils.coordinates,s=e("components:look-at:warn"),n=i.isCoordinates||i.isCoordinate;delete AFRAME.components["look-at"],AFRAME.registerComponent("look-at",{schema:{default:"0 0 0",parse:function(t){return n(t)||"object"==typeof t?i.parse(t):t},stringify:function(t){return"object"==typeof t?i.stringify(t):t}},init:function(){this.target3D=null,this.vector=new THREE.Vector3,this.cameraListener=AFRAME.utils.bind(this.cameraListener,this),this.el.addEventListener("componentinitialized",this.cameraListener),this.el.addEventListener("componentremoved",this.cameraListener)},update:function(){var t,e=this,i=e.data;return!i||"object"==typeof i&&!Object.keys(i).length?e.remove():"object"==typeof i?this.lookAt(new THREE.Vector3(i.x,i.y,i.z)):(t=e.el.sceneEl.querySelector(i))?t.hasLoaded?e.beginTracking(t):t.addEventListener("loaded",(function(){e.beginTracking(t)})):void s('"'+i+'" does not point to a valid entity to look-at')},tick:(t=new THREE.Vector3,function(e){var i=this.target3D;i&&(i.getWorldPosition(t),this.lookAt(t))}),remove:function(){this.el.removeEventListener("componentinitialized",this.cameraListener),this.el.removeEventListener("componentremoved",this.cameraListener)},beginTracking:function(t){this.target3D=t.object3D},cameraListener:function(t){t.detail&&"camera"===t.detail.name&&this.update()},lookAt:function(t){var e=this.vector,i=this.el.object3D;this.el.getObject3D("camera")?e.subVectors(i.position,t).add(i.position):e.copy(t),i.lookAt(e)}})},699:()=>{AFRAME.registerComponent("proxy-event",{schema:{captureBubbles:{default:!1},enabled:{default:!0},event:{type:"string"},from:{type:"string"},to:{type:"string"},as:{type:"string"},bubbles:{default:!1}},multiple:!0,init:function(){var t,e,i,s=this.data,n=this.el,o=this;if(s.from?t="PARENT"===s.from?[n.parentNode]:document.querySelectorAll(s.from):i="CHILDREN"===s.to?n.querySelectorAll("*"):"SELF"===s.to?[n]:document.querySelectorAll(s.to),s.from)for(e=0;e","<","<=",">="],u=/\s+/,p=/\(|\)|\!/g;function f(t){return-1===(t=function(t){return 0===t.indexOf("!!")?t.replace("!!",""):0===t.indexOf("!")?t.replace("!",""):t}(t.trim())).indexOf(".")?t:t.substring(0,t.indexOf("."))}t.exports.parseKeysToWatch=function(t,e,i){var s,n;for(n=y(e,u),s=0;s-1&&this.subscriptions.splice(e,1)},shouldUpdate:function(t,e,i){for(var s=0;s [data-bind-for-active="false"]'))(s=r.querySelector('[data-bind-for-active="false"]')).setAttribute("data-bind-for-key",l),s.setAttribute("data-bind-for-value",d),s.object3D.visible=!0,s.play(),s.setAttribute("data-bind-for-active","true"),s.emit("bindforupdateinplace",a,!1);else{var c=this.generateFromTemplate(a,i);c.addEventListener("loaded",(function(){c.emit("bindforupdateinplace",a,!1)})),r.appendChild(c)}this.renderedKeys.push(d)}else-1!==e.indexOf(d)&&(t.length&&t[0].constructor===String?(s=r.querySelector('[data-bind-for-value="'+d+'"]')).setAttribute("data-bind-for-key",i):s=r.querySelector('[data-bind-for-key="'+l+'"]'),s.emit("bindforupdateinplace",a,!1));t[i+1]&&(this.data.delay?setTimeout((function(){n.renderItemsInPlace(t,e,i+1)}),this.data.delay):this.renderItemsInPlace(t,e,i+1))},generateFromTemplate:function(t,e){var i=this.data;this.el.appendChild(this.system.renderTemplate(this.template,t));var s=this.el.children[this.el.children.length-1];if(!t)return s.setAttribute("data-bind-for-key",""),s.setAttribute("data-bind-for-active","false"),s;var n=this.getBindForKey(t,e);return s.setAttribute("data-bind-for-key",n),i.key||s.setAttribute("data-bind-for-value",t),s.setAttribute("data-bind-for-active","true"),s},getElsToRemove:(s=[],function(t,e){var i=this.data,n=this.el;s.length=0;for(var o=0;o{AFRAME.registerComponent("grid-coord",{schema:{gridCoord:{type:"string",default:""},gridSize:{type:"number",default:5},gridDivisions:{type:"number",default:20}},init:function(){const t=this.data,e=this.el;if(!t.gridCoord)return;[this.lon,this.lat]=t.gridCoord.split(",");const i=this.stateToLocalGrid(t.gridSize,t.gridDivisions);e.setAttribute("position",i)},stateToLocalGrid:function(t,e){const i=e/t,s=this.el.getAttribute("snap");let n=s?s.offset:.01;const[o,r]=[this.lon,this.lat].map((t=>{const e=Number(t);return(e+(e>=0?-n:n))/i}));return{x:o,z:-1*r}}})},613:()=>{AFRAME.registerComponent("grid-cursor",{schema:{allowFrom:{default:"*"},cursor:{default:"#cursor"}},init:function(){this.helperVector=new THREE.Vector3,this.cursorEl=document.querySelector(this.data.cursor),this.oldPos=(new THREE.Vector3).copy(this.cursorEl.object3D.position),this.el.addEventListener("raycaster-intersected",(t=>{t.detail.el.matches(this.data.allowFrom)&&(this.raycaster=t.detail.el)})),this.el.addEventListener("raycaster-intersected-cleared",(t=>{t.detail.el.matches(this.data.allowFrom)&&(this.raycaster=null)})),this.tick=AFRAME.utils.throttleTick(this.tick,30,this)},tick:function(){if(!this.raycaster)return void this.cursorEl.setAttribute("visible",!1);let t=this.raycaster.components.raycaster.getIntersection(this.el);if(!t)return void this.cursorEl.setAttribute("visible",!1);this.cursorEl.setAttribute("visible",!0);const e=((t,e,i)=>{const s=this.helperVector;return s.copy(t),s.x=Math.floor(s.x/i)*i+e,s.y=Math.floor(s.y/i)*i+e,s.z=Math.floor(s.z/i)*i+e,s})((t=>{const e=this.helperVector;return e.copy(t),this.el.object3D.worldToLocal(e),e})(t.point),.125,.25),i=(t=>{const e=new THREE.Vector3;return e.copy(t),this.el.object3D.localToWorld(e),e})(e);this.oldPos.equals(e)||(this.cursorEl.object3D.position.copy(i),this.oldPos.copy(e),this.cursorEl.emit("cursormoved"))}})},318:()=>{AFRAME.registerComponent("grid-model",{schema:{model:{type:"string",default:""}},addGltfModel:function(t){const e=this.el,i=e.sceneEl;i.catalogIsloaded?e.setAttribute("gltf-model","./"+i.systems.state.state.model.list[t].dist):i.addEventListener("catalogIsLoaded",(()=>{e.setAttribute("gltf-model","./"+i.systems.state.state.model.list[t].dist)}))},update:function(t){this.addGltfModel(this.data.model)}})},684:()=>{AFRAME.registerComponent("grid-rotation",{schema:{rotation:{type:"number",default:0}},update:function(t){const e=this.data;this.el.setAttribute("rotation",{x:0,y:e.rotation,z:0})}})},216:()=>{AFRAME.registerComponent("intersection-spawn",{schema:{default:"",parse:AFRAME.utils.styleParser.parse},init:function(){const t=this.data,e=this.el;this.helperVector=new THREE.Vector3,e.addEventListener(t.event,(e=>{if(t.objects&&!e.detail.intersectedEl.classList.contains(t.objects))return;const i=e.detail.intersection.object.el,s=((t,e)=>{const i=this.helperVector;return i.copy(t),e.object3D.worldToLocal(i),i})(e.detail.intersection.point,i),n=this.localToStateGrid(s,t.gridSize,t.gridDivisions);AFRAME.scenes[0].emit("addGridObject",{lon:n.x,lat:n.y})}))},localToStateGrid:function(t,e,i){const s=i/e,n=t.x*s,o=t.z*s*-1;return{x:Math.round(n+(n>=0?.5:-.5)),y:Math.round(o+(o>=0?.5:-.5))}}})},490:()=>{AFRAME.registerComponent("set-rotation-from-anchor",{schema:{anchorId:{type:"selector"}},init:function(){this.anchorEl=null,this.data.anchorId?this.anchorEl=document.querySelector(this.data.anchorId):this.anchorEl=document.querySelector("[anchored]")},tick:function(){this.anchorEl&&this.anchorEl.object3D&&this.el.object3D.quaternion.copy(this.anchorEl.object3D.quaternion)}})},133:()=>{AFRAME.registerComponent("snap",{dependencies:["position"],schema:{offset:{type:"number"},snap:{type:"number"},localId:{type:"selector"}},init:function(){var t=this;this.helperVector=new THREE.Vector3,this.originalPos=this.el.getAttribute("position"),this.el.addEventListener("componentchanged",(function(e){"position"===e.detail.name&&t.update()})),this.localEl=null,this.data.anchorId&&(this.localEl=document.querySelector(this.data.localId))},update:function(){this.data;const t=(t,e,i)=>{const s=this.helperVector;return s.copy(t),s.x=Math.floor(s.x/i)*i+e,s.y=Math.floor(s.y/i)*i+e,s.z=Math.floor(s.z/i)*i+e,s},e=t=>{const e=this.helperVector;return e.copy(t),this.el.object3D.worldToLocal(e),e},i=t=>{const e=new THREE.Vector3;return e.copy(t),this.el.object3D.localToWorld(e),e};let s;s=this.localEl&&this.localEl.object3D?i(t(e(this.localEl.object3D.position),this.data.offset,this.data.snap)):t(this.el.object3D.position,this.data.offset,this.data.snap),console.log("snapPos",s),this.el.object3D.position.copy(s),this.el.object3D.position.y=0}})},657:()=>{const t=[],e=[[-1,-1],[-1,1],[1,-1],[1,1]];e.forEach((e=>{e[0],e[1],t.push({coord:e.join(","),model:"park_base",rotation:0,elevation:0})}));const i={color:{list:{Blue:"#6199D5",Red:"#E54661",Green:"#61D576",Yellow:"#E0D629",Purple:"#CA29E0"},index:0,name:"",hex:""},model:{list:{watertower:{dist:"dist/models/watertower.glb",img:"dist/img/watertower.jpg"},tree_E:{dist:"dist/models/tree_E.glb",img:"dist/img/tree_E.jpg"},road_junction:{dist:"dist/models/road_junction.glb",img:"dist/img/road_junction.jpg"},road_straight:{dist:"dist/models/road_straight.glb",img:"dist/img/road_straight.jpg"},building_F:{dist:"dist/models/building_F.glb",img:"dist/img/building_F.jpg"}},index:0,name:"",img:""},grid:t};function s(t,i){return!(!t&&i)&&-1!=e.findIndex((e=>e[0]==t&&e[1]==i))}function n(t,e,i){if(!e&&i)return;const s=[e,i].join(","),n=t.findIndex((t=>t.coord==s));return-1===n?null:n}function o(t){return Object.keys(t.color.list)[t.color.index]}function r(t){const e=o(t);return t.color.list[e]}function a(t){return Object.keys(t.model.list)[t.model.index]}function l(t){const e=a(t);return t.model.list[e].dist}AFRAME.registerState({initialState:i,handlers:{decreaseColorIndex:function(t){t.color.index-=1,t.color.index<0&&(t.color.index=0)},increaseColorIndex:function(t){t.color.index+=1,t.color.index>=Object.keys(t.color.list).length&&(t.color.index-=1)},decreaseModelIndex:function(t){t.model.index-=1,t.model.index<0&&(t.model.index=0)},increaseModelIndex:function(t){t.model.index+=1,t.model.index>=Object.keys(t.model.list).length&&(t.model.index-=1)},addModel:function(t,e){t.model.list[e.name]={dist:e.dist,img:e.img}},addGridObject:function(t,e){console.log("Adding Grid Object:",e);let{lon:i,lat:o,model:r,rotation:l,elevation:d}=e;if(s(i,o))return void console.log("Cannot place object on city hall");r||(r=a(t)),l||(l=0),d||(d=0),console.log("model",r);const c=n(t.grid,i,o);c?t.grid[c].model===r?this.rotateOrElevateGridObject(t,{keyCell:c,addRotation:90}):(t.grid.__dirty=!0,t.grid[c].model=r,t.grid[c].rotation=0):t.grid.push({coord:[i,o].join(","),model:r,rotation:l,elevation:d}),console.log("Updated Grid State:",t.grid)},rotateOrElevateGridObject:function(t,e){let{lon:i,lat:o,addRotation:r,addElevation:a,keyCell:l}=e;if(!s(i,o)){if(l=l??n(t.grid,i,o),r){t.grid.__dirty=!0;const e=t.grid[l].rotation;t.grid[l].rotation=(e+r)%360}a&&(t.grid[l].elevation+=a)}},clearGridCell:function(t,e){const{lon:i,lat:o,keyCell:r}=e;s(i,o)||(r=r??n(t.grid,i,o),r&&t.grid.splice(r,1))}},computeState:function(t,e){t.color.name=o(t),t.color.hex=r(t),t.model.name=a(t),t.model.img=function(t){const e=a(t);return t.model.list[e].img}(t),t.model.path=l(t)}}),AFRAME.registerComponent("load-catalog",{schema:{source:{type:"selector"}},init:function(){if(this.data.source){this.jsonCatalogData=JSON.parse(this.data.source.data),console.log(this.jsonCatalogData);for(let t=0;t{!function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={exports:{},id:s,loaded:!1};return t[s].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}i.m=t,i.c=e,i.p="",i(0)}([function(t,e){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");AFRAME.registerComponent("slice9",{schema:{alphaTest:{default:0},bottom:{default:0,min:0},color:{type:"color",default:"#fff"},debug:{default:!1},height:{default:1,min:0},left:{default:0,min:0},opacity:{default:1,min:0,max:1},padding:{default:.1,min:.01},right:{default:0,min:0},side:{default:"front",oneOf:["front","back","double"]},src:{type:"map"},top:{default:0,min:0},transparent:{default:!0},width:{default:1,min:0},usingCustomMaterial:{default:!1},usingAtlas:{default:!1},uvAtlasMin:{type:"vec2"},uvAtlasMax:{type:"vec2"}},init:function(){var t,e,i=this.data;this.textureSrc=null,t=this.geometry=new THREE.PlaneGeometry(i.width,i.height,3,3),i.usingCustomMaterial?this.plane=new THREE.Mesh(t):(e=this.material=new THREE.MeshBasicMaterial({alphaTest:i.alphaTest,color:i.color,opacity:i.opacity,transparent:i.transparent,wireframe:i.debug}),this.plane=new THREE.Mesh(t,e)),this.el.setObject3D("mesh",this.plane)},remove:function(){this.geometry&&this.geometry.dispose(),this.material&&this.material.dispose()},regenerateMesh:function(){var t,e,i,s=this.data,n=this.geometry.attributes.position.array,o=this.geometry.attributes.uv.array;if(!this.material||this.material.map){s.usingCustomMaterial?(t=1,i=1):(t=this.material.map.image.width,i=this.material.map.image.width),p(1,(e={left:s.left/i,right:s.right/i,top:s.top/t,bottom:s.bottom/t}).left,1),p(2,e.right,1),p(4,0,e.bottom),p(5,e.left,e.bottom),p(6,e.right,e.bottom),p(7,1,e.bottom),p(8,0,e.top),p(9,e.left,e.top),p(10,e.right,e.top),p(11,1,e.top),p(13,e.left,0),p(14,e.right,0),s.usingAtlas&&(p(0,0,1),p(3,1,1),p(12,0,0),p(15,1,0));var r=s.width/2,a=s.height/2,l=-r+s.padding,d=r-s.padding,c=a-s.padding,h=-a+s.padding;u(0,-r,a),u(1,l,a),u(2,d,a),u(3,r,a),u(4,-r,c),u(5,l,c),u(6,d,c),u(7,r,c),u(8,-r,h),u(9,l,h),u(10,d,h),u(11,r,h),u(13,l,-a),u(14,d,-a),u(12,-r,-a),u(15,r,-a),this.geometry.attributes.position.needsUpdate=!0,this.geometry.attributes.uv.needsUpdate=!0}function u(t,e,i){n[3*t]=e,n[3*t+1]=i}function p(t,e,i){s.usingAtlas&&(e=s.uvAtlasMin.x+e*(s.uvAtlasMax.x-s.uvAtlasMin.x),i=s.uvAtlasMin.y+i*(s.uvAtlasMax.y-s.uvAtlasMin.y)),o[2*t]=e,o[2*t+1]=i}},update:function(t){var e,i=this.data;e=AFRAME.utils.diff(i,t),i.usingCustomMaterial||(this.material.alphaTest=i.alphaTest,this.material.color.setStyle(i.color),this.material.opacity=i.opacity,this.material.transparent=i.transparent,this.material.wireframe=i.debug,this.material.side=function(t){switch(t){case"back":return THREE.BackSide;case"double":return THREE.DoubleSide;default:return THREE.FrontSide}}(i.side),"src"in e&&this.updateMap()),("width"in e||"height"in e)&&(this.geometry=new THREE.PlaneGeometry(i.width,i.height,3,3),this.plane.geometry=this.geometry),("width"in e||"height"in e||"padding"in e||"left"in e||"top"in e||"bottom"in e||"right"in e)&&this.regenerateMesh()},updateMap:function(){var t=this.data.src;if(t){if(t===this.textureSrc)return;return this.textureSrc=t,void this.el.sceneEl.systems.material.loadTexture(t,{src:t},e.bind(this))}function e(t){this.material.map=t,this.material.needsUpdate=!0,this.regenerateMesh()}this.material.map&&e(null)}})}])}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var o=e[s]={exports:{}};return t[s].call(o.exports,o,o.exports,i),o.exports}return i(699),i(858),i(174),i(631),i(699),i(1),i(430),i(613),i(216),i(133),i(490),i(657),i(58),i(318),i(684),{}})())); \ No newline at end of file