feat(hero): 机房场景退役 + 抽象数据场落库(ADR-0016 §17 撤回 / §17.5 继任)
退役(零视觉影响:NEXT_PUBLIC_HERO_SCENE 从未在任何 .env* 设置): - 删 hero-scene.tsx(694行)/caption/单测/文案真源/CC0 机柜/海报帧 - R26 删除、R22 登记归零、e2e heroSceneMask 移除(无命中的假安全网) - R22 自证改可注入(夹具不再依赖生产条目) 落库(flag NEXT_PUBLIC_HERO_FIELD 样期默认关 ⇒ 基线零影响): - hero-field.tsx 三拍:噪声→增长→判断;bloom 半分辨率;DPR≤1.5 - 降级统一看结论帧(reduced-motion 定格 T_HOLD=40500 非 0) - 文案真源含承诺词正则守卫(禁帮助/赋能/提升/%/倍) - 海报帧 capture 脚本与资产同批入库(1920x864/26.9KB,可复现) - eslint 忽略 demo/**/vendor/**(vendored three 不可被 lint-staged --fix 改写) 守卫重建:R26 指向 hero-field(43260ms/3 拍合规);R22 登记 HeroField 条目 验证:tsc 0 / eslint 0 error / jest 162 套件 1906 例 / check:grammar 26+26 / check:a11y 0 违规 / 默认构建首页 DOM 冒烟 E 案不变
This commit was merged in pull request #65.
This commit is contained in:
1 parent
2bb342cfa9
commit
6ce794164a
108 files changed
+98666
-1005
No files matched your search
@@ -0,0 +1,267 @@
|
||||
import {
|
||||
HalfFloatType,
|
||||
ShaderMaterial,
|
||||
WebGLRenderTarget
|
||||
} from 'three';
|
||||
import { FullScreenQuad, Pass } from './Pass.js';
|
||||
|
||||
/**
|
||||
* A special type of render pass for implementing transition effects.
|
||||
* When active, the pass will transition from scene A to scene B.
|
||||
*
|
||||
* ```js
|
||||
* const renderTransitionPass = new RenderTransitionPass( fxSceneA.scene, fxSceneA.camera, fxSceneB.scene, fxSceneB.camera );
|
||||
* renderTransitionPass.setTexture( textures[ 0 ] );
|
||||
* composer.addPass( renderTransitionPass );
|
||||
* ```
|
||||
*
|
||||
* @augments Pass
|
||||
* @three_import import { RenderTransitionPass } from 'three/addons/postprocessing/RenderTransitionPass.js';
|
||||
*/
|
||||
class RenderTransitionPass extends Pass {
|
||||
|
||||
/**
|
||||
* Constructs a render transition pass.
|
||||
*
|
||||
* @param {Scene} sceneA - The first scene.
|
||||
* @param {Camera} cameraA - The camera of the first scene.
|
||||
* @param {Scene} sceneB - The second scene.
|
||||
* @param {Camera} cameraB - The camera of the second scene.
|
||||
*/
|
||||
constructor( sceneA, cameraA, sceneB, cameraB ) {
|
||||
|
||||
super();
|
||||
|
||||
/**
|
||||
* The first scene.
|
||||
*
|
||||
* @type {Scene}
|
||||
*/
|
||||
this.sceneA = sceneA;
|
||||
|
||||
|
||||
/**
|
||||
* The camera of the first scene.
|
||||
*
|
||||
* @type {Camera}
|
||||
*/
|
||||
this.cameraA = cameraA;
|
||||
|
||||
/**
|
||||
* The second scene.
|
||||
*
|
||||
* @type {Scene}
|
||||
*/
|
||||
this.sceneB = sceneB;
|
||||
|
||||
/**
|
||||
* The camera of the second scene.
|
||||
*
|
||||
* @type {Camera}
|
||||
*/
|
||||
this.cameraB = cameraB;
|
||||
|
||||
/**
|
||||
* The pass material.
|
||||
*
|
||||
* @type {ShaderMaterial}
|
||||
*/
|
||||
this.material = this._createMaterial();
|
||||
|
||||
// internals
|
||||
|
||||
this._renderTargetA = new WebGLRenderTarget();
|
||||
this._renderTargetA.texture.type = HalfFloatType;
|
||||
this._renderTargetB = new WebGLRenderTarget();
|
||||
this._renderTargetB.texture.type = HalfFloatType;
|
||||
|
||||
this._fsQuad = new FullScreenQuad( this.material );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the transition factor. Must be in the range `[0,1]`.
|
||||
* This value determines to what degree both scenes are mixed.
|
||||
*
|
||||
* @param {boolean|number} value - The transition factor.
|
||||
*/
|
||||
setTransition( value ) {
|
||||
|
||||
this.material.uniforms.mixRatio.value = value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the usage of a texture for the effect.
|
||||
*
|
||||
* @param {boolean} value - Whether to use a texture for the transition effect or not.
|
||||
*/
|
||||
useTexture( value ) {
|
||||
|
||||
this.material.uniforms.useTexture.value = value ? 1 : 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the effect texture.
|
||||
*
|
||||
* @param {Texture} value - The effect texture.
|
||||
*/
|
||||
setTexture( value ) {
|
||||
|
||||
this.material.uniforms.tMixTexture.value = value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the texture threshold. This value defines how strong the texture effects
|
||||
* the transition. Must be in the range `[0,1]` (0 means full effect, 1 means no effect).
|
||||
*
|
||||
* @param {boolean|number} value - The threshold value.
|
||||
*/
|
||||
setTextureThreshold( value ) {
|
||||
|
||||
this.material.uniforms.threshold.value = value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of the pass.
|
||||
*
|
||||
* @param {number} width - The width to set.
|
||||
* @param {number} height - The height to set.
|
||||
*/
|
||||
setSize( width, height ) {
|
||||
|
||||
this._renderTargetA.setSize( width, height );
|
||||
this._renderTargetB.setSize( width, height );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the transition pass.
|
||||
*
|
||||
* @param {WebGLRenderer} renderer - The renderer.
|
||||
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
||||
* destination for the pass.
|
||||
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
||||
* previous pass from this buffer.
|
||||
* @param {number} deltaTime - The delta time in seconds.
|
||||
* @param {boolean} maskActive - Whether masking is active or not.
|
||||
*/
|
||||
render( renderer, writeBuffer/*, readBuffer , deltaTime, maskActive */ ) {
|
||||
|
||||
renderer.setRenderTarget( this._renderTargetA );
|
||||
renderer.render( this.sceneA, this.cameraA );
|
||||
renderer.setRenderTarget( this._renderTargetB );
|
||||
renderer.render( this.sceneB, this.cameraB );
|
||||
|
||||
const uniforms = this._fsQuad.material.uniforms;
|
||||
uniforms.tDiffuse1.value = this._renderTargetA.texture;
|
||||
uniforms.tDiffuse2.value = this._renderTargetB.texture;
|
||||
|
||||
if ( this.renderToScreen ) {
|
||||
|
||||
renderer.setRenderTarget( null );
|
||||
renderer.clear();
|
||||
|
||||
} else {
|
||||
|
||||
renderer.setRenderTarget( writeBuffer );
|
||||
if ( this.clear ) renderer.clear();
|
||||
|
||||
}
|
||||
|
||||
this._fsQuad.render( renderer );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the GPU-related resources allocated by this instance. Call this
|
||||
* method whenever the pass is no longer used in your app.
|
||||
*/
|
||||
dispose() {
|
||||
|
||||
this.material.dispose();
|
||||
|
||||
this._renderTargetA.dispose();
|
||||
this._renderTargetB.dispose();
|
||||
this._fsQuad.dispose();
|
||||
|
||||
}
|
||||
|
||||
// internals
|
||||
|
||||
_createMaterial() {
|
||||
|
||||
return new ShaderMaterial( {
|
||||
uniforms: {
|
||||
tDiffuse1: {
|
||||
value: null
|
||||
},
|
||||
tDiffuse2: {
|
||||
value: null
|
||||
},
|
||||
mixRatio: {
|
||||
value: 0.0
|
||||
},
|
||||
threshold: {
|
||||
value: 0.1
|
||||
},
|
||||
useTexture: {
|
||||
value: 1
|
||||
},
|
||||
tMixTexture: {
|
||||
value: null
|
||||
}
|
||||
},
|
||||
vertexShader: /* glsl */`
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
vUv = vec2( uv.x, uv.y );
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||||
|
||||
}
|
||||
`,
|
||||
fragmentShader: /* glsl */`
|
||||
uniform float mixRatio;
|
||||
|
||||
uniform sampler2D tDiffuse1;
|
||||
uniform sampler2D tDiffuse2;
|
||||
uniform sampler2D tMixTexture;
|
||||
|
||||
uniform int useTexture;
|
||||
uniform float threshold;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 texel1 = texture2D( tDiffuse1, vUv );
|
||||
vec4 texel2 = texture2D( tDiffuse2, vUv );
|
||||
|
||||
if (useTexture == 1) {
|
||||
|
||||
vec4 transitionTexel = texture2D( tMixTexture, vUv );
|
||||
float r = mixRatio * ( 1.0 + threshold * 2.0 ) - threshold;
|
||||
float mixf = clamp( ( transitionTexel.r - r ) * ( 1.0 / threshold ), 0.0, 1.0 );
|
||||
|
||||
gl_FragColor = mix( texel1, texel2, mixf );
|
||||
|
||||
} else {
|
||||
|
||||
gl_FragColor = mix( texel2, texel1, mixRatio );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
`
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { RenderTransitionPass };
|
||||
Reference in new issue
Block a user