@galacean/cli 2.0.0-alpha.11 → 2.0.0-alpha.14
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/cli.bundle.cjs +3171 -2951
- package/dist/viewport-client/_static/Accordion-3d330bc6.js +1 -0
- package/dist/viewport-client/_static/AmbientLightAsset-bdbc4e1d.js +5 -0
- package/dist/viewport-client/_static/AnimationClipAsset-9167378a.js +1 -0
- package/dist/viewport-client/_static/AnimatorControllerAsset-21dc6332.js +1 -0
- package/dist/viewport-client/_static/AnimatorStore-18d3c551.js +1 -0
- package/dist/viewport-client/_static/AssetViewer-64cd01fa.js +1 -0
- package/dist/viewport-client/_static/AudioAsset-0c828c80.js +1 -0
- package/dist/viewport-client/_static/AudioComponent-fbff3825.js +1 -0
- package/dist/viewport-client/_static/Callout-ba7e2adf.js +1 -0
- package/dist/viewport-client/_static/CameraComponent-74975570.js +1 -0
- package/dist/viewport-client/_static/Component-ed7aa0ab.js +1 -0
- package/dist/viewport-client/_static/DirectLight-b884e7db.js +1 -0
- package/dist/viewport-client/_static/FontAsset-d1ced18d.js +5 -0
- package/dist/viewport-client/_static/FormItemArray-6d69acd4.js +6 -0
- package/dist/viewport-client/_static/GlTFAsset-2723b84a.js +20 -0
- package/dist/viewport-client/_static/IconEdit-ab77303f.js +6 -0
- package/dist/viewport-client/_static/IconPointFilled-811fc660.js +6 -0
- package/dist/viewport-client/_static/LightBaseComponent-12dc27d1.js +1 -0
- package/dist/viewport-client/_static/LottieAnimationComponent-c48c5eb5.js +1 -0
- package/dist/viewport-client/_static/LottieAsset-3692580d.js +6 -0
- package/dist/viewport-client/_static/MarkdownAsset-bcb90be4.js +1 -0
- package/dist/viewport-client/_static/MaterialAsset-6ef9b4ed.js +1 -0
- package/dist/viewport-client/_static/MaterialInspector-e8242674.js +1 -0
- package/dist/viewport-client/_static/Menu-0b8da92f.js +17 -0
- package/dist/viewport-client/_static/MeshAsset-ca9305e5.js +1 -0
- package/dist/viewport-client/_static/MeshRendererBaseComponent-9efd3943.js +1 -0
- package/dist/viewport-client/_static/MeshRendererComponent-c9a03641.js +1 -0
- package/dist/viewport-client/_static/MeshThumbnail-ab28b3b8.js +1 -0
- package/dist/viewport-client/_static/ParticleRendererComponent-96947c1d.js +26 -0
- package/dist/viewport-client/_static/PhysicsMaterialAsset-4a1e5ea3.js +1 -0
- package/dist/viewport-client/_static/PhysicsStore-33cac578.js +1 -0
- package/dist/viewport-client/_static/PointLight-fd514526.js +1 -0
- package/dist/viewport-client/_static/PostProcessComponent-d0ea27a4.js +6 -0
- package/dist/viewport-client/_static/PrefabAsset-9179b95c.js +1 -0
- package/dist/viewport-client/_static/PrimitiveMesh-0572a073.js +1 -0
- package/dist/viewport-client/_static/ProxyConfigs-3a5fd860.js +1 -0
- package/dist/viewport-client/_static/ReferencedMaterial-5773c9d2.js +1 -0
- package/dist/viewport-client/_static/RenderTargetAsset-ab6e06d2.js +1 -0
- package/dist/viewport-client/_static/SceneAsset-385fa837.js +1 -0
- package/dist/viewport-client/_static/ShaderAsset-f4514b03.js +185 -0
- package/dist/viewport-client/_static/ShaderChunkAsset-34116f2c.js +5 -0
- package/dist/viewport-client/_static/ShaderUIScriptAsset-fc503291.js +516 -0
- package/dist/viewport-client/_static/SkinnedMeshRendererComponent-494ad439.js +1 -0
- package/dist/viewport-client/_static/SpineAnimationComponent-3918d7b5.js +1 -0
- package/dist/viewport-client/_static/SpineSkeletonDataAsset-27244892.js +1 -0
- package/dist/viewport-client/_static/SpotLight-f9972dc0.js +1 -0
- package/dist/viewport-client/_static/SpriteAsset-558ffca8.js +6 -0
- package/dist/viewport-client/_static/SpriteAtlasAsset-cdc34386.js +1 -0
- package/dist/viewport-client/_static/SpriteBaseComponent-3edafa31.js +1 -0
- package/dist/viewport-client/_static/SpriteMaskComponent-de2e5231.js +1 -0
- package/dist/viewport-client/_static/SpriteRendererComponent-e999e735.js +1 -0
- package/dist/viewport-client/_static/TaskQueue-05c94a4d.js +1 -0
- package/dist/viewport-client/_static/TextBaseComponent-ce1402c3.js +11 -0
- package/dist/viewport-client/_static/TextRendererComponent-f7c0deae.js +1 -0
- package/dist/viewport-client/_static/TextureAsset-39fb07fe.js +36 -0
- package/dist/viewport-client/_static/Tooltip-82063435.js +1 -0
- package/dist/viewport-client/_static/TrailRendererComponent-37f5c981.js +1 -0
- package/dist/viewport-client/_static/TransformBaseComponent-713d57e9.js +1 -0
- package/dist/viewport-client/_static/TransformComponent-40a57948.js +1 -0
- package/dist/viewport-client/_static/XRReferenceImageAsset-2f6ff226.js +1 -0
- package/dist/viewport-client/_static/assetEditorActions-c4e5962f.js +1 -0
- package/dist/viewport-client/_static/audio-7120ec91.js +1 -0
- package/dist/viewport-client/_static/bundlers-9b0d37fc.js +1 -0
- package/dist/viewport-client/_static/createOnModelChange-b57a0da8.js +1 -0
- package/dist/viewport-client/_static/encode-ac4bb64e.js +1 -0
- package/dist/viewport-client/_static/enum-58295f88.js +1 -0
- package/dist/viewport-client/_static/glTFIO-79bbca27.js +1 -0
- package/dist/viewport-client/_static/index-483b5738.js +1 -0
- package/dist/viewport-client/_static/index-74130ff3.js +1 -0
- package/dist/viewport-client/_static/index-78269e76.js +1 -0
- package/dist/viewport-client/_static/index-7834b582.js +1 -0
- package/dist/viewport-client/_static/index-7917f782.js +20 -0
- package/dist/viewport-client/_static/index-7acd49d2.js +1 -0
- package/dist/viewport-client/_static/index-9d3917da.js +1 -0
- package/dist/viewport-client/_static/index-a9b2675e.js +1 -0
- package/dist/viewport-client/_static/index-aec7e708.js +11487 -0
- package/dist/viewport-client/_static/index-b5582401.js +1 -0
- package/dist/viewport-client/_static/index-bfe6f30e.js +16 -0
- package/dist/viewport-client/_static/index-c63c9606.js +2 -0
- package/dist/viewport-client/_static/index-cd1fee9d.js +1 -0
- package/dist/viewport-client/_static/index-e73ceaed.js +1 -0
- package/dist/viewport-client/_static/index-e8a45e82.js +1 -0
- package/dist/viewport-client/_static/index-f2cb64af.js +1 -0
- package/dist/viewport-client/_static/index-fbe040bf.js +31 -0
- package/dist/viewport-client/_static/ktx2-encoder-53b21bdc.js +1 -0
- package/dist/viewport-client/_static/ktx2-worker-a04f41ea.js +1 -0
- package/dist/viewport-client/_static/meshopt_simplifier.module-cd99529d.js +1 -0
- package/dist/viewport-client/_static/module-220b3921.js +1 -0
- package/dist/viewport-client/_static/module-8816772d.js +1 -0
- package/dist/viewport-client/_static/module-ffeaf99f.js +56 -0
- package/dist/viewport-client/_static/postmen-2f47f6bb.js +1 -0
- package/dist/viewport-client/_static/scriptPropertyActions-d3a583d2.js +1 -0
- package/dist/viewport-client/index.html +20 -0
- package/package.json +2 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
var k=Object.defineProperty;var $=(i,e,r)=>e in i?k(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var g=(i,e,r)=>($(i,typeof e!="symbol"?e+"":e,r),r);import{aO as H,aQ as G,aS as T,e as A,C as l,bu as Q,aW as X,bv as z,bw as K,j as Z,u as q,bx as J,N as w,K as E,V as N,B as O,by as Y,bz as ee,bA as te,ao as L,bB as re,bC as se,a$ as ae,x as ie,bD as oe,n as ne,o as ce}from"./index-aec7e708.js";import"./index-e8a45e82.js";import{E as S,b as le,s as de}from"./ProxyConfigs-3a5fd860.js";import{I as pe}from"./IconPointFilled-811fc660.js";import{F as ue}from"./index-74130ff3.js";import{c as j,E as U,b as he}from"./ShaderUIScriptAsset-fc503291.js";H(pe,{variants:{checked:{true:{color:"$green10"}}}});const fe=G(i=>{const{asset:e}=i;if(e.compileError)return T.jsx(ue,{label:A("shader.inspector.compile-error"),value:e.compileError});const r=[],t={};for(const a of e.properties??[]){const{uiInfo:s}=a;if(!s||s.hide)continue;const o=s.assetType??s.type,n={label:s.label,type:l.PureDisplay,disabled:!0,value:a.bundleType==="macro"?"MACRO":o,property:a.prop};if(s.group){const c=t[a.uiInfo.group]??{children:[],type:l.Group,property:s.group};c.children.push(n),t[s.group]=c}else r.push(n)}for(const a in t)r.push(t[a]);return T.jsxs(T.Fragment,{children:[T.jsx(Q,{inspectorConfig:{property:A("shader.inspector.properties"),type:l.Group,children:r},onModelChange:null,model:e},"Properties"),e.shaderScriptRefId&&T.jsx(X.Item,{model:e,inspectorConfig:{label:A("shader.inspector.included-ui-script"),type:l.Display,disabled:!0,property:"uiScript",value:e.root.assetStore.assets[e.shaderScriptRefId.refId].getRouteString()},onModelChange:null})]})}),Se={Unlit:{filename:"UnlitShader.shader",uiScriptTemplateType:j.UnlitUIScript,uiScriptFileName:"UnlitScript.ts"},PBR:{filename:"PBRShader.shader",uiScriptTemplateType:j.PbrUIScript,uiScriptFileName:"PBRScript.ts"},Sprite:{filename:"SpriteShader.shader"}},me=`
|
|
2
|
+
RenderQueueType renderQueueType;
|
|
3
|
+
BlendFactor sourceColorBlendFactor;
|
|
4
|
+
BlendFactor destinationColorBlendFactor;
|
|
5
|
+
BlendFactor sourceAlphaBlendFactor;
|
|
6
|
+
BlendFactor destinationAlphaBlendFactor;
|
|
7
|
+
CullMode rasterStateCullMode;
|
|
8
|
+
Bool blendEnabled;
|
|
9
|
+
Bool depthWriteEnabled;
|
|
10
|
+
|
|
11
|
+
DepthState customDepthState {
|
|
12
|
+
WriteEnabled = depthWriteEnabled;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
BlendState customBlendState {
|
|
16
|
+
Enabled = blendEnabled;
|
|
17
|
+
SourceColorBlendFactor = sourceColorBlendFactor;
|
|
18
|
+
DestinationColorBlendFactor = destinationColorBlendFactor;
|
|
19
|
+
SourceAlphaBlendFactor = sourceAlphaBlendFactor;
|
|
20
|
+
DestinationAlphaBlendFactor = destinationAlphaBlendFactor;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
RasterState customRasterState {
|
|
24
|
+
CullMode = rasterStateCullMode;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
DepthState = customDepthState;
|
|
28
|
+
BlendState = customBlendState;
|
|
29
|
+
RasterState = customRasterState;
|
|
30
|
+
RenderQueueType = renderQueueType;
|
|
31
|
+
`,ge=i=>`Shader "${i}" {
|
|
32
|
+
SubShader "Default" {
|
|
33
|
+
Pass "Pass0" {
|
|
34
|
+
DepthState customDepthState {
|
|
35
|
+
WriteEnabled = false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
BlendState customBlendState {
|
|
39
|
+
Enabled = true;
|
|
40
|
+
SourceColorBlendFactor = BlendFactor.SourceAlpha;
|
|
41
|
+
DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
42
|
+
SourceAlphaBlendFactor = BlendFactor.One;
|
|
43
|
+
DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
|
|
44
|
+
ColorBlendOperation = BlendOperation.Add;
|
|
45
|
+
AlphaBlendOperation = BlendOperation.Add;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
RasterState customRasterState {
|
|
49
|
+
CullMode = CullMode.Off;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
RenderQueueType = Transparent;
|
|
53
|
+
DepthState = customDepthState;
|
|
54
|
+
BlendState = customBlendState;
|
|
55
|
+
RasterState = customRasterState;
|
|
56
|
+
|
|
57
|
+
struct Attributes {
|
|
58
|
+
vec3 POSITION;
|
|
59
|
+
vec2 TEXCOORD_0;
|
|
60
|
+
vec4 COLOR_0;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
struct Varyings {
|
|
64
|
+
vec2 uv;
|
|
65
|
+
vec4 color;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
#include "Common.glsl"
|
|
69
|
+
#include "Transform.glsl"
|
|
70
|
+
|
|
71
|
+
sampler2D renderer_SpriteTexture;
|
|
72
|
+
|
|
73
|
+
VertexShader = vert;
|
|
74
|
+
FragmentShader = frag;
|
|
75
|
+
|
|
76
|
+
Varyings vert(Attributes attr) {
|
|
77
|
+
Varyings v;
|
|
78
|
+
gl_Position = renderer_MVPMat * vec4(attr.POSITION, 1.0);
|
|
79
|
+
v.uv = attr.TEXCOORD_0;
|
|
80
|
+
v.color = attr.COLOR_0;
|
|
81
|
+
|
|
82
|
+
return v;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
void frag(Varyings v) {
|
|
86
|
+
vec4 baseColor = texture2DSRGB(renderer_SpriteTexture, v.uv);
|
|
87
|
+
gl_FragColor = baseColor * v.color;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}`,be=(i,e)=>`Shader "${i}" {
|
|
92
|
+
Editor {
|
|
93
|
+
Properties {
|
|
94
|
+
/**
|
|
95
|
+
* @language zh
|
|
96
|
+
* 主颜色
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @language en
|
|
101
|
+
* Main Color
|
|
102
|
+
*/
|
|
103
|
+
material_BaseColor("Main Color", Color) = (0, 0, 0, 1);
|
|
104
|
+
material_BaseTexture("Texture", Texture2D);
|
|
105
|
+
material_AlphaCutoff("Alpha Cutoff", Range(0, 1, 0.01)) = 0;
|
|
106
|
+
|
|
107
|
+
Header("Common"){
|
|
108
|
+
isTransparent("Transparent", Boolean) = false;
|
|
109
|
+
renderFace("Render Face", Enum(Front:0, Back:1, Double:2)) = 0;
|
|
110
|
+
blendMode("Blend Mode", Enum(Normal:0, Additive:1)) = 0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
UIScript "${e}";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
SubShader "Default" {
|
|
118
|
+
UsePass "pbr/Default/ShadowCaster"
|
|
119
|
+
|
|
120
|
+
Pass "Pass0" {
|
|
121
|
+
${me}
|
|
122
|
+
|
|
123
|
+
struct Attributes {
|
|
124
|
+
vec3 POSITION;
|
|
125
|
+
vec2 TEXCOORD_0;
|
|
126
|
+
vec4 JOINTS_0;
|
|
127
|
+
vec4 WEIGHTS_0;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
struct Varyings {
|
|
131
|
+
vec2 uv;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
#include "Common.glsl"
|
|
135
|
+
#include "Skin.glsl"
|
|
136
|
+
#include "Transform.glsl"
|
|
137
|
+
|
|
138
|
+
vec4 material_BaseColor;
|
|
139
|
+
float material_AlphaCutoff;
|
|
140
|
+
sampler2D material_BaseTexture;
|
|
141
|
+
|
|
142
|
+
VertexShader = vert;
|
|
143
|
+
FragmentShader = frag;
|
|
144
|
+
|
|
145
|
+
Varyings vert(Attributes attr) {
|
|
146
|
+
Varyings v;
|
|
147
|
+
|
|
148
|
+
vec4 position = vec4(attr.POSITION, 1.0);
|
|
149
|
+
|
|
150
|
+
// Skin
|
|
151
|
+
#ifdef RENDERER_HAS_SKIN
|
|
152
|
+
mat4 skinMatrix = getSkinMatrix(attr);
|
|
153
|
+
position = skinMatrix * position;
|
|
154
|
+
#endif
|
|
155
|
+
|
|
156
|
+
gl_Position = renderer_MVPMat * position;
|
|
157
|
+
v.uv = attr.TEXCOORD_0;
|
|
158
|
+
|
|
159
|
+
return v;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
void frag(Varyings v) {
|
|
163
|
+
vec4 baseColor = material_BaseColor;
|
|
164
|
+
|
|
165
|
+
#ifdef MATERIAL_HAS_BASETEXTURE
|
|
166
|
+
vec4 textureColor = texture2D(material_BaseTexture, v.uv);
|
|
167
|
+
baseColor *= textureColor;
|
|
168
|
+
#endif
|
|
169
|
+
|
|
170
|
+
#ifdef MATERIAL_IS_ALPHA_CUTOFF
|
|
171
|
+
if( baseColor.a < material_AlphaCutoff ) {
|
|
172
|
+
discard;
|
|
173
|
+
}
|
|
174
|
+
#endif
|
|
175
|
+
|
|
176
|
+
gl_FragColor = baseColor;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}`,_e=(i,e)=>z.replace("PBRShaderName",i).replace("UIScriptPath",e);function Ce(i,e){switch(e.template){case"PBR":return _e(i,e.uiScriptPath);case"Unlit":return be(i,e.uiScriptPath);case"Sprite":return ge(i)}}var W=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Ie=(i,e,r)=>e in i?W(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,P=(i,e,r,t)=>{for(var a=t>1?void 0:t?ye(e,r):e,s=i.length-1,o;s>=0;s--)(o=i[s])&&(a=(t?o(e,r,a):o(a))||a);return t&&a&&W(e,r,a),a},B=(i,e,r)=>(Ie(i,typeof e!="symbol"?e+"":e,r),r);K();var Me=(i=>(i.Color="Color",i.Vector4="Vector4",i.Vector3="Vector3",i.Vector2="Vector2",i.Int="Int",i.Float="Float",i.Range="Range",i.Texture2D="Texture2D",i.TextureCube="TextureCube",i.Boolean="Boolean",i.Null="Null",i.HDRColor="HDRColor",i))(Me||{});class x{constructor(e,r,t){g(this,"min");g(this,"max");g(this,"dragStep");this.min=e,this.max=r,this.dragStep=t}static create(e){const r=/Range\(\s*(.+?)\)/,t=e.match(r);if(!t)throw`invalid range type ${e}`;const a=t[1].split(",").map(Number);return new x(...a)}}class v{constructor(e,r){this.data=e,this.type=r}static create(e){const t=e.slice(5,-1).split(","),s=t[0].split(":").indexOf(".")===-1?S.Integer:S.Float,o=t.map(n=>{const[c,h]=n.split(":");return{label:c.trim(),value:Number(h)}});return new v(o,s)}}let d=class extends Z{constructor(e){super(e);g(this,"_shaderSource");g(this,"_shaderScriptRefId");g(this,"includePath");g(this,"builtinShaderName");g(this,"_compileError");g(this,"properties",[]);g(this,"_referencedMaterialList",[]);q(this)}get compileError(){return this._compileError}get shaderSource(){return this._shaderSource}get shaderScriptRefId(){return this._shaderScriptRefId}async initByMeta(e){await super.initByMeta(e),this.builtinShaderName=e.builtinShaderName}addReferencedMaterial(e){this._referencedMaterialList.findIndex(r=>r.id===e.id)===-1&&this._referencedMaterialList.push(e)}removeReferencedMaterial(e){if(!this._referencedMaterialList)return;const r=this._referencedMaterialList.findIndex(t=>t.id===e.id);r!==-1&&this._referencedMaterialList.splice(r,1)}updateShaderSourceName(){this.includePath=this.getRouteString(),this._shaderSource=this._shaderSource.replace(/Shader\s+"[^"]*"\s*{/,`Shader "${this.includePath}" {`),this.updateCode(this._shaderSource),this.saveMainAndMeta()}async rename(e){await super.rename(e),this.updateShaderSourceName();for(const r of this._referencedMaterialList)this.root.assetFacade.persistAssetMain(r.id)}async moveTo(e){await this.moveViaFacade(e),this.updateShaderSourceName();for(const r of this._referencedMaterialList)this.root.assetFacade.persistAssetMain(r.id)}async initByMain(e,r){const t=await e.text();this.includePath=this.getRouteString();const a=Object.values(this.root.assetStore.assets).filter(s=>s.meta.type==="ShaderChunk"||s.meta.subType===U.ShaderUI);await Promise.all(a.map(s=>s.loadMainFilePromise?s.loadMainFilePromise:s.loadMainFile())),this.updateCode(t)}async initByCreation(e,r,t){const a=t==null?void 0:t.template,s=Se[a];s&&this.setNameByIncrease(s.filename);const{uiScriptTemplateType:o,uiScriptFileName:n}=s;let c;return o&&(c=`./${(await this.root.assetFacade.createAssetByAdd({assetType:"script",params:{template:o,subType:U.ShaderUI},name:n,parentFolderId:this.parentFolderId})).name}`,window.Tracert.click("c351688.d418024",{type:"ShaderUIScript",source:"Shader"})),this._shaderSource=Ce(this.getRouteString(),{template:t.template,uiScriptPath:c}),Promise.resolve(this.getMainData())}getMainData(){return this._shaderSource}isBuiltinShader(){return this.builtinShaderName}parseEditorModule(){if(d._editorModuleRegex.test(this._shaderSource)){const e=this.extractPropertyContent("Editor");this.parseShaderScript(e);const r=this.extractPropertyContent("Properties",e);this.parseProperties(r);const t=this.extractPropertyContent("Macros",e);this.parseMacros(t)}else{const e=this.extractPropertyContent("EditorProperties");this.parseProperties(e);const r=this.extractPropertyContent("EditorMacros");this.parseMacros(r)}}parseProperties(e){if(!e)return;const r=e.split(`
|
|
181
|
+
`);let t,a;for(let s=0;s<r.length;s++){const o=r[s],n=o.trim();if(n.startsWith("/**")){a=a??{};let h="",b="default";const _=C=>{const u=C.match(d._commentsLineRegex);if(u!=null&&u[1]){const p=u[1].match(d._langSpecification);p!=null&&p[1]?b=p[1]:h+=u[1]+`
|
|
182
|
+
`}else h+=u?"":C+`
|
|
183
|
+
`};let R=n.substring(2);for(;!R.startsWith("*/");)_(R),R=r[++s].trim();a[b]=h;continue}const c=n.match(d._groupRegex);c?t={type:c[1],title:c[2]}:o&&(this.parsePropertyItem(o,a,t),a=void 0),n.endsWith("}")&&(t=void 0)}}parseMacros(e){if(!e)return;const r=e.split(`
|
|
184
|
+
`);let t;for(const a of r){const s=a.trim(),o=s.match(d._groupRegex);o?t={type:o[1],title:o[2]}:this.parseMacroItem(a,t),s.endsWith("}")&&(t=void 0)}}parseShaderScript(e){const r=e.match(d._scriptRegex),t=r==null?void 0:r[1];if(t){const a=this.getRouteString(!1),s=J(a,t),o=he.assetsMap.get(s);if(o){if(o.addReferencedShader(this),this._shaderScriptRefId){const n=this.root.assetStore.assets[this._shaderScriptRefId.refId];n==null||n.removeReferencedShader(this)}}else{this._compileError+=`
|
|
185
|
+
Not found shader script in ${t}`;return}this._shaderScriptRefId={refId:o.id}}else{const a=this._shaderScriptRefId;if(a){const s=this.root.assetStore.assets[a.refId];s==null||s.removeReferencedShader(this)}this._shaderScriptRefId=void 0}}extractPropertyContent(e,r){let t=0,a=-1,s=-1;const o=r??this._shaderSource;for(let n=0;n<o.length;n++)if(/\W/.test(o[n-1])&&o.substring(n,n+e.length)===e&&(a=n+e.length),!(a<0)){if(o[n]==="{")t++;else if(o[n]==="}"&&--t===0){s=n+1;break}}if(a>=0)return o.substring(a,s+1)}parseMacroItem(e,r){const t=/^\s*?(\[(On|Off)\])?\s*?(\w+)\(\s*?"([\u4e00-\u9fa5_a-zA-Z0-9\s]+)"\s*?(,\s*?(Range\(.+?\)|\w+))?\s*\)(\s*=\s*([^;]+))?/,a=e.match(t);if(a){const[s,o,n,c,h,b,_,R,C]=a;let u;_!=null&&_.trim().startsWith("Range(")?u=x.create(_):u=_??"Null";const p=this._shaderScriptRefId?this.root.assetStore.assets[this._shaderScriptRefId.refId]:void 0,I=this.parsePropertyValueAndUIType(u,!0,C);if(I){const D={prop:c,defaultValue:I.defaultValue,bundleType:"macro",engineType:I.engineType,uiInfo:{label:h,group:r==null?void 0:r.title,...I.uiInfo},macroInfo:{checked:n?n==="On":void 0,switchable:!0,onSwitch:(f,m)=>{const y=m.engineObject.shaderData,M=m.extraData.disabledMacros??[],F=M.indexOf(c)??-1;f?(y.enableMacro(c),F!==-1&&(M.splice(F,1),this.root.assetFacade.persistAssetMeta(m.id))):(y.disableMacro(c),F===-1&&(M.push(c),m.extraData.disabledMacros=M,this.root.assetFacade.persistAssetMeta(m.id)));const V=p==null?void 0:p.getMacroCallback(c);V&&(V(m.engineObject,f,void 0),m.refreshFormConfig(this.properties,m._getMainData()))}},onChange:async(f,m,y)=>{const M=p==null?void 0:p.getMacroCallback(c);M&&(M(f.engineObject,y,y),f.refreshFormConfig(this.properties,f._getMainData())),f.engineObject.shaderData.enableMacro(c,y)}};this.properties.push(D)}}}parsePropertyItem(e,r,t){const a=/^\s*?(\w+)\(\s*?"([\u4e00-\u9fa5_a-zA-Z0-9\s]+)"\s*?,\s*?(\w+|Range\(.+?\)|Enum\([^()]+\))\s*\)(\s*=\s*([^;]+))?/,o=e.replace(/\/\/.*\n/,"").trim().match(a);if(o){const[n,c,h,b,_,R]=o;let C;b.startsWith("Range(")?C=x.create(b):b.startsWith("Enum(")?C=v.create(b):C=b;const u=this._shaderScriptRefId?this.root.assetStore.assets[this._shaderScriptRefId.refId]:void 0,p=this.parsePropertyValueAndUIType(C,!1,R);p&&this.properties.push({prop:c,defaultValue:p.defaultValue,onChange:async(I,D,f)=>{const m=u==null?void 0:u.getPropertyCallback(D);if(m){let y=f;f!=null&&f.refId&&(y=(await this.root.assetStore.getAssetByRef(f)).engineObject),m(I.engineObject,y),I.refreshFormConfig(this.properties,I._getMainData())}},uiInfo:{label:h,group:t==null?void 0:t.title,collapsible:(t==null?void 0:t.type)==="Collapsible",comments:r,...p.uiInfo},engineType:p.engineType})}}parsePropertyValueAndUIType(e,r,t){if(e instanceof x)return{defaultValue:t?Number(t):void 0,uiInfo:{type:l.Slider,...e},engineType:S.Float};if(e instanceof v)return{defaultValue:t?Number(t):void 0,uiInfo:{type:l.Select,options:e.data},engineType:e.type};const a=s=>{var o;return(o=s.match(/\((.*?)\)/))==null?void 0:o[1]};switch(e){case"Color":return{defaultValue:t?new O(...a(t).split(",").map(Number)):new O,uiInfo:{type:l.Color},engineType:S.Color};case"HDRColor":{const s=a(t).split(",").map(Number);return{defaultValue:t?{r:s[0],g:s[1],b:s[2],a:s[3],intensity:s[4]??Math.max(s[0],s[1],s[2],1)}:{r:0,g:0,b:0,a:1,intensity:1},uiInfo:{type:l.Color,mode:"hdr"},engineType:S.Color}}case"Vector4":return{defaultValue:t?new N(...a(t).split(",").map(Number)):new N,uiInfo:{type:l.Vector4},engineType:S.Vector4};case"Vector3":return{defaultValue:t?new E(...a(t).split(",").map(Number)):new E,uiInfo:{type:l.Vector3},engineType:S.Vector3};case"Vector2":return{defaultValue:t?new w(...a(t).split(",").map(Number)):new w,uiInfo:{type:l.Vector2},engineType:S.Vector2};case"Int":return{defaultValue:t?Number(t):0,uiInfo:{type:l.Number},engineType:S.Integer};case"Float":return{defaultValue:t?Number(t):0,uiInfo:{type:l.Number},engineType:S.Float};case"Texture2D":return{defaultValue:t,uiInfo:{type:l.AssetPicker,assetType:"Texture",customFilter:s=>s.shape!=="Cube"},engineType:S.Texture};case"TextureCube":return{defaultValue:t,uiInfo:{type:l.AssetPicker,assetType:"Texture",customFilter:s=>s.shape==="Cube"},engineType:S.Texture};case"Boolean":return{defaultValue:t==="true",uiInfo:{type:l.Boolean},engineType:S.Boolean};case"Null":return{defaultValue:null,uiInfo:{type:l.Null}};default:throw`not support type ${e}`}}onDoubleClick(){if(this.locked){Y.error("Cannot edit internal Shader");return}ee(this.root.projectStore.id,this.id),te()}reCompile(){this.updateCode(this._shaderSource)}updateCode(e){var o;this._shaderSource=e,this._originMainFile=new File([e],this._name);const r=this.isBuiltinShader(),{properties:t}=this;let a;t?(a=Array.from(this.properties),this.properties.length=0):a=[];let s=[];if(r)this.bindEngineObject(L.find(r)),this.properties=le.filter(n=>n.when?n.when(this.name):!0);else{(o=this.engineObject)==null||o.destroy(!0);const n=L.create(this._shaderSource,re.GLSLES100,this.includePath);this.bindEngineObject(n),this.parseEditorModule();const c=this.properties;if(!c)s=a;else for(const h of a)c.findIndex(_=>_.prop===h.prop)===-1&&s.push(h)}this.refreshMaterial(s)}destroy(){const e=this.root.assetStore.assets[d.ErrorShaderRefId];for(const r of this._referencedMaterialList)r.bindShaderAsset(e),r.engineObject.shaderData.setColor("material_BaseColor",new O(1,0,1.01,1)),this.root.assetFacade.persistAssetMain(r.id);if(this.properties=null,this._referencedMaterialList=null,this.engineObject&&!this.isBuiltinShader()&&this.engineObject.destroy(!0),this._shaderScriptRefId){const r=this.root.assetStore.assets[this._shaderScriptRefId.refId];if(r){const t=r.referencedShaderList,a=t.findIndex(s=>s.id===this.id);a!==-1&&t.splice(a,1)}}super.destroy()}refreshMaterial(e){for(const r of this._referencedMaterialList)if(!r.engineObject.destroyed){if(e)for(const t of e){const{shaderData:a}=r.engineObject;if(t.bundleType==="macro")a.disableMacro(t.prop);else{const s=se.getByName(t.prop);t==null||t.onChange(r,t.prop,void 0),de(r,t.prop,void 0,t.engineType),delete a._propertyValueMap[s._uniqueId]}}r.applyBoundPathChange("shader",l.AssetPicker,this.getCurrentRef()),r.bindShaderAsset(this,r._getMainData()).then(()=>{if(e)for(const t of e)for(const a of this._referencedMaterialList)a[t.prop]=void 0})}}};B(d,"ErrorShaderRefId","0000508");B(d,"_groupRegex",/\b(Header|Collapsible)\s*\(\s*"([\w\s]+)"\s*\)/);B(d,"_scriptRegex",/^\s*UIScript\s+"([\w./]+)"/m);B(d,"_editorModuleRegex",/\bEditor\s*{/);B(d,"_commentsLineRegex",/^\s*\*\s*(.*)?$/);B(d,"_langSpecification",/@language\s+(\w+)/);P([ae()],d.prototype,"builtinShaderName",2);P([ie],d.prototype,"_compileError",2);P([oe],d.prototype,"compileError",1);d=P([ne({type:"Shader",label:A("asset.shader.title"),defaultName:"Shader.shader",icon:"shader",extname:"shader",importMenuConfig:{type:ce.Add},bundle({content:i}){return{content:new Blob([i],{type:"text/plain; charset=utf-8"})}},customInspector:fe})],d);export{Me as E,Se as S,x as a,v as b,d as c};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var T=Object.defineProperty;var j=(s,e,t)=>e in s?T(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var m=(s,e,t)=>(j(s,typeof e!="symbol"?e+"":e,t),t);import{L as D}from"./module-ffeaf99f.js";import{aO as R,aQ as w,aU as x,aS as h,bN as O,q as A,j as v,a$ as F,x as P,m as M,n as _,e as b,c5 as $,u as E,c6 as d,bz as B,bA as L,p as k,C as U,o as z}from"./index-aec7e708.js";import{u as N}from"./index-e8a45e82.js";import"./postmen-2f47f6bb.js";import{F as S}from"./index-74130ff3.js";import{F as q}from"./FormItemArray-6d69acd4.js";import{s as Q}from"./SpineSkeletonDataAsset-27244892.js";const V=R("div",{marginTop:"20px",fontSize:"12px",fontWeight:500,color:"$gray12"}),W=w(function(s){const{asset:{textures:e,textureAtlas:t,missingTexture:r}}=s,{assetStore:o}=N(),[l,a]=x.useState([]),u=x.useMemo(()=>{if(!t)return[];const n=t.pages,i=[];for(let p=0;p<n.length;p+=1){const c=n[p];i.push({name:c.name,regions:c.regions.map(C=>C.name)})}return i},[t]);return x.useEffect(()=>{let n=!1;return Promise.all(e.map(i=>o.getAssetByRef(i))).then(i=>{n||a(i)}).catch(i=>{n||(console.warn("[SpineAtlasInspector] Failed to load atlas textures:",i),a([]))}),()=>{n=!0}},[o,e]),r?h.jsx(V,{children:"Missing atlas texture, please reupload atlas and image files."}):h.jsxs(h.Fragment,{children:[h.jsx(S,{label:"atlas textures",value:""}),l.map((n,i)=>h.jsx(O,{dropLayer:A.Texture,label:"",value:n.name,assets:[],asset:n,onLocate:()=>{var c;const p=(c=e==null?void 0:e[i])==null?void 0:c.refId;p&&o.selectAsset(p)}},n.id)),h.jsx(S,{label:"atlas regions",value:""}),h.jsx(q,{label:"",items:u.map((n,i)=>({removable:!1,children:n.regions.map(c=>h.jsx(S,{label:"",value:c},c)),id:`${i}`,name:n.name}))})]})});var G=Object.defineProperty,H=Object.getOwnPropertyDescriptor,g=(s,e,t,r)=>{for(var o=r>1?void 0:r?H(e,t):e,l=s.length-1,a;l>=0;l--)(a=s[l])&&(o=(r?a(e,t,o):a(o))||o);return r&&o&&G(e,t,o),o};let f=class extends v{constructor(e){super(e);m(this,"_textureAtlas");m(this,"textures",[]);m(this,"atlasText","");m(this,"missingTexture",!1)}get textureAtlas(){return this._textureAtlas}async initByMain(e){this.atlasText=await e.text();const t=this.meta,{textures:r}=t;this.textures=r;const l=(await Promise.all(this.textures.map(n=>this.root.assetStore.getAssetByRef(n)))).map(n=>n==null?void 0:n.engineObject),a=l.some(n=>n==null)||r.length===0;if(this.missingTexture=a,a)return;const u=D.createTextureAtlas(this.atlasText,l);this._textureAtlas=u}};g([F(),P],f.prototype,"textures",2);g([M()],f.prototype,"atlasText",2);g([P],f.prototype,"missingTexture",2);f=g([_({type:"SpineAtlas",label:b("asset.spine-atlas.title"),dragLayer:A.SpineAtlas,customInspector:W,loaderType:"SpineAtlas",preUpload:Q,bundle(s){return s.dependencies=$(s.meta,["textures"]),{content:s.content}}})],f);function J(s){return`// ${s}
|
|
2
|
+
float function() {
|
|
3
|
+
return 3.1415926;
|
|
4
|
+
}
|
|
5
|
+
`}var X=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,I=(s,e,t,r)=>{for(var o=r>1?void 0:r?Y(e,t):e,l=s.length-1,a;l>=0;l--)(a=s[l])&&(o=(r?a(e,t,o):a(o))||o);return r&&o&&X(e,t,o),o};function Z(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}let y=class extends v{constructor(e){super(e);m(this,"_shaderSource");E(this)}get includePath(){const e=this.getTempRoutes();return e.push(this._name),e.join("/")}initByCreation(e,t,r){return this._shaderSource=J(this.name),Promise.resolve(this.getMainData())}getMainData(){return this._shaderSource}async initByMain(e,t){const r=await e.text();this.updateCode(r)}async rename(e){const t=this.includePath;d.unRegisterInclude(t),await super.rename(e),d.registerInclude(this.includePath,this._shaderSource),this.refreshIncludedShaders(t)}async moveTo(e){const t=this.includePath;d.unRegisterInclude(t),await this.moveViaFacade(e),d.registerInclude(this.includePath,this._shaderSource),this.refreshIncludedShaders(t)}updateCode(e,t){const r=this.includePath;d.unRegisterInclude(r),d.registerInclude(r,e),this._shaderSource=e,this.refreshIncludedShaders(void 0,t)}beforeDelete(){this.path&&d.unRegisterInclude(this.path),this.refreshIncludedShaders()}refreshIncludedShaders(e,t=new Set){if(t.has(this.id))return;t.add(this.id);let r;if(e){const a=e.split("/");r=a[a.length-1]}else r=this._name;const o=new RegExp(`#include\\s+"[^"]*${Z(r)}"`),l=Object.values(this.root.assetStore.assets).filter(a=>{if(a.meta.type!=="Shader"&&a.meta.type!=="ShaderChunk")return!1;const u=this.getAssetSource(a);return o.test(u)});for(const a of l){if(t.has(a.id))continue;if(a.meta.type==="ShaderChunk"){const n=a,i=n.getMainData();n.updateCode(typeof i=="string"?i:"",t);continue}const u=a;u.updateCode(u.shaderSource)}}getAssetSource(e){if(e.meta.type==="Shader")return e.shaderSource;if(e.meta.type==="ShaderChunk"){const t=e.getMainData();return typeof t=="string"?t:""}return""}onDoubleClick(){B(this.root.projectStore.id,this.id),L()}};I([k({type:U.Input,label:b("shader.chunk.include-path"),disabled:!0})],y.prototype,"includePath",1);y=I([_({type:"ShaderChunk",label:b("shader.chunk.title"),defaultName:"ShaderChunk.glsl",icon:"shader",extname:"glsl",importMenuConfig:{type:z.Add},bundle({content:s}){return{content:new Blob([s],{type:"text/plain; charset=utf-8"})}}})],y);export{f as S,y as a};
|