@eturnity/eturnity_3d 7.24.2 → 7.30.0

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": "7.24.2",
4
+ "version": "7.30.0",
5
5
  "files": [
6
6
  "dist",
7
7
  "src"
@@ -15,7 +15,7 @@
15
15
  "prettier": "prettier --write \"**/*.{js,vue}\""
16
16
  },
17
17
  "dependencies": {
18
- "@eturnity/eturnity_maths": "7.24.1",
18
+ "@eturnity/eturnity_maths": "7.30.0",
19
19
  "@originjs/vite-plugin-commonjs": "1.0.3",
20
20
  "core-js": "2.6.12",
21
21
  "cors": "2.8.5",
@@ -27,7 +27,6 @@
27
27
  "lodash": "4.17.21",
28
28
  "svd-js": "1.1.1",
29
29
  "three": "0.149.0",
30
- "three-projected-material": "2.2.1",
31
30
  "tween": "0.9.0",
32
31
  "uuid": "9.0.0",
33
32
  "vite-plugin-require": "1.1.14",
@@ -53,15 +53,16 @@ export default class ImageOverlay extends Overlay {
53
53
  }
54
54
  async initialiseImage(url) {
55
55
  const img = new Image()
56
+ img.crossOrigin = 'Anonymous'
56
57
  const _this = this
57
58
  const promise = new Promise((resolve, reject) => {
58
59
  img.onload = function () {
59
60
  _this.width = this.width
60
61
  _this.height = this.height
62
+ _this.img = this
61
63
  resolve(true)
62
64
  }
63
65
  img.onerror = reject
64
- this.img = img
65
66
  })
66
67
  img.src = url
67
68
  return promise
@@ -166,10 +167,12 @@ export default class ImageOverlay extends Overlay {
166
167
  handles.visible = isRotationHandleVisible
167
168
  }
168
169
  loadImageOverlay(url, corners) {
169
- let rasterImageOverlay = new Paper.Raster({
170
- source: url,
171
- crossOrigin: 'Anonymous'
172
- })
170
+ let rasterImageOverlay = this.img
171
+ ? new Paper.Raster(this.img)
172
+ : new Paper.Raster({
173
+ source: url,
174
+ crossOrigin: 'Anonymous'
175
+ })
173
176
  rasterImageOverlay.onLoad = () => {
174
177
  this.applyRasterToCorners(rasterImageOverlay, corners)
175
178
  }
@@ -13,7 +13,7 @@ import {
13
13
  getBufferRoofGeometry
14
14
  } from '../helper/render/geometryHandler'
15
15
  import * as THREE from 'three'
16
- import ProjectedMaterial from 'three-projected-material'
16
+ import ProjectedMaterial from '../helper/projectedMaterial'
17
17
  export default class Overlay extends Item {
18
18
  constructor(overlay, emit) {
19
19
  super(emit)
@@ -148,8 +148,9 @@ export default class Overlay extends Item {
148
148
  resolve(this.imageOverlayProjectionMaterial)
149
149
  return
150
150
  }
151
- const loader = new THREE.TextureLoader()
152
- loader.load(url, (texture) => {
151
+
152
+ const callback = (texture) => {
153
+ texture.needsUpdate = true
153
154
  this.setImageOverlayCameraPosition()
154
155
  let imageOverlayProjectionMaterial = new ProjectedMaterial({
155
156
  camera: this.overlayProjectionCamera,
@@ -166,7 +167,14 @@ export default class Overlay extends Item {
166
167
  imageOverlayProjectionMaterial.opacity = this.opacity
167
168
  this.imageOverlayProjectionMaterial = imageOverlayProjectionMaterial
168
169
  resolve(imageOverlayProjectionMaterial)
169
- })
170
+ }
171
+
172
+ if (this.img) {
173
+ callback(new THREE.Texture(this.img))
174
+ } else {
175
+ const loader = new THREE.TextureLoader()
176
+ loader.load(url, callback)
177
+ }
170
178
  })
171
179
  }
172
180
  getBackgroundGeometry() {
@@ -216,17 +224,19 @@ export default class Overlay extends Item {
216
224
  cameraChanged = true
217
225
  }
218
226
  this.overlayProjectionCamera.rotation.set(0, 0, (zAngle * Math.PI) / 180)
227
+ const CAMERA_HEIGHT_OFFSET = 50
219
228
  if (
220
229
  this.overlayProjectionCamera.position.x != boxCenter.x / 1000 ||
221
230
  this.overlayProjectionCamera.position.y != boxCenter.y / 1000 ||
222
- this.overlayProjectionCamera.position.z != boxCenter.z / 1000 + 50
231
+ this.overlayProjectionCamera.position.z !=
232
+ boxCenter.z / 1000 + CAMERA_HEIGHT_OFFSET
223
233
  ) {
224
234
  cameraChanged = true
225
235
  }
226
236
  this.overlayProjectionCamera.position.set(
227
237
  boxCenter.x / 1000,
228
238
  boxCenter.y / 1000,
229
- boxCenter.z / 1000 + 50
239
+ boxCenter.z / 1000 + CAMERA_HEIGHT_OFFSET
230
240
  )
231
241
  this.overlayProjectionCamera.updateProjectionMatrix()
232
242
  return cameraChanged
@@ -577,8 +577,8 @@ function _saveCameraMatrices2() {
577
577
  this.uniforms.viewMatrixCamera.value.copy(viewMatrixCamera)
578
578
  this.uniforms.projectionMatrixCamera.value.copy(projectionMatrixCamera)
579
579
  this.uniforms.projPosition.value.setFromMatrixPosition(modelMatrixCamera)
580
- this.uniforms.projDirection.value.set(0, 0, 1).applyMatrix4(modelMatrixCamera) // tell the shader we've projected
581
-
580
+ this.uniforms.projDirection.value.set(0, 0, 1).transformDirection(modelMatrixCamera)
581
+ // tell the shader we've projected
582
582
  this.uniforms.isTextureProjected.value = true
583
583
  }
584
584
 
@@ -1,5 +1,4 @@
1
1
  import * as THREE from 'three'
2
- import ProjectedMaterial from 'three-projected-material'
3
2
 
4
3
  export default {
5
4
  methods: {
@@ -42,7 +42,7 @@ export default {
42
42
  '_' +
43
43
  mapLayer
44
44
  tileProjectionMaterial.userData.mapLayer = mapLayer
45
- tileProjectionMaterial.userData.priority = 10
45
+ tileProjectionMaterial.priority = 10
46
46
  this.material.projectionTiles.push(tileProjectionMaterial)
47
47
  this.material.roof = this.material.roof.filter(
48
48
  (m) => m.userData.type != 'tileProjectionMaterial'