Skip to content
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

Closed
wants to merge 6 commits into from
Closed

Conversation

LucaArgentieri
Copy link

@LucaArgentieri LucaArgentieri commented Feb 19, 2025

Related issue: #685

Description

  • Created ASCIITexture
  • Created ASCIIEffect
  • Created ascii demo in manual
  • Added unit test

Errors / Failed test

I got this error:

Could not find a valid mainImage or mainUv function (ASCIIEffect) , something seems to be broken in the ascii.frag
This test fail:

✘ [fail]: effects › ASCIIEffect › can be created and destroyed Error thrown in test

ReferenceError {
  message: 'document is not defined',
}

I also commented setSize because I can’t access this.resolution and don’t know if this function is useful.

window.addEventListener(
"load",
() =>
void load().then((assets) => {
Copy link
Member

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.

// .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 });
Copy link
Member

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.

folder.addBinding(effect, "color", { color: { type: "float" } });
// folder
// .addBinding(params, "useSceneColor")
// .on("change", (e) => void (effect.color = e.value ? null : effect.color.getHex()));
Copy link
Member

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).


pipeline
.compile()
.then(() => {
Copy link
Member

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.

import { Color, Uniform, Vector4 } from "three";
import { ASCIITexture } from "../textures/ASCIITexture.js";
import { Effect } from "./Effect.js";
import { AddBlendFunction } from "./blending/index.js";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { AddBlendFunction } from "./blending/index.js";

Comment on lines 95 to 98
const colorUniform = this.input.uniforms.get("color");
if (colorUniform && colorUniform.value instanceof Color) {
colorUniform.value.set(value);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);

set inverted(value: boolean) {
if (this.inverted !== value) {
if (value) {
this.input.defines.set("INVERTED", "1");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.input.defines.set("INVERTED", "1");
this.input.defines.set("INVERTED", true);

import { CanvasTexture, RepeatWrapping } from "three";

export interface ASCIITextureOptions {
characters?: string;
Copy link
Member

@vanruesc vanruesc Feb 20, 2025

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 {
Copy link
Member

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.

Comment on lines 17 to 26
/**
* The amount of characters in this texture.
*
*/
readonly characterCount: number;

/**
* The amount of cells along each side of the texture.
*
*/
Copy link
Member

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.

@vanruesc
Copy link
Member

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 npm run test after applying the changes.

document is not defined

The tests fail because document isn't available in the test runner context. You can comment out the tests for now - I'll take care of that later.

@vanruesc vanruesc changed the title Created ASCIITexture | Created ASCIIEffect | Created ascii demo in manual | Added unit test | Add ASCIITexture and ASCIIEffect Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants