vim-web 0.4.0 → 0.4.1-dev.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/dist/types/core-viewers/webgl/viewer/camera/camera.d.ts +3 -4
- package/dist/types/core-viewers/webgl/viewer/camera/cameraInterface.d.ts +9 -0
- package/dist/types/core-viewers/webgl/viewer/camera/cameraMovement.d.ts +5 -2
- package/dist/types/core-viewers/webgl/viewer/camera/cameraMovementLerp.d.ts +2 -2
- package/dist/types/core-viewers/webgl/viewer/camera/cameraMovementSnap.d.ts +0 -1
- package/dist/types/core-viewers/webgl/viewer/camera/cameraOrthographic.d.ts +1 -2
- package/dist/types/core-viewers/webgl/viewer/camera/cameraPerspective.d.ts +1 -2
- package/dist/vim-web.iife.js +53 -38
- package/dist/vim-web.iife.js.map +1 -1
- package/dist/vim-web.js +53 -38
- package/dist/vim-web.js.map +1 -1
- package/package.json +1 -1
package/dist/vim-web.js
CHANGED
|
@@ -50031,6 +50031,24 @@ const index$9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
50031
50031
|
createTransparent,
|
|
50032
50032
|
createWireframe
|
|
50033
50033
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
50034
|
+
class CameraSaveState {
|
|
50035
|
+
constructor(camera2) {
|
|
50036
|
+
__publicField(this, "_camera");
|
|
50037
|
+
__publicField(this, "_position", new Vector3());
|
|
50038
|
+
__publicField(this, "_target", new Vector3());
|
|
50039
|
+
this._camera = camera2;
|
|
50040
|
+
}
|
|
50041
|
+
save() {
|
|
50042
|
+
this._position.copy(this._camera.position);
|
|
50043
|
+
this._target.copy(this._camera.target);
|
|
50044
|
+
}
|
|
50045
|
+
get position() {
|
|
50046
|
+
return this._position;
|
|
50047
|
+
}
|
|
50048
|
+
get target() {
|
|
50049
|
+
return this._target;
|
|
50050
|
+
}
|
|
50051
|
+
}
|
|
50034
50052
|
const _Marker = class _Marker {
|
|
50035
50053
|
/**
|
|
50036
50054
|
* Constructs a new Marker object.
|
|
@@ -50214,9 +50232,13 @@ __publicField(_Marker, "_tmpMatrix", new Matrix4());
|
|
|
50214
50232
|
__publicField(_Marker, "_unitVector", new Vector3(1, 1, 1));
|
|
50215
50233
|
let Marker = _Marker;
|
|
50216
50234
|
class CameraMovement {
|
|
50217
|
-
constructor(camera2) {
|
|
50235
|
+
constructor(camera2, savedState, getBoundingBox) {
|
|
50218
50236
|
__publicField(this, "_camera");
|
|
50237
|
+
__publicField(this, "_savedState");
|
|
50238
|
+
__publicField(this, "_getBoundingBox");
|
|
50219
50239
|
this._camera = camera2;
|
|
50240
|
+
this._savedState = savedState;
|
|
50241
|
+
this._getBoundingBox = getBoundingBox;
|
|
50220
50242
|
}
|
|
50221
50243
|
/**
|
|
50222
50244
|
* Moves the camera in a specified 2D direction within a plane defined by the given axes.
|
|
@@ -50264,6 +50286,12 @@ class CameraMovement {
|
|
|
50264
50286
|
angle.multiplyScalar(180 / Math.PI);
|
|
50265
50287
|
this.orbit(angle);
|
|
50266
50288
|
}
|
|
50289
|
+
/**
|
|
50290
|
+
* Resets the camera to its last saved position and orientation.
|
|
50291
|
+
*/
|
|
50292
|
+
reset() {
|
|
50293
|
+
this.set(this._camera.position, this._camera.target);
|
|
50294
|
+
}
|
|
50267
50295
|
/**
|
|
50268
50296
|
* Sets the camera's orientation and position to focus on the specified target.
|
|
50269
50297
|
* @param {IObject | Vim | THREE.Sphere | THREE.Box3 | 'all' | undefined} target - The target object, or 'all' to frame all objects.
|
|
@@ -50278,7 +50306,7 @@ class CameraMovement {
|
|
|
50278
50306
|
}
|
|
50279
50307
|
if (target === "all") {
|
|
50280
50308
|
console.log("frame all");
|
|
50281
|
-
target = this.
|
|
50309
|
+
target = this._getBoundingBox();
|
|
50282
50310
|
}
|
|
50283
50311
|
if (target instanceof Box3) {
|
|
50284
50312
|
target = target.getBoundingSphere(new Sphere());
|
|
@@ -50310,8 +50338,8 @@ class CameraMovement {
|
|
|
50310
50338
|
}
|
|
50311
50339
|
}
|
|
50312
50340
|
class CameraLerp extends CameraMovement {
|
|
50313
|
-
constructor(camera2, movement) {
|
|
50314
|
-
super(camera2);
|
|
50341
|
+
constructor(camera2, movement, savedState, getBoundingBox) {
|
|
50342
|
+
super(camera2, savedState, getBoundingBox);
|
|
50315
50343
|
__publicField(this, "_movement");
|
|
50316
50344
|
__publicField(this, "_clock", new Clock());
|
|
50317
50345
|
// position
|
|
@@ -50352,11 +50380,11 @@ class CameraLerp extends CameraMovement {
|
|
|
50352
50380
|
const start = this._camera.position.clone();
|
|
50353
50381
|
const end = this._camera.position.clone().add(v);
|
|
50354
50382
|
const pos = new Vector3();
|
|
50383
|
+
const offset = this._camera.forward.multiplyScalar(this._camera.orbitDistance);
|
|
50355
50384
|
this.onProgress = (progress) => {
|
|
50356
|
-
console.log("progress", progress);
|
|
50357
50385
|
pos.copy(start);
|
|
50358
50386
|
pos.lerp(end, progress);
|
|
50359
|
-
this._movement.
|
|
50387
|
+
this._movement.set(pos, pos.clone().add(offset));
|
|
50360
50388
|
};
|
|
50361
50389
|
}
|
|
50362
50390
|
rotate(angle) {
|
|
@@ -50412,9 +50440,6 @@ class CameraLerp extends CameraMovement {
|
|
|
50412
50440
|
this._movement.applyRotation(r);
|
|
50413
50441
|
};
|
|
50414
50442
|
}
|
|
50415
|
-
reset() {
|
|
50416
|
-
this.set(this._camera._savedPosition, this._camera._savedTarget);
|
|
50417
|
-
}
|
|
50418
50443
|
set(position, target) {
|
|
50419
50444
|
const endTarget = target ?? this._camera.target;
|
|
50420
50445
|
const startPos = this._camera.position.clone();
|
|
@@ -50436,9 +50461,6 @@ class CameraMovementSnap extends CameraMovement {
|
|
|
50436
50461
|
const dist2 = this._camera.orbitDistance * amount;
|
|
50437
50462
|
this.setDistance(dist2);
|
|
50438
50463
|
}
|
|
50439
|
-
reset() {
|
|
50440
|
-
this.set(this._camera._savedPosition, this._camera._savedTarget);
|
|
50441
|
-
}
|
|
50442
50464
|
setDistance(dist2) {
|
|
50443
50465
|
const pos = this._camera.target.clone().sub(this._camera.forward.multiplyScalar(dist2));
|
|
50444
50466
|
this.set(pos, this._camera.target);
|
|
@@ -51138,10 +51160,14 @@ function threeNDCFromVector2(position) {
|
|
|
51138
51160
|
);
|
|
51139
51161
|
}
|
|
51140
51162
|
class OrthographicCamera2 {
|
|
51141
|
-
constructor(camera2) {
|
|
51163
|
+
constructor(camera2, settings2) {
|
|
51142
51164
|
__publicField(this, "camera");
|
|
51143
51165
|
this.camera = camera2;
|
|
51144
51166
|
this.camera.layers.enable(Layers2.NoRaycast);
|
|
51167
|
+
this.camera.zoom = settings2.camera.zoom;
|
|
51168
|
+
this.camera.near = -settings2.camera.far;
|
|
51169
|
+
this.camera.far = settings2.camera.far;
|
|
51170
|
+
this.camera.updateProjectionMatrix();
|
|
51145
51171
|
}
|
|
51146
51172
|
frustrumSizeAt(point) {
|
|
51147
51173
|
return new Vector2(
|
|
@@ -51149,12 +51175,6 @@ class OrthographicCamera2 {
|
|
|
51149
51175
|
this.camera.top - this.camera.bottom
|
|
51150
51176
|
);
|
|
51151
51177
|
}
|
|
51152
|
-
applySettings(settings2) {
|
|
51153
|
-
this.camera.zoom = settings2.camera.zoom;
|
|
51154
|
-
this.camera.near = -settings2.camera.far;
|
|
51155
|
-
this.camera.far = settings2.camera.far;
|
|
51156
|
-
this.camera.updateProjectionMatrix();
|
|
51157
|
-
}
|
|
51158
51178
|
updateProjection(size, aspect2) {
|
|
51159
51179
|
const max2 = Math.max(size.x, size.y);
|
|
51160
51180
|
this.camera.left = -max2 * aspect2;
|
|
@@ -51165,12 +51185,10 @@ class OrthographicCamera2 {
|
|
|
51165
51185
|
}
|
|
51166
51186
|
}
|
|
51167
51187
|
class PerspectiveCamera2 {
|
|
51168
|
-
constructor(camera2) {
|
|
51188
|
+
constructor(camera2, settings2) {
|
|
51169
51189
|
__publicField(this, "camera");
|
|
51170
51190
|
this.camera = camera2;
|
|
51171
51191
|
this.camera.layers.enable(Layers2.NoRaycast);
|
|
51172
|
-
}
|
|
51173
|
-
applySettings(settings2) {
|
|
51174
51192
|
this.camera.fov = settings2.camera.fov;
|
|
51175
51193
|
this.camera.zoom = settings2.camera.zoom;
|
|
51176
51194
|
this.camera.near = settings2.camera.near;
|
|
@@ -51210,8 +51228,7 @@ let Camera$1 = class Camera2 {
|
|
|
51210
51228
|
__publicField(this, "_tmp1", new Vector3());
|
|
51211
51229
|
__publicField(this, "_tmp2", new Vector3());
|
|
51212
51230
|
// saves
|
|
51213
|
-
__publicField(this, "
|
|
51214
|
-
__publicField(this, "_savedTarget", new Vector3(0, 0, 0));
|
|
51231
|
+
__publicField(this, "_savedState", new CameraSaveState(this));
|
|
51215
51232
|
__publicField(this, "_onValueChanged", new distExports$1.SignalDispatcher());
|
|
51216
51233
|
__publicField(this, "_hasMoved");
|
|
51217
51234
|
__publicField(this, "_onMoved", new distExports$1.SignalDispatcher());
|
|
@@ -51229,18 +51246,24 @@ let Camera$1 = class Camera2 {
|
|
|
51229
51246
|
__publicField(this, "_defaultForward", new Vector3(1, -1, 1).normalize());
|
|
51230
51247
|
// Settings
|
|
51231
51248
|
__publicField(this, "_velocityBlendFactor", 1e-4);
|
|
51232
|
-
this.camPerspective = new PerspectiveCamera2(new PerspectiveCamera$1());
|
|
51249
|
+
this.camPerspective = new PerspectiveCamera2(new PerspectiveCamera$1(), settings2);
|
|
51233
51250
|
this.camPerspective.camera.up = new Vector3(0, 0, 1);
|
|
51234
51251
|
this.camPerspective.camera.lookAt(new Vector3(0, 1, 0));
|
|
51235
51252
|
this.camOrthographic = new OrthographicCamera2(
|
|
51236
|
-
new OrthographicCamera$1()
|
|
51253
|
+
new OrthographicCamera$1(),
|
|
51254
|
+
settings2
|
|
51237
51255
|
);
|
|
51238
|
-
this.
|
|
51239
|
-
this.
|
|
51256
|
+
this._savedState = new CameraSaveState(this);
|
|
51257
|
+
this._movement = new CameraMovementSnap(this, this._savedState, () => this._scene.getBoundingBox());
|
|
51258
|
+
this._lerp = new CameraLerp(this, this._movement, this._savedState, () => this._scene.getBoundingBox());
|
|
51240
51259
|
this._scene = scene;
|
|
51241
51260
|
this._viewport = viewport;
|
|
51242
51261
|
this._viewport.onResize.sub(() => this.updateProjection());
|
|
51243
|
-
this.
|
|
51262
|
+
this.defaultForward = settings2.camera.forward;
|
|
51263
|
+
this._orthographic = settings2.camera.orthographic;
|
|
51264
|
+
this.allowedMovement = settings2.camera.allowedMovement;
|
|
51265
|
+
this.allowedRotation = settings2.camera.allowedRotation;
|
|
51266
|
+
this._onValueChanged.dispatch();
|
|
51244
51267
|
this.snap(true).setDistance(-1e3);
|
|
51245
51268
|
this.snap(true).orbitTowards(this._defaultForward);
|
|
51246
51269
|
this.updateProjection();
|
|
@@ -51391,13 +51414,6 @@ let Camera$1 = class Camera2 {
|
|
|
51391
51414
|
return this._target;
|
|
51392
51415
|
}
|
|
51393
51416
|
applySettings(settings2) {
|
|
51394
|
-
this.defaultForward = settings2.camera.forward;
|
|
51395
|
-
this._orthographic = settings2.camera.orthographic;
|
|
51396
|
-
this.allowedMovement = settings2.camera.allowedMovement;
|
|
51397
|
-
this.allowedRotation = settings2.camera.allowedRotation;
|
|
51398
|
-
this.camPerspective.applySettings(settings2);
|
|
51399
|
-
this.camOrthographic.applySettings(settings2);
|
|
51400
|
-
this._onValueChanged.dispatch();
|
|
51401
51417
|
}
|
|
51402
51418
|
/**
|
|
51403
51419
|
* The distance from the camera to the target.
|
|
@@ -51410,8 +51426,7 @@ let Camera$1 = class Camera2 {
|
|
|
51410
51426
|
*/
|
|
51411
51427
|
save() {
|
|
51412
51428
|
this._lerp.cancel();
|
|
51413
|
-
this.
|
|
51414
|
-
this._savedTarget.copy(this._target);
|
|
51429
|
+
this._savedState.save();
|
|
51415
51430
|
}
|
|
51416
51431
|
/**
|
|
51417
51432
|
* Represents whether the camera projection is orthographic.
|