@eturnity/eturnity_3d 6.34.0 → 6.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +5 -0
- package/package.json +8 -4
- package/src/App.vue +16 -16
- package/src/assets/theme.js +4 -4
- package/src/components/ThreeCanvasViewer.vue +56 -43
- package/src/config.js +139 -65
- package/src/helper/MapView.js +214 -241
- package/src/helper/UpdateRoofModuleFieldRelations.js +17 -23
- package/src/helper/UpdateRoofObstacleRelations.js +48 -41
- package/src/helper/cameraMixin.js +97 -93
- package/src/helper/customProvider.js +28 -28
- package/src/helper/materialMixin.js +86 -70
- package/src/helper/materials.js +64 -49
- package/src/helper/render/background.js +2 -5
- package/src/helper/render/base.js +43 -40
- package/src/helper/render/clear.js +96 -84
- package/src/helper/render/edge.js +59 -65
- package/src/helper/render/geometryHandler.js +166 -128
- package/src/helper/render/imageOverlay.js +157 -106
- package/src/helper/render/index.js +21 -3
- package/src/helper/render/loader.js +34 -34
- package/src/helper/render/mapProjection.js +88 -74
- package/src/helper/render/margin.js +46 -50
- package/src/helper/render/moduleField.js +26 -24
- package/src/helper/render/node.js +43 -43
- package/src/helper/render/obstacle.js +50 -48
- package/src/helper/render/panel.js +85 -79
- package/src/helper/render/projectionMaterial.js +58 -50
- package/src/helper/render/roof.js +136 -133
- package/src/helper/render/texture.js +17 -17
- package/src/helper/render/tile.js +291 -0
- package/src/helper/renderMixin.js +30 -37
- package/src/helper/threeMixin.js +40 -101
- package/src/main.js +22 -18
- package/src/store/AddMargin.js +87 -83
- package/src/store/hydrateData.js +40 -30
- package/src/store/nodesEdgesCreation.js +177 -160
- package/src/store/three-d-module.js +41 -27
- package/src/utils/cancellablePromise.js +23 -0
- package/.eslintrc.json +0 -18
- package/src/helper/geo-three.module.js +0 -1903
|
@@ -7,17 +7,6 @@ export default {
|
|
|
7
7
|
mixins: [renderMixin, cameraMixin],
|
|
8
8
|
data() {
|
|
9
9
|
return {
|
|
10
|
-
meshes: {
|
|
11
|
-
baseMeshes: {},
|
|
12
|
-
roofMeshes: {},
|
|
13
|
-
flatRoofMeshes: {},
|
|
14
|
-
obstacleMeshes: {},
|
|
15
|
-
panelsMeshes: {},
|
|
16
|
-
nodeMeshes: null,
|
|
17
|
-
edgeMeshes: {},
|
|
18
|
-
roofMarginMeshes: {},
|
|
19
|
-
moduleFieldsMeshes: {}
|
|
20
|
-
},
|
|
21
10
|
lastTic: new Date().getTime() * 1e4,
|
|
22
11
|
//lastTic:(new Date()).getTime()
|
|
23
12
|
lastGeometryEventIdDone: -1,
|
|
@@ -34,7 +23,8 @@ export default {
|
|
|
34
23
|
nodeMeshes: null,
|
|
35
24
|
edgeMeshes: {},
|
|
36
25
|
roofMarginMeshes: {},
|
|
37
|
-
moduleFieldsMeshes: {}
|
|
26
|
+
moduleFieldsMeshes: {},
|
|
27
|
+
tileMeshes: {}
|
|
38
28
|
}
|
|
39
29
|
},
|
|
40
30
|
|
|
@@ -46,7 +36,6 @@ export default {
|
|
|
46
36
|
selectedMapLayer: (state) => state.threeDModule.selectedMapLayer,
|
|
47
37
|
panelOpacity: (state) => state.threeDModule.panelOpacity,
|
|
48
38
|
pvDataMemo: (state) => state.threeDModule.pvDataMemo
|
|
49
|
-
|
|
50
39
|
}),
|
|
51
40
|
...mapGetters({
|
|
52
41
|
selectedTool: 'getSelectedTool',
|
|
@@ -198,8 +187,8 @@ export default {
|
|
|
198
187
|
break
|
|
199
188
|
case 'backgroundTextureChange':
|
|
200
189
|
methodList.push({
|
|
201
|
-
name: '
|
|
202
|
-
method: this.
|
|
190
|
+
name: 'renderTiles',
|
|
191
|
+
method: this.renderTiles,
|
|
203
192
|
arg: []
|
|
204
193
|
})
|
|
205
194
|
break
|
|
@@ -214,23 +203,28 @@ export default {
|
|
|
214
203
|
method: this.applyTextureOnRoofs,
|
|
215
204
|
arg: []
|
|
216
205
|
})
|
|
206
|
+
methodList.push({
|
|
207
|
+
name: 'renderTiles',
|
|
208
|
+
method: this.renderTiles,
|
|
209
|
+
arg: []
|
|
210
|
+
})
|
|
217
211
|
break
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
212
|
+
// methodList.push({
|
|
213
|
+
// name: 'removeImageOverlay',
|
|
214
|
+
// method: this.removeImageOverlay,
|
|
215
|
+
// arg: []
|
|
216
|
+
// })
|
|
217
|
+
// methodList.push({
|
|
218
|
+
// name: 'applyTextureOnBackground',
|
|
219
|
+
// method: this.renderImageOverlayOnBackground,
|
|
220
|
+
// arg: []
|
|
221
|
+
// })
|
|
222
|
+
// methodList.push({
|
|
223
|
+
// name: 'applyTextureOnRoofs',
|
|
224
|
+
// method: this.applyTextureOnRoofs,
|
|
225
|
+
// arg: []
|
|
226
|
+
// })
|
|
227
|
+
// break
|
|
234
228
|
case 'removeImageOverlay':
|
|
235
229
|
case 'changeImageOverlay':
|
|
236
230
|
case 'updateImageOverlay':
|
|
@@ -270,8 +264,8 @@ export default {
|
|
|
270
264
|
this.renderEdges()
|
|
271
265
|
this.renderFlatRoofs()
|
|
272
266
|
},
|
|
273
|
-
|
|
274
|
-
async initializeProjectionMaterial(){
|
|
267
|
+
|
|
268
|
+
async initializeProjectionMaterial() {
|
|
275
269
|
await this.updateProjectionMaterials()
|
|
276
270
|
this.applyTextureOnRoofs()
|
|
277
271
|
},
|
|
@@ -362,10 +356,9 @@ export default {
|
|
|
362
356
|
this.scene = null
|
|
363
357
|
this.camera = null
|
|
364
358
|
this.cameraprojection = null
|
|
365
|
-
Object.values(this.material).forEach((m) =>{
|
|
366
|
-
if(m && m.dispose)
|
|
367
|
-
|
|
368
|
-
} )
|
|
359
|
+
Object.values(this.material).forEach((m) => {
|
|
360
|
+
if (m && m.dispose) m.dispose()
|
|
361
|
+
})
|
|
369
362
|
this.material = null
|
|
370
363
|
this.orbitControl = null
|
|
371
364
|
this.raycaster = null
|
package/src/helper/threeMixin.js
CHANGED
|
@@ -1,79 +1,14 @@
|
|
|
1
1
|
import * as THREE from 'three'
|
|
2
2
|
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
|
|
3
3
|
import { Sky } from 'three/examples/jsm/objects/Sky.js'
|
|
4
|
-
import {
|
|
5
|
-
import {CustomProvider} from './customProvider'
|
|
4
|
+
import { CustomProvider } from './customProvider'
|
|
6
5
|
|
|
7
6
|
export default {
|
|
8
|
-
methods:{
|
|
9
|
-
initialiseThreeMap(){
|
|
10
|
-
if(this.three_map){
|
|
11
|
-
this.three_map.clear()
|
|
12
|
-
this.scene.remove(this.three_map)
|
|
13
|
-
this.clearThreeObjects(this.three_map)
|
|
14
|
-
}
|
|
15
|
-
if(this.background_map){
|
|
16
|
-
this.background_map.clear()
|
|
17
|
-
this.scene.remove(this.background_map)
|
|
18
|
-
this.clearThreeObjects(this.background_map)
|
|
19
|
-
}
|
|
20
|
-
this.background_map=new THREE.Group();
|
|
7
|
+
methods: {
|
|
8
|
+
initialiseThreeMap() {
|
|
21
9
|
//Extention of the map with geo-map
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// Create the map view and add it to your THREE scene
|
|
25
|
-
this.three_map = new MapView(MapView.PLANAR, this.provider);
|
|
26
|
-
this.three_map.rotateX(Math.PI / 2)
|
|
27
|
-
const coef=Math.cos(this.layoutSettings.layout_latitude*Math.PI/180)
|
|
28
|
-
this.three_map.scale.set(2*20015111.9287618*coef, 1, 2*20015111.9287618*coef);
|
|
29
|
-
var coords = UnitsUtils.datumsToSpherical(this.layoutSettings.layout_latitude, this.layoutSettings.layout_longitude)
|
|
30
|
-
this.three_map.position.set(-coords.x*coef,-coords.y*coef,0)
|
|
31
|
-
this.scene.add(this.three_map)
|
|
32
|
-
}else{
|
|
33
|
-
let googleMapType='satellite'
|
|
34
|
-
switch(this.selectedMapLayer.key){
|
|
35
|
-
case 'googleLayerRoadmap':
|
|
36
|
-
googleMapType='roadmap'
|
|
37
|
-
break;
|
|
38
|
-
case 'googleLayer':
|
|
39
|
-
googleMapType='satellite'
|
|
40
|
-
break;
|
|
41
|
-
case 'googleLayerTerrain':
|
|
42
|
-
googleMapType='terrain'
|
|
43
|
-
break;
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
let apiKey = process.env.VUE_APP_GOOGLE_MAP_API_KEY
|
|
48
|
-
let backgroundPlane=[]
|
|
49
|
-
let size=640
|
|
50
|
-
let planeGeometry=[]
|
|
51
|
-
let planeMaterial=[]
|
|
52
|
-
let texture=[]
|
|
53
|
-
let zoomLevels=[19,16]
|
|
54
|
-
for(let indexGoogleBackground=0;indexGoogleBackground<zoomLevels.length; indexGoogleBackground++){
|
|
55
|
-
let zoomLevel=zoomLevels[indexGoogleBackground]
|
|
56
|
-
let groundResolution = (Math.cos(this.layoutSettings.layout_latitude * Math.PI/180) * 2 * Math.PI * 6378137) / (256 * Math.pow(2,zoomLevel))
|
|
57
|
-
let sizeInMeter=groundResolution*size
|
|
58
|
-
planeGeometry[indexGoogleBackground] = new THREE.PlaneGeometry(sizeInMeter, sizeInMeter)
|
|
59
|
-
let googleBackgroundUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${
|
|
60
|
-
this.layoutSettings.layout_latitude +
|
|
61
|
-
',' +
|
|
62
|
-
this.layoutSettings.layout_longitude
|
|
63
|
-
}&maptype=${googleMapType}&zoom=${zoomLevel}&size=${size}x${size}&key=${apiKey}`
|
|
64
|
-
|
|
65
|
-
texture[indexGoogleBackground] = this.loader.load(googleBackgroundUrl)
|
|
66
|
-
planeMaterial[indexGoogleBackground] = new THREE.MeshBasicMaterial({
|
|
67
|
-
map: texture[indexGoogleBackground],
|
|
68
|
-
side: THREE.DoubleSide
|
|
69
|
-
})
|
|
70
|
-
backgroundPlane[indexGoogleBackground] = new THREE.Mesh(planeGeometry[indexGoogleBackground], planeMaterial[indexGoogleBackground])
|
|
71
|
-
backgroundPlane[indexGoogleBackground].position.z = -indexGoogleBackground/2
|
|
72
|
-
this.background_map.add(backgroundPlane[indexGoogleBackground])
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
this.scene.add(this.background_map)
|
|
10
|
+
this.provider = new CustomProvider('', this.selectedMapLayer.key)
|
|
11
|
+
this.renderTiles()
|
|
77
12
|
},
|
|
78
13
|
initSky() {
|
|
79
14
|
// Add Sky
|
|
@@ -83,69 +18,75 @@ export default {
|
|
|
83
18
|
this.scene.add(sky)
|
|
84
19
|
this.clearThreeObjects(sky)
|
|
85
20
|
let sun = new THREE.Vector3()
|
|
86
|
-
|
|
21
|
+
|
|
87
22
|
const uniforms = sky.material.uniforms
|
|
88
23
|
uniforms.up.value = new THREE.Vector3(0, 0, 1)
|
|
89
24
|
uniforms['turbidity'].value = 20
|
|
90
25
|
uniforms['rayleigh'].value = 0.06
|
|
91
26
|
uniforms['mieCoefficient'].value = 0.01
|
|
92
27
|
uniforms['mieDirectionalG'].value = 0.1
|
|
93
|
-
const elevation=10
|
|
94
|
-
const azimuth
|
|
28
|
+
const elevation = 10
|
|
29
|
+
const azimuth = -20
|
|
95
30
|
const phi = THREE.MathUtils.degToRad(90 - elevation)
|
|
96
31
|
const theta = THREE.MathUtils.degToRad(azimuth)
|
|
97
|
-
|
|
32
|
+
|
|
98
33
|
sun.setFromSphericalCoords(1, phi, theta)
|
|
99
|
-
|
|
34
|
+
|
|
100
35
|
uniforms['sunPosition'].value.copy(sun)
|
|
101
|
-
sun=null
|
|
36
|
+
sun = null
|
|
102
37
|
},
|
|
103
38
|
initialiseThree(isInteractive = true) {
|
|
39
|
+
//this.loader.crossOrigin = null
|
|
104
40
|
|
|
105
|
-
//this.loader.crossOrigin = null
|
|
106
|
-
|
|
107
41
|
this.scene.background = new THREE.Color(0xb0b0b0)
|
|
108
42
|
|
|
109
43
|
this.camera.position.set(0, -100, 50)
|
|
110
44
|
this.camera.up.set(0, 0, 1)
|
|
111
|
-
|
|
112
|
-
this.cameraprojection = new THREE.PerspectiveCamera(
|
|
45
|
+
|
|
46
|
+
this.cameraprojection = new THREE.PerspectiveCamera(
|
|
47
|
+
1,
|
|
48
|
+
300 / 300,
|
|
49
|
+
100,
|
|
50
|
+
1000
|
|
51
|
+
)
|
|
113
52
|
this.cameraprojection.position.set(0, 0, 24)
|
|
114
53
|
this.cameraprojection.up.set(0, 0, 1)
|
|
115
|
-
|
|
54
|
+
|
|
116
55
|
// const helper = new THREE.CameraHelper( this.cameraprojection );
|
|
117
56
|
// this.scene.add( helper );
|
|
118
|
-
|
|
57
|
+
|
|
119
58
|
// const axesHelper = new THREE.AxesHelper( 20 );
|
|
120
59
|
// this.scene.add( axesHelper );
|
|
121
60
|
//Light
|
|
122
61
|
const ambientLight = new THREE.AmbientLight(0xf0f0f0, 0.5)
|
|
123
62
|
this.scene.add(ambientLight)
|
|
124
|
-
|
|
125
|
-
var directionalLight = new THREE.DirectionalLight(0xffffff, 0.5)
|
|
126
|
-
directionalLight.position.set(0, 1000, 500)
|
|
127
|
-
var directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.5)
|
|
128
|
-
directionalLight2.position.set(0, -1000, 500)
|
|
129
|
-
this.scene.add(directionalLight)
|
|
130
|
-
this.scene.add(directionalLight2)
|
|
131
|
-
|
|
63
|
+
|
|
64
|
+
var directionalLight = new THREE.DirectionalLight(0xffffff, 0.5)
|
|
65
|
+
directionalLight.position.set(0, 1000, 500)
|
|
66
|
+
var directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.5)
|
|
67
|
+
directionalLight2.position.set(0, -1000, 500)
|
|
68
|
+
this.scene.add(directionalLight)
|
|
69
|
+
this.scene.add(directionalLight2)
|
|
70
|
+
|
|
132
71
|
// this.renderer.setClearColor('#ffffff');
|
|
133
72
|
this.renderer.setPixelRatio(window.devicePixelRatio)
|
|
134
73
|
this.renderer.toneMappingExposure = 0.01
|
|
135
74
|
this.$refs.canvas3DContainer.appendChild(this.renderer.domElement)
|
|
136
|
-
|
|
75
|
+
|
|
137
76
|
//sky
|
|
138
77
|
this.initSky()
|
|
139
|
-
if(isInteractive){
|
|
140
|
-
this.orbitControl=new OrbitControls(
|
|
141
|
-
|
|
78
|
+
if (isInteractive) {
|
|
79
|
+
this.orbitControl = new OrbitControls(
|
|
80
|
+
this.camera,
|
|
81
|
+
this.renderer.domElement
|
|
82
|
+
)
|
|
83
|
+
this.orbitControl.maxPolarAngle = (Math.PI / 2) * (87 / 90)
|
|
142
84
|
}
|
|
143
85
|
window.addEventListener('resize', this.onWindowResize, false)
|
|
144
|
-
|
|
86
|
+
|
|
145
87
|
ambientLight.dispose()
|
|
146
88
|
directionalLight.dispose()
|
|
147
89
|
directionalLight2.dispose()
|
|
148
|
-
|
|
149
90
|
},
|
|
150
91
|
onWindowResize() {
|
|
151
92
|
this.camera.aspect = window.innerWidth / window.innerHeight
|
|
@@ -173,8 +114,6 @@ export default {
|
|
|
173
114
|
|
|
174
115
|
// update any render target sizes here
|
|
175
116
|
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/main.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
import Vue from
|
|
1
|
+
import Vue from 'vue'
|
|
2
2
|
import Vuex from 'vuex'
|
|
3
3
|
import App from './App.vue'
|
|
4
4
|
// import axios from 'axios'
|
|
5
5
|
import threeDModule from './store/three-d-module'
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
Vue.use(Vuex)
|
|
9
8
|
|
|
10
9
|
const Renderer = class {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
constructor() {}
|
|
11
|
+
mount(identifier, geometryData, specificData, isInteractive = false) {
|
|
12
|
+
const myStore = new Vuex.Store({
|
|
13
|
+
modules: {
|
|
14
|
+
threeDModule: {
|
|
15
|
+
...threeDModule,
|
|
16
|
+
state: {
|
|
17
|
+
...threeDModule.state,
|
|
18
|
+
geometryData,
|
|
19
|
+
...specificData,
|
|
20
|
+
isInteractive
|
|
19
21
|
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
this.App = new Vue({
|
|
26
|
+
store: myStore,
|
|
27
|
+
render: (h) => h(App)
|
|
28
|
+
})
|
|
29
|
+
this.App.$mount(identifier)
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
|
-
export {Renderer}
|
|
32
|
+
export { Renderer }
|
package/src/store/AddMargin.js
CHANGED
|
@@ -1,107 +1,111 @@
|
|
|
1
|
-
import {
|
|
2
|
-
multiplyVector,
|
|
3
|
-
getMarginPoint,
|
|
4
|
-
} from '@eturnity/eturnity_maths'
|
|
1
|
+
import { multiplyVector, getMarginPoint } from '@eturnity/eturnity_maths'
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export function updateMarginsOutline(state) {
|
|
4
|
+
state.polygons
|
|
5
|
+
.filter((p) => p.layer == 'roof')
|
|
6
|
+
.forEach((polygon) => {
|
|
7
|
+
polygon = getRoofMarginOutline(polygon)
|
|
10
8
|
})
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
state.polygons
|
|
10
|
+
.filter((p) => p.layer == 'obstacle')
|
|
11
|
+
.forEach((polygon) => {
|
|
12
|
+
polygon = getObstacleMarginOutline(polygon)
|
|
13
13
|
})
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
return state
|
|
15
|
+
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
17
|
+
export function updateMarginOutlinePolygon(polygon) {
|
|
18
|
+
if (polygon.layer == 'roof') {
|
|
19
|
+
return getRoofMarginOutline(polygon)
|
|
20
|
+
} else if (polygon.layer == 'obstacle') {
|
|
21
|
+
return getObstacleMarginOutline(polygon)
|
|
22
|
+
} else {
|
|
23
|
+
return polygon
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
polygon.margins.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getRoofMarginOutline(polygon) {
|
|
28
|
+
let clockwiseNormalVector = polygon.normalVector
|
|
29
|
+
if (!polygon.isClockwise) {
|
|
30
|
+
clockwiseNormalVector = multiplyVector(-1, clockwiseNormalVector)
|
|
31
|
+
}
|
|
32
|
+
//outterOutline is the outline close to the wall
|
|
33
|
+
polygon.margins.outterOutline = polygon.flatOutline
|
|
34
|
+
polygon.margins.innerOutline = []
|
|
35
|
+
const length = polygon.margins.outterOutline.length
|
|
36
|
+
for (let index = 0; index < length; index++) {
|
|
37
|
+
const B = polygon.margins.outterOutline[index]
|
|
38
|
+
//A,B,C three consecutive points on the polygon.
|
|
39
|
+
//n is a vector in the plan normal to AB of length margin[A] directed towards the inside
|
|
40
|
+
//m is a vector in the plan normal to BC of length margin[B] directed towards the inside
|
|
41
|
+
//K is the margin outline linked with B
|
|
42
|
+
const A = polygon.margins.outterOutline[(index - 1 + length) % length]
|
|
43
|
+
const C = polygon.margins.outterOutline[(index + 1) % length]
|
|
44
|
+
//filling the margins values if not initiated.
|
|
45
|
+
let marginA
|
|
46
|
+
let marginB
|
|
47
|
+
if (polygon.margins.isSameMargin) {
|
|
48
|
+
marginA = polygon.margins.sameMargin
|
|
49
|
+
marginB = polygon.margins.sameMargin
|
|
50
|
+
polygon.margins.distances[index] = polygon.margins.sameMargin
|
|
51
|
+
} else {
|
|
52
|
+
if (
|
|
53
|
+
!polygon.margins.distances[(index - 1 + length) % length] === undefined
|
|
54
|
+
) {
|
|
55
|
+
polygon.margins.distances[(index - 1 + length) % length] =
|
|
56
|
+
polygon.margins.sameMargin
|
|
57
|
+
}
|
|
58
|
+
if (!polygon.margins.distances[index] === undefined) {
|
|
59
|
+
polygon.margins.distances[index] = polygon.margins.sameMargin
|
|
61
60
|
}
|
|
62
|
-
|
|
63
|
-
polygon.margins.
|
|
61
|
+
marginA = polygon.margins.distances[(index - 1 + length) % length]
|
|
62
|
+
marginB = polygon.margins.distances[index]
|
|
64
63
|
}
|
|
65
|
-
|
|
64
|
+
let K = getMarginPoint(A, B, C, marginA, marginB, clockwiseNormalVector)
|
|
65
|
+
polygon.margins.innerOutline.push(K)
|
|
66
66
|
}
|
|
67
|
+
return polygon
|
|
68
|
+
}
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
clockwiseNormalVector=multiplyVector(-1,clockwiseNormalVector)
|
|
70
|
+
export function getObstacleMarginOutline(polygon) {
|
|
71
|
+
let clockwiseNormalVector = polygon.normalVector
|
|
72
|
+
if (polygon.isClockwise) {
|
|
73
|
+
clockwiseNormalVector = multiplyVector(-1, clockwiseNormalVector)
|
|
73
74
|
}
|
|
74
75
|
//outterOutline is the outline close to the wall
|
|
75
|
-
polygon.margins.innerOutline=polygon.flatOutline
|
|
76
|
-
polygon.margins.outterOutline=[]
|
|
77
|
-
const length=polygon.margins.innerOutline.length
|
|
78
|
-
for(let index=0;index<length;index++){
|
|
79
|
-
const B=polygon.margins.innerOutline[index]
|
|
76
|
+
polygon.margins.innerOutline = polygon.flatOutline
|
|
77
|
+
polygon.margins.outterOutline = []
|
|
78
|
+
const length = polygon.margins.innerOutline.length
|
|
79
|
+
for (let index = 0; index < length; index++) {
|
|
80
|
+
const B = polygon.margins.innerOutline[index]
|
|
80
81
|
//A,B,C three consecutive points on the polygon.
|
|
81
82
|
//n is a vector in the plan normal to AB of length margin[A] directed towards the inside
|
|
82
83
|
//m is a vector in the plan normal to BC of length margin[B] directed towards the inside
|
|
83
84
|
//K is the margin outline linked with B
|
|
84
|
-
const A=polygon.margins.innerOutline[(index-1+length)%length]
|
|
85
|
-
const C=polygon.margins.innerOutline[(index+1)%length]
|
|
85
|
+
const A = polygon.margins.innerOutline[(index - 1 + length) % length]
|
|
86
|
+
const C = polygon.margins.innerOutline[(index + 1) % length]
|
|
86
87
|
//filling the margins values if not initiated.
|
|
87
88
|
let marginA
|
|
88
89
|
let marginB
|
|
89
|
-
if(polygon.margins.isSameMargin){
|
|
90
|
-
marginA=polygon.margins.sameMargin
|
|
91
|
-
marginB=polygon.margins.sameMargin
|
|
92
|
-
polygon.margins.distances[index]=polygon.margins.sameMargin
|
|
93
|
-
}else{
|
|
94
|
-
if(
|
|
95
|
-
polygon.margins.distances[(index-1+length)%length]
|
|
90
|
+
if (polygon.margins.isSameMargin) {
|
|
91
|
+
marginA = polygon.margins.sameMargin
|
|
92
|
+
marginB = polygon.margins.sameMargin
|
|
93
|
+
polygon.margins.distances[index] = polygon.margins.sameMargin
|
|
94
|
+
} else {
|
|
95
|
+
if (
|
|
96
|
+
polygon.margins.distances[(index - 1 + length) % length] === undefined
|
|
97
|
+
) {
|
|
98
|
+
polygon.margins.distances[(index - 1 + length) % length] =
|
|
99
|
+
polygon.margins.sameMargin
|
|
96
100
|
}
|
|
97
|
-
if(polygon.margins.distances[index]===undefined){
|
|
98
|
-
polygon.margins.distances[index]=polygon.margins.sameMargin
|
|
101
|
+
if (polygon.margins.distances[index] === undefined) {
|
|
102
|
+
polygon.margins.distances[index] = polygon.margins.sameMargin
|
|
99
103
|
}
|
|
100
|
-
marginA=polygon.margins.distances[(index-1+length)%length]
|
|
101
|
-
marginB=polygon.margins.distances[index]
|
|
104
|
+
marginA = polygon.margins.distances[(index - 1 + length) % length]
|
|
105
|
+
marginB = polygon.margins.distances[index]
|
|
102
106
|
}
|
|
103
|
-
let K=getMarginPoint(A,B,C,marginA,marginB,clockwiseNormalVector)
|
|
107
|
+
let K = getMarginPoint(A, B, C, marginA, marginB, clockwiseNormalVector)
|
|
104
108
|
polygon.margins.outterOutline.push(K)
|
|
105
109
|
}
|
|
106
110
|
return polygon
|
|
107
|
-
|
|
111
|
+
}
|