@wonderlandengine/editor-api 1.2.0-dev.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/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # Wonderland Editor JavaScript Plugin API
2
+
3
+ (Experimental!) API to extend the Wonderland Editor with JavaScript or TypeScript.
4
+
5
+ **Note:** This package requires the upcoming 1.2.0 version of Wonderland Engine.
6
+
7
+ Learn more about Wonderland Engine in the [documentation](https://wonderlandengine.com/editor/plugins/).
8
+
9
+ # How to use
10
+
11
+ Create a new plugin project:
12
+ ```sh
13
+ npm init
14
+ ```
15
+
16
+ Add a "wonderlandengine" key in your `package.json`. Now install the API:
17
+
18
+ ```sh
19
+ npm i --save @wonderlandengine/editor-api
20
+ ```
21
+
22
+ And create your first plugin!
23
+
24
+ That plugin can be used in any Wonderland Engine project by [installing the directory](https://wonderlandengine.com/editor/plugins#development).
package/dist/data.d.ts ADDED
@@ -0,0 +1,671 @@
1
+ /** Object reference */
2
+ export type ObjectReference = string | null;
3
+ /** Mesh reference */
4
+ export type MeshReference = string | null;
5
+ /** Texture reference */
6
+ export type TextureReference = string | null;
7
+ /** Shader reference */
8
+ export type ShaderReference = string | null;
9
+ /** Font reference */
10
+ export type FontReference = string | null;
11
+ /** Pipeline reference */
12
+ export type PipelineReference = string | null;
13
+ /** Material reference */
14
+ export type MaterialReference = string | null;
15
+ /** Skin reference */
16
+ export type SkinReference = string | null;
17
+ /** Image reference */
18
+ export type ImageReference = string | null;
19
+ /** Animation reference */
20
+ export type AnimationReference = string | null;
21
+ /** Project settings */
22
+ export declare class ProjectSettings {
23
+ name: string;
24
+ customIndexHtml: boolean;
25
+ extraFilesFolder: string;
26
+ packageForStreaming: boolean;
27
+ }
28
+ /** Sky settings */
29
+ export declare class SkySettings {
30
+ enabled: boolean;
31
+ material: MaterialReference;
32
+ }
33
+ /** Bloom settings */
34
+ export declare class BloomSettings {
35
+ enabled: boolean;
36
+ kernelSize: number;
37
+ passes: number;
38
+ threshold: number;
39
+ intensity: number;
40
+ }
41
+ /** HDR settings */
42
+ export declare class HdrSettings {
43
+ exposure: number;
44
+ }
45
+ /** Texture streaming settings */
46
+ export declare class TextureStreamingSettings {
47
+ maxCacheSize: number;
48
+ maxUploadPerFrame: number;
49
+ }
50
+ /** Rendering settings */
51
+ export declare class RenderingSettings {
52
+ textureAtlasSize: number[];
53
+ compressedTextureAtlasSize: number[];
54
+ clearColor: number[];
55
+ maxShadows: number;
56
+ usePreZ: boolean;
57
+ useMultiDraw: boolean;
58
+ useFrustumCulling: boolean;
59
+ sky: SkySettings;
60
+ bloom: BloomSettings;
61
+ hdr: HdrSettings;
62
+ textureStreaming: TextureStreamingSettings;
63
+ }
64
+ /** Camera settings */
65
+ export declare class CameraSettings {
66
+ near: number;
67
+ far: number;
68
+ }
69
+ /** Editor settings */
70
+ export declare class EditorSettings {
71
+ serverPort: number;
72
+ serverCOEP: string;
73
+ camera: CameraSettings;
74
+ ids: string;
75
+ }
76
+ /** Plugins settings */
77
+ export declare class PluginsSettings {
78
+ }
79
+ /** WebXR feature flags */
80
+ export interface WebXRFeatureFlags {
81
+ local: boolean;
82
+ 'local-floor': boolean;
83
+ 'bounded-floor': boolean;
84
+ unbounded: boolean;
85
+ 'hand-tracking': boolean;
86
+ 'hit-test': boolean;
87
+ 'plane-detection': boolean;
88
+ 'light-estimation': boolean;
89
+ anchors: boolean;
90
+ occlusion: boolean;
91
+ 'marker-tracking': boolean;
92
+ extraFeatures: string;
93
+ }
94
+ /** WebXR settings */
95
+ export declare class WebXRSettings {
96
+ optionalFeatures: WebXRFeatureFlags;
97
+ requiredFeatures: WebXRFeatureFlags;
98
+ }
99
+ /** PWA settings */
100
+ export declare class PWASettings {
101
+ enable: boolean;
102
+ customServiceWorker: boolean;
103
+ customManifest: boolean;
104
+ display: 'fullscreen' | 'standalone' | 'minimal-ui' | 'browser';
105
+ ovrPackageName: string;
106
+ appIcon: ImageReference;
107
+ }
108
+ /** Runtime settings */
109
+ export declare class RuntimeSettings {
110
+ visualizeColliders: boolean;
111
+ visualizePhysX: boolean;
112
+ visualizeOverdraw: boolean;
113
+ googleAnalytics: string;
114
+ googleAnalyticsSecondary: string;
115
+ enableRuntimeGltf: boolean;
116
+ viewObject: ObjectReference;
117
+ webxr: WebXRSettings;
118
+ xrButtonColor: string;
119
+ pwa: PWASettings;
120
+ }
121
+ /** Bundling type enum */
122
+ export declare enum BundlingType {
123
+ None = "none",
124
+ Esbuild = "esbuild",
125
+ Npm = "npm"
126
+ }
127
+ /** Scripting settings */
128
+ export declare class ScriptingSettings {
129
+ sourcePaths: never[];
130
+ libraryPaths: never[];
131
+ bundlingType: BundlingType;
132
+ npmScript: string;
133
+ esbuildFlags: string;
134
+ entryPoint: string;
135
+ }
136
+ /** VR settings */
137
+ export declare class VRSettings {
138
+ enable: boolean;
139
+ rightEyeObject: ObjectReference;
140
+ leftEyeObject: ObjectReference;
141
+ framebufferScaleFactor: number;
142
+ }
143
+ /** Physics settings */
144
+ export declare class PhysXSettings {
145
+ enable: boolean;
146
+ maxTimestep: number;
147
+ contactOffset: number;
148
+ restOffset: number;
149
+ groupNames: {
150
+ '0': string;
151
+ '1': string;
152
+ '2': string;
153
+ '3': string;
154
+ '4': string;
155
+ '5': string;
156
+ '6': string;
157
+ '7': string;
158
+ };
159
+ gravity: number[];
160
+ lengthToleranceScale: number;
161
+ speedToleranceScale: number;
162
+ }
163
+ /** AR settings */
164
+ export declare class ARSettings {
165
+ enable: boolean;
166
+ }
167
+ /** Localization settings */
168
+ export declare class LocalizationSettings {
169
+ enableZipCompression: boolean;
170
+ format: 'i18next';
171
+ languagesFolder: string;
172
+ defaultLanguage: string;
173
+ }
174
+ /** Settings for the currently open project */
175
+ export declare class Settings {
176
+ project: ProjectSettings;
177
+ rendering: RenderingSettings;
178
+ editor: EditorSettings;
179
+ runtime: RuntimeSettings;
180
+ scripting: ScriptingSettings;
181
+ plugins: PluginsSettings;
182
+ vr: VRSettings;
183
+ ar: ARSettings;
184
+ physx: PhysXSettings;
185
+ localization: LocalizationSettings;
186
+ }
187
+ /** Image compression type */
188
+ export declare enum ImageCompressionType {
189
+ None = "etc1s",
190
+ ETC1s = "etc1s",
191
+ UASTC = "uastc"
192
+ }
193
+ /** Image resource */
194
+ export declare class ImageResource {
195
+ name: string;
196
+ maxSize: number[];
197
+ compression: ImageCompressionType;
198
+ stream: boolean;
199
+ isProbe: boolean;
200
+ isSpecularProbe: boolean;
201
+ }
202
+ /** Texture resource */
203
+ export declare class TextureResource {
204
+ name: string;
205
+ image: ImageReference;
206
+ type: number;
207
+ minFilter: number;
208
+ magFilter: number;
209
+ mipFilter: number;
210
+ wrapping: number[];
211
+ }
212
+ /** Shader stage enum */
213
+ export declare enum ShaderStage {
214
+ Fragment = "fragment",
215
+ Vertex = "vertex"
216
+ }
217
+ /** Shader type enum */
218
+ export declare enum ShaderType {
219
+ Forward = "forward",
220
+ Fullscreen = "fullscreen"
221
+ }
222
+ /** Shader resource */
223
+ export declare class ShaderResource {
224
+ name: string;
225
+ stage: ShaderStage;
226
+ type: ShaderType;
227
+ packageUnused: boolean;
228
+ }
229
+ /** Mesh resource */
230
+ export declare class MeshResource {
231
+ name: string;
232
+ simplify: boolean;
233
+ simplifyTarget: number;
234
+ simplifyTargetError: number;
235
+ importScaling: number;
236
+ }
237
+ /** Material properties for the default Phong pipeline */
238
+ export declare class PhongMaterial {
239
+ ambientColor: number[];
240
+ diffuseTexture: TextureReference;
241
+ diffuseColor: number[];
242
+ specularColor: number[];
243
+ emissiveTexture: TextureReference;
244
+ emissiveColor: number[];
245
+ fogColor: number[];
246
+ normalTexture: TextureReference;
247
+ lightmapTexture: TextureReference;
248
+ lightmapFactor: number;
249
+ shininess: number;
250
+ alphaMaskThreshold: number;
251
+ alphaMaskTexture: TextureReference;
252
+ }
253
+ /** Material properties for the default Phong pipeline */
254
+ export declare class PhysicalMaterial {
255
+ albedoColor: number[];
256
+ emissiveTexture: TextureReference;
257
+ emissiveColor: number[];
258
+ albedoTexture: TextureReference;
259
+ metallicFactor: number;
260
+ roughnessFactor: number;
261
+ roughnessMetallicTexture: TextureReference;
262
+ specularProbeTexture: TextureReference;
263
+ irradianceProbeTexture: TextureReference;
264
+ normalTexture: TextureReference;
265
+ occlusionTexture: TextureReference;
266
+ occlusionFactor: number;
267
+ alphaMaskThreshold: number;
268
+ alphaMaskTexture: TextureReference;
269
+ }
270
+ /** Material properties for the default MeshVisualizer pipeline */
271
+ export declare class MeshVisualizerMaterial {
272
+ color: number[];
273
+ wireframeColor: number[];
274
+ }
275
+ /** Material properties for the default Flat pipeline */
276
+ export declare class FlatMaterial {
277
+ color: number[];
278
+ flatTexture: TextureReference;
279
+ alphaMaskThreshold: number;
280
+ alphaMaskTexture: TextureReference;
281
+ }
282
+ /** Material properties for the default Particle pipeline */
283
+ export declare class ParticleMaterial {
284
+ color: number[];
285
+ mainTexture: TextureReference;
286
+ noiseTexture: TextureReference;
287
+ offsetX: number;
288
+ offsetY: number;
289
+ }
290
+ /** Material properties for the default DistanceFieldVector pipeline */
291
+ export declare class DistanceFieldVectorMaterial {
292
+ color: number[];
293
+ outlineColor: number[];
294
+ outlineRange: number[];
295
+ vectorTexture: TextureReference;
296
+ smoothness: number;
297
+ }
298
+ /** Material properties for the default Text pipeline */
299
+ export declare class TextMaterial {
300
+ color: number[];
301
+ effectColor: number[];
302
+ font: FontReference;
303
+ }
304
+ /** Material properties for the default Sky pipeline */
305
+ export declare class SkyMaterial {
306
+ colorStop0: number[];
307
+ colorStop1: number[];
308
+ colorStop2: number[];
309
+ colorStop3: number[];
310
+ texture: TextureReference;
311
+ }
312
+ /** Material properties for the default Background pipeline */
313
+ export declare class BackgroundMaterial {
314
+ colorStop0: number[];
315
+ colorStop1: number[];
316
+ colorStop2: number[];
317
+ colorStop3: number[];
318
+ texture: TextureReference;
319
+ }
320
+ /** Material properties for the default Particle pipeline */
321
+ export declare class MaterialResource {
322
+ pipeline: PipelineReference;
323
+ name: string;
324
+ Phong?: PhongMaterial;
325
+ Physical?: PhysicalMaterial;
326
+ MeshVisualizer?: MeshVisualizerMaterial;
327
+ Flat?: FlatMaterial;
328
+ Particle?: ParticleMaterial;
329
+ DistanceFieldVector?: DistanceFieldVectorMaterial;
330
+ Text?: TextMaterial;
331
+ Sky?: SkyMaterial;
332
+ Background?: BackgroundMaterial;
333
+ }
334
+ /** 'animation' component configuration */
335
+ export declare class AnimationComponent {
336
+ preview: boolean;
337
+ retarget: boolean;
338
+ autoplay: boolean;
339
+ playCount: number;
340
+ speed: number;
341
+ skin: SkinReference;
342
+ animation: AnimationReference;
343
+ }
344
+ /** Light type enum */
345
+ export declare enum LightType {
346
+ /** Point light type */
347
+ Point = "point",
348
+ /** Spot light type */
349
+ Spot = "spot",
350
+ /** Sun light type */
351
+ Sun = "sun"
352
+ }
353
+ /** 'light' component configuration */
354
+ export declare class LightComponent {
355
+ type: LightType;
356
+ color: number[];
357
+ intensity: number;
358
+ shadowRange: number;
359
+ outerAngle: number;
360
+ innerAngle: number;
361
+ shadows: boolean;
362
+ shadowBias: number;
363
+ shadowNormalBias: number;
364
+ shadowTexelSize: number;
365
+ cascadeCount: number;
366
+ }
367
+ /** 'view' component configuration */
368
+ export declare class ViewComponent {
369
+ fov: number;
370
+ near: number;
371
+ far: number;
372
+ }
373
+ /** Settings for a sphere physics shape */
374
+ export declare class PhysXSphereConfig {
375
+ radius: number;
376
+ }
377
+ /** Settings for a box physics shape */
378
+ export declare class PhysXBoxConfig {
379
+ extents: number[];
380
+ }
381
+ /** Settings for a capsule physics shape */
382
+ export declare class PhysXCapsuleConfig {
383
+ radius: number;
384
+ halfHeight: number;
385
+ }
386
+ /** Settings for a triangle mesh physics shape */
387
+ export declare class PhysXTriangleMeshConfig {
388
+ mesh: MeshReference;
389
+ scaling: number[];
390
+ }
391
+ /** Settings for a convex mesh physics shape */
392
+ export declare class PhysXConvexMeshConfig {
393
+ mesh: MeshReference;
394
+ scaling: number[];
395
+ }
396
+ /** Physics shape type enum */
397
+ export declare enum PhysXShapeType {
398
+ Sphere = "sphere",
399
+ Box = "box",
400
+ Capsule = "capsule",
401
+ TriangleMesh = "triangleMesh",
402
+ ConvexMesh = "convexMesh"
403
+ }
404
+ /** 'physx' component configuration */
405
+ export declare class PhysXComponent {
406
+ static: boolean;
407
+ kinematic: boolean;
408
+ simulate: boolean;
409
+ allowQuery: boolean;
410
+ allowSimulation: boolean;
411
+ mass: number;
412
+ shape: PhysXShapeType;
413
+ sphere?: PhysXSphereConfig;
414
+ box?: PhysXBoxConfig;
415
+ capsule?: PhysXCapsuleConfig;
416
+ triangleMesh?: PhysXTriangleMeshConfig;
417
+ convexMesh?: PhysXConvexMeshConfig;
418
+ linearDamping: number;
419
+ angularDamping: number;
420
+ staticFriction: number;
421
+ dynamicFriction: number;
422
+ bounciness: number;
423
+ gravity: boolean;
424
+ trigger: boolean;
425
+ block: number;
426
+ groups: number;
427
+ lockAxis: number;
428
+ sleepOnActivate: boolean;
429
+ translationOffset: number[];
430
+ rotationOffset: number[];
431
+ solverPositionIterations: number;
432
+ solverVelocityIterations: number;
433
+ }
434
+ /** 'mesh' component configuration */
435
+ export declare class MeshComponent {
436
+ material: MaterialReference;
437
+ mesh: MeshReference;
438
+ skin: SkinReference;
439
+ }
440
+ /** Text effect type enum */
441
+ export declare enum TextEffectType {
442
+ None = "none",
443
+ Outline = "outline"
444
+ }
445
+ /** 'text' component configuration */
446
+ export declare class TextComponent {
447
+ alignment: string;
448
+ justification: string;
449
+ characterSpacing: number;
450
+ lineSpacing: number;
451
+ effect: TextEffectType;
452
+ text: string;
453
+ material: MaterialReference;
454
+ }
455
+ /** Settings for a sphere collider */
456
+ export declare class SphereConfig {
457
+ radius: number;
458
+ }
459
+ /** Settings for a AxisAlignedBoundingBox collider */
460
+ export declare class AABBConfig {
461
+ extents: number[];
462
+ }
463
+ /** Settings for a box collider */
464
+ export declare class BoxConfig {
465
+ extents: number[];
466
+ }
467
+ /** 'collision' component configuration */
468
+ export declare class CollisionComponent {
469
+ collider: 'sphere' | 'aabb' | 'box';
470
+ sphere?: SphereConfig;
471
+ aabb?: AABBConfig;
472
+ box?: BoxConfig;
473
+ groups: number;
474
+ }
475
+ /** Input type enum */
476
+ export declare enum InputType {
477
+ Head = "head",
478
+ EyeLeft = "eye left",
479
+ EyeRight = "eye right",
480
+ HandLeft = "hand left",
481
+ HandRight = "hand right",
482
+ RayLeft = "ray left",
483
+ RayRight = "ray right"
484
+ }
485
+ /** 'input' component configuration */
486
+ export declare class InputComponent {
487
+ type: InputType;
488
+ }
489
+ export declare class AnimationEvent {
490
+ time: number;
491
+ name: string;
492
+ }
493
+ /** Animation resource */
494
+ export declare class AnimationResource {
495
+ /** Name of the animation */
496
+ name: string;
497
+ /** Whether to compress the animation */
498
+ pack: boolean;
499
+ /** Targets influenced per track */
500
+ targets: ObjectReference[];
501
+ /** Animation events track */
502
+ events: AnimationEvent[];
503
+ }
504
+ /** Component configuration */
505
+ export declare class ComponentConfig {
506
+ /** Component type */
507
+ type: string | null;
508
+ /** Whether the component is active */
509
+ active: boolean;
510
+ /** Configuration for animation components */
511
+ animation?: AnimationComponent;
512
+ /** Configuration for collision components */
513
+ collision?: CollisionComponent;
514
+ /** Configuration for input components */
515
+ input?: InputComponent;
516
+ /** Configuration for light components */
517
+ light?: LightComponent;
518
+ /** Configuration for mesh components */
519
+ mesh?: MeshComponent;
520
+ /** Configuration for physx components */
521
+ physx?: PhysXComponent;
522
+ /** Configuration for text components */
523
+ text?: TextComponent;
524
+ /** Configuration for view components */
525
+ view?: ViewComponent;
526
+ }
527
+ /** Object resource */
528
+ export declare class ObjectResource {
529
+ /** Name of the object */
530
+ name: string;
531
+ /** Translation vector */
532
+ translation: number[];
533
+ /** Rotation quaternion */
534
+ rotation: number[];
535
+ /** Scaling vector */
536
+ scaling: number[];
537
+ /** Parent object, or null if parent is root */
538
+ parent: ObjectReference;
539
+ /** Skin this object is part of, or `null`, if not a joint. */
540
+ skin: SkinReference;
541
+ /** List of components on this object */
542
+ components: ComponentConfig[];
543
+ }
544
+ /** Skin resource */
545
+ export declare class SkinResource {
546
+ /** Name of the skin */
547
+ name: string;
548
+ /** List of objects that make up the joints of this skin */
549
+ joints: ObjectReference[];
550
+ }
551
+ /** Blend function enum for {@link PipelineResource} */
552
+ export declare enum BlendFunction {
553
+ Zero = "zero",
554
+ One = "one",
555
+ SourceColor = "source color",
556
+ OnceMinusSourceColor = "one minus source color",
557
+ SourceAlpha = "source alpha",
558
+ SourceAlphaSaturate = "source alpha saturate",
559
+ OneMinusSourceAlpha = "one minus source alpha",
560
+ DestinationColor = "destination color",
561
+ OneMinusDestinationColor = "one minus destination color",
562
+ DestinationAlpha = "destination alpha",
563
+ OneMinusDestinationAlpha = "one minus destination alpha"
564
+ }
565
+ /** Blend equation enum for {@link PipelineResource} */
566
+ export declare enum BlendEquation {
567
+ Add = "add",
568
+ Subtract = "subtract",
569
+ ReverseSubtract = "reverse subtract",
570
+ Min = "min",
571
+ Max = "max"
572
+ }
573
+ /** Depth function enum for {@link PipelineResource} */
574
+ export declare enum DepthFunction {
575
+ Never = "never",
576
+ Always = "always",
577
+ Less = "less",
578
+ LessOrEqual = "less or equal",
579
+ Equal = "equal",
580
+ NotEqual = "not equal",
581
+ GreaterOrEqual = "greater or equal",
582
+ Greater = "greater"
583
+ }
584
+ /** Pipeline resource */
585
+ export declare class PipelineResource {
586
+ name: string;
587
+ doubleSided: boolean;
588
+ castShadows: boolean;
589
+ depthTest: boolean;
590
+ depthWrite: boolean;
591
+ blending: boolean;
592
+ sampleAlphaToCoverage: boolean;
593
+ shader: ShaderReference;
594
+ viewVertexShader: ShaderReference;
595
+ features: {
596
+ [key: string]: boolean;
597
+ };
598
+ blendSrcRgb: BlendFunction;
599
+ blendSrcAlpha: BlendFunction;
600
+ blendDestRgb: BlendFunction;
601
+ blendDestAlpha: BlendFunction;
602
+ blendEqRgb: BlendEquation;
603
+ blendEqAlpha: BlendEquation;
604
+ depthFunction: DepthFunction;
605
+ }
606
+ /** Font resource */
607
+ export declare class FontResource {
608
+ /** Name of the font */
609
+ name: string;
610
+ /** Which characters need to be renderable with this font */
611
+ characters: string;
612
+ /** Whether to support the "outline" effect with this font */
613
+ outline: boolean;
614
+ /** Size of the outline */
615
+ outlineSize: number;
616
+ }
617
+ /** Language resource */
618
+ export declare class LanguageResource {
619
+ /** Name of the language */
620
+ name: string;
621
+ /** Custom terms */
622
+ strings: {
623
+ [key: string]: string;
624
+ };
625
+ }
626
+ /**
627
+ * @brief Access to Wonderland Editor's data
628
+ *
629
+ * Hold control and hover any field in Wonderland Editor to see its JSON path.
630
+ * The path is equivalent to how you find the matching chain of properties.
631
+ * @example
632
+ *
633
+ * ```
634
+ * /objects/123/components/0/text/text
635
+ * ```
636
+ *
637
+ * Will match the following code:
638
+ *
639
+ * ```ts
640
+ * WL.data.objects[123].components[0].text.text
641
+ * ```
642
+ */
643
+ export declare class EditorData {
644
+ /** Project settings */
645
+ settings: Settings;
646
+ /** List of scene file paths */
647
+ files: string[];
648
+ /** Animation resources */
649
+ animations: AnimationResource[];
650
+ /** Object resources */
651
+ objects: ObjectResource[];
652
+ /** Skin resources */
653
+ skins: SkinResource[];
654
+ /** Image resources */
655
+ images: ImageResource[];
656
+ /** Shader resources */
657
+ shaders: ShaderResource[];
658
+ /** Mesh resources */
659
+ meshes: MeshResource[];
660
+ /** Texture resources */
661
+ textures: TextureResource[];
662
+ /** Material resources */
663
+ materials: MaterialResource[];
664
+ /** Font resources */
665
+ fonts: FontResource[];
666
+ /** Pipeline resources */
667
+ pipelines: PipelineResource[];
668
+ /** Language resources */
669
+ languages: LanguageResource[];
670
+ }
671
+ export declare let data: EditorData;