@eturnity/eturnity_3d
Advanced tools
Comparing version 1.0.41-EPDM-7327 to 1.0.42-EPDM-7379-0
{ | ||
"name": "@eturnity/eturnity_3d", | ||
"private": false, | ||
"version": "1.0.41-EPDM-7327", | ||
"version": "1.0.42-EPDM-7379-0", | ||
"main": "dist/main.js", | ||
@@ -11,3 +11,3 @@ "scripts": { | ||
"dependencies": { | ||
"@eturnity/eturnity_maths": "^1.0.2", | ||
"@eturnity/eturnity_maths": "1.0.10-EPDM-7379-0", | ||
"axios": "^1.3.2", | ||
@@ -14,0 +14,0 @@ "cors": "^2.8.5", |
import {mapState, mapGetters } from 'vuex' | ||
import * as THREE from 'three' | ||
import TWEEN from 'tween' | ||
import { | ||
maximumGapLimit, | ||
colorArrayBase, | ||
} from '../config' | ||
import { | ||
addVector, | ||
multiplyVector, | ||
verticalProjectionOnPlane, | ||
} from '@eturnity/eturnity_maths' | ||
import { | ||
getBufferWallGeometry, | ||
updateBufferWallGeometry, | ||
getBufferRoofGeometry, | ||
updateBufferRoofGeometry, | ||
getBufferObstacleGeometry, | ||
getBufferObstacleSideGeometry, | ||
getBufferModuleFieldGeometry, | ||
getBufferPanelGeometry, | ||
updateBufferPanelGeometry, | ||
getBufferPanelSideGeometry, | ||
updateBufferPanelSideGeometry, | ||
getBufferRoofMarginGeometry | ||
} from './geometryHandler' | ||
import ProjectedMaterial from 'three-projected-material' | ||
import { material } from './materials' | ||
import { intersectOutlines } from '@eturnity/eturnity_maths' | ||
import clearThreeObjects from './clearThreeObjects' | ||
const meshTypes = [ | ||
'baseMeshes', | ||
'backgroundMesh', | ||
'roofMeshes', | ||
'flatRoofMeshes', | ||
'obstacleMeshes', | ||
'panelsMeshes', | ||
'nodeMeshes', | ||
'edgeMeshes', | ||
'roofMarginMeshes', | ||
'moduleFieldsMeshes' | ||
] | ||
import renderMixin from "./render" | ||
export default { | ||
mixins : [renderMixin], | ||
data() { | ||
@@ -281,43 +247,3 @@ return { | ||
renderBackground() { | ||
if(this.meshes.backgroundMesh){ | ||
let sizeInMm={width:2000000,height:2000000} | ||
let positionInMm={x:0,y:0} | ||
if(this.layoutSettings.background_map_settings && this.layoutSettings.background_map_settings.sizeInMm){ | ||
sizeInMm=this.layoutSettings.background_map_settings.sizeInMm | ||
positionInMm=this.layoutSettings.background_map_settings.positionInMm | ||
} | ||
this.meshes.backgroundMesh.geometry.dispose() | ||
let xMin=positionInMm.x/1000-sizeInMm.width/2000 | ||
let xMax=positionInMm.x/1000+sizeInMm.width/2000 | ||
let yMin=positionInMm.y/1000-sizeInMm.height/2000 | ||
let yMax=positionInMm.y/1000+sizeInMm.height/2000 | ||
let c1=[xMin,yMax,0.1] | ||
let c2=[xMax,yMax,0.1] | ||
let c3=[xMax,yMin,0.1] | ||
let c4=[xMin,yMin,0.1] | ||
let geometry = new THREE.BufferGeometry(); | ||
const vertices = new Float32Array( [ | ||
...c1, | ||
...c4, | ||
...c3, | ||
...c3, | ||
...c2, | ||
...c1 | ||
] ); | ||
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) ); | ||
geometry.computeVertexNormals() | ||
this.meshes.backgroundMesh.geometry=geometry | ||
}else{ | ||
this.initialiseThreeMap() | ||
// let geometry = new THREE.PlaneGeometry(this.backgroundImagesizeInMm.width / 1000,this.backgroundImagesizeInMm.height / 1000) | ||
// const backgroundMesh = new THREE.Mesh(geometry, this.material.roof) | ||
// this.material.roof.project(backgroundMesh) | ||
// this.scene.add(backgroundMesh) | ||
// // this.scene.remove(this.meshes.backgroundMesh) | ||
// this.meshes.backgroundMesh = backgroundMesh | ||
// backgroundMesh.matrixAutoUpdate = true | ||
} | ||
}, | ||
applyTextureOnRoofs(){ | ||
@@ -342,495 +268,3 @@ this.roofs.forEach(roof=>{ | ||
}, | ||
renderBase() { | ||
//rendering of walls | ||
//this.clearByType('baseMeshes') | ||
this.clearRemovedOnes('baseMeshes') | ||
let geometry | ||
let mesh | ||
this.roofs.forEach((roofPolygon) => { | ||
//everythime the essencials data are changed, version goes up. we compare polygon version and mesh version to know if we have to rerender | ||
if ( | ||
this.meshes.baseMeshes[roofPolygon.id] && | ||
this.meshes.baseMeshes[roofPolygon.id].userData.version < | ||
roofPolygon.version | ||
) { | ||
//this.clearMesh(this.meshes.baseMeshes[roofPolygon.id]) | ||
mesh = this.meshes.baseMeshes[roofPolygon.id] | ||
geometry = mesh.geometry | ||
geometry = updateBufferWallGeometry(roofPolygon, geometry) | ||
mesh.geometry = geometry | ||
mesh.updateMatrix() | ||
} | ||
if (!this.meshes.baseMeshes[roofPolygon.id]) { | ||
//create | ||
geometry = getBufferWallGeometry(roofPolygon) | ||
mesh = new THREE.Mesh(geometry, this.material.wall) | ||
mesh.userData.version = roofPolygon.version | ||
mesh.userData.type = 'baseMeshes' | ||
mesh.userData.meshId = roofPolygon.id | ||
mesh.userData.polygonId = roofPolygon.id | ||
mesh.matrixAutoUpdate = false | ||
mesh.frustumCulled = false | ||
//geometry.dispose() | ||
//geometry=null | ||
this.scene.add(mesh) | ||
this.meshes.baseMeshes[roofPolygon.id] = mesh | ||
} | ||
}) | ||
}, | ||
updateRoofGeometry(geometry, roofPolygon) { | ||
const roofOutline = roofPolygon.outline | ||
let cropedHolesOutline = roofPolygon.holes | ||
.filter((h) => h.layer == 'obstacle') | ||
.map((h) => { | ||
//let's crop obstacle with roof outline | ||
const cropedHoleOutline = | ||
intersectOutlines(h.outline, roofPolygon.outline)[0] || [] | ||
const outline = cropedHoleOutline.map((p) => { | ||
return { | ||
x: p.x, | ||
y: p.y, | ||
z: verticalProjectionOnPlane( | ||
p, | ||
roofPolygon.normalVector, | ||
roofPolygon.flatOutline[0] | ||
).z | ||
} | ||
}) | ||
return outline | ||
}) | ||
cropedHolesOutline = cropedHolesOutline.filter((outline) => !!outline) | ||
geometry = updateBufferRoofGeometry( | ||
roofOutline, | ||
cropedHolesOutline, | ||
geometry | ||
) | ||
return geometry | ||
}, | ||
createRoofGeometry(roofPolygon) { | ||
const roofOutline = roofPolygon.outline | ||
let cropedHolesOutline = roofPolygon.holes | ||
.filter((h) => h.layer == 'obstacle') | ||
.map((h) => { | ||
//let's crop obstacle with roof outline | ||
const cropedHoleOutline = | ||
intersectOutlines(h.outline, roofPolygon.outline)[0] || [] | ||
const outline = cropedHoleOutline.map((p) => { | ||
return { | ||
x: p.x, | ||
y: p.y, | ||
z: verticalProjectionOnPlane( | ||
p, | ||
roofPolygon.normalVector, | ||
roofPolygon.flatOutline[0] | ||
).z | ||
} | ||
}) | ||
return outline | ||
}) | ||
cropedHolesOutline = cropedHolesOutline.filter((outline) => !!outline) | ||
let geometry = getBufferRoofGeometry(roofOutline, cropedHolesOutline) | ||
return geometry | ||
}, | ||
renderRoofs() { | ||
this.clearRemovedOnes('roofMeshes') | ||
this.roofs.forEach((roofPolygon) => { | ||
let mesh | ||
let geometry | ||
if ( | ||
this.meshes.roofMeshes[roofPolygon.id] && | ||
this.meshes.roofMeshes[roofPolygon.id].userData.version < | ||
roofPolygon.version | ||
) { | ||
//update mesh | ||
mesh = this.meshes.roofMeshes[roofPolygon.id] | ||
geometry = mesh.geometry | ||
geometry = this.updateRoofGeometry(geometry, roofPolygon) | ||
mesh.geometry = geometry | ||
if(this.material.roof){ | ||
mesh.material=this.material.roof | ||
if(this.material.roof && this.material.roof.project) this.material.roof.project(mesh) | ||
} | ||
mesh.frustumCulled = false | ||
mesh.updateMatrix() | ||
} | ||
if (!this.meshes.roofMeshes[roofPolygon.id]) { | ||
//create | ||
geometry = this.createRoofGeometry(roofPolygon) | ||
if (geometry) { | ||
mesh = new THREE.Mesh(geometry, this.material.roof) | ||
mesh.userData.version = roofPolygon.version | ||
mesh.userData.type = 'roofMeshes' | ||
mesh.userData.meshId = roofPolygon.id | ||
mesh.userData.polygonId = roofPolygon.id | ||
mesh.matrixAutoUpdate = false | ||
this.scene.add(mesh) | ||
if(this.material.roof){ | ||
mesh.material=this.material.roof | ||
if(this.material.roof.project) this.material.roof.project(mesh) | ||
} | ||
mesh.frustumCulled = false | ||
this.meshes.roofMeshes[roofPolygon.id] = mesh | ||
} | ||
} | ||
}) | ||
}, | ||
renderFlatRoofs() { | ||
//this.clearRemovedOnes('flatRoofMeshes') | ||
this.clearByType('flatRoofMeshes') | ||
this.roofs.forEach((roofPolygon) => { | ||
//if(this.meshes.flatRoofMeshes[roofPolygon.id]) | ||
if(roofPolygon.maximumGap < maximumGapLimit) return | ||
let geometry = getBufferRoofGeometry(roofPolygon.flatOutline) | ||
if (geometry) { | ||
const material =this.material.curvedRoof | ||
const mesh = new THREE.Mesh(geometry, material) | ||
geometry.dispose() | ||
geometry = null | ||
mesh.itemData = roofPolygon | ||
mesh.frustumCulled = false | ||
this.scene.add(mesh) | ||
this.meshes.flatRoofMeshes[roofPolygon.id] = mesh | ||
} | ||
}) | ||
}, | ||
renderRoofsMargin() { | ||
this.clearByType('roofMarginMeshes') | ||
if (this.selectedTool == 'selectMargin') { | ||
this.roofs.forEach((roofPolygon) => { | ||
const geometries = getBufferRoofMarginGeometry(roofPolygon) | ||
geometries.forEach((geometry, index) => { | ||
if (geometry) { | ||
const marginColor = roofPolygon.margins.isSameMargin | ||
? colorArrayBase[0] | ||
: colorArrayBase[index % colorArrayBase.length] | ||
let material = new THREE.MeshPhongMaterial({ | ||
color: marginColor, | ||
specular: 0x009900, | ||
shininess: 0, | ||
flatShading: true, | ||
side: THREE.DoubleSide, | ||
transparent: true, | ||
opacity: 0.8 | ||
}) | ||
const mesh = new THREE.Mesh(geometry, material) | ||
geometry.dispose() | ||
this.scene.add(mesh) | ||
this.meshes.roofMarginMeshes[roofPolygon.id + '_' + index] = mesh | ||
} | ||
}) | ||
roofPolygon.holes.forEach((obstaclePolygon) => { | ||
const geometries = getBufferRoofMarginGeometry( | ||
obstaclePolygon, | ||
roofPolygon | ||
) | ||
geometries.forEach((geometry, index) => { | ||
if (geometry) { | ||
const marginColor = obstaclePolygon.margins.isSameMargin | ||
? colorArrayBase[0] | ||
: colorArrayBase[index % colorArrayBase.length] | ||
let material = new THREE.MeshPhongMaterial({ | ||
color: marginColor, | ||
specular: 0x009900, | ||
shininess: 0, | ||
flatShading: true, | ||
side: THREE.DoubleSide, | ||
transparent: true, | ||
opacity: 0.8 | ||
}) | ||
const mesh = new THREE.Mesh(geometry, material) | ||
geometry.dispose() | ||
geometry = null | ||
material.dispose() | ||
material = null | ||
this.scene.add(mesh) | ||
this.meshes.roofMarginMeshes[ | ||
obstaclePolygon.id + '_' + roofPolygon.id + '_' + index | ||
] = mesh | ||
} | ||
}) | ||
}) | ||
}) | ||
} | ||
}, | ||
renderNodes() { | ||
let geometry | ||
if (this.meshes.nodeMeshes) { | ||
geometry = this.meshes.nodeMeshes.geometry | ||
geometry.attributes.position.needsUpdate = true | ||
} else { | ||
geometry = new THREE.BufferGeometry() | ||
} | ||
// let geometry = new THREE.SphereGeometry(node3DRadius, 4, 4) | ||
const vertices = [] | ||
this.nodes | ||
.filter((node) => node.layer == 'roof') | ||
.forEach((node) => { | ||
vertices.push(node.x / 1000, node.y / 1000, node.z / 1000) | ||
}) | ||
if ( | ||
geometry.attributes.position && | ||
geometry.attributes.position.array.length <= vertices.length | ||
) { | ||
let positions = geometry.attributes.position.array | ||
for (let k in vertices) { | ||
positions[k] = vertices[k] | ||
} | ||
geometry.setDrawRange(0, vertices.length / 3) | ||
} else { | ||
geometry.setAttribute( | ||
'position', | ||
new THREE.Float32BufferAttribute(vertices, 3) | ||
) | ||
} | ||
let material = this.material.node | ||
const nodeMeshes = new THREE.Points(geometry, material) | ||
nodeMeshes.userData.version = 0 | ||
nodeMeshes.userData.type = 'nodeMeshes' | ||
nodeMeshes.userData.meshId = null | ||
nodeMeshes.userData.polygonId = null | ||
nodeMeshes.matrixAutoUpdate = false | ||
this.meshes.nodeMeshes = nodeMeshes | ||
this.scene.add(nodeMeshes) | ||
}, | ||
renderEdges() { | ||
this.clearEdgesRemovedOnes('edgeMeshes') | ||
let cylinder | ||
//this.clearByType('edgeMeshes') | ||
// const material = new THREE.LineBasicMaterial( { color: beamColor,transparent:true,opacity:beamOpacity ,sizeAttenuation: true} ); | ||
// material.linewidth=5 | ||
const material = this.material.edge | ||
this.edges | ||
.filter((edge) => edge.layer == 'roof') | ||
.forEach((edge) => { | ||
cylinder = this.meshes.edgeMeshes[edge.id] | ||
if (cylinder) { | ||
//update | ||
const point_0 = new THREE.Vector3( | ||
edge.outline[0].x / 1000, | ||
edge.outline[0].y / 1000, | ||
edge.outline[0].z / 1000 | ||
) | ||
const point_1 = new THREE.Vector3( | ||
edge.outline[1].x / 1000, | ||
edge.outline[1].y / 1000, | ||
edge.outline[1].z / 1000 | ||
) | ||
const midPoint = point_0.clone().add(point_1).multiplyScalar(0.5) | ||
var direction = new THREE.Vector3().subVectors(point_1, point_0) | ||
let length = direction.length() | ||
//cylinder.rotation.set(arrow.rotation) | ||
var axis = new THREE.Vector3(0, 1, 0) | ||
cylinder.quaternion.setFromUnitVectors( | ||
axis, | ||
direction.clone().normalize() | ||
) | ||
//cylinder.position.set(new THREE.Vector3().addVectors( pointX, direction.multiplyScalar(0.5) )) | ||
cylinder.position.copy(midPoint.clone()) | ||
let oldLength = cylinder.userData.cylinderLength | ||
let newLength = length | ||
if (oldLength != 0) { | ||
let scaleRatio = newLength / oldLength | ||
//let scaleVector=direction.multiplyScalar(scaleRatio-1) | ||
cylinder.scale.set(1, newLength, 1) | ||
cylinder.userData.cylinderLength = newLength | ||
} | ||
cylinder.updateMatrix() | ||
//change cylinder length | ||
} else { | ||
const point_0 = new THREE.Vector3( | ||
edge.outline[0].x / 1000, | ||
edge.outline[0].y / 1000, | ||
edge.outline[0].z / 1000 | ||
) | ||
const point_1 = new THREE.Vector3( | ||
edge.outline[1].x / 1000, | ||
edge.outline[1].y / 1000, | ||
edge.outline[1].z / 1000 | ||
) | ||
const midPoint = point_0.clone().add(point_1).multiplyScalar(0.5) | ||
var direction = new THREE.Vector3().subVectors(point_1, point_0) | ||
let length = direction.length() | ||
const geometry = new THREE.CylinderGeometry(0.1, 0.1, 1, 6) | ||
cylinder = new THREE.Mesh(geometry, material) | ||
cylinder.scale.set(1, length, 1) | ||
cylinder.userData.cylinderLength = length | ||
//cylinder.rotation.set(arrow.rotation) | ||
var axis = new THREE.Vector3(0, 1, 0) | ||
cylinder.quaternion.setFromUnitVectors( | ||
axis, | ||
direction.clone().normalize() | ||
) | ||
//cylinder.position.set(new THREE.Vector3().addVectors( pointX, direction.multiplyScalar(0.5) )) | ||
cylinder.position.copy(midPoint.clone()) | ||
//cylinder.position.set(edge.outline[0].x/1000, edge.outline[0].y/1000, edge.outline[0].z/1000); | ||
cylinder.userData.edgeId = edge.id | ||
cylinder.matrixAutoUpdate = false | ||
this.meshes.edgeMeshes[edge.id] = cylinder | ||
this.scene.add(cylinder) | ||
} | ||
}) | ||
}, | ||
renderObstacles() { | ||
this.clearByType('obstacleMeshes') | ||
this.roofs.forEach((roofPolygon) => { | ||
roofPolygon.holes | ||
.filter((poly) => poly.layer == 'obstacle') | ||
.forEach((obstaclePolygon) => { | ||
const geometry = getBufferObstacleGeometry( | ||
obstaclePolygon, | ||
roofPolygon | ||
) | ||
const geometrySide = getBufferObstacleSideGeometry( | ||
obstaclePolygon, | ||
roofPolygon | ||
) | ||
if (geometry && geometrySide) { | ||
const mesh = new THREE.Mesh(geometry, this.material.roof) | ||
const meshSide = new THREE.Mesh(geometrySide, material.wall) | ||
geometry.dispose() | ||
geometrySide.dispose() | ||
if(this.material.roof){ | ||
mesh.material=this.material.roof | ||
if(this.material.roof.project) this.material.roof.project(mesh) | ||
} | ||
mesh.matrixAutoUpdate = false | ||
meshSide.matrixAutoUpdate = false | ||
mesh.frustumCulled = false | ||
meshSide.frustumCulled = false | ||
this.scene.add(mesh) | ||
this.scene.add(meshSide) | ||
this.meshes.obstacleMeshes[ | ||
obstaclePolygon.id + '-' + roofPolygon.id + '_top' | ||
] = mesh | ||
this.meshes.obstacleMeshes[ | ||
obstaclePolygon.id + '-' + roofPolygon.id + '_side' | ||
] = meshSide | ||
} | ||
}) | ||
}) | ||
}, | ||
renderModuleFields() { | ||
this.clearByType('moduleFieldsMeshes') | ||
this.moduleFields.forEach((moduleFieldPolygon) => { | ||
if(!moduleFieldPolygon.data.number_of_panels_override && !this.areModuleFieldsVisible )return | ||
const geometry = getBufferModuleFieldGeometry(moduleFieldPolygon) | ||
if (geometry) { | ||
const mesh = new THREE.Mesh(geometry, this.material.moduleField) | ||
geometry.dispose() | ||
mesh.matrixAutoUpdate = false | ||
mesh.userData.version = moduleFieldPolygon.version | ||
mesh.userData.type = 'moduleFieldsMeshes' | ||
mesh.userData.meshId = moduleFieldPolygon.id | ||
mesh.userData.polygonId = moduleFieldPolygon.id | ||
this.scene.add(mesh) | ||
this.meshes.moduleFieldsMeshes[moduleFieldPolygon.id] = mesh | ||
} | ||
}) | ||
}, | ||
clearPanelsFromChangingRoofs(roofIds){ | ||
const roofs=this.polygons.filter(polygon=>roofIds.includes(polygon.id)) | ||
roofs.forEach(roof=>roof.moduleFields.forEach(mf=>mf.panels.forEach(panel=>{ | ||
let meshTop=this.meshes.panelsMeshes[panel.id+'_top'] | ||
let meshSide=this.meshes.panelsMeshes[panel.id+'_side'] | ||
if(meshTop || meshSide){ | ||
this.clearMesh(meshTop) | ||
this.clearMesh(meshSide) | ||
} | ||
}) | ||
) | ||
) | ||
}, | ||
renderPanels() { | ||
this.clearRemovedOnes('panelsMeshes') | ||
Object.values(this.meshes.panelsMeshes).forEach((mesh) => { | ||
//clear UserDeactivatedModules | ||
if ( | ||
this.polygons.find( | ||
(poly) => | ||
poly.id == mesh.userData.polygonId && | ||
poly.layer == 'user_deactivated_panel' | ||
) | ||
) { | ||
this.clearMesh(mesh) | ||
} | ||
//clear panel on moduleField with overriden number of panel | ||
let panel=this.polygons.find(poly=>mesh.userData.polygonId==poly.id) | ||
if ( | ||
!panel || panel.moduleField.data.number_of_panels_override | ||
) { | ||
this.clearMesh(mesh) | ||
} | ||
}) | ||
this.panels.forEach((panelPolygon) => { | ||
//definition of the material | ||
if(panelPolygon.moduleField.data.number_of_panels_override) return | ||
let material = this.material.panel['default_'+this.moduleTextureVersionId] | ||
if (panelPolygon.moduleField.pvData) { | ||
let pvId = panelPolygon.moduleField.pvData.id | ||
if (this.material.panel[pvId]) { | ||
material = this.material.panel[pvId] | ||
} | ||
}else if(panelPolygon.moduleField.data){ | ||
let pvId = panelPolygon.moduleField.data.component_id_pv_module | ||
if (this.material.panel[pvId]) { | ||
material = this.material.panel[pvId] | ||
} | ||
} | ||
if ( | ||
!this.meshes.panelsMeshes[panelPolygon.id + '_top'] || | ||
!this.meshes.panelsMeshes[panelPolygon.id + '_side'] | ||
) { | ||
const geometry = getBufferPanelGeometry(panelPolygon) | ||
const geometrySide = getBufferPanelSideGeometry(panelPolygon) | ||
if (geometry && geometrySide) { | ||
const mesh = new THREE.Mesh(geometry, material) | ||
const meshSide = new THREE.Mesh(geometrySide, this.material.wall) | ||
mesh.userData.version = panelPolygon.version | ||
mesh.userData.type = 'panelsMeshes' | ||
mesh.userData.meshId = panelPolygon.id + '_top' | ||
mesh.userData.polygonId = panelPolygon.id | ||
meshSide.userData.version = panelPolygon.version | ||
meshSide.userData.type = 'panelsMeshes' | ||
meshSide.userData.meshId = panelPolygon.id + '_side' | ||
meshSide.userData.polygonId = panelPolygon.id | ||
geometry.dispose() | ||
geometrySide.dispose() | ||
this.scene.add(mesh) | ||
this.scene.add(meshSide) | ||
mesh.matrixAutoUpdate = false | ||
meshSide.matrixAutoUpdate = false | ||
this.meshes.panelsMeshes[panelPolygon.id + '_top'] = mesh | ||
this.meshes.panelsMeshes[panelPolygon.id + '_side'] = meshSide | ||
} | ||
}else{ | ||
const topMesh=this.meshes.panelsMeshes[panelPolygon.id + '_top'] | ||
const sideMesh=this.meshes.panelsMeshes[panelPolygon.id + '_side'] | ||
if(panelPolygon.version>topMesh.userData.version){ | ||
topMesh.geometry=updateBufferPanelGeometry(panelPolygon,topMesh.geometry) | ||
sideMesh.geometry=updateBufferPanelSideGeometry(panelPolygon,sideMesh.geometry) | ||
} | ||
let pvId = panelPolygon.moduleField.pvData.id | ||
topMesh.material= material | ||
} | ||
}) | ||
}, | ||
async updateProjectionMaterial(){ | ||
@@ -841,64 +275,3 @@ await this.loadProjectionMaterial() | ||
}, | ||
async loadProjectionMaterial() { | ||
const _this=this | ||
if(!this.layoutSettings.base64_image_url) | ||
{ | ||
this.loader.load(require("../assets/images/white_tile.png"),(texture)=>{ | ||
let projectionMaterial = new ProjectedMaterial({ | ||
camera: _this.cameraprojection, | ||
texture: texture | ||
}) | ||
this.material.roof = projectionMaterial | ||
}) | ||
return | ||
} | ||
let projectedMaterialLoaded= await new Promise((resolve,reject) => { | ||
this.loader.load(this.layoutSettings.base64_image_url,(texture)=>{ | ||
let backgroundImageZoomLvl=_this.layoutSettings.map_zoom | ||
let backgroundImageCenter={ | ||
lat:_this.layoutSettings.layout_latitude, | ||
lng:_this.layoutSettings.layout_longitude | ||
} | ||
if(_this.layoutSettings.background_map_settings){ | ||
backgroundImageZoomLvl=_this.layoutSettings.background_map_settings.zoom_lvl | ||
backgroundImageCenter={ | ||
lat:_this.layoutSettings.background_map_settings.lat, | ||
lng:_this.layoutSettings.background_map_settings.lng | ||
} | ||
} | ||
_this.backgroundImagesizeInMm=_this.layoutSettings.background_map_settings.sizeInMm | ||
if (_this.backgroundImagesizeInMm) { | ||
_this.cameraprojection.aspect = | ||
_this.backgroundImagesizeInMm.width / _this.backgroundImagesizeInMm.height | ||
let projectionAltitude = | ||
_this.backgroundImagesizeInMm.height / | ||
(2 * Math.tan((_this.cameraprojection.fov * Math.PI) / 360)) | ||
//set projection camera over background_map_center | ||
let cameraProjectionPosition={x:0,y:0,z:projectionAltitude / 1000} | ||
if(_this.layoutSettings.background_map_settings && _this.layoutSettings.background_map_settings.positionInMm){ | ||
// let averageLat=(_this.layoutSettings.layout_latitude+_this.layoutSettings.background_map_settings.lat)/2 | ||
// let deltaLat=_this.layoutSettings.background_map_settings.lat-_this.layoutSettings.layout_latitude | ||
// let deltaLng=_this.layoutSettings.background_map_settings.lng-_this.layoutSettings.layout_longitude | ||
// let {x:x_mm,y:y_mm}=deltaLatLngToDistance(deltaLat,deltaLng,averageLat) | ||
let positionInMm=this.layoutSettings.background_map_settings.positionInMm | ||
cameraProjectionPosition.x=positionInMm.x/1000 | ||
cameraProjectionPosition.y=positionInMm.y/1000 | ||
} | ||
_this.cameraprojection.position.set(cameraProjectionPosition.x, cameraProjectionPosition.y, projectionAltitude / 1000) | ||
_this.cameraprojection.far = projectionAltitude * 16 | ||
_this.cameraprojection.updateProjectionMatrix() | ||
} | ||
let projectionMaterial = new ProjectedMaterial({ | ||
camera: _this.cameraprojection, | ||
texture: texture | ||
}) | ||
resolve(projectionMaterial) | ||
}) | ||
}) | ||
this.material.roof =projectedMaterialLoaded | ||
}, | ||
setCameraGlobalPosition() { | ||
@@ -1037,90 +410,4 @@ if(this.roofs.length==0)return | ||
}, | ||
clearMesh(mesh) { | ||
if (!mesh) return | ||
this.scene.remove(mesh) | ||
if (mesh.geometry && mesh.geometry.dispose) { | ||
mesh.geometry.dispose() | ||
mesh.geometry = null | ||
} | ||
if (mesh.material && mesh.material.dispose) { | ||
mesh.material.dispose() | ||
mesh.material = null | ||
} | ||
if ( | ||
mesh.userData.meshId && | ||
this.meshes[mesh.userData.type][mesh.userData.meshId] | ||
) { | ||
delete this.meshes[mesh.userData.type][mesh.userData.meshId] | ||
} else { | ||
this.meshes[mesh.userData.type] = null | ||
} | ||
mesh = null | ||
}, | ||
clearEdgesRemovedOnes() { | ||
Object.values(this.meshes['edgeMeshes']).forEach((mesh) => { | ||
if (!this.edgeIds.includes(mesh.userData.edgeId)) { | ||
this.clearMesh(mesh) | ||
} | ||
}) | ||
}, | ||
clearNodesRemovedOnes() { | ||
Object.values(this.meshes['nodeMeshes']).forEach((mesh) => { | ||
if (!this.nodeIds.includes(mesh.userData.nodeId)) { | ||
this.clearMesh(mesh) | ||
} | ||
}) | ||
}, | ||
clearRemovedOnes(type) { | ||
Object.values(this.meshes[type]).forEach((mesh) => { | ||
if (!this.polygonIds.includes(mesh.userData.polygonId)) { | ||
this.clearMesh(mesh) | ||
} | ||
}) | ||
}, | ||
clearByType(type) { | ||
Object.values(this.meshes[type]).forEach((mesh) => { | ||
mesh.geometry.dispose() | ||
mesh.geometry = null | ||
if (mesh.material.dispose) { | ||
mesh.material.dispose() | ||
} | ||
mesh.material = null | ||
this.scene.remove(mesh) | ||
}) | ||
this.meshes[type] = {} | ||
this.renderer.renderLists.dispose() | ||
}, | ||
loadNewTexture(){ | ||
Object.values(this.pvDataMemo).forEach((component) => { | ||
const pvId = component.id | ||
if (!this.material.panel[pvId]) { | ||
if (!component.texture_img_url) { | ||
this.material.panel[pvId] = this.material.panel.default | ||
} else { | ||
let texture = this.loader.load(component.texture_img_url) | ||
this.material.panel[pvId] = new THREE.MeshBasicMaterial({ | ||
map: texture, | ||
side: THREE.DoubleSide | ||
}) | ||
} | ||
} | ||
}) | ||
}, | ||
async loadTextureFromModuleFields(){ | ||
for(let k=0;k<this.moduleFields.length;k++){ | ||
let mf=this.moduleFields[k] | ||
const pvId = mf.data.component_id_pv_module | ||
if (!this.material.panel[pvId]) { | ||
if (!mf.data.texture_img_url) { | ||
this.material.panel[pvId] = this.material.panel.default | ||
} else { | ||
let texture = await this.loader.load(mf.data.texture_img_url) | ||
this.material.panel[pvId] = new THREE.MeshBasicMaterial({ | ||
map: texture, | ||
side: THREE.DoubleSide | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
@@ -1151,6 +438,6 @@ watch: { | ||
} | ||
clearThreeObjects(this.scene) | ||
this.clearThreeObjects(this.scene) | ||
if(this.three_map){ | ||
this.three_map.clear() | ||
clearThreeObjects(this.three_map) | ||
this.clearThreeObjects(this.three_map) | ||
} | ||
@@ -1157,0 +444,0 @@ this.renderer.clear() |
@@ -6,3 +6,2 @@ import * as THREE from 'three' | ||
import {CustomProvider} from './customProvider' | ||
import clearThreeObjects from './clearThreeObjects' | ||
@@ -15,3 +14,3 @@ export default { | ||
this.scene.remove(this.three_map) | ||
clearThreeObjects(this.three_map) | ||
this.clearThreeObjects(this.three_map) | ||
} | ||
@@ -21,3 +20,3 @@ if(this.background_map){ | ||
this.scene.remove(this.background_map) | ||
clearThreeObjects(this.background_map) | ||
this.clearThreeObjects(this.background_map) | ||
} | ||
@@ -51,3 +50,3 @@ | ||
this.background_map.add( helper ) | ||
clearThreeObjects(helper) | ||
this.clearThreeObjects(helper) | ||
helper=null | ||
@@ -118,3 +117,3 @@ | ||
this.scene.add(sky) | ||
clearThreeObjects(sky) | ||
this.clearThreeObjects(sky) | ||
let sun = new THREE.Vector3() | ||
@@ -121,0 +120,0 @@ |
@@ -41,3 +41,3 @@ //Synchronisation with BE: | ||
commit('mutate_layoutSettings', layoutSetting) | ||
commit('mutate_moduleTextureVersionId', layoutSetting.module_texture_version_id) | ||
commit('mutate_module_texture_version_id', layoutSetting.module_texture_version_id) | ||
let layers=getLayers() | ||
@@ -44,0 +44,0 @@ let selectedLayer=layers.find(layer=>layer.key==layoutSetting.background_map_settings.layerKey) |
@@ -33,3 +33,3 @@ import { | ||
mountingDataMemo:[], | ||
moduleTextureVersionId:0, | ||
module_texture_version_id:0, | ||
selectedMapLayer:null, | ||
@@ -133,5 +133,8 @@ globalProjectProperties: [], | ||
}, | ||
mutate_moduleTextureVersionId(state,value){ | ||
state.moduleTextureVersionId=value | ||
mutate_module_texture_version_id(state,value){ | ||
state.module_texture_version_id=value | ||
}, | ||
mutate_module_texture_version_id(state,value){ | ||
state.module_texture_version_id=value | ||
}, | ||
mutate_selectedMapLayer(state,value){ | ||
@@ -138,0 +141,0 @@ state.selectedMapLayer=value |
Sorry, the diff of this file is not supported yet
89
14408264
66335
+ Added@eturnity/eturnity_maths@1.0.10-EPDM-7379-0(transitive)
- Removed@eturnity/eturnity_maths@1.0.12(transitive)