3dtiles-inspector 0.2.2 → 0.2.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/CHANGELOG.md +22 -0
- package/README.md +6 -5
- package/dist/inspector-assets/viewer/app.js +1359 -122
- package/package.json +1 -1
- package/src/server/viewerHtml.js +112 -3
- package/src/viewer/app.js +8 -3
- package/src/viewer/navigation/cameraFlyTo.js +730 -0
- package/src/viewer/navigation/flyTo.js +78 -16
- package/src/viewer/scene/cameraController.js +2 -2
- package/src/viewer/scene/sceneSetup.js +3 -6
- package/src/viewer/screenSelection/cropController.js +418 -6
- package/src/viewer/screenSelection/editOverlay.js +348 -0
- package/src/viewer/screenSelection/geometry.js +66 -52
- package/src/viewer/screenSelection/index.js +61 -0
- package/src/viewer/screenSelection/pointerTracker.js +19 -11
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Raycaster, Sphere, Vector2, Vector3 } from 'three';
|
|
2
|
+
import {
|
|
3
|
+
createCameraFlight,
|
|
4
|
+
flyTo as applyCameraFlyTo,
|
|
5
|
+
getFlyToParamsFromBoundingSphere,
|
|
6
|
+
} from './cameraFlyTo.js';
|
|
2
7
|
import { mouseToCoords, setRaycasterFromCamera } from '../utils.js';
|
|
3
8
|
|
|
4
9
|
export function createFlyToController({
|
|
@@ -19,6 +24,8 @@ export function createFlyToController({
|
|
|
19
24
|
const pickRaycaster = new Raycaster();
|
|
20
25
|
const pickTargets = [];
|
|
21
26
|
const sphere = new Sphere();
|
|
27
|
+
let activeCameraFlight = null;
|
|
28
|
+
let activeCameraFlightStatus = '';
|
|
22
29
|
|
|
23
30
|
function getActiveEllipsoid() {
|
|
24
31
|
return getTiles()?.ellipsoid || globeController.getEllipsoid();
|
|
@@ -74,6 +81,58 @@ export function createFlyToController({
|
|
|
74
81
|
return geoCamera.getCartographicFromWorldPosition(coordinateWorldPosition);
|
|
75
82
|
}
|
|
76
83
|
|
|
84
|
+
function startCameraFlight(
|
|
85
|
+
position,
|
|
86
|
+
target,
|
|
87
|
+
options = {},
|
|
88
|
+
{ activeStatus = 'Moving camera.', doneStatus = 'Moved camera.' } = {},
|
|
89
|
+
) {
|
|
90
|
+
cameraController.setCamera(camera);
|
|
91
|
+
activeCameraFlight = createCameraFlight(camera, position, target, options);
|
|
92
|
+
activeCameraFlightStatus = doneStatus;
|
|
93
|
+
if (!activeCameraFlight) {
|
|
94
|
+
cameraController.setCamera(camera);
|
|
95
|
+
setStatus(doneStatus);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setStatus(activeStatus);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function startBoundingSphereFlight(
|
|
103
|
+
target,
|
|
104
|
+
radius,
|
|
105
|
+
options = {},
|
|
106
|
+
status = {},
|
|
107
|
+
) {
|
|
108
|
+
const flyToParams = getFlyToParamsFromBoundingSphere(
|
|
109
|
+
camera,
|
|
110
|
+
target,
|
|
111
|
+
radius,
|
|
112
|
+
options,
|
|
113
|
+
);
|
|
114
|
+
startCameraFlight(
|
|
115
|
+
flyToParams.position,
|
|
116
|
+
flyToParams.target,
|
|
117
|
+
flyToParams.options,
|
|
118
|
+
status,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function update(time = performance.now()) {
|
|
123
|
+
if (!activeCameraFlight) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const done = applyCameraFlyTo(camera, activeCameraFlight, time);
|
|
128
|
+
if (done) {
|
|
129
|
+
activeCameraFlight = null;
|
|
130
|
+
setStatus(activeCameraFlightStatus);
|
|
131
|
+
activeCameraFlightStatus = '';
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
|
|
77
136
|
async function applyTilesSetPositionFromPointerEvent(event) {
|
|
78
137
|
const coordinate = pickCoordinateFromPointerEvent(event);
|
|
79
138
|
if (!coordinate) {
|
|
@@ -97,29 +156,32 @@ export function createFlyToController({
|
|
|
97
156
|
}
|
|
98
157
|
}
|
|
99
158
|
|
|
100
|
-
function frameTileset(
|
|
159
|
+
function frameTileset({
|
|
160
|
+
activeStatus = 'Moving camera to the tileset.',
|
|
161
|
+
doneStatus = 'Moved camera to the tileset.',
|
|
162
|
+
} = {}) {
|
|
101
163
|
if (!getTilesetBoundingSphere(sphere)) {
|
|
102
164
|
return false;
|
|
103
165
|
}
|
|
104
166
|
|
|
105
|
-
|
|
167
|
+
startBoundingSphereFlight(
|
|
106
168
|
sphere.center,
|
|
107
|
-
sphere.radius,
|
|
169
|
+
sphere.radius / 2,
|
|
108
170
|
moveToTilesPose,
|
|
171
|
+
{
|
|
172
|
+
activeStatus,
|
|
173
|
+
doneStatus,
|
|
174
|
+
},
|
|
109
175
|
);
|
|
110
|
-
camera.position.copy(pose.position);
|
|
111
|
-
camera.quaternion.copy(pose.quaternion);
|
|
112
|
-
camera.updateMatrixWorld(true);
|
|
113
|
-
cameraController.setCamera(camera);
|
|
114
176
|
return true;
|
|
115
177
|
}
|
|
116
178
|
|
|
117
179
|
function moveCameraToTiles() {
|
|
118
180
|
if (frameTileset()) {
|
|
119
|
-
|
|
120
|
-
} else {
|
|
121
|
-
setStatus('Tileset is not ready to frame yet.', true);
|
|
181
|
+
return;
|
|
122
182
|
}
|
|
183
|
+
|
|
184
|
+
setStatus('Tileset is not ready to frame yet.', true);
|
|
123
185
|
}
|
|
124
186
|
|
|
125
187
|
function moveCameraToCoordinate(coordinate) {
|
|
@@ -129,16 +191,15 @@ export function createFlyToController({
|
|
|
129
191
|
coordinate.height,
|
|
130
192
|
coordinateWorldPosition,
|
|
131
193
|
);
|
|
132
|
-
|
|
194
|
+
startBoundingSphereFlight(
|
|
133
195
|
coordinateWorldPosition,
|
|
134
196
|
moveToCoordinateRadius,
|
|
135
197
|
moveToTilesPose,
|
|
198
|
+
{
|
|
199
|
+
activeStatus: 'Moving camera to the specified coordinate.',
|
|
200
|
+
doneStatus: 'Moved camera to the specified coordinate.',
|
|
201
|
+
},
|
|
136
202
|
);
|
|
137
|
-
camera.position.copy(pose.position);
|
|
138
|
-
camera.quaternion.copy(pose.quaternion);
|
|
139
|
-
camera.updateMatrixWorld(true);
|
|
140
|
-
cameraController.setCamera(camera);
|
|
141
|
-
setStatus('Moved camera to the specified coordinate.');
|
|
142
203
|
}
|
|
143
204
|
|
|
144
205
|
return {
|
|
@@ -148,5 +209,6 @@ export function createFlyToController({
|
|
|
148
209
|
moveCameraToCoordinate,
|
|
149
210
|
moveCameraToTiles,
|
|
150
211
|
pickCoordinateFromPointerEvent,
|
|
212
|
+
update,
|
|
151
213
|
};
|
|
152
214
|
}
|
|
@@ -1100,7 +1100,7 @@ class CameraController extends EventDispatcher {
|
|
|
1100
1100
|
const minScale = 0;
|
|
1101
1101
|
metrics.distanceScale = baseScale;
|
|
1102
1102
|
metrics.transitionWeight = 0;
|
|
1103
|
-
if (!this.#ellipsoid) {
|
|
1103
|
+
if (!this.#ellipsoid || this.#isCameraCenterMode()) {
|
|
1104
1104
|
return metrics;
|
|
1105
1105
|
}
|
|
1106
1106
|
const taperStartRadius = this.#ellipsoidMaxRadius * 1.5;
|
|
@@ -1161,7 +1161,7 @@ class CameraController extends EventDispatcher {
|
|
|
1161
1161
|
const source = _vec4.copy(this.#camera.position);
|
|
1162
1162
|
let distanceScale = 1;
|
|
1163
1163
|
let transitionWeight = 0;
|
|
1164
|
-
if (zoomAmount < 0 && this.#ellipsoid) {
|
|
1164
|
+
if (zoomAmount < 0 && this.#ellipsoid && !this.#isCameraCenterMode()) {
|
|
1165
1165
|
const metrics = this.#getZoomOutMetrics(source, hit.virtual ? null : hit);
|
|
1166
1166
|
distanceScale = metrics.distanceScale;
|
|
1167
1167
|
transitionWeight = metrics.transitionWeight;
|
|
@@ -6,10 +6,7 @@ import {
|
|
|
6
6
|
Scene,
|
|
7
7
|
WebGLRenderer,
|
|
8
8
|
} from 'three';
|
|
9
|
-
import {
|
|
10
|
-
SplatEdit,
|
|
11
|
-
SplatEditRgbaBlendMode,
|
|
12
|
-
} from '@sparkjsdev/spark';
|
|
9
|
+
import { SplatEdit, SplatEditRgbaBlendMode } from '@sparkjsdev/spark';
|
|
13
10
|
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
|
|
14
11
|
import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
|
|
15
12
|
import { CameraController } from './cameraController.js';
|
|
@@ -47,9 +44,9 @@ export function createViewerScene({
|
|
|
47
44
|
60,
|
|
48
45
|
window.innerWidth / window.innerHeight,
|
|
49
46
|
1,
|
|
50
|
-
2e7,
|
|
47
|
+
1.2e7,
|
|
51
48
|
);
|
|
52
|
-
camera.position.set(0, 0, 1.
|
|
49
|
+
camera.position.set(0, 0, 1.2e7);
|
|
53
50
|
camera.updateMatrixWorld(true);
|
|
54
51
|
|
|
55
52
|
const contentGroup = new Group();
|