@@ -4,16 +4,22 @@
|
|
4
4
|
|
5
5
|
module.exports = async function (source, _map) {
|
6
6
|
|
7
|
+
/** @ts-ignore */
|
8
|
+
const options = this.getOptions();
|
9
|
+
|
7
10
|
/** @type {string | undefined} */
|
8
|
-
let team =
|
11
|
+
let team = options.team;
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
if (!team) {
|
14
|
+
const meta = await getMeta();
|
15
|
+
if (meta) {
|
16
|
+
team = meta.license?.team;
|
17
|
+
}
|
13
18
|
}
|
14
19
|
|
15
20
|
// console.log("RESOLVE LICENSE...");
|
16
21
|
return (await mod).replaceLicense(source, {
|
22
|
+
accessToken: options.accessToken,
|
17
23
|
team: team,
|
18
24
|
});
|
19
25
|
};
|
@@ -43,13 +43,14 @@
|
|
43
43
|
export async function resolveLicense(args = null) {
|
44
44
|
let accessToken = args?.accessToken;
|
45
45
|
|
46
|
-
|
46
|
+
// If a process.env.NEEDLE_CLOUD_TOKEN is set we want to use this (e.g. via nextjs)
|
47
|
+
if (!accessToken) {
|
47
48
|
if (process.env.NEEDLE_CLOUD_TOKEN) {
|
48
|
-
console.log("[needle-license] INFO: Using Needle Cloud access token from environment variable");
|
49
|
+
console.log("[needle-license] INFO: Using Needle Cloud access token from NEEDLE_CLOUD_TOKEN environment variable");
|
49
50
|
accessToken = process.env.NEEDLE_CLOUD_TOKEN;
|
50
51
|
}
|
51
|
-
else {
|
52
|
-
console.warn("[needle-license] WARN: Missing NEEDLE_CLOUD_TOKEN for CI environment
|
52
|
+
else if (process.env.CI) {
|
53
|
+
console.warn("[needle-license] WARN: Missing NEEDLE_CLOUD_TOKEN for CI environment");
|
53
54
|
}
|
54
55
|
}
|
55
56
|
|
@@ -92,8 +93,8 @@
|
|
92
93
|
console.warn(message);
|
93
94
|
return null;
|
94
95
|
}
|
95
|
-
else if (
|
96
|
-
console.error("[needle-license] License server is not available
|
96
|
+
else if (!canRunCLI(args)) {
|
97
|
+
console.error("[needle-license] License server CLI is not available. Please use an access token for authorization.");
|
97
98
|
return null;
|
98
99
|
}
|
99
100
|
|
@@ -237,8 +238,8 @@
|
|
237
238
|
return null;
|
238
239
|
}
|
239
240
|
}
|
240
|
-
else if (
|
241
|
-
console.error("[needle-license] License server is not available
|
241
|
+
else if (!canRunCLI(opts)) {
|
242
|
+
console.error("[needle-license] License server CLI is not available. Please use an access token for authorization.");
|
242
243
|
return null;
|
243
244
|
}
|
244
245
|
|
@@ -355,8 +356,17 @@
|
|
355
356
|
}
|
356
357
|
|
357
358
|
|
358
|
-
|
359
|
-
|
359
|
+
/**
|
360
|
+
* @param {DefaultOptions | undefined | null} opts
|
361
|
+
*/
|
362
|
+
function canRunCLI(opts) {
|
363
|
+
// Note: the .stackblitz directory doesnt always exist it seems
|
364
|
+
if (existsSync("/home/.stackblitz")) {
|
365
|
+
if (opts?.loglevel === "verbose") console.log("[needle-license] INFO: Running in Stackblitz environment");
|
366
|
+
return false;
|
367
|
+
}
|
368
|
+
// Default to true:
|
369
|
+
return true;
|
360
370
|
}
|
361
371
|
|
362
372
|
/**
|
@@ -89,10 +89,18 @@
|
|
89
89
|
|
90
90
|
if (!config.module) config.module = {};
|
91
91
|
if (!config.module.rules) config.module.rules = [];
|
92
|
+
|
93
|
+
|
92
94
|
// add license plugin
|
95
|
+
const team_id = userSettings?.license?.team || undefined;
|
96
|
+
|
93
97
|
config.module.rules.push({
|
94
98
|
test: /engine_license\.(ts|js)$/,
|
95
|
-
loader: resolve(__dirname,
|
99
|
+
loader: resolve(__dirname, `license.cjs`),
|
100
|
+
options: {
|
101
|
+
team: team_id,
|
102
|
+
accessToken: userSettings?.license?.accessToken,
|
103
|
+
}
|
96
104
|
});
|
97
105
|
// add mesh bvh worker transform
|
98
106
|
config.module.rules.push({
|
@@ -671,15 +671,30 @@
|
|
671
671
|
}
|
672
672
|
|
673
673
|
|
674
|
-
|
675
|
-
getKeyDown(): string | null
|
674
|
+
/** Get a key (if any) that was just pressed this frame (this is only true for the frame it was pressed down) */
|
675
|
+
getKeyDown(): string | null;
|
676
|
+
/** Get true or false if the given key was pressed this frame */
|
677
|
+
getKeyDown(key: KeyCode | ({} & string)): boolean;
|
678
|
+
getKeyDown(key?: KeyCode | ({} & string)): boolean | string | null {
|
679
|
+
// If a key is provided check if it was pressed this frame
|
680
|
+
if (key !== undefined) {
|
681
|
+
return this.isKeyDown(key);
|
682
|
+
}
|
683
|
+
// If no key was provided get the first key that was pressed this frame
|
676
684
|
for (const key in this.keysPressed) {
|
677
685
|
const k = this.keysPressed[key];
|
678
686
|
if (k.startFrame === this.context.time.frameCount) return k.key;
|
679
687
|
}
|
680
688
|
return null;
|
681
689
|
}
|
682
|
-
|
690
|
+
/** Get a key (if any) that is currently being pressed (held down) */
|
691
|
+
getKeyPressed(): string | null;
|
692
|
+
/** Get true or false if the given key is pressed */
|
693
|
+
getKeyPressed(key: KeyCode | ({} & string)): boolean
|
694
|
+
getKeyPressed(key?: KeyCode | ({} & string)): boolean | string | null {
|
695
|
+
if (key !== undefined) {
|
696
|
+
return this.isKeyPressed(key);
|
697
|
+
}
|
683
698
|
for (const key in this.keysPressed) {
|
684
699
|
const k = this.keysPressed[key];
|
685
700
|
if (k.pressed)
|
@@ -687,6 +702,25 @@
|
|
687
702
|
}
|
688
703
|
return null;
|
689
704
|
}
|
705
|
+
|
706
|
+
/** Get a key (if any) that was released in this frame */
|
707
|
+
getKeyUp(): string | null;
|
708
|
+
/** Get true or false if the given key was released this frame */
|
709
|
+
getKeyUp(key: KeyCode | ({} & string)): boolean;
|
710
|
+
getKeyUp(key?: KeyCode | ({} & string)): boolean | string | null {
|
711
|
+
|
712
|
+
if (key !== undefined) {
|
713
|
+
return this.isKeyUp(key);
|
714
|
+
}
|
715
|
+
for (const key in this.keysPressed) {
|
716
|
+
const k = this.keysPressed[key];
|
717
|
+
if (k.pressed === false && k.frame === this.context.time.frameCount) return true;
|
718
|
+
return false;
|
719
|
+
}
|
720
|
+
|
721
|
+
return null;
|
722
|
+
}
|
723
|
+
|
690
724
|
isKeyDown(keyCode: KeyCode | ({} & string)) {
|
691
725
|
if (!this.context.application.isVisible || !this.context.application.hasFocus) return false;
|
692
726
|
const codes = this.getCodeForCommonKeyName(keyCode);
|
@@ -694,7 +728,9 @@
|
|
694
728
|
for (const code of codes) if (this.isKeyDown(code)) return true;
|
695
729
|
return false;
|
696
730
|
}
|
697
|
-
|
731
|
+
const k = this.keysPressed[keyCode];
|
732
|
+
if (!k) return false;
|
733
|
+
return k.startFrame === this.context.time.frameCount && k.pressed;
|
698
734
|
}
|
699
735
|
isKeyUp(keyCode: KeyCode | ({} & string)) {
|
700
736
|
if (!this.context.application.isVisible || !this.context.application.hasFocus) return false;
|
@@ -703,16 +739,20 @@
|
|
703
739
|
for (const code of codes) if (this.isKeyUp(code)) return true;
|
704
740
|
return false;
|
705
741
|
}
|
706
|
-
|
742
|
+
const k = this.keysPressed[keyCode];
|
743
|
+
if (!k) return false;
|
744
|
+
return k.frame === this.context.time.frameCount && k.pressed === false;
|
707
745
|
}
|
708
|
-
isKeyPressed(keyCode: KeyCode | ({} & string)) {
|
746
|
+
isKeyPressed(keyCode: KeyCode | ({} & string)): boolean {
|
709
747
|
if (!this.context.application.isVisible || !this.context.application.hasFocus) return false;
|
710
748
|
const codes = this.getCodeForCommonKeyName(keyCode);
|
711
749
|
if (codes !== null) {
|
712
750
|
for (const code of codes) if (this.isKeyPressed(code)) return true;
|
713
751
|
return false;
|
714
752
|
}
|
715
|
-
|
753
|
+
const k = this.keysPressed[keyCode];
|
754
|
+
if (!k) return false;
|
755
|
+
return k.pressed || false;
|
716
756
|
}
|
717
757
|
|
718
758
|
// utility helper for mapping common names to actual codes; e.g. "Shift" -> "ShiftLeft" and "ShiftRight" or "a" -> "KeyA"
|
@@ -232,7 +232,7 @@
|
|
232
232
|
padding-left: 30px;
|
233
233
|
`;
|
234
234
|
if (NEEDLE_ENGINE_LICENSE_TYPE === "edu") {
|
235
|
-
console.log("%c " + "
|
235
|
+
console.log("%c " + "This project is supported by Needle for Education – https://needle.tools", style);
|
236
236
|
}
|
237
237
|
else {
|
238
238
|
// if the user has a basic license we already show the logo in the menu and log a license message
|
@@ -321,7 +321,7 @@
|
|
321
321
|
|
322
322
|
if (this._model && !this._model.hasOwnership && this._model.isOwned) {
|
323
323
|
if (this._receivedDataBefore) {
|
324
|
-
const t = this._receivedFastUpdate || this.fastMode ? .
|
324
|
+
const t = this._receivedFastUpdate || this.fastMode ? .5 : .3;
|
325
325
|
let requireMarkDirty = false;
|
326
326
|
if (this.interpolatePosition && this._targetPosition) {
|
327
327
|
const pos = this.worldPosition;
|