@vived/app 4.13.0 → 4.14.1
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/lib/Components/Babylon/Mocks/MockBabylonRenderingUC.d.ts +2 -3
- package/lib/Components/Babylon/Mocks/MockBabylonRenderingUC.js +3 -3
- package/lib/Components/Babylon/Mocks/MockPixelToSceneRayUC.d.ts +1 -1
- package/lib/Components/Babylon/Mocks/MockPixelToSceneRayUC.js +3 -3
- package/lib/Components/Babylon/Mocks/MockSceneRayPickUC.d.ts +1 -1
- package/lib/Components/Babylon/Mocks/MockSceneRayPickUC.js +3 -3
- package/lib/Components/Babylon/UC/BabylonRenderingUC.d.ts +0 -9
- package/lib/Components/Babylon/UC/BabylonRenderingUC.js +1 -14
- package/lib/Components/Babylon/UC/PixelToSceneRayUC.d.ts +0 -7
- package/lib/Components/Babylon/UC/PixelToSceneRayUC.js +1 -12
- package/lib/Components/Babylon/UC/ScenePixelPickUC.d.ts +0 -7
- package/lib/Components/Babylon/UC/ScenePixelPickUC.js +1 -12
- package/lib/Components/Babylon/UC/SceneRayPickUC.d.ts +0 -7
- package/lib/Components/Babylon/UC/SceneRayPickUC.js +1 -12
- package/lib/Components/Babylon/index.d.ts +1 -0
- package/lib/Components/Babylon/index.js +1 -0
- package/lib/Components/Question/Entities/QuestionAnswerEntity.d.ts +0 -1
- package/lib/Components/Question/Entities/QuestionAnswerEntity.js +2 -6
- package/lib/Components/Transform3D/Controllers/Mouse/DragScaleTransformMC.d.ts +12 -0
- package/lib/Components/Transform3D/Controllers/Mouse/DragScaleTransformMC.js +49 -0
- package/lib/Components/Transform3D/Controllers/Mouse/PanTransformMC.d.ts +12 -0
- package/lib/Components/Transform3D/Controllers/Mouse/PanTransformMC.js +48 -0
- package/lib/Components/Transform3D/Controllers/Mouse/RollScaleTransformMC.d.ts +9 -0
- package/lib/Components/Transform3D/Controllers/Mouse/RollScaleTransformMC.js +37 -0
- package/lib/Components/Transform3D/Controllers/Mouse/index.d.ts +3 -0
- package/lib/Components/Transform3D/Controllers/Mouse/index.js +15 -0
- package/lib/Components/Transform3D/Controllers/Stylus/PanScaleTransformSC.d.ts +13 -0
- package/lib/Components/Transform3D/Controllers/Stylus/PanScaleTransformSC.js +54 -0
- package/lib/Components/Transform3D/Controllers/Stylus/PanTransformSC.d.ts +13 -0
- package/lib/Components/Transform3D/Controllers/Stylus/PanTransformSC.js +54 -0
- package/lib/Components/Transform3D/Controllers/Stylus/ScaleTransformSC.d.ts +13 -0
- package/lib/Components/Transform3D/Controllers/Stylus/ScaleTransformSC.js +54 -0
- package/lib/Components/Transform3D/Controllers/Stylus/index.d.ts +3 -0
- package/lib/Components/Transform3D/Controllers/Stylus/index.js +15 -0
- package/lib/Components/Transform3D/Controllers/Touch/DragScaleTransformTC.d.ts +13 -0
- package/lib/Components/Transform3D/Controllers/Touch/DragScaleTransformTC.js +60 -0
- package/lib/Components/Transform3D/Controllers/Touch/PanTransformTC.d.ts +12 -0
- package/lib/Components/Transform3D/Controllers/Touch/PanTransformTC.js +52 -0
- package/lib/Components/Transform3D/Controllers/Touch/PinchTransformTC.d.ts +13 -0
- package/lib/Components/Transform3D/Controllers/Touch/PinchTransformTC.js +55 -0
- package/lib/Components/Transform3D/Controllers/Touch/index.d.ts +3 -0
- package/lib/Components/Transform3D/Controllers/Touch/index.js +15 -0
- package/lib/Components/Transform3D/Controllers/index.d.ts +3 -0
- package/lib/Components/Transform3D/Controllers/index.js +15 -0
- package/lib/Components/Transform3D/Mocks/MockBumpTransformScaleAboutPixelPoint.d.ts +14 -0
- package/lib/Components/Transform3D/Mocks/MockBumpTransformScaleAboutPixelPoint.js +14 -0
- package/lib/Components/Transform3D/Mocks/MockPanTransformUC.d.ts +18 -0
- package/lib/Components/Transform3D/Mocks/MockPanTransformUC.js +18 -0
- package/lib/Components/Transform3D/Mocks/MockPinchTransformUC.d.ts +15 -0
- package/lib/Components/Transform3D/Mocks/MockPinchTransformUC.js +15 -0
- package/lib/Components/Transform3D/Mocks/MockRayPanScaleTransformUC.d.ts +19 -0
- package/lib/Components/Transform3D/Mocks/MockRayPanScaleTransformUC.js +15 -0
- package/lib/Components/Transform3D/Mocks/MockRayScaleTransform.d.ts +18 -0
- package/lib/Components/Transform3D/Mocks/MockRayScaleTransform.js +18 -0
- package/lib/Components/Transform3D/Mocks/index.d.ts +5 -0
- package/lib/Components/Transform3D/Mocks/index.js +17 -0
- package/lib/Components/Transform3D/UC/BumpTransformScaleAboutPixelPoint.d.ts +13 -0
- package/lib/Components/Transform3D/UC/BumpTransformScaleAboutPixelPoint.js +73 -0
- package/lib/Components/Transform3D/UC/PanTransformUC.d.ts +18 -0
- package/lib/Components/Transform3D/UC/PanTransformUC.js +94 -0
- package/lib/Components/Transform3D/UC/PinchTransform.d.ts +14 -0
- package/lib/Components/Transform3D/UC/PinchTransform.js +95 -0
- package/lib/Components/Transform3D/UC/RayPanScaleTransform.d.ts +18 -0
- package/lib/Components/Transform3D/UC/RayPanScaleTransform.js +113 -0
- package/lib/Components/Transform3D/UC/ScaleTransform.d.ts +17 -0
- package/lib/Components/Transform3D/UC/ScaleTransform.js +108 -0
- package/lib/Components/Transform3D/UC/index.d.ts +6 -0
- package/lib/Components/Transform3D/UC/index.js +6 -0
- package/lib/Components/Transform3D/index.d.ts +2 -0
- package/lib/Components/Transform3D/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePanTransformUC = exports.PanTransformUC = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
const ValueObjects_1 = require("../../../ValueObjects");
|
|
6
|
+
const Babylon_1 = require("../../Babylon");
|
|
7
|
+
const Dispatcher_1 = require("../../Dispatcher");
|
|
8
|
+
const Entities_1 = require("../Entities");
|
|
9
|
+
class PanTransformUC extends AppObject_1.AppObjectUC {
|
|
10
|
+
}
|
|
11
|
+
exports.PanTransformUC = PanTransformUC;
|
|
12
|
+
PanTransformUC.type = "PanTransformUC";
|
|
13
|
+
function makePanTransformUC(appObject) {
|
|
14
|
+
return new PanTransformUCImp(appObject);
|
|
15
|
+
}
|
|
16
|
+
exports.makePanTransformUC = makePanTransformUC;
|
|
17
|
+
class PanTransformUCImp extends PanTransformUC {
|
|
18
|
+
constructor(appObject) {
|
|
19
|
+
super(appObject, PanTransformUC.type);
|
|
20
|
+
this.enabled = true;
|
|
21
|
+
this.panPlane = ValueObjects_1.ParametricPlane.XY();
|
|
22
|
+
this.dispatchStateChangeOnComplete = true;
|
|
23
|
+
this.pickOffset = ValueObjects_1.Vector3.Zero();
|
|
24
|
+
this.initialPosition = ValueObjects_1.Vector3.Zero();
|
|
25
|
+
this.hasBeenInitialized = false;
|
|
26
|
+
this.initializePixel = (initialPixelPos) => {
|
|
27
|
+
const ray = Babylon_1.pixelToSceneRay(initialPixelPos, this.appObjects);
|
|
28
|
+
this.initializeRay(ray);
|
|
29
|
+
};
|
|
30
|
+
this.updatePixel = (pixelPosition) => {
|
|
31
|
+
if (!this.enabled)
|
|
32
|
+
return;
|
|
33
|
+
const pickRay = Babylon_1.pixelToSceneRay(pixelPosition, this.appObjects);
|
|
34
|
+
this.updateRay(pickRay);
|
|
35
|
+
};
|
|
36
|
+
this.initializeRay = (ray) => {
|
|
37
|
+
var _a;
|
|
38
|
+
if (!this.transformNode)
|
|
39
|
+
return;
|
|
40
|
+
const pick = (_a = this.panPlane.intersectLine(ray)) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero();
|
|
41
|
+
const rootPos = this.transformNode.worldPosition;
|
|
42
|
+
this.pickOffset = ValueObjects_1.Vector3.Subtract(rootPos, pick);
|
|
43
|
+
this.hasBeenInitialized = true;
|
|
44
|
+
this.initialPosition = this.transformNode.worldPosition;
|
|
45
|
+
};
|
|
46
|
+
this.updateRay = (ray) => {
|
|
47
|
+
var _a;
|
|
48
|
+
if (!this.transformNode)
|
|
49
|
+
return;
|
|
50
|
+
if (!this.hasBeenInitialized)
|
|
51
|
+
return;
|
|
52
|
+
if (!this.enabled)
|
|
53
|
+
return;
|
|
54
|
+
const pick = (_a = this.panPlane.intersectLine(ray)) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero();
|
|
55
|
+
let wPos = ValueObjects_1.Vector3.Add(pick, this.pickOffset);
|
|
56
|
+
if (this.minX !== undefined && wPos.x < this.minX) {
|
|
57
|
+
wPos = new ValueObjects_1.Vector3(this.minX, wPos.y, wPos.z);
|
|
58
|
+
}
|
|
59
|
+
if (this.maxX !== undefined && wPos.x > this.maxX) {
|
|
60
|
+
wPos = new ValueObjects_1.Vector3(this.maxX, wPos.y, wPos.z);
|
|
61
|
+
}
|
|
62
|
+
if (this.minY !== undefined && wPos.y < this.minY) {
|
|
63
|
+
wPos = new ValueObjects_1.Vector3(wPos.x, this.minY, wPos.z);
|
|
64
|
+
}
|
|
65
|
+
if (this.maxY !== undefined && wPos.y > this.maxY) {
|
|
66
|
+
wPos = new ValueObjects_1.Vector3(wPos.x, this.maxY, wPos.z);
|
|
67
|
+
}
|
|
68
|
+
this.transformNode.worldPosition = wPos;
|
|
69
|
+
};
|
|
70
|
+
this.finish = () => {
|
|
71
|
+
var _a;
|
|
72
|
+
if (!this.transformNode)
|
|
73
|
+
return;
|
|
74
|
+
if (!this.hasBeenInitialized)
|
|
75
|
+
return;
|
|
76
|
+
if (!this.enabled)
|
|
77
|
+
return;
|
|
78
|
+
this.hasBeenInitialized = false;
|
|
79
|
+
if (ValueObjects_1.Vector3.Equal(this.initialPosition, (_a = this.transformNode) === null || _a === void 0 ? void 0 : _a.worldPosition))
|
|
80
|
+
return;
|
|
81
|
+
if (this.dispatchStateChangeOnComplete) {
|
|
82
|
+
Dispatcher_1.dispatchStateChange(this.appObjects);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
this.cancelPan = () => {
|
|
86
|
+
this.hasBeenInitialized = false;
|
|
87
|
+
};
|
|
88
|
+
this.transformNode = appObject.getComponent(Entities_1.Transform3D.type);
|
|
89
|
+
if (!this.transformNode) {
|
|
90
|
+
this.error("App Object does not have a Transform3D");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AppObject, AppObjectUC } from "../../../AppObject";
|
|
2
|
+
import { ParametricPlane, Vector2 } from "../../../ValueObjects";
|
|
3
|
+
export declare abstract class PinchTransformUC extends AppObjectUC {
|
|
4
|
+
static readonly type = "PinchTransformUC";
|
|
5
|
+
abstract sensitivity: number;
|
|
6
|
+
abstract enabled: boolean;
|
|
7
|
+
abstract minScale?: number;
|
|
8
|
+
abstract maxScale?: number;
|
|
9
|
+
abstract pickPlane?: ParametricPlane;
|
|
10
|
+
abstract doPinch: (touchPos1: Vector2, touchPos2: Vector2) => void;
|
|
11
|
+
abstract initializePinch: (touchPos1: Vector2, touchPos2: Vector2) => void;
|
|
12
|
+
abstract finishPinch: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function makePinchTransformUC(appObject: AppObject): PinchTransformUC;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePinchTransformUC = exports.PinchTransformUC = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
const ValueObjects_1 = require("../../../ValueObjects");
|
|
6
|
+
const Babylon_1 = require("../../Babylon");
|
|
7
|
+
const Dispatcher_1 = require("../../Dispatcher");
|
|
8
|
+
const Entities_1 = require("../Entities");
|
|
9
|
+
class PinchTransformUC extends AppObject_1.AppObjectUC {
|
|
10
|
+
}
|
|
11
|
+
exports.PinchTransformUC = PinchTransformUC;
|
|
12
|
+
PinchTransformUC.type = "PinchTransformUC";
|
|
13
|
+
function makePinchTransformUC(appObject) {
|
|
14
|
+
return new PinchTransformUCImp(appObject);
|
|
15
|
+
}
|
|
16
|
+
exports.makePinchTransformUC = makePinchTransformUC;
|
|
17
|
+
class PinchTransformUCImp extends PinchTransformUC {
|
|
18
|
+
constructor(appObject) {
|
|
19
|
+
super(appObject, PinchTransformUC.type);
|
|
20
|
+
this.sensitivity = 0.01;
|
|
21
|
+
this.enabled = true;
|
|
22
|
+
this.previousDistanceBetweenTouches = 0;
|
|
23
|
+
this._panPlane = ValueObjects_1.ParametricPlane.XY();
|
|
24
|
+
this.pickOffset = ValueObjects_1.Vector3.Zero();
|
|
25
|
+
this.initialScale = 0;
|
|
26
|
+
this.initializePinch = (touchPos1, touchPos2) => {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
if (!this.transform)
|
|
29
|
+
return;
|
|
30
|
+
this.previousDistanceBetweenTouches = this.getTouchDistance(touchPos1, touchPos2);
|
|
31
|
+
const touchCenter = this.getTouchCenter(touchPos1, touchPos2);
|
|
32
|
+
const scenePick = Babylon_1.scenePixelPick(touchCenter, this.appObjects);
|
|
33
|
+
if (this.pickPlane) {
|
|
34
|
+
this._panPlane = this.pickPlane;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const pickPoint = (_a = scenePick === null || scenePick === void 0 ? void 0 : scenePick.worldPickPoint) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero();
|
|
38
|
+
const pickPlaneDirection = ValueObjects_1.Vector3.Backward();
|
|
39
|
+
this._panPlane = ValueObjects_1.ParametricPlane.FromPointNormal(pickPoint, pickPlaneDirection);
|
|
40
|
+
}
|
|
41
|
+
const pickRay = Babylon_1.pixelToSceneRay(touchCenter, this.appObjects);
|
|
42
|
+
const planePick = (_b = this._panPlane.intersectLine(pickRay)) !== null && _b !== void 0 ? _b : ValueObjects_1.Vector3.Zero();
|
|
43
|
+
this.pickOffset = this.transform.worldPointToLocal(planePick);
|
|
44
|
+
this.initialScale = this.transform.worldScale.x;
|
|
45
|
+
};
|
|
46
|
+
this.doPinch = (touchPos1, touchPos2) => {
|
|
47
|
+
var _a;
|
|
48
|
+
if (!this.enabled)
|
|
49
|
+
return;
|
|
50
|
+
if (!this.transform)
|
|
51
|
+
return;
|
|
52
|
+
const currentTouchDist = this.getTouchDistance(touchPos1, touchPos2);
|
|
53
|
+
const touchDelta = currentTouchDist - this.previousDistanceBetweenTouches;
|
|
54
|
+
const currentScale = this.transform.worldScale.x;
|
|
55
|
+
const scaleDelta = touchDelta * this.sensitivity * currentScale;
|
|
56
|
+
let newScale = currentScale + scaleDelta;
|
|
57
|
+
if (this.minScale !== undefined && newScale < this.minScale) {
|
|
58
|
+
newScale = this.minScale;
|
|
59
|
+
}
|
|
60
|
+
if (this.maxScale !== undefined && newScale > this.maxScale) {
|
|
61
|
+
newScale = this.maxScale;
|
|
62
|
+
}
|
|
63
|
+
this.transform.worldScale = new ValueObjects_1.Vector3(newScale, newScale, newScale);
|
|
64
|
+
const touchCenter = this.getTouchCenter(touchPos1, touchPos2);
|
|
65
|
+
const pickRay = Babylon_1.pixelToSceneRay(touchCenter, this.appObjects);
|
|
66
|
+
const planePick = (_a = this._panPlane.intersectLine(pickRay)) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero();
|
|
67
|
+
const globalOffset = this.transform.localPointToWorld(this.pickOffset);
|
|
68
|
+
const delta = ValueObjects_1.Vector3.Subtract(planePick, globalOffset);
|
|
69
|
+
const currentWorldPos = this.transform.worldPosition;
|
|
70
|
+
const newWorldPos = ValueObjects_1.Vector3.Add(currentWorldPos, delta);
|
|
71
|
+
this.transform.worldPosition = newWorldPos;
|
|
72
|
+
this.previousDistanceBetweenTouches = currentTouchDist;
|
|
73
|
+
};
|
|
74
|
+
this.finishPinch = () => {
|
|
75
|
+
var _a;
|
|
76
|
+
if (this.initialScale === ((_a = this.transform) === null || _a === void 0 ? void 0 : _a.worldScale.x))
|
|
77
|
+
return;
|
|
78
|
+
Dispatcher_1.dispatchStateChange(this.appObjects);
|
|
79
|
+
};
|
|
80
|
+
this.transform = appObject.getComponent(Entities_1.Transform3D.type);
|
|
81
|
+
if (!this.transform) {
|
|
82
|
+
this.warn("PinchSceneRootUC UC has been added to an App Object that does not have a Transform3D");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
getTouchCenter(t1, t2) {
|
|
87
|
+
const delta = ValueObjects_1.Vector2.Subtract(t2, t1);
|
|
88
|
+
const halfDelta = ValueObjects_1.Vector2.NewVectorOfLength(delta.unit, 0.5 * delta.magnitued);
|
|
89
|
+
return ValueObjects_1.Vector2.Add(t1, halfDelta);
|
|
90
|
+
}
|
|
91
|
+
getTouchDistance(t1, t2) {
|
|
92
|
+
const delta = ValueObjects_1.Vector2.Subtract(t2, t1);
|
|
93
|
+
return delta.magnitued;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AppObject, AppObjectUC } from "../../../AppObject";
|
|
2
|
+
import { ParametricLine, ParametricPlane } from "../../../ValueObjects";
|
|
3
|
+
export declare abstract class RayPanScaleTransformUC extends AppObjectUC {
|
|
4
|
+
static readonly type = "RayPanScaleTransformUC";
|
|
5
|
+
abstract sensitivity: number;
|
|
6
|
+
abstract enabled: boolean;
|
|
7
|
+
abstract minScale?: number;
|
|
8
|
+
abstract maxScale?: number;
|
|
9
|
+
abstract minX?: number;
|
|
10
|
+
abstract maxX?: number;
|
|
11
|
+
abstract minY?: number;
|
|
12
|
+
abstract maxY?: number;
|
|
13
|
+
abstract pickPlane?: ParametricPlane;
|
|
14
|
+
abstract update: (ray: ParametricLine) => void;
|
|
15
|
+
abstract initialize: (ray: ParametricLine) => void;
|
|
16
|
+
abstract finish: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function makeRayPanScaleTransformUC(appObject: AppObject): RayPanScaleTransformUC;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeRayPanScaleTransformUC = exports.RayPanScaleTransformUC = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
const ValueObjects_1 = require("../../../ValueObjects");
|
|
6
|
+
const Babylon_1 = require("../../Babylon");
|
|
7
|
+
const Dispatcher_1 = require("../../Dispatcher");
|
|
8
|
+
const Entities_1 = require("../Entities");
|
|
9
|
+
class RayPanScaleTransformUC extends AppObject_1.AppObjectUC {
|
|
10
|
+
}
|
|
11
|
+
exports.RayPanScaleTransformUC = RayPanScaleTransformUC;
|
|
12
|
+
RayPanScaleTransformUC.type = "RayPanScaleTransformUC";
|
|
13
|
+
function makeRayPanScaleTransformUC(appObject) {
|
|
14
|
+
return new RayPanScaleTransformUCImp(appObject);
|
|
15
|
+
}
|
|
16
|
+
exports.makeRayPanScaleTransformUC = makeRayPanScaleTransformUC;
|
|
17
|
+
class RayPanScaleTransformUCImp extends RayPanScaleTransformUC {
|
|
18
|
+
constructor(appObject) {
|
|
19
|
+
super(appObject, RayPanScaleTransformUC.type);
|
|
20
|
+
this.enabled = true;
|
|
21
|
+
this.sensitivity = 1;
|
|
22
|
+
this.allowUpdate = false;
|
|
23
|
+
this.initialScale = 1;
|
|
24
|
+
this.pickOffset = ValueObjects_1.Vector3.Zero();
|
|
25
|
+
this._panPlane = ValueObjects_1.ParametricPlane.XY();
|
|
26
|
+
this.lastRayLength = 0;
|
|
27
|
+
this.initialize = (ray) => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
this.allowUpdate = false;
|
|
30
|
+
if (!this.transform)
|
|
31
|
+
return;
|
|
32
|
+
if (this.pickPlane) {
|
|
33
|
+
this._panPlane = this.pickPlane;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const pick = Babylon_1.sceneRayPick(ray, this.appObjects);
|
|
37
|
+
this._panPlane = ValueObjects_1.ParametricPlane.FromPointNormal((_a = pick === null || pick === void 0 ? void 0 : pick.worldPickPoint) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero(), ValueObjects_1.Vector3.Backward());
|
|
38
|
+
}
|
|
39
|
+
const pickPoint = (_b = this._panPlane.intersectLine(ray)) !== null && _b !== void 0 ? _b : ValueObjects_1.Vector3.Zero();
|
|
40
|
+
this.lastRayLength = ValueObjects_1.ParametricLine.GetDistanceToPoint(ray, pickPoint);
|
|
41
|
+
this.pickOffset = this.transform.worldPointToLocal(pickPoint);
|
|
42
|
+
this.initialScale = this.transform.worldScale.x;
|
|
43
|
+
this.allowUpdate = true;
|
|
44
|
+
};
|
|
45
|
+
this.update = (ray) => {
|
|
46
|
+
var _a;
|
|
47
|
+
if (!this.enabled)
|
|
48
|
+
return;
|
|
49
|
+
if (!this.allowUpdate)
|
|
50
|
+
return;
|
|
51
|
+
if (!this.transform)
|
|
52
|
+
return;
|
|
53
|
+
const pick = (_a = this._panPlane.intersectLine(ray)) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero();
|
|
54
|
+
this.updateScale(ray, pick);
|
|
55
|
+
this.updatePosition(pick);
|
|
56
|
+
};
|
|
57
|
+
this.finish = () => {
|
|
58
|
+
if (!this.transform)
|
|
59
|
+
return;
|
|
60
|
+
if (!this.allowUpdate)
|
|
61
|
+
return;
|
|
62
|
+
if (this.initialScale !== this.transform.worldScale.x) {
|
|
63
|
+
Dispatcher_1.dispatchStateChange(this.appObjects);
|
|
64
|
+
}
|
|
65
|
+
this.allowUpdate = false;
|
|
66
|
+
};
|
|
67
|
+
this.transform = appObject.getComponent(Entities_1.Transform3D.type);
|
|
68
|
+
if (!this.transform) {
|
|
69
|
+
this.error("App Object does not have a Transform3D Entity");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
updatePosition(pick) {
|
|
73
|
+
if (!this.transform)
|
|
74
|
+
return;
|
|
75
|
+
const originalPickOffset = this.transform.localPointToWorld(this.pickOffset);
|
|
76
|
+
const movement = ValueObjects_1.Vector3.Subtract(pick, originalPickOffset);
|
|
77
|
+
let wPos = ValueObjects_1.Vector3.Add(movement, this.transform.worldPosition);
|
|
78
|
+
if (this.minX !== undefined && wPos.x < this.minX) {
|
|
79
|
+
wPos = new ValueObjects_1.Vector3(this.minX, wPos.y, wPos.z);
|
|
80
|
+
}
|
|
81
|
+
if (this.maxX !== undefined && wPos.x > this.maxX) {
|
|
82
|
+
wPos = new ValueObjects_1.Vector3(this.maxX, wPos.y, wPos.z);
|
|
83
|
+
}
|
|
84
|
+
if (this.minY !== undefined && wPos.y < this.minY) {
|
|
85
|
+
wPos = new ValueObjects_1.Vector3(wPos.x, this.minY, wPos.z);
|
|
86
|
+
}
|
|
87
|
+
if (this.maxY !== undefined && wPos.y > this.maxY) {
|
|
88
|
+
wPos = new ValueObjects_1.Vector3(wPos.x, this.maxY, wPos.z);
|
|
89
|
+
}
|
|
90
|
+
this.transform.worldPosition = wPos;
|
|
91
|
+
}
|
|
92
|
+
updateScale(ray, pick) {
|
|
93
|
+
if (!this.transform)
|
|
94
|
+
return;
|
|
95
|
+
const rayLength = ValueObjects_1.ParametricLine.GetDistanceToPoint(ray, pick);
|
|
96
|
+
const rayDelta = rayLength - this.lastRayLength;
|
|
97
|
+
const localPickOffset = this.transform.worldPointToLocal(pick);
|
|
98
|
+
const currentScale = this.transform.worldScale.x;
|
|
99
|
+
const scaleDelta = rayDelta * this.sensitivity * currentScale;
|
|
100
|
+
let newScale = currentScale + scaleDelta;
|
|
101
|
+
if (this.minScale !== undefined && newScale < this.minScale) {
|
|
102
|
+
newScale = this.minScale;
|
|
103
|
+
}
|
|
104
|
+
if (this.maxScale !== undefined && newScale > this.maxScale) {
|
|
105
|
+
newScale = this.maxScale;
|
|
106
|
+
}
|
|
107
|
+
this.transform.worldScale = new ValueObjects_1.Vector3(newScale, newScale, newScale);
|
|
108
|
+
const worldPickOffset = this.transform.localPointToWorld(localPickOffset);
|
|
109
|
+
const bump = ValueObjects_1.Vector3.Subtract(pick, worldPickOffset);
|
|
110
|
+
this.transform.worldPosition = ValueObjects_1.Vector3.Add(bump, this.transform.worldPosition);
|
|
111
|
+
this.lastRayLength = rayLength;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AppObject, AppObjectUC } from "../../../AppObject";
|
|
2
|
+
import { ParametricLine, ParametricPlane, Vector2 } from "../../../ValueObjects";
|
|
3
|
+
export declare abstract class ScaleTransformUC extends AppObjectUC {
|
|
4
|
+
static readonly type = "ScaleTransformUC";
|
|
5
|
+
abstract raySensitivity: number;
|
|
6
|
+
abstract pixelSensitivity: number;
|
|
7
|
+
abstract enabled: boolean;
|
|
8
|
+
abstract minScale?: number;
|
|
9
|
+
abstract maxScale?: number;
|
|
10
|
+
abstract pickPlane?: ParametricPlane;
|
|
11
|
+
abstract initializeRay: (ray: ParametricLine) => void;
|
|
12
|
+
abstract updateRay: (ray: ParametricLine) => void;
|
|
13
|
+
abstract initializePixel: (pixel: Vector2) => void;
|
|
14
|
+
abstract updatePixel: (pixel: Vector2) => void;
|
|
15
|
+
abstract finish: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function makeScaleTransformUC(appObject: AppObject): ScaleTransformUC;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeScaleTransformUC = exports.ScaleTransformUC = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
const ValueObjects_1 = require("../../../ValueObjects");
|
|
6
|
+
const Babylon_1 = require("../../Babylon");
|
|
7
|
+
const Dispatcher_1 = require("../../Dispatcher");
|
|
8
|
+
const Entities_1 = require("../Entities");
|
|
9
|
+
class ScaleTransformUC extends AppObject_1.AppObjectUC {
|
|
10
|
+
}
|
|
11
|
+
exports.ScaleTransformUC = ScaleTransformUC;
|
|
12
|
+
ScaleTransformUC.type = "ScaleTransformUC";
|
|
13
|
+
function makeScaleTransformUC(appObject) {
|
|
14
|
+
return new ScaleTransformUCImp(appObject);
|
|
15
|
+
}
|
|
16
|
+
exports.makeScaleTransformUC = makeScaleTransformUC;
|
|
17
|
+
class ScaleTransformUCImp extends ScaleTransformUC {
|
|
18
|
+
constructor(appObject) {
|
|
19
|
+
super(appObject, ScaleTransformUC.type);
|
|
20
|
+
this.raySensitivity = 1;
|
|
21
|
+
this.pixelSensitivity = 0.1;
|
|
22
|
+
this.enabled = true;
|
|
23
|
+
this.lastPosition = 0;
|
|
24
|
+
this.pickPoint = ValueObjects_1.Vector3.Zero();
|
|
25
|
+
this.initialScale = 1;
|
|
26
|
+
this.isScaling = false;
|
|
27
|
+
this.initializeRay = (ray) => {
|
|
28
|
+
this.lastPosition = ray.origin.z;
|
|
29
|
+
this.doInitialize(ray);
|
|
30
|
+
};
|
|
31
|
+
this.updateRay = (ray) => {
|
|
32
|
+
if (!this.isScaling)
|
|
33
|
+
return;
|
|
34
|
+
if (!this.transform)
|
|
35
|
+
return;
|
|
36
|
+
if (!this.enabled)
|
|
37
|
+
return;
|
|
38
|
+
const movement = this.lastPosition - ray.origin.z;
|
|
39
|
+
const currentScale = this.transform.worldScale.x;
|
|
40
|
+
const scaleDelta = movement * this.raySensitivity * currentScale;
|
|
41
|
+
this.bumpScaleAboutPoint(scaleDelta, this.pickPoint);
|
|
42
|
+
this.lastPosition = ray.origin.z;
|
|
43
|
+
};
|
|
44
|
+
this.initializePixel = (initialPixelPos) => {
|
|
45
|
+
this.lastPosition = initialPixelPos.y;
|
|
46
|
+
const ray = Babylon_1.pixelToSceneRay(initialPixelPos, this.appObjects);
|
|
47
|
+
this.doInitialize(ray);
|
|
48
|
+
};
|
|
49
|
+
this.updatePixel = (pixelPosition) => {
|
|
50
|
+
if (!this.enabled)
|
|
51
|
+
return;
|
|
52
|
+
if (!this.transform)
|
|
53
|
+
return;
|
|
54
|
+
if (!this.isScaling)
|
|
55
|
+
return;
|
|
56
|
+
const pixelChange = pixelPosition.y - this.lastPosition;
|
|
57
|
+
this.lastPosition = pixelPosition.y;
|
|
58
|
+
const currentScale = this.transform.worldScale.x;
|
|
59
|
+
const scaleDelta = pixelChange * this.pixelSensitivity * currentScale;
|
|
60
|
+
this.bumpScaleAboutPoint(scaleDelta, this.pickPoint);
|
|
61
|
+
};
|
|
62
|
+
this.finish = () => {
|
|
63
|
+
if (!this.transform)
|
|
64
|
+
return;
|
|
65
|
+
if (!this.isScaling)
|
|
66
|
+
return;
|
|
67
|
+
if (this.initialScale !== this.transform.worldScale.x) {
|
|
68
|
+
Dispatcher_1.dispatchStateChange(this.appObjects);
|
|
69
|
+
}
|
|
70
|
+
this.isScaling = false;
|
|
71
|
+
};
|
|
72
|
+
this.bumpScaleAboutPoint = (amount, worldPoint) => {
|
|
73
|
+
if (!this.transform)
|
|
74
|
+
return;
|
|
75
|
+
const localPickOffset = this.transform.worldPointToLocal(worldPoint);
|
|
76
|
+
const currentScale = this.transform.worldScale.x;
|
|
77
|
+
let newScale = currentScale + amount;
|
|
78
|
+
if (this.minScale !== undefined && newScale < this.minScale) {
|
|
79
|
+
newScale = this.minScale;
|
|
80
|
+
}
|
|
81
|
+
if (this.maxScale !== undefined && newScale > this.maxScale) {
|
|
82
|
+
newScale = this.maxScale;
|
|
83
|
+
}
|
|
84
|
+
this.transform.worldScale = new ValueObjects_1.Vector3(newScale, newScale, newScale);
|
|
85
|
+
const worldPickOffset = this.transform.localPointToWorld(localPickOffset);
|
|
86
|
+
const bump = ValueObjects_1.Vector3.Subtract(worldPoint, worldPickOffset);
|
|
87
|
+
this.transform.worldPosition = ValueObjects_1.Vector3.Add(bump, this.transform.worldPosition);
|
|
88
|
+
};
|
|
89
|
+
this.transform = appObject.getComponent(Entities_1.Transform3D.type);
|
|
90
|
+
if (!this.transform) {
|
|
91
|
+
this.error("App Object does not have a Transform3D Entity");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
doInitialize(ray) {
|
|
95
|
+
var _a, _b, _c;
|
|
96
|
+
this.isScaling = false;
|
|
97
|
+
if (!this.transform)
|
|
98
|
+
return;
|
|
99
|
+
if (this.pickPlane) {
|
|
100
|
+
this.pickPoint = (_a = this.pickPlane.intersectLine(ray)) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero();
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.pickPoint = (_c = (_b = Babylon_1.sceneRayPick(ray, this.appObjects)) === null || _b === void 0 ? void 0 : _b.worldPickPoint) !== null && _c !== void 0 ? _c : ValueObjects_1.Vector3.Zero();
|
|
104
|
+
}
|
|
105
|
+
this.initialScale = this.transform.worldScale.x;
|
|
106
|
+
this.isScaling = true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export * from "./BumpTransformScaleAboutPixelPoint";
|
|
1
2
|
export * from "./DragTransformUC";
|
|
3
|
+
export * from "./MoveTransformUndoRedo";
|
|
4
|
+
export * from "./PanTransformUC";
|
|
5
|
+
export * from "./PinchTransform";
|
|
6
|
+
export * from "./RayPanScaleTransform";
|
|
7
|
+
export * from "./ScaleTransform";
|
|
2
8
|
export * from "./StickTransformUC";
|
|
3
9
|
export * from "./StylusMoveTransformUC";
|
|
@@ -10,6 +10,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./BumpTransformScaleAboutPixelPoint"), exports);
|
|
13
14
|
__exportStar(require("./DragTransformUC"), exports);
|
|
15
|
+
__exportStar(require("./MoveTransformUndoRedo"), exports);
|
|
16
|
+
__exportStar(require("./PanTransformUC"), exports);
|
|
17
|
+
__exportStar(require("./PinchTransform"), exports);
|
|
18
|
+
__exportStar(require("./RayPanScaleTransform"), exports);
|
|
19
|
+
__exportStar(require("./ScaleTransform"), exports);
|
|
14
20
|
__exportStar(require("./StickTransformUC"), exports);
|
|
15
21
|
__exportStar(require("./StylusMoveTransformUC"), exports);
|
|
@@ -10,6 +10,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Controllers"), exports);
|
|
13
14
|
__exportStar(require("./Entities"), exports);
|
|
15
|
+
__exportStar(require("./Mocks"), exports);
|
|
14
16
|
__exportStar(require("./UC"), exports);
|
|
15
17
|
__exportStar(require("./PM"), exports);
|