opencode-agent-flow 0.0.0-stage → 0.1.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.
@@ -0,0 +1,195 @@
1
+ import { Pass } from './Pass.js';
2
+
3
+ /**
4
+ * This pass can be used to define a mask during post processing.
5
+ * Meaning only areas of subsequent post processing are affected
6
+ * which lie in the masking area of this pass. Internally, the masking
7
+ * is implemented with the stencil buffer.
8
+ *
9
+ * ```js
10
+ * const maskPass = new MaskPass( scene, camera );
11
+ * composer.addPass( maskPass );
12
+ * ```
13
+ *
14
+ * @augments Pass
15
+ * @three_import import { MaskPass } from 'three/addons/postprocessing/MaskPass.js';
16
+ */
17
+ class MaskPass extends Pass {
18
+
19
+ /**
20
+ * Constructs a new mask pass.
21
+ *
22
+ * @param {Scene} scene - The 3D objects in this scene will define the mask.
23
+ * @param {Camera} camera - The camera.
24
+ */
25
+ constructor( scene, camera ) {
26
+
27
+ super();
28
+
29
+ /**
30
+ * The scene that defines the mask.
31
+ *
32
+ * @type {Scene}
33
+ */
34
+ this.scene = scene;
35
+
36
+ /**
37
+ * The camera.
38
+ *
39
+ * @type {Camera}
40
+ */
41
+ this.camera = camera;
42
+
43
+ /**
44
+ * Overwritten to perform a clear operation by default.
45
+ *
46
+ * @type {boolean}
47
+ * @default true
48
+ */
49
+ this.clear = true;
50
+
51
+ /**
52
+ * Overwritten to disable the swap.
53
+ *
54
+ * @type {boolean}
55
+ * @default false
56
+ */
57
+ this.needsSwap = false;
58
+
59
+ /**
60
+ * Whether to inverse the mask or not.
61
+ *
62
+ * @type {boolean}
63
+ * @default false
64
+ */
65
+ this.inverse = false;
66
+
67
+ }
68
+
69
+ /**
70
+ * Performs a mask pass with the configured scene and camera.
71
+ *
72
+ * @param {WebGLRenderer} renderer - The renderer.
73
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
74
+ * destination for the pass.
75
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
76
+ * previous pass from this buffer.
77
+ * @param {number} deltaTime - The delta time in seconds.
78
+ * @param {boolean} maskActive - Whether masking is active or not.
79
+ */
80
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
81
+
82
+ const context = renderer.getContext();
83
+ const state = renderer.state;
84
+
85
+ // don't update color or depth
86
+
87
+ state.buffers.color.setMask( false );
88
+ state.buffers.depth.setMask( false );
89
+
90
+ // lock buffers
91
+
92
+ state.buffers.color.setLocked( true );
93
+ state.buffers.depth.setLocked( true );
94
+
95
+ // set up stencil
96
+
97
+ let writeValue, clearValue;
98
+
99
+ if ( this.inverse ) {
100
+
101
+ writeValue = 0;
102
+ clearValue = 1;
103
+
104
+ } else {
105
+
106
+ writeValue = 1;
107
+ clearValue = 0;
108
+
109
+ }
110
+
111
+ state.buffers.stencil.setTest( true );
112
+ state.buffers.stencil.setOp( context.REPLACE, context.REPLACE, context.REPLACE );
113
+ state.buffers.stencil.setFunc( context.ALWAYS, writeValue, 0xffffffff );
114
+ state.buffers.stencil.setClear( clearValue );
115
+ state.buffers.stencil.setLocked( true );
116
+
117
+ // draw into the stencil buffer
118
+
119
+ renderer.setRenderTarget( readBuffer );
120
+ if ( this.clear ) renderer.clear();
121
+ renderer.render( this.scene, this.camera );
122
+
123
+ renderer.setRenderTarget( writeBuffer );
124
+ if ( this.clear ) renderer.clear();
125
+ renderer.render( this.scene, this.camera );
126
+
127
+ // unlock color and depth buffer and make them writable for subsequent rendering/clearing
128
+
129
+ state.buffers.color.setLocked( false );
130
+ state.buffers.depth.setLocked( false );
131
+
132
+ state.buffers.color.setMask( true );
133
+ state.buffers.depth.setMask( true );
134
+
135
+ // only render where stencil is set to 1
136
+
137
+ state.buffers.stencil.setLocked( false );
138
+ state.buffers.stencil.setFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1
139
+ state.buffers.stencil.setOp( context.KEEP, context.KEEP, context.KEEP );
140
+ state.buffers.stencil.setLocked( true );
141
+
142
+ }
143
+
144
+ }
145
+
146
+ /**
147
+ * This pass can be used to clear a mask previously defined with {@link MaskPass}.
148
+ *
149
+ * ```js
150
+ * const clearPass = new ClearMaskPass();
151
+ * composer.addPass( clearPass );
152
+ * ```
153
+ *
154
+ * @augments Pass
155
+ */
156
+ class ClearMaskPass extends Pass {
157
+
158
+ /**
159
+ * Constructs a new clear mask pass.
160
+ */
161
+ constructor() {
162
+
163
+ super();
164
+
165
+ /**
166
+ * Overwritten to disable the swap.
167
+ *
168
+ * @type {boolean}
169
+ * @default false
170
+ */
171
+ this.needsSwap = false;
172
+
173
+ }
174
+
175
+ /**
176
+ * Performs the clear of the currently defined mask.
177
+ *
178
+ * @param {WebGLRenderer} renderer - The renderer.
179
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
180
+ * destination for the pass.
181
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
182
+ * previous pass from this buffer.
183
+ * @param {number} deltaTime - The delta time in seconds.
184
+ * @param {boolean} maskActive - Whether masking is active or not.
185
+ */
186
+ render( renderer /*, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
187
+
188
+ renderer.state.buffers.stencil.setLocked( false );
189
+ renderer.state.buffers.stencil.setTest( false );
190
+
191
+ }
192
+
193
+ }
194
+
195
+ export { MaskPass, ClearMaskPass };
@@ -0,0 +1,139 @@
1
+ import {
2
+ ColorManagement,
3
+ RawShaderMaterial,
4
+ UniformsUtils,
5
+ LinearToneMapping,
6
+ ReinhardToneMapping,
7
+ CineonToneMapping,
8
+ AgXToneMapping,
9
+ ACESFilmicToneMapping,
10
+ NeutralToneMapping,
11
+ CustomToneMapping,
12
+ SRGBTransfer
13
+ } from 'three';
14
+ import { Pass, FullScreenQuad } from './Pass.js';
15
+ import { OutputShader } from '../shaders/OutputShader.js';
16
+
17
+ /**
18
+ * This pass is responsible for including tone mapping and color space conversion
19
+ * into your pass chain. In most cases, this pass should be included at the end
20
+ * of each pass chain. If a pass requires sRGB input (e.g. like FXAA), the pass
21
+ * must follow `OutputPass` in the pass chain.
22
+ *
23
+ * The tone mapping and color space settings are extracted from the renderer.
24
+ *
25
+ * ```js
26
+ * const outputPass = new OutputPass();
27
+ * composer.addPass( outputPass );
28
+ * ```
29
+ *
30
+ * @augments Pass
31
+ * @three_import import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
32
+ */
33
+ class OutputPass extends Pass {
34
+
35
+ /**
36
+ * Constructs a new output pass.
37
+ */
38
+ constructor() {
39
+
40
+ super();
41
+
42
+ /**
43
+ * The pass uniforms.
44
+ *
45
+ * @type {Object}
46
+ */
47
+ this.uniforms = UniformsUtils.clone( OutputShader.uniforms );
48
+
49
+ /**
50
+ * The pass material.
51
+ *
52
+ * @type {RawShaderMaterial}
53
+ */
54
+ this.material = new RawShaderMaterial( {
55
+ name: OutputShader.name,
56
+ uniforms: this.uniforms,
57
+ vertexShader: OutputShader.vertexShader,
58
+ fragmentShader: OutputShader.fragmentShader
59
+ } );
60
+
61
+ // internals
62
+
63
+ this._fsQuad = new FullScreenQuad( this.material );
64
+
65
+ this._outputColorSpace = null;
66
+ this._toneMapping = null;
67
+
68
+ }
69
+
70
+ /**
71
+ * Performs the output pass.
72
+ *
73
+ * @param {WebGLRenderer} renderer - The renderer.
74
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
75
+ * destination for the pass.
76
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
77
+ * previous pass from this buffer.
78
+ * @param {number} deltaTime - The delta time in seconds.
79
+ * @param {boolean} maskActive - Whether masking is active or not.
80
+ */
81
+ render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive */ ) {
82
+
83
+ this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
84
+ this.uniforms[ 'toneMappingExposure' ].value = renderer.toneMappingExposure;
85
+
86
+ // rebuild defines if required
87
+
88
+ if ( this._outputColorSpace !== renderer.outputColorSpace || this._toneMapping !== renderer.toneMapping ) {
89
+
90
+ this._outputColorSpace = renderer.outputColorSpace;
91
+ this._toneMapping = renderer.toneMapping;
92
+
93
+ this.material.defines = {};
94
+
95
+ if ( ColorManagement.getTransfer( this._outputColorSpace ) === SRGBTransfer ) this.material.defines.SRGB_TRANSFER = '';
96
+
97
+ if ( this._toneMapping === LinearToneMapping ) this.material.defines.LINEAR_TONE_MAPPING = '';
98
+ else if ( this._toneMapping === ReinhardToneMapping ) this.material.defines.REINHARD_TONE_MAPPING = '';
99
+ else if ( this._toneMapping === CineonToneMapping ) this.material.defines.CINEON_TONE_MAPPING = '';
100
+ else if ( this._toneMapping === ACESFilmicToneMapping ) this.material.defines.ACES_FILMIC_TONE_MAPPING = '';
101
+ else if ( this._toneMapping === AgXToneMapping ) this.material.defines.AGX_TONE_MAPPING = '';
102
+ else if ( this._toneMapping === NeutralToneMapping ) this.material.defines.NEUTRAL_TONE_MAPPING = '';
103
+ else if ( this._toneMapping === CustomToneMapping ) this.material.defines.CUSTOM_TONE_MAPPING = '';
104
+
105
+ this.material.needsUpdate = true;
106
+
107
+ }
108
+
109
+ //
110
+
111
+ if ( this.renderToScreen === true ) {
112
+
113
+ renderer.setRenderTarget( null );
114
+ this._fsQuad.render( renderer );
115
+
116
+ } else {
117
+
118
+ renderer.setRenderTarget( writeBuffer );
119
+ if ( this.clear ) renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
120
+ this._fsQuad.render( renderer );
121
+
122
+ }
123
+
124
+ }
125
+
126
+ /**
127
+ * Frees the GPU-related resources allocated by this instance. Call this
128
+ * method whenever the pass is no longer used in your app.
129
+ */
130
+ dispose() {
131
+
132
+ this.material.dispose();
133
+ this._fsQuad.dispose();
134
+
135
+ }
136
+
137
+ }
138
+
139
+ export { OutputPass };
@@ -0,0 +1,191 @@
1
+ import {
2
+ BufferGeometry,
3
+ Float32BufferAttribute,
4
+ OrthographicCamera,
5
+ Mesh
6
+ } from 'three';
7
+
8
+ /**
9
+ * Abstract base class for all post processing passes.
10
+ *
11
+ * This module is only relevant for post processing with {@link WebGLRenderer}.
12
+ *
13
+ * @abstract
14
+ * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';
15
+ */
16
+ class Pass {
17
+
18
+ /**
19
+ * Constructs a new pass.
20
+ */
21
+ constructor() {
22
+
23
+ /**
24
+ * This flag can be used for type testing.
25
+ *
26
+ * @type {boolean}
27
+ * @readonly
28
+ * @default true
29
+ */
30
+ this.isPass = true;
31
+
32
+ /**
33
+ * If set to `true`, the pass is processed by the composer.
34
+ *
35
+ * @type {boolean}
36
+ * @default true
37
+ */
38
+ this.enabled = true;
39
+
40
+ /**
41
+ * If set to `true`, the pass indicates to swap read and write buffer after rendering.
42
+ *
43
+ * @type {boolean}
44
+ * @default true
45
+ */
46
+ this.needsSwap = true;
47
+
48
+ /**
49
+ * If set to `true`, the pass clears its buffer before rendering
50
+ *
51
+ * @type {boolean}
52
+ * @default false
53
+ */
54
+ this.clear = false;
55
+
56
+ /**
57
+ * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers
58
+ * pass chain gets automatically rendered to screen, no matter how this property is configured.
59
+ *
60
+ * @type {boolean}
61
+ * @default false
62
+ */
63
+ this.renderToScreen = false;
64
+
65
+ }
66
+
67
+ /**
68
+ * Sets the size of the pass.
69
+ *
70
+ * @abstract
71
+ * @param {number} width - The width to set.
72
+ * @param {number} height - The height to set.
73
+ */
74
+ setSize( /* width, height */ ) {}
75
+
76
+ /**
77
+ * This method holds the render logic of a pass. It must be implemented in all derived classes.
78
+ *
79
+ * @abstract
80
+ * @param {WebGLRenderer} renderer - The renderer.
81
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
82
+ * destination for the pass.
83
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
84
+ * previous pass from this buffer.
85
+ * @param {number} deltaTime - The delta time in seconds.
86
+ * @param {boolean} maskActive - Whether masking is active or not.
87
+ */
88
+ render( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
89
+
90
+ console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
91
+
92
+ }
93
+
94
+ /**
95
+ * Frees the GPU-related resources allocated by this instance. Call this
96
+ * method whenever the pass is no longer used in your app.
97
+ *
98
+ * @abstract
99
+ */
100
+ dispose() {}
101
+
102
+ }
103
+
104
+ // Helper for passes that need to fill the viewport with a single quad.
105
+
106
+ const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
107
+
108
+ // https://github.com/mrdoob/three.js/pull/21358
109
+
110
+ class FullscreenTriangleGeometry extends BufferGeometry {
111
+
112
+ constructor() {
113
+
114
+ super();
115
+
116
+ this.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
117
+ this.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
118
+
119
+ }
120
+
121
+ }
122
+
123
+ const _geometry = new FullscreenTriangleGeometry();
124
+
125
+
126
+ /**
127
+ * This module is a helper for passes which need to render a full
128
+ * screen effect which is quite common in context of post processing.
129
+ *
130
+ * The intended usage is to reuse a single full screen quad for rendering
131
+ * subsequent passes by just reassigning the `material` reference.
132
+ *
133
+ * This module can only be used with {@link WebGLRenderer}.
134
+ *
135
+ * @augments Mesh
136
+ * @three_import import { FullScreenQuad } from 'three/addons/postprocessing/Pass.js';
137
+ */
138
+ class FullScreenQuad {
139
+
140
+ /**
141
+ * Constructs a new full screen quad.
142
+ *
143
+ * @param {?Material} material - The material to render te full screen quad with.
144
+ */
145
+ constructor( material ) {
146
+
147
+ this._mesh = new Mesh( _geometry, material );
148
+
149
+ }
150
+
151
+ /**
152
+ * Frees the GPU-related resources allocated by this instance. Call this
153
+ * method whenever the instance is no longer used in your app.
154
+ */
155
+ dispose() {
156
+
157
+ this._mesh.geometry.dispose();
158
+
159
+ }
160
+
161
+ /**
162
+ * Renders the full screen quad.
163
+ *
164
+ * @param {WebGLRenderer} renderer - The renderer.
165
+ */
166
+ render( renderer ) {
167
+
168
+ renderer.render( this._mesh, _camera );
169
+
170
+ }
171
+
172
+ /**
173
+ * The quad's material.
174
+ *
175
+ * @type {?Material}
176
+ */
177
+ get material() {
178
+
179
+ return this._mesh.material;
180
+
181
+ }
182
+
183
+ set material( value ) {
184
+
185
+ this._mesh.material = value;
186
+
187
+ }
188
+
189
+ }
190
+
191
+ export { Pass, FullScreenQuad };
@@ -0,0 +1,183 @@
1
+ import {
2
+ Color
3
+ } from 'three';
4
+ import { Pass } from './Pass.js';
5
+
6
+ /**
7
+ * This class represents a render pass. It takes a camera and a scene and produces
8
+ * a beauty pass for subsequent post processing effects.
9
+ *
10
+ * ```js
11
+ * const renderPass = new RenderPass( scene, camera );
12
+ * composer.addPass( renderPass );
13
+ * ```
14
+ *
15
+ * @augments Pass
16
+ * @three_import import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
17
+ */
18
+ class RenderPass extends Pass {
19
+
20
+ /**
21
+ * Constructs a new render pass.
22
+ *
23
+ * @param {Scene} scene - The scene to render.
24
+ * @param {Camera} camera - The camera.
25
+ * @param {?Material} [overrideMaterial=null] - The override material. If set, this material is used
26
+ * for all objects in the scene.
27
+ * @param {?(number|Color|string)} [clearColor=null] - The clear color of the render pass.
28
+ * @param {?number} [clearAlpha=null] - The clear alpha of the render pass.
29
+ */
30
+ constructor( scene, camera, overrideMaterial = null, clearColor = null, clearAlpha = null ) {
31
+
32
+ super();
33
+
34
+ /**
35
+ * The scene to render.
36
+ *
37
+ * @type {Scene}
38
+ */
39
+ this.scene = scene;
40
+
41
+ /**
42
+ * The camera.
43
+ *
44
+ * @type {Camera}
45
+ */
46
+ this.camera = camera;
47
+
48
+ /**
49
+ * The override material. If set, this material is used
50
+ * for all objects in the scene.
51
+ *
52
+ * @type {?Material}
53
+ * @default null
54
+ */
55
+ this.overrideMaterial = overrideMaterial;
56
+
57
+ /**
58
+ * The clear color of the render pass.
59
+ *
60
+ * @type {?(number|Color|string)}
61
+ * @default null
62
+ */
63
+ this.clearColor = clearColor;
64
+
65
+ /**
66
+ * The clear alpha of the render pass.
67
+ *
68
+ * @type {?number}
69
+ * @default null
70
+ */
71
+ this.clearAlpha = clearAlpha;
72
+
73
+ /**
74
+ * Overwritten to perform a clear operation by default.
75
+ *
76
+ * @type {boolean}
77
+ * @default true
78
+ */
79
+ this.clear = true;
80
+
81
+ /**
82
+ * If set to `true`, only the depth can be cleared when `clear` is to `false`.
83
+ *
84
+ * @type {boolean}
85
+ * @default false
86
+ */
87
+ this.clearDepth = false;
88
+
89
+ /**
90
+ * Overwritten to disable the swap.
91
+ *
92
+ * @type {boolean}
93
+ * @default false
94
+ */
95
+ this.needsSwap = false;
96
+ this._oldClearColor = new Color();
97
+
98
+ }
99
+
100
+ /**
101
+ * Performs a beauty pass with the configured scene and camera.
102
+ *
103
+ * @param {WebGLRenderer} renderer - The renderer.
104
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
105
+ * destination for the pass.
106
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
107
+ * previous pass from this buffer.
108
+ * @param {number} deltaTime - The delta time in seconds.
109
+ * @param {boolean} maskActive - Whether masking is active or not.
110
+ */
111
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
112
+
113
+ const oldAutoClear = renderer.autoClear;
114
+ renderer.autoClear = false;
115
+
116
+ let oldClearAlpha, oldOverrideMaterial;
117
+
118
+ if ( this.overrideMaterial !== null ) {
119
+
120
+ oldOverrideMaterial = this.scene.overrideMaterial;
121
+
122
+ this.scene.overrideMaterial = this.overrideMaterial;
123
+
124
+ }
125
+
126
+ if ( this.clearColor !== null ) {
127
+
128
+ renderer.getClearColor( this._oldClearColor );
129
+ renderer.setClearColor( this.clearColor, renderer.getClearAlpha() );
130
+
131
+ }
132
+
133
+ if ( this.clearAlpha !== null ) {
134
+
135
+ oldClearAlpha = renderer.getClearAlpha();
136
+ renderer.setClearAlpha( this.clearAlpha );
137
+
138
+ }
139
+
140
+ if ( this.clearDepth == true ) {
141
+
142
+ renderer.clearDepth();
143
+
144
+ }
145
+
146
+ renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
147
+
148
+ if ( this.clear === true ) {
149
+
150
+ // TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
151
+ renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
152
+
153
+ }
154
+
155
+ renderer.render( this.scene, this.camera );
156
+
157
+ // restore
158
+
159
+ if ( this.clearColor !== null ) {
160
+
161
+ renderer.setClearColor( this._oldClearColor );
162
+
163
+ }
164
+
165
+ if ( this.clearAlpha !== null ) {
166
+
167
+ renderer.setClearAlpha( oldClearAlpha );
168
+
169
+ }
170
+
171
+ if ( this.overrideMaterial !== null ) {
172
+
173
+ this.scene.overrideMaterial = oldOverrideMaterial;
174
+
175
+ }
176
+
177
+ renderer.autoClear = oldAutoClear;
178
+
179
+ }
180
+
181
+ }
182
+
183
+ export { RenderPass };