@luma.gl/engine 9.4.0-beta.2 → 9.4.0-beta.3
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/controls/orbit-controls.d.ts +5 -2
- package/dist/controls/orbit-controls.d.ts.map +1 -1
- package/dist/controls/orbit-controls.js +70 -20
- package/dist/controls/orbit-controls.js.map +1 -1
- package/dist/dist.dev.js +68 -19
- package/dist/dist.min.js +4 -4
- package/dist/index.cjs +64 -19
- package/dist/index.cjs.map +1 -1
- package/package.json +2 -2
- package/src/controls/orbit-controls.ts +81 -20
package/dist/index.cjs
CHANGED
|
@@ -5383,8 +5383,9 @@ var OrbitControls = class {
|
|
|
5383
5383
|
pitch;
|
|
5384
5384
|
distance;
|
|
5385
5385
|
dragging = false;
|
|
5386
|
-
|
|
5386
|
+
activePointers = /* @__PURE__ */ new Map();
|
|
5387
5387
|
lastPointer = [0, 0];
|
|
5388
|
+
previousPinchDistance = null;
|
|
5388
5389
|
previousTimeMilliseconds = null;
|
|
5389
5390
|
previousCursor;
|
|
5390
5391
|
previousTouchAction;
|
|
@@ -5457,57 +5458,101 @@ var OrbitControls = class {
|
|
|
5457
5458
|
this.canvas.removeEventListener("pointerup", this.handlePointerUp);
|
|
5458
5459
|
this.canvas.removeEventListener("pointercancel", this.handlePointerUp);
|
|
5459
5460
|
this.canvas.removeEventListener("wheel", this.handleWheel);
|
|
5460
|
-
|
|
5461
|
-
this.canvas.releasePointerCapture(this.pointerId);
|
|
5462
|
-
}
|
|
5461
|
+
this.endPointerInteraction();
|
|
5463
5462
|
this.canvas.style.cursor = this.previousCursor;
|
|
5464
5463
|
this.canvas.style.touchAction = this.previousTouchAction;
|
|
5465
5464
|
}
|
|
5466
5465
|
handlePointerDown = (event) => {
|
|
5467
5466
|
var _a, _b;
|
|
5468
|
-
if (!this.props.enabled || event.button !== 0) {
|
|
5467
|
+
if (!this.props.enabled || event.button !== 0 || this.activePointers.has(event.pointerId) || this.activePointers.size >= 2 || this.activePointers.size > 0 && event.pointerType !== "touch") {
|
|
5469
5468
|
return;
|
|
5470
5469
|
}
|
|
5471
|
-
|
|
5470
|
+
if (this.activePointers.size === 0) {
|
|
5471
|
+
(_b = (_a = this.props).onInteractionStart) == null ? void 0 : _b.call(_a);
|
|
5472
|
+
}
|
|
5472
5473
|
this.dragging = true;
|
|
5473
|
-
this.pointerId
|
|
5474
|
-
this.
|
|
5474
|
+
this.activePointers.set(event.pointerId, [event.clientX, event.clientY]);
|
|
5475
|
+
if (this.activePointers.size === 1) {
|
|
5476
|
+
this.lastPointer = [event.clientX, event.clientY];
|
|
5477
|
+
} else {
|
|
5478
|
+
const { center, distance } = this.getMultiPointerState();
|
|
5479
|
+
this.lastPointer = center;
|
|
5480
|
+
this.previousPinchDistance = distance;
|
|
5481
|
+
}
|
|
5475
5482
|
this.canvas.setPointerCapture(event.pointerId);
|
|
5476
5483
|
this.canvas.style.cursor = "grabbing";
|
|
5477
5484
|
};
|
|
5478
5485
|
handlePointerMove = (event) => {
|
|
5479
|
-
if (!this.props.enabled || !this.dragging || event.pointerId
|
|
5486
|
+
if (!this.props.enabled || !this.dragging || !this.activePointers.has(event.pointerId)) {
|
|
5487
|
+
return;
|
|
5488
|
+
}
|
|
5489
|
+
this.activePointers.set(event.pointerId, [event.clientX, event.clientY]);
|
|
5490
|
+
if (this.activePointers.size > 1) {
|
|
5491
|
+
const { center, distance } = this.getMultiPointerState();
|
|
5492
|
+
if (this.props.enablePan) {
|
|
5493
|
+
this.panTarget(center[0] - this.lastPointer[0], center[1] - this.lastPointer[1]);
|
|
5494
|
+
}
|
|
5495
|
+
if (this.props.enableZoom && this.previousPinchDistance && distance > 0) {
|
|
5496
|
+
this.distance = clampNumber(this.distance * this.previousPinchDistance / distance, this.props.minDistance, this.props.maxDistance);
|
|
5497
|
+
}
|
|
5498
|
+
this.lastPointer = center;
|
|
5499
|
+
this.previousPinchDistance = distance;
|
|
5480
5500
|
return;
|
|
5481
5501
|
}
|
|
5482
5502
|
const deltaX = event.clientX - this.lastPointer[0];
|
|
5483
5503
|
const deltaY = event.clientY - this.lastPointer[1];
|
|
5484
5504
|
this.lastPointer = [event.clientX, event.clientY];
|
|
5485
5505
|
if (this.props.enablePan && event.shiftKey) {
|
|
5486
|
-
|
|
5487
|
-
this.props.target = [
|
|
5488
|
-
this.props.target[0] - Math.cos(this.yaw) * deltaX * panScale,
|
|
5489
|
-
this.props.target[1] + deltaY * panScale,
|
|
5490
|
-
this.props.target[2] + Math.sin(this.yaw) * deltaX * panScale
|
|
5491
|
-
];
|
|
5506
|
+
this.panTarget(deltaX, deltaY);
|
|
5492
5507
|
} else {
|
|
5493
5508
|
this.yaw -= deltaX * this.props.rotateSpeed;
|
|
5494
5509
|
this.pitch = clampNumber(this.pitch - deltaY * (this.props.pitchSpeed ?? this.props.rotateSpeed), this.props.minPitch, this.props.maxPitch);
|
|
5495
5510
|
}
|
|
5496
5511
|
};
|
|
5497
5512
|
handlePointerUp = (event) => {
|
|
5498
|
-
if (event.pointerId
|
|
5513
|
+
if (!this.activePointers.has(event.pointerId)) {
|
|
5514
|
+
return;
|
|
5515
|
+
}
|
|
5516
|
+
if (this.canvas.hasPointerCapture(event.pointerId)) {
|
|
5517
|
+
this.canvas.releasePointerCapture(event.pointerId);
|
|
5518
|
+
}
|
|
5519
|
+
this.activePointers.delete(event.pointerId);
|
|
5520
|
+
this.previousPinchDistance = null;
|
|
5521
|
+
const remainingPointer = this.activePointers.entries().next().value;
|
|
5522
|
+
if (remainingPointer) {
|
|
5523
|
+
this.lastPointer = remainingPointer[1];
|
|
5499
5524
|
return;
|
|
5500
5525
|
}
|
|
5501
5526
|
this.endPointerInteraction();
|
|
5502
5527
|
};
|
|
5503
5528
|
endPointerInteraction() {
|
|
5504
5529
|
this.dragging = false;
|
|
5505
|
-
|
|
5506
|
-
this.canvas.
|
|
5530
|
+
for (const pointerId of this.activePointers.keys()) {
|
|
5531
|
+
if (this.canvas.hasPointerCapture(pointerId)) {
|
|
5532
|
+
this.canvas.releasePointerCapture(pointerId);
|
|
5533
|
+
}
|
|
5507
5534
|
}
|
|
5508
|
-
this.
|
|
5535
|
+
this.activePointers.clear();
|
|
5536
|
+
this.previousPinchDistance = null;
|
|
5509
5537
|
this.canvas.style.cursor = "grab";
|
|
5510
5538
|
}
|
|
5539
|
+
getMultiPointerState() {
|
|
5540
|
+
const [firstPointer, secondPointer] = this.activePointers.values();
|
|
5541
|
+
const deltaX = secondPointer[0] - firstPointer[0];
|
|
5542
|
+
const deltaY = secondPointer[1] - firstPointer[1];
|
|
5543
|
+
return {
|
|
5544
|
+
center: [(firstPointer[0] + secondPointer[0]) / 2, (firstPointer[1] + secondPointer[1]) / 2],
|
|
5545
|
+
distance: Math.hypot(deltaX, deltaY)
|
|
5546
|
+
};
|
|
5547
|
+
}
|
|
5548
|
+
panTarget(deltaX, deltaY) {
|
|
5549
|
+
const panScale = this.distance * this.props.panSpeed;
|
|
5550
|
+
this.props.target = [
|
|
5551
|
+
this.props.target[0] - Math.cos(this.yaw) * deltaX * panScale,
|
|
5552
|
+
this.props.target[1] + deltaY * panScale,
|
|
5553
|
+
this.props.target[2] + Math.sin(this.yaw) * deltaX * panScale
|
|
5554
|
+
];
|
|
5555
|
+
}
|
|
5511
5556
|
handleWheel = (event) => {
|
|
5512
5557
|
var _a, _b;
|
|
5513
5558
|
if (!this.props.enabled || !this.props.enableZoom) {
|