From 214a06bd744541deefdb17a29399c2208f5f9bdd Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Tue, 5 Sep 2023 20:43:48 -0300 Subject: [PATCH 1/4] fix intersection saving issue --- src/index.js | 64 +++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/index.js b/src/index.js index 34d03779a..df257f91f 100644 --- a/src/index.js +++ b/src/index.js @@ -124,6 +124,11 @@ AFRAME.registerComponent('intersection', { init: function () { var data = this.data; var el = this.el; + + // remove all child nodes if exists + while (el.firstChild) { + el.removeChild(el.lastChild); + } const dimensionsArray = data.dimensions.split(' ').map((i) => Number(i)); const positionArray = [this.el.getAttribute('position').x, this.el.getAttribute('position').y, this.el.getAttribute('position').z]; const sidewalkArray = data.sidewalk.split(' ').map((i) => Number(i)); @@ -138,13 +143,8 @@ AFRAME.registerComponent('intersection', { const intersectWidth = dimensionsArray[0]; const intersectDepth = dimensionsArray[1]; - this.el.setAttribute('geometry', 'primitive', 'plane'); - this.geometry = new THREE.PlaneGeometry(intersectWidth, intersectDepth, 1, 1); - this.material = new THREE.MeshStandardMaterial({ color: '#FF0000' }); - this.mesh = new THREE.Mesh(this.geometry, this.material); - el.setObject3D('mesh', this.mesh); - - this.el.setAttribute('position', { x: positionArray[0], y: positionArray[1], z: positionArray[2] }); + this.el.setAttribute('geometry', `primitive:box; width: ${intersectWidth}; height: ${intersectDepth}; depth:0.2`); + this.el.setAttribute('position', { x: positionArray[0], y: - 0.1, z: positionArray[2] }); this.el.setAttribute('rotation', '-90 0 0'); this.el.setAttribute('material', 'src: #asphalt-texture; repeat:5 5; roughness:1'); @@ -170,13 +170,13 @@ AFRAME.registerComponent('intersection', { // describe sidewalk parameters const sidewalkParams = { west: { - positionVec: { x: intersectWidth / 2 - sidewalkArray[0] / 2 }, + positionVec: { x: intersectWidth / 2 - sidewalkArray[0] / 2, z: 0.1 }, rotationVec: { x: 90, y: 0, z: 0 }, length: intersectDepth, width: sidewalkArray[0] }, east: { - positionVec: { x: -intersectWidth / 2 + sidewalkArray[1] / 2 }, + positionVec: { x: -intersectWidth / 2 + sidewalkArray[1] / 2, z: 0.1 }, rotationVec: { x: 90, y: 0, z: 0 }, length: intersectDepth, width: sidewalkArray[1] @@ -185,7 +185,8 @@ AFRAME.registerComponent('intersection', { positionVec: { y: -intersectDepth / 2 + sidewalkArray[2] / 2, // add x offset to avoid sidewalk's element overlap - x: sidewalkArray[1] / 2 - sidewalkArray[0] / 2 + x: sidewalkArray[1] / 2 - sidewalkArray[0] / 2, + z: 0.1 }, rotationVec: { x: 0, y: 90, z: -90 }, // minus the width of the crossing sidewalk @@ -196,7 +197,8 @@ AFRAME.registerComponent('intersection', { positionVec: { y: intersectDepth / 2 - sidewalkArray[3] / 2, // add x offset to avoid sidewalk's element overlap - x: sidewalkArray[1] / 2 - sidewalkArray[0] / 2 + x: sidewalkArray[1] / 2 - sidewalkArray[0] / 2, + z: 0.1 }, rotationVec: { x: 0, y: 90, z: -90 }, // minus the width of the crossing sidewalk @@ -217,25 +219,25 @@ AFRAME.registerComponent('intersection', { // describe curb parameters const curbParams = { northeast: { - positionVec: { x: intersectWidth / 2 - northeastcurbArray[0] / 2, y: intersectDepth / 2 - northeastcurbArray[1] / 2 }, + positionVec: { x: intersectWidth / 2 - northeastcurbArray[0] / 2, y: intersectDepth / 2 - northeastcurbArray[1] / 2, z: 0.1 }, rotationVec: { x: 0, y: 90, z: -90 }, length: northeastcurbArray[0], width: northeastcurbArray[1] }, southwest: { - positionVec: { x: -intersectWidth / 2 + southwestcurbArray[0] / 2, y: -intersectDepth / 2 + southwestcurbArray[1] / 2 }, + positionVec: { x: -intersectWidth / 2 + southwestcurbArray[0] / 2, y: -intersectDepth / 2 + southwestcurbArray[1] / 2, z: 0.1 }, rotationVec: { x: 0, y: 90, z: -90 }, length: southwestcurbArray[0], width: southwestcurbArray[1] }, southeast: { - positionVec: { x: intersectWidth / 2 - southeastcurbArray[0] / 2, y: -intersectDepth / 2 + southeastcurbArray[1] / 2 }, + positionVec: { x: intersectWidth / 2 - southeastcurbArray[0] / 2, y: -intersectDepth / 2 + southeastcurbArray[1] / 2, z: 0.1 }, rotationVec: { x: 0, y: 90, z: -90 }, length: southeastcurbArray[0], width: southeastcurbArray[1] }, northwest: { - positionVec: { x: -intersectWidth / 2 + northwestcurbArray[0] / 2, y: intersectDepth / 2 - northwestcurbArray[1] / 2 }, + positionVec: { x: -intersectWidth / 2 + northwestcurbArray[0] / 2, y: intersectDepth / 2 - northwestcurbArray[1] / 2, z: 0.1 }, rotationVec: { x: 0, y: 90, z: -90 }, length: northwestcurbArray[0], width: northwestcurbArray[1] @@ -251,28 +253,28 @@ AFRAME.registerComponent('intersection', { if (stopsignArray[0]) { const ss1 = document.createElement('a-entity'); - ss1.setAttribute('position', { x: intersectWidth / 2, y: intersectDepth / 3, z: 0.03 }); + ss1.setAttribute('position', { x: intersectWidth / 2, y: intersectDepth / 3, z: 0.1 }); ss1.setAttribute('rotation', { x: 0, y: 90, z: 90 }); ss1.setAttribute('mixin', 'stop_sign'); el.appendChild(ss1); } if (stopsignArray[1]) { const ss2 = document.createElement('a-entity'); - ss2.setAttribute('position', { x: -intersectWidth / 2, y: -intersectDepth / 3, z: 0.03 }); + ss2.setAttribute('position', { x: -intersectWidth / 2, y: -intersectDepth / 3, z: 0.1 }); ss2.setAttribute('rotation', { x: 0, y: -90, z: -90 }); ss2.setAttribute('mixin', 'stop_sign'); el.appendChild(ss2); } if (stopsignArray[2]) { const ss3 = document.createElement('a-entity'); - ss3.setAttribute('position', { x: -intersectWidth / 3, y: intersectDepth / 2, z: 0.03 }); + ss3.setAttribute('position', { x: -intersectWidth / 3, y: intersectDepth / 2, z: 0.1 }); ss3.setAttribute('rotation', { x: -90, y: 90, z: 90 }); ss3.setAttribute('mixin', 'stop_sign'); el.appendChild(ss3); } if (stopsignArray[3]) { const ss4 = document.createElement('a-entity'); - ss4.setAttribute('position', { x: intersectWidth / 3, y: -intersectDepth / 2, z: 0.03 }); + ss4.setAttribute('position', { x: intersectWidth / 3, y: -intersectDepth / 2, z: 0.1 }); ss4.setAttribute('rotation', { x: 90, y: -90, z: -90 }); ss4.setAttribute('mixin', 'stop_sign'); el.appendChild(ss4); @@ -280,48 +282,48 @@ AFRAME.registerComponent('intersection', { if (trafficsignalArray[0]) { const ts1 = document.createElement('a-entity'); - ts1.setAttribute('position', { x: intersectWidth / 2, y: intersectDepth / 3, z: 0.03 }); + ts1.setAttribute('position', { x: intersectWidth / 2, y: intersectDepth / 3, z: 0.3 }); ts1.setAttribute('rotation', { x: 210, y: 90, z: 90 }); ts1.setAttribute('mixin', 'signal_left'); el.appendChild(ts1); const ts2 = document.createElement('a-entity'); - ts2.setAttribute('position', { x: intersectWidth / 2, y: -intersectDepth / 3, z: 0.03 }); + ts2.setAttribute('position', { x: intersectWidth / 2, y: -intersectDepth / 3, z: 0.3 }); ts2.setAttribute('rotation', { x: 180, y: 90, z: 90 }); ts2.setAttribute('mixin', 'signal_right'); el.appendChild(ts2); } if (trafficsignalArray[1]) { const ts3 = document.createElement('a-entity'); - ts3.setAttribute('position', { x: -intersectWidth / 2, y: -intersectDepth / 3, z: 0.03 }); + ts3.setAttribute('position', { x: -intersectWidth / 2, y: -intersectDepth / 3, z: 0.3 }); ts3.setAttribute('rotation', { x: 30, y: 90, z: 90 }); ts3.setAttribute('mixin', 'signal_left'); el.appendChild(ts3); const ts4 = document.createElement('a-entity'); - ts4.setAttribute('position', { x: -intersectWidth / 2, y: intersectDepth / 3, z: 0.03 }); + ts4.setAttribute('position', { x: -intersectWidth / 2, y: intersectDepth / 3, z: 0.3 }); ts4.setAttribute('rotation', { x: 0, y: 90, z: 90 }); ts4.setAttribute('mixin', 'signal_right'); el.appendChild(ts4); } if (trafficsignalArray[2]) { const ts5 = document.createElement('a-entity'); - ts5.setAttribute('position', { x: -intersectWidth / 3, y: intersectDepth / 2, z: 0.03 }); + ts5.setAttribute('position', { x: -intersectWidth / 3, y: intersectDepth / 2, z: 0.1 }); ts5.setAttribute('rotation', { x: 120, y: 90, z: 90 }); ts5.setAttribute('mixin', 'signal_left'); el.appendChild(ts5); const ts6 = document.createElement('a-entity'); - ts6.setAttribute('position', { x: intersectWidth / 3, y: intersectDepth / 2, z: 0.03 }); + ts6.setAttribute('position', { x: intersectWidth / 3, y: intersectDepth / 2, z: 0.1 }); ts6.setAttribute('rotation', { x: 90, y: 90, z: 90 }); ts6.setAttribute('mixin', 'signal_right'); el.appendChild(ts6); } if (trafficsignalArray[3]) { const ts7 = document.createElement('a-entity'); - ts7.setAttribute('position', { x: intersectWidth / 3, y: -intersectDepth / 2, z: 0.03 }); + ts7.setAttribute('position', { x: intersectWidth / 3, y: -intersectDepth / 2, z: 0.1 }); ts7.setAttribute('rotation', { x: -60, y: 90, z: 90 }); ts7.setAttribute('mixin', 'signal_left'); el.appendChild(ts7); const ts8 = document.createElement('a-entity'); - ts8.setAttribute('position', { x: -intersectWidth / 3, y: -intersectDepth / 2, z: 0.03 }); + ts8.setAttribute('position', { x: -intersectWidth / 3, y: -intersectDepth / 2, z: 0.1 }); ts8.setAttribute('rotation', { x: -90, y: 90, z: 90 }); ts8.setAttribute('mixin', 'signal_right'); el.appendChild(ts8); @@ -329,7 +331,7 @@ AFRAME.registerComponent('intersection', { if (crosswalklArray[0]) { const cw1 = document.createElement('a-entity'); - cw1.setAttribute('position', { x: intersectWidth / 2 - 2, z: 0.013 }); + cw1.setAttribute('position', { x: intersectWidth / 2 - 2, z: 0.11 }); cw1.setAttribute('rotation', { x: 0, y: 0, z: 180 }); cw1.setAttribute('scale', { y: intersectDepth / 12 }); cw1.setAttribute('mixin', 'markings crosswalk-zebra'); @@ -337,7 +339,7 @@ AFRAME.registerComponent('intersection', { } if (crosswalklArray[1]) { const cw2 = document.createElement('a-entity'); - cw2.setAttribute('position', { x: -intersectWidth / 2 + 2, z: 0.012 }); + cw2.setAttribute('position', { x: -intersectWidth / 2 + 2, z: 0.11 }); cw2.setAttribute('rotation', { x: 0, y: 0, z: 180 }); cw2.setAttribute('scale', { y: intersectDepth / 12 }); cw2.setAttribute('mixin', 'markings crosswalk-zebra'); @@ -345,7 +347,7 @@ AFRAME.registerComponent('intersection', { } if (crosswalklArray[2]) { const cw3 = document.createElement('a-entity'); - cw3.setAttribute('position', { y: -intersectDepth / 2 + 2, z: 0.011 }); + cw3.setAttribute('position', { y: -intersectDepth / 2 + 2, z: 0.11 }); cw3.setAttribute('rotation', { x: 0, y: 0, z: 90 }); cw3.setAttribute('scale', { y: intersectWidth / 12 }); cw3.setAttribute('mixin', 'markings crosswalk-zebra'); @@ -353,7 +355,7 @@ AFRAME.registerComponent('intersection', { } if (crosswalklArray[3]) { const cw4 = document.createElement('a-entity'); - cw4.setAttribute('position', { y: intersectDepth / 2 - 2, z: 0.01 }); + cw4.setAttribute('position', { y: intersectDepth / 2 - 2, z: 0.11 }); cw4.setAttribute('rotation', { x: 0, y: 0, z: 90 }); cw4.setAttribute('scale', { y: intersectWidth / 12 }); cw4.setAttribute('mixin', 'markings crosswalk-zebra'); From 2ceae96da1ab55bb9b31b9dac89a3e12847666ad Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Tue, 5 Sep 2023 23:10:19 -0300 Subject: [PATCH 2/4] Update json-utils.js --- src/json-utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/json-utils.js b/src/json-utils.js index 760c96060..76b6c53fa 100644 --- a/src/json-utils.js +++ b/src/json-utils.js @@ -130,7 +130,8 @@ const removeProps = { // a list of component_name:new_component_name pairs to rename in JSON string const renameProps = { 'streetmix-loader': 'not-streetmix-loader', - street: 'not-street' + street: 'not-street', + intersection: 'not-intersection' }; function filterJSONstreet (removeProps, renameProps, streetJSON) { From 6f4c23b5fea91f85539b40e69b56e22f501f60d3 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Thu, 7 Sep 2023 15:30:16 -0300 Subject: [PATCH 3/4] add intesection scene for deploy-preview test --- index-intersection.html | 227 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 index-intersection.html diff --git a/index-intersection.html b/index-intersection.html new file mode 100644 index 000000000..1151b0779 --- /dev/null +++ b/index-intersection.html @@ -0,0 +1,227 @@ + + + + + + + + + + + + + + + + + + + + + 3DStreet + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5252f283b3957f265c2186b95e8d29575030a1bb Mon Sep 17 00:00:00 2001 From: Kieran Farr Date: Thu, 7 Sep 2023 23:11:36 -0700 Subject: [PATCH 4/4] quick lint fix --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index df257f91f..9d71b3110 100644 --- a/src/index.js +++ b/src/index.js @@ -128,7 +128,7 @@ AFRAME.registerComponent('intersection', { // remove all child nodes if exists while (el.firstChild) { el.removeChild(el.lastChild); - } + } const dimensionsArray = data.dimensions.split(' ').map((i) => Number(i)); const positionArray = [this.el.getAttribute('position').x, this.el.getAttribute('position').y, this.el.getAttribute('position').z]; const sidewalkArray = data.sidewalk.split(' ').map((i) => Number(i)); @@ -144,7 +144,7 @@ AFRAME.registerComponent('intersection', { const intersectDepth = dimensionsArray[1]; this.el.setAttribute('geometry', `primitive:box; width: ${intersectWidth}; height: ${intersectDepth}; depth:0.2`); - this.el.setAttribute('position', { x: positionArray[0], y: - 0.1, z: positionArray[2] }); + this.el.setAttribute('position', { x: positionArray[0], y: -0.1, z: positionArray[2] }); this.el.setAttribute('rotation', '-90 0 0'); this.el.setAttribute('material', 'src: #asphalt-texture; repeat:5 5; roughness:1');