reze-engine 0.55.13 → 0.55.14
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/camera.d.ts +7 -6
- package/dist/camera.d.ts.map +1 -1
- package/dist/camera.js +17 -11
- package/dist/engine.js +8 -8
- package/package.json +1 -1
- package/src/camera.ts +17 -9
- package/src/engine.ts +8 -8
package/dist/camera.d.ts
CHANGED
|
@@ -19,15 +19,16 @@ export declare class Camera {
|
|
|
19
19
|
private canvas;
|
|
20
20
|
private inputLocked;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Where a pan goes while the orbit rides a bone (Engine.setCameraFollow).
|
|
23
23
|
*
|
|
24
24
|
* A pan moves `target`, and the follow rewrites `target` from the bone every
|
|
25
|
-
* frame — so
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* on
|
|
25
|
+
* frame — so a pan into the target went nowhere, and read as the camera
|
|
26
|
+
* stuttering under the pointer. While following, the engine points this at
|
|
27
|
+
* the follow's OFFSET from the bone, and a pan moves that instead: the shot
|
|
28
|
+
* stays on her, and the drag decides where beside her it sits. Null while
|
|
29
|
+
* the target is free.
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
panSink: Vec3 | null;
|
|
31
32
|
private isDragging;
|
|
32
33
|
private mouseButton;
|
|
33
34
|
private lastMousePos;
|
package/dist/camera.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAQ,IAAI,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAyBpD,qBAAa,MAAM;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,IAAI,CA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CAAC,WAAW;IAsBnB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,OAAO;IAYf,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,WAAW;IAuFnB,OAAO,CAAC,UAAU;CA+BnB"}
|
package/dist/camera.js
CHANGED
|
@@ -37,15 +37,16 @@ export class Camera {
|
|
|
37
37
|
this.canvas = null;
|
|
38
38
|
this.inputLocked = false;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Where a pan goes while the orbit rides a bone (Engine.setCameraFollow).
|
|
41
41
|
*
|
|
42
42
|
* A pan moves `target`, and the follow rewrites `target` from the bone every
|
|
43
|
-
* frame — so
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* on
|
|
43
|
+
* frame — so a pan into the target went nowhere, and read as the camera
|
|
44
|
+
* stuttering under the pointer. While following, the engine points this at
|
|
45
|
+
* the follow's OFFSET from the bone, and a pan moves that instead: the shot
|
|
46
|
+
* stays on her, and the drag decides where beside her it sits. Null while
|
|
47
|
+
* the target is free.
|
|
47
48
|
*/
|
|
48
|
-
this.
|
|
49
|
+
this.panSink = null;
|
|
49
50
|
this.isDragging = false;
|
|
50
51
|
this.mouseButton = null; // Track which mouse button is pressed (0 = left, 2 = right)
|
|
51
52
|
this.lastMousePos = { x: 0, y: 0 };
|
|
@@ -311,7 +312,14 @@ export class Camera {
|
|
|
311
312
|
// Vertical movement: drag up pans up (positive up vector)
|
|
312
313
|
const panRight = right.scale(-deltaX * panDistance);
|
|
313
314
|
const panUp = up.scale(deltaY * panDistance);
|
|
314
|
-
//
|
|
315
|
+
// Into the follow's offset while the shot rides a bone — see panSink.
|
|
316
|
+
const sink = this.panSink;
|
|
317
|
+
if (sink) {
|
|
318
|
+
sink.x += panRight.x + panUp.x;
|
|
319
|
+
sink.y += panRight.y + panUp.y;
|
|
320
|
+
sink.z += panRight.z + panUp.z;
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
315
323
|
this.target = this.target.add(panRight).add(panUp);
|
|
316
324
|
}
|
|
317
325
|
/** Far plane grows with zoom-out so big floors / distant geometry stay visible */
|
|
@@ -405,8 +413,7 @@ export class Camera {
|
|
|
405
413
|
const deltaY = e.clientY - this.lastMousePos.y;
|
|
406
414
|
if (this.mouseButton === 2) {
|
|
407
415
|
// Right-click: pan the camera target
|
|
408
|
-
|
|
409
|
-
this.panCamera(deltaX, deltaY);
|
|
416
|
+
this.panCamera(deltaX, deltaY);
|
|
410
417
|
}
|
|
411
418
|
else {
|
|
412
419
|
// Left-click (or default): rotate the camera
|
|
@@ -512,8 +519,7 @@ export class Camera {
|
|
|
512
519
|
if (isPanGesture) {
|
|
513
520
|
// Primary gesture is pan (two-finger drag)
|
|
514
521
|
// Use panning similar to right-click pan
|
|
515
|
-
|
|
516
|
-
this.panCamera(midpointDeltaX, midpointDeltaY);
|
|
522
|
+
this.panCamera(midpointDeltaX, midpointDeltaY);
|
|
517
523
|
}
|
|
518
524
|
// Update tracking values
|
|
519
525
|
this.lastPinchDistance = distance;
|
package/dist/engine.js
CHANGED
|
@@ -6585,23 +6585,23 @@ export class Engine {
|
|
|
6585
6585
|
this.camera.attachControl(this.canvas);
|
|
6586
6586
|
}
|
|
6587
6587
|
setCameraTarget(modelOrVec, boneName, offset) {
|
|
6588
|
-
//
|
|
6589
|
-
//
|
|
6590
|
-
//
|
|
6588
|
+
// panSink tracks the BINDING, on every path that changes it — a target set
|
|
6589
|
+
// after a follow would otherwise still send pans into an offset nothing
|
|
6590
|
+
// reads any more. See Camera.panSink.
|
|
6591
6591
|
if (modelOrVec === null) {
|
|
6592
|
-
this.camera.
|
|
6592
|
+
this.camera.panSink = null;
|
|
6593
6593
|
this.cameraTargetModel = null;
|
|
6594
6594
|
return;
|
|
6595
6595
|
}
|
|
6596
6596
|
if ("x" in modelOrVec && "y" in modelOrVec && "z" in modelOrVec) {
|
|
6597
|
-
this.camera.
|
|
6597
|
+
this.camera.panSink = null;
|
|
6598
6598
|
this.cameraTargetModel = null;
|
|
6599
6599
|
this.camera.target.x = modelOrVec.x;
|
|
6600
6600
|
this.camera.target.y = modelOrVec.y;
|
|
6601
6601
|
this.camera.target.z = modelOrVec.z;
|
|
6602
6602
|
return;
|
|
6603
6603
|
}
|
|
6604
|
-
this.camera.
|
|
6604
|
+
this.camera.panSink = this.cameraTargetOffset;
|
|
6605
6605
|
this.cameraTargetModel = modelOrVec;
|
|
6606
6606
|
this.cameraTargetBoneName = boneName ?? "";
|
|
6607
6607
|
this.cameraTargetOffset.x = offset?.x ?? 0;
|
|
@@ -6611,8 +6611,8 @@ export class Engine {
|
|
|
6611
6611
|
/** Souls-style follow cam: orbit center tracks a model bone each frame. Shorthand for setCameraTarget(model, boneName, offset). */
|
|
6612
6612
|
setCameraFollow(model, boneName, offset, smoothing) {
|
|
6613
6613
|
// Panning sets the very thing the follow overwrites each frame, so it is
|
|
6614
|
-
//
|
|
6615
|
-
this.camera.
|
|
6614
|
+
// goes to the offset for as long as the shot is riding a bone. See Camera.panSink.
|
|
6615
|
+
this.camera.panSink = model !== null ? this.cameraTargetOffset : null;
|
|
6616
6616
|
if (model === null) {
|
|
6617
6617
|
this.cameraTargetModel = null;
|
|
6618
6618
|
return;
|
package/package.json
CHANGED
package/src/camera.ts
CHANGED
|
@@ -45,15 +45,16 @@ export class Camera {
|
|
|
45
45
|
private canvas: HTMLCanvasElement | null = null
|
|
46
46
|
private inputLocked: boolean = false
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Where a pan goes while the orbit rides a bone (Engine.setCameraFollow).
|
|
49
49
|
*
|
|
50
50
|
* A pan moves `target`, and the follow rewrites `target` from the bone every
|
|
51
|
-
* frame — so
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* on
|
|
51
|
+
* frame — so a pan into the target went nowhere, and read as the camera
|
|
52
|
+
* stuttering under the pointer. While following, the engine points this at
|
|
53
|
+
* the follow's OFFSET from the bone, and a pan moves that instead: the shot
|
|
54
|
+
* stays on her, and the drag decides where beside her it sits. Null while
|
|
55
|
+
* the target is free.
|
|
55
56
|
*/
|
|
56
|
-
|
|
57
|
+
panSink: Vec3 | null = null
|
|
57
58
|
private isDragging: boolean = false
|
|
58
59
|
private mouseButton: number | null = null // Track which mouse button is pressed (0 = left, 2 = right)
|
|
59
60
|
private lastMousePos = { x: 0, y: 0 }
|
|
@@ -337,7 +338,14 @@ export class Camera {
|
|
|
337
338
|
const panRight = right.scale(-deltaX * panDistance)
|
|
338
339
|
const panUp = up.scale(deltaY * panDistance)
|
|
339
340
|
|
|
340
|
-
//
|
|
341
|
+
// Into the follow's offset while the shot rides a bone — see panSink.
|
|
342
|
+
const sink = this.panSink
|
|
343
|
+
if (sink) {
|
|
344
|
+
sink.x += panRight.x + panUp.x
|
|
345
|
+
sink.y += panRight.y + panUp.y
|
|
346
|
+
sink.z += panRight.z + panUp.z
|
|
347
|
+
return
|
|
348
|
+
}
|
|
341
349
|
this.target = this.target.add(panRight).add(panUp)
|
|
342
350
|
}
|
|
343
351
|
|
|
@@ -440,7 +448,7 @@ export class Camera {
|
|
|
440
448
|
|
|
441
449
|
if (this.mouseButton === 2) {
|
|
442
450
|
// Right-click: pan the camera target
|
|
443
|
-
|
|
451
|
+
this.panCamera(deltaX, deltaY)
|
|
444
452
|
} else {
|
|
445
453
|
// Left-click (or default): rotate the camera
|
|
446
454
|
this.alpha += deltaX * this.angularSensitivity
|
|
@@ -559,7 +567,7 @@ export class Camera {
|
|
|
559
567
|
if (isPanGesture) {
|
|
560
568
|
// Primary gesture is pan (two-finger drag)
|
|
561
569
|
// Use panning similar to right-click pan
|
|
562
|
-
|
|
570
|
+
this.panCamera(midpointDeltaX, midpointDeltaY)
|
|
563
571
|
}
|
|
564
572
|
|
|
565
573
|
// Update tracking values
|
package/src/engine.ts
CHANGED
|
@@ -7897,23 +7897,23 @@ export class Engine {
|
|
|
7897
7897
|
/** Bind camera orbit center to a model's bone (Souls-style follow cam). Pass null to unbind. */
|
|
7898
7898
|
setCameraTarget(model: Model | null, boneName: string, offset?: Vec3): void
|
|
7899
7899
|
setCameraTarget(modelOrVec: Model | Vec3 | null, boneName?: string, offset?: Vec3): void {
|
|
7900
|
-
//
|
|
7901
|
-
//
|
|
7902
|
-
//
|
|
7900
|
+
// panSink tracks the BINDING, on every path that changes it — a target set
|
|
7901
|
+
// after a follow would otherwise still send pans into an offset nothing
|
|
7902
|
+
// reads any more. See Camera.panSink.
|
|
7903
7903
|
if (modelOrVec === null) {
|
|
7904
|
-
this.camera.
|
|
7904
|
+
this.camera.panSink = null
|
|
7905
7905
|
this.cameraTargetModel = null
|
|
7906
7906
|
return
|
|
7907
7907
|
}
|
|
7908
7908
|
if ("x" in modelOrVec && "y" in modelOrVec && "z" in modelOrVec) {
|
|
7909
|
-
this.camera.
|
|
7909
|
+
this.camera.panSink = null
|
|
7910
7910
|
this.cameraTargetModel = null
|
|
7911
7911
|
this.camera.target.x = modelOrVec.x
|
|
7912
7912
|
this.camera.target.y = modelOrVec.y
|
|
7913
7913
|
this.camera.target.z = modelOrVec.z
|
|
7914
7914
|
return
|
|
7915
7915
|
}
|
|
7916
|
-
this.camera.
|
|
7916
|
+
this.camera.panSink = this.cameraTargetOffset
|
|
7917
7917
|
this.cameraTargetModel = modelOrVec
|
|
7918
7918
|
this.cameraTargetBoneName = boneName ?? ""
|
|
7919
7919
|
this.cameraTargetOffset.x = offset?.x ?? 0
|
|
@@ -7924,8 +7924,8 @@ export class Engine {
|
|
|
7924
7924
|
/** Souls-style follow cam: orbit center tracks a model bone each frame. Shorthand for setCameraTarget(model, boneName, offset). */
|
|
7925
7925
|
setCameraFollow(model: Model | null, boneName?: string, offset?: Vec3, smoothing?: number): void {
|
|
7926
7926
|
// Panning sets the very thing the follow overwrites each frame, so it is
|
|
7927
|
-
//
|
|
7928
|
-
this.camera.
|
|
7927
|
+
// goes to the offset for as long as the shot is riding a bone. See Camera.panSink.
|
|
7928
|
+
this.camera.panSink = model !== null ? this.cameraTargetOffset : null
|
|
7929
7929
|
if (model === null) {
|
|
7930
7930
|
this.cameraTargetModel = null
|
|
7931
7931
|
return
|