@openspecui/web 1.6.0 → 2.0.1
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/assets/{BufferResource-LpIscPOh.js → BufferResource-Cipj3hQ5.js} +1 -1
- package/dist/assets/{CanvasRenderer-hdBAgk8Z.js → CanvasRenderer-C151fKcy.js} +1 -1
- package/dist/assets/{Filter-DJVBXWdE.js → Filter-BpxymkGv.js} +1 -1
- package/dist/assets/{RenderTargetSystem-CEuUrT8d.js → RenderTargetSystem-C0zk81Mh.js} +1 -1
- package/dist/assets/{WebGLRenderer-DUSFltAk.js → WebGLRenderer-De3GrxdN.js} +1 -1
- package/dist/assets/{WebGPURenderer-DafJULoy.js → WebGPURenderer-BkpejvST.js} +1 -1
- package/dist/assets/{browserAll-DYvdsmhE.js → browserAll-B8KqF-Xa.js} +1 -1
- package/dist/assets/{ghostty-web-BitlvuYh.js → ghostty-web-BO5ww0eG.js} +1 -1
- package/dist/assets/{index-CYTyn82I.js → index-2DXouwnE.js} +1 -1
- package/dist/assets/index-B-vvVL83.js +1541 -0
- package/dist/assets/{index-hXwe0Xwc.js → index-Bp2dpDFJ.js} +1 -1
- package/dist/assets/{index-CjHce-bH.js → index-Bxm-n0do.js} +1 -1
- package/dist/assets/{index-Dge9ymDE.js → index-CDX9fioY.js} +1 -1
- package/dist/assets/{index-CGTRVPmS.js → index-CFAzjIVm.js} +1 -1
- package/dist/assets/{index-BhxOfd1V.js → index-Cj_nv8ue.js} +1 -1
- package/dist/assets/{index-BwqUcS4o.js → index-Cv-LON1K.js} +1 -1
- package/dist/assets/{index-DtJ1xKq6.js → index-CwA_uPvf.js} +1 -1
- package/dist/assets/{index-DEgCfC-b.js → index-CxDip8xJ.js} +1 -1
- package/dist/assets/{index-gPPYc26D.js → index-DL08rl2O.js} +1 -1
- package/dist/assets/{index-5zLYkWge.js → index-DtTSWBHJ.js} +1 -1
- package/dist/assets/{index-B8AH-4mO.js → index-DzK6gT7C.js} +1 -1
- package/dist/assets/{index-DbrGteUX.js → index-Nl7iD8Yi.js} +1 -1
- package/dist/assets/{index-CuiBRRWA.js → index-a8osabOh.js} +1 -1
- package/dist/assets/index-aWxXp1oO.css +1 -0
- package/dist/assets/{index-BXlwoClD.js → index-iROJdLzk.js} +1 -1
- package/dist/assets/{webworkerAll-CFbGR7bA.js → webworkerAll-DPcI1cDK.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-ssg/client/.vite/ssr-manifest.json +3124 -603
- package/dist-ssg/client/assets/BufferResource-Djy-vqXo.js +185 -0
- package/dist-ssg/client/assets/CanvasRenderer-KFsP4iAw.js +1 -0
- package/dist-ssg/client/assets/Filter-3xK-3KVh.js +1 -0
- package/dist-ssg/client/assets/RenderTargetSystem-BAJ5M6Aj.js +172 -0
- package/dist-ssg/client/assets/WebGLRenderer-DezzkAy6.js +156 -0
- package/dist-ssg/client/assets/WebGPURenderer-ZzdUU8jb.js +41 -0
- package/dist-ssg/client/assets/browserAll-CbpHY1zT.js +14 -0
- package/dist-ssg/client/assets/gemini-Bk-V9kKu.png +0 -0
- package/dist-ssg/client/assets/{index-BWss1-RY.js → index-B5xZnlc2.js} +1 -1
- package/dist-ssg/client/assets/{index-BiJDZ6HF.js → index-BwBOsQe8.js} +1 -1
- package/dist-ssg/client/assets/{index-BTlc4gRd.js → index-C23IRugh.js} +1 -1
- package/dist-ssg/client/assets/index-CR6zSaLm.css +1 -0
- package/dist-ssg/client/assets/{index-DDs25DSq.js → index-CckipaE4.js} +1 -1
- package/dist-ssg/client/assets/{index-D05l7owO.js → index-ChvVJs5U.js} +1 -1
- package/dist-ssg/client/assets/{index-CXPcc7SN.js → index-Cmce45ci.js} +1 -1
- package/dist-ssg/client/assets/index-Csq0Slx9.js +7 -0
- package/dist-ssg/client/assets/{index-LZFdJ_jX.js → index-D5ENxVE5.js} +1 -1
- package/dist-ssg/client/assets/{index-Dw5LFumn.js → index-DEEhv4xj.js} +1 -1
- package/dist-ssg/client/assets/{index-CZlM3xpa.js → index-DHzU_xY8.js} +1 -1
- package/dist-ssg/client/assets/{index-DMgvGt5z.js → index-DY7da1s-.js} +1 -1
- package/dist-ssg/client/assets/{index-ChGuHVYh.js → index-DaL9PO7O.js} +1 -1
- package/dist-ssg/client/assets/index-YHr5vAyz.js +1 -0
- package/dist-ssg/client/assets/{index-JFh0HIYc.js → index-Z0tLCpB3.js} +1 -1
- package/dist-ssg/client/assets/{index-DGbspcQI.js → index-yIXrbgDj.js} +1 -1
- package/dist-ssg/client/assets/index.ssg-CYPPqc3Y.js +1531 -0
- package/dist-ssg/client/assets/webworkerAll-Ds7nVNhd.js +83 -0
- package/dist-ssg/client/index.ssg.html +2 -2
- package/dist-ssg/server/assets/BufferResource-BXrsGVSz.js +592 -0
- package/dist-ssg/server/assets/CanvasRenderer-D9aMd7WV.js +1530 -0
- package/dist-ssg/server/assets/Filter-ClU0-pLL.js +80 -0
- package/dist-ssg/server/assets/RenderTargetSystem-CVz6i60H.js +3037 -0
- package/dist-ssg/server/assets/WebGLRenderer-B0I5TP5d.js +3887 -0
- package/dist-ssg/server/assets/WebGPURenderer-DCgUFny7.js +2146 -0
- package/dist-ssg/server/assets/browserAll-BixK1BYs.js +2691 -0
- package/dist-ssg/server/assets/{index-nz5WUxV1.js → index-3uSTc-o9.js} +1 -1
- package/dist-ssg/server/assets/{index-CmaTLdHp.js → index-8uE7RyRi.js} +1 -1
- package/dist-ssg/server/assets/{index-Uo0092kH.js → index-BkJYfA64.js} +1 -1
- package/dist-ssg/server/assets/{index-B4YlAmAc.js → index-BvGNqnLD.js} +1 -1
- package/dist-ssg/server/assets/{index-8B1WJzeR.js → index-BvURgefh.js} +1 -1
- package/dist-ssg/server/assets/{index-DEVS1pbk.js → index-C2CuXbSQ.js} +1 -1
- package/dist-ssg/server/assets/{index-85lrvP9c.js → index-C3RtR5EA.js} +1 -1
- package/dist-ssg/server/assets/{index-Dr8hGWNq.js → index-CZtnphnE.js} +1 -1
- package/dist-ssg/server/assets/{index-cD9YNBBl.js → index-D0DRToHj.js} +1 -1
- package/dist-ssg/server/assets/{index-p0cUlQgG.js → index-D5MdLWau.js} +1 -1
- package/dist-ssg/server/assets/{index-BGh-0lci.js → index-DBYODvy4.js} +1 -1
- package/dist-ssg/server/assets/{index-Cv9QdO7F.js → index-DL23PkQi.js} +1 -1
- package/dist-ssg/server/assets/{index-MmnHcNid.js → index-DfcLdBOi.js} +1 -1
- package/dist-ssg/server/assets/{index-gsGirPQZ.js → index-O2XMojWG.js} +1 -1
- package/dist-ssg/server/assets/init-CnkBvt-J.js +666 -0
- package/dist-ssg/server/assets/webworkerAll-DNiMFaVV.js +12 -0
- package/dist-ssg/server/entry-server.js +55701 -15294
- package/package.json +6 -3
- package/dist/assets/index-CKfGQiMr.js +0 -1547
- package/dist/assets/index-USotIqwU.css +0 -1
- package/dist-ssg/client/assets/index-DRxWBSjo.js +0 -7
- package/dist-ssg/client/assets/index-DbUWuKU6.js +0 -1
- package/dist-ssg/client/assets/index-Di6aqhqv.css +0 -1
- package/dist-ssg/client/assets/index.ssg-2R4_pvpx.js +0 -631
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import{G as R,u as S,T as b,R as P,af as I,ab as B,aq as T,V as _,aJ as O,a1 as A,y as C,ap as E,a2 as k}from"./index.ssg-CYPPqc3Y.js";import{F as z}from"./Filter-3xK-3KVh.js";var U=`in vec2 aPosition;
|
|
2
|
+
out vec2 vTextureCoord;
|
|
3
|
+
|
|
4
|
+
uniform vec4 uInputSize;
|
|
5
|
+
uniform vec4 uOutputFrame;
|
|
6
|
+
uniform vec4 uOutputTexture;
|
|
7
|
+
|
|
8
|
+
vec4 filterVertexPosition( void )
|
|
9
|
+
{
|
|
10
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
11
|
+
|
|
12
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
13
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
14
|
+
|
|
15
|
+
return vec4(position, 0.0, 1.0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
vec2 filterTextureCoord( void )
|
|
19
|
+
{
|
|
20
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void main(void)
|
|
24
|
+
{
|
|
25
|
+
gl_Position = filterVertexPosition();
|
|
26
|
+
vTextureCoord = filterTextureCoord();
|
|
27
|
+
}
|
|
28
|
+
`,M=`in vec2 vTextureCoord;
|
|
29
|
+
out vec4 finalColor;
|
|
30
|
+
uniform sampler2D uTexture;
|
|
31
|
+
void main() {
|
|
32
|
+
finalColor = texture(uTexture, vTextureCoord);
|
|
33
|
+
}
|
|
34
|
+
`,v=`struct GlobalFilterUniforms {
|
|
35
|
+
uInputSize: vec4<f32>,
|
|
36
|
+
uInputPixel: vec4<f32>,
|
|
37
|
+
uInputClamp: vec4<f32>,
|
|
38
|
+
uOutputFrame: vec4<f32>,
|
|
39
|
+
uGlobalFrame: vec4<f32>,
|
|
40
|
+
uOutputTexture: vec4<f32>,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
|
|
44
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
45
|
+
@group(0) @binding(2) var uSampler: sampler;
|
|
46
|
+
|
|
47
|
+
struct VSOutput {
|
|
48
|
+
@builtin(position) position: vec4<f32>,
|
|
49
|
+
@location(0) uv: vec2<f32>
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
|
|
53
|
+
{
|
|
54
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
55
|
+
|
|
56
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
57
|
+
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
58
|
+
|
|
59
|
+
return vec4(position, 0.0, 1.0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
|
|
63
|
+
{
|
|
64
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@vertex
|
|
68
|
+
fn mainVertex(
|
|
69
|
+
@location(0) aPosition: vec2<f32>,
|
|
70
|
+
) -> VSOutput {
|
|
71
|
+
return VSOutput(
|
|
72
|
+
filterVertexPosition(aPosition),
|
|
73
|
+
filterTextureCoord(aPosition)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@fragment
|
|
78
|
+
fn mainFragment(
|
|
79
|
+
@location(0) uv: vec2<f32>,
|
|
80
|
+
) -> @location(0) vec4<f32> {
|
|
81
|
+
return textureSample(uTexture, uSampler, uv);
|
|
82
|
+
}
|
|
83
|
+
`;class V extends z{constructor(){const e=R.from({vertex:{source:v,entryPoint:"mainVertex"},fragment:{source:v,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=S.from({vertex:U,fragment:M,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}}class w{constructor(e){this._renderer=e}push(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){e.action==="pushFilter"?this._renderer.filter.push(e):e.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}w.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:"filter"};const y=new P;function Y(g,e){e.clear();const t=e.matrix;for(let r=0;r<g.length;r++){const i=g[r];if(i.globalDisplayStatus<7)continue;const n=i.renderGroup??i.parentRenderGroup;n?.isCachedAsTexture?e.matrix=y.copyFrom(n.textureOffsetInverseTransform).append(i.worldTransform):n?._parentCacheAsTextureRenderGroup?e.matrix=y.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform):e.matrix=i.worldTransform,e.addBounds(i.bounds)}return e.matrix=t,e}const q=new O({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class X{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new E,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}}class G{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new I({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new B({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){const t=this.renderer,r=e.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=r,i.container=e.container,i.outputRenderSurface=t.renderTarget.renderSurface;const n=t.renderTarget.renderTarget.colorTexture.source,o=n.resolution,s=n.antialias;if(r.every(d=>!d.enabled)){i.skip=!0;return}const c=i.bounds;if(this._calculateFilterArea(e,c),this._calculateFilterBounds(i,t.renderTarget.rootViewPort,s,o,1),i.skip)return;const u=this._getPreviousFilterData(),f=this._findFilterResolution(o);let l=0,a=0;u&&(l=u.bounds.minX,a=u.bounds.minY),this._calculateGlobalFrame(i,l,a,f,n.width,n.height),this._setupFilterTextures(i,c,t,u)}generateFilteredTexture({texture:e,filters:t}){const r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=t;const i=e.source,n=i.resolution,o=i.antialias;if(t.every(d=>!d.enabled))return r.skip=!0,e;const s=r.bounds;if(s.addRect(e.frame),this._calculateFilterBounds(r,s.rectangle,o,n,0),r.skip)return e;const c=n;this._calculateGlobalFrame(r,0,0,c,i.width,i.height),r.outputRenderSurface=T.getOptimalTexture(s.width,s.height,r.resolution,r.antialias),r.backTexture=_.EMPTY,r.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);const a=r.outputRenderSurface;return a.source.alphaMode="premultiplied-alpha",a}pop(){const e=this.renderer,t=this._popFilterData();t.skip||(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired&&T.returnTexture(t.backTexture),T.returnTexture(t.inputTexture))}getBackTexture(e,t,r){const i=e.colorTexture.source._resolution,n=T.getOptimalTexture(t.width,t.height,i,!1);let o=t.minX,s=t.minY;r&&(o-=r.minX,s-=r.minY),o=Math.floor(o*i),s=Math.floor(s*i);const c=Math.ceil(t.width*i),u=Math.ceil(t.height*i);return this.renderer.renderTarget.copyToTexture(e,n,{x:o,y:s},{width:c,height:u},{x:0,y:0}),n}applyFilter(e,t,r,i){const n=this.renderer,o=this._activeFilterData,c=o.outputRenderSurface===r,u=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,f=this._findFilterResolution(u);let l=0,a=0;if(c){const p=this._findPreviousFilterOffset();l=p.x,a=p.y}this._updateFilterUniforms(t,r,o,l,a,f,c,i);const d=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,t,n)}calculateSpriteMatrix(e,t){const r=this._activeFilterData,i=e.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),n=t.worldTransform.copyTo(P.shared),o=t.renderGroup||t.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),i.prepend(n),i.scale(1/t.texture.orig.width,1/t.texture.orig.height),i.translate(t.anchor.x,t.anchor.y),i}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new V),this._passthroughFilter}_setupBindGroupsAndRender(e,t,r){if(r.renderPipes.uniformBatch){const i=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(i,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:q,shader:e,state:e._state,topology:"triangle-list"}),r.type===A.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,r,i){if(e.backTexture=_.EMPTY,e.inputTexture=T.getOptimalTexture(t.width,t.height,e.resolution,e.antialias),e.blendRequired){r.renderTarget.finishRenderPass();const n=r.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(n,t,i?.bounds)}r.renderTarget.bind(e.inputTexture,!0),r.globalUniforms.push({offset:t})}_calculateGlobalFrame(e,t,r,i,n,o){const s=e.globalFrame;s.x=t*i,s.y=r*i,s.width=n*i,s.height=o*i}_updateFilterUniforms(e,t,r,i,n,o,s,c){const u=this._filterGlobalUniforms.uniforms,f=u.uOutputFrame,l=u.uInputSize,a=u.uInputPixel,d=u.uInputClamp,p=u.uGlobalFrame,x=u.uOutputTexture;s?(f[0]=r.bounds.minX-i,f[1]=r.bounds.minY-n):(f[0]=0,f[1]=0),f[2]=e.frame.width,f[3]=e.frame.height,l[0]=e.source.width,l[1]=e.source.height,l[2]=1/l[0],l[3]=1/l[1],a[0]=e.source.pixelWidth,a[1]=e.source.pixelHeight,a[2]=1/a[0],a[3]=1/a[1],d[0]=.5*a[2],d[1]=.5*a[3],d[2]=e.frame.width*l[2]-.5*a[2],d[3]=e.frame.height*l[3]-.5*a[3];const F=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=i*o,p[1]=n*o,p[2]=F.source.width*o,p[3]=F.source.height*o,t instanceof _&&(t.source.resource=null);const m=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind(t,!!c),t instanceof _?(x[0]=t.frame.width,x[1]=t.frame.height):(x[0]=m.width,x[1]=m.height),x[2]=m.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(e){let t=this._filterStackIndex-1;for(;t>0&&this._filterStack[t].skip;)--t;return t>0&&this._filterStack[t].inputTexture?this._filterStack[t].inputTexture.source._resolution:e}_findPreviousFilterOffset(){let e=0,t=0,r=this._filterStackIndex;for(;r>0;){r--;const i=this._filterStack[r];if(!i.skip){e=i.bounds.minX,t=i.bounds.minY;break}}return{x:e,y:t}}_calculateFilterArea(e,t){if(e.renderables?Y(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const i=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;i&&t.applyMatrix(i)}}_applyFiltersToTexture(e,t){const r=e.inputTexture,i=e.bounds,n=e.filters,o=e.firstEnabledIndex,s=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),o===s)n[o].apply(this,r,e.outputRenderSurface,t);else{let c=e.inputTexture;const u=T.getOptimalTexture(i.width,i.height,c.source._resolution,!1);let f=u;for(let l=o;l<s;l++){const a=n[l];if(!a.enabled)continue;a.apply(this,c,f,!0);const d=c;c=f,f=d}n[s].apply(this,c,e.outputRenderSurface,t),T.returnTexture(u)}}_calculateFilterBounds(e,t,r,i,n){const o=this.renderer,s=e.bounds,c=e.filters;let u=1/0,f=0,l=!0,a=!1,d=!1,p=!0,x=-1,F=-1;for(let m=0;m<c.length;m++){const h=c[m];if(!h.enabled)continue;if(x===-1&&(x=m),F=m,u=Math.min(u,h.resolution==="inherit"?i:h.resolution),f+=h.padding,h.antialias==="off"?l=!1:h.antialias==="inherit"&&l&&(l=r),h.clipToViewport||(p=!1),!!!(h.compatibleRenderers&o.type)){d=!1;break}if(h.blendRequired&&!(o.backBuffer?.useBackBuffer??!0)){C("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=!1;break}d=!0,a||(a=h.blendRequired)}if(!d){e.skip=!0;return}if(p&&s.fitBounds(0,t.width/i,0,t.height/i),s.scale(u).ceil().scale(1/u).pad((f|0)*n),!s.isPositive){e.skip=!0;return}e.antialias=l,e.resolution=u,e.blendRequired=a,e.firstEnabledIndex=x,e.lastEnabledIndex=F}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let e,t=this._filterStackIndex-1;for(;t>0&&(t--,e=this._filterStack[t],!!e.skip););return e}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new X),this._filterStackIndex++,e}}G.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:"filter"};k.add(G);k.add(w);
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
document.head.append(preconnectApi, preconnectStatic, stylesheet)
|
|
36
36
|
})()
|
|
37
37
|
</script>
|
|
38
|
-
<script type="module" crossorigin src="/assets/index.ssg-
|
|
39
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
38
|
+
<script type="module" crossorigin src="/assets/index.ssg-CYPPqc3Y.js"></script>
|
|
39
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CR6zSaLm.css">
|
|
40
40
|
</head>
|
|
41
41
|
<body>
|
|
42
42
|
<div id="root"><!--app-html--></div>
|
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
import { D as warn, J as getAttributeInfoFromFormat, K as STENCIL_MODES, O as unsafeEvalSupported, P as Buffer, Q as BufferUsage, V as EventEmitter, W as uid } from "../entry-server.js";
|
|
2
|
+
const localUniformBit = {
|
|
3
|
+
name: "local-uniform-bit",
|
|
4
|
+
vertex: {
|
|
5
|
+
header: (
|
|
6
|
+
/* wgsl */
|
|
7
|
+
`
|
|
8
|
+
|
|
9
|
+
struct LocalUniforms {
|
|
10
|
+
uTransformMatrix:mat3x3<f32>,
|
|
11
|
+
uColor:vec4<f32>,
|
|
12
|
+
uRound:f32,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
16
|
+
`
|
|
17
|
+
),
|
|
18
|
+
main: (
|
|
19
|
+
/* wgsl */
|
|
20
|
+
`
|
|
21
|
+
vColor *= localUniforms.uColor;
|
|
22
|
+
modelMatrix *= localUniforms.uTransformMatrix;
|
|
23
|
+
`
|
|
24
|
+
),
|
|
25
|
+
end: (
|
|
26
|
+
/* wgsl */
|
|
27
|
+
`
|
|
28
|
+
if(localUniforms.uRound == 1)
|
|
29
|
+
{
|
|
30
|
+
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
31
|
+
}
|
|
32
|
+
`
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const localUniformBitGroup2 = {
|
|
37
|
+
...localUniformBit,
|
|
38
|
+
vertex: {
|
|
39
|
+
...localUniformBit.vertex,
|
|
40
|
+
// replace the group!
|
|
41
|
+
header: localUniformBit.vertex.header.replace("group(1)", "group(2)")
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const localUniformBitGl = {
|
|
45
|
+
name: "local-uniform-bit",
|
|
46
|
+
vertex: {
|
|
47
|
+
header: (
|
|
48
|
+
/* glsl */
|
|
49
|
+
`
|
|
50
|
+
|
|
51
|
+
uniform mat3 uTransformMatrix;
|
|
52
|
+
uniform vec4 uColor;
|
|
53
|
+
uniform float uRound;
|
|
54
|
+
`
|
|
55
|
+
),
|
|
56
|
+
main: (
|
|
57
|
+
/* glsl */
|
|
58
|
+
`
|
|
59
|
+
vColor *= uColor;
|
|
60
|
+
modelMatrix = uTransformMatrix;
|
|
61
|
+
`
|
|
62
|
+
),
|
|
63
|
+
end: (
|
|
64
|
+
/* glsl */
|
|
65
|
+
`
|
|
66
|
+
if(uRound == 1.)
|
|
67
|
+
{
|
|
68
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
69
|
+
}
|
|
70
|
+
`
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const textureBit = {
|
|
75
|
+
name: "texture-bit",
|
|
76
|
+
vertex: {
|
|
77
|
+
header: (
|
|
78
|
+
/* wgsl */
|
|
79
|
+
`
|
|
80
|
+
|
|
81
|
+
struct TextureUniforms {
|
|
82
|
+
uTextureMatrix:mat3x3<f32>,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
|
|
86
|
+
`
|
|
87
|
+
),
|
|
88
|
+
main: (
|
|
89
|
+
/* wgsl */
|
|
90
|
+
`
|
|
91
|
+
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
92
|
+
`
|
|
93
|
+
)
|
|
94
|
+
},
|
|
95
|
+
fragment: {
|
|
96
|
+
header: (
|
|
97
|
+
/* wgsl */
|
|
98
|
+
`
|
|
99
|
+
@group(2) @binding(0) var uTexture: texture_2d<f32>;
|
|
100
|
+
@group(2) @binding(1) var uSampler: sampler;
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
`
|
|
104
|
+
),
|
|
105
|
+
main: (
|
|
106
|
+
/* wgsl */
|
|
107
|
+
`
|
|
108
|
+
outColor = textureSample(uTexture, uSampler, vUV);
|
|
109
|
+
`
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const textureBitGl = {
|
|
114
|
+
name: "texture-bit",
|
|
115
|
+
vertex: {
|
|
116
|
+
header: (
|
|
117
|
+
/* glsl */
|
|
118
|
+
`
|
|
119
|
+
uniform mat3 uTextureMatrix;
|
|
120
|
+
`
|
|
121
|
+
),
|
|
122
|
+
main: (
|
|
123
|
+
/* glsl */
|
|
124
|
+
`
|
|
125
|
+
uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
126
|
+
`
|
|
127
|
+
)
|
|
128
|
+
},
|
|
129
|
+
fragment: {
|
|
130
|
+
header: (
|
|
131
|
+
/* glsl */
|
|
132
|
+
`
|
|
133
|
+
uniform sampler2D uTexture;
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
`
|
|
137
|
+
),
|
|
138
|
+
main: (
|
|
139
|
+
/* glsl */
|
|
140
|
+
`
|
|
141
|
+
outColor = texture(uTexture, vUV);
|
|
142
|
+
`
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
function ensureAttributes(geometry, extractedData) {
|
|
147
|
+
for (const i in geometry.attributes) {
|
|
148
|
+
const attribute = geometry.attributes[i];
|
|
149
|
+
const attributeData = extractedData[i];
|
|
150
|
+
if (attributeData) {
|
|
151
|
+
attribute.format ?? (attribute.format = attributeData.format);
|
|
152
|
+
attribute.offset ?? (attribute.offset = attributeData.offset);
|
|
153
|
+
attribute.instance ?? (attribute.instance = attributeData.instance);
|
|
154
|
+
} else {
|
|
155
|
+
warn(`Attribute ${i} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
ensureStartAndStride(geometry);
|
|
159
|
+
}
|
|
160
|
+
function ensureStartAndStride(geometry) {
|
|
161
|
+
const { buffers, attributes } = geometry;
|
|
162
|
+
const tempStride = {};
|
|
163
|
+
const tempStart = {};
|
|
164
|
+
for (const j in buffers) {
|
|
165
|
+
const buffer = buffers[j];
|
|
166
|
+
tempStride[buffer.uid] = 0;
|
|
167
|
+
tempStart[buffer.uid] = 0;
|
|
168
|
+
}
|
|
169
|
+
for (const j in attributes) {
|
|
170
|
+
const attribute = attributes[j];
|
|
171
|
+
tempStride[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;
|
|
172
|
+
}
|
|
173
|
+
for (const j in attributes) {
|
|
174
|
+
const attribute = attributes[j];
|
|
175
|
+
attribute.stride ?? (attribute.stride = tempStride[attribute.buffer.uid]);
|
|
176
|
+
attribute.start ?? (attribute.start = tempStart[attribute.buffer.uid]);
|
|
177
|
+
tempStart[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const GpuStencilModesToPixi = [];
|
|
181
|
+
GpuStencilModesToPixi[STENCIL_MODES.NONE] = void 0;
|
|
182
|
+
GpuStencilModesToPixi[STENCIL_MODES.DISABLED] = {
|
|
183
|
+
stencilWriteMask: 0,
|
|
184
|
+
stencilReadMask: 0
|
|
185
|
+
};
|
|
186
|
+
GpuStencilModesToPixi[STENCIL_MODES.RENDERING_MASK_ADD] = {
|
|
187
|
+
stencilFront: {
|
|
188
|
+
compare: "equal",
|
|
189
|
+
passOp: "increment-clamp"
|
|
190
|
+
},
|
|
191
|
+
stencilBack: {
|
|
192
|
+
compare: "equal",
|
|
193
|
+
passOp: "increment-clamp"
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
GpuStencilModesToPixi[STENCIL_MODES.RENDERING_MASK_REMOVE] = {
|
|
197
|
+
stencilFront: {
|
|
198
|
+
compare: "equal",
|
|
199
|
+
passOp: "decrement-clamp"
|
|
200
|
+
},
|
|
201
|
+
stencilBack: {
|
|
202
|
+
compare: "equal",
|
|
203
|
+
passOp: "decrement-clamp"
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
GpuStencilModesToPixi[STENCIL_MODES.MASK_ACTIVE] = {
|
|
207
|
+
stencilWriteMask: 0,
|
|
208
|
+
stencilFront: {
|
|
209
|
+
compare: "equal",
|
|
210
|
+
passOp: "keep"
|
|
211
|
+
},
|
|
212
|
+
stencilBack: {
|
|
213
|
+
compare: "equal",
|
|
214
|
+
passOp: "keep"
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
GpuStencilModesToPixi[STENCIL_MODES.INVERSE_MASK_ACTIVE] = {
|
|
218
|
+
stencilWriteMask: 0,
|
|
219
|
+
stencilFront: {
|
|
220
|
+
compare: "not-equal",
|
|
221
|
+
passOp: "keep"
|
|
222
|
+
},
|
|
223
|
+
stencilBack: {
|
|
224
|
+
compare: "not-equal",
|
|
225
|
+
passOp: "keep"
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
class UboSystem {
|
|
229
|
+
constructor(adaptor) {
|
|
230
|
+
this._syncFunctionHash = /* @__PURE__ */ Object.create(null);
|
|
231
|
+
this._adaptor = adaptor;
|
|
232
|
+
this._systemCheck();
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Overridable function by `pixi.js/unsafe-eval` to silence
|
|
236
|
+
* throwing an error if platform doesn't support unsafe-evals.
|
|
237
|
+
* @private
|
|
238
|
+
*/
|
|
239
|
+
_systemCheck() {
|
|
240
|
+
if (!unsafeEvalSupported()) {
|
|
241
|
+
throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.");
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
ensureUniformGroup(uniformGroup) {
|
|
245
|
+
const uniformData = this.getUniformGroupData(uniformGroup);
|
|
246
|
+
uniformGroup.buffer || (uniformGroup.buffer = new Buffer({
|
|
247
|
+
data: new Float32Array(uniformData.layout.size / 4),
|
|
248
|
+
usage: BufferUsage.UNIFORM | BufferUsage.COPY_DST
|
|
249
|
+
}));
|
|
250
|
+
}
|
|
251
|
+
getUniformGroupData(uniformGroup) {
|
|
252
|
+
return this._syncFunctionHash[uniformGroup._signature] || this._initUniformGroup(uniformGroup);
|
|
253
|
+
}
|
|
254
|
+
_initUniformGroup(uniformGroup) {
|
|
255
|
+
const uniformGroupSignature = uniformGroup._signature;
|
|
256
|
+
let uniformData = this._syncFunctionHash[uniformGroupSignature];
|
|
257
|
+
if (!uniformData) {
|
|
258
|
+
const elements = Object.keys(uniformGroup.uniformStructures).map((i) => uniformGroup.uniformStructures[i]);
|
|
259
|
+
const layout = this._adaptor.createUboElements(elements);
|
|
260
|
+
const syncFunction = this._generateUboSync(layout.uboElements);
|
|
261
|
+
uniformData = this._syncFunctionHash[uniformGroupSignature] = {
|
|
262
|
+
layout,
|
|
263
|
+
syncFunction
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
return this._syncFunctionHash[uniformGroupSignature];
|
|
267
|
+
}
|
|
268
|
+
_generateUboSync(uboElements) {
|
|
269
|
+
return this._adaptor.generateUboSync(uboElements);
|
|
270
|
+
}
|
|
271
|
+
syncUniformGroup(uniformGroup, data, offset) {
|
|
272
|
+
const uniformGroupData = this.getUniformGroupData(uniformGroup);
|
|
273
|
+
uniformGroup.buffer || (uniformGroup.buffer = new Buffer({
|
|
274
|
+
data: new Float32Array(uniformGroupData.layout.size / 4),
|
|
275
|
+
usage: BufferUsage.UNIFORM | BufferUsage.COPY_DST
|
|
276
|
+
}));
|
|
277
|
+
let dataInt32 = null;
|
|
278
|
+
if (!data) {
|
|
279
|
+
data = uniformGroup.buffer.data;
|
|
280
|
+
dataInt32 = uniformGroup.buffer.dataInt32;
|
|
281
|
+
}
|
|
282
|
+
offset || (offset = 0);
|
|
283
|
+
uniformGroupData.syncFunction(uniformGroup.uniforms, data, dataInt32, offset);
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
updateUniformGroup(uniformGroup) {
|
|
287
|
+
if (uniformGroup.isStatic && !uniformGroup._dirtyId) return false;
|
|
288
|
+
uniformGroup._dirtyId = 0;
|
|
289
|
+
const synced = this.syncUniformGroup(uniformGroup);
|
|
290
|
+
uniformGroup.buffer.update();
|
|
291
|
+
return synced;
|
|
292
|
+
}
|
|
293
|
+
destroy() {
|
|
294
|
+
this._syncFunctionHash = null;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
const uniformParsers = [
|
|
298
|
+
// uploading pixi matrix object to mat3
|
|
299
|
+
{
|
|
300
|
+
type: "mat3x3<f32>",
|
|
301
|
+
test: (data) => {
|
|
302
|
+
const value = data.value;
|
|
303
|
+
return value.a !== void 0;
|
|
304
|
+
},
|
|
305
|
+
ubo: `
|
|
306
|
+
var matrix = uv[name].toArray(true);
|
|
307
|
+
data[offset] = matrix[0];
|
|
308
|
+
data[offset + 1] = matrix[1];
|
|
309
|
+
data[offset + 2] = matrix[2];
|
|
310
|
+
data[offset + 4] = matrix[3];
|
|
311
|
+
data[offset + 5] = matrix[4];
|
|
312
|
+
data[offset + 6] = matrix[5];
|
|
313
|
+
data[offset + 8] = matrix[6];
|
|
314
|
+
data[offset + 9] = matrix[7];
|
|
315
|
+
data[offset + 10] = matrix[8];
|
|
316
|
+
`,
|
|
317
|
+
uniform: `
|
|
318
|
+
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
|
|
319
|
+
`
|
|
320
|
+
},
|
|
321
|
+
// uploading a pixi rectangle as a vec4
|
|
322
|
+
{
|
|
323
|
+
type: "vec4<f32>",
|
|
324
|
+
test: (data) => data.type === "vec4<f32>" && data.size === 1 && data.value.width !== void 0,
|
|
325
|
+
ubo: `
|
|
326
|
+
v = uv[name];
|
|
327
|
+
data[offset] = v.x;
|
|
328
|
+
data[offset + 1] = v.y;
|
|
329
|
+
data[offset + 2] = v.width;
|
|
330
|
+
data[offset + 3] = v.height;
|
|
331
|
+
`,
|
|
332
|
+
uniform: `
|
|
333
|
+
cv = ud[name].value;
|
|
334
|
+
v = uv[name];
|
|
335
|
+
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
|
|
336
|
+
cv[0] = v.x;
|
|
337
|
+
cv[1] = v.y;
|
|
338
|
+
cv[2] = v.width;
|
|
339
|
+
cv[3] = v.height;
|
|
340
|
+
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
|
|
341
|
+
}
|
|
342
|
+
`
|
|
343
|
+
},
|
|
344
|
+
// uploading a pixi point as a vec2
|
|
345
|
+
{
|
|
346
|
+
type: "vec2<f32>",
|
|
347
|
+
test: (data) => data.type === "vec2<f32>" && data.size === 1 && data.value.x !== void 0,
|
|
348
|
+
ubo: `
|
|
349
|
+
v = uv[name];
|
|
350
|
+
data[offset] = v.x;
|
|
351
|
+
data[offset + 1] = v.y;
|
|
352
|
+
`,
|
|
353
|
+
uniform: `
|
|
354
|
+
cv = ud[name].value;
|
|
355
|
+
v = uv[name];
|
|
356
|
+
if (cv[0] !== v.x || cv[1] !== v.y) {
|
|
357
|
+
cv[0] = v.x;
|
|
358
|
+
cv[1] = v.y;
|
|
359
|
+
gl.uniform2f(ud[name].location, v.x, v.y);
|
|
360
|
+
}
|
|
361
|
+
`
|
|
362
|
+
},
|
|
363
|
+
// uploading a pixi color as a vec4
|
|
364
|
+
{
|
|
365
|
+
type: "vec4<f32>",
|
|
366
|
+
test: (data) => data.type === "vec4<f32>" && data.size === 1 && data.value.red !== void 0,
|
|
367
|
+
ubo: `
|
|
368
|
+
v = uv[name];
|
|
369
|
+
data[offset] = v.red;
|
|
370
|
+
data[offset + 1] = v.green;
|
|
371
|
+
data[offset + 2] = v.blue;
|
|
372
|
+
data[offset + 3] = v.alpha;
|
|
373
|
+
`,
|
|
374
|
+
uniform: `
|
|
375
|
+
cv = ud[name].value;
|
|
376
|
+
v = uv[name];
|
|
377
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
|
|
378
|
+
cv[0] = v.red;
|
|
379
|
+
cv[1] = v.green;
|
|
380
|
+
cv[2] = v.blue;
|
|
381
|
+
cv[3] = v.alpha;
|
|
382
|
+
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
|
|
383
|
+
}
|
|
384
|
+
`
|
|
385
|
+
},
|
|
386
|
+
// uploading a pixi color as a vec3
|
|
387
|
+
{
|
|
388
|
+
type: "vec3<f32>",
|
|
389
|
+
test: (data) => data.type === "vec3<f32>" && data.size === 1 && data.value.red !== void 0,
|
|
390
|
+
ubo: `
|
|
391
|
+
v = uv[name];
|
|
392
|
+
data[offset] = v.red;
|
|
393
|
+
data[offset + 1] = v.green;
|
|
394
|
+
data[offset + 2] = v.blue;
|
|
395
|
+
`,
|
|
396
|
+
uniform: `
|
|
397
|
+
cv = ud[name].value;
|
|
398
|
+
v = uv[name];
|
|
399
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
|
|
400
|
+
cv[0] = v.red;
|
|
401
|
+
cv[1] = v.green;
|
|
402
|
+
cv[2] = v.blue;
|
|
403
|
+
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
|
|
404
|
+
}
|
|
405
|
+
`
|
|
406
|
+
}
|
|
407
|
+
];
|
|
408
|
+
function createUboSyncFunction(uboElements, parserCode, arrayGenerationFunction, singleSettersMap) {
|
|
409
|
+
const funcFragments = [`
|
|
410
|
+
var v = null;
|
|
411
|
+
var v2 = null;
|
|
412
|
+
var t = 0;
|
|
413
|
+
var index = 0;
|
|
414
|
+
var name = null;
|
|
415
|
+
var arrayOffset = null;
|
|
416
|
+
`];
|
|
417
|
+
let prev = 0;
|
|
418
|
+
for (let i = 0; i < uboElements.length; i++) {
|
|
419
|
+
const uboElement = uboElements[i];
|
|
420
|
+
const name = uboElement.data.name;
|
|
421
|
+
let parsed = false;
|
|
422
|
+
let offset = 0;
|
|
423
|
+
for (let j = 0; j < uniformParsers.length; j++) {
|
|
424
|
+
const uniformParser = uniformParsers[j];
|
|
425
|
+
if (uniformParser.test(uboElement.data)) {
|
|
426
|
+
offset = uboElement.offset / 4;
|
|
427
|
+
funcFragments.push(
|
|
428
|
+
`name = "${name}";`,
|
|
429
|
+
`offset += ${offset - prev};`,
|
|
430
|
+
uniformParsers[j][parserCode] || uniformParsers[j].ubo
|
|
431
|
+
);
|
|
432
|
+
parsed = true;
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
if (!parsed) {
|
|
437
|
+
if (uboElement.data.size > 1) {
|
|
438
|
+
offset = uboElement.offset / 4;
|
|
439
|
+
funcFragments.push(arrayGenerationFunction(uboElement, offset - prev));
|
|
440
|
+
} else {
|
|
441
|
+
const template = singleSettersMap[uboElement.data.type];
|
|
442
|
+
offset = uboElement.offset / 4;
|
|
443
|
+
funcFragments.push(
|
|
444
|
+
/* wgsl */
|
|
445
|
+
`
|
|
446
|
+
v = uv.${name};
|
|
447
|
+
offset += ${offset - prev};
|
|
448
|
+
${template};
|
|
449
|
+
`
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
prev = offset;
|
|
454
|
+
}
|
|
455
|
+
const fragmentSrc = funcFragments.join("\n");
|
|
456
|
+
return new Function(
|
|
457
|
+
"uv",
|
|
458
|
+
"data",
|
|
459
|
+
"dataInt32",
|
|
460
|
+
"offset",
|
|
461
|
+
fragmentSrc
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
function loopMatrix(col, row) {
|
|
465
|
+
const total = col * row;
|
|
466
|
+
return `
|
|
467
|
+
for (let i = 0; i < ${total}; i++) {
|
|
468
|
+
data[offset + (((i / ${col})|0) * 4) + (i % ${col})] = v[i];
|
|
469
|
+
}
|
|
470
|
+
`;
|
|
471
|
+
}
|
|
472
|
+
const uboSyncFunctionsSTD40 = {
|
|
473
|
+
f32: `
|
|
474
|
+
data[offset] = v;`,
|
|
475
|
+
i32: `
|
|
476
|
+
dataInt32[offset] = v;`,
|
|
477
|
+
"vec2<f32>": `
|
|
478
|
+
data[offset] = v[0];
|
|
479
|
+
data[offset + 1] = v[1];`,
|
|
480
|
+
"vec3<f32>": `
|
|
481
|
+
data[offset] = v[0];
|
|
482
|
+
data[offset + 1] = v[1];
|
|
483
|
+
data[offset + 2] = v[2];`,
|
|
484
|
+
"vec4<f32>": `
|
|
485
|
+
data[offset] = v[0];
|
|
486
|
+
data[offset + 1] = v[1];
|
|
487
|
+
data[offset + 2] = v[2];
|
|
488
|
+
data[offset + 3] = v[3];`,
|
|
489
|
+
"vec2<i32>": `
|
|
490
|
+
dataInt32[offset] = v[0];
|
|
491
|
+
dataInt32[offset + 1] = v[1];`,
|
|
492
|
+
"vec3<i32>": `
|
|
493
|
+
dataInt32[offset] = v[0];
|
|
494
|
+
dataInt32[offset + 1] = v[1];
|
|
495
|
+
dataInt32[offset + 2] = v[2];`,
|
|
496
|
+
"vec4<i32>": `
|
|
497
|
+
dataInt32[offset] = v[0];
|
|
498
|
+
dataInt32[offset + 1] = v[1];
|
|
499
|
+
dataInt32[offset + 2] = v[2];
|
|
500
|
+
dataInt32[offset + 3] = v[3];`,
|
|
501
|
+
"mat2x2<f32>": `
|
|
502
|
+
data[offset] = v[0];
|
|
503
|
+
data[offset + 1] = v[1];
|
|
504
|
+
data[offset + 4] = v[2];
|
|
505
|
+
data[offset + 5] = v[3];`,
|
|
506
|
+
"mat3x3<f32>": `
|
|
507
|
+
data[offset] = v[0];
|
|
508
|
+
data[offset + 1] = v[1];
|
|
509
|
+
data[offset + 2] = v[2];
|
|
510
|
+
data[offset + 4] = v[3];
|
|
511
|
+
data[offset + 5] = v[4];
|
|
512
|
+
data[offset + 6] = v[5];
|
|
513
|
+
data[offset + 8] = v[6];
|
|
514
|
+
data[offset + 9] = v[7];
|
|
515
|
+
data[offset + 10] = v[8];`,
|
|
516
|
+
"mat4x4<f32>": `
|
|
517
|
+
for (let i = 0; i < 16; i++) {
|
|
518
|
+
data[offset + i] = v[i];
|
|
519
|
+
}`,
|
|
520
|
+
"mat3x2<f32>": loopMatrix(3, 2),
|
|
521
|
+
"mat4x2<f32>": loopMatrix(4, 2),
|
|
522
|
+
"mat2x3<f32>": loopMatrix(2, 3),
|
|
523
|
+
"mat4x3<f32>": loopMatrix(4, 3),
|
|
524
|
+
"mat2x4<f32>": loopMatrix(2, 4),
|
|
525
|
+
"mat3x4<f32>": loopMatrix(3, 4)
|
|
526
|
+
};
|
|
527
|
+
const uboSyncFunctionsWGSL = {
|
|
528
|
+
...uboSyncFunctionsSTD40,
|
|
529
|
+
"mat2x2<f32>": `
|
|
530
|
+
data[offset] = v[0];
|
|
531
|
+
data[offset + 1] = v[1];
|
|
532
|
+
data[offset + 2] = v[2];
|
|
533
|
+
data[offset + 3] = v[3];
|
|
534
|
+
`
|
|
535
|
+
};
|
|
536
|
+
class BufferResource extends EventEmitter {
|
|
537
|
+
/**
|
|
538
|
+
* Create a new Buffer Resource.
|
|
539
|
+
* @param options - The options for the buffer resource
|
|
540
|
+
* @param options.buffer - The underlying buffer that this resource is using
|
|
541
|
+
* @param options.offset - The offset of the buffer this resource is using.
|
|
542
|
+
* If not provided, then it will use the offset of the buffer.
|
|
543
|
+
* @param options.size - The size of the buffer this resource is using.
|
|
544
|
+
* If not provided, then it will use the size of the buffer.
|
|
545
|
+
*/
|
|
546
|
+
constructor({ buffer, offset, size }) {
|
|
547
|
+
super();
|
|
548
|
+
this.uid = uid("buffer");
|
|
549
|
+
this._resourceType = "bufferResource";
|
|
550
|
+
this._touched = 0;
|
|
551
|
+
this._resourceId = uid("resource");
|
|
552
|
+
this._bufferResource = true;
|
|
553
|
+
this.destroyed = false;
|
|
554
|
+
this.buffer = buffer;
|
|
555
|
+
this.offset = offset | 0;
|
|
556
|
+
this.size = size;
|
|
557
|
+
this.buffer.on("change", this.onBufferChange, this);
|
|
558
|
+
}
|
|
559
|
+
onBufferChange() {
|
|
560
|
+
this._resourceId = uid("resource");
|
|
561
|
+
this.emit("change", this);
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Destroys this resource. Make sure the underlying buffer is not used anywhere else
|
|
565
|
+
* if you want to destroy it as well, or code will explode
|
|
566
|
+
* @param destroyBuffer - Should the underlying buffer be destroyed as well?
|
|
567
|
+
*/
|
|
568
|
+
destroy(destroyBuffer = false) {
|
|
569
|
+
this.destroyed = true;
|
|
570
|
+
if (destroyBuffer) {
|
|
571
|
+
this.buffer.destroy();
|
|
572
|
+
}
|
|
573
|
+
this.emit("change", this);
|
|
574
|
+
this.buffer = null;
|
|
575
|
+
this.removeAllListeners();
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
export {
|
|
579
|
+
BufferResource as B,
|
|
580
|
+
GpuStencilModesToPixi as G,
|
|
581
|
+
UboSystem as U,
|
|
582
|
+
localUniformBit as a,
|
|
583
|
+
uboSyncFunctionsSTD40 as b,
|
|
584
|
+
createUboSyncFunction as c,
|
|
585
|
+
uniformParsers as d,
|
|
586
|
+
ensureAttributes as e,
|
|
587
|
+
localUniformBitGl as f,
|
|
588
|
+
textureBitGl as g,
|
|
589
|
+
localUniformBitGroup2 as l,
|
|
590
|
+
textureBit as t,
|
|
591
|
+
uboSyncFunctionsWGSL as u
|
|
592
|
+
};
|