@eturnity/eturnity_3d 1.0.10 → 1.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_3d",
3
3
  "private": false,
4
- "version": "1.0.10",
4
+ "version": "1.0.11",
5
5
  "main": "dist/main.js",
6
6
  "scripts": {
7
7
  "dev": "vue-cli-service serve --skip-plugins @vue/cli-plugin-eslint",
@@ -106,6 +106,7 @@ export default {
106
106
  set_module_texture_version_id: 'mutate_module_texture_version_id'
107
107
  }),
108
108
  setCamera(polygon, view_mode) {
109
+ let margin=0.2
109
110
  console.log('viewmode', view_mode)
110
111
  if (!polygon || view_mode == 'global') {
111
112
  let roofsBounds = this.roofsBounds
@@ -116,29 +117,9 @@ export default {
116
117
  this.orthographicCamera.position.set(...position)
117
118
  this.orthographicCamera.lookAt(...target)
118
119
  this.isReady.camera = true
119
- let ratioCanvas=this.canvasHeight/this.canvasWidth
120
- let width=roofsBounds.xMax-roofsBounds.xMin
121
- let height=roofsBounds.yMax-roofsBounds.yMin
122
- let ratio=height/width
123
-
124
- let xCenter=(roofsBounds.xMax+roofsBounds.xMin)/2
125
- let yCenter=(roofsBounds.yMax+roofsBounds.yMin)/2
126
- let xMin
127
- let xMax
128
- let yMin
129
- let yMax
130
- if(ratioCanvas<ratio){
131
- //canvas wider
132
- xMin=xCenter-width*(ratio/ratioCanvas)/2
133
- xMax=xCenter+width*(ratio/ratioCanvas)/2
134
- yMin=yCenter-height/2
135
- yMax=yCenter+height/2
136
- }else{
137
- xMin=xCenter-width/ratio/2
138
- xMax=xCenter+width/ratio/2
139
- yMin=yCenter-height*(ratioCanvas/ratio)/2
140
- yMax=yCenter+height*(ratioCanvas/ratio)/2
141
- }
120
+
121
+ let {xMin,xMax,yMin,yMax}=this.orthographicBounds(roofsBounds,margin)
122
+
142
123
  this.orthographicCamera.left = xMin / 1000
143
124
  this.orthographicCamera.right = xMax / 1000
144
125
  this.orthographicCamera.top = yMax / 1000
@@ -191,13 +172,15 @@ export default {
191
172
  const position = [0,0, 100]
192
173
  const target = [0, 0, 0]
193
174
 
175
+ let {xMin,xMax,yMin,yMax}=this.orthographicBounds(polygonBounds,margin)
194
176
  console.log('top POS TARGET', position, target)
195
177
  this.orthographicCamera.position.set(...position)
196
178
  this.orthographicCamera.lookAt(...target)
197
- this.orthographicCamera.left = polygonBounds.xMin / 1000
198
- this.orthographicCamera.right = polygonBounds.xMax / 1000
199
- this.orthographicCamera.top = polygonBounds.yMax / 1000
200
- this.orthographicCamera.bottom = polygonBounds.yMin / 1000
179
+
180
+ this.orthographicCamera.left = xMin / 1000
181
+ this.orthographicCamera.right = xMax / 1000
182
+ this.orthographicCamera.top = yMax / 1000
183
+ this.orthographicCamera.bottom = yMin / 1000
201
184
  this.orthographicCamera.updateProjectionMatrix()
202
185
  } else {
203
186
  //street view
@@ -222,6 +205,32 @@ export default {
222
205
  this.isReady.camera = true
223
206
  }
224
207
  },
208
+ orthographicBounds(bounds,margin){
209
+ let ratioCanvas=this.canvasHeight/this.canvasWidth
210
+ let width=(bounds.xMax-bounds.xMin)*(1+margin)
211
+ let height=(bounds.yMax-bounds.yMin)*(1+margin)
212
+ let ratio=height/width
213
+
214
+ let xCenter=(bounds.xMax+bounds.xMin)/2
215
+ let yCenter=(bounds.yMax+bounds.yMin)/2
216
+ let xMin
217
+ let xMax
218
+ let yMin
219
+ let yMax
220
+ if(ratioCanvas<ratio){
221
+ //canvas wider
222
+ xMin=xCenter-width*(ratio/ratioCanvas)/2
223
+ xMax=xCenter+width*(ratio/ratioCanvas)/2
224
+ yMin=yCenter-height/2
225
+ yMax=yCenter+height/2
226
+ }else{
227
+ xMin=xCenter-width/ratio/2
228
+ xMax=xCenter+width/ratio/2
229
+ yMin=yCenter-height*(ratioCanvas/ratio)/2
230
+ yMax=yCenter+height*(ratioCanvas/ratio)/2
231
+ }
232
+ return {xMin,xMax,yMin,yMax}
233
+ },
225
234
  animate() {
226
235
  this.render()
227
236
  requestAnimationFrame(this.animate)