/** Capture Three-expanded courtyard/photo sources for optional offline compilers. * This script creates no WebGL context and does not claim browser or GPU QA. */ import fs from 'node:fs'; import * as THREE from 'three'; import {WebGLProgram} from 'three/src/renderers/webgl/WebGLProgram.js'; import {loadTypescript} from './load-typescript.mjs'; const {ExperimentalCourtyard}=await loadTypescript(new URL('../../src/objects/ExperimentalCourtyard.ts',import.meta.url)); const {PetDepthMesh}=await loadTypescript(new URL('../../src/objects/PetDepthMesh.ts',import.meta.url)); const {createHousePhotoOccluder}=await loadTypescript(new URL('../../src/objects/BlenderHouseSurround.ts',import.meta.url)); const courtyard=new ExperimentalCourtyard(),photo=new PetDepthMesh(new THREE.Texture(),new THREE.Texture()),occluder=createHousePhotoOccluder(photo); for(const [name,material] of [['courtyard',courtyard.group.children[0].material],['peeking-photo',photo.material],['peeking-occluder',occluder.mesh.material]]){ const params={vertexShader:material.vertexShader,fragmentShader:material.fragmentShader,uniforms:material.uniforms,defines:material.defines,precision:'highp',shaderType:'ShaderMaterial',shaderName:name,isRawShaderMaterial:false,toneMapping:THREE.NoToneMapping,outputColorSpace:THREE.LinearSRGBColorSpace,numDirLights:0,numPointLights:0,numSpotLights:0,numSpotLightMaps:0,numRectAreaLights:0,numHemiLights:0,numDirLightShadows:0,numSpotLightShadows:0,numSpotLightShadowsWithMaps:0,numPointLightShadows:0,numClippingPlanes:0,numClipIntersection:0}; const sentinel=new Error('offline-source-capture-complete'); const gl={VERTEX_SHADER:0,FRAGMENT_SHADER:1,createProgram:()=>({}),createShader:type=>({type}),shaderSource:(shader,source)=>fs.writeFileSync(`/tmp/b-review-${name}.${shader.type===0?'vert':'frag'}`,source),compileShader:shader=>{if(shader.type===1)throw sentinel;}}; try{new WebGLProgram({getContext:()=>gl},name,params,{});throw new Error(`Missing capture for ${name}`);}catch(error){if(error!==sentinel)throw error;console.log(`Captured r169 ${name} shader sources (no GL execution)`);} } occluder.dispose();courtyard.dispose();photo.geometry.dispose();photo.material.dispose(); photo.material.uniforms.uTexture.value.dispose();photo.material.uniforms.uDepthMap.value.dispose();