@eturnity/eturnity_3d 6.29.0 → 6.29.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/package.json +6 -6
- package/src/components/ThreeCanvasViewer.vue +0 -2
- package/src/config.js +1 -0
- package/src/helper/cameraMixin.js +95 -0
- package/src/helper/render/background.js +40 -0
- package/src/helper/render/base.js +43 -0
- package/src/helper/render/clear.js +93 -0
- package/src/helper/render/edge.js +85 -0
- package/src/helper/{geometryHandler.js → render/geometryHandler.js} +1 -1
- package/src/helper/render/index.js +16 -0
- package/src/helper/render/loader.js +97 -0
- package/src/helper/render/margin.js +72 -0
- package/src/helper/render/moduleField.js +27 -0
- package/src/helper/render/node.js +47 -0
- package/src/helper/render/obstacle.js +61 -0
- package/src/helper/render/panel.js +88 -0
- package/src/helper/render/roof.js +134 -0
- package/src/helper/renderMixin.js +10 -626
- package/src/helper/threeMixin.js +3 -4
- package/src/store/hydrateData.js +1 -0
- package/src/utils/layers.js +1 -1
- package/src/helper/DFS.js +0 -80
- package/src/helper/clearThreeObjects.js +0 -21
- package/src/helper/graphCreation.js +0 -43
- package/src/helper/projectedMaterial.js +0 -502
|
@@ -1,46 +1,10 @@
|
|
|
1
1
|
import {mapState, mapGetters } from 'vuex'
|
|
2
|
+
import renderMixin from './render'
|
|
3
|
+
import cameraMixin from './cameraMixin'
|
|
2
4
|
import * as THREE from 'three'
|
|
3
|
-
import TWEEN from 'tween'
|
|
4
|
-
import {
|
|
5
|
-
maximumGapLimit,
|
|
6
|
-
colorArrayBase,
|
|
7
|
-
} from '../config'
|
|
8
|
-
import {
|
|
9
|
-
addVector,
|
|
10
|
-
multiplyVector,
|
|
11
|
-
verticalProjectionOnPlane,
|
|
12
|
-
} from '@eturnity/eturnity_maths'
|
|
13
|
-
import {
|
|
14
|
-
getBufferWallGeometry,
|
|
15
|
-
updateBufferWallGeometry,
|
|
16
|
-
getBufferRoofGeometry,
|
|
17
|
-
updateBufferRoofGeometry,
|
|
18
|
-
getBufferObstacleGeometry,
|
|
19
|
-
getBufferObstacleSideGeometry,
|
|
20
|
-
getBufferModuleFieldGeometry,
|
|
21
|
-
getBufferPanelGeometry,
|
|
22
|
-
updateBufferPanelGeometry,
|
|
23
|
-
getBufferPanelSideGeometry,
|
|
24
|
-
updateBufferPanelSideGeometry,
|
|
25
|
-
getBufferRoofMarginGeometry
|
|
26
|
-
} from './geometryHandler'
|
|
27
|
-
import ProjectedMaterial from 'three-projected-material'
|
|
28
|
-
import { material } from './materials'
|
|
29
|
-
import { intersectOutlines } from '@eturnity/eturnity_maths'
|
|
30
|
-
import clearThreeObjects from './clearThreeObjects'
|
|
31
|
-
const meshTypes = [
|
|
32
|
-
'baseMeshes',
|
|
33
|
-
'roofMeshes',
|
|
34
|
-
'flatRoofMeshes',
|
|
35
|
-
'obstacleMeshes',
|
|
36
|
-
'panelsMeshes',
|
|
37
|
-
'nodeMeshes',
|
|
38
|
-
'edgeMeshes',
|
|
39
|
-
'roofMarginMeshes',
|
|
40
|
-
'moduleFieldsMeshes'
|
|
41
|
-
]
|
|
42
5
|
|
|
43
6
|
export default {
|
|
7
|
+
mixins:[renderMixin,cameraMixin],
|
|
44
8
|
data() {
|
|
45
9
|
return {
|
|
46
10
|
meshes: {
|
|
@@ -276,11 +240,6 @@ export default {
|
|
|
276
240
|
this.renderFlatRoofs()
|
|
277
241
|
},
|
|
278
242
|
|
|
279
|
-
renderBackground() {
|
|
280
|
-
if(!this.background_map){
|
|
281
|
-
this.initialiseThreeMap()
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
243
|
applyTextureOnRoofs(){
|
|
285
244
|
this.roofs.forEach(roof=>{
|
|
286
245
|
//roofs
|
|
@@ -297,503 +256,13 @@ export default {
|
|
|
297
256
|
})
|
|
298
257
|
})
|
|
299
258
|
},
|
|
300
|
-
|
|
301
|
-
//rendering of walls
|
|
302
|
-
//this.clearByType('baseMeshes')
|
|
303
|
-
this.clearRemovedOnes('baseMeshes')
|
|
304
|
-
let geometry
|
|
305
|
-
let mesh
|
|
306
|
-
this.roofs.forEach((roofPolygon) => {
|
|
307
|
-
//everythime the essencials data are changed, version goes up. we compare polygon version and mesh version to know if we have to rerender
|
|
308
|
-
if (
|
|
309
|
-
this.meshes.baseMeshes[roofPolygon.id] &&
|
|
310
|
-
this.meshes.baseMeshes[roofPolygon.id].userData.version <
|
|
311
|
-
roofPolygon.version
|
|
312
|
-
) {
|
|
313
|
-
//this.clearMesh(this.meshes.baseMeshes[roofPolygon.id])
|
|
314
|
-
mesh = this.meshes.baseMeshes[roofPolygon.id]
|
|
315
|
-
geometry = mesh.geometry
|
|
316
|
-
geometry = updateBufferWallGeometry(roofPolygon, geometry)
|
|
317
|
-
mesh.geometry = geometry
|
|
318
|
-
mesh.updateMatrix()
|
|
319
|
-
}
|
|
320
|
-
if (!this.meshes.baseMeshes[roofPolygon.id]) {
|
|
321
|
-
//create
|
|
322
|
-
geometry = getBufferWallGeometry(roofPolygon)
|
|
323
|
-
mesh = new THREE.Mesh(geometry, this.material.wall)
|
|
324
|
-
mesh.userData.version = roofPolygon.version
|
|
325
|
-
mesh.userData.type = 'baseMeshes'
|
|
326
|
-
mesh.userData.meshId = roofPolygon.id
|
|
327
|
-
mesh.userData.polygonId = roofPolygon.id
|
|
328
|
-
mesh.matrixAutoUpdate = false
|
|
329
|
-
mesh.frustumCulled = false
|
|
330
|
-
//geometry.dispose()
|
|
331
|
-
//geometry=null
|
|
332
|
-
this.scene.add(mesh)
|
|
333
|
-
this.meshes.baseMeshes[roofPolygon.id] = mesh
|
|
334
|
-
}
|
|
335
|
-
})
|
|
336
|
-
},
|
|
337
|
-
updateRoofGeometry(geometry, roofPolygon) {
|
|
338
|
-
const roofOutline = roofPolygon.outline
|
|
339
|
-
let cropedHolesOutline = roofPolygon.holes
|
|
340
|
-
.filter((h) => h.layer == 'obstacle')
|
|
341
|
-
.map((h) => {
|
|
342
|
-
//let's crop obstacle with roof outline
|
|
343
|
-
const cropedHoleOutline =
|
|
344
|
-
intersectOutlines(h.outline, roofPolygon.outline)[0] || []
|
|
345
|
-
const outline = cropedHoleOutline.map((p) => {
|
|
346
|
-
return {
|
|
347
|
-
x: p.x,
|
|
348
|
-
y: p.y,
|
|
349
|
-
z: verticalProjectionOnPlane(
|
|
350
|
-
p,
|
|
351
|
-
roofPolygon.normalVector,
|
|
352
|
-
roofPolygon.flatOutline[0]
|
|
353
|
-
).z
|
|
354
|
-
}
|
|
355
|
-
})
|
|
356
|
-
return outline
|
|
357
|
-
})
|
|
358
|
-
|
|
359
|
-
cropedHolesOutline = cropedHolesOutline.filter((outline) => !!outline)
|
|
360
|
-
geometry = updateBufferRoofGeometry(
|
|
361
|
-
roofOutline,
|
|
362
|
-
cropedHolesOutline,
|
|
363
|
-
geometry
|
|
364
|
-
)
|
|
365
|
-
|
|
366
|
-
return geometry
|
|
367
|
-
},
|
|
368
|
-
createRoofGeometry(roofPolygon) {
|
|
369
|
-
const roofOutline = roofPolygon.outline
|
|
370
|
-
let cropedHolesOutline = roofPolygon.holes
|
|
371
|
-
.filter((h) => h.layer == 'obstacle')
|
|
372
|
-
.map((h) => {
|
|
373
|
-
//let's crop obstacle with roof outline
|
|
374
|
-
const cropedHoleOutline =
|
|
375
|
-
intersectOutlines(h.outline, roofPolygon.outline)[0] || []
|
|
376
|
-
const outline = cropedHoleOutline.map((p) => {
|
|
377
|
-
return {
|
|
378
|
-
x: p.x,
|
|
379
|
-
y: p.y,
|
|
380
|
-
z: verticalProjectionOnPlane(
|
|
381
|
-
p,
|
|
382
|
-
roofPolygon.normalVector,
|
|
383
|
-
roofPolygon.flatOutline[0]
|
|
384
|
-
).z
|
|
385
|
-
}
|
|
386
|
-
})
|
|
387
|
-
return outline
|
|
388
|
-
})
|
|
389
|
-
|
|
390
|
-
cropedHolesOutline = cropedHolesOutline.filter((outline) => !!outline)
|
|
391
|
-
let geometry = getBufferRoofGeometry(roofOutline, cropedHolesOutline)
|
|
392
|
-
|
|
393
|
-
return geometry
|
|
394
|
-
},
|
|
395
|
-
renderRoofs() {
|
|
396
|
-
this.clearRemovedOnes('roofMeshes')
|
|
397
|
-
this.roofs.forEach((roofPolygon) => {
|
|
398
|
-
let mesh
|
|
399
|
-
let geometry
|
|
400
|
-
if (
|
|
401
|
-
this.meshes.roofMeshes[roofPolygon.id] &&
|
|
402
|
-
this.meshes.roofMeshes[roofPolygon.id].userData.version <
|
|
403
|
-
roofPolygon.version
|
|
404
|
-
) {
|
|
405
|
-
//update mesh
|
|
406
|
-
mesh = this.meshes.roofMeshes[roofPolygon.id]
|
|
407
|
-
geometry = mesh.geometry
|
|
408
|
-
geometry = this.updateRoofGeometry(geometry, roofPolygon)
|
|
409
|
-
mesh.geometry = geometry
|
|
410
|
-
if(this.material.roof){
|
|
411
|
-
mesh.material=this.material.roof
|
|
412
|
-
if(this.material.roof && this.material.roof.project) this.material.roof.project(mesh)
|
|
413
|
-
}
|
|
414
|
-
mesh.frustumCulled = false
|
|
415
|
-
mesh.updateMatrix()
|
|
416
|
-
}
|
|
417
|
-
if (!this.meshes.roofMeshes[roofPolygon.id]) {
|
|
418
|
-
//create
|
|
419
|
-
geometry = this.createRoofGeometry(roofPolygon)
|
|
420
|
-
if (geometry) {
|
|
421
|
-
mesh = new THREE.Mesh(geometry, this.material.roof)
|
|
422
|
-
mesh.userData.version = roofPolygon.version
|
|
423
|
-
mesh.userData.type = 'roofMeshes'
|
|
424
|
-
mesh.userData.meshId = roofPolygon.id
|
|
425
|
-
mesh.userData.polygonId = roofPolygon.id
|
|
426
|
-
mesh.matrixAutoUpdate = false
|
|
427
|
-
this.scene.add(mesh)
|
|
428
|
-
if(this.material.roof){
|
|
429
|
-
mesh.material=this.material.roof
|
|
430
|
-
if(this.material.roof.project) this.material.roof.project(mesh)
|
|
431
|
-
}
|
|
432
|
-
mesh.frustumCulled = false
|
|
433
|
-
this.meshes.roofMeshes[roofPolygon.id] = mesh
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
})
|
|
437
|
-
},
|
|
438
|
-
renderFlatRoofs() {
|
|
439
|
-
//this.clearRemovedOnes('flatRoofMeshes')
|
|
440
|
-
this.clearByType('flatRoofMeshes')
|
|
441
|
-
this.roofs.forEach((roofPolygon) => {
|
|
442
|
-
//if(this.meshes.flatRoofMeshes[roofPolygon.id])
|
|
443
|
-
if(roofPolygon.maximumGap < maximumGapLimit) return
|
|
444
|
-
let geometry = getBufferRoofGeometry(roofPolygon.flatOutline)
|
|
445
|
-
if (geometry) {
|
|
446
|
-
const material =this.material.curvedRoof
|
|
447
|
-
const mesh = new THREE.Mesh(geometry, material)
|
|
448
|
-
geometry.dispose()
|
|
449
|
-
geometry = null
|
|
450
|
-
mesh.itemData = roofPolygon
|
|
451
|
-
mesh.frustumCulled = false
|
|
452
|
-
this.scene.add(mesh)
|
|
453
|
-
this.meshes.flatRoofMeshes[roofPolygon.id] = mesh
|
|
454
|
-
}
|
|
455
|
-
})
|
|
456
|
-
},
|
|
457
|
-
renderRoofsMargin() {
|
|
458
|
-
this.clearByType('roofMarginMeshes')
|
|
459
|
-
|
|
460
|
-
if (this.selectedTool == 'selectMargin') {
|
|
461
|
-
this.roofs.forEach((roofPolygon) => {
|
|
462
|
-
const geometries = getBufferRoofMarginGeometry(roofPolygon)
|
|
463
|
-
|
|
464
|
-
geometries.forEach((geometry, index) => {
|
|
465
|
-
if (geometry) {
|
|
466
|
-
const marginColor = roofPolygon.margins.isSameMargin
|
|
467
|
-
? colorArrayBase[0]
|
|
468
|
-
: colorArrayBase[index % colorArrayBase.length]
|
|
469
|
-
let material = new THREE.MeshPhongMaterial({
|
|
470
|
-
color: marginColor,
|
|
471
|
-
specular: 0x009900,
|
|
472
|
-
shininess: 0,
|
|
473
|
-
flatShading: true,
|
|
474
|
-
side: THREE.DoubleSide,
|
|
475
|
-
transparent: true,
|
|
476
|
-
opacity: 0.8
|
|
477
|
-
})
|
|
478
|
-
const mesh = new THREE.Mesh(geometry, material)
|
|
479
|
-
geometry.dispose()
|
|
480
|
-
this.scene.add(mesh)
|
|
481
|
-
this.meshes.roofMarginMeshes[roofPolygon.id + '_' + index] = mesh
|
|
482
|
-
}
|
|
483
|
-
})
|
|
484
|
-
roofPolygon.holes.forEach((obstaclePolygon) => {
|
|
485
|
-
const geometries = getBufferRoofMarginGeometry(
|
|
486
|
-
obstaclePolygon,
|
|
487
|
-
roofPolygon
|
|
488
|
-
)
|
|
489
|
-
geometries.forEach((geometry, index) => {
|
|
490
|
-
if (geometry) {
|
|
491
|
-
const marginColor = obstaclePolygon.margins.isSameMargin
|
|
492
|
-
? colorArrayBase[0]
|
|
493
|
-
: colorArrayBase[index % colorArrayBase.length]
|
|
494
|
-
let material = new THREE.MeshPhongMaterial({
|
|
495
|
-
color: marginColor,
|
|
496
|
-
specular: 0x009900,
|
|
497
|
-
shininess: 0,
|
|
498
|
-
flatShading: true,
|
|
499
|
-
side: THREE.DoubleSide,
|
|
500
|
-
transparent: true,
|
|
501
|
-
opacity: 0.8
|
|
502
|
-
})
|
|
503
|
-
const mesh = new THREE.Mesh(geometry, material)
|
|
504
|
-
geometry.dispose()
|
|
505
|
-
geometry = null
|
|
506
|
-
material.dispose()
|
|
507
|
-
material = null
|
|
508
|
-
this.scene.add(mesh)
|
|
509
|
-
this.meshes.roofMarginMeshes[
|
|
510
|
-
obstaclePolygon.id + '_' + roofPolygon.id + '_' + index
|
|
511
|
-
] = mesh
|
|
512
|
-
}
|
|
513
|
-
})
|
|
514
|
-
})
|
|
515
|
-
})
|
|
516
|
-
}
|
|
517
|
-
},
|
|
518
|
-
renderNodes() {
|
|
519
|
-
let geometry
|
|
520
|
-
if (this.meshes.nodeMeshes) {
|
|
521
|
-
geometry = this.meshes.nodeMeshes.geometry
|
|
522
|
-
geometry.attributes.position.needsUpdate = true
|
|
523
|
-
} else {
|
|
524
|
-
geometry = new THREE.BufferGeometry()
|
|
525
|
-
}
|
|
526
|
-
// let geometry = new THREE.SphereGeometry(node3DRadius, 4, 4)
|
|
527
|
-
const vertices = []
|
|
528
|
-
this.nodes
|
|
529
|
-
.filter((node) => node.layer == 'roof')
|
|
530
|
-
.forEach((node) => {
|
|
531
|
-
vertices.push(node.x / 1000, node.y / 1000, node.z / 1000)
|
|
532
|
-
})
|
|
533
|
-
|
|
534
|
-
if (
|
|
535
|
-
geometry.attributes.position &&
|
|
536
|
-
geometry.attributes.position.array.length <= vertices.length
|
|
537
|
-
) {
|
|
538
|
-
let positions = geometry.attributes.position.array
|
|
539
|
-
for (let k in vertices) {
|
|
540
|
-
positions[k] = vertices[k]
|
|
541
|
-
}
|
|
542
|
-
geometry.setDrawRange(0, vertices.length / 3)
|
|
543
|
-
} else {
|
|
544
|
-
geometry.setAttribute(
|
|
545
|
-
'position',
|
|
546
|
-
new THREE.Float32BufferAttribute(vertices, 3)
|
|
547
|
-
)
|
|
548
|
-
}
|
|
549
|
-
let material = this.material.node
|
|
550
|
-
const nodeMeshes = new THREE.Points(geometry, material)
|
|
551
|
-
nodeMeshes.userData.version = 0
|
|
552
|
-
nodeMeshes.userData.type = 'nodeMeshes'
|
|
553
|
-
nodeMeshes.userData.meshId = null
|
|
554
|
-
nodeMeshes.userData.polygonId = null
|
|
555
|
-
nodeMeshes.matrixAutoUpdate = false
|
|
556
|
-
this.meshes.nodeMeshes = nodeMeshes
|
|
557
|
-
this.scene.add(nodeMeshes)
|
|
558
|
-
|
|
559
|
-
},
|
|
560
|
-
renderEdges() {
|
|
561
|
-
this.clearEdgesRemovedOnes('edgeMeshes')
|
|
562
|
-
let cylinder
|
|
563
|
-
//this.clearByType('edgeMeshes')
|
|
564
|
-
// const material = new THREE.LineBasicMaterial( { color: beamColor,transparent:true,opacity:beamOpacity ,sizeAttenuation: true} );
|
|
565
|
-
// material.linewidth=5
|
|
566
|
-
const material = this.material.edge
|
|
567
|
-
this.edges
|
|
568
|
-
.filter((edge) => edge.layer == 'roof')
|
|
569
|
-
.forEach((edge) => {
|
|
570
|
-
cylinder = this.meshes.edgeMeshes[edge.id]
|
|
571
|
-
if (cylinder) {
|
|
572
|
-
//update
|
|
573
|
-
const point_0 = new THREE.Vector3(
|
|
574
|
-
edge.outline[0].x / 1000,
|
|
575
|
-
edge.outline[0].y / 1000,
|
|
576
|
-
edge.outline[0].z / 1000
|
|
577
|
-
)
|
|
578
|
-
const point_1 = new THREE.Vector3(
|
|
579
|
-
edge.outline[1].x / 1000,
|
|
580
|
-
edge.outline[1].y / 1000,
|
|
581
|
-
edge.outline[1].z / 1000
|
|
582
|
-
)
|
|
583
|
-
const midPoint = point_0.clone().add(point_1).multiplyScalar(0.5)
|
|
584
|
-
var direction = new THREE.Vector3().subVectors(point_1, point_0)
|
|
585
|
-
let length = direction.length()
|
|
586
|
-
//cylinder.rotation.set(arrow.rotation)
|
|
587
|
-
var axis = new THREE.Vector3(0, 1, 0)
|
|
588
|
-
cylinder.quaternion.setFromUnitVectors(
|
|
589
|
-
axis,
|
|
590
|
-
direction.clone().normalize()
|
|
591
|
-
)
|
|
592
|
-
//cylinder.position.set(new THREE.Vector3().addVectors( pointX, direction.multiplyScalar(0.5) ))
|
|
593
|
-
cylinder.position.copy(midPoint.clone())
|
|
594
|
-
let oldLength = cylinder.userData.cylinderLength
|
|
595
|
-
let newLength = length
|
|
596
|
-
if (oldLength != 0) {
|
|
597
|
-
let scaleRatio = newLength / oldLength
|
|
598
|
-
//let scaleVector=direction.multiplyScalar(scaleRatio-1)
|
|
599
|
-
cylinder.scale.set(1, newLength, 1)
|
|
600
|
-
cylinder.userData.cylinderLength = newLength
|
|
601
|
-
}
|
|
602
|
-
cylinder.updateMatrix()
|
|
603
|
-
//change cylinder length
|
|
604
|
-
} else {
|
|
605
|
-
const point_0 = new THREE.Vector3(
|
|
606
|
-
edge.outline[0].x / 1000,
|
|
607
|
-
edge.outline[0].y / 1000,
|
|
608
|
-
edge.outline[0].z / 1000
|
|
609
|
-
)
|
|
610
|
-
const point_1 = new THREE.Vector3(
|
|
611
|
-
edge.outline[1].x / 1000,
|
|
612
|
-
edge.outline[1].y / 1000,
|
|
613
|
-
edge.outline[1].z / 1000
|
|
614
|
-
)
|
|
615
|
-
|
|
616
|
-
const midPoint = point_0.clone().add(point_1).multiplyScalar(0.5)
|
|
617
|
-
var direction = new THREE.Vector3().subVectors(point_1, point_0)
|
|
618
|
-
let length = direction.length()
|
|
619
|
-
const geometry = new THREE.CylinderGeometry(0.1, 0.1, 1, 6)
|
|
620
|
-
cylinder = new THREE.Mesh(geometry, material)
|
|
621
|
-
cylinder.scale.set(1, length, 1)
|
|
622
|
-
cylinder.userData.cylinderLength = length
|
|
623
|
-
//cylinder.rotation.set(arrow.rotation)
|
|
624
|
-
var axis = new THREE.Vector3(0, 1, 0)
|
|
625
|
-
cylinder.quaternion.setFromUnitVectors(
|
|
626
|
-
axis,
|
|
627
|
-
direction.clone().normalize()
|
|
628
|
-
)
|
|
629
|
-
//cylinder.position.set(new THREE.Vector3().addVectors( pointX, direction.multiplyScalar(0.5) ))
|
|
630
|
-
cylinder.position.copy(midPoint.clone())
|
|
631
|
-
//cylinder.position.set(edge.outline[0].x/1000, edge.outline[0].y/1000, edge.outline[0].z/1000);
|
|
632
|
-
cylinder.userData.edgeId = edge.id
|
|
633
|
-
cylinder.matrixAutoUpdate = false
|
|
634
|
-
this.meshes.edgeMeshes[edge.id] = cylinder
|
|
635
|
-
this.scene.add(cylinder)
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
})
|
|
639
|
-
},
|
|
640
|
-
|
|
641
|
-
renderObstacles() {
|
|
642
|
-
this.clearByType('obstacleMeshes')
|
|
643
|
-
|
|
644
|
-
this.roofs.forEach((roofPolygon) => {
|
|
645
|
-
roofPolygon.holes
|
|
646
|
-
.filter((poly) => poly.layer == 'obstacle')
|
|
647
|
-
.forEach((obstaclePolygon) => {
|
|
648
|
-
const geometry = getBufferObstacleGeometry(
|
|
649
|
-
obstaclePolygon,
|
|
650
|
-
roofPolygon
|
|
651
|
-
)
|
|
652
|
-
|
|
653
|
-
const geometrySide = getBufferObstacleSideGeometry(
|
|
654
|
-
obstaclePolygon,
|
|
655
|
-
roofPolygon
|
|
656
|
-
)
|
|
657
|
-
if (geometry && geometrySide) {
|
|
658
|
-
const mesh = new THREE.Mesh(geometry, this.material.roof)
|
|
659
|
-
const meshSide = new THREE.Mesh(geometrySide, material.wall)
|
|
660
|
-
geometry.dispose()
|
|
661
|
-
geometrySide.dispose()
|
|
662
|
-
if(this.material.roof){
|
|
663
|
-
mesh.material=this.material.roof
|
|
664
|
-
if(this.material.roof.project) this.material.roof.project(mesh)
|
|
665
|
-
}
|
|
666
|
-
mesh.matrixAutoUpdate = false
|
|
667
|
-
meshSide.matrixAutoUpdate = false
|
|
668
|
-
mesh.frustumCulled = false
|
|
669
|
-
meshSide.frustumCulled = false
|
|
670
|
-
this.scene.add(mesh)
|
|
671
|
-
this.scene.add(meshSide)
|
|
672
|
-
this.meshes.obstacleMeshes[
|
|
673
|
-
obstaclePolygon.id + '-' + roofPolygon.id + '_top'
|
|
674
|
-
] = mesh
|
|
675
|
-
this.meshes.obstacleMeshes[
|
|
676
|
-
obstaclePolygon.id + '-' + roofPolygon.id + '_side'
|
|
677
|
-
] = meshSide
|
|
678
|
-
}
|
|
679
|
-
})
|
|
680
|
-
})
|
|
681
|
-
},
|
|
682
|
-
renderModuleFields() {
|
|
683
|
-
this.clearByType('moduleFieldsMeshes')
|
|
684
|
-
|
|
685
|
-
this.moduleFields.forEach((moduleFieldPolygon) => {
|
|
686
|
-
if(!moduleFieldPolygon.data.number_of_panels_override && !this.areModuleFieldsVisible )return
|
|
687
|
-
const geometry = getBufferModuleFieldGeometry(moduleFieldPolygon)
|
|
688
|
-
if (geometry) {
|
|
689
|
-
const mesh = new THREE.Mesh(geometry, this.material.moduleField)
|
|
690
|
-
geometry.dispose()
|
|
691
|
-
mesh.matrixAutoUpdate = false
|
|
692
|
-
mesh.userData.version = moduleFieldPolygon.version
|
|
693
|
-
mesh.userData.type = 'moduleFieldsMeshes'
|
|
694
|
-
mesh.userData.meshId = moduleFieldPolygon.id
|
|
695
|
-
mesh.userData.polygonId = moduleFieldPolygon.id
|
|
696
|
-
this.scene.add(mesh)
|
|
697
|
-
this.meshes.moduleFieldsMeshes[moduleFieldPolygon.id] = mesh
|
|
698
|
-
}
|
|
699
|
-
})
|
|
700
|
-
},
|
|
701
|
-
clearPanelsFromChangingRoofs(roofIds){
|
|
702
|
-
const roofs=this.polygons.filter(polygon=>roofIds.includes(polygon.id))
|
|
703
|
-
roofs.forEach(roof=>roof.moduleFields.forEach(mf=>mf.panels.forEach(panel=>{
|
|
704
|
-
let meshTop=this.meshes.panelsMeshes[panel.id+'_top']
|
|
705
|
-
let meshSide=this.meshes.panelsMeshes[panel.id+'_side']
|
|
706
|
-
if(meshTop || meshSide){
|
|
707
|
-
this.clearMesh(meshTop)
|
|
708
|
-
this.clearMesh(meshSide)
|
|
709
|
-
}
|
|
710
|
-
})
|
|
711
|
-
)
|
|
712
|
-
)
|
|
713
|
-
},
|
|
714
|
-
renderPanels() {
|
|
715
|
-
this.clearRemovedOnes('panelsMeshes')
|
|
716
|
-
Object.values(this.meshes.panelsMeshes).forEach((mesh) => {
|
|
717
|
-
//clear UserDeactivatedModules
|
|
718
|
-
if (
|
|
719
|
-
this.polygons.find(
|
|
720
|
-
(poly) =>
|
|
721
|
-
poly.id == mesh.userData.polygonId &&
|
|
722
|
-
poly.layer == 'user_deactivated_panel'
|
|
723
|
-
)
|
|
724
|
-
) {
|
|
725
|
-
this.clearMesh(mesh)
|
|
726
|
-
}
|
|
727
|
-
//clear panel on moduleField with overriden number of panel
|
|
728
|
-
let panel=this.polygons.find(poly=>mesh.userData.polygonId==poly.id)
|
|
729
|
-
if (
|
|
730
|
-
!panel || panel.moduleField.data.number_of_panels_override
|
|
731
|
-
) {
|
|
732
|
-
this.clearMesh(mesh)
|
|
733
|
-
}
|
|
734
|
-
})
|
|
735
|
-
|
|
736
|
-
this.panels.forEach((panelPolygon) => {
|
|
737
|
-
//definition of the material
|
|
738
|
-
if(panelPolygon.moduleField.data.number_of_panels_override) return
|
|
739
|
-
let material = this.material.panel['default_'+this.moduleTextureVersionId]
|
|
740
|
-
if (panelPolygon.moduleField.pvData) {
|
|
741
|
-
let pvId = panelPolygon.moduleField.pvData.id
|
|
742
|
-
if (this.material.panel[pvId]) {
|
|
743
|
-
material = this.material.panel[pvId]
|
|
744
|
-
}
|
|
745
|
-
}else if(panelPolygon.moduleField.data){
|
|
746
|
-
let pvId = panelPolygon.moduleField.data.component_id_pv_module
|
|
747
|
-
if (this.material.panel[pvId]) {
|
|
748
|
-
material = this.material.panel[pvId]
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
if (
|
|
753
|
-
!this.meshes.panelsMeshes[panelPolygon.id + '_top'] ||
|
|
754
|
-
!this.meshes.panelsMeshes[panelPolygon.id + '_side']
|
|
755
|
-
) {
|
|
756
|
-
const geometry = getBufferPanelGeometry(panelPolygon)
|
|
757
|
-
const geometrySide = getBufferPanelSideGeometry(panelPolygon)
|
|
758
|
-
|
|
759
|
-
if (geometry && geometrySide) {
|
|
760
|
-
|
|
761
|
-
const mesh = new THREE.Mesh(geometry, material)
|
|
762
|
-
const meshSide = new THREE.Mesh(geometrySide, this.material.wall)
|
|
763
|
-
mesh.userData.version = panelPolygon.version
|
|
764
|
-
mesh.userData.type = 'panelsMeshes'
|
|
765
|
-
mesh.userData.meshId = panelPolygon.id + '_top'
|
|
766
|
-
mesh.userData.polygonId = panelPolygon.id
|
|
767
|
-
meshSide.userData.version = panelPolygon.version
|
|
768
|
-
meshSide.userData.type = 'panelsMeshes'
|
|
769
|
-
meshSide.userData.meshId = panelPolygon.id + '_side'
|
|
770
|
-
meshSide.userData.polygonId = panelPolygon.id
|
|
771
|
-
geometry.dispose()
|
|
772
|
-
geometrySide.dispose()
|
|
773
|
-
this.scene.add(mesh)
|
|
774
|
-
this.scene.add(meshSide)
|
|
775
|
-
mesh.matrixAutoUpdate = false
|
|
776
|
-
meshSide.matrixAutoUpdate = false
|
|
777
|
-
this.meshes.panelsMeshes[panelPolygon.id + '_top'] = mesh
|
|
778
|
-
this.meshes.panelsMeshes[panelPolygon.id + '_side'] = meshSide
|
|
779
|
-
}
|
|
780
|
-
}else{
|
|
781
|
-
const topMesh=this.meshes.panelsMeshes[panelPolygon.id + '_top']
|
|
782
|
-
const sideMesh=this.meshes.panelsMeshes[panelPolygon.id + '_side']
|
|
783
|
-
if(panelPolygon.version>topMesh.userData.version){
|
|
784
|
-
topMesh.geometry=updateBufferPanelGeometry(panelPolygon,topMesh.geometry)
|
|
785
|
-
sideMesh.geometry=updateBufferPanelSideGeometry(panelPolygon,sideMesh.geometry)
|
|
786
|
-
}
|
|
787
|
-
topMesh.material= material
|
|
788
|
-
|
|
789
|
-
}
|
|
790
|
-
})
|
|
791
|
-
},
|
|
259
|
+
|
|
792
260
|
async updateProjectionMaterial(){
|
|
793
261
|
await this.loadProjectionMaterial()
|
|
794
262
|
this.applyTextureOnRoofs()
|
|
795
263
|
this.renderBackground()
|
|
796
264
|
},
|
|
265
|
+
<<<<<<< HEAD
|
|
797
266
|
async loadProjectionMaterial() {
|
|
798
267
|
const _this=this
|
|
799
268
|
if(!this.layoutSettings.base64_image_url)
|
|
@@ -945,6 +414,9 @@ export default {
|
|
|
945
414
|
.start()
|
|
946
415
|
}
|
|
947
416
|
},
|
|
417
|
+
=======
|
|
418
|
+
|
|
419
|
+
>>>>>>> origin/EPDM-7663
|
|
948
420
|
getCanvasOffset() {
|
|
949
421
|
if (!this.$refs.canvas3DContainer) return { top: 0, left: 0 }
|
|
950
422
|
var box = this.$refs.canvas3DContainer.getBoundingClientRect()
|
|
@@ -993,94 +465,6 @@ export default {
|
|
|
993
465
|
}
|
|
994
466
|
canvas = null
|
|
995
467
|
},
|
|
996
|
-
clearMesh(mesh) {
|
|
997
|
-
if (!mesh) return
|
|
998
|
-
this.scene.remove(mesh)
|
|
999
|
-
if (mesh.geometry && mesh.geometry.dispose) {
|
|
1000
|
-
mesh.geometry.dispose()
|
|
1001
|
-
mesh.geometry = null
|
|
1002
|
-
}
|
|
1003
|
-
if (mesh.material && mesh.material.dispose) {
|
|
1004
|
-
mesh.material.dispose()
|
|
1005
|
-
mesh.material = null
|
|
1006
|
-
}
|
|
1007
|
-
if (
|
|
1008
|
-
mesh.userData.meshId &&
|
|
1009
|
-
this.meshes[mesh.userData.type][mesh.userData.meshId]
|
|
1010
|
-
) {
|
|
1011
|
-
delete this.meshes[mesh.userData.type][mesh.userData.meshId]
|
|
1012
|
-
} else {
|
|
1013
|
-
this.meshes[mesh.userData.type] = null
|
|
1014
|
-
}
|
|
1015
|
-
mesh = null
|
|
1016
|
-
},
|
|
1017
|
-
clearEdgesRemovedOnes() {
|
|
1018
|
-
Object.values(this.meshes['edgeMeshes']).forEach((mesh) => {
|
|
1019
|
-
if (!this.edgeIds.includes(mesh.userData.edgeId)) {
|
|
1020
|
-
this.clearMesh(mesh)
|
|
1021
|
-
}
|
|
1022
|
-
})
|
|
1023
|
-
},
|
|
1024
|
-
clearNodesRemovedOnes() {
|
|
1025
|
-
Object.values(this.meshes['nodeMeshes']).forEach((mesh) => {
|
|
1026
|
-
if (!this.nodeIds.includes(mesh.userData.nodeId)) {
|
|
1027
|
-
this.clearMesh(mesh)
|
|
1028
|
-
}
|
|
1029
|
-
})
|
|
1030
|
-
},
|
|
1031
|
-
clearRemovedOnes(type) {
|
|
1032
|
-
Object.values(this.meshes[type]).forEach((mesh) => {
|
|
1033
|
-
if (!this.polygonIds.includes(mesh.userData.polygonId)) {
|
|
1034
|
-
this.clearMesh(mesh)
|
|
1035
|
-
}
|
|
1036
|
-
})
|
|
1037
|
-
},
|
|
1038
|
-
clearByType(type) {
|
|
1039
|
-
Object.values(this.meshes[type]).forEach((mesh) => {
|
|
1040
|
-
mesh.geometry.dispose()
|
|
1041
|
-
mesh.geometry = null
|
|
1042
|
-
if (mesh.material.dispose) {
|
|
1043
|
-
mesh.material.dispose()
|
|
1044
|
-
}
|
|
1045
|
-
mesh.material = null
|
|
1046
|
-
this.scene.remove(mesh)
|
|
1047
|
-
})
|
|
1048
|
-
this.meshes[type] = {}
|
|
1049
|
-
this.renderer.renderLists.dispose()
|
|
1050
|
-
},
|
|
1051
|
-
loadNewTexture(){
|
|
1052
|
-
Object.values(this.pvDataMemo).forEach((component) => {
|
|
1053
|
-
const pvId = component.id
|
|
1054
|
-
if (!this.material.panel[pvId]) {
|
|
1055
|
-
if (!component.texture_img_url) {
|
|
1056
|
-
this.material.panel[pvId] = this.material.panel.default
|
|
1057
|
-
} else {
|
|
1058
|
-
let texture = this.loader.load(component.texture_img_url)
|
|
1059
|
-
this.material.panel[pvId] = new THREE.MeshBasicMaterial({
|
|
1060
|
-
map: texture,
|
|
1061
|
-
side: THREE.DoubleSide
|
|
1062
|
-
})
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
})
|
|
1066
|
-
},
|
|
1067
|
-
async loadTextureFromModuleFields(){
|
|
1068
|
-
for(let k=0;k<this.moduleFields.length;k++){
|
|
1069
|
-
let mf=this.moduleFields[k]
|
|
1070
|
-
const pvId = mf.data.component_id_pv_module
|
|
1071
|
-
if (!this.material.panel[pvId]) {
|
|
1072
|
-
if (!mf.data.texture_img_url) {
|
|
1073
|
-
this.material.panel[pvId] = this.material.panel.default
|
|
1074
|
-
} else {
|
|
1075
|
-
let texture = await this.loader.load(mf.data.texture_img_url)
|
|
1076
|
-
this.material.panel[pvId] = new THREE.MeshBasicMaterial({
|
|
1077
|
-
map: texture,
|
|
1078
|
-
side: THREE.DoubleSide
|
|
1079
|
-
})
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
468
|
},
|
|
1085
469
|
watch: {
|
|
1086
470
|
wallColor(color) {
|
|
@@ -1110,10 +494,10 @@ export default {
|
|
|
1110
494
|
if (this.tweenCamera) {
|
|
1111
495
|
this.tweenCamera = null
|
|
1112
496
|
}
|
|
1113
|
-
clearThreeObjects(this.scene)
|
|
497
|
+
this.clearThreeObjects(this.scene)
|
|
1114
498
|
if(this.three_map){
|
|
1115
499
|
this.three_map.clear()
|
|
1116
|
-
clearThreeObjects(this.three_map)
|
|
500
|
+
this.clearThreeObjects(this.three_map)
|
|
1117
501
|
}
|
|
1118
502
|
this.renderer.clear()
|
|
1119
503
|
this.renderer.dispose()
|