@eturnity/eturnity_3d 6.30.0 → 6.31.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.
Files changed (39) hide show
  1. package/bitbucket-pipelines.yml +2 -2
  2. package/dist/assets/images/panels/longiSolarLR4_60HPH_350M.png +0 -0
  3. package/dist/assets/images/panels/longiSolarLR4_60HPH_370M.png +0 -0
  4. package/dist/assets/images/panels/reneSola_Virtus_2_JC320S_24_Bbw copy.png +0 -0
  5. package/dist/assets/images/panels/reneSola_Virtus_2_JC320S_24_Bbw.png +0 -0
  6. package/dist/assets/images/panels/uv.png +0 -0
  7. package/dist/assets/panels/longiSolarLR4_60HPH_350M.png +0 -0
  8. package/dist/assets/panels/longiSolarLR4_60HPH_370M.png +0 -0
  9. package/dist/assets/panels/reneSola_Virtus_2_JC320S_24_Bbw.png +0 -0
  10. package/dist/assets/panels/uv.png +0 -0
  11. package/dist/assets/theme.js +43 -0
  12. package/dist/assets/vue.svg +1 -0
  13. package/dist/css/main.d97599b7.css +1 -0
  14. package/dist/img/longiSolarLR4_60HPH_350M.85a84b2e.png +0 -0
  15. package/dist/img/longiSolarLR4_60HPH_370M.bf6b1f4e.png +0 -0
  16. package/dist/img/reneSola_Virtus_2_JC320S_24_Bbw.8b1892e0.png +0 -0
  17. package/dist/index.html +26 -0
  18. package/dist/main.js +60562 -0
  19. package/dist/main.js.map +1 -0
  20. package/dist/vite.svg +1 -0
  21. package/package.json +2 -2
  22. package/src/components/ThreeCanvasViewer.vue +6 -7
  23. package/src/helper/materialMixin.js +75 -0
  24. package/src/helper/materials.js +2 -1
  25. package/src/helper/render/background.js +2 -34
  26. package/src/helper/render/clear.js +2 -2
  27. package/src/helper/render/geometryHandler.js +50 -1
  28. package/src/helper/render/imageOverlay.js +126 -0
  29. package/src/helper/render/index.js +5 -1
  30. package/src/helper/render/loader.js +7 -62
  31. package/src/helper/render/mapProjection.js +86 -0
  32. package/src/helper/render/obstacle.js +2 -8
  33. package/src/helper/render/panel.js +2 -0
  34. package/src/helper/render/projectionMaterial.js +57 -0
  35. package/src/helper/render/roof.js +19 -8
  36. package/src/helper/render/texture.js +19 -0
  37. package/src/helper/renderMixin.js +46 -38
  38. package/src/store/hydrateData.js +10 -1
  39. package/src/store/three-d-module.js +9 -1
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_3d",
3
3
  "private": false,
4
- "version": "6.30.0",
4
+ "version": "6.31.1",
5
5
  "main": "dist/main.js",
6
6
  "scripts": {
7
7
  "dev": "vue-cli-service serve --skip-plugins @vue/cli-plugin-eslint",
8
8
  "build": "vue-cli-service build --skip-plugins @vue/cli-plugin-eslint"
9
9
  },
10
10
  "dependencies": {
11
- "@eturnity/eturnity_maths": "6.29.0",
11
+ "@eturnity/eturnity_maths": "6.31.1",
12
12
  "axios": "^1.3.2",
13
13
  "core-js": "^2.6.12",
14
14
  "cors": "^2.8.5",
@@ -9,7 +9,7 @@ import { addVector, multiplyVector } from '@eturnity/eturnity_maths'
9
9
  import { updateComputedGeometryPolygon } from '@eturnity/eturnity_maths'
10
10
 
11
11
  import threeMixin from '../helper/threeMixin'
12
- import { material } from '../helper/materials'
12
+ import materialMixin from '../helper/materialMixin'
13
13
  import renderMixin from '../helper/renderMixin'
14
14
  export default {
15
15
  name: 'ThreeCanvas',
@@ -28,7 +28,6 @@ export default {
28
28
  provider:null,
29
29
  cameraprojection: null,
30
30
  texture: null,
31
- material: material,
32
31
  renderer: new THREE.WebGLRenderer({
33
32
  antialias: true,
34
33
  preserveDrawingBuffer: true
@@ -57,21 +56,21 @@ export default {
57
56
  areModuleFieldsVisible:false
58
57
  }
59
58
  },
60
- mixins: [renderMixin,threeMixin],
59
+ mixins: [renderMixin,threeMixin,materialMixin],
61
60
  async mounted() {
62
61
  await this.hydrateData(this.geometryData)
63
62
  this.renderer.domElement.style.width = '100%'
64
63
  this.renderer.domElement.style.height = '100%'
65
64
 
66
65
  this.initialiseThree(this.isInteractive)
67
- this.loadProjectionMaterial()
68
66
  this.initialiseThreeMap()
69
- await this.loadTextureFromModuleFields()
67
+ await this.loadPanelsTexture()
70
68
  this.renderGeometry()
71
69
  this.onWindowResize()
70
+ // this.updateProjectionMaterials()
72
71
  this.animate()
73
72
  this.$root.$on('on-roofSelected',(polygon)=>this.setCameraOrthogonalTo(polygon))
74
- this.updateProjectionMaterial()
73
+ this.initializeProjectionMaterial()
75
74
 
76
75
  const polygon = this.polygons.find((p) => p.id == this.uuid)
77
76
  this.setCamera(polygon, this.view_mode)
@@ -83,6 +82,7 @@ export default {
83
82
  uuid: (state) => state.threeDModule.uuid,
84
83
  view_mode: (state) => state.threeDModule.view_mode,
85
84
  isInteractive: (state) => state.threeDModule.isInteractive,
85
+ imageOverlay: (state) => state.threeDModule.imageOverlay,
86
86
  }),
87
87
  ...mapGetters({
88
88
  polygons: 'getPolygons',
@@ -91,7 +91,6 @@ export default {
91
91
  mapConfig: 'getMapConfig',
92
92
  roofsBounds: 'getRoofsBounds',
93
93
  layoutSettings: 'getLayoutSettings',
94
-
95
94
  roofs: 'getRoofs',
96
95
  obstacles: 'getObstacles',
97
96
  moduleFields: 'getModuleFields',
@@ -0,0 +1,75 @@
1
+ import * as THREE from 'three'
2
+ import {beamColor,beamOpacity,node3DColor,node3dOpacity,defaultTextureUrls} from '../config'
3
+ export default {
4
+ data(){
5
+ return {
6
+ material:{}
7
+ }
8
+ },
9
+ created(){
10
+ let wallColor=0xdddddd
11
+ if(this.wallColor){
12
+ wallColor = new THREE.Color(this.wallColor)
13
+ }
14
+ this.material.wall = new THREE.MeshLambertMaterial({
15
+ color: wallColor,
16
+ side:THREE.DoubleSide
17
+ })
18
+
19
+ this.material.obstacle = new THREE.MeshPhongMaterial({
20
+ color: 0xff0000,
21
+ side:THREE.DoubleSide,
22
+ })
23
+
24
+ this.material.edge=new THREE.MeshPhongMaterial({ color: beamColor,transparent:true,opacity:beamOpacity })
25
+ this.material.node=new THREE.PointsMaterial( { size: 0.05, sizeAttenuation: true,color: node3DColor, opacity:node3dOpacity, transparent: true } );
26
+ const loader = new THREE.TextureLoader()
27
+ // loader.crossOrigin = 'anonymous'
28
+ // texture.minFilter = THREE.LinearFilter
29
+ this.material.panel={}
30
+
31
+ for(let k=0;k<defaultTextureUrls.length;k++){
32
+ let texture=loader.load(defaultTextureUrls[k], function (texture) {})
33
+ this.material.panel['default_'+k] = new THREE.MeshBasicMaterial({
34
+ map: texture,
35
+ side: THREE.DoubleSide,
36
+ })
37
+ }
38
+ this.material.roof=[this.material.wall]
39
+
40
+ this.material.flatRoof = new THREE.MeshPhongMaterial({
41
+ color: 0x00ff00,
42
+ specular: 0x009900,
43
+ shininess: 0,
44
+ flatShading: true,
45
+ side:THREE.DoubleSide,
46
+ transparent:true,
47
+ opacity:0.5
48
+ })
49
+
50
+ this.material.moduleField = new THREE.MeshPhongMaterial({
51
+ color: 0xfc9d03,
52
+ specular: 0x000000,
53
+ shininess: 0,
54
+ flatShading: true,
55
+ side:THREE.DoubleSide,
56
+ transparent:true,
57
+ opacity:0.8
58
+ })
59
+ this.material.curvedRoof = new THREE.MeshPhongMaterial({
60
+ color: 0xffff00,
61
+ specular: 0x009900,
62
+ shininess: 0,
63
+ flatShading: true,
64
+ side:THREE.DoubleSide,
65
+ transparent:true,
66
+ opacity:0.5
67
+ })
68
+ },
69
+ watch: {
70
+ wallColor(color) {
71
+ let wallColor = new THREE.Color(color)
72
+ this.material.wall.color.set(wallColor)
73
+ },
74
+ }
75
+ }
@@ -25,6 +25,7 @@ material.panel={}
25
25
  material.panel['default_'+k] = new THREE.MeshBasicMaterial({
26
26
  map: texture,
27
27
  side: THREE.DoubleSide,
28
+ transparent: true
28
29
  })
29
30
  }
30
31
 
@@ -45,7 +46,7 @@ material.moduleField = new THREE.MeshPhongMaterial({
45
46
  flatShading: true,
46
47
  side:THREE.DoubleSide,
47
48
  transparent:true,
48
- opacity:0.8
49
+ opacity:0.6
49
50
  })
50
51
  material.curvedRoof = new THREE.MeshPhongMaterial({
51
52
  color: 0xffff00,
@@ -1,40 +1,8 @@
1
1
  import * as THREE from 'three'
2
2
 
3
+
3
4
  export default {
4
5
  methods:{
5
- renderBackground() {
6
- // if(this.meshes.backgroundMesh){
7
- // let sizeInMm={width:2000000,height:2000000}
8
- // let positionInMm={x:0,y:0}
9
- // if(this.layoutSettings.background_map_settings && this.layoutSettings.background_map_settings.sizeInMm){
10
- // sizeInMm=this.layoutSettings.background_map_settings.sizeInMm
11
- // positionInMm=this.layoutSettings.background_map_settings.positionInMm
12
- // }
13
-
14
- // this.meshes.backgroundMesh.geometry.dispose()
15
- // let xMin=positionInMm.x/1000-sizeInMm.width/2000
16
- // let xMax=positionInMm.x/1000+sizeInMm.width/2000
17
- // let yMin=positionInMm.y/1000-sizeInMm.height/2000
18
- // let yMax=positionInMm.y/1000+sizeInMm.height/2000
19
- // let c1=[xMin,yMax,0.1]
20
- // let c2=[xMax,yMax,0.1]
21
- // let c3=[xMax,yMin,0.1]
22
- // let c4=[xMin,yMin,0.1]
23
- // let geometry = new THREE.BufferGeometry();
24
- // const vertices = new Float32Array( [
25
- // ...c1,
26
- // ...c4,
27
- // ...c3,
28
- // ...c3,
29
- // ...c2,
30
- // ...c1
31
- // ] );
32
- // geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
33
- // geometry.computeVertexNormals()
34
- // this.meshes.backgroundMesh.geometry=geometry
35
- // }else{
36
- // this.initialiseThreeMap()
37
- // }
38
- },
6
+
39
7
  }
40
8
  }
@@ -12,13 +12,13 @@ export default {
12
12
  //in case of map, bumpMap, normalMap, envMap ...
13
13
  Object.keys(obj.material).forEach((prop) => {
14
14
  if (!obj.material[prop]) return
15
- if (
15
+ if (false &&
16
16
  obj.material[prop] !== null &&
17
17
  typeof obj.material[prop].dispose === 'function'
18
18
  )
19
19
  obj.material[prop].dispose()
20
20
  })
21
- obj.material.dispose()
21
+ if(obj.material.dispose) obj.material.dispose()
22
22
  }
23
23
  },
24
24
  clearPanelsFromChangingRoofs(roofIds){
@@ -375,6 +375,56 @@ export function getBufferModuleFieldGeometry(moduleFieldPolygon) {
375
375
  return geometry
376
376
  }
377
377
 
378
+ export function getBufferImageOverlayGeometry(corners){
379
+ corners.forEach(p=>p.z=0)
380
+ let normalVector = getNormalVectorFrom3Points(
381
+ corners[0],
382
+ corners[1],
383
+ corners[2]
384
+ )
385
+ if (normalVector.z < 0) {
386
+ normalVector = multiplyVector(-1, normalVector)
387
+ }
388
+
389
+ const geometry = new THREE.BufferGeometry()
390
+ //Calcul of triangles using cutear algo
391
+ const trianglesVertices = []
392
+ trianglesVertices.push(...getTriangleVerticesFromOutline(corners))
393
+ if(hasNaN(trianglesVertices)){return null}
394
+ const vertices = new Float32Array(trianglesVertices)
395
+ var A = corners[2]
396
+ var B = corners[3]
397
+ var C = corners[1]
398
+ var D = corners[0]
399
+ const AB = getDistanceBetweenPoints(A, B)
400
+ const AC = getDistanceBetweenPoints(A, C)
401
+ let uvs
402
+ if (AB < AC) {
403
+ uvs = new Float32Array([
404
+ 0, 1,
405
+ 0, 0,
406
+ 1, 0,
407
+
408
+ 0, 1,
409
+ 1, 0,
410
+ 1, 1
411
+ ])
412
+ }else{
413
+ uvs = new Float32Array([
414
+ 0, 0,
415
+ 1, 0,
416
+ 1, 1,
417
+
418
+ 1, 0,
419
+ 0, 1,
420
+ 1, 1
421
+ ])
422
+ }
423
+ geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
424
+ geometry.setAttribute('uv', new THREE.BufferAttribute(uvs, 2))
425
+ geometry.computeVertexNormals()
426
+ return geometry
427
+ }
378
428
  export function getBufferPanelGeometry(panelPolygon) {
379
429
  let panelNormalVector = getNormalVectorFrom3Points(
380
430
  panelPolygon.outline[0],
@@ -384,7 +434,6 @@ export function getBufferPanelGeometry(panelPolygon) {
384
434
  if (panelNormalVector.z < 0) {
385
435
  panelNormalVector = multiplyVector(-1, panelNormalVector)
386
436
  }
387
- const roofPolygon = panelPolygon.roof
388
437
  const panelHeight = parseInt(panelPolygon.height || 50)
389
438
  //get lowest verticalProjection
390
439
 
@@ -0,0 +1,126 @@
1
+ import * as THREE from 'three'
2
+ import {mapGetters} from 'vuex'
3
+ import ProjectedMaterial from 'three-projected-material'
4
+ import {
5
+ substractVector,
6
+ addVector,
7
+ multiplyVector,
8
+ getDistanceBetweenPoints,
9
+ getAngleInDegFromCanvasVector
10
+ } from '@eturnity/eturnity_maths'
11
+ import {getBufferImageOverlayGeometry,updateBufferRoofGeometry} from './geometryHandler'
12
+
13
+ export default {
14
+ data(){
15
+ return {
16
+ imageOverlayProjectionCamera: new THREE.PerspectiveCamera(1, 300 / 300, 100, 1000),
17
+ imageOverlayTexture:null,
18
+ imageOverlayMaterial:null,
19
+ }
20
+ },
21
+ computed:{
22
+ ...mapGetters({
23
+ imageOverlay: 'getImageOverlay',
24
+ }),
25
+ },
26
+ methods:{
27
+ renderImageOverlayOnBackground() {
28
+ if(!this.imageOverlay || !this.imageOverlayMaterial){
29
+ this.clearMesh(this.meshes.backgroundMesh)
30
+ this.meshes.backgroundMesh=null
31
+ return
32
+ }
33
+ let corners=this.imageOverlay.corners.map(p=>{return {...p,z:100}})
34
+ if(this.meshes.backgroundMesh && this.meshes.backgroundMesh.geometry){
35
+ let geometry=this.meshes.backgroundMesh.geometry
36
+ geometry=updateBufferRoofGeometry(corners,[],geometry)
37
+ //updateBufferRoofGeometry(corners,[],geometry)
38
+ this.meshes.backgroundMesh.geometry=geometry
39
+
40
+ }else{
41
+ let planeGeometry = getBufferImageOverlayGeometry(corners)
42
+ let planeMaterial = this.imageOverlayMaterial
43
+
44
+ this.meshes.backgroundMesh = new THREE.Mesh(planeGeometry, planeMaterial)
45
+ this.scene.add(this.meshes.backgroundMesh)
46
+ }
47
+ this.meshes.backgroundMesh.position.z=0.15
48
+ if(this.imageOverlayMaterial){
49
+ this.applyTextureOnMesh([this.imageOverlayMaterial],this.meshes.backgroundMesh)
50
+ }
51
+ this.meshes.backgroundMesh.visible=true
52
+ },
53
+ async changeImageOverlay(){
54
+ if(this.imageOverlayMaterial){
55
+ this.imageOverlayMaterial.dispose()
56
+ this.imageOverlayMaterial=null
57
+ }
58
+ await this.updateProjectionMaterials()
59
+ },
60
+ async getImageOverlayMaterial(){
61
+ if(!this.imageOverlay || !this.imageOverlay.url){
62
+ if(this.imageOverlayMaterial){
63
+ this.imageOverlayMaterial.dispose()
64
+ }
65
+ this.imageOverlayMaterial=null
66
+ return null
67
+ }
68
+
69
+ if(!this.imageOverlayMaterial || this.imageOverlay.url!= this.imageOverlayMaterial.userData.url){
70
+ this.imageOverlayMaterial = await this.newImageOverlayMaterial()
71
+ }else{
72
+ this.setImageOverlayCameraPosition()
73
+ }
74
+ return this.imageOverlayMaterial
75
+ },
76
+ removeImageOverlay(){
77
+ if(this.imageOverlayMaterial && this.imageOverlayMaterial.dispose)
78
+ this.imageOverlayMaterial.dispose()
79
+ this.imageOverlayMaterial=null
80
+ this.material.roof=this.material.roof.filter(material=>material.userData.type!='imageOverlayMaterial')
81
+ },
82
+ async newImageOverlayMaterial(){
83
+ return new Promise((resolve)=>{this.loader.load(this.imageOverlay.url,(texture)=>{
84
+ this.imageOverlayTexture=texture
85
+ this.setImageOverlayCameraPosition()
86
+ let imageOverlayProjectionMaterial = new ProjectedMaterial({
87
+ camera: this.imageOverlayProjectionCamera,
88
+ texture: this.imageOverlayTexture,
89
+ transparent: true,
90
+ side: THREE.DoubleSide,
91
+ depthWrite: false
92
+ })
93
+ imageOverlayProjectionMaterial.userData={}
94
+ imageOverlayProjectionMaterial.userData.type="imageOverlayMaterial"
95
+ imageOverlayProjectionMaterial.userData.priority=2
96
+ imageOverlayProjectionMaterial.userData.url=this.imageOverlay.url
97
+ resolve(imageOverlayProjectionMaterial)
98
+ })
99
+ })
100
+ },
101
+ setImageOverlayCameraPosition(){
102
+ if(!this.imageOverlay || !this.imageOverlay.url) return
103
+ let height=getDistanceBetweenPoints(this.imageOverlay.corners[1],this.imageOverlay.corners[2])
104
+ let width=getDistanceBetweenPoints(this.imageOverlay.corners[0],this.imageOverlay.corners[1])
105
+ this.imageOverlayProjectionCamera.aspect =
106
+ width / height
107
+ let projectionAltitude = height /(2 * Math.tan((this.imageOverlayProjectionCamera.fov * Math.PI) / 360))
108
+
109
+
110
+ //set projection camera over background_map_center
111
+ let imageOverlayProjectionCameraPosition={x:0,y:0,z:projectionAltitude / 1000}
112
+
113
+ let positionInMm=multiplyVector(0.5,addVector(this.imageOverlay.corners[0],this.imageOverlay.corners[2]))
114
+ imageOverlayProjectionCameraPosition.x=positionInMm.x/1000
115
+ imageOverlayProjectionCameraPosition.y=positionInMm.y/1000
116
+
117
+ this.imageOverlayProjectionCamera.position.set(imageOverlayProjectionCameraPosition.x, imageOverlayProjectionCameraPosition.y, projectionAltitude / 1000)
118
+ this.imageOverlayProjectionCamera.lookAt(imageOverlayProjectionCameraPosition.x, imageOverlayProjectionCameraPosition.y,0)
119
+ let zAngle=getAngleInDegFromCanvasVector(substractVector(this.imageOverlay.corners[3],this.imageOverlay.corners[0]))
120
+ this.imageOverlayProjectionCamera.rotation.set(0, 0, zAngle*Math.PI/180)
121
+ this.imageOverlayProjectionCamera.far = projectionAltitude * 1.5
122
+ this.imageOverlayProjectionCamera.near = projectionAltitude * 0.8
123
+ this.imageOverlayProjectionCamera.updateProjectionMatrix()
124
+ },
125
+ }
126
+ }
@@ -9,8 +9,12 @@ import moduleField from './moduleField'
9
9
  import obstacle from './obstacle'
10
10
  import panel from './panel'
11
11
  import roof from './roof'
12
+ import imageOverlay from './imageOverlay'
13
+ import mapProjection from './mapProjection'
14
+ import texture from './texture'
15
+ import projectionMaterial from './projectionMaterial'
12
16
 
13
17
  export default {
14
18
  //mixins:[node,background,clear,edge,loader,margin,moduleField,obstacle,panel,roof,base]
15
- mixins:[margin,node,background, base,roof,edge,obstacle,moduleField,panel,clear,loader]
19
+ mixins:[margin,node,background, base,roof,edge,obstacle,moduleField,panel,clear,loader,imageOverlay,texture,mapProjection,projectionMaterial]
16
20
  }
@@ -1,8 +1,9 @@
1
1
  import * as THREE from 'three'
2
2
  import ProjectedMaterial from 'three-projected-material'
3
+
3
4
  export default {
4
5
  methods:{
5
- loadNewTexture(){
6
+ loadNewPanelTextures(){
6
7
  Object.values(this.pvDataMemo).forEach((component) => {
7
8
  const pvId = component.id
8
9
  if (!this.material.panel[pvId]) {
@@ -12,13 +13,14 @@ export default {
12
13
  let texture = this.loader.load(component.texture_img_url)
13
14
  this.material.panel[pvId] = new THREE.MeshBasicMaterial({
14
15
  map: texture,
15
- side: THREE.DoubleSide
16
+ side: THREE.DoubleSide,
17
+ transparent: true
16
18
  })
17
19
  }
18
20
  }
19
21
  })
20
22
  },
21
- async loadTextureFromModuleFields(){
23
+ async loadPanelsTexture(){
22
24
  for(let k=0;k<this.moduleFields.length;k++){
23
25
  let mf=this.moduleFields[k]
24
26
  const pvId = mf.data.component_id_pv_module
@@ -29,69 +31,12 @@ export default {
29
31
  let texture = await this.loader.load(mf.data.texture_img_url)
30
32
  this.material.panel[pvId] = new THREE.MeshBasicMaterial({
31
33
  map: texture,
32
- side: THREE.DoubleSide
34
+ side: THREE.DoubleSide,
35
+ transparent: true
33
36
  })
34
37
  }
35
38
  }
36
39
  }
37
40
  },
38
- async loadProjectionMaterial() {
39
- const _this=this
40
- if(!this.layoutSettings.base64_image_url)
41
- {
42
- this.loader.load(require("../../assets/images/white_tile.png"),(texture)=>{
43
- let projectionMaterial = new ProjectedMaterial({
44
- camera: _this.cameraprojection,
45
- texture: texture
46
- })
47
- this.material.roof = projectionMaterial
48
- })
49
- return
50
- }
51
- let projectedMaterialLoaded= await new Promise((resolve,reject) => {
52
- this.loader.load(this.layoutSettings.base64_image_url,(texture)=>{
53
- let backgroundImageZoomLvl=_this.layoutSettings.map_zoom
54
- let backgroundImageCenter={
55
- lat:_this.layoutSettings.layout_latitude,
56
- lng:_this.layoutSettings.layout_longitude
57
- }
58
- if(_this.layoutSettings.background_map_settings){
59
- backgroundImageZoomLvl=_this.layoutSettings.background_map_settings.zoom_lvl
60
- backgroundImageCenter={
61
- lat:_this.layoutSettings.background_map_settings.lat,
62
- lng:_this.layoutSettings.background_map_settings.lng
63
- }
64
- }
65
- _this.backgroundImagesizeInMm=_this.layoutSettings.background_map_settings.sizeInMm
66
- if (_this.backgroundImagesizeInMm) {
67
- _this.cameraprojection.aspect =
68
- _this.backgroundImagesizeInMm.width / _this.backgroundImagesizeInMm.height
69
- let projectionAltitude =
70
- _this.backgroundImagesizeInMm.height /
71
- (2 * Math.tan((_this.cameraprojection.fov * Math.PI) / 360))
72
-
73
-
74
- //set projection camera over background_map_center
75
- let cameraProjectionPosition={x:0,y:0,z:projectionAltitude / 1000}
76
- if(_this.layoutSettings.background_map_settings && _this.layoutSettings.background_map_settings.positionInMm){
77
- let positionInMm=this.layoutSettings.background_map_settings.positionInMm
78
- cameraProjectionPosition.x=positionInMm.x/1000
79
- cameraProjectionPosition.y=positionInMm.y/1000
80
- }
81
-
82
- _this.cameraprojection.position.set(cameraProjectionPosition.x, cameraProjectionPosition.y, projectionAltitude / 1000)
83
- _this.cameraprojection.far = projectionAltitude * 16
84
- _this.cameraprojection.updateProjectionMatrix()
85
- }
86
-
87
- let projectionMaterial = new ProjectedMaterial({
88
- camera: _this.cameraprojection,
89
- texture: texture
90
- })
91
- resolve(projectionMaterial)
92
- })
93
- })
94
- this.material.roof =projectedMaterialLoaded
95
- },
96
41
  }
97
42
  }
@@ -0,0 +1,86 @@
1
+ import * as THREE from 'three'
2
+ import ProjectedMaterial from 'three-projected-material'
3
+
4
+ export default {
5
+ data(){
6
+ return {
7
+ mapProjectionTexture:null,
8
+ mapProjectionMaterial:null
9
+ }
10
+ },
11
+ methods:{
12
+ async changeMapProjection(){
13
+ if(this.mapProjectionMaterial){
14
+ this.mapProjectionMaterial.dispose()
15
+ this.mapProjectionMaterial=null
16
+ }
17
+ await this.updateProjectionMaterials()
18
+ },
19
+ async getMapProjectionMaterial(){
20
+ if(!this.layoutSettings.base64_image_url){
21
+ return null
22
+ }else{
23
+ if(!this.mapProjectionMaterial){
24
+ this.mapProjectionMaterial = await this.newMapProjectionMaterial()
25
+ }else{
26
+ this.setMapProjectionCameraPosition()
27
+ }
28
+ }
29
+ return this.mapProjectionMaterial
30
+ },
31
+
32
+ async newMapProjectionMaterial() {
33
+ return new Promise((resolve,reject) => {
34
+ this.loader.load(this.layoutSettings.base64_image_url,(texture)=>{
35
+ this.mapProjectionTexture=texture
36
+ this.setMapProjectionCameraPosition()
37
+ let mapProjectionMaterial = new ProjectedMaterial({
38
+ camera: this.cameraprojection,
39
+ texture: texture,
40
+ transparent: true,
41
+ side: THREE.DoubleSide,
42
+ })
43
+ mapProjectionMaterial.userData={}
44
+ mapProjectionMaterial.userData.type="mapProjectionMaterial"
45
+ mapProjectionMaterial.userData.priority=1
46
+ mapProjectionMaterial.userData.url=this.layoutSettings.base64_image_url
47
+ resolve(mapProjectionMaterial)
48
+ })
49
+ })
50
+ },
51
+ setMapProjectionCameraPosition(){
52
+ let backgroundImageCenter={
53
+ lat:this.layoutSettings.layout_latitude,
54
+ lng:this.layoutSettings.layout_longitude
55
+ }
56
+ if(this.layoutSettings.background_map_settings){
57
+ backgroundImageCenter={
58
+ lat:this.layoutSettings.background_map_settings.lat,
59
+ lng:this.layoutSettings.background_map_settings.lng
60
+ }
61
+ }
62
+ this.backgroundImagesizeInMm=this.layoutSettings.background_map_settings.sizeInMm
63
+ if (this.backgroundImagesizeInMm) {
64
+ this.cameraprojection.aspect =
65
+ this.backgroundImagesizeInMm.width / this.backgroundImagesizeInMm.height
66
+ let projectionAltitude =
67
+ this.backgroundImagesizeInMm.height /
68
+ (2 * Math.tan((this.cameraprojection.fov * Math.PI) / 360))
69
+
70
+ //set projection camera over background_map_center
71
+ let cameraProjectionPosition={x:0,y:0,z:projectionAltitude / 1000}
72
+ if(this.layoutSettings.background_map_settings && this.layoutSettings.background_map_settings.positionInMm){
73
+ let positionInMm=this.layoutSettings.background_map_settings.positionInMm
74
+ cameraProjectionPosition.x=positionInMm.x/1000
75
+ cameraProjectionPosition.y=positionInMm.y/1000
76
+ }
77
+
78
+ this.cameraprojection.position.set(cameraProjectionPosition.x, cameraProjectionPosition.y, projectionAltitude / 1000)
79
+ this.cameraprojection.far = projectionAltitude * 1.5
80
+ this.cameraprojection.near = projectionAltitude * 0.5
81
+ this.cameraprojection.updateProjectionMatrix()
82
+ }
83
+ },
84
+
85
+ }
86
+ }
@@ -3,7 +3,6 @@ import {
3
3
  getBufferObstacleGeometry,
4
4
  getBufferObstacleSideGeometry,
5
5
  } from './geometryHandler'
6
- import { material } from '../materials'
7
6
  export default {
8
7
  methods:{
9
8
  renderObstacles() {
@@ -24,13 +23,8 @@ export default {
24
23
  )
25
24
  if (geometry && geometrySide) {
26
25
  const mesh = new THREE.Mesh(geometry, this.material.roof)
27
- const meshSide = new THREE.Mesh(geometrySide, material.wall)
28
- mesh.material=this.material.roof
29
- if(this.material.roof && this.material.roof.project){
30
- this.material.roof.project(mesh)
31
- }else{
32
- mesh.material=this.material.wall
33
- }
26
+ const meshSide = new THREE.Mesh(geometrySide, this.material.wall)
27
+ this.applyTextureOnMesh(this.material.roof,mesh)
34
28
 
35
29
  mesh.userData.version = obstaclePolygon.version
36
30
  mesh.userData.type = 'obstacleMeshes'
@@ -33,6 +33,8 @@ export default {
33
33
  //definition of the material
34
34
  if(panelPolygon.moduleField.data.number_of_panels_override) return
35
35
  let material = this.material.panel['default_'+this.moduleTextureVersionId]
36
+ material.transparent=true
37
+ material.opacity=this.panelOpacity
36
38
  if (panelPolygon.moduleField.pvData) {
37
39
  let pvId = panelPolygon.moduleField.pvData.id
38
40
  if (this.material.panel[pvId]) {