opencode-agent-flow 0.0.0-stage → 0.1.0

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,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 };
@@ -0,0 +1,135 @@
1
+ import {
2
+ ShaderMaterial,
3
+ UniformsUtils
4
+ } from 'three';
5
+ import { Pass, FullScreenQuad } from './Pass.js';
6
+
7
+ /**
8
+ * This pass can be used to create a post processing effect
9
+ * with a raw GLSL shader object. Useful for implementing custom
10
+ * effects.
11
+ *
12
+ * ```js
13
+ * const fxaaPass = new ShaderPass( FXAAShader );
14
+ * composer.addPass( fxaaPass );
15
+ * ```
16
+ *
17
+ * @augments Pass
18
+ * @three_import import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
19
+ */
20
+ class ShaderPass extends Pass {
21
+
22
+ /**
23
+ * Constructs a new shader pass.
24
+ *
25
+ * @param {Object|ShaderMaterial} [shader] - A shader object holding vertex and fragment shader as well as
26
+ * defines and uniforms. It's also valid to pass a custom shader material.
27
+ * @param {string} [textureID='tDiffuse'] - The name of the texture uniform that should sample
28
+ * the read buffer.
29
+ */
30
+ constructor( shader, textureID = 'tDiffuse' ) {
31
+
32
+ super();
33
+
34
+ /**
35
+ * The name of the texture uniform that should sample the read buffer.
36
+ *
37
+ * @type {string}
38
+ * @default 'tDiffuse'
39
+ */
40
+ this.textureID = textureID;
41
+
42
+ /**
43
+ * The pass uniforms.
44
+ *
45
+ * @type {?Object}
46
+ */
47
+ this.uniforms = null;
48
+
49
+ /**
50
+ * The pass material.
51
+ *
52
+ * @type {?ShaderMaterial}
53
+ */
54
+ this.material = null;
55
+
56
+ if ( shader instanceof ShaderMaterial ) {
57
+
58
+ this.uniforms = shader.uniforms;
59
+
60
+ this.material = shader;
61
+
62
+ } else if ( shader ) {
63
+
64
+ this.uniforms = UniformsUtils.clone( shader.uniforms );
65
+
66
+ this.material = new ShaderMaterial( {
67
+
68
+ name: ( shader.name !== undefined ) ? shader.name : 'unspecified',
69
+ defines: Object.assign( {}, shader.defines ),
70
+ uniforms: this.uniforms,
71
+ vertexShader: shader.vertexShader,
72
+ fragmentShader: shader.fragmentShader
73
+
74
+ } );
75
+
76
+ }
77
+
78
+ // internals
79
+
80
+ this._fsQuad = new FullScreenQuad( this.material );
81
+
82
+ }
83
+
84
+ /**
85
+ * Performs the shader pass.
86
+ *
87
+ * @param {WebGLRenderer} renderer - The renderer.
88
+ * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
89
+ * destination for the pass.
90
+ * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
91
+ * previous pass from this buffer.
92
+ * @param {number} deltaTime - The delta time in seconds.
93
+ * @param {boolean} maskActive - Whether masking is active or not.
94
+ */
95
+ render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
96
+
97
+ if ( this.uniforms[ this.textureID ] ) {
98
+
99
+ this.uniforms[ this.textureID ].value = readBuffer.texture;
100
+
101
+ }
102
+
103
+ this._fsQuad.material = this.material;
104
+
105
+ if ( this.renderToScreen ) {
106
+
107
+ renderer.setRenderTarget( null );
108
+ this._fsQuad.render( renderer );
109
+
110
+ } else {
111
+
112
+ renderer.setRenderTarget( writeBuffer );
113
+ // TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
114
+ if ( this.clear ) renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
115
+ this._fsQuad.render( renderer );
116
+
117
+ }
118
+
119
+ }
120
+
121
+ /**
122
+ * Frees the GPU-related resources allocated by this instance. Call this
123
+ * method whenever the pass is no longer used in your app.
124
+ */
125
+ dispose() {
126
+
127
+ this.material.dispose();
128
+
129
+ this._fsQuad.dispose();
130
+
131
+ }
132
+
133
+ }
134
+
135
+ export { ShaderPass };