@vived/app 4.29.0 → 4.30.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/lib/Components/ChannelModel/Adapters/index.d.ts +1 -0
- package/lib/Components/ChannelModel/Adapters/index.js +1 -0
- package/lib/Components/ChannelModel/Adapters/modelObjectsAreStickableAdapter.d.ts +2 -0
- package/lib/Components/ChannelModel/Adapters/modelObjectsAreStickableAdapter.js +27 -0
- package/lib/Components/ChannelModel/Controllers/index.d.ts +1 -0
- package/lib/Components/ChannelModel/Controllers/index.js +1 -0
- package/lib/Components/ChannelModel/Controllers/stickAllActiveObjects.d.ts +2 -0
- package/lib/Components/ChannelModel/Controllers/stickAllActiveObjects.js +23 -0
- package/lib/Components/ChannelModel/Mocks/ModelObjectsAreStickableMock.d.ts +7 -0
- package/lib/Components/ChannelModel/Mocks/ModelObjectsAreStickableMock.js +11 -0
- package/lib/Components/ChannelModel/Mocks/StickAllChannelModelObjectsUCMock.d.ts +9 -0
- package/lib/Components/ChannelModel/Mocks/StickAllChannelModelObjectsUCMock.js +13 -0
- package/lib/Components/ChannelModel/Mocks/index.d.ts +2 -0
- package/lib/Components/ChannelModel/Mocks/index.js +2 -0
- package/lib/Components/ChannelModel/PMs/ModelObjectsAreStickablePM.d.ts +6 -0
- package/lib/Components/ChannelModel/PMs/ModelObjectsAreStickablePM.js +56 -0
- package/lib/Components/ChannelModel/PMs/index.d.ts +1 -0
- package/lib/Components/ChannelModel/PMs/index.js +1 -0
- package/lib/Components/ChannelModel/UC/StickAllChannelModelObjectsUC.d.ts +7 -0
- package/lib/Components/ChannelModel/UC/StickAllChannelModelObjectsUC.js +87 -0
- package/lib/Components/ChannelModel/UC/index.d.ts +1 -0
- package/lib/Components/ChannelModel/UC/index.js +1 -0
- package/lib/Components/Stick/Adapters/index.d.ts +1 -0
- package/lib/Components/Stick/Adapters/index.js +13 -0
- package/lib/Components/Stick/Adapters/stickTargetAdapter.d.ts +3 -0
- package/lib/Components/Stick/Adapters/stickTargetAdapter.js +23 -0
- package/lib/Components/Stick/Controllers/DoubleClickToStickMC.d.ts +15 -0
- package/lib/Components/Stick/Controllers/DoubleClickToStickMC.js +57 -0
- package/lib/Components/Stick/Controllers/DoubleTapToStickTC.d.ts +15 -0
- package/lib/Components/Stick/Controllers/DoubleTapToStickTC.js +52 -0
- package/lib/Components/Stick/Controllers/clickStick.d.ts +2 -0
- package/lib/Components/Stick/Controllers/clickStick.js +13 -0
- package/lib/Components/Stick/Controllers/index.d.ts +3 -0
- package/lib/Components/Stick/Controllers/index.js +15 -0
- package/lib/Components/Stick/Entities/Stickable.d.ts +22 -0
- package/lib/Components/Stick/Entities/Stickable.js +101 -0
- package/lib/Components/Stick/Entities/index.d.ts +1 -0
- package/lib/Components/Stick/Entities/index.js +13 -0
- package/lib/Components/Stick/Factories/index.d.ts +1 -0
- package/lib/Components/Stick/Factories/index.js +13 -0
- package/lib/Components/Stick/Factories/setupStick.d.ts +2 -0
- package/lib/Components/Stick/Factories/setupStick.js +15 -0
- package/lib/Components/Stick/Mocks/StickTargetPmMock.d.ts +7 -0
- package/lib/Components/Stick/Mocks/StickTargetPmMock.js +11 -0
- package/lib/Components/Stick/Mocks/StickUCMock.d.ts +7 -0
- package/lib/Components/Stick/Mocks/StickUCMock.js +11 -0
- package/lib/Components/Stick/Mocks/TryStickAppObjectUCMock.d.ts +10 -0
- package/lib/Components/Stick/Mocks/TryStickAppObjectUCMock.js +17 -0
- package/lib/Components/Stick/Mocks/index.d.ts +3 -0
- package/lib/Components/Stick/Mocks/index.js +15 -0
- package/lib/Components/Stick/PMs/StickTargetPM.d.ts +11 -0
- package/lib/Components/Stick/PMs/StickTargetPM.js +50 -0
- package/lib/Components/Stick/PMs/index.d.ts +1 -0
- package/lib/Components/Stick/PMs/index.js +13 -0
- package/lib/Components/Stick/UCs/PanTransformWithStickUC.d.ts +3 -0
- package/lib/Components/Stick/UCs/PanTransformWithStickUC.js +131 -0
- package/lib/Components/Stick/UCs/StickUC.d.ts +7 -0
- package/lib/Components/Stick/UCs/StickUC.js +71 -0
- package/lib/Components/Stick/UCs/TryPickStickTarget.d.ts +8 -0
- package/lib/Components/Stick/UCs/TryPickStickTarget.js +26 -0
- package/lib/Components/Stick/UCs/TryStickAppObjectUC.d.ts +10 -0
- package/lib/Components/Stick/UCs/TryStickAppObjectUC.js +74 -0
- package/lib/Components/Stick/UCs/index.d.ts +4 -0
- package/lib/Components/Stick/UCs/index.js +16 -0
- package/lib/Components/Stick/index.d.ts +7 -0
- package/lib/Components/Stick/index.js +19 -0
- package/lib/Components/Stylus/Factories/index.d.ts +1 -0
- package/lib/Components/Stylus/Factories/index.js +13 -0
- package/lib/Components/Stylus/Factories/setupStylus.d.ts +2 -0
- package/lib/Components/Stylus/Factories/setupStylus.js +19 -0
- package/lib/Components/Stylus/index.d.ts +1 -0
- package/lib/Components/Stylus/index.js +1 -0
- package/lib/Components/Transform3D/UC/PanTransformUC.d.ts +28 -1
- package/lib/Components/Transform3D/UC/PanTransformUC.js +52 -34
- package/lib/Components/Transform3D/UC/TryPanTransformUC.d.ts +3 -2
- package/lib/Components/Transform3D/UC/index.d.ts +0 -1
- package/lib/Components/Transform3D/UC/index.js +0 -1
- package/lib/Components/index.d.ts +1 -0
- package/lib/Components/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeStickableEntity = exports.StickableEntity = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
const Entities_1 = require("../../../Entities");
|
|
6
|
+
const Utilities_1 = require("../../../Utilities");
|
|
7
|
+
const ValueObjects_1 = require("../../../ValueObjects");
|
|
8
|
+
const Transform3D_1 = require("../../Transform3D");
|
|
9
|
+
class StickableEntity extends AppObject_1.AppObjectEntity {
|
|
10
|
+
static get(id, appObjects) {
|
|
11
|
+
var _a;
|
|
12
|
+
return (_a = appObjects
|
|
13
|
+
.get(id)) === null || _a === void 0 ? void 0 : _a.getComponent(StickableEntity.type);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.StickableEntity = StickableEntity;
|
|
17
|
+
StickableEntity.type = "StickableEntity";
|
|
18
|
+
function makeStickableEntity(appObject) {
|
|
19
|
+
return new StickableEntityImp(appObject);
|
|
20
|
+
}
|
|
21
|
+
exports.makeStickableEntity = makeStickableEntity;
|
|
22
|
+
class StickableEntityImp extends StickableEntity {
|
|
23
|
+
constructor(appObject) {
|
|
24
|
+
super(appObject, StickableEntity.type);
|
|
25
|
+
this.stickDurationMS = 500;
|
|
26
|
+
this.easeFn = Utilities_1.expoOut;
|
|
27
|
+
this.memoizedCanBeStuck = new Entities_1.MemoizedBoolean(false, this.notifyOnChange);
|
|
28
|
+
this.memoizedStickPosition = new Entities_1.MemoizedVector3(ValueObjects_1.Vector3.Zero(), this.notifyOnChange);
|
|
29
|
+
this.memoizedStickRotation = new Entities_1.MemoizedQuaternion(ValueObjects_1.Quaternion.Identity(), this.notifyOnChange);
|
|
30
|
+
this.memoizedStickScale = new Entities_1.MemoizedNumber(1, this.notifyOnChange);
|
|
31
|
+
this.memoizedShowStickTarget = new Entities_1.MemoizedBoolean(false, this.notifyOnChange);
|
|
32
|
+
this.memoizedHighlightTarget = new Entities_1.MemoizedBoolean(false, this.notifyOnChange);
|
|
33
|
+
this.checkIfStickable = () => {
|
|
34
|
+
if (!ValueObjects_1.Vector3.Equal(this.transform.localPosition, this.memoizedStickPosition.val)) {
|
|
35
|
+
this.memoizedCanBeStuck.val = true;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (this.transform.localScale.x !== this.memoizedStickScale.val) {
|
|
39
|
+
this.memoizedCanBeStuck.val = true;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!ValueObjects_1.Quaternion.Close(this.transform.localRotation, this.memoizedStickRotation.val)) {
|
|
43
|
+
this.memoizedCanBeStuck.val = true;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.memoizedCanBeStuck.val = false;
|
|
47
|
+
};
|
|
48
|
+
this.transform = Transform3D_1.Transform3D.addIfMissing(appObject);
|
|
49
|
+
this.transform.addChangeObserver(this.checkIfStickable);
|
|
50
|
+
this.checkIfStickable();
|
|
51
|
+
}
|
|
52
|
+
doStick(onCompleteCallback) {
|
|
53
|
+
if (!this.canBeStuck)
|
|
54
|
+
return;
|
|
55
|
+
const lerpData = {
|
|
56
|
+
durationMS: this.stickDurationMS,
|
|
57
|
+
ease: this.easeFn,
|
|
58
|
+
desiredPosition: this.stickPosition,
|
|
59
|
+
desiredRotation: this.stickRotation,
|
|
60
|
+
desiredScale: new ValueObjects_1.Vector3(this.stickScale, this.stickScale, this.stickScale),
|
|
61
|
+
onCompletedCallback: onCompleteCallback
|
|
62
|
+
};
|
|
63
|
+
this.transform.lerp(lerpData);
|
|
64
|
+
}
|
|
65
|
+
get canBeStuck() {
|
|
66
|
+
return this.memoizedCanBeStuck.val;
|
|
67
|
+
}
|
|
68
|
+
get stickPosition() {
|
|
69
|
+
return this.memoizedStickPosition.val;
|
|
70
|
+
}
|
|
71
|
+
set stickPosition(val) {
|
|
72
|
+
this.memoizedStickPosition.val = val;
|
|
73
|
+
this.checkIfStickable();
|
|
74
|
+
}
|
|
75
|
+
get stickRotation() {
|
|
76
|
+
return this.memoizedStickRotation.val;
|
|
77
|
+
}
|
|
78
|
+
set stickRotation(val) {
|
|
79
|
+
this.memoizedStickRotation.val = val;
|
|
80
|
+
this.checkIfStickable();
|
|
81
|
+
}
|
|
82
|
+
get stickScale() {
|
|
83
|
+
return this.memoizedStickScale.val;
|
|
84
|
+
}
|
|
85
|
+
set stickScale(val) {
|
|
86
|
+
this.memoizedStickScale.val = val;
|
|
87
|
+
this.checkIfStickable();
|
|
88
|
+
}
|
|
89
|
+
get showStickTarget() {
|
|
90
|
+
return this.memoizedShowStickTarget.val;
|
|
91
|
+
}
|
|
92
|
+
set showStickTarget(showStickTarget) {
|
|
93
|
+
this.memoizedShowStickTarget.val = showStickTarget;
|
|
94
|
+
}
|
|
95
|
+
get highlightTarget() {
|
|
96
|
+
return this.memoizedHighlightTarget.val;
|
|
97
|
+
}
|
|
98
|
+
set highlightTarget(highlightTarget) {
|
|
99
|
+
this.memoizedHighlightTarget.val = highlightTarget;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Stickable";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Stickable"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./setupStick";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./setupStick"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupStick = void 0;
|
|
4
|
+
const DoubleClickToStickMC_1 = require("../Controllers/DoubleClickToStickMC");
|
|
5
|
+
const DoubleTapToStickTC_1 = require("../Controllers/DoubleTapToStickTC");
|
|
6
|
+
const TryStickAppObjectUC_1 = require("../UCs/TryStickAppObjectUC");
|
|
7
|
+
function setupStick(appObjects) {
|
|
8
|
+
const ao = appObjects.getOrCreate("Stick");
|
|
9
|
+
// UCs
|
|
10
|
+
TryStickAppObjectUC_1.makeTryStickAppObjectUC(ao);
|
|
11
|
+
// Controllers
|
|
12
|
+
new DoubleClickToStickMC_1.DoubleClickToStickMC(ao);
|
|
13
|
+
new DoubleTapToStickTC_1.DoubleTapToStickTC(ao);
|
|
14
|
+
}
|
|
15
|
+
exports.setupStick = setupStick;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { AppObject } from "../../../AppObject";
|
|
3
|
+
import { StickTargetPM } from "../PMs/StickTargetPM";
|
|
4
|
+
export declare class StickTargetPmMock extends StickTargetPM {
|
|
5
|
+
vmsAreEqual: jest.Mock<any, any>;
|
|
6
|
+
constructor(appObject: AppObject);
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StickTargetPmMock = void 0;
|
|
4
|
+
const StickTargetPM_1 = require("../PMs/StickTargetPM");
|
|
5
|
+
class StickTargetPmMock extends StickTargetPM_1.StickTargetPM {
|
|
6
|
+
constructor(appObject) {
|
|
7
|
+
super(appObject, StickTargetPM_1.StickTargetPM.type);
|
|
8
|
+
this.vmsAreEqual = jest.fn();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.StickTargetPmMock = StickTargetPmMock;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StickUCMock = void 0;
|
|
4
|
+
const StickUC_1 = require("../UCs/StickUC");
|
|
5
|
+
class StickUCMock extends StickUC_1.StickUC {
|
|
6
|
+
constructor(appObject) {
|
|
7
|
+
super(appObject, StickUC_1.StickUC.type);
|
|
8
|
+
this.doStick = jest.fn();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.StickUCMock = StickUCMock;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { AppObject, AppObjectRepo } from "../../../AppObject";
|
|
3
|
+
import { TryStickAppObjectUC } from "../UCs/TryStickAppObjectUC";
|
|
4
|
+
export declare class TryStickAppObjectUCMock extends TryStickAppObjectUC {
|
|
5
|
+
allow: jest.Mock<any, any>;
|
|
6
|
+
tryWithRay: jest.Mock<any, any>;
|
|
7
|
+
tryWithPixel: jest.Mock<any, any>;
|
|
8
|
+
constructor(appObject: AppObject);
|
|
9
|
+
}
|
|
10
|
+
export declare function makeTryStickAppObjectUCMock(appObjects: AppObjectRepo): TryStickAppObjectUCMock;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeTryStickAppObjectUCMock = exports.TryStickAppObjectUCMock = void 0;
|
|
4
|
+
const TryStickAppObjectUC_1 = require("../UCs/TryStickAppObjectUC");
|
|
5
|
+
class TryStickAppObjectUCMock extends TryStickAppObjectUC_1.TryStickAppObjectUC {
|
|
6
|
+
constructor(appObject) {
|
|
7
|
+
super(appObject, TryStickAppObjectUC_1.TryStickAppObjectUC.type);
|
|
8
|
+
this.allow = jest.fn();
|
|
9
|
+
this.tryWithRay = jest.fn();
|
|
10
|
+
this.tryWithPixel = jest.fn();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.TryStickAppObjectUCMock = TryStickAppObjectUCMock;
|
|
14
|
+
function makeTryStickAppObjectUCMock(appObjects) {
|
|
15
|
+
return new TryStickAppObjectUCMock(appObjects.getOrCreate("TryStickAppObjectUCMock"));
|
|
16
|
+
}
|
|
17
|
+
exports.makeTryStickAppObjectUCMock = makeTryStickAppObjectUCMock;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./"), exports);
|
|
14
|
+
__exportStar(require("./StickUCMock"), exports);
|
|
15
|
+
__exportStar(require("./TryStickAppObjectUCMock"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AppObject, AppObjectPM, AppObjectRepo } from "../../../AppObject";
|
|
2
|
+
export interface StickTargetVM {
|
|
3
|
+
showStickTarget: boolean;
|
|
4
|
+
highlightTarget: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare abstract class StickTargetPM extends AppObjectPM<StickTargetVM> {
|
|
7
|
+
static readonly type = "StickTargetPM";
|
|
8
|
+
static get(id: string, appObjects: AppObjectRepo): StickTargetPM | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function makeStickTargetPM(appObject: AppObject): StickTargetPM;
|
|
11
|
+
export declare const defaultStickTargetVM: StickTargetVM;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultStickTargetVM = exports.makeStickTargetPM = exports.StickTargetPM = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
const Stickable_1 = require("../Entities/Stickable");
|
|
6
|
+
class StickTargetPM extends AppObject_1.AppObjectPM {
|
|
7
|
+
static get(id, appObjects) {
|
|
8
|
+
var _a;
|
|
9
|
+
return (_a = appObjects.get(id)) === null || _a === void 0 ? void 0 : _a.getComponent(StickTargetPM.type);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.StickTargetPM = StickTargetPM;
|
|
13
|
+
StickTargetPM.type = "StickTargetPM";
|
|
14
|
+
function makeStickTargetPM(appObject) {
|
|
15
|
+
return new StickTargetPMImp(appObject);
|
|
16
|
+
}
|
|
17
|
+
exports.makeStickTargetPM = makeStickTargetPM;
|
|
18
|
+
class StickTargetPMImp extends StickTargetPM {
|
|
19
|
+
constructor(appObject) {
|
|
20
|
+
var _a;
|
|
21
|
+
super(appObject, StickTargetPM.type);
|
|
22
|
+
this.onEntityChange = () => {
|
|
23
|
+
if (!this.entity)
|
|
24
|
+
return;
|
|
25
|
+
const showStickTarget = this.entity.showStickTarget;
|
|
26
|
+
const highlightTarget = this.entity.highlightTarget;
|
|
27
|
+
const vm = {
|
|
28
|
+
showStickTarget,
|
|
29
|
+
highlightTarget,
|
|
30
|
+
};
|
|
31
|
+
this.doUpdateView(vm);
|
|
32
|
+
};
|
|
33
|
+
(_a = this.entity) === null || _a === void 0 ? void 0 : _a.addChangeObserver(this.onEntityChange);
|
|
34
|
+
this.onEntityChange();
|
|
35
|
+
}
|
|
36
|
+
get entity() {
|
|
37
|
+
return this.getCachedLocalComponent(Stickable_1.StickableEntity.type);
|
|
38
|
+
}
|
|
39
|
+
vmsAreEqual(a, b) {
|
|
40
|
+
if (a.highlightTarget !== b.highlightTarget)
|
|
41
|
+
return false;
|
|
42
|
+
if (a.showStickTarget !== b.showStickTarget)
|
|
43
|
+
return false;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.defaultStickTargetVM = {
|
|
48
|
+
showStickTarget: false,
|
|
49
|
+
highlightTarget: false,
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./StickTargetPM";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./StickTargetPM"), exports);
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePanTransformWithStickUC = void 0;
|
|
4
|
+
const ValueObjects_1 = require("../../../ValueObjects");
|
|
5
|
+
const Transform3D_1 = require("../../Transform3D");
|
|
6
|
+
const Stickable_1 = require("../Entities/Stickable");
|
|
7
|
+
const TryPickStickTarget_1 = require("./TryPickStickTarget");
|
|
8
|
+
function makePanTransformWithStickUC(appObject) {
|
|
9
|
+
return new PanTransformWithStickUC(appObject);
|
|
10
|
+
}
|
|
11
|
+
exports.makePanTransformWithStickUC = makePanTransformWithStickUC;
|
|
12
|
+
class PanTransformWithStickUC extends Transform3D_1.PanTransformUCImp {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.isFirstPeel = true;
|
|
16
|
+
this.initialScale = ValueObjects_1.Vector3.Zero();
|
|
17
|
+
this.initialRot = ValueObjects_1.Quaternion.Identity();
|
|
18
|
+
this.initializeRay = (ray) => {
|
|
19
|
+
var _a;
|
|
20
|
+
if (!this.transformNode || !this.stickable || !this.pickTargetsUC) {
|
|
21
|
+
this.error("Missing components");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const pick = (_a = this.panPlane.intersectLine(ray)) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero();
|
|
25
|
+
const rootPos = this.transformNode.worldPosition;
|
|
26
|
+
this.pickOffset = ValueObjects_1.Vector3.Subtract(rootPos, pick);
|
|
27
|
+
this.initialScale = this.transformNode.localScale;
|
|
28
|
+
this.initialRot = this.transformNode.localRotation;
|
|
29
|
+
this.isFirstPeel = true;
|
|
30
|
+
this.hasBeenInitialized = true;
|
|
31
|
+
this.initialPosition = this.transformNode.localPosition;
|
|
32
|
+
};
|
|
33
|
+
this.updateRay = (ray) => {
|
|
34
|
+
var _a;
|
|
35
|
+
if (!this.transformNode || !this.stickable || !this.pickTargetsUC) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!this.hasBeenInitialized)
|
|
39
|
+
return;
|
|
40
|
+
if (!this.enabled)
|
|
41
|
+
return;
|
|
42
|
+
const pick = (_a = this.panPlane.intersectLine(ray)) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero();
|
|
43
|
+
const wPos = ValueObjects_1.Vector3.Add(pick, this.pickOffset);
|
|
44
|
+
const clampedPos = this.enforceBoundaries(wPos);
|
|
45
|
+
this.transformNode.worldPosition = clampedPos;
|
|
46
|
+
const isHitStickTarget = this.pickTargetsUC.tryPick(ray);
|
|
47
|
+
if (isHitStickTarget) {
|
|
48
|
+
if (this.isFirstPeel) {
|
|
49
|
+
this.stickable.showStickTarget = false;
|
|
50
|
+
this.stickable.highlightTarget = false;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.stickable.showStickTarget = true;
|
|
54
|
+
this.stickable.highlightTarget = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.stickable.showStickTarget = true;
|
|
59
|
+
this.stickable.highlightTarget = false;
|
|
60
|
+
this.isFirstPeel = false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
this.finish = () => {
|
|
64
|
+
if (!this.stickable) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!this.hasBeenInitialized)
|
|
68
|
+
return;
|
|
69
|
+
if (!this.enabled)
|
|
70
|
+
return;
|
|
71
|
+
const doStick = this.stickable.highlightTarget;
|
|
72
|
+
this.hasBeenInitialized = false;
|
|
73
|
+
this.stickable.showStickTarget = false;
|
|
74
|
+
this.stickable.highlightTarget = false;
|
|
75
|
+
if (doStick) {
|
|
76
|
+
this.finishWithStick();
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.submitDispatchAndUndo();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
this.cancelPan = () => {
|
|
83
|
+
this.hasBeenInitialized = false;
|
|
84
|
+
if (this.stickable) {
|
|
85
|
+
this.stickable.showStickTarget = false;
|
|
86
|
+
this.stickable.highlightTarget = false;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
get stickable() {
|
|
91
|
+
return this.getCachedLocalComponent(Stickable_1.StickableEntity.type);
|
|
92
|
+
}
|
|
93
|
+
get pickTargetsUC() {
|
|
94
|
+
return this.getCachedLocalComponent(TryPickStickTarget_1.TryPickStickTargetUC.type);
|
|
95
|
+
}
|
|
96
|
+
finishWithStick() {
|
|
97
|
+
var _a;
|
|
98
|
+
const dispatch = this.dispatchStateChange;
|
|
99
|
+
const transform = this.transformNode;
|
|
100
|
+
if (!transform || !dispatch || !this.stickable)
|
|
101
|
+
return;
|
|
102
|
+
const startPos = this.initialPosition;
|
|
103
|
+
const finalPos = this.stickable.stickPosition;
|
|
104
|
+
const startRot = this.initialRot;
|
|
105
|
+
const finalRot = this.stickable.stickRotation;
|
|
106
|
+
const startScale = this.initialScale;
|
|
107
|
+
const finalScale = new ValueObjects_1.Vector3(this.stickable.stickScale, this.stickable.stickScale, this.stickable.stickScale);
|
|
108
|
+
if (this.dispatchStateChangeOnComplete) {
|
|
109
|
+
this.stickable.doStick(dispatch);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.stickable.doStick();
|
|
113
|
+
}
|
|
114
|
+
if (this.submitUndoOnComplete) {
|
|
115
|
+
(_a = this.undoRedo) === null || _a === void 0 ? void 0 : _a.submitAction({
|
|
116
|
+
undoAction: () => {
|
|
117
|
+
transform.localPosition = startPos;
|
|
118
|
+
transform.localRotation = startRot;
|
|
119
|
+
transform.localScale = startScale;
|
|
120
|
+
dispatch();
|
|
121
|
+
},
|
|
122
|
+
redoAction: () => {
|
|
123
|
+
transform.localPosition = finalPos;
|
|
124
|
+
transform.localRotation = finalRot;
|
|
125
|
+
transform.localScale = finalScale;
|
|
126
|
+
dispatch();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AppObject, AppObjectRepo, AppObjectUC } from "../../../AppObject";
|
|
2
|
+
export declare abstract class StickUC extends AppObjectUC {
|
|
3
|
+
static readonly type = "StickUC";
|
|
4
|
+
abstract doStick(): void;
|
|
5
|
+
static get(id: string, appObjects: AppObjectRepo): StickUC | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare function makeStickUC(appObject: AppObject): StickUC;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeStickUC = exports.StickUC = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
const ValueObjects_1 = require("../../../ValueObjects");
|
|
6
|
+
const DispatchStateChangeUC_1 = require("../../Dispatcher/UC/DispatchStateChangeUC");
|
|
7
|
+
const Transform3D_1 = require("../../Transform3D/Entities/Transform3D");
|
|
8
|
+
const UndoRedoEntity_1 = require("../../UndoRedo/Entities/UndoRedoEntity");
|
|
9
|
+
const Stickable_1 = require("../Entities/Stickable");
|
|
10
|
+
class StickUC extends AppObject_1.AppObjectUC {
|
|
11
|
+
static get(id, appObjects) {
|
|
12
|
+
var _a;
|
|
13
|
+
return (_a = appObjects.get(id)) === null || _a === void 0 ? void 0 : _a.getComponent(StickUC.type);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.StickUC = StickUC;
|
|
17
|
+
StickUC.type = "StickUC";
|
|
18
|
+
function makeStickUC(appObject) {
|
|
19
|
+
return new StickUCImp(appObject);
|
|
20
|
+
}
|
|
21
|
+
exports.makeStickUC = makeStickUC;
|
|
22
|
+
class StickUCImp extends StickUC {
|
|
23
|
+
constructor(appObject) {
|
|
24
|
+
super(appObject, StickUC.type);
|
|
25
|
+
this.doStick = () => {
|
|
26
|
+
var _a;
|
|
27
|
+
const transform = this.transform3D;
|
|
28
|
+
const dispatch = this.dispatchStateChange;
|
|
29
|
+
if (!transform || !this.stickEntity || !dispatch) {
|
|
30
|
+
this.error("Missing Components");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!this.stickEntity.canBeStuck)
|
|
34
|
+
return;
|
|
35
|
+
const startPos = transform.localPosition;
|
|
36
|
+
const finalPos = this.stickEntity.stickPosition;
|
|
37
|
+
const startRot = transform.localRotation;
|
|
38
|
+
const finalRot = this.stickEntity.stickRotation;
|
|
39
|
+
const startScale = transform.localScale;
|
|
40
|
+
const finalScale = new ValueObjects_1.Vector3(this.stickEntity.stickScale, this.stickEntity.stickScale, this.stickEntity.stickScale);
|
|
41
|
+
this.stickEntity.doStick(dispatch);
|
|
42
|
+
(_a = this.undo) === null || _a === void 0 ? void 0 : _a.submitAction({
|
|
43
|
+
undoAction: () => {
|
|
44
|
+
transform.localPosition = startPos;
|
|
45
|
+
transform.localRotation = startRot;
|
|
46
|
+
transform.localScale = startScale;
|
|
47
|
+
dispatch();
|
|
48
|
+
},
|
|
49
|
+
redoAction: () => {
|
|
50
|
+
transform.localPosition = finalPos;
|
|
51
|
+
transform.localRotation = finalRot;
|
|
52
|
+
transform.localScale = finalScale;
|
|
53
|
+
dispatch();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
get stickEntity() {
|
|
59
|
+
return this.getCachedLocalComponent(Stickable_1.StickableEntity.type);
|
|
60
|
+
}
|
|
61
|
+
get transform3D() {
|
|
62
|
+
return this.getCachedLocalComponent(Transform3D_1.Transform3D.type);
|
|
63
|
+
}
|
|
64
|
+
get dispatchStateChange() {
|
|
65
|
+
var _a;
|
|
66
|
+
return (_a = this.getCachedSingleton(DispatchStateChangeUC_1.DispatchStateChangeUC.type)) === null || _a === void 0 ? void 0 : _a.doDispatch;
|
|
67
|
+
}
|
|
68
|
+
get undo() {
|
|
69
|
+
return this.getCachedSingleton(UndoRedoEntity_1.UndoRedoEntity.type);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AppObject, AppObjectRepo, AppObjectUC } from "../../../AppObject";
|
|
2
|
+
import { ParametricLine } from "../../../ValueObjects";
|
|
3
|
+
export declare abstract class TryPickStickTargetUC extends AppObjectUC {
|
|
4
|
+
static type: string;
|
|
5
|
+
abstract tryPick(ray: ParametricLine): boolean;
|
|
6
|
+
static get(id: string, appObjects: AppObjectRepo): TryPickStickTargetUC | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare function makeTryPickStickTargetUC(appObject: AppObject): TryPickStickTargetUC;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeTryPickStickTargetUC = exports.TryPickStickTargetUC = void 0;
|
|
4
|
+
const AppObject_1 = require("../../../AppObject");
|
|
5
|
+
class TryPickStickTargetUC extends AppObject_1.AppObjectUC {
|
|
6
|
+
static get(id, appObjects) {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = appObjects
|
|
9
|
+
.get(id)) === null || _a === void 0 ? void 0 : _a.getComponent(TryPickStickTargetUC.type);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.TryPickStickTargetUC = TryPickStickTargetUC;
|
|
13
|
+
TryPickStickTargetUC.type = "TryPickStickTargetUC";
|
|
14
|
+
function makeTryPickStickTargetUC(appObject) {
|
|
15
|
+
return new TryPickStickTargetUCImp(appObject);
|
|
16
|
+
}
|
|
17
|
+
exports.makeTryPickStickTargetUC = makeTryPickStickTargetUC;
|
|
18
|
+
class TryPickStickTargetUCImp extends TryPickStickTargetUC {
|
|
19
|
+
constructor(appObject) {
|
|
20
|
+
super(appObject, TryPickStickTargetUC.type);
|
|
21
|
+
this.tryPick = (pickRay) => {
|
|
22
|
+
this.warn("Picker needs to be injected");
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AppObject, AppObjectRepo, AppObjectUC } from "../../../AppObject";
|
|
2
|
+
import { ParametricLine, Vector2 } from "../../../ValueObjects";
|
|
3
|
+
export declare abstract class TryStickAppObjectUC extends AppObjectUC {
|
|
4
|
+
static type: string;
|
|
5
|
+
abstract tryWithRay(ray: ParametricLine): void;
|
|
6
|
+
abstract tryWithPixel(pixel: Vector2): void;
|
|
7
|
+
abstract allow(): void;
|
|
8
|
+
static get(appObjects: AppObjectRepo): TryStickAppObjectUC | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function makeTryStickAppObjectUC(appObject: AppObject): TryStickAppObjectUC;
|