@phil65/demoreel 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/args.js +12 -0
- package/dist/cli.js +31 -2
- package/dist/compose.d.ts +4 -0
- package/dist/compose.js +4 -0
- package/dist/gif.d.ts +16 -0
- package/dist/gif.js +19 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/openscreen/project.js +3 -3
- package/dist/project.d.ts +51 -1
- package/dist/project.js +89 -1
- package/dist/record.d.ts +6 -1
- package/dist/record.js +2 -1
- package/dist/renderer/assets/CanvasPool-PBu3bHFZ.js +1 -0
- package/dist/renderer/assets/CanvasRenderer-HmF-4gyW.js +1 -0
- package/dist/renderer/assets/RenderTargetSystem-Dk1U4wDJ.js +184 -0
- package/dist/renderer/assets/WebGLRenderer-C0v9HBel.js +149 -0
- package/dist/renderer/assets/WebGPURenderer-Ce0-U9Q1.js +95 -0
- package/dist/renderer/assets/{browserAll-aHn2isHo.js → browserAll-DhvWQ7nM.js} +2 -2
- package/dist/renderer/assets/canvasUtils-KRroregW.js +1 -0
- package/dist/renderer/assets/{getTexelRangeRects-yD6MQ0xy.js → getTexelRangeRects-D3pwCyRt.js} +3 -3
- package/dist/renderer/assets/index-CE-lli1m.js +556 -0
- package/dist/renderer/assets/init-DfmWKarH.js +83 -0
- package/dist/renderer/assets/webworkerAll-B41hok0-.js +1 -0
- package/dist/renderer/index.html +1 -6
- package/dist/scene.d.ts +24 -4
- package/dist/scene.js +74 -5
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
- package/dist/renderer/assets/CanvasPool-CHSHS1-v.js +0 -23
- package/dist/renderer/assets/RenderTargetSystem-EAUH9iQk.js +0 -404
- package/dist/renderer/assets/canvasUtils-n5g2f3_X.js +0 -1
- package/dist/renderer/assets/getTextureBatchBindGroup-Bwvgbco6.js +0 -1
- package/dist/renderer/assets/index-BwP6rH7I.js +0 -556
- package/dist/renderer/assets/init-C2Za5NQh.js +0 -83
- package/dist/renderer/assets/webworkerAll-JSSmbaR2.js +0 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import{B as e,Ct as t,Dt as n,Et as r,H as i,L as a,M as o,R as s,Z as c,b as l,ct as u,dt as d,ut as f,z as p}from"./index-CE-lli1m.js";import{t as m}from"./canvasUtils-KRroregW.js";import{t as h}from"./CanvasPool-PBu3bHFZ.js";var g=new t;function _(e,t){t.clear();let n=t.matrix;for(let n=0;n<e.length;n++){let r=e[n];if(r.globalDisplayStatus<7)continue;let i=r.renderGroup??r.parentRenderGroup;t.matrix=i?.isCachedAsTexture?g.copyFrom(i.textureOffsetInverseTransform).append(r.worldTransform):i?._parentCacheAsTextureRenderGroup?g.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(r.groupTransform):r.worldTransform,t.addBounds(r.bounds)}return t.matrix=n,t}var v=new f;function y(e,t,n,r,i=!1,a){let o=v;o.minX=0,o.minY=0,o.maxX=e.width/r|0,o.maxY=e.height/r|0;let s=c.getOptimalTexture({width:o.width,height:o.height,resolution:r,autoGenerateMipmaps:i,scaleMode:a});return s.source.uploadMethodId=`image`,s.source.resource=e,s.source.alphaMode=`premultiply-alpha-on-upload`,s.frame.width=t/r,s.frame.height=n/r,s.source.emit(`update`,s.source),s.updateUvs(),s}function b(e){return typeof e.getCanvasFilterString==`function`}var x=class{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new f,this.cssFilterString=``}},S=class{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){let t=this._pushFilterFrame(),n=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=n,t.container=e.container,t.cssFilterString=``,n.every(e=>!e.enabled)){t.skip=!0;return}let r=[];for(let e of n){if(!e.enabled)continue;if(!b(e)){this._warnUnsupportedFilter(e);continue}let t=e.getCanvasFilterString();t===null?this._warnUnsupportedFilter(e):t&&r.push(t)}if(r.length===0){t.skip=!0;return}t.cssFilterString=r.join(` `),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;let i=this.renderer.canvasContext.activeContext,a=i.filter||`none`;if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){let e=this.renderer.canvasContext.activeResolution||1;i.save(),i.setTransform(1,0,0,1,0,0),i.beginPath(),i.rect(t.bounds.x*e,t.bounds.y*e,t.bounds.width*e,t.bounds.height*e),i.clip()}else t.useClip=!1;t.cssFilterString&&(i.filter=a===`none`?t.cssFilterString:`${a} ${t.cssFilterString}`)}pop(){let e=this._popFilterFrame();if(e.skip)return;let t=this._savedStates.pop();if(!t)return;let n=this.renderer.canvasContext.activeContext;e.useClip?n.restore():n.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every(e=>!e.enabled))return e;let n=[];for(let e of t){if(!e.enabled)continue;if(!b(e)){this._warnUnsupportedFilter(e);continue}let t=e.getCanvasFilterString();t===null?this._warnUnsupportedFilter(e):t&&n.push(t)}if(n.length===0)return e;let r=m.getCanvasSource(e);if(!r)return e;let i=e.frame,a=e.source._resolution??e.source.resolution??1,o=i.width,s=i.height,{canvas:c,context:l}=h.getOptimalCanvasAndContext(o,s,a);l.setTransform(1,0,0,1,0,0),l.clearRect(0,0,c.width,c.height),n.length&&(l.filter=n.join(` `));let u=i.x*a,d=i.y*a,f=o*a,p=s*a;return l.drawImage(r,u,d,f,p,0,0,f,p),l.filter=`none`,l.globalAlpha=1,y(c,o,s,a)}_calculateFilterArea(e,t){if(e.renderables?_(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){let n=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;n&&t.applyMatrix(n)}}_warnUnsupportedFilter(e){let t=e?.constructor?.name||`Filter`;this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||=this._filterStack[this._filterStackIndex]=new x,this._filterStackIndex++,e}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}};S.extension={type:[r.CanvasSystem],name:`filter`};var C=`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
|
+
`,w=`in vec2 vTextureCoord;
|
|
29
|
+
out vec4 finalColor;
|
|
30
|
+
uniform sampler2D uTexture;
|
|
31
|
+
void main() {
|
|
32
|
+
finalColor = texture(uTexture, vTextureCoord);
|
|
33
|
+
}
|
|
34
|
+
`,T=`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
|
+
`,E=class extends o{constructor(){let t=e.from({vertex:{source:T,entryPoint:`mainVertex`},fragment:{source:T,entryPoint:`mainFragment`},name:`passthrough-filter`}),n=i.from({vertex:C,fragment:w,name:`passthrough-filter`});super({gpuProgram:t,glProgram:n})}},D=class{constructor(e){this._renderer=e}push(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:`filter`,canBundle:!1,action:`pushFilter`,container:t,filterEffect:e})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.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}};D.extension={type:[r.WebGLPipes,r.WebGPUPipes,r.CanvasPipes],name:`filter`};var O=new l({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])}),k=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new f,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}},A=class{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new p({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 s({}),this.renderer=e}init(){c.on(`evict`,this._unbindPassTextures,this)}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){let t=this.renderer,n=e.filterEffect.filters,r=this._pushFilterData();r.skip=!1,r.filters=n,r.container=e.container,r.outputRenderSurface=t.renderTarget.renderSurface;let i=t.renderTarget.renderTarget.colorTexture.source,a=i.resolution,o=i.antialias;if(n.every(e=>!e.enabled)){r.skip=!0;return}let s=r.bounds;if(this._calculateFilterArea(e,s),this._calculateFilterBounds(r,t.renderTarget.rootViewPort,o,a,1),r.skip)return;let c=this._getPreviousFilterData();this._setupFilterTextures(r,s,t,c)}generateFilteredTexture({texture:e,filters:t}){if(t.every(e=>!e.enabled))return e;let n=this._pushFilterData();this._activeFilterData=n,n.skip=!1,n.filters=t;let r=e.source,i=r.resolution,a=r.antialias,o=n.bounds;if(o.clear(),o.addRect(e.frame),this._calculateFilterBounds(n,o.rectangle,a,i,0),n.skip)return this._popFilterData(),e;n.outputRenderSurface=c.getOptimalTexture({width:o.width,height:o.height,resolution:n.resolution,antialias:n.antialias}),n.backTexture=d.EMPTY,n.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(n,!0);let s=n.outputRenderSurface;return s.source.alphaMode=`premultiplied-alpha`,this._popFilterData(),s}pop(){let e=this.renderer,t=this._popFilterData();t.skip||(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired&&c.returnTexture(t.backTexture),c.returnTexture(t.inputTexture))}getBackTexture(e,t,n){let{_resolution:r,format:i}=e.colorTexture.source,a=c.getOptimalTexture({width:t.width,height:t.height,resolution:r,format:i});return this._copyBackTexture(e,a,t,n)}_copyBackTexture(e,t,n,r){let i=t.source._resolution,a=n.minX,o=n.minY;r&&(a-=r.minX,o-=r.minY),a=Math.floor(a*i+1e-6),o=Math.floor(o*i+1e-6);let s=Math.min(Math.ceil(n.width*i),t.source.pixelWidth),c=Math.min(Math.ceil(n.height*i),t.source.pixelHeight);return this.renderer.renderTarget.copyToTexture(e,t,{x:a,y:o},{width:s,height:c},{x:0,y:0}),t}applyFilter(e,t,n,r){let i=this.renderer,a=this._activeFilterData,o=a.outputRenderSurface===n,s=this._findClosestFilterData(),c=s?s.inputTexture.source._resolution:i.renderTarget.rootRenderTarget.colorTexture.source._resolution,l=0,u=0;o&&s&&(l=s.bounds.minX,u=s.bounds.minY),this._updateFilterUniforms(t,n,a,l,u,c,o,r);let d=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,t,i)}calculateSpriteMatrix(e,n){let r=this._activeFilterData,i=e.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),a=n.worldTransform.copyTo(t.shared),o=n.renderGroup||n.parentRenderGroup;return o&&o.cacheToLocalTransform&&a.prepend(o.cacheToLocalTransform),a.invert(),i.prepend(a),i.scale(1/n.texture.orig.width,1/n.texture.orig.height),i.translate(n.anchor.x,n.anchor.y),i}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null,c.off(`evict`,this._unbindPassTextures,this),this._globalFilterBindGroup.destroy()}_unbindPassTextures(){let e=this._globalFilterBindGroup;e.setResource(d.EMPTY.source,1),e.setResource(d.EMPTY.source.style,2),e.setResource(d.EMPTY.source,3)}_getPassthroughFilter(){return this._passthroughFilter??=new E,this._passthroughFilter}_setupBindGroupsAndRender(e,t,n){if(n.renderPipes.uniformBatch){let e=n.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(e,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,n.encoder.draw({geometry:O,shader:e,state:e._state,topology:`triangle-list`}),n.type===a.WEBGL&&n.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,n,r){if(e.backTexture=d.EMPTY,e.inputTexture=c.getOptimalTexture({width:t.width,height:t.height,resolution:e.resolution,antialias:e.antialias}),e.blendRequired){n.renderTarget.finishRenderPass();let i=n.renderTarget.getRenderTarget(e.outputRenderSurface),a=i.colorTexture.source,o=c.getAlignedTexture(e.inputTexture,a._resolution,a.format);e.backTexture=this._copyBackTexture(i,o,t,r?.bounds)}n.renderTarget.bind({target:e.inputTexture,clear:!0}),n.globalUniforms.push({offset:t})}_updateFilterUniforms(e,t,n,r,i,a,o,s){let c=this._filterGlobalUniforms.uniforms,l=c.uOutputFrame,u=c.uInputSize,f=c.uInputPixel,p=c.uInputClamp,m=c.uGlobalFrame,h=c.uOutputTexture;o?(l[0]=n.bounds.minX-r,l[1]=n.bounds.minY-i):(l[0]=0,l[1]=0),l[2]=e.frame.width,l[3]=e.frame.height,u[0]=e.source.width,u[1]=e.source.height,u[2]=1/u[0],u[3]=1/u[1],f[0]=e.source.pixelWidth,f[1]=e.source.pixelHeight,f[2]=1/f[0],f[3]=1/f[1],p[0]=.5*f[2],p[1]=.5*f[3],p[2]=e.frame.width*u[2]-.5*f[2],p[3]=e.frame.height*u[3]-.5*f[3];let g=this.renderer.renderTarget.rootRenderTarget.colorTexture;m[0]=r*a,m[1]=i*a,m[2]=g.source.width*a,m[3]=g.source.height*a,t instanceof d&&(t.source.resource=null);let _=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind({target:t,clear:!!s}),t instanceof d?(h[0]=t.frame.width,h[1]=t.frame.height):(h[0]=_.width,h[1]=_.height),h[2]=_.isRoot?-1:1,this._filterGlobalUniforms.update()}_findClosestFilterData(){for(let e=this._filterStackIndex-1;e>=0;e--){let t=this._filterStack[e];if(!t.skip)return t}return null}_calculateFilterArea(e,t){if(e.renderables?_(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){let n=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;n&&t.applyMatrix(n)}}_applyFiltersToTexture(e,t){let n=e.inputTexture,r=e.bounds,i=e.filters,a=e.firstEnabledIndex,o=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(n.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),a===o)i[a].apply(this,n,e.outputRenderSurface,t);else{let n=e.inputTexture,s=c.getOptimalTexture({width:r.width,height:r.height,resolution:n.source._resolution}),l=s;for(let e=a;e<o;e++){let t=i[e];if(!t.enabled)continue;t.apply(this,n,l,!0);let r=n;n=l,l=r}i[o].apply(this,n,e.outputRenderSurface,t),c.returnTexture(s)}}_calculateFilterBounds(e,t,n,r,i){let a=this.renderer,o=e.bounds,s=e.filters,c=1/0,l=0,d=!0,f=!1,p=!1,m=!0,h=-1,g=-1;for(let e=0;e<s.length;e++){let t=s[e];if(t.enabled){if(h===-1&&(h=e),g=e,c=Math.min(c,t.resolution===`inherit`?r:t.resolution),l+=t.padding,t.antialias===`off`?d=!1:t.antialias===`inherit`&&(d&&=n),t.clipToViewport||(m=!1),!(t.compatibleRenderers&a.type)){p=!1;break}if(t.blendRequired&&!(a.backBuffer?.useBackBuffer??!0)){u("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),p=!1;break}p=!0,f||=t.blendRequired}}p?(m&&o.fitBounds(0,t.width/r,0,t.height/r),o.scale(c).ceil().scale(1/c).pad((l|0)*i),o.isPositive?(e.antialias=d,e.resolution=c,e.blendRequired=f,e.firstEnabledIndex=h,e.lastEnabledIndex=g):e.skip=!0):e.skip=!0}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){for(let e=this._filterStackIndex-2;e>=0;e--){let t=this._filterStack[e];if(!t.skip)return t}return null}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];return e||=this._filterStack[this._filterStackIndex]=new k,this._filterStackIndex++,e}};A.extension={type:[r.WebGLSystem,r.WebGPUSystem],name:`filter`},n.add(A,S),n.add(D);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./index-CE-lli1m.js";import"./init-DfmWKarH.js";
|
package/dist/renderer/index.html
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
2
|
<html>
|
|
3
|
-
<head><meta charset="utf-8" /><title>demoreel renderer</title> <script type="module" crossorigin src="./assets/index-
|
|
4
|
-
<link rel="modulepreload" crossorigin href="./assets/CanvasPool-CHSHS1-v.js">
|
|
5
|
-
<link rel="modulepreload" crossorigin href="./assets/canvasUtils-n5g2f3_X.js">
|
|
6
|
-
<link rel="modulepreload" crossorigin href="./assets/RenderTargetSystem-EAUH9iQk.js">
|
|
7
|
-
<link rel="modulepreload" crossorigin href="./assets/getTextureBatchBindGroup-Bwvgbco6.js">
|
|
8
|
-
<link rel="modulepreload" crossorigin href="./assets/getTexelRangeRects-yD6MQ0xy.js">
|
|
3
|
+
<head><meta charset="utf-8" /><title>demoreel renderer</title> <script type="module" crossorigin src="./assets/index-CE-lli1m.js"></script>
|
|
9
4
|
</head>
|
|
10
5
|
<body style="margin:0;background:#111;color:#ddd;font:14px sans-serif">
|
|
11
6
|
<div id="status">demoreel headless renderer</div>
|
package/dist/scene.d.ts
CHANGED
|
@@ -80,6 +80,14 @@ export interface ZoomOptions {
|
|
|
80
80
|
wait?: boolean;
|
|
81
81
|
label?: string;
|
|
82
82
|
}
|
|
83
|
+
export interface ClickRippleOptions {
|
|
84
|
+
/** Ring stroke colour (default "rgba(96, 165, 250, 0.9)"). */
|
|
85
|
+
color?: string;
|
|
86
|
+
/** Base ring diameter in px before expansion (default 36). */
|
|
87
|
+
size?: number;
|
|
88
|
+
/** Ripple animation duration in ms (default 380). */
|
|
89
|
+
durationMs?: number;
|
|
90
|
+
}
|
|
83
91
|
export interface HighlightOptions {
|
|
84
92
|
/** How long the highlight stays (ms, default 1800). */
|
|
85
93
|
duration?: number;
|
|
@@ -87,12 +95,23 @@ export interface HighlightOptions {
|
|
|
87
95
|
color?: string;
|
|
88
96
|
/** Space between element and outline (px, default 6). */
|
|
89
97
|
padding?: number;
|
|
98
|
+
/** Spotlight backdrop dim outside the element (`true` => 0.55 opacity, or a 0-1 alpha). */
|
|
99
|
+
dim?: boolean | number;
|
|
100
|
+
/** Optional short callout badge floating next to the highlighted element. */
|
|
101
|
+
badge?: string;
|
|
90
102
|
/** Also zoom onto the element while highlighted (default false). */
|
|
91
103
|
zoom?: boolean | ZoomHint;
|
|
92
104
|
/** Block until the highlight is gone (default false). */
|
|
93
105
|
wait?: boolean;
|
|
94
106
|
label?: string;
|
|
95
107
|
}
|
|
108
|
+
export interface PressOptions {
|
|
109
|
+
label?: string;
|
|
110
|
+
/** Show a keycap HUD overlay for this key press (overrides `look.showKeys`). */
|
|
111
|
+
show?: boolean;
|
|
112
|
+
/** How long the keycap HUD stays visible (ms). */
|
|
113
|
+
duration?: number;
|
|
114
|
+
}
|
|
96
115
|
/** Applies a `data-demoreel-zoom` value to an action's zoom setting. */
|
|
97
116
|
export declare function applyZoomAnchor(zoom: boolean | ZoomHint, anchor: {
|
|
98
117
|
value: string;
|
|
@@ -108,6 +127,7 @@ export declare class Scene {
|
|
|
108
127
|
private recorder;
|
|
109
128
|
private startRecording;
|
|
110
129
|
private fast;
|
|
130
|
+
private clickRipple;
|
|
111
131
|
pacing: PacingOptions;
|
|
112
132
|
/** The underlying Playwright page, for anything the Scene API does not cover. */
|
|
113
133
|
readonly page: Page;
|
|
@@ -115,6 +135,7 @@ export declare class Scene {
|
|
|
115
135
|
constructor(page: Page, viewport: Viewport, startRecording: () => Promise<SceneClock>, opts?: {
|
|
116
136
|
seed?: number;
|
|
117
137
|
pacing?: Partial<PacingOptions>;
|
|
138
|
+
clickRipple?: boolean | ClickRippleOptions;
|
|
118
139
|
fast?: boolean;
|
|
119
140
|
});
|
|
120
141
|
private ensureRecording;
|
|
@@ -131,6 +152,7 @@ export declare class Scene {
|
|
|
131
152
|
private kindAt;
|
|
132
153
|
/** Moves the real mouse along an eased curve at ~60 Hz, recording every position. */
|
|
133
154
|
private travel;
|
|
155
|
+
private showClickRipple;
|
|
134
156
|
private clickHere;
|
|
135
157
|
private record;
|
|
136
158
|
goto(url: string, opts?: {
|
|
@@ -160,9 +182,7 @@ export declare class Scene {
|
|
|
160
182
|
clear?: boolean;
|
|
161
183
|
}): Promise<void>;
|
|
162
184
|
/** Presses a key or chord (Playwright syntax, e.g. "Enter", "Control+K"). */
|
|
163
|
-
press(key: string, opts?:
|
|
164
|
-
label?: string;
|
|
165
|
-
}): Promise<void>;
|
|
185
|
+
press(key: string, opts?: PressOptions): Promise<void>;
|
|
166
186
|
hover(target: Target, opts?: ActionOptions & {
|
|
167
187
|
dwell?: number;
|
|
168
188
|
}): Promise<void>;
|
|
@@ -189,7 +209,7 @@ export declare class Scene {
|
|
|
189
209
|
* Non-blocking by default: script the actions to show while zoomed right after it.
|
|
190
210
|
*/
|
|
191
211
|
zoom(target: Target, opts?: ZoomOptions): Promise<void>;
|
|
192
|
-
/** Draws an outline
|
|
212
|
+
/** Draws an outline (and optional spotlight dim / badge) around an element in the page. */
|
|
193
213
|
highlight(target: Target, opts?: HighlightOptions): Promise<void>;
|
|
194
214
|
pause(ms: number): Promise<void>;
|
|
195
215
|
/**
|
package/dist/scene.js
CHANGED
|
@@ -117,6 +117,7 @@ export class Scene {
|
|
|
117
117
|
recorder = null;
|
|
118
118
|
startRecording;
|
|
119
119
|
fast;
|
|
120
|
+
clickRipple;
|
|
120
121
|
pacing;
|
|
121
122
|
/** The underlying Playwright page, for anything the Scene API does not cover. */
|
|
122
123
|
page;
|
|
@@ -129,6 +130,13 @@ export class Scene {
|
|
|
129
130
|
this.rand = mulberry32(opts.seed ?? 42);
|
|
130
131
|
this.pacing = { ...DEFAULT_PACING, ...opts.pacing };
|
|
131
132
|
this.cursor = { x: viewport.width * 0.62, y: viewport.height * 0.72 };
|
|
133
|
+
this.clickRipple = opts.clickRipple
|
|
134
|
+
? {
|
|
135
|
+
color: (typeof opts.clickRipple === "object" ? opts.clickRipple.color : undefined) ?? "rgba(96, 165, 250, 0.9)",
|
|
136
|
+
size: (typeof opts.clickRipple === "object" ? opts.clickRipple.size : undefined) ?? 36,
|
|
137
|
+
durationMs: (typeof opts.clickRipple === "object" ? opts.clickRipple.durationMs : undefined) ?? 380,
|
|
138
|
+
}
|
|
139
|
+
: null;
|
|
132
140
|
}
|
|
133
141
|
// ---- clock / telemetry -------------------------------------------------------------------
|
|
134
142
|
async ensureRecording() {
|
|
@@ -244,7 +252,38 @@ export class Scene {
|
|
|
244
252
|
await this.page.mouse.move(to.x, to.y);
|
|
245
253
|
this.sample("move");
|
|
246
254
|
}
|
|
255
|
+
async showClickRipple(at) {
|
|
256
|
+
if (!this.clickRipple || this.fast)
|
|
257
|
+
return;
|
|
258
|
+
const cfg = this.clickRipple;
|
|
259
|
+
await this.page
|
|
260
|
+
.evaluate((o) => {
|
|
261
|
+
const d = document.createElement("div");
|
|
262
|
+
d.setAttribute("data-demoreel-ripple", "");
|
|
263
|
+
d.style.cssText = [
|
|
264
|
+
"position:fixed",
|
|
265
|
+
`left:${o.x}px`,
|
|
266
|
+
`top:${o.y}px`,
|
|
267
|
+
`width:${o.size}px`,
|
|
268
|
+
`height:${o.size}px`,
|
|
269
|
+
"border-radius:9999px",
|
|
270
|
+
`border:3px solid ${o.color}`,
|
|
271
|
+
`box-shadow:0 0 12px color-mix(in srgb, ${o.color} 50%, transparent)`,
|
|
272
|
+
"pointer-events:none",
|
|
273
|
+
"z-index:2147483647",
|
|
274
|
+
"transform:translate(-50%,-50%) scale(0.35)",
|
|
275
|
+
].join(";");
|
|
276
|
+
document.documentElement.appendChild(d);
|
|
277
|
+
const anim = d.animate([
|
|
278
|
+
{ transform: "translate(-50%,-50%) scale(0.35)", opacity: 0.95 },
|
|
279
|
+
{ transform: "translate(-50%,-50%) scale(1.75)", opacity: 0 },
|
|
280
|
+
], { duration: o.durationMs, easing: "cubic-bezier(0.22, 1, 0.36, 1)", fill: "forwards" });
|
|
281
|
+
anim.onfinish = () => d.remove();
|
|
282
|
+
}, { x: at.x, y: at.y, ...cfg })
|
|
283
|
+
.catch(() => { });
|
|
284
|
+
}
|
|
247
285
|
async clickHere() {
|
|
286
|
+
await this.showClickRipple(this.cursor);
|
|
248
287
|
await this.page.mouse.down();
|
|
249
288
|
this.sample("click");
|
|
250
289
|
await sleep(this.ms(70 + this.rand() * 40));
|
|
@@ -310,6 +349,7 @@ export class Scene {
|
|
|
310
349
|
await this.travel(this.aimPoint(box), box, kind);
|
|
311
350
|
const arriveMs = this.now();
|
|
312
351
|
await sleep(this.ms(this.pacing.aimDwell));
|
|
352
|
+
await this.showClickRipple(this.cursor);
|
|
313
353
|
this.sample("click");
|
|
314
354
|
await loc.selectOption(value);
|
|
315
355
|
await sleep(this.ms(70));
|
|
@@ -441,8 +481,16 @@ export class Scene {
|
|
|
441
481
|
await this.ensureRecording();
|
|
442
482
|
const startMs = this.now();
|
|
443
483
|
await this.page.keyboard.press(key);
|
|
444
|
-
this.record({
|
|
445
|
-
|
|
484
|
+
this.record({
|
|
485
|
+
kind: "press",
|
|
486
|
+
startMs,
|
|
487
|
+
arriveMs: startMs,
|
|
488
|
+
label: opts.label ?? key,
|
|
489
|
+
text: key,
|
|
490
|
+
...(opts.show !== undefined ? { showKey: opts.show } : {}),
|
|
491
|
+
...(opts.duration !== undefined ? { keyDurationMs: opts.duration } : {}),
|
|
492
|
+
});
|
|
493
|
+
await sleep(this.ms(260));
|
|
446
494
|
}
|
|
447
495
|
async hover(target, opts = {}) {
|
|
448
496
|
await this.ensureRecording();
|
|
@@ -566,16 +614,19 @@ export class Scene {
|
|
|
566
614
|
if (opts.wait && !this.fast)
|
|
567
615
|
await sleep(duration);
|
|
568
616
|
}
|
|
569
|
-
/** Draws an outline
|
|
617
|
+
/** Draws an outline (and optional spotlight dim / badge) around an element in the page. */
|
|
570
618
|
async highlight(target, opts = {}) {
|
|
571
619
|
await this.ensureRecording();
|
|
572
620
|
const { loc, box, anchor } = await this.prepare(target);
|
|
573
621
|
const startMs = this.now();
|
|
574
622
|
const duration = this.ms(opts.duration ?? 1800);
|
|
623
|
+
const dimAlpha = opts.dim === true ? 0.55 : typeof opts.dim === "number" ? Math.min(0.95, Math.max(0, opts.dim)) : 0;
|
|
575
624
|
await loc.evaluate((el, o) => {
|
|
576
625
|
const r = el.getBoundingClientRect();
|
|
577
626
|
const d = document.createElement("div");
|
|
578
627
|
d.setAttribute("data-demoreel-highlight", "");
|
|
628
|
+
const glow = `0 0 0 4px color-mix(in srgb, ${o.color} 30%, transparent), 0 0 24px 4px color-mix(in srgb, ${o.color} 45%, transparent)`;
|
|
629
|
+
const shadow = o.dimAlpha > 0 ? `${glow}, 0 0 0 9999px rgba(6, 9, 20, ${o.dimAlpha})` : glow;
|
|
579
630
|
d.style.cssText = [
|
|
580
631
|
"position:fixed",
|
|
581
632
|
`left:${r.left - o.padding}px`,
|
|
@@ -584,12 +635,30 @@ export class Scene {
|
|
|
584
635
|
`height:${r.height + 2 * o.padding}px`,
|
|
585
636
|
`border:3px solid ${o.color}`,
|
|
586
637
|
"border-radius:10px",
|
|
587
|
-
`box-shadow
|
|
638
|
+
`box-shadow:${shadow}`,
|
|
588
639
|
"pointer-events:none",
|
|
589
640
|
"z-index:2147483647",
|
|
590
641
|
"opacity:0",
|
|
591
642
|
"transition:opacity 220ms ease-out",
|
|
592
643
|
].join(";");
|
|
644
|
+
if (o.badge) {
|
|
645
|
+
const b = document.createElement("div");
|
|
646
|
+
b.textContent = o.badge;
|
|
647
|
+
const above = r.top - o.padding > 44;
|
|
648
|
+
b.style.cssText = [
|
|
649
|
+
"position:absolute",
|
|
650
|
+
"left:0",
|
|
651
|
+
above ? "bottom:calc(100% + 10px)" : "top:calc(100% + 10px)",
|
|
652
|
+
`background:${o.color}`,
|
|
653
|
+
"color:#0b1020",
|
|
654
|
+
"font:700 13px/1.2 Inter,system-ui,-apple-system,sans-serif",
|
|
655
|
+
"padding:5px 10px",
|
|
656
|
+
"border-radius:7px",
|
|
657
|
+
"white-space:nowrap",
|
|
658
|
+
"box-shadow:0 4px 16px rgba(0,0,0,0.35)",
|
|
659
|
+
].join(";");
|
|
660
|
+
d.appendChild(b);
|
|
661
|
+
}
|
|
593
662
|
document.documentElement.appendChild(d);
|
|
594
663
|
requestAnimationFrame(() => {
|
|
595
664
|
d.style.opacity = "1";
|
|
@@ -598,7 +667,7 @@ export class Scene {
|
|
|
598
667
|
d.style.opacity = "0";
|
|
599
668
|
setTimeout(() => d.remove(), 260);
|
|
600
669
|
}, Math.max(0, o.duration - 260));
|
|
601
|
-
}, { duration, color: opts.color ?? "#ffcc00", padding: opts.padding ?? 6 });
|
|
670
|
+
}, { duration, color: opts.color ?? "#ffcc00", padding: opts.padding ?? 6, dimAlpha, badge: opts.badge ?? "" });
|
|
602
671
|
this.record({
|
|
603
672
|
kind: "highlight",
|
|
604
673
|
startMs,
|
package/dist/types.d.ts
CHANGED
|
@@ -47,6 +47,10 @@ export interface ActionRecord {
|
|
|
47
47
|
};
|
|
48
48
|
label?: string;
|
|
49
49
|
text?: string;
|
|
50
|
+
/** For `press` actions: override whether a keycap HUD overlay is shown for this key. */
|
|
51
|
+
showKey?: boolean;
|
|
52
|
+
/** For `press` actions: how long the keycap HUD stays visible (ms). */
|
|
53
|
+
keyDurationMs?: number;
|
|
50
54
|
}
|
|
51
55
|
export interface ZoomHint {
|
|
52
56
|
/** Force a depth (1..6) instead of deriving it from the element size. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phil65/demoreel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Scripted product demo videos (videos as code): Playwright scenarios with auto cursor + auto zoom, rendered headless by OpenScreen's exporter.",
|
|
6
6
|
"keywords": [
|