Skip to content
21 changes: 21 additions & 0 deletions .github/workflows/archive-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
- run: npm install
- name: Install isolated image processing tools
run: npm install --prefix "$RUNNER_TEMP/gallery-tools" --no-package-lock --no-save sharp@0.35.4
- name: Prepare verified garden assets
run: node scripts/prepare-garden-assets.mjs
env:
GALLERY_TOOLS_DIR: ${{ runner.temp }}/gallery-tools
- name: Validate records, permissions and image processing
run: node --test scripts/archive.test.mjs scripts/seasons.test.mjs
env:
Expand All @@ -40,3 +44,20 @@ jobs:
test -s github-dist/3d-alpha/index.html
test -s github-dist/art-data/manifest.json
test -s github-dist/records/index.json
- name: Install isolated cloud browser
run: |
sudo apt-get update -qq
sudo apt-get install -y fonts-noto-cjk
npm install --prefix "$RUNNER_TEMP/gallery-tools" --no-package-lock --no-save sharp@0.35.4 playwright@1.63.0
"$RUNNER_TEMP/gallery-tools/node_modules/.bin/playwright" install --with-deps chromium
- name: Check all styles and camera interactions in cloud Chromium
run: node scripts/garden-browser-check.mjs
env:
GALLERY_TOOLS_DIR: ${{ runner.temp }}/gallery-tools
- name: Save visual review evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: garden-visual-review
path: garden-qa
retention-days: 7
6 changes: 5 additions & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Install isolated image processing tools
run: npm install --prefix "$RUNNER_TEMP/gallery-tools" --no-package-lock --no-save sharp@0.35.4
- name: Validate archive security and image processing
run: node --test scripts/archive.test.mjs
run: node --test scripts/archive.test.mjs scripts/seasons.test.mjs
env:
GALLERY_TOOLS_DIR: ${{ runner.temp }}/gallery-tools
- name: Prepare owner artwork and growth records
Expand All @@ -54,6 +54,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
GALLERY_TOOLS_DIR: ${{ runner.temp }}/gallery-tools
- name: Prepare verified garden assets
run: node scripts/prepare-garden-assets.mjs
env:
GALLERY_TOOLS_DIR: ${{ runner.temp }}/gallery-tools
- name: Build website
run: npm run build
- name: Save knowledge and journal files in GitHub
Expand Down
172 changes: 116 additions & 56 deletions app/garden/SeasonGarden.tsx

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions app/garden/garden.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions app/garden/presentation.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import * as T from "three";
import {EffectComposer} from "three/addons/postprocessing/EffectComposer.js";
import {RenderPass} from "three/addons/postprocessing/RenderPass.js";
import {ShaderPass} from "three/addons/postprocessing/ShaderPass.js";
import {OutputPass} from "three/addons/postprocessing/OutputPass.js";
export const STYLES=[
{id:"real",name:"写实",description:"自然光 · 真实纹理"},
{id:"anime",name:"动漫",description:"赛璐璐 · 明快色层"},
{id:"ink",name:"水墨",description:"淡墨远山 · 宣纸留白"},
];
const vertexShader="varying vec2 vUv; void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.);}";
const fragmentShader=`
uniform sampler2D tDiffuse;
uniform vec2 resolution;
uniform float mode;
varying vec2 vUv;
float lum(vec3 c){return dot(c,vec3(.299,.587,.114));}
float hash(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}
void main(){
vec3 c=texture2D(tDiffuse,vUv).rgb;
vec2 px=1./resolution;
float l=lum(c);
float dx=lum(texture2D(tDiffuse,vUv+vec2(px.x,0.)).rgb)-lum(texture2D(tDiffuse,vUv-vec2(px.x,0.)).rgb);
float dy=lum(texture2D(tDiffuse,vUv+vec2(0.,px.y)).rgb)-lum(texture2D(tDiffuse,vUv-vec2(0.,px.y)).rgb);
float edge=smoothstep(.045,.3,length(vec2(dx,dy)));
if(mode>.5&&mode<1.5){
c=mix(c,vec3(.09,.14,.17),edge*.38);
c=mix(vec3(l),c,1.13);
}else if(mode>1.5){
vec3 base=c;
float grain=hash(floor(vUv*resolution))-.5;
float fibers=sin(vUv.x*resolution.x*.85+sin(vUv.y*resolution.y*.19));
vec3 paper=vec3(.94,.914,.845);
float wash=smoothstep(.04,.85,l);
c=mix(vec3(.12,.16,.155),paper,wash);
c-=edge*.035;
c+=(grain*.022+fibers*.004);
float vermilion=step(base.g*1.15,base.r)*step(base.b*1.25,base.r)*step(.3,base.r);
c=mix(c,vec3(.61,.27,.20),vermilion*.7);
}
gl_FragColor=vec4(c,1.);
}`;
export function createPresentation(renderer,scene,camera){
const composer=new EffectComposer(renderer);
composer.addPass(new RenderPass(scene,camera));
const pass=new ShaderPass({uniforms:{tDiffuse:{value:null},resolution:{value:new T.Vector2(1,1)},mode:{value:0}},vertexShader,fragmentShader});
composer.addPass(new OutputPass());composer.addPass(pass);
return {
setStyle(id){pass.uniforms.mode.value=id==="ink"?2:id==="anime"?1:0;},
resize(w,h){composer.setSize(w,h);pass.uniforms.resolution.value.set(w*renderer.getPixelRatio(),h*renderer.getPixelRatio());},
render(){composer.render();},
dispose(){for(const p of composer.passes)p.dispose?.();composer.dispose();}
};
}
26 changes: 20 additions & 6 deletions app/garden/seasons.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
export const SEASONS=[
{name:"春",en:"SPRING",note:"新芽初醒 · 花瓣与微雨",sky:"#091b25",leaf:"#efacc7",second:"#99e6b7",ground:"#163b32",sun:"#ffd8ac",rain:.25,snow:0,foliage:1},
{name:"夏",en:"SUMMER",note:"枝叶繁盛 · 日光与雨露",sky:"#08212b",leaf:"#43b784",second:"#a3ec8c",ground:"#124c36",sun:"#fff0a6",rain:.75,snow:0,foliage:1.15},
{name:"秋",en:"AUTUMN",note:"风过树梢 · 金色的告别",sky:"#251724",leaf:"#f88a3b",second:"#f7c35b",ground:"#443321",sun:"#ffb66f",rain:0,snow:0,foliage:.78},
{name:"冬",en:"WINTER",note:"雪落无声 · 等待下一次生长",sky:"#101e34",leaf:"#d7e7f5",second:"#c3dbf4",ground:"#78929f",sun:"#b6d4ff",rain:0,snow:1,foliage:.05}
];
export const SEASON_HOLD_SECONDS=18;
export const SEASON_TRANSITION_SECONDS=4;
export const SEASON_DURATION_SECONDS=22;
export const SEASON_CYCLE_SECONDS=88;
export const SEASONS=Object.freeze([
Object.freeze({id:"spring",name:"春",en:"SPRING",note:"春雨润新芽"}),
Object.freeze({id:"summer",name:"夏",en:"SUMMER",note:"日光穿过繁叶"}),
Object.freeze({id:"autumn",name:"秋",en:"AUTUMN",note:"风起,金叶飘落"}),
Object.freeze({id:"winter",name:"冬",en:"WINTER",note:"枝影映雪,静待新生"}),
]);
export function sampleSeason(elapsedSeconds){
if(typeof elapsedSeconds!=="number"||!Number.isFinite(elapsedSeconds))throw new TypeError("elapsedSeconds must be a finite number");
const remainder=elapsedSeconds%SEASON_CYCLE_SECONDS;
const wrapped=remainder<0?remainder+SEASON_CYCLE_SECONDS:remainder;
const time=wrapped>=SEASON_CYCLE_SECONDS||Object.is(wrapped,-0)?0:wrapped;
const from=Math.floor(time/SEASON_DURATION_SECONDS),local=time-from*SEASON_DURATION_SECONDS;
const transitioning=local>=SEASON_HOLD_SECONDS,to=transitioning?(from+1)%4:from;
const progress=transitioning?Math.min(1,(local-SEASON_HOLD_SECONDS)/SEASON_TRANSITION_SECONDS):0;
return {from,to,mix:progress*progress*(3-2*progress),transitioning,label:transitioning?SEASONS[from].name+" → "+SEASONS[to].name:SEASONS[from].name};
}
Loading
Loading