UNPKG

@wonderlandengine/editor-api

Version:

Wonderland Engine's Editor API for plugins - very experimental.

841 lines (840 loc) 24.7 kB
export let data = (global._wl_internalBinding ?? (() => { }))('data'); /* Copy over the access functions to the base prototype */ let ApiObject = data ? Object.getPrototypeOf(Object.getPrototypeOf(data)) : null; /** Project type */ export var ProjectType; (function (ProjectType) { ProjectType["Website"] = "website"; ProjectType["Game"] = "game"; })(ProjectType || (ProjectType = {})); export function toValue(value) { if (ApiObject.isPrototypeOf(value)) return value.toValue(); else return value; } export var RecordType; (function (RecordType) { /** An object record */ RecordType[RecordType["Object"] = 0] = "Object"; /** An array of records */ RecordType[RecordType["Array"] = 1] = "Array"; /** A dictionary (key-value pairs) of records */ RecordType[RecordType["Dict"] = 2] = "Dict"; /** A dictionary (key-value pairs) of records with stable indices */ RecordType[RecordType["IdDict"] = 3] = "IdDict"; })(RecordType || (RecordType = {})); ; export class Access { recordType; exists; keys() { return Object.keys(this).filter((k) => this.exists(k)); } values() { return Object.keys(this) .filter((k) => this.exists(k)) .map((k) => toValue(this[k])); } entries() { return Object.entries(this) .filter(([k, v]) => this.exists(k)) .map(([k, v]) => [k, toValue(v)]); } toValue() { if (this.recordType() == RecordType.Array) return this.values(); else return Object.fromEntries(this.entries()); } toJSON() { return this.toValue(); } [Symbol.iterator]() { return Object.entries(this)[Symbol.iterator](); } } if (ApiObject) { Object.assign(ApiObject, { keys: Access.prototype.keys, values: Access.prototype.values, entries: Access.prototype.entries, toValue: Access.prototype.toValue, toJSON: Access.prototype.toJSON, [Symbol.iterator]: Access.prototype[Symbol.iterator], }); } /** Project settings */ export class ProjectSettings extends Access { name = ''; description = ''; type = ProjectType.Website; customIndexHtml = false; extraFilesFolder = 'static'; prefab = false; version = [1, 2, 0]; maxTexturesBinSize = 0; } /** Sky settings */ export class SkySettings extends Access { enabled = false; material = null; } /** Bloom settings */ export class BloomSettings extends Access { enabled = false; passes = 3; threshold = 1.25; intensity = 2.0; width = 0.5; } /** Tonemapping mode enum */ export var TonemappingMode; (function (TonemappingMode) { /** No tonemapping */ TonemappingMode["None"] = "none"; /** Tonemapping with a polynomial fit of the ACES transform */ TonemappingMode["ACES"] = "aces"; /** Tonemapping with a simpler fit of the ACES transform */ TonemappingMode["ACESApproximated"] = "aces approximated"; /** Tonemapping with the Khronos PBR Neutral Tone Mapper */ TonemappingMode["KhronosPBRNeutral"] = "khronos pbr neutral"; /** Tonemapping with the global Reinhard operator */ TonemappingMode["Reinhard"] = "reinhard"; /** Tonemapping with an exponential curve */ TonemappingMode["Exponential"] = "exponential"; })(TonemappingMode || (TonemappingMode = {})); /** HDR settings */ export class HdrSettings extends Access { exposure = 1.0; tonemapping = TonemappingMode.Reinhard; } /** Texture streaming settings */ export class TextureStreamingSettings extends Access { maxCacheSize = 1024; maxUploadPerFrame = 10; } export var EnvironmentMode; (function (EnvironmentMode) { EnvironmentMode["Disabled"] = "disabled"; EnvironmentMode["SphericalHarmonic0"] = "spherical-harmonic-0"; EnvironmentMode["SphericalHarmonic1"] = "spherical-harmonic-1"; EnvironmentMode["SphericalHarmonic2"] = "spherical-harmonic-2"; })(EnvironmentMode || (EnvironmentMode = {})); /** Environment settings */ export class EnvironmentSettings extends Access { enabled = false; image = null; mode = EnvironmentMode.Disabled; intensity = 1.0; bakeExposure = 1.0; tint = [1.0, 1.0, 1.0]; maxSpecularEnvironmentSize = 512; } /** Rendering settings */ export class RenderingSettings extends Access { api = 'webgl2'; textureAtlasSize = [8192, 4096]; compressedTextureAtlasSize = [16384, 8192]; clearColor = [0.168, 0.168, 0.168, 1.0]; maxShadows = 4; usePreZ = false; useMultiDraw = false; useFrustumCulling = true; useTextureStreaming = true; sky = new SkySettings(); bloom = new BloomSettings(); hdr = new HdrSettings(); textureStreaming = new TextureStreamingSettings(); environment = new EnvironmentSettings(); maxTextures = 1024; } /** Camera settings */ export class CameraSettings extends Access { near = 0.02; far = 100.0; } /** Editor settings */ export class EditorSettings extends Access { serverPort = 8080; serverCOEP = 'require-corp'; camera = new CameraSettings(); ids = 'incremental-number'; pluginsPaths = []; package = { packageUnusedMeshes: false, packageUnusedAnimations: false, supercompressionLevel: 8, }; importPhysicalAsPhongMaterials = true; } /** Plugins settings */ export class PluginsSettings extends Access { } /** PWA settings */ export class PWASettings extends Access { enable = false; customServiceWorker = false; customManifest = false; display = 'standalone'; ovrPackageName = ''; appIcon = null; } /** Runtime settings */ export class RuntimeSettings extends Access { visualizeColliders = false; visualizePhysX = false; visualizeOverdraw = false; googleAnalytics = ''; googleAnalyticsSecondary = ''; enableRuntimeGltf = false; viewObject = null; xrButtonColor = 'white'; pwa = new PWASettings(); } /** Bundling type enum */ export var BundlingType; (function (BundlingType) { BundlingType["None"] = "none"; BundlingType["Esbuild"] = "esbuild"; BundlingType["Npm"] = "npm"; })(BundlingType || (BundlingType = {})); /** Scripting settings */ export class ScriptingSettings extends Access { sourcePaths = []; libraryPaths = []; materialDefinitions = null; components = { bundling: 'esbuild', npmScript: 'build', esbuildFlags: '--format=esm --target=es2022 --external:@wonderlandengine/api', entryPoint: 'js/index.js', output: null, }; application = { bundling: 'esbuild', npmScript: 'build', esbuildFlags: '--format=esm --target=es2022 --external:@wonderlandengine/api', entryPoint: 'app.js', output: null, }; } /** VR settings */ export class VRSettings extends Access { enable = true; } /** AR settings */ export class ARSettings extends Access { enable = false; } /** WebXR settings */ export class WebXRSettings extends Access { framebufferScaleFactor = 1.0; offerSession = true; optionalFeatures = { 'local': true, 'local-floor': false, 'bounded-floor': false, 'unbounded': false, 'hand-tracking': true, 'hit-test': true, 'plane-detection': false, 'light-estimation': false, 'anchors': false, 'occlusion': false, 'marker-tracking': false, }; optionalFeaturesExtra = ''; requiredFeatures = { 'local': true, 'local-floor': false, 'bounded-floor': false, 'unbounded': false, 'hand-tracking': false, 'hit-test': false, 'plane-detection': false, 'light-estimation': false, 'anchors': false, 'occlusion': false, 'marker-tracking': false, }; requiredFeaturesExtra = ''; } /** XR settings */ export class XRSettings extends Access { vr = new VRSettings(); ar = new ARSettings(); webxr = new WebXRSettings(); leftEyeObject = null; rightEyeObject = null; } /** Physics settings */ export class PhysXSettings extends Access { enable = false; maxTimestep = 0.05; contactOffset = 0.02; restOffset = 0.0; groupNames = { '0': 'static', '1': 'dynamic', '2': 'ui', '3': 'nav', '4': 'player', '5': 'enemy', '6': 'group6', '7': 'group7', }; gravity = [0.0, -9.81, 0.0]; lengthToleranceScale = 1.0; speedToleranceScale = 10.0; } /** Localization settings */ export class LocalizationSettings extends Access { enableZipCompression = false; format = 'i18next'; languagesFolder = 'languages'; defaultLanguage = 'en'; } /** Image compression type */ export var ImageCompressionType; (function (ImageCompressionType) { ImageCompressionType["None"] = "etc1s"; ImageCompressionType["ETC1s"] = "etc1s"; ImageCompressionType["UASTC"] = "uastc"; })(ImageCompressionType || (ImageCompressionType = {})); export class Link extends Access { name = ''; file = ''; } export class Resource extends Access { name = ''; link = null; packageAlways = false; } /** Image resource */ export class ImageResource extends Resource { name = 'image'; maxSize = [8192, 8192]; compression = ImageCompressionType.ETC1s; stream = true; hdr = false; } /** Texture resource */ export class TextureResource extends Resource { name = 'texture'; image = null; type = 1; minFilter = 0; magFilter = 0; mipFilter = 0; wrapping = [0, 0, 0]; } /** Shader stage enum */ export var ShaderStage; (function (ShaderStage) { ShaderStage["Fragment"] = "fragment"; ShaderStage["Vertex"] = "vertex"; })(ShaderStage || (ShaderStage = {})); /** Shader type enum */ export var ShaderType; (function (ShaderType) { ShaderType["Forward"] = "forward"; ShaderType["Fullscreen"] = "fullscreen"; })(ShaderType || (ShaderType = {})); /** Shader resource */ export class ShaderResource extends Resource { name = 'shader'; stage = ShaderStage.Fragment; type = ShaderType.Forward; packageUnused = false; } /** Mesh resource */ export class MeshResource extends Resource { name = 'mesh'; simplify = false; simplifyTarget = 0.5; simplifyTargetError = 0.02; importScaling = 1.0; hasMorphTargets = false; } /** Material properties for the default Phong pipeline */ export class PhongMaterial extends Access { ambientColor = [0.05, 0.05, 0.05, 1.0]; diffuseTexture = null; diffuseColor = [1, 1, 1, 1.0]; specularColor = [1.0, 1.0, 1.0, 0.0]; emissiveTexture = null; emissiveColor = [0.0, 0.0, 0.0, 1.0]; fogColor = [1.0, 1.0, 1.0, 0.0]; normalTexture = null; lightmapTexture = null; lightmapFactor = 1.0; shininess = 2; alphaMaskThreshold = 0.5; alphaMaskTexture = null; } /** Material properties for the default Phong pipeline */ export class PhysicalMaterial extends Access { albedoColor = [1.0, 1.0, 1.0, 1.0]; emissiveTexture = null; emissiveColor = [0.0, 0.0, 0.0, 1.0]; fogColor = [1.0, 1.0, 1.0, 0.0]; albedoTexture = null; metallicFactor = 1.0; roughnessFactor = 1.0; occlusionRoughnessMetallicTexture = null; roughnessMetallicTexture = null; specularProbeTexture = null; irradianceProbeTexture = null; normalTexture = null; occlusionTexture = null; occlusionFactor = 1.0; alphaMaskThreshold = 0.5; alphaMaskTexture = null; } /** Material properties for the default MeshVisualizer pipeline */ export class MeshVisualizerMaterial extends Access { color = [0.5, 0.5, 0.5, 1]; wireframeColor = [1, 1, 1, 1]; } /** Material properties for the default Flat pipeline */ export class FlatMaterial extends Access { color = [1, 1, 1, 1]; flatTexture = null; alphaMaskThreshold = 0.5; alphaMaskTexture = null; } /** Material properties for the default Particle pipeline */ export class ParticleMaterial extends Access { color = [1, 1, 1, 1]; mainTexture = null; noiseTexture = null; offsetX = 0.0; offsetY = 0.0; } /** Material properties for the default DistanceFieldVector pipeline */ export class DistanceFieldVectorMaterial extends Access { color = [1, 1, 1, 1]; outlineColor = [0, 0, 0, 1]; outlineRange = [0.4, 0.3]; vectorTexture = null; smoothness = 0.02; } /** Material properties for the default Text pipeline */ export class TextMaterial extends Access { color = [1, 1, 1, 1]; effectColor = [0, 0, 0, 1]; font = null; } /** Material properties for the default Sky pipeline */ export class SkyMaterial extends Access { colorStop0 = [1, 1, 1, 1]; colorStop1 = [0.55, 0.95, 1, 1]; colorStop2 = [0.55, 0.95, 1, 1]; colorStop3 = [0.55, 0.95, 1, 1]; texture = null; } /** Material properties for the default Sky pipeline */ export class AtmosphericSkyMaterial extends Access { direction = [0.0, 1.0, 1.0]; exposure = 0.5; } /** Material properties for the default Background pipeline */ export class BackgroundMaterial extends Access { colorStop0 = [1, 1, 1, 1]; colorStop1 = [0.55, 0.95, 1, 1]; colorStop2 = [0.55, 0.95, 1, 1]; colorStop3 = [0.55, 0.95, 1, 1]; texture = null; } /** Material properties for the default Particle pipeline */ export class MaterialResource extends Resource { pipeline = null; name = 'material'; Phong; Physical; MeshVisualizer; Flat; Particle; DistanceFieldVector; Text; Sky; AtmosphericSky; Background; } /** Animation blending type */ export var AnimationBlendType; (function (AnimationBlendType) { AnimationBlendType["None"] = "none"; AnimationBlendType["Blend1D"] = "blend1D"; })(AnimationBlendType || (AnimationBlendType = {})); /** Root motion handling mode */ export var RootMotionMode; (function (RootMotionMode) { RootMotionMode["None"] = "none"; RootMotionMode["ApplyToOwner"] = "applyToOwner"; RootMotionMode["ScriptEvent"] = "scriptEvent"; })(RootMotionMode || (RootMotionMode = {})); /** 'animation' component */ export class AnimationComponent extends Access { preview = false; retarget = false; autoplay = false; playCount = 0; speed = 1.0; skin = null; animation = null; rootMotionMode = RootMotionMode.None; blendFactor = 0.0; blendType = AnimationBlendType.None; blendAnimations = { animations: [], playbackSpeeds: [] }; } /** Light type enum */ export var LightType; (function (LightType) { /** Point light type */ LightType["Point"] = "point"; /** Spot light type */ LightType["Spot"] = "spot"; /** Sun light type */ LightType["Sun"] = "sun"; })(LightType || (LightType = {})); /** 'light' component */ export class LightComponent extends Access { type = LightType.Point; color = [1.0, 1.0, 1.0]; intensity = 1; shadowRange = 10.0; outerAngle = 90; innerAngle = 45; shadows = false; shadowBias = 0.0012; shadowNormalBias = 0.001; shadowTexelSize = 1.0; cascadeCount = 4; } /** View projection type enum */ export var ProjectionType; (function (ProjectionType) { /** Perspective projection */ ProjectionType["Perspective"] = "perspective"; /** Orthographic projection */ ProjectionType["Orthographic"] = "orthographic"; })(ProjectionType || (ProjectionType = {})); /** 'view' component */ export class ViewComponent extends Access { projectionType = ProjectionType.Perspective; fov = 90; extent = 10; near = 0.01; far = 100; } /** Sphere physics shape */ export class PhysXSphere extends Access { radius = 0.25; } /** Box physics shape */ export class PhysXBox extends Access { extents = [0.25, 0.25, 0.25]; } /** Capsule physics shape */ export class PhysXCapsule extends Access { radius = 0.15; halfHeight = 0.25; } /** Triangle mesh physics shape */ export class PhysXTriangleMesh extends Access { mesh = null; scaling = [1, 1, 1]; } /** Convex mesh physics shape */ export class PhysXConvexMesh extends Access { mesh = null; scaling = [1, 1, 1]; } /** Physics shape type enum */ export var PhysXShapeType; (function (PhysXShapeType) { PhysXShapeType["Sphere"] = "sphere"; PhysXShapeType["Box"] = "box"; PhysXShapeType["Capsule"] = "capsule"; PhysXShapeType["TriangleMesh"] = "triangleMesh"; PhysXShapeType["ConvexMesh"] = "convexMesh"; })(PhysXShapeType || (PhysXShapeType = {})); /** 'physx' component */ export class PhysXComponent extends Access { static = false; kinematic = false; simulate = true; allowQuery = true; allowSimulation = true; mass = 1.0; shape = PhysXShapeType.Sphere; sphere; box; capsule; triangleMesh; convexMesh; linearDamping = 0.0; angularDamping = 0.05; staticFriction = 0.5; dynamicFriction = 0.5; bounciness = 0.5; gravity = true; trigger = false; block = 255; groups = 255; lockAxis = 0; sleepOnActivate = false; translationOffset = [0, 0, 0]; rotationOffset = [0, 0, 0, 1]; solverPositionIterations = 4; solverVelocityIterations = 1; } /** 'mesh' component */ export class MeshComponent extends Access { material = null; mesh = null; skin = null; morphTargets = null; morphTargetWeights = []; } /** Text effect type enum */ export var TextEffectType; (function (TextEffectType) { TextEffectType["None"] = "none"; TextEffectType["Outline"] = "outline"; TextEffectType["Shadow"] = "shadow"; })(TextEffectType || (TextEffectType = {})); /** Text wrap mode */ export var TextWrapMode; (function (TextWrapMode) { TextWrapMode["None"] = "none"; TextWrapMode["Soft"] = "soft"; TextWrapMode["Hard"] = "hard"; TextWrapMode["Clip"] = "clip"; })(TextWrapMode || (TextWrapMode = {})); /** 'text' component */ export class TextComponent extends Access { alignment = 'center'; verticalAlignment = 'middle'; justified = false; characterSpacing = 0.0; lineSpacing = 1.2; effect = TextEffectType.None; effectOffset = [0.0, 0.0]; text = 'Wonderland Engine'; material = 'DefaultFontMaterial'; wrapMode = TextWrapMode.None; wrapWidth = 0.0; } /** Sphere collider */ export class Sphere extends Access { radius = 1.0; } /** AxisAlignedBoundingBox collider */ export class AABB extends Access { extents = [1.0, 1.0, 1.0]; } /** Box collider */ export class Box extends Access { extents = [1.0, 1.0, 1.0]; } /** 'collision' component */ export class CollisionComponent extends Access { collider = 'sphere'; sphere; aabb; box; groups = 255; } /** Input type enum */ export var InputType; (function (InputType) { InputType["Head"] = "head"; InputType["EyeLeft"] = "eye left"; InputType["EyeRight"] = "eye right"; InputType["HandLeft"] = "hand left"; InputType["HandRight"] = "hand right"; InputType["RayLeft"] = "ray left"; InputType["RayRight"] = "ray right"; })(InputType || (InputType = {})); /** 'input' component */ export class InputComponent extends Access { type = InputType.Head; } /** 'particle-effect' component */ export class ParticleEffectComponent extends Access { particleEffect = null; } export class AnimationEvent extends Access { time = 0.0; name = ''; } export class RootMotion extends Access { target = null; translationAxis = 0; rotationAxis = 0; } /** Animation resource */ export class AnimationResource extends Resource { /** Name of the animation */ name = 'animation'; /** Whether to compress the animation */ pack = true; /** Targets influenced per track */ targets = []; /** Animation events track */ events = []; rootMotion; } /** Component */ export class ObjectComponent extends Access { /** Component type */ type = null; /** Whether the component is active */ active = true; /** Animation component */ animation; /** Collision component */ collision; /** Input component */ input; /** Light component */ light; /** Mesh component */ mesh; /** Physx component */ physx; /** Text component */ text; /** View component */ view; /** Particle effect component */ particleEffect; } /** Object resource */ export class ObjectResource extends Resource { /** Name of the object */ name = 'object'; /** Translation vector */ translation = [0, 0, 0]; /** Rotation quaternion */ rotation = [0, 0, 0, 1]; /** Scaling vector */ scaling = [1, 1, 1]; /** Parent object, or null if parent is root */ parent = null; /** Skin this object is part of, or `null`, if not a joint. */ skin = null; /** List of components on this object */ components = []; } /** Skin resource */ export class SkinResource extends Resource { /** Name of the skin */ name = 'skin'; /** List of objects that make up the joints of this skin */ joints = []; } /** Blend function enum for {@link PipelineResource} */ export var BlendFunction; (function (BlendFunction) { BlendFunction["Zero"] = "zero"; BlendFunction["One"] = "one"; BlendFunction["SourceColor"] = "source color"; BlendFunction["OnceMinusSourceColor"] = "one minus source color"; BlendFunction["SourceAlpha"] = "source alpha"; BlendFunction["SourceAlphaSaturate"] = "source alpha saturate"; BlendFunction["OneMinusSourceAlpha"] = "one minus source alpha"; BlendFunction["DestinationColor"] = "destination color"; BlendFunction["OneMinusDestinationColor"] = "one minus destination color"; BlendFunction["DestinationAlpha"] = "destination alpha"; BlendFunction["OneMinusDestinationAlpha"] = "one minus destination alpha"; })(BlendFunction || (BlendFunction = {})); /** Blend equation enum for {@link PipelineResource} */ export var BlendEquation; (function (BlendEquation) { BlendEquation["Add"] = "add"; BlendEquation["Subtract"] = "subtract"; BlendEquation["ReverseSubtract"] = "reverse subtract"; BlendEquation["Min"] = "min"; BlendEquation["Max"] = "max"; })(BlendEquation || (BlendEquation = {})); /** Depth function enum for {@link PipelineResource} */ export var DepthFunction; (function (DepthFunction) { DepthFunction["Never"] = "never"; DepthFunction["Always"] = "always"; DepthFunction["Less"] = "less"; DepthFunction["LessOrEqual"] = "less or equal"; DepthFunction["Equal"] = "equal"; DepthFunction["NotEqual"] = "not equal"; DepthFunction["GreaterOrEqual"] = "greater or equal"; DepthFunction["Greater"] = "greater"; })(DepthFunction || (DepthFunction = {})); /** Mesh sorting mode */ export var MeshSorting; (function (MeshSorting) { MeshSorting["None"] = "none"; MeshSorting["Z"] = "z"; MeshSorting["InverseZ"] = "inverse-z"; MeshSorting["MeshIndex"] = "mesh-index"; })(MeshSorting || (MeshSorting = {})); /** Pipeline resource */ export class PipelineResource extends Resource { name = 'pipeline'; doubleSided = false; castShadows = false; colorWrite = { red: true, green: true, blue: true, alpha: true, }; depthTest = true; depthWrite = true; blending = false; sampleAlphaToCoverage = false; shader = null; viewVertexShader = null; features = {}; meshSorting = MeshSorting.None; blendSrcRgb = BlendFunction.One; blendSrcAlpha = BlendFunction.One; blendDestRgb = BlendFunction.Zero; blendDestAlpha = BlendFunction.Zero; blendEqRgb = BlendEquation.Add; blendEqAlpha = BlendEquation.Add; depthFunction = DepthFunction.Less; } /** Font resource */ export class FontResource extends Resource { /** Name of the font */ name = 'font'; /** Which characters need to be renderable with this font */ characters = 'abcdefghijklmnopqrstuvwxyz\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n0123456789\n:-_+*,.!`"\'?°=\\/\n()[]<>{}$&%@|’‘ '; /** Whether to support the "outline" effect with this font */ outline = false; /** Size of the outline */ outlineSize = 0.1; } /** Language resource */ export class LanguageResource extends Resource { /** Name of the language */ name = 'language'; /** Whether this is the default language */ isDefault = false; } /** Particle effect resource */ export class ParticleEffectResource extends Resource { name = 'particleEffect'; } /** File resource */ export class FileResource extends Resource { fileName = ''; importerName = ''; importPhysicalAsPhongMaterials = true; } export class ResourceSection { }