@mcolabs/threebox-plugin 4.0.2 → 4.0.4
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/dist/threebox.cjs +1 -1
- package/dist/threebox.cjs.map +1 -1
- package/dist/threebox.iife.js +1 -1
- package/dist/threebox.iife.js.map +1 -1
- package/dist/threebox.js +9 -1
- package/dist/threebox.js.map +1 -1
- package/package.json +1 -1
- package/src/animation/AnimationManager.js +0 -1
- package/src/camera/CameraSync.js +13 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcolabs/threebox-plugin",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Three.js plugin for Mapbox GL JS, using the CustomLayerInterface feature. Provides convenient methods to manage objects in lnglat coordinates, and to synchronize the map and scene cameras.",
|
|
6
6
|
"main": "dist/threebox.cjs",
|
|
@@ -456,7 +456,6 @@ AnimationManager.prototype = {
|
|
|
456
456
|
if (item.type === 'playDefault') {
|
|
457
457
|
object.activateAllActions();
|
|
458
458
|
object.isPlaying = true;
|
|
459
|
-
object.animationMethod = requestAnimationFrame(this.update);
|
|
460
459
|
object.mixer.update(object.clock.getDelta());
|
|
461
460
|
object.threebox.map.repaint = true;
|
|
462
461
|
}
|
package/src/camera/CameraSync.js
CHANGED
|
@@ -13,13 +13,11 @@ function CameraSync(map, camera, world) {
|
|
|
13
13
|
this.active = true;
|
|
14
14
|
|
|
15
15
|
this.camera.matrixAutoUpdate = false; // We're in charge of the camera now!
|
|
16
|
-
this.camera.matrixWorldAutoUpdate = false; // Three.js r150+: prevent auto world matrix recalculation
|
|
17
16
|
|
|
18
17
|
// Postion and configure the world group so we can scale it appropriately when the camera zooms
|
|
19
18
|
this.world = world || new THREE.Group();
|
|
20
19
|
this.world.position.x = this.world.position.y = ThreeboxConstants.WORLD_SIZE / 2
|
|
21
20
|
this.world.matrixAutoUpdate = false;
|
|
22
|
-
this.world.matrixWorldAutoUpdate = false; // Three.js r150+: prevent auto world matrix recalculation
|
|
23
21
|
|
|
24
22
|
// set up basic camera state
|
|
25
23
|
this.state = {
|
|
@@ -60,6 +58,17 @@ CameraSync.prototype = {
|
|
|
60
58
|
|
|
61
59
|
const t = this.map.transform;
|
|
62
60
|
this.camera.aspect = t.width / t.height; //bug fixed, if aspect is not reset raycast will fail on map resize
|
|
61
|
+
|
|
62
|
+
// Check if canvas size changed and update renderer for correct raycasting
|
|
63
|
+
if (this.map.tb && this.map.tb.renderer) {
|
|
64
|
+
const canvas = this.map.getCanvas();
|
|
65
|
+
if (this._lastCanvasWidth !== canvas.clientWidth || this._lastCanvasHeight !== canvas.clientHeight) {
|
|
66
|
+
this._lastCanvasWidth = canvas.clientWidth;
|
|
67
|
+
this._lastCanvasHeight = canvas.clientHeight;
|
|
68
|
+
this.map.tb.renderer.setSize(canvas.clientWidth, canvas.clientHeight);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
63
72
|
const offset = t.centerOffset || new THREE.Vector3(); //{ x: t.width / 2, y: t.height / 2 };
|
|
64
73
|
let farZ = 0;
|
|
65
74
|
let furthestDistance = 0;
|
|
@@ -114,6 +123,8 @@ CameraSync.prototype = {
|
|
|
114
123
|
}
|
|
115
124
|
this.camera.projectionMatrix.elements[8] = -offset.x * 2 / t.width;
|
|
116
125
|
this.camera.projectionMatrix.elements[9] = offset.y * 2 / t.height;
|
|
126
|
+
// Update inverse projection matrix for raycasting
|
|
127
|
+
this.camera.projectionMatrixInverse.copy(this.camera.projectionMatrix).invert();
|
|
117
128
|
|
|
118
129
|
// Unlike the Mapbox GL JS camera, separate camera translation and rotation out into its world matrix
|
|
119
130
|
// If this is applied directly to the projection matrix, it will work OK but break raycasting
|