-
-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ASCIITexture and ASCIIEffect #687
Conversation
manual/assets/js/src/demos/ascii.ts
Outdated
window.addEventListener( | ||
"load", | ||
() => | ||
void load().then((assets) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This formatting doesn't look right.
manual/assets/js/src/demos/ascii.ts
Outdated
// .on("change", (e) => void (effect.color = e.value ? null : effect.color.getHex())); | ||
|
||
// folder.addBinding(effect.blendMode.opacity, "value", { label: "opacity", min: 0, max: 1, step: 0.01 }); | ||
// folder.addBinding(effect.blendMode, "blendFunction", { options: BlendFunction }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check the other demos to see how the blend options can be added.
manual/assets/js/src/demos/ascii.ts
Outdated
folder.addBinding(effect, "color", { color: { type: "float" } }); | ||
// folder | ||
// .addBinding(params, "useSceneColor") | ||
// .on("change", (e) => void (effect.color = e.value ? null : effect.color.getHex())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably doesn't work because of the incorrect type used for the internal uniform (see other comment in ASCIIEffect
).
manual/assets/js/src/demos/ascii.ts
Outdated
|
||
pipeline | ||
.compile() | ||
.then(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatting should be the same as in the other demos.
src/effects/ASCIIEffect.ts
Outdated
import { Color, Uniform, Vector4 } from "three"; | ||
import { ASCIITexture } from "../textures/ASCIITexture.js"; | ||
import { Effect } from "./Effect.js"; | ||
import { AddBlendFunction } from "./blending/index.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { AddBlendFunction } from "./blending/index.js"; |
src/effects/ASCIIEffect.ts
Outdated
const colorUniform = this.input.uniforms.get("color"); | ||
if (colorUniform && colorUniform.value instanceof Color) { | ||
colorUniform.value.set(value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const colorUniform = this.input.uniforms.get("color"); | |
if (colorUniform && colorUniform.value instanceof Color) { | |
colorUniform.value.set(value); | |
} | |
const color = this.input.uniforms.get("color").value as Color; | |
color.value.set(value); |
src/effects/ASCIIEffect.ts
Outdated
set inverted(value: boolean) { | ||
if (this.inverted !== value) { | ||
if (value) { | ||
this.input.defines.set("INVERTED", "1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.input.defines.set("INVERTED", "1"); | |
this.input.defines.set("INVERTED", true); |
import { CanvasTexture, RepeatWrapping } from "three"; | ||
|
||
export interface ASCIITextureOptions { | ||
characters?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All options require doc comments (with @defaultValue
tags).
@@ -0,0 +1,64 @@ | |||
import { CanvasTexture, RepeatWrapping } from "three"; | |||
|
|||
export interface ASCIITextureOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interface itself also needs a doc comment.
src/textures/ASCIITexture.ts
Outdated
/** | ||
* The amount of characters in this texture. | ||
* | ||
*/ | ||
readonly characterCount: number; | ||
|
||
/** | ||
* The amount of cells along each side of the texture. | ||
* | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These doc comments aren't formatted correctly.
Instead of applying these suggestions individually, I'd recommend applying them locally by hand and then doing a single commit with all changes. Please run
The tests fail because |
Related issue: #685
Description
Errors / Failed test
I got this error:
Could not find a valid mainImage or mainUv function (ASCIIEffect)
, something seems to be broken in theascii.frag
This test fail:
I also commented setSize because I can’t access
this.resolution
and don’t know if this function is useful.