@rr0/ufoathome 0.178.0 → 0.178.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-embed-scene/GenerativeKit-BmhvjjzB.js +9 -0
- package/dist-embed-scene/{GenerativeKitMessages-Cu7wXgYa.js → GenerativeKitMessages-7-3kT9Ef.js} +1 -1
- package/{dist-embed-sighting/GenerativeKitMessages_en-Cl3kA96x.js → dist-embed-scene/GenerativeKitMessages_en-BY4B6yas.js} +3 -2
- package/{dist-embed-sighting-editor/GenerativeKitMessages_es-CEU93Cl3.js → dist-embed-scene/GenerativeKitMessages_es-_iYkoRhK.js} +3 -2
- package/dist-embed-scene/{GenerativeKitMessages_fr-DmW0OAmF.js → GenerativeKitMessages_fr-BY5yUJwK.js} +3 -2
- package/{dist-embed-sighting/GenerativeKitMessages_it-Ba87kumS.js → dist-embed-scene/GenerativeKitMessages_it-DAgB31P1.js} +3 -2
- package/dist-embed-scene/rr0-scene.mjs +43 -43
- package/dist-embed-sighting/{CaseReportExport-Uf7Bs2Qz.js → CaseReportExport-N7KM0IT0.js} +1 -1
- package/dist-embed-sighting/GenerativeKit-BmhvjjzB.js +9 -0
- package/dist-embed-sighting/{GenerativeKitMessages-BudEc93g.js → GenerativeKitMessages-CRj85mnY.js} +1 -1
- package/{dist-embed-scene/GenerativeKitMessages_en-Cl3kA96x.js → dist-embed-sighting/GenerativeKitMessages_en-BY4B6yas.js} +3 -2
- package/{dist-embed-scene/GenerativeKitMessages_es-CEU93Cl3.js → dist-embed-sighting/GenerativeKitMessages_es-_iYkoRhK.js} +3 -2
- package/{dist-embed-sighting-editor/GenerativeKitMessages_fr-DmW0OAmF.js → dist-embed-sighting/GenerativeKitMessages_fr-BY5yUJwK.js} +3 -2
- package/{dist-embed-sighting-editor/GenerativeKitMessages_it-Ba87kumS.js → dist-embed-sighting/GenerativeKitMessages_it-DAgB31P1.js} +3 -2
- package/dist-embed-sighting/rr0-sighting.mjs +80 -80
- package/dist-embed-sighting-editor/{CaseReportExport-iCzv1W9B.js → CaseReportExport-C1trLSiC.js} +1 -1
- package/dist-embed-sighting-editor/GenerativeKit-BmhvjjzB.js +9 -0
- package/dist-embed-sighting-editor/{GenerativeKitMessages-BNXaLr1m.js → GenerativeKitMessages-BtNG1usJ.js} +1 -1
- package/dist-embed-sighting-editor/{GenerativeKitMessages_en-Cl3kA96x.js → GenerativeKitMessages_en-BY4B6yas.js} +3 -2
- package/{dist-embed-sighting/GenerativeKitMessages_es-CEU93Cl3.js → dist-embed-sighting-editor/GenerativeKitMessages_es-_iYkoRhK.js} +3 -2
- package/{dist-embed-sighting/GenerativeKitMessages_fr-DmW0OAmF.js → dist-embed-sighting-editor/GenerativeKitMessages_fr-BY5yUJwK.js} +3 -2
- package/{dist-embed-scene/GenerativeKitMessages_it-Ba87kumS.js → dist-embed-sighting-editor/GenerativeKitMessages_it-DAgB31P1.js} +3 -2
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +61 -61
- package/package.json +1 -1
- package/dist-embed-scene/GenerativeKit-DR6C3LMC.js +0 -4
- package/dist-embed-sighting/GenerativeKit-DR6C3LMC.js +0 -4
- package/dist-embed-sighting-editor/GenerativeKit-DR6C3LMC.js +0 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rr0/ufoathome",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.178.
|
|
4
|
+
"version": "0.178.1",
|
|
5
5
|
"description": "UFO@home — record and replay a UFO sighting's shape, movement and appearance",
|
|
6
6
|
"author": "Jérôme Beau <rr0@rr0.org> (https://rr0.org)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{zip as x}from"./browser-CltifEM0.js";import{g as $,V as A,O as T,B as v,M as D,C as F,Q as _}from"./VideoExport-B8ZhHNnd.js";class p{static DEPTH_NEAR_M=1;static DEPTH_FAR_M=2e4;static MASK_MARGIN_PX=4;static depthLevel(e){if(!(e>0))return 0;const t=1-Math.log(e/p.DEPTH_NEAR_M)/Math.log(p.DEPTH_FAR_M/p.DEPTH_NEAR_M);return Math.min(1,Math.max(0,t))}static dilate(e,t,a,r,o=p.MASK_MARGIN_PX){const i=new Uint8Array(e.length);for(let n=0;n<r;n++)for(let s=0;s<a;s++){let f=0;for(let m=-o;m<=o&&!f;m++){const h=s+m;h>=0&&h<a&&e[n*a+h]&&(f=255)}i[n*a+s]=f}for(let n=0;n<r;n++)for(let s=0;s<a;s++){let f=0;for(let m=-o;m<=o&&!f;m++){const h=n+m;h>=0&&h<r&&i[h*a+s]&&(f=255)}t[n*a+s]=f}}}class g{static of(e,t){const a=e,r=t.rate&&t.rate>0?t.rate:1,o=n=>Math.max(0,(n-t.fromSeconds)/r);return[`Realistic, steady first-person view, as seen by a pedestrian's own eyes, ${a.place?.name??"place not stated"}, local time ${a.time??"not stated"}.`,"Keep exactly the geometry, horizon, framing, lighting and motion of the reference video: only make the textures (vegetation, ground,","buildings, clouds, rain) photographic. Render the phenomenon as realistically as the rest (same grain, blur, haze and light), but keep","its shape, size, colour, brightness, position and motion exactly those of the reference video.","","Phenomenon, as drawn by the reconstruction from the testimony:",...g.shapes(a,t.fromSeconds),...g.section("What happens:",g.milestones(a,t,o)),...g.section("Weather and light (follow this, not the reference's own colours):",g.weather(a,t,o)),"","Negative prompt:","added objects, windows, portholes, lights or beams not in the reference, smoke, people, animals, camera shake beyond the reference,","lens flares not in the reference, any change of the phenomenon's shape, size, colour, brightness, position or motion, text, logos."].join(`
|
|
2
|
-
`)+`
|
|
3
|
-
`}static section(e,t){return t.length>0?["",e,...t]:[]}static text(e,t="en"){if(e!==void 0)return typeof e=="string"?e:e[t]??e.en??Object.values(e)[0]}static shapes(e,t){const a=new Map;for(const r of e.timeline?.keyframes??[])for(const o of r.shapes??[])(r.t<=t*1e3||!a.has(o.sourceId))&&a.set(o.sourceId,o.shape);return a.size===0?["- none drawn."]:[...a.entries()].map(([r,o])=>{const i=o.angular?`${o.angular.widthDeg}° wide and ${o.angular.heightDeg}° tall as seen`:"size not stated",n=o.aim?`, at azimuth ${Math.round(o.aim.azimuthDeg)}°, ${o.aim.altitudeDeg.toFixed(1)}° above the horizon`:"";return`- ${g.text(o.title)??r}: colour ${o.color??"not stated"}, ${i}${n}.`})}static milestones(e,t,a){return(e.milestones??[]).filter(r=>r.t/1e3>=t.fromSeconds&&r.t/1e3<=t.toSeconds).map(r=>`- ${a(r.t/1e3).toFixed(1)} s into the video: ${g.text(r.note)??""}`)}static weather(e,t,a){const r=(e.tags??[]).length>0?[`- ${(e.tags??[]).join(", ")}.`]:[];let o="";for(const i of e.weatherTrack?.keyframes??[]){const n=i.t/1e3;if(n>t.toSeconds)break;const s=g.describe(i.weather);s!==o&&(o=s,r.push(`- ${n<=t.fromSeconds?"from the start":`from ${a(n).toFixed(1)} s into the video`}: ${s}.`))}return r}static describe(e){const t=[];return typeof e.cloudCover=="number"&&t.push(e.cloudCover>=.95?"overcast":`cloud cover ${Math.round(e.cloudCover*100)} %`),typeof e.cloudBaseM=="number"&&t.push(`cloud base ${Math.round(e.cloudBaseM)} m`),t.push(e.precipitationType&&e.precipitationType!=="none"?`${e.precipitationType}, intensity ${e.precipitationIntensity??"not stated"}`:"no precipitation"),t.join(", ")}}class b{static async make(e,t,a,r){const o=Math.max(2,Math.floor(e.film.width/2)*2),i=Math.max(2,Math.floor(e.film.height/2)*2),n=await $(["avc","vp9","av1"],{width:o,height:i});if(!n)throw new Error(`No video codec for ${o}×${i}`);const s=await Promise.all(["depth","phenomenon-mask","sky-mask"].map(w=>b.passFilm(w,o,i,n))),[f,m,h]=s;let l,y,E=0;try{const w=await A.film({...e.film,frameAt:(c,d,M)=>e.film.frameAt(c,d,M)?(l=e.drawControlPasses(),!0):!1,hearInto:c=>e.film.hearInto(c),afterFrame:async(c,d)=>{if(c===0&&(y=await d.canvas.convertToBlob({type:"image/png"})),!l)throw new Error(`No control passes for frame ${c}`);b.paint(l,f.context,m.context,h.context),l=void 0;for(const M of s)await M.source.add(c/A.FRAME_RATE,1/A.FRAME_RATE);E=c+1}},a,r),u=await Promise.all(s.map(async c=>{await c.output.finalize();const d=c.output.target.buffer;if(!d)throw new Error(`Empty ${c.name} film`);return[c.name,new Uint8Array(d)]}));return await b.zipped(e,t,new Uint8Array(await w.arrayBuffer()),u,y,E)}catch(w){throw await Promise.all(s.map(u=>u.output.cancel().catch(()=>{}))),w}}static async passFilm(e,t,a,r){const o=new OffscreenCanvas(t,a),i=o.getContext("2d");if(!i)throw new Error("No 2D context");i.imageSmoothingEnabled=!1;const n=new T({format:new D({fastStart:"in-memory"}),target:new v}),s=new F(o,{codec:r,quality:_});return n.addVideoTrack(s,{frameRate:A.FRAME_RATE}),await n.start(),{name:e,output:n,source:s,context:i}}static paint(e,t,a,r){const{width:o,height:i}=e,n=o*i,s=new Uint8Array(n);p.dilate(e.phenomenon,s,o,i);const f={depth:new ImageData(o,i),phenomenon:new ImageData(o,i),sky:new ImageData(o,i)};for(let l=0;l<n;l++){const y=e.distanceM[l],E=Math.round(p.depthLevel(y)*255),w=y>0?0:255,u=l*4;for(const[c,d]of[[f.depth.data,E],[f.phenomenon.data,s[l]],[f.sky.data,w]])c[u]=d,c[u+1]=d,c[u+2]=d,c[u+3]=255}const m=new OffscreenCanvas(o,i),h=m.getContext("2d");for(const[l,y]of[[t,f.depth],[a,f.phenomenon],[r,f.sky]])h.putImageData(y,0,0),l.drawImage(m,0,0,l.canvas.width,l.canvas.height)}static zipped(e,t,a,r,o,i){const n=new TextEncoder,s=e.film.fromMs/1e3,f=e.film.toMs/1e3,m=e.film.rate>0?e.film.rate:1,h=Math.round(i/A.FRAME_RATE*10)/10,l=new Date().toISOString().slice(0,10),y={title:e.title,source:e.source??"",date:l,fps:String(A.FRAME_RATE),duration:String(h),near:String(p.DEPTH_NEAR_M),far:String(p.DEPTH_FAR_M),margin:String(p.MASK_MARGIN_PX),label:t.label},E=t.readme.replace(/\{(\w+)\}/g,(d,M)=>y[M]??d),w={title:e.title,source:e.source,madeBy:A.MADE_BY,date:l,clip:{fromSeconds:s/m,toSeconds:f/m,fps:A.FRAME_RATE,frames:i,width:e.film.width,height:e.film.height},depth:{encoding:"1 - ln(d / near) / ln(far / near), clamped to 0..1; 0 for the sky",nearM:p.DEPTH_NEAR_M,farM:p.DEPTH_FAR_M},phenomenonMaskMarginPx:p.MASK_MARGIN_PX,label:t.label},u={level:0},c={"reference.mp4":[a,u],...Object.fromEntries(r.map(([d,M])=>[`${d}.mp4`,[M,u]])),"prompt.txt":n.encode(g.of(e.recording,{fromSeconds:s,toSeconds:f,rate:m})),[t.readmeFile]:n.encode(E),"manifest.json":n.encode(JSON.stringify(w,null,2)+`
|
|
4
|
-
`)};return(async()=>(o&&(c["first-frame.png"]=[new Uint8Array(await o.arrayBuffer()),u]),new Promise((d,M)=>x(c,(R,S)=>R?M(R):d(new Blob([S],{type:"application/zip"}))))))()}}export{b as GenerativeKit};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{zip as x}from"./browser-CltifEM0.js";import{g as $,V as A,O as T,B as v,M as D,C as F,Q as _}from"./VideoExport-B8ZhHNnd.js";class p{static DEPTH_NEAR_M=1;static DEPTH_FAR_M=2e4;static MASK_MARGIN_PX=4;static depthLevel(e){if(!(e>0))return 0;const t=1-Math.log(e/p.DEPTH_NEAR_M)/Math.log(p.DEPTH_FAR_M/p.DEPTH_NEAR_M);return Math.min(1,Math.max(0,t))}static dilate(e,t,a,r,o=p.MASK_MARGIN_PX){const i=new Uint8Array(e.length);for(let n=0;n<r;n++)for(let s=0;s<a;s++){let f=0;for(let m=-o;m<=o&&!f;m++){const h=s+m;h>=0&&h<a&&e[n*a+h]&&(f=255)}i[n*a+s]=f}for(let n=0;n<r;n++)for(let s=0;s<a;s++){let f=0;for(let m=-o;m<=o&&!f;m++){const h=n+m;h>=0&&h<r&&i[h*a+s]&&(f=255)}t[n*a+s]=f}}}class g{static of(e,t){const a=e,r=t.rate&&t.rate>0?t.rate:1,o=n=>Math.max(0,(n-t.fromSeconds)/r);return[`Realistic, steady first-person view, as seen by a pedestrian's own eyes, ${a.place?.name??"place not stated"}, local time ${a.time??"not stated"}.`,"Keep exactly the geometry, horizon, framing, lighting and motion of the reference video: only make the textures (vegetation, ground,","buildings, clouds, rain) photographic. Render the phenomenon as realistically as the rest (same grain, blur, haze and light), but keep","its shape, size, colour, brightness, position and motion exactly those of the reference video.","","Phenomenon, as drawn by the reconstruction from the testimony:",...g.shapes(a,t.fromSeconds),...g.section("What happens:",g.milestones(a,t,o)),...g.section("Weather and light (follow this, not the reference's own colours):",g.weather(a,t,o)),"","Negative prompt:","added objects, windows, portholes, lights or beams not in the reference, smoke, people, animals, camera shake beyond the reference,","lens flares not in the reference, any change of the phenomenon's shape, size, colour, brightness, position or motion, text, logos."].join(`
|
|
2
|
-
`)+`
|
|
3
|
-
`}static section(e,t){return t.length>0?["",e,...t]:[]}static text(e,t="en"){if(e!==void 0)return typeof e=="string"?e:e[t]??e.en??Object.values(e)[0]}static shapes(e,t){const a=new Map;for(const r of e.timeline?.keyframes??[])for(const o of r.shapes??[])(r.t<=t*1e3||!a.has(o.sourceId))&&a.set(o.sourceId,o.shape);return a.size===0?["- none drawn."]:[...a.entries()].map(([r,o])=>{const i=o.angular?`${o.angular.widthDeg}° wide and ${o.angular.heightDeg}° tall as seen`:"size not stated",n=o.aim?`, at azimuth ${Math.round(o.aim.azimuthDeg)}°, ${o.aim.altitudeDeg.toFixed(1)}° above the horizon`:"";return`- ${g.text(o.title)??r}: colour ${o.color??"not stated"}, ${i}${n}.`})}static milestones(e,t,a){return(e.milestones??[]).filter(r=>r.t/1e3>=t.fromSeconds&&r.t/1e3<=t.toSeconds).map(r=>`- ${a(r.t/1e3).toFixed(1)} s into the video: ${g.text(r.note)??""}`)}static weather(e,t,a){const r=(e.tags??[]).length>0?[`- ${(e.tags??[]).join(", ")}.`]:[];let o="";for(const i of e.weatherTrack?.keyframes??[]){const n=i.t/1e3;if(n>t.toSeconds)break;const s=g.describe(i.weather);s!==o&&(o=s,r.push(`- ${n<=t.fromSeconds?"from the start":`from ${a(n).toFixed(1)} s into the video`}: ${s}.`))}return r}static describe(e){const t=[];return typeof e.cloudCover=="number"&&t.push(e.cloudCover>=.95?"overcast":`cloud cover ${Math.round(e.cloudCover*100)} %`),typeof e.cloudBaseM=="number"&&t.push(`cloud base ${Math.round(e.cloudBaseM)} m`),t.push(e.precipitationType&&e.precipitationType!=="none"?`${e.precipitationType}, intensity ${e.precipitationIntensity??"not stated"}`:"no precipitation"),t.join(", ")}}class b{static async make(e,t,a,r){const o=Math.max(2,Math.floor(e.film.width/2)*2),i=Math.max(2,Math.floor(e.film.height/2)*2),n=await $(["avc","vp9","av1"],{width:o,height:i});if(!n)throw new Error(`No video codec for ${o}×${i}`);const s=await Promise.all(["depth","phenomenon-mask","sky-mask"].map(w=>b.passFilm(w,o,i,n))),[f,m,h]=s;let l,y,E=0;try{const w=await A.film({...e.film,frameAt:(c,d,M)=>e.film.frameAt(c,d,M)?(l=e.drawControlPasses(),!0):!1,hearInto:c=>e.film.hearInto(c),afterFrame:async(c,d)=>{if(c===0&&(y=await d.canvas.convertToBlob({type:"image/png"})),!l)throw new Error(`No control passes for frame ${c}`);b.paint(l,f.context,m.context,h.context),l=void 0;for(const M of s)await M.source.add(c/A.FRAME_RATE,1/A.FRAME_RATE);E=c+1}},a,r),u=await Promise.all(s.map(async c=>{await c.output.finalize();const d=c.output.target.buffer;if(!d)throw new Error(`Empty ${c.name} film`);return[c.name,new Uint8Array(d)]}));return await b.zipped(e,t,new Uint8Array(await w.arrayBuffer()),u,y,E)}catch(w){throw await Promise.all(s.map(u=>u.output.cancel().catch(()=>{}))),w}}static async passFilm(e,t,a,r){const o=new OffscreenCanvas(t,a),i=o.getContext("2d");if(!i)throw new Error("No 2D context");i.imageSmoothingEnabled=!1;const n=new T({format:new D({fastStart:"in-memory"}),target:new v}),s=new F(o,{codec:r,quality:_});return n.addVideoTrack(s,{frameRate:A.FRAME_RATE}),await n.start(),{name:e,output:n,source:s,context:i}}static paint(e,t,a,r){const{width:o,height:i}=e,n=o*i,s=new Uint8Array(n);p.dilate(e.phenomenon,s,o,i);const f={depth:new ImageData(o,i),phenomenon:new ImageData(o,i),sky:new ImageData(o,i)};for(let l=0;l<n;l++){const y=e.distanceM[l],E=Math.round(p.depthLevel(y)*255),w=y>0?0:255,u=l*4;for(const[c,d]of[[f.depth.data,E],[f.phenomenon.data,s[l]],[f.sky.data,w]])c[u]=d,c[u+1]=d,c[u+2]=d,c[u+3]=255}const m=new OffscreenCanvas(o,i),h=m.getContext("2d");for(const[l,y]of[[t,f.depth],[a,f.phenomenon],[r,f.sky]])h.putImageData(y,0,0),l.drawImage(m,0,0,l.canvas.width,l.canvas.height)}static zipped(e,t,a,r,o,i){const n=new TextEncoder,s=e.film.fromMs/1e3,f=e.film.toMs/1e3,m=e.film.rate>0?e.film.rate:1,h=Math.round(i/A.FRAME_RATE*10)/10,l=new Date().toISOString().slice(0,10),y={title:e.title,source:e.source??"",date:l,fps:String(A.FRAME_RATE),duration:String(h),near:String(p.DEPTH_NEAR_M),far:String(p.DEPTH_FAR_M),margin:String(p.MASK_MARGIN_PX),label:t.label},E=t.readme.replace(/\{(\w+)\}/g,(d,M)=>y[M]??d),w={title:e.title,source:e.source,madeBy:A.MADE_BY,date:l,clip:{fromSeconds:s/m,toSeconds:f/m,fps:A.FRAME_RATE,frames:i,width:e.film.width,height:e.film.height},depth:{encoding:"1 - ln(d / near) / ln(far / near), clamped to 0..1; 0 for the sky",nearM:p.DEPTH_NEAR_M,farM:p.DEPTH_FAR_M},phenomenonMaskMarginPx:p.MASK_MARGIN_PX,label:t.label},u={level:0},c={"reference.mp4":[a,u],...Object.fromEntries(r.map(([d,M])=>[`${d}.mp4`,[M,u]])),"prompt.txt":n.encode(g.of(e.recording,{fromSeconds:s,toSeconds:f,rate:m})),[t.readmeFile]:n.encode(E),"manifest.json":n.encode(JSON.stringify(w,null,2)+`
|
|
4
|
-
`)};return(async()=>(o&&(c["first-frame.png"]=[new Uint8Array(await o.arrayBuffer()),u]),new Promise((d,M)=>x(c,(R,S)=>R?M(R):d(new Blob([S],{type:"application/zip"}))))))()}}export{b as GenerativeKit};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{zip as x}from"./browser-CltifEM0.js";import{g as $,V as A,O as T,B as v,M as D,C as F,Q as _}from"./VideoExport-B8ZhHNnd.js";class p{static DEPTH_NEAR_M=1;static DEPTH_FAR_M=2e4;static MASK_MARGIN_PX=4;static depthLevel(e){if(!(e>0))return 0;const t=1-Math.log(e/p.DEPTH_NEAR_M)/Math.log(p.DEPTH_FAR_M/p.DEPTH_NEAR_M);return Math.min(1,Math.max(0,t))}static dilate(e,t,a,r,o=p.MASK_MARGIN_PX){const i=new Uint8Array(e.length);for(let n=0;n<r;n++)for(let s=0;s<a;s++){let f=0;for(let m=-o;m<=o&&!f;m++){const h=s+m;h>=0&&h<a&&e[n*a+h]&&(f=255)}i[n*a+s]=f}for(let n=0;n<r;n++)for(let s=0;s<a;s++){let f=0;for(let m=-o;m<=o&&!f;m++){const h=n+m;h>=0&&h<r&&i[h*a+s]&&(f=255)}t[n*a+s]=f}}}class g{static of(e,t){const a=e,r=t.rate&&t.rate>0?t.rate:1,o=n=>Math.max(0,(n-t.fromSeconds)/r);return[`Realistic, steady first-person view, as seen by a pedestrian's own eyes, ${a.place?.name??"place not stated"}, local time ${a.time??"not stated"}.`,"Keep exactly the geometry, horizon, framing, lighting and motion of the reference video: only make the textures (vegetation, ground,","buildings, clouds, rain) photographic. Render the phenomenon as realistically as the rest (same grain, blur, haze and light), but keep","its shape, size, colour, brightness, position and motion exactly those of the reference video.","","Phenomenon, as drawn by the reconstruction from the testimony:",...g.shapes(a,t.fromSeconds),...g.section("What happens:",g.milestones(a,t,o)),...g.section("Weather and light (follow this, not the reference's own colours):",g.weather(a,t,o)),"","Negative prompt:","added objects, windows, portholes, lights or beams not in the reference, smoke, people, animals, camera shake beyond the reference,","lens flares not in the reference, any change of the phenomenon's shape, size, colour, brightness, position or motion, text, logos."].join(`
|
|
2
|
-
`)+`
|
|
3
|
-
`}static section(e,t){return t.length>0?["",e,...t]:[]}static text(e,t="en"){if(e!==void 0)return typeof e=="string"?e:e[t]??e.en??Object.values(e)[0]}static shapes(e,t){const a=new Map;for(const r of e.timeline?.keyframes??[])for(const o of r.shapes??[])(r.t<=t*1e3||!a.has(o.sourceId))&&a.set(o.sourceId,o.shape);return a.size===0?["- none drawn."]:[...a.entries()].map(([r,o])=>{const i=o.angular?`${o.angular.widthDeg}° wide and ${o.angular.heightDeg}° tall as seen`:"size not stated",n=o.aim?`, at azimuth ${Math.round(o.aim.azimuthDeg)}°, ${o.aim.altitudeDeg.toFixed(1)}° above the horizon`:"";return`- ${g.text(o.title)??r}: colour ${o.color??"not stated"}, ${i}${n}.`})}static milestones(e,t,a){return(e.milestones??[]).filter(r=>r.t/1e3>=t.fromSeconds&&r.t/1e3<=t.toSeconds).map(r=>`- ${a(r.t/1e3).toFixed(1)} s into the video: ${g.text(r.note)??""}`)}static weather(e,t,a){const r=(e.tags??[]).length>0?[`- ${(e.tags??[]).join(", ")}.`]:[];let o="";for(const i of e.weatherTrack?.keyframes??[]){const n=i.t/1e3;if(n>t.toSeconds)break;const s=g.describe(i.weather);s!==o&&(o=s,r.push(`- ${n<=t.fromSeconds?"from the start":`from ${a(n).toFixed(1)} s into the video`}: ${s}.`))}return r}static describe(e){const t=[];return typeof e.cloudCover=="number"&&t.push(e.cloudCover>=.95?"overcast":`cloud cover ${Math.round(e.cloudCover*100)} %`),typeof e.cloudBaseM=="number"&&t.push(`cloud base ${Math.round(e.cloudBaseM)} m`),t.push(e.precipitationType&&e.precipitationType!=="none"?`${e.precipitationType}, intensity ${e.precipitationIntensity??"not stated"}`:"no precipitation"),t.join(", ")}}class b{static async make(e,t,a,r){const o=Math.max(2,Math.floor(e.film.width/2)*2),i=Math.max(2,Math.floor(e.film.height/2)*2),n=await $(["avc","vp9","av1"],{width:o,height:i});if(!n)throw new Error(`No video codec for ${o}×${i}`);const s=await Promise.all(["depth","phenomenon-mask","sky-mask"].map(w=>b.passFilm(w,o,i,n))),[f,m,h]=s;let l,y,E=0;try{const w=await A.film({...e.film,frameAt:(c,d,M)=>e.film.frameAt(c,d,M)?(l=e.drawControlPasses(),!0):!1,hearInto:c=>e.film.hearInto(c),afterFrame:async(c,d)=>{if(c===0&&(y=await d.canvas.convertToBlob({type:"image/png"})),!l)throw new Error(`No control passes for frame ${c}`);b.paint(l,f.context,m.context,h.context),l=void 0;for(const M of s)await M.source.add(c/A.FRAME_RATE,1/A.FRAME_RATE);E=c+1}},a,r),u=await Promise.all(s.map(async c=>{await c.output.finalize();const d=c.output.target.buffer;if(!d)throw new Error(`Empty ${c.name} film`);return[c.name,new Uint8Array(d)]}));return await b.zipped(e,t,new Uint8Array(await w.arrayBuffer()),u,y,E)}catch(w){throw await Promise.all(s.map(u=>u.output.cancel().catch(()=>{}))),w}}static async passFilm(e,t,a,r){const o=new OffscreenCanvas(t,a),i=o.getContext("2d");if(!i)throw new Error("No 2D context");i.imageSmoothingEnabled=!1;const n=new T({format:new D({fastStart:"in-memory"}),target:new v}),s=new F(o,{codec:r,quality:_});return n.addVideoTrack(s,{frameRate:A.FRAME_RATE}),await n.start(),{name:e,output:n,source:s,context:i}}static paint(e,t,a,r){const{width:o,height:i}=e,n=o*i,s=new Uint8Array(n);p.dilate(e.phenomenon,s,o,i);const f={depth:new ImageData(o,i),phenomenon:new ImageData(o,i),sky:new ImageData(o,i)};for(let l=0;l<n;l++){const y=e.distanceM[l],E=Math.round(p.depthLevel(y)*255),w=y>0?0:255,u=l*4;for(const[c,d]of[[f.depth.data,E],[f.phenomenon.data,s[l]],[f.sky.data,w]])c[u]=d,c[u+1]=d,c[u+2]=d,c[u+3]=255}const m=new OffscreenCanvas(o,i),h=m.getContext("2d");for(const[l,y]of[[t,f.depth],[a,f.phenomenon],[r,f.sky]])h.putImageData(y,0,0),l.drawImage(m,0,0,l.canvas.width,l.canvas.height)}static zipped(e,t,a,r,o,i){const n=new TextEncoder,s=e.film.fromMs/1e3,f=e.film.toMs/1e3,m=e.film.rate>0?e.film.rate:1,h=Math.round(i/A.FRAME_RATE*10)/10,l=new Date().toISOString().slice(0,10),y={title:e.title,source:e.source??"",date:l,fps:String(A.FRAME_RATE),duration:String(h),near:String(p.DEPTH_NEAR_M),far:String(p.DEPTH_FAR_M),margin:String(p.MASK_MARGIN_PX),label:t.label},E=t.readme.replace(/\{(\w+)\}/g,(d,M)=>y[M]??d),w={title:e.title,source:e.source,madeBy:A.MADE_BY,date:l,clip:{fromSeconds:s/m,toSeconds:f/m,fps:A.FRAME_RATE,frames:i,width:e.film.width,height:e.film.height},depth:{encoding:"1 - ln(d / near) / ln(far / near), clamped to 0..1; 0 for the sky",nearM:p.DEPTH_NEAR_M,farM:p.DEPTH_FAR_M},phenomenonMaskMarginPx:p.MASK_MARGIN_PX,label:t.label},u={level:0},c={"reference.mp4":[a,u],...Object.fromEntries(r.map(([d,M])=>[`${d}.mp4`,[M,u]])),"prompt.txt":n.encode(g.of(e.recording,{fromSeconds:s,toSeconds:f,rate:m})),[t.readmeFile]:n.encode(E),"manifest.json":n.encode(JSON.stringify(w,null,2)+`
|
|
4
|
-
`)};return(async()=>(o&&(c["first-frame.png"]=[new Uint8Array(await o.arrayBuffer()),u]),new Promise((d,M)=>x(c,(R,S)=>R?M(R):d(new Blob([S],{type:"application/zip"}))))))()}}export{b as GenerativeKit};
|