@needle-tools/engine 3.2.13-alpha → 3.2.15-alpha
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/CHANGELOG.md +9 -0
- package/dist/needle-engine.js +8177 -8108
- package/dist/needle-engine.min.js +274 -288
- package/dist/needle-engine.umd.cjs +264 -278
- package/lib/engine/codegen/register_types.js +2 -0
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_license.js +11 -24
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.d.ts +1 -1
- package/lib/engine-components/SceneSwitcher.js +25 -1
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -0
- package/lib/engine-components/codegen/components.js +1 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.d.ts +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +13 -6
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.js +11 -4
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/utils/OpenURL.d.ts +21 -0
- package/lib/engine-components/utils/OpenURL.js +125 -0
- package/lib/engine-components/utils/OpenURL.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/engine/codegen/register_types.js +2 -0
- package/src/engine/engine_license.ts +12 -25
- package/src/engine-components/SceneSwitcher.ts +28 -3
- package/src/engine-components/codegen/components.ts +1 -0
- package/src/engine-components/export/usdz/USDZExporter.ts +10 -6
- package/src/engine-components/ui/EventSystem.ts +11 -5
- package/src/engine-components/utils/OpenURL.ts +119 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IPointerClickHandler, PointerEventData } from "../ui";
|
|
2
|
+
import { Behaviour } from "../Component";
|
|
3
|
+
export declare enum OpenURLMode {
|
|
4
|
+
NewTab = 0,
|
|
5
|
+
SameTab = 1,
|
|
6
|
+
NewWindow = 2
|
|
7
|
+
}
|
|
8
|
+
export declare class OpenURL extends Behaviour implements IPointerClickHandler {
|
|
9
|
+
clickable: boolean;
|
|
10
|
+
url?: string;
|
|
11
|
+
mode: OpenURLMode;
|
|
12
|
+
open(): Promise<void>;
|
|
13
|
+
start(): void;
|
|
14
|
+
onEnable(): void;
|
|
15
|
+
onDisable(): void;
|
|
16
|
+
onPointerEnter(args: any): void;
|
|
17
|
+
onPointerExit(): void;
|
|
18
|
+
onPointerClick(args: PointerEventData): void;
|
|
19
|
+
private _safariNewTabWorkaround;
|
|
20
|
+
private _validateUrl;
|
|
21
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Behaviour } from "../Component";
|
|
8
|
+
import { serializable } from "../../engine/engine_serialization";
|
|
9
|
+
import { isDevEnvironment, showBalloonMessage } from "../../engine/debug";
|
|
10
|
+
import { isSafari } from "../../engine/engine_utils";
|
|
11
|
+
import { ObjectRaycaster, Raycaster } from "../ui/Raycaster";
|
|
12
|
+
import { tryGetUIComponent } from "../ui/Utils";
|
|
13
|
+
export var OpenURLMode;
|
|
14
|
+
(function (OpenURLMode) {
|
|
15
|
+
OpenURLMode[OpenURLMode["NewTab"] = 0] = "NewTab";
|
|
16
|
+
OpenURLMode[OpenURLMode["SameTab"] = 1] = "SameTab";
|
|
17
|
+
OpenURLMode[OpenURLMode["NewWindow"] = 2] = "NewWindow";
|
|
18
|
+
})(OpenURLMode || (OpenURLMode = {}));
|
|
19
|
+
export class OpenURL extends Behaviour {
|
|
20
|
+
clickable = true;
|
|
21
|
+
url;
|
|
22
|
+
mode = OpenURLMode.NewTab;
|
|
23
|
+
async open() {
|
|
24
|
+
if (!this.url) {
|
|
25
|
+
console.error("URL is not set", this);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this._validateUrl();
|
|
29
|
+
if (isDevEnvironment())
|
|
30
|
+
showBalloonMessage("Open URL: " + this.url);
|
|
31
|
+
switch (this.mode) {
|
|
32
|
+
case OpenURLMode.NewTab:
|
|
33
|
+
if (isSafari()) {
|
|
34
|
+
globalThis.open(this.url, "_blank");
|
|
35
|
+
}
|
|
36
|
+
else
|
|
37
|
+
globalThis.open(this.url, "_blank");
|
|
38
|
+
break;
|
|
39
|
+
case OpenURLMode.SameTab:
|
|
40
|
+
if (isSafari()) {
|
|
41
|
+
globalThis.open(this.url, "_top");
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
globalThis.open(this.url, "_self");
|
|
45
|
+
break;
|
|
46
|
+
case OpenURLMode.NewWindow:
|
|
47
|
+
if (isSafari()) {
|
|
48
|
+
globalThis.open(this.url, "_top");
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
globalThis.open(this.url, "_new");
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
start() {
|
|
56
|
+
const raycaster = this.gameObject.getComponentInParent(ObjectRaycaster);
|
|
57
|
+
if (!raycaster)
|
|
58
|
+
this.gameObject.addNewComponent(ObjectRaycaster);
|
|
59
|
+
}
|
|
60
|
+
onEnable() {
|
|
61
|
+
if (isSafari())
|
|
62
|
+
window.addEventListener("touchend", this._safariNewTabWorkaround);
|
|
63
|
+
}
|
|
64
|
+
onDisable() {
|
|
65
|
+
if (isSafari())
|
|
66
|
+
window.removeEventListener("touchend", this._safariNewTabWorkaround);
|
|
67
|
+
}
|
|
68
|
+
onPointerEnter(args) {
|
|
69
|
+
if (!args.used && this.clickable)
|
|
70
|
+
this.context.input.setCursorPointer();
|
|
71
|
+
}
|
|
72
|
+
onPointerExit() {
|
|
73
|
+
if (this.clickable)
|
|
74
|
+
this.context.input.setCursorNormal();
|
|
75
|
+
}
|
|
76
|
+
onPointerClick(args) {
|
|
77
|
+
if (this.clickable && !args.used && this.url?.length)
|
|
78
|
+
this.open();
|
|
79
|
+
}
|
|
80
|
+
_safariNewTabWorkaround = () => {
|
|
81
|
+
if (!this.clickable || !this.url?.length)
|
|
82
|
+
return;
|
|
83
|
+
// we only need this workaround for opening a new tab
|
|
84
|
+
if (this.mode === OpenURLMode.SameTab)
|
|
85
|
+
return;
|
|
86
|
+
// When we process the click directly in the browser event we can open a new tab
|
|
87
|
+
// by emitting a link attribute and calling onClick
|
|
88
|
+
const raycaster = this.gameObject.getComponentInParent(Raycaster);
|
|
89
|
+
if (raycaster) {
|
|
90
|
+
const hits = raycaster.performRaycast();
|
|
91
|
+
if (!hits)
|
|
92
|
+
return;
|
|
93
|
+
for (const hit of hits) {
|
|
94
|
+
if (hit.object === this.gameObject || tryGetUIComponent(hit.object)?.gameObject === this.gameObject) {
|
|
95
|
+
this._validateUrl();
|
|
96
|
+
var a = document.createElement('a');
|
|
97
|
+
a.setAttribute("target", "_blank");
|
|
98
|
+
a.setAttribute("href", this.url);
|
|
99
|
+
a.click();
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
_validateUrl() {
|
|
106
|
+
if (!this.url)
|
|
107
|
+
return;
|
|
108
|
+
if (this.url.startsWith("www.")) {
|
|
109
|
+
if (isDevEnvironment()) {
|
|
110
|
+
console.warn("URL is not valid, adding https:// to the start of the URL", this.url);
|
|
111
|
+
}
|
|
112
|
+
this.url = "https://" + this.url;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
__decorate([
|
|
117
|
+
serializable()
|
|
118
|
+
], OpenURL.prototype, "clickable", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
serializable()
|
|
121
|
+
], OpenURL.prototype, "url", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
serializable()
|
|
124
|
+
], OpenURL.prototype, "mode", void 0);
|
|
125
|
+
//# sourceMappingURL=OpenURL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenURL.js","sourceRoot":"","sources":["../../../src/engine-components/utils/OpenURL.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,iDAAU,CAAA;IACV,mDAAW,CAAA;IACX,uDAAa,CAAA;AACjB,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAED,MAAM,OAAO,OAAQ,SAAQ,SAAS;IAGlC,SAAS,GAAY,IAAI,CAAC;IAG1B,GAAG,CAAU;IAGb,IAAI,GAAgB,WAAW,CAAC,MAAM,CAAC;IAEvC,KAAK,CAAC,IAAI;QACN,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;YACtC,OAAO;SACV;QAED,IAAI,CAAC,YAAY,EAAE,CAAC;QAEpB,IAAI,gBAAgB,EAAE;YAAE,kBAAkB,CAAC,YAAY,GAAG,IA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