@eturnity/eturnity_3d 6.34.6 → 6.34.7
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 +2 -2
- package/src/components/ThreeCanvasViewer.vue +14 -21
- package/src/helper/materialMixin.js +10 -7
- package/src/helper/render/base.js +14 -5
- package/src/helper/render/imageOverlay.js +4 -4
- package/src/helper/render/index.js +3 -3
- package/src/helper/render/loader.js +4 -4
- package/src/helper/render/mergedGeometry.js +108 -0
- package/src/helper/render/obstacle.js +38 -8
- package/src/helper/render/panel.js +82 -14
- package/src/helper/render/projectionMaterial.js +2 -28
- package/src/helper/render/roof.js +24 -24
- package/src/helper/render/texture.js +3 -0
- package/src/helper/render/tile.js +92 -63
- package/src/helper/render/tileProjection.js +3 -3
- package/src/helper/renderMixin.js +105 -43
- package/src/helper/threeMixin.js +15 -4
- package/src/helper/MapView.js +0 -221
- package/src/helper/materials.js +0 -77
- package/src/helper/render/mapProjection.js +0 -100
package/src/helper/MapView.js
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { Mesh, MeshBasicMaterial } from 'three'
|
|
2
|
-
import { MapNode, LODRaycast, MapPlaneNode } from 'geo-three'
|
|
3
|
-
/**
|
|
4
|
-
* Map viewer is used to read and display map tiles from a server.
|
|
5
|
-
*
|
|
6
|
-
* It was designed to work with a OpenMapTiles but can also be used with another map tiles.
|
|
7
|
-
*
|
|
8
|
-
* The map is drawn in plane map nodes using a quad tree that is subdivided as necessary to guaratee good map quality.
|
|
9
|
-
*/
|
|
10
|
-
export class MapView extends Mesh {
|
|
11
|
-
/**
|
|
12
|
-
* Planar map projection.
|
|
13
|
-
*/
|
|
14
|
-
PLANAR = 200
|
|
15
|
-
|
|
16
|
-
mapModes = new Map([[MapView.PLANAR, MapPlaneNode]])
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* LOD control object used to defined how tiles are loaded in and out of memory.
|
|
20
|
-
*/
|
|
21
|
-
lod = null
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Map tile color layer provider.
|
|
25
|
-
*/
|
|
26
|
-
provider = null
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Map height (terrain elevation) layer provider.
|
|
30
|
-
*
|
|
31
|
-
* Only used for HEIGHT, HEIGHT_SHADER and MARTINI map modes.
|
|
32
|
-
*/
|
|
33
|
-
heightProvider = null
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Define the type of map node in use, defined how the map is presented.
|
|
37
|
-
*
|
|
38
|
-
* Should only be set on creation.
|
|
39
|
-
*/
|
|
40
|
-
root = null
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Indicate if the nodes should cache its children when it is simplified. Nodes that are no longer in use should be kept in memory.
|
|
44
|
-
*
|
|
45
|
-
* Usefull for fast moving scenarios to prevent reparsing data in fast moving scenes.
|
|
46
|
-
*
|
|
47
|
-
* Should only be used if the child generation process is time consuming. Should be kept off unless required.
|
|
48
|
-
*/
|
|
49
|
-
cacheTiles = false
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Constructor for the map view objects.
|
|
53
|
-
*
|
|
54
|
-
* @param root - Map view node modes can be SPHERICAL, HEIGHT or PLANAR. PLANAR is used by default. Can also be a custom MapNode instance.
|
|
55
|
-
* @param provider - Map color tile provider by default a OSM maps provider is used if none specified.
|
|
56
|
-
* @param heightProvider - Map height tile provider, by default no height provider is used.
|
|
57
|
-
*/
|
|
58
|
-
constructor(
|
|
59
|
-
root = MapView.PLANAR,
|
|
60
|
-
provider = new OpenStreetMapsProvider(),
|
|
61
|
-
heightProvider = null
|
|
62
|
-
) {
|
|
63
|
-
super(undefined, new MeshBasicMaterial({ transparent: true, opacity: 0.0 }))
|
|
64
|
-
this.lod = new LODRaycast()
|
|
65
|
-
this.provider = provider
|
|
66
|
-
this.heightProvider = heightProvider
|
|
67
|
-
this.setRoot(root)
|
|
68
|
-
this.preSubdivide()
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Ajust node configuration depending on the camera distance.
|
|
73
|
-
*
|
|
74
|
-
* Called everytime automatically before render by the renderer.
|
|
75
|
-
*/
|
|
76
|
-
onBeforeRender = (renderer, scene, camera) => {
|
|
77
|
-
this.lod.updateLOD(this, camera, renderer, scene)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Set the root of the map view.
|
|
82
|
-
*
|
|
83
|
-
* Is set by the constructor by default, can be changed in runtime.
|
|
84
|
-
*
|
|
85
|
-
* @param root - Map node to be used as root.
|
|
86
|
-
*/
|
|
87
|
-
setRoot(root) {
|
|
88
|
-
if (typeof root === 'number') {
|
|
89
|
-
const rootConstructor = MapPlaneNode //MapView.mapModes.get(root);
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
root = new rootConstructor(null, this)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Remove old root
|
|
95
|
-
if (!!this.root) {
|
|
96
|
-
this.remove(this.root)
|
|
97
|
-
this.root = null
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
this.root = root
|
|
102
|
-
|
|
103
|
-
// Initialize root node
|
|
104
|
-
if (!!this.root) {
|
|
105
|
-
// @ts-ignore
|
|
106
|
-
this.geometry = this.root.constructor.baseGeometry
|
|
107
|
-
// // @ts-ignore
|
|
108
|
-
this.scale.copy(this.root.constructor.baseScale)
|
|
109
|
-
|
|
110
|
-
this.root.mapView = this
|
|
111
|
-
this.add(this.root)
|
|
112
|
-
this.root.initialize()
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Pre-subdivide map tree to create nodes of levels not available in the provider.
|
|
118
|
-
*
|
|
119
|
-
* Checks for the minimum zoom level in the providers attached to the map view.
|
|
120
|
-
*/
|
|
121
|
-
preSubdivide() {
|
|
122
|
-
const minZoom = this.provider.minZoom
|
|
123
|
-
const maxZoom = this.provider.maxZoom
|
|
124
|
-
function subdivide(node, depth) {
|
|
125
|
-
if (depth <= 0) {
|
|
126
|
-
return
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
node.subdivide()
|
|
130
|
-
|
|
131
|
-
for (let i = 0; i < node.children.length; i++) {
|
|
132
|
-
if (node.children[i] instanceof MapNode) {
|
|
133
|
-
const child = node.children[i]
|
|
134
|
-
subdivide(child, depth - 1)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (minZoom > 0) {
|
|
140
|
-
subdivide(this.root, minZoom)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Change the map provider of this map view.
|
|
146
|
-
*
|
|
147
|
-
* Will discard all the tiles already loaded using the old provider.
|
|
148
|
-
*/
|
|
149
|
-
setProvider(provider) {
|
|
150
|
-
if (provider !== this.provider) {
|
|
151
|
-
this.provider = provider
|
|
152
|
-
this.clear()
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Change the map height provider of this map view.
|
|
158
|
-
*
|
|
159
|
-
* Will discard all the tiles already loaded using the old provider.
|
|
160
|
-
*/
|
|
161
|
-
setHeightProvider(heightProvider) {
|
|
162
|
-
if (heightProvider !== this.heightProvider) {
|
|
163
|
-
this.heightProvider = heightProvider
|
|
164
|
-
this.clear()
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Clears all tiles from memory and reloads data. Used when changing the provider.
|
|
170
|
-
*
|
|
171
|
-
* Should be called manually if any changed to the provider are made without setting the provider.
|
|
172
|
-
*/
|
|
173
|
-
clear() {
|
|
174
|
-
this.traverse(function (children) {
|
|
175
|
-
// @ts-ignore
|
|
176
|
-
if (children.childrenCache) {
|
|
177
|
-
// @ts-ignore
|
|
178
|
-
children.childrenCache = null
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// @ts-ignore
|
|
182
|
-
if (children.initialize) {
|
|
183
|
-
// @ts-ignore
|
|
184
|
-
children.initialize()
|
|
185
|
-
}
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
return this
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Get the minimum zoom level available in the providers attached to the map view.
|
|
193
|
-
*
|
|
194
|
-
* @returns Minimum zoom level available.
|
|
195
|
-
*/
|
|
196
|
-
minZoom() {
|
|
197
|
-
return 15
|
|
198
|
-
return Math.max(this.provider.minZoom, -Infinity)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Get the maximum zoom level available in the providers attached to the map view.
|
|
203
|
-
*
|
|
204
|
-
* @returns Maximum zoom level available.
|
|
205
|
-
*/
|
|
206
|
-
maxZoom() {
|
|
207
|
-
return 18
|
|
208
|
-
return Math.min(this.provider.maxZoom, Infinity)
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Get map meta data from server if supported.
|
|
213
|
-
*/
|
|
214
|
-
getMetaData() {
|
|
215
|
-
this.provider.getMetaData()
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
raycast(raycaster, intersects) {
|
|
219
|
-
return false
|
|
220
|
-
}
|
|
221
|
-
}
|
package/src/helper/materials.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three'
|
|
2
|
-
import {
|
|
3
|
-
beamColor,
|
|
4
|
-
beamOpacity,
|
|
5
|
-
node3DColor,
|
|
6
|
-
node3dOpacity,
|
|
7
|
-
defaultTextureUrls
|
|
8
|
-
} from '../config'
|
|
9
|
-
const material = []
|
|
10
|
-
|
|
11
|
-
material.wall = new THREE.MeshLambertMaterial({
|
|
12
|
-
color: 0xdddddd,
|
|
13
|
-
side: THREE.DoubleSide
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
// TODO get Canvas image from TwoD
|
|
17
|
-
material.obstacle = new THREE.MeshPhongMaterial({
|
|
18
|
-
color: 0xff0000,
|
|
19
|
-
side: THREE.DoubleSide
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
material.edge = new THREE.MeshPhongMaterial({
|
|
23
|
-
color: beamColor,
|
|
24
|
-
transparent: true,
|
|
25
|
-
opacity: beamOpacity
|
|
26
|
-
})
|
|
27
|
-
material.node = new THREE.PointsMaterial({
|
|
28
|
-
size: 0.05,
|
|
29
|
-
sizeAttenuation: true,
|
|
30
|
-
color: node3DColor,
|
|
31
|
-
opacity: node3dOpacity,
|
|
32
|
-
transparent: true
|
|
33
|
-
})
|
|
34
|
-
const loader = new THREE.TextureLoader()
|
|
35
|
-
// loader.crossOrigin = 'anonymous'
|
|
36
|
-
// texture.minFilter = THREE.LinearFilter
|
|
37
|
-
material.panel = {}
|
|
38
|
-
|
|
39
|
-
for (let k = 0; k < defaultTextureUrls.length; k++) {
|
|
40
|
-
let texture = loader.load(defaultTextureUrls[k], function (texture) {})
|
|
41
|
-
material.panel['default_' + k] = new THREE.MeshBasicMaterial({
|
|
42
|
-
map: texture,
|
|
43
|
-
side: THREE.DoubleSide,
|
|
44
|
-
transparent: true
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
material.flatRoof = new THREE.MeshPhongMaterial({
|
|
49
|
-
color: 0x00ff00,
|
|
50
|
-
specular: 0x009900,
|
|
51
|
-
shininess: 0,
|
|
52
|
-
flatShading: true,
|
|
53
|
-
side: THREE.DoubleSide,
|
|
54
|
-
transparent: true,
|
|
55
|
-
opacity: 0.5
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
material.moduleField = new THREE.MeshPhongMaterial({
|
|
59
|
-
color: 0xfc9d03,
|
|
60
|
-
specular: 0x000000,
|
|
61
|
-
shininess: 0,
|
|
62
|
-
flatShading: true,
|
|
63
|
-
side: THREE.DoubleSide,
|
|
64
|
-
transparent: true,
|
|
65
|
-
opacity: 0.6
|
|
66
|
-
})
|
|
67
|
-
material.curvedRoof = new THREE.MeshPhongMaterial({
|
|
68
|
-
color: 0xffff00,
|
|
69
|
-
specular: 0x009900,
|
|
70
|
-
shininess: 0,
|
|
71
|
-
flatShading: true,
|
|
72
|
-
side: THREE.DoubleSide,
|
|
73
|
-
transparent: true,
|
|
74
|
-
opacity: 0.5
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
export { material }
|
|
@@ -1,100 +0,0 @@
|
|
|
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 =
|
|
47
|
-
this.layoutSettings.base64_image_url
|
|
48
|
-
resolve(mapProjectionMaterial)
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
},
|
|
52
|
-
setMapProjectionCameraPosition() {
|
|
53
|
-
let backgroundImageCenter = {
|
|
54
|
-
lat: this.layoutSettings.layout_latitude,
|
|
55
|
-
lng: this.layoutSettings.layout_longitude
|
|
56
|
-
}
|
|
57
|
-
if (this.layoutSettings.background_map_settings) {
|
|
58
|
-
backgroundImageCenter = {
|
|
59
|
-
lat: this.layoutSettings.background_map_settings.lat,
|
|
60
|
-
lng: this.layoutSettings.background_map_settings.lng
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
this.backgroundImagesizeInMm =
|
|
64
|
-
this.layoutSettings.background_map_settings.sizeInMm
|
|
65
|
-
if (this.backgroundImagesizeInMm) {
|
|
66
|
-
this.cameraProjection.aspect =
|
|
67
|
-
this.backgroundImagesizeInMm.width /
|
|
68
|
-
this.backgroundImagesizeInMm.height
|
|
69
|
-
let projectionAltitude =
|
|
70
|
-
this.backgroundImagesizeInMm.height /
|
|
71
|
-
(2 * Math.tan((this.cameraProjection.fov * Math.PI) / 360))
|
|
72
|
-
|
|
73
|
-
//set projection camera over background_map_center
|
|
74
|
-
let cameraProjectionPosition = {
|
|
75
|
-
x: 0,
|
|
76
|
-
y: 0,
|
|
77
|
-
z: projectionAltitude / 1000
|
|
78
|
-
}
|
|
79
|
-
if (
|
|
80
|
-
this.layoutSettings.background_map_settings &&
|
|
81
|
-
this.layoutSettings.background_map_settings.positionInMm
|
|
82
|
-
) {
|
|
83
|
-
let positionInMm =
|
|
84
|
-
this.layoutSettings.background_map_settings.positionInMm
|
|
85
|
-
cameraProjectionPosition.x = positionInMm.x / 1000
|
|
86
|
-
cameraProjectionPosition.y = positionInMm.y / 1000
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
this.cameraProjection.position.set(
|
|
90
|
-
cameraProjectionPosition.x,
|
|
91
|
-
cameraProjectionPosition.y,
|
|
92
|
-
projectionAltitude / 1000
|
|
93
|
-
)
|
|
94
|
-
this.cameraProjection.far = projectionAltitude * 1.5
|
|
95
|
-
this.cameraProjection.near = projectionAltitude * 0.5
|
|
96
|
-
this.cameraProjection.updateProjectionMatrix()
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|