@wonderlandengine/editor-api 1.2.0-dev.0 → 1.2.0-dev.2

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/data.d.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  export type ObjectReference = string | null;
3
3
  /** Mesh reference */
4
4
  export type MeshReference = string | null;
5
+ /** Morph targets reference */
6
+ export type MorphTargetsReference = string | null;
5
7
  /** Texture reference */
6
8
  export type TextureReference = string | null;
7
9
  /** Shader reference */
@@ -33,14 +35,28 @@ export declare class SkySettings {
33
35
  /** Bloom settings */
34
36
  export declare class BloomSettings {
35
37
  enabled: boolean;
36
- kernelSize: number;
37
38
  passes: number;
38
39
  threshold: number;
39
40
  intensity: number;
41
+ width: number;
42
+ }
43
+ /** Tonemapping mode enum */
44
+ export declare enum TonemappingMode {
45
+ /** No tonemapping */
46
+ None = "none",
47
+ /** Tonemapping with a polynomial fit of the ACES transform */
48
+ ACES = "aces",
49
+ /** Tonemapping with a simpler fit of the ACES transform */
50
+ ACESApproximated = "aces approximated",
51
+ /** Tonemapping with the global Reinhard operator */
52
+ Reinhard = "reinhard",
53
+ /** Tonemapping with an exponential curve */
54
+ Exponential = "exponential"
40
55
  }
41
56
  /** HDR settings */
42
57
  export declare class HdrSettings {
43
58
  exposure: number;
59
+ tonemapping: TonemappingMode;
44
60
  }
45
61
  /** Texture streaming settings */
46
62
  export declare class TextureStreamingSettings {
@@ -436,6 +452,7 @@ export declare class MeshComponent {
436
452
  material: MaterialReference;
437
453
  mesh: MeshReference;
438
454
  skin: SkinReference;
455
+ morphTargets: MorphTargetsReference;
439
456
  }
440
457
  /** Text effect type enum */
441
458
  export declare enum TextEffectType {
@@ -445,7 +462,7 @@ export declare enum TextEffectType {
445
462
  /** 'text' component configuration */
446
463
  export declare class TextComponent {
447
464
  alignment: string;
448
- justification: string;
465
+ verticalAlignment: string;
449
466
  characterSpacing: number;
450
467
  lineSpacing: number;
451
468
  effect: TextEffectType;
@@ -624,7 +641,7 @@ export declare class LanguageResource {
624
641
  };
625
642
  }
626
643
  /**
627
- * @brief Access to Wonderland Editor's data
644
+ * Access to Wonderland Editor's data.
628
645
  *
629
646
  * Hold control and hover any field in Wonderland Editor to see its JSON path.
630
647
  * The path is equivalent to how you find the matching chain of properties.
package/dist/data.js CHANGED
@@ -13,14 +13,29 @@ export class SkySettings {
13
13
  /** Bloom settings */
14
14
  export class BloomSettings {
15
15
  enabled = false;
16
- kernelSize = 6;
17
- passes = 1;
16
+ passes = 3;
18
17
  threshold = 1.25;
19
18
  intensity = 2.0;
20
- }
19
+ width = 0.5;
20
+ }
21
+ /** Tonemapping mode enum */
22
+ export var TonemappingMode;
23
+ (function (TonemappingMode) {
24
+ /** No tonemapping */
25
+ TonemappingMode["None"] = "none";
26
+ /** Tonemapping with a polynomial fit of the ACES transform */
27
+ TonemappingMode["ACES"] = "aces";
28
+ /** Tonemapping with a simpler fit of the ACES transform */
29
+ TonemappingMode["ACESApproximated"] = "aces approximated";
30
+ /** Tonemapping with the global Reinhard operator */
31
+ TonemappingMode["Reinhard"] = "reinhard";
32
+ /** Tonemapping with an exponential curve */
33
+ TonemappingMode["Exponential"] = "exponential";
34
+ })(TonemappingMode || (TonemappingMode = {}));
21
35
  /** HDR settings */
22
36
  export class HdrSettings {
23
- exposure = 1.5;
37
+ exposure = 1.0;
38
+ tonemapping = TonemappingMode.Reinhard;
24
39
  }
25
40
  /** Texture streaming settings */
26
41
  export class TextureStreamingSettings {
@@ -433,6 +448,7 @@ export class MeshComponent {
433
448
  material = null;
434
449
  mesh = null;
435
450
  skin = null;
451
+ morphTargets = null;
436
452
  }
437
453
  /** Text effect type enum */
438
454
  export var TextEffectType;
@@ -443,7 +459,7 @@ export var TextEffectType;
443
459
  /** 'text' component configuration */
444
460
  export class TextComponent {
445
461
  alignment = 'center';
446
- justification = 'middle';
462
+ verticalAlignment = 'middle';
447
463
  characterSpacing = 0.0;
448
464
  lineSpacing = 1.2;
449
465
  effect = TextEffectType.None;
@@ -622,7 +638,7 @@ export class LanguageResource {
622
638
  strings = {};
623
639
  }
624
640
  /**
625
- * @brief Access to Wonderland Editor's data
641
+ * Access to Wonderland Editor's data.
626
642
  *
627
643
  * Hold control and hover any field in Wonderland Editor to see its JSON path.
628
644
  * The path is equivalent to how you find the matching chain of properties.
package/dist/native.d.ts CHANGED
@@ -7,14 +7,19 @@ interface NativeToolsAPI {
7
7
  }
8
8
  interface NativeUiAPI {
9
9
  freeImage(id: number): void;
10
- loadImage(path: string, cb: (id: number) => void): void;
10
+ loadImage(data: ArrayBuffer): [number, number];
11
11
  text(text: string): void;
12
12
  label(text: string): void;
13
13
  button(label: string): boolean;
14
14
  image(id: number, width: number, height: number): boolean;
15
15
  inputText(label: string, value: string): string | null;
16
+ checkbox(label: string, value: boolean): boolean | null;
17
+ colorEdit4(label: string, value: Float32Array): boolean;
16
18
  dummy(width: number, height: number): void;
17
19
  sameLine(offset: number): void;
20
+ separator(): void;
21
+ beginGroup(): void;
22
+ endGroup(): void;
18
23
  }
19
24
  declare global {
20
25
  function _wl_internalBinding(moduleName: 'tools'): NativeToolsAPI;
package/dist/tools.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /** @hidden */
2
+ export declare function awaitJob(jobId: number): Promise<void>;
1
3
  /**
2
4
  * Package the current project
3
5
  * @param destDir Destination directory into which to package, default `'<project-root>/deploy'`.
package/dist/tools.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const tools = _wl_internalBinding('tools');
2
- function awaitJob(jobId) {
2
+ /** @hidden */
3
+ export function awaitJob(jobId) {
3
4
  return new Promise((resolve, reject) => {
4
5
  tools.awaitJob(jobId, (success) => {
5
6
  if (success)
package/dist/ui.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" resolution-mode="require"/>
1
2
  /** Image to be used in the {@ref Ui}. */
2
3
  export declare class UiImage {
3
4
  _id: number;
@@ -17,7 +18,7 @@ export declare const label: (text: string) => void;
17
18
  * @example
18
19
  * In a draw function of a plugin, use as follows:
19
20
  * ```ts
20
- * if(WLE.button('Click me!')) {
21
+ * if(ui.button('Click me!')) {
21
22
  * console.log('You clicked the button.');
22
23
  * }
23
24
  * ```
@@ -33,21 +34,67 @@ export declare const button: (label: string) => boolean;
33
34
  * In a draw function of a plugin, use as follows:
34
35
  * ```ts
35
36
  * this.thumbnail = null;
36
- * loadUiImage("cache/plugins/my-plugin/downloads/thumbnail.png")
37
+ * loadImage(fs.readFileSync("cache/plugins/my-plugin/downloads/thumbnail.png"))
37
38
  * .then((img) => this.thumbnail = img);
38
39
  * ```
39
40
  *
40
41
  * @see image()
41
42
  */
42
- export declare function loadUiImage(filepath: string): Promise<UiImage>;
43
+ export declare function loadImage(data: ArrayBuffer | Buffer): Promise<UiImage>;
43
44
  export declare function image(image: UiImage, width: number, height: number): boolean;
44
45
  /**
45
46
  * Text input field.
46
47
  *
47
- * @usage
48
- * s = ui.inputText("change this:", s) || s;
48
+ * @param label Label to display next to the field.
49
+ * @param value Current value to set the field to.
50
+ * @returns The new string value when changed by the user this frame, otherwise `null`.
51
+ *
52
+ * @example
53
+ * s = ui.inputText("change this:", s) || s;
49
54
  */
50
55
  export declare const inputText: (label: string, value: string) => string | null;
51
- export declare function inputColor4(label: string, value: ArrayLike<number>): boolean;
56
+ /**
57
+ * Checkbox.
58
+ *
59
+ * @param label Label to display next to the checkbox.
60
+ * @param value Current value to set the checkbox to.
61
+ * @returns The new boolean value when changed by the user this frame, otherwise `null`.
62
+ *
63
+ * @example
64
+ * const n = ui.checkbox("change this:", myBool);
65
+ * if(n !== null) myBool = n;
66
+ */
67
+ export declare const checkbox: (label: string, value: boolean) => boolean | null;
68
+ /**
69
+ * Color picker for RGBA color.
70
+ *
71
+ * @param label Label to display next to the picker.
72
+ * @param value Value to be in-place edited.
73
+ * @returns `true` if changed by the user this frame, `false` otherwise.
74
+ *
75
+ * @example
76
+ * const col = new Float32Array(4);
77
+ * if(ui.colorEdit4("My color:", col)) {
78
+ * console.log("Changed!");
79
+ * }
80
+ */
81
+ export declare const colorEdit4: (label: string, value: Float32Array) => boolean;
82
+ /**
83
+ * Dummy element (space).
84
+ *
85
+ * @param width Width of the dummy element
86
+ * @param height Height of the dummy element
87
+ */
52
88
  export declare const dummy: (width: number, height: number) => void;
89
+ /**
90
+ * Draw next widget on the same line.
91
+ *
92
+ * @param offset Offset on the x axis.
93
+ */
53
94
  export declare const sameLine: (offset: number) => void;
95
+ /** Separator line. */
96
+ export declare const separator: () => void;
97
+ /** Begin a widget group. */
98
+ export declare const beginGroup: () => void;
99
+ /** End a widget group. */
100
+ export declare const endGroup: () => void;
package/dist/ui.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { awaitJob } from './tools.js';
1
2
  const ui = _wl_internalBinding('ui');
2
3
  /** Image to be used in the {@ref Ui}. */
3
4
  export class UiImage {
@@ -23,7 +24,7 @@ export const label = ui.label.bind(ui);
23
24
  * @example
24
25
  * In a draw function of a plugin, use as follows:
25
26
  * ```ts
26
- * if(WLE.button('Click me!')) {
27
+ * if(ui.button('Click me!')) {
27
28
  * console.log('You clicked the button.');
28
29
  * }
29
30
  * ```
@@ -39,41 +40,85 @@ export const button = ui.button.bind(ui);
39
40
  * In a draw function of a plugin, use as follows:
40
41
  * ```ts
41
42
  * this.thumbnail = null;
42
- * loadUiImage("cache/plugins/my-plugin/downloads/thumbnail.png")
43
+ * loadImage(fs.readFileSync("cache/plugins/my-plugin/downloads/thumbnail.png"))
43
44
  * .then((img) => this.thumbnail = img);
44
45
  * ```
45
46
  *
46
47
  * @see image()
47
48
  */
48
- export function loadUiImage(filepath) {
49
- // Wrapper around a GL::Texture. People will be tempted calling
50
- // this in weird places, so better just throw it on the JobSystem
51
- // for the MainThread and spread it over time.
52
- return new Promise((resolve, reject) => {
53
- ui.loadImage(filepath, (id) => {
54
- if (id < 0) {
55
- reject();
56
- return;
57
- }
58
- resolve(new UiImage(id));
59
- });
60
- });
49
+ export async function loadImage(data) {
50
+ if (!(data instanceof ArrayBuffer)) {
51
+ const converted = new Uint8Array(data.byteLength);
52
+ for (let i = 0; i < data.byteLength; ++i) {
53
+ converted[i] = data[i];
54
+ }
55
+ data = converted.buffer;
56
+ }
57
+ /* Wrapper around a GL::Texture. People will be tempted calling
58
+ * this in weird places, so better just throw it on the JobSystem
59
+ * for the MainThread and spread it over time. */
60
+ const [job, imageId] = ui.loadImage(data);
61
+ await awaitJob(job);
62
+ return new UiImage(imageId);
61
63
  }
62
64
  export function image(image, width, height) {
63
- // Since ImGui expects GL::Texture, we load the image for the user
64
- // from filepath. Avoids them pulling in pngjs and other mistakes
65
+ /* Since ImGui expects GL::Texture, we load the image for the user
66
+ * from filepath. Avoids them pulling in pngjs and other mistakes */
65
67
  return ui.image(image._id, width, height);
66
68
  }
67
69
  /**
68
70
  * Text input field.
69
71
  *
70
- * @usage
71
- * s = ui.inputText("change this:", s) || s;
72
+ * @param label Label to display next to the field.
73
+ * @param value Current value to set the field to.
74
+ * @returns The new string value when changed by the user this frame, otherwise `null`.
75
+ *
76
+ * @example
77
+ * s = ui.inputText("change this:", s) || s;
72
78
  */
73
79
  export const inputText = ui.inputText.bind(ui);
74
- export function inputColor4(label, value) {
75
- // We can in-place edit Float32Array, probably even number array
76
- return false;
77
- }
80
+ /**
81
+ * Checkbox.
82
+ *
83
+ * @param label Label to display next to the checkbox.
84
+ * @param value Current value to set the checkbox to.
85
+ * @returns The new boolean value when changed by the user this frame, otherwise `null`.
86
+ *
87
+ * @example
88
+ * const n = ui.checkbox("change this:", myBool);
89
+ * if(n !== null) myBool = n;
90
+ */
91
+ export const checkbox = ui.checkbox.bind(ui);
92
+ /**
93
+ * Color picker for RGBA color.
94
+ *
95
+ * @param label Label to display next to the picker.
96
+ * @param value Value to be in-place edited.
97
+ * @returns `true` if changed by the user this frame, `false` otherwise.
98
+ *
99
+ * @example
100
+ * const col = new Float32Array(4);
101
+ * if(ui.colorEdit4("My color:", col)) {
102
+ * console.log("Changed!");
103
+ * }
104
+ */
105
+ export const colorEdit4 = ui.colorEdit4.bind(ui);
106
+ /**
107
+ * Dummy element (space).
108
+ *
109
+ * @param width Width of the dummy element
110
+ * @param height Height of the dummy element
111
+ */
78
112
  export const dummy = ui.dummy.bind(ui);
113
+ /**
114
+ * Draw next widget on the same line.
115
+ *
116
+ * @param offset Offset on the x axis.
117
+ */
79
118
  export const sameLine = ui.sameLine.bind(ui);
119
+ /** Separator line. */
120
+ export const separator = ui.separator.bind(ui);
121
+ /** Begin a widget group. */
122
+ export const beginGroup = ui.beginGroup.bind(ui);
123
+ /** End a widget group. */
124
+ export const endGroup = ui.endGroup.bind(ui);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderlandengine/editor-api",
3
- "version": "1.2.0-dev.0",
3
+ "version": "1.2.0-dev.2",
4
4
  "description": "Wonderland Engine's Editor API for plugins - very experimental.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -24,23 +24,25 @@
24
24
  "url": "https://discord.wonderlandengine.com/"
25
25
  },
26
26
  "homepage": "https://wonderlandengine.com/editor/plugins/",
27
+ "prettier": "@wonderlandengine/prettier-config",
27
28
  "scripts": {
28
29
  "build": "tsc",
29
30
  "build:watch": "tsc --watch",
30
31
  "defaults": "npm run build && npm run doc && node scripts/generate-defaults.mjs ./doc.json",
31
- "pretty": "prettier --config ./prettierrc.json --write ./src",
32
+ "pretty": "prettier --write ./src",
33
+ "pretty:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
32
34
  "doc": "typedoc --entryPoints ./src/index.ts --tsconfig tsconfig.json --json ./doc.json",
33
- "json-diff": "npm run defaults && npx json-diff ../../src/WonderlandEditor/defaults.json defaults.json",
34
- "prepublishOnly": "npm run build"
35
+ "json-diff": "npm run defaults && npx json-diff ../../src/WonderlandEditor/Test/defaults.json defaults.json",
36
+ "prepack": "npm run build"
35
37
  },
36
- "peerDependencies": {},
37
38
  "devDependencies": {
38
39
  "@types/node": "^18.11.9",
40
+ "@wonderlandengine/prettier-config": "^1.0.0",
39
41
  "prettier": "^2.8.0",
40
42
  "typedoc": "^0.23.21",
41
43
  "typescript": "^4.9.3"
42
44
  },
43
45
  "files": [
44
- "dist"
46
+ "dist"
45
47
  ]
46
48
  }