@galacean/cli 2.0.0-alpha.10 → 2.0.0-alpha.12
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 +3083 -2856
- package/dist/viewport-client/_static/Accordion-4897319b.js +6 -0
- package/dist/viewport-client/_static/AmbientLightAsset-f70b95f1.js +5 -0
- package/dist/viewport-client/_static/AnimationClipAsset-01f3deb6.js +1 -0
- package/dist/viewport-client/_static/AnimatorControllerAsset-b7424e9c.js +1 -0
- package/dist/viewport-client/_static/AnimatorStore-fd98c00e.js +1 -0
- package/dist/viewport-client/_static/AssetPreviewer-24e31d97.js +6 -0
- package/dist/viewport-client/_static/AssetViewer-bc198e16.js +1 -0
- package/dist/viewport-client/_static/AudioAsset-eae03324.js +1 -0
- package/dist/viewport-client/_static/AudioComponent-44070c2c.js +1 -0
- package/dist/viewport-client/_static/Callout-cb4a55ff.js +1 -0
- package/dist/viewport-client/_static/CameraComponent-907ac745.js +1 -0
- package/dist/viewport-client/_static/CanvasRenderer-9dd98cb3.js +1 -0
- package/dist/viewport-client/_static/Component-f923abb1.js +1 -0
- package/dist/viewport-client/_static/DirectLight-58f5fe9e.js +1 -0
- package/dist/viewport-client/_static/FontAsset-abfb9a8a.js +5 -0
- package/dist/viewport-client/_static/FormItemArray-66be8701.js +1 -0
- package/dist/viewport-client/_static/GlTFAsset-9c68f862.js +20 -0
- package/dist/viewport-client/_static/IconPlayerPlayFilled-b058c98f.js +6 -0
- package/dist/viewport-client/_static/IconPointFilled-a304fd34.js +6 -0
- package/dist/viewport-client/_static/InstanceEditorAsset-a70e73fe.js +1 -0
- package/dist/viewport-client/_static/LightBaseComponent-fbc3ae49.js +1 -0
- package/dist/viewport-client/_static/LottieAnimationComponent-1c3e02a5.js +1 -0
- package/dist/viewport-client/_static/LottieAsset-377c1419.js +1 -0
- package/dist/viewport-client/_static/MarkdownAsset-7ea387a9.js +1 -0
- package/dist/viewport-client/_static/MaterialAsset-74a15124.js +1 -0
- package/dist/viewport-client/_static/MaterialInspector-aec1248b.js +1 -0
- package/dist/viewport-client/_static/Menu-cd3be298.js +17 -0
- package/dist/viewport-client/_static/MeshAsset-73e2cc8e.js +1 -0
- package/dist/viewport-client/_static/MeshRendererBaseComponent-3a0e09ed.js +1 -0
- package/dist/viewport-client/_static/MeshRendererComponent-5385d30f.js +1 -0
- package/dist/viewport-client/_static/MeshThumbnail-49273f71.js +1 -0
- package/dist/viewport-client/_static/ParticleRendererComponent-5a7b57d9.js +21 -0
- package/dist/viewport-client/_static/PhysicsMaterialAsset-a5ac9f82.js +1 -0
- package/dist/viewport-client/_static/PhysicsStore-0729e76d.js +1 -0
- package/dist/viewport-client/_static/PointLight-0e1d1546.js +1 -0
- package/dist/viewport-client/_static/PostProcessComponent-8276d33c.js +1 -0
- package/dist/viewport-client/_static/PrefabAsset-1a7edfbd.js +1 -0
- package/dist/viewport-client/_static/PrimitiveMesh-3ce6fa2f.js +1 -0
- package/dist/viewport-client/_static/ProxyConfigs-4de3304c.js +1 -0
- package/dist/viewport-client/_static/ReferencedMaterial-a87818f3.js +1 -0
- package/dist/viewport-client/_static/RenderTargetAsset-33c0d9e7.js +1 -0
- package/dist/viewport-client/_static/SceneAsset-8917c210.js +1 -0
- package/dist/viewport-client/_static/ShaderAsset-cb3ff628.js +185 -0
- package/dist/viewport-client/_static/ShaderChunkAsset-83f923f4.js +5 -0
- package/dist/viewport-client/_static/ShaderUIScriptAsset-d13fa4e2.js +516 -0
- package/dist/viewport-client/_static/SkinnedMeshRendererComponent-2a8323bf.js +1 -0
- package/dist/viewport-client/_static/SpineAnimationComponent-e733d50f.js +1 -0
- package/dist/viewport-client/_static/SpineSkeletonDataAsset-b64a3ee3.js +1 -0
- package/dist/viewport-client/_static/SpotLight-ca6c0c3b.js +1 -0
- package/dist/viewport-client/_static/SpriteAsset-9a31ec24.js +1 -0
- package/dist/viewport-client/_static/SpriteAtlasAsset-a862db46.js +1 -0
- package/dist/viewport-client/_static/SpriteBaseComponent-f6f1731f.js +1 -0
- package/dist/viewport-client/_static/SpriteMaskComponent-778be04f.js +1 -0
- package/dist/viewport-client/_static/SpriteRendererComponent-2b4d153b.js +1 -0
- package/dist/viewport-client/_static/TaskQueue-05c94a4d.js +1 -0
- package/dist/viewport-client/_static/TextBaseComponent-69233798.js +11 -0
- package/dist/viewport-client/_static/TextRendererComponent-130b4e99.js +1 -0
- package/dist/viewport-client/_static/TextureAsset-28fedf2a.js +36 -0
- package/dist/viewport-client/_static/ThumbnailMixin-35997457.js +1 -0
- package/dist/viewport-client/_static/ThumbnailRegistry-495c18c9.js +1 -0
- package/dist/viewport-client/_static/Tooltip-33f770ba.js +1 -0
- package/dist/viewport-client/_static/TrailRendererComponent-148550b5.js +1 -0
- package/dist/viewport-client/_static/TransformBaseComponent-02318c5a.js +1 -0
- package/dist/viewport-client/_static/TransformComponent-96106065.js +1 -0
- package/dist/viewport-client/_static/ViewerManager-202b570a.js +1 -0
- package/dist/viewport-client/_static/XRReferenceImageAsset-6a6adb3b.js +1 -0
- package/dist/viewport-client/_static/assetEditorActions-c4e5962f.js +1 -0
- package/dist/viewport-client/_static/audio-244358e2.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-45ff9a17.js +1 -0
- package/dist/viewport-client/_static/index-0a8702e2.js +11217 -0
- package/dist/viewport-client/_static/index-237c84cd.js +20 -0
- package/dist/viewport-client/_static/index-37c74ae9.js +26 -0
- package/dist/viewport-client/_static/index-4cca0201.js +1 -0
- package/dist/viewport-client/_static/index-59732f86.js +1 -0
- package/dist/viewport-client/_static/index-6c8198f6.js +2 -0
- package/dist/viewport-client/_static/index-6f827618.js +1 -0
- package/dist/viewport-client/_static/index-803ca489.js +1 -0
- package/dist/viewport-client/_static/index-85a6cf6a.js +1 -0
- package/dist/viewport-client/_static/index-98982ce2.js +1 -0
- package/dist/viewport-client/_static/index-b3d51f87.js +1 -0
- package/dist/viewport-client/_static/index-be6bc38a.js +177 -0
- package/dist/viewport-client/_static/index-c403cbcd.js +1 -0
- package/dist/viewport-client/_static/index-e46ec5b1.js +16 -0
- package/dist/viewport-client/_static/index-e73966ae.js +1 -0
- package/dist/viewport-client/_static/index-e95b4498.js +1 -0
- package/dist/viewport-client/_static/index-f5a67a46.js +1 -0
- package/dist/viewport-client/_static/ktx-parse.modern-6c9f771f.js +1 -0
- package/dist/viewport-client/_static/ktx2-encoder-1e63c1eb.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-107b7430.js +56 -0
- package/dist/viewport-client/_static/module-5c85b07e.js +1 -0
- package/dist/viewport-client/_static/module-6406b050.js +1 -0
- package/dist/viewport-client/_static/postmen-45d4c238.js +1 -0
- package/dist/viewport-client/_static/scriptPropertyActions-d3a583d2.js +1 -0
- package/dist/viewport-client/_static/utilities-e09052e3.js +11 -0
- package/dist/viewport-client/index.html +20 -0
- package/package.json +2 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
var W=Object.defineProperty;var H=(i,e,r)=>e in i?W(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var g=(i,e,r)=>(H(i,typeof e!="symbol"?e+"":e,r),r);import{aH as $,aT as G,aD as B,e as A,C as c,bh as Q,aY as X,bi as z,bj as Z,j as q,o as J,bk as K,I as E,H as w,V as N,x as O,bl as Y,bm as ee,ao as L,bn as te,bo as re,b0 as se,u as ae,bp as ie}from"./index-0a8702e2.js";import{a as oe,A as ne}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{E as m,b as le,s as ce}from"./ProxyConfigs-4de3304c.js";import{I as de}from"./IconPointFilled-a304fd34.js";import{F as pe}from"./index-98982ce2.js";import{c as j,E as U,b as ue}from"./ShaderUIScriptAsset-d13fa4e2.js";import{n as he}from"./index-be6bc38a.js";$(de,{variants:{checked:{true:{color:"$green10"}}}});const fe=G(i=>{const{asset:e}=i;if(e.compileError)return B.jsx(pe,{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:c.PureDisplay,disabled:!0,value:a.bundleType==="macro"?"MACRO":o,property:a.prop};if(s.group){const l=t[a.uiInfo.group]??{children:[],type:c.Group,property:s.group};l.children.push(n),t[s.group]=l}else r.push(n)}for(const a in t)r.push(t[a]);return B.jsxs(B.Fragment,{children:[B.jsx(Q,{inspectorConfig:{property:A("shader.inspector.properties"),type:c.Group,children:r},onModelChange:null,model:e},"Properties"),e.shaderScriptRefId&&B.jsx(X.Item,{model:e,inspectorConfig:{label:A("shader.inspector.included-ui-script"),type:c.Display,disabled:!0,property:"uiScript",value:e.root.assetStore.assets[e.shaderScriptRefId.refId].getRouteString()},onModelChange:null})]})}),me={Unlit:{filename:"UnlitShader.shader",uiScriptTemplateType:j.UnlitUIScript,uiScriptFileName:"UnlitScript.ts"},PBR:{filename:"PBRShader.shader",uiScriptTemplateType:j.PbrUIScript,uiScriptFileName:"PBRScript.ts"},Sprite:{filename:"SpriteShader.shader"}},Se=`
|
|
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
|
+
${Se}
|
|
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 k=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Ie=(i,e,r)=>e in i?k(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&&k(e,r,a),a},T=(i,e,r)=>(Ie(i,typeof e!="symbol"?e+"":e,r),r);Z();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?m.Integer:m.Float,o=t.map(n=>{const[l,h]=n.split(":");return{label:l.trim(),value:Number(h)}});return new v(o,s)}}let d=class extends q{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",[]);J(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=me[a];s&&this.setNameByIncrease(s.filename);const{uiScriptTemplateType:o,uiScriptFileName:n}=s;let l;return o&&(l=`./${(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:l}),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 l=n.match(d._groupRegex);l?t={type:l[1],title:l[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=K(a,t),o=ue.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,l,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:l,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,S)=>{const y=S.engineObject.shaderData,M=S.extraData.disabledMacros??[],F=M.indexOf(l)??-1;f?(y.enableMacro(l),F!==-1&&(M.splice(F,1),this.root.assetFacade.persistAssetMeta(S.id))):(y.disableMacro(l),F===-1&&(M.push(l),S.extraData.disabledMacros=M,this.root.assetFacade.persistAssetMeta(S.id)));const V=p==null?void 0:p.getMacroCallback(l);V&&(V(S.engineObject,f,void 0),S.refreshFormConfig(this.properties,S._getMainData()))}},onChange:async(f,S,y)=>{const M=p==null?void 0:p.getMacroCallback(l);M&&(M(f.engineObject,y,y),f.refreshFormConfig(this.properties,f._getMainData())),f.engineObject.shaderData.enableMacro(l,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,l,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:l,defaultValue:p.defaultValue,onChange:async(I,D,f)=>{const S=u==null?void 0:u.getPropertyCallback(D);if(S){let y=f;f!=null&&f.refId&&(y=(await this.root.assetStore.getAssetByRef(f)).engineObject),S(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:c.Slider,...e},engineType:m.Float};if(e instanceof v)return{defaultValue:t?Number(t):void 0,uiInfo:{type:c.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:c.Color},engineType:m.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:c.Color,mode:"hdr"},engineType:m.Color}}case"Vector4":return{defaultValue:t?new N(...a(t).split(",").map(Number)):new N,uiInfo:{type:c.Vector4},engineType:m.Vector4};case"Vector3":return{defaultValue:t?new w(...a(t).split(",").map(Number)):new w,uiInfo:{type:c.Vector3},engineType:m.Vector3};case"Vector2":return{defaultValue:t?new E(...a(t).split(",").map(Number)):new E,uiInfo:{type:c.Vector2},engineType:m.Vector2};case"Int":return{defaultValue:t?Number(t):0,uiInfo:{type:c.Number},engineType:m.Integer};case"Float":return{defaultValue:t?Number(t):0,uiInfo:{type:c.Number},engineType:m.Float};case"Texture2D":return{defaultValue:t,uiInfo:{type:c.AssetPicker,assetType:"Texture",customFilter:s=>s.shape!=="Cube"},engineType:m.Texture};case"TextureCube":return{defaultValue:t,uiInfo:{type:c.AssetPicker,assetType:"Texture",customFilter:s=>s.shape==="Cube"},engineType:m.Texture};case"Boolean":return{defaultValue:t==="true",uiInfo:{type:c.Boolean},engineType:m.Boolean};case"Null":return{defaultValue:null,uiInfo:{type:c.Null}};default:throw`not support type ${e}`}}onDoubleClick(){if(this.locked){he.error("Cannot edit internal Shader");return}Y(this.root.projectStore.id,this.id),ee()}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,te.GLSLES100,this.includePath);this.bindEngineObject(n),this.parseEditorModule();const l=this.properties;if(!l)s=a;else for(const h of a)l.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=re.getByName(t.prop);t==null||t.onChange(r,t.prop,void 0),ce(r,t.prop,void 0,t.engineType),delete a._propertyValueMap[s._uniqueId]}}r.applyBoundPathChange("shader",c.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})}}};T(d,"ErrorShaderRefId","0000508");T(d,"_groupRegex",/\b(Header|Collapsible)\s*\(\s*"([\w\s]+)"\s*\)/);T(d,"_scriptRegex",/^\s*UIScript\s+"([\w./]+)"/m);T(d,"_editorModuleRegex",/\bEditor\s*{/);T(d,"_commentsLineRegex",/^\s*\*\s*(.*)?$/);T(d,"_langSpecification",/@language\s+(\w+)/);P([se()],d.prototype,"builtinShaderName",2);P([ae],d.prototype,"_compileError",2);P([ie],d.prototype,"compileError",1);d=P([oe({type:"Shader",label:A("asset.shader.title"),defaultName:"Shader.shader",icon:"shader",extname:"shader",importMenuConfig:{type:ne.Add},bundle({content:i}){return{content:new Blob([i],{type:"text/plain; charset=utf-8"})}},customInspector:fe})],d);export{Me as E,me as S,x as a,v as b,d as c};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var C=Object.defineProperty;var j=(s,e,t)=>e in s?C(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-107b7430.js";import{aH as R,aT as w,aJ as x,aD as h,bz as F,n as A,j as v,b0 as O,u as P,m as M,e as b,c9 as $,o as E,ca as d,bl as B,bm as L,p as k,C as U}from"./index-0a8702e2.js";import{u as z,a as _,A as H}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{F as S}from"./index-98982ce2.js";import{F as J}from"./FormItemArray-66be8701.js";import{s as N}from"./SpineSkeletonDataAsset-b64a3ee3.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}=z(),[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(T=>T.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(F,{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(J,{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 q=Object.defineProperty,G=Object.getOwnPropertyDescriptor,g=(s,e,t,r)=>{for(var o=r>1?void 0:r?G(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&&q(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([O(),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:N,bundle(s){return s.dependencies=$(s.meta,["textures"]),{content:s.content}}})],f);function Q(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=Q(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:H.Add},bundle({content:s}){return{content:new Blob([s],{type:"text/plain; charset=utf-8"})}}})],y);export{f as S,y as a};
|