minerender 2.1.0-alpha.117 → 2.1.0-alpha.118
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/browser/index.d.mts +11 -2
- package/dist/browser/index.d.ts +11 -2
- package/dist/browser/index.js +43 -6
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +43 -6
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +43 -6
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +11 -2
- package/dist/node/index.d.ts +11 -2
- package/dist/node/index.js +43 -6
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +43 -6
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.mts
CHANGED
|
@@ -2925,11 +2925,12 @@ interface FlyControlsEventMap {
|
|
|
2925
2925
|
type FlyAction = "forward" | "back" | "left" | "right" | "up" | "down" | "sprint";
|
|
2926
2926
|
/**
|
|
2927
2927
|
* Creative-flight camera controls: WASD moves horizontally along the view direction, space and shift
|
|
2928
|
-
* move up and down,
|
|
2928
|
+
* move up and down, R sprints, and the mouse turns the camera (pointer lock, or drag).
|
|
2929
2929
|
*
|
|
2930
2930
|
* Call {@link FlyControls.update} with the elapsed seconds once per frame; the `change` event marks the
|
|
2931
2931
|
* renderer dirty while keys are held. Speeds use scene units (16 per block). The element becomes focusable
|
|
2932
|
-
* and keys apply while it has focus or the pointer is locked.
|
|
2932
|
+
* and keys apply while it has focus or the pointer is locked. A key pressed with Control, Alt, or Command
|
|
2933
|
+
* stays a browser shortcut unless that modifier is bound. The wheel changes the speed, as in vanilla
|
|
2933
2934
|
* spectator mode. Touch input uses the left half of the element as a joystick and the right half for looking.
|
|
2934
2935
|
*/
|
|
2935
2936
|
declare class FlyControls extends Controls<FlyControlsEventMap, Camera> {
|
|
@@ -2961,9 +2962,13 @@ declare class FlyControls extends Controls<FlyControlsEventMap, Camera> {
|
|
|
2961
2962
|
private _position0;
|
|
2962
2963
|
private _quaternion0;
|
|
2963
2964
|
private _dragPointer?;
|
|
2965
|
+
private _dragX;
|
|
2966
|
+
private _dragY;
|
|
2964
2967
|
private _dragMoved;
|
|
2968
|
+
private _dragTravel;
|
|
2965
2969
|
private _joystick?;
|
|
2966
2970
|
private _locked;
|
|
2971
|
+
private _madeFocusable;
|
|
2967
2972
|
private _lastTime?;
|
|
2968
2973
|
private readonly _onKeyDown;
|
|
2969
2974
|
private readonly _onKeyUp;
|
|
@@ -3001,12 +3006,15 @@ declare class FlyControls extends Controls<FlyControlsEventMap, Camera> {
|
|
|
3001
3006
|
/**
|
|
3002
3007
|
* Advances movement by `delta` seconds (measured since the previous call when omitted)
|
|
3003
3008
|
* and dispatches `change` when the camera moved.
|
|
3009
|
+
* A step longer than 0.1 s is applied as 0.1 s.
|
|
3004
3010
|
*/
|
|
3005
3011
|
update(delta?: number): void;
|
|
3006
3012
|
private move;
|
|
3007
3013
|
private notifyChange;
|
|
3008
3014
|
private releaseKeys;
|
|
3009
3015
|
private handleKey;
|
|
3016
|
+
/** A key pressed with Control, Alt, or Command stays a browser shortcut unless that modifier is bound to an action. */
|
|
3017
|
+
private isBrowserShortcut;
|
|
3010
3018
|
private actionFor;
|
|
3011
3019
|
private handlePointerDown;
|
|
3012
3020
|
private onJoystickSide;
|
|
@@ -3062,6 +3070,7 @@ declare class Renderer implements Disposable {
|
|
|
3062
3070
|
/**
|
|
3063
3071
|
* Replaces renderer-owned controls with the selected mode, keeping the camera where it is.
|
|
3064
3072
|
* Switching to orbit controls targets the point the camera looks at, at the previous orbit distance.
|
|
3073
|
+
* The previous controls object is disposed, so its listeners and settings do not carry over.
|
|
3065
3074
|
* Returns the new controls, or undefined when controls were disabled at construction or after disposal.
|
|
3066
3075
|
*/
|
|
3067
3076
|
setControlsMode(mode: ControlsMode): Maybe<RendererControls>;
|
package/dist/node/index.d.ts
CHANGED
|
@@ -2925,11 +2925,12 @@ interface FlyControlsEventMap {
|
|
|
2925
2925
|
type FlyAction = "forward" | "back" | "left" | "right" | "up" | "down" | "sprint";
|
|
2926
2926
|
/**
|
|
2927
2927
|
* Creative-flight camera controls: WASD moves horizontally along the view direction, space and shift
|
|
2928
|
-
* move up and down,
|
|
2928
|
+
* move up and down, R sprints, and the mouse turns the camera (pointer lock, or drag).
|
|
2929
2929
|
*
|
|
2930
2930
|
* Call {@link FlyControls.update} with the elapsed seconds once per frame; the `change` event marks the
|
|
2931
2931
|
* renderer dirty while keys are held. Speeds use scene units (16 per block). The element becomes focusable
|
|
2932
|
-
* and keys apply while it has focus or the pointer is locked.
|
|
2932
|
+
* and keys apply while it has focus or the pointer is locked. A key pressed with Control, Alt, or Command
|
|
2933
|
+
* stays a browser shortcut unless that modifier is bound. The wheel changes the speed, as in vanilla
|
|
2933
2934
|
* spectator mode. Touch input uses the left half of the element as a joystick and the right half for looking.
|
|
2934
2935
|
*/
|
|
2935
2936
|
declare class FlyControls extends Controls<FlyControlsEventMap, Camera> {
|
|
@@ -2961,9 +2962,13 @@ declare class FlyControls extends Controls<FlyControlsEventMap, Camera> {
|
|
|
2961
2962
|
private _position0;
|
|
2962
2963
|
private _quaternion0;
|
|
2963
2964
|
private _dragPointer?;
|
|
2965
|
+
private _dragX;
|
|
2966
|
+
private _dragY;
|
|
2964
2967
|
private _dragMoved;
|
|
2968
|
+
private _dragTravel;
|
|
2965
2969
|
private _joystick?;
|
|
2966
2970
|
private _locked;
|
|
2971
|
+
private _madeFocusable;
|
|
2967
2972
|
private _lastTime?;
|
|
2968
2973
|
private readonly _onKeyDown;
|
|
2969
2974
|
private readonly _onKeyUp;
|
|
@@ -3001,12 +3006,15 @@ declare class FlyControls extends Controls<FlyControlsEventMap, Camera> {
|
|
|
3001
3006
|
/**
|
|
3002
3007
|
* Advances movement by `delta` seconds (measured since the previous call when omitted)
|
|
3003
3008
|
* and dispatches `change` when the camera moved.
|
|
3009
|
+
* A step longer than 0.1 s is applied as 0.1 s.
|
|
3004
3010
|
*/
|
|
3005
3011
|
update(delta?: number): void;
|
|
3006
3012
|
private move;
|
|
3007
3013
|
private notifyChange;
|
|
3008
3014
|
private releaseKeys;
|
|
3009
3015
|
private handleKey;
|
|
3016
|
+
/** A key pressed with Control, Alt, or Command stays a browser shortcut unless that modifier is bound to an action. */
|
|
3017
|
+
private isBrowserShortcut;
|
|
3010
3018
|
private actionFor;
|
|
3011
3019
|
private handlePointerDown;
|
|
3012
3020
|
private onJoystickSide;
|
|
@@ -3062,6 +3070,7 @@ declare class Renderer implements Disposable {
|
|
|
3062
3070
|
/**
|
|
3063
3071
|
* Replaces renderer-owned controls with the selected mode, keeping the camera where it is.
|
|
3064
3072
|
* Switching to orbit controls targets the point the camera looks at, at the previous orbit distance.
|
|
3073
|
+
* The previous controls object is disposed, so its listeners and settings do not carry over.
|
|
3065
3074
|
* Returns the new controls, or undefined when controls were disabled at construction or after disposal.
|
|
3066
3075
|
*/
|
|
3067
3076
|
setControlsMode(mode: ControlsMode): Maybe<RendererControls>;
|
package/dist/node/index.js
CHANGED
|
@@ -13441,6 +13441,8 @@ var import_three35 = require("three");
|
|
|
13441
13441
|
var VANILLA_FLY_SPEED = 10.89;
|
|
13442
13442
|
var PITCH_LIMIT = Math.PI / 2;
|
|
13443
13443
|
var MOVE_EPSILON = 1e-6;
|
|
13444
|
+
var MAX_STEP_SECONDS = 0.1;
|
|
13445
|
+
var CLICK_SLOP_PIXELS = 4;
|
|
13444
13446
|
var _euler = new import_three35.Euler(0, 0, 0, "YXZ");
|
|
13445
13447
|
var _forward = new import_three35.Vector3();
|
|
13446
13448
|
var _right = new import_three35.Vector3();
|
|
@@ -13475,7 +13477,8 @@ var FlyControls = class extends import_three35.Controls {
|
|
|
13475
13477
|
right: ["KeyD", "ArrowRight"],
|
|
13476
13478
|
up: ["Space"],
|
|
13477
13479
|
down: ["ShiftLeft", "ShiftRight"],
|
|
13478
|
-
|
|
13480
|
+
// Not Control: Ctrl+W closes the browser tab on Windows and Linux, and a page cannot block it.
|
|
13481
|
+
sprint: ["KeyR"]
|
|
13479
13482
|
};
|
|
13480
13483
|
this._pressed = /* @__PURE__ */ new Set();
|
|
13481
13484
|
this._velocity = new import_three35.Vector3();
|
|
@@ -13483,8 +13486,12 @@ var FlyControls = class extends import_three35.Controls {
|
|
|
13483
13486
|
this._lastQuaternion = new import_three35.Quaternion();
|
|
13484
13487
|
this._position0 = new import_three35.Vector3();
|
|
13485
13488
|
this._quaternion0 = new import_three35.Quaternion();
|
|
13489
|
+
this._dragX = 0;
|
|
13490
|
+
this._dragY = 0;
|
|
13486
13491
|
this._dragMoved = false;
|
|
13492
|
+
this._dragTravel = 0;
|
|
13487
13493
|
this._locked = false;
|
|
13494
|
+
this._madeFocusable = false;
|
|
13488
13495
|
this._onKeyDown = (event) => this.handleKey(event, true);
|
|
13489
13496
|
this._onKeyUp = (event) => this.handleKey(event, false);
|
|
13490
13497
|
this._onPointerDown = (event) => this.handlePointerDown(event);
|
|
@@ -13514,7 +13521,10 @@ var FlyControls = class extends import_three35.Controls {
|
|
|
13514
13521
|
element.addEventListener("wheel", this._onWheel, { passive: false });
|
|
13515
13522
|
element.addEventListener("blur", this._onBlur);
|
|
13516
13523
|
element.style.touchAction = "none";
|
|
13517
|
-
if (element.tabIndex < 0)
|
|
13524
|
+
if (element.tabIndex < 0) {
|
|
13525
|
+
element.tabIndex = 0;
|
|
13526
|
+
this._madeFocusable = true;
|
|
13527
|
+
}
|
|
13518
13528
|
}
|
|
13519
13529
|
disconnect() {
|
|
13520
13530
|
const element = this.domElement;
|
|
@@ -13532,6 +13542,10 @@ var FlyControls = class extends import_three35.Controls {
|
|
|
13532
13542
|
element.removeEventListener("wheel", this._onWheel);
|
|
13533
13543
|
element.removeEventListener("blur", this._onBlur);
|
|
13534
13544
|
element.style.touchAction = "auto";
|
|
13545
|
+
if (this._madeFocusable) {
|
|
13546
|
+
element.removeAttribute("tabindex");
|
|
13547
|
+
this._madeFocusable = false;
|
|
13548
|
+
}
|
|
13535
13549
|
this.unlock();
|
|
13536
13550
|
this._locked = false;
|
|
13537
13551
|
this.releaseKeys();
|
|
@@ -13602,6 +13616,7 @@ var FlyControls = class extends import_three35.Controls {
|
|
|
13602
13616
|
/**
|
|
13603
13617
|
* Advances movement by `delta` seconds (measured since the previous call when omitted)
|
|
13604
13618
|
* and dispatches `change` when the camera moved.
|
|
13619
|
+
* A step longer than 0.1 s is applied as 0.1 s.
|
|
13605
13620
|
*/
|
|
13606
13621
|
update(delta) {
|
|
13607
13622
|
if (delta === void 0) {
|
|
@@ -13613,7 +13628,7 @@ var FlyControls = class extends import_three35.Controls {
|
|
|
13613
13628
|
this._velocity.set(0, 0, 0);
|
|
13614
13629
|
return;
|
|
13615
13630
|
}
|
|
13616
|
-
if (delta > 0) this.move(delta);
|
|
13631
|
+
if (delta > 0) this.move(Math.min(delta, MAX_STEP_SECONDS));
|
|
13617
13632
|
this.notifyChange();
|
|
13618
13633
|
}
|
|
13619
13634
|
move(delta) {
|
|
@@ -13660,15 +13675,21 @@ var FlyControls = class extends import_three35.Controls {
|
|
|
13660
13675
|
this._pressed.clear();
|
|
13661
13676
|
}
|
|
13662
13677
|
handleKey(event, down) {
|
|
13678
|
+
if (event.code === "MetaLeft" || event.code === "MetaRight") this.releaseKeys();
|
|
13663
13679
|
const action = this.actionFor(event.code);
|
|
13664
13680
|
if (!action) return;
|
|
13665
13681
|
const ownsInput = this.enabled && (this._locked || event.target === this.domElement);
|
|
13666
|
-
if (down && !ownsInput) return;
|
|
13682
|
+
if (down && (!ownsInput || this.isBrowserShortcut(event))) return;
|
|
13667
13683
|
const pressed = this._pressed.has(action);
|
|
13668
13684
|
if (down) this._pressed.add(action);
|
|
13669
13685
|
else this._pressed.delete(action);
|
|
13670
13686
|
if (ownsInput || this.enabled && pressed) event.preventDefault();
|
|
13671
13687
|
}
|
|
13688
|
+
/** A key pressed with Control, Alt, or Command stays a browser shortcut unless that modifier is bound to an action. */
|
|
13689
|
+
isBrowserShortcut(event) {
|
|
13690
|
+
const bound = (modifier) => Object.values(this.keys).some((codes) => codes.some((code) => code.startsWith(modifier)));
|
|
13691
|
+
return event.ctrlKey && !bound("Control") || event.altKey && !bound("Alt") || event.metaKey && !bound("Meta");
|
|
13692
|
+
}
|
|
13672
13693
|
actionFor(code) {
|
|
13673
13694
|
for (const action in this.keys) {
|
|
13674
13695
|
if (this.keys[action].includes(code)) return action;
|
|
@@ -13688,7 +13709,10 @@ var FlyControls = class extends import_three35.Controls {
|
|
|
13688
13709
|
if (this._dragPointer !== void 0) return;
|
|
13689
13710
|
if (event.pointerType === "mouse" && event.button !== 0 && event.button !== 2) return;
|
|
13690
13711
|
this._dragPointer = event.pointerId;
|
|
13712
|
+
this._dragX = event.clientX;
|
|
13713
|
+
this._dragY = event.clientY;
|
|
13691
13714
|
this._dragMoved = false;
|
|
13715
|
+
this._dragTravel = 0;
|
|
13692
13716
|
element.setPointerCapture?.(event.pointerId);
|
|
13693
13717
|
}
|
|
13694
13718
|
onJoystickSide(event) {
|
|
@@ -13704,8 +13728,20 @@ var FlyControls = class extends import_three35.Controls {
|
|
|
13704
13728
|
return;
|
|
13705
13729
|
}
|
|
13706
13730
|
if (!this._locked && event.pointerId !== this._dragPointer) return;
|
|
13707
|
-
|
|
13708
|
-
|
|
13731
|
+
let dx, dy;
|
|
13732
|
+
if (this._locked) {
|
|
13733
|
+
dx = event.movementX ?? 0;
|
|
13734
|
+
dy = event.movementY ?? 0;
|
|
13735
|
+
} else {
|
|
13736
|
+
dx = event.clientX - this._dragX;
|
|
13737
|
+
dy = event.clientY - this._dragY;
|
|
13738
|
+
this._dragX = event.clientX;
|
|
13739
|
+
this._dragY = event.clientY;
|
|
13740
|
+
if (!this._dragMoved) {
|
|
13741
|
+
this._dragTravel += Math.hypot(dx, dy);
|
|
13742
|
+
if (this._dragTravel <= CLICK_SLOP_PIXELS) return;
|
|
13743
|
+
}
|
|
13744
|
+
}
|
|
13709
13745
|
if (!dx && !dy) return;
|
|
13710
13746
|
this._dragMoved = true;
|
|
13711
13747
|
this.turn(dx, dy);
|
|
@@ -15657,6 +15693,7 @@ var Renderer = class _Renderer {
|
|
|
15657
15693
|
/**
|
|
15658
15694
|
* Replaces renderer-owned controls with the selected mode, keeping the camera where it is.
|
|
15659
15695
|
* Switching to orbit controls targets the point the camera looks at, at the previous orbit distance.
|
|
15696
|
+
* The previous controls object is disposed, so its listeners and settings do not carry over.
|
|
15660
15697
|
* Returns the new controls, or undefined when controls were disabled at construction or after disposal.
|
|
15661
15698
|
*/
|
|
15662
15699
|
setControlsMode(mode) {
|