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

Port work from 'dev' to master #32

Merged
merged 10 commits into from
Apr 19, 2022
Merged

Port work from 'dev' to master #32

merged 10 commits into from
Apr 19, 2022

Conversation

sritchie
Copy link
Collaborator

@sritchie sritchie commented Apr 17, 2022

This PR moves over all of @unconed 's work from the dev branch that I lost during my initial conversion to JS. Notes from that CHANGELOG:

0.0.6-dev

  • When specifying fps on a data buffer, catch up correctly if starting late (e.g. on a slide)
  • Add indices and channels props to <shader /> to match <resample />.
  • Add missing docs for line width.
  • Rename expr in script steps (steps, play, ...) to bind to avoid collision with expr prop.
  • Fix origin/range changes not being picked up
  • Force <layer /> to flatten to an orthogonal view
  • Fix rendering of partially filled buffers
  • Make closed lines/vectors work properly
  • Make closed surfaces work properly
  • Add optional normals to <surface />
  • Add <latch /> to control expr/data updates when conditions change

@unconed
Copy link
Owner

unconed commented Apr 18, 2022

Could you please not tag me if it's not actually addressed to me because otherwise I will turn off all notifications.

@sritchie
Copy link
Collaborator Author

Noted!

@sritchie sritchie changed the title Port work from 'dev' to master [in progress] Port work from 'dev' to master Apr 18, 2022
@sritchie sritchie self-assigned this Apr 18, 2022
return x && JSON.parse(JSON.stringify(x));
}

function deepEq(a, b) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's replace these with the equivalent lodash.

Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW: re import { isEqual } from 'lodash' vs import isEqual from lodash.isequal... I used to use the method-specific packages but stopped because https://lodash.com/per-method-packages

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, nice - so instead I will import with a deeper relative import and we’ll be set.

@@ -112,7 +112,7 @@ export class Sprite extends Base {
this.geometry.dispose();
this.edgeMaterial.dispose();
this.fillMaterial.dispose();
this.nreders =
this.renders =
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

typo fixed!

@sritchie
Copy link
Collaborator Author

@ChristopherChudzicki this is ready for a look, if you wouldn't mind!

Copy link
Collaborator

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

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

This all looks good to me 👍 I have not tried to understand the reverse/latch primitives much, but the examples seem to work.

I left a few minor js comments about arguments.

One thing that I think should be added—and parts or all of this could be done separately—is typescript definitions. Things I think should happen:

  • add a test using expect-type that would fail if a PR, such as this, added more primitives without adding the types. This wasn't high on my priority list since I didn't think we'd be adding more primitives...and maybe we won't after this. But it would be easy to do, so might as well do it.

    expect-type is a package I've used before that is nice for compile-time assertions about typescript. I first came across its use in https://github.com/sequelize/sequelize when I added a type there, and I've been very happy with it.

  • Add types + ts-documentation for the new latch and reveal primitives. This would involve:

    • in node_types.ts, new interfaces SetTraitsReverse, GetTraitsReverse corresponding to the new reverse trait added in traits.ts
    This defines a type for the "reverse" trait which is ued as part of the new Reverse primitive. The reason there would be two interfaces (the Get and Set variants) is that mathbox allows multiple ways of setting a prop, then standardizes to single array. (E.g., "classes" can be set as a space-separated string or an array, but it is always standardized to an array.)
    
    • in node_types.ts, new ReversePropsNormalized and ReverseProps. The props for the primitive are determined by the traits used in the primitive, so it's just a matter of something like

      export interface ReversePropsNormalized
        extends GetTraitsNode,
          GetTraitsOperator,
          GetTraitsReverse {}

      And something similar, with the Set traits, for ReverseProps.

    • in node_types.ts, add the new indices and channels props to GetTraitsShader and SetTraitsShader

    • Add reveal and latch methods to MathboxSelection, etc, in types.ts.

    • Add tsdoc comments in node_types.ts and types.ts for the new traits + props, as well as for the

    Re this last point... I would eventually like to stop using src/docs for doc-generation, and instead generate docs just for the tsdoc comments. The tsdoc comments are much more verbose (in terms of lines of code, I mean). But they are more standard.

    I've been experimenting with typedoc as an alternative to src/docs. You can see its current output with npm run typedoc. It's pretty good, if a bit click-heavy on the navigation.

I am happy to do any or all those items. Let me know your preference.

}

make() {
super.make(...arguments);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
super.make(...arguments);
super.make();

This superclass's make method has no args. I am confident this never does anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good, this was a suggestion from a decaffeinate script I ran to check my conversion!

}

unmake() {
return super.unmake(...arguments);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same: The superclass's unmake has no args anyway (and does not reference the special arguments object)

this._resolveOffset("items", dims)
);

return super.resize(...arguments);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same.

size: 10,
points: "<<",
colors: "<",
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
});
color: 0xFFFFFF
});

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the nice bright colors...

Maybe this should happen by default if colors is provided and color is not...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree!

@sritchie sritchie merged commit fbf7880 into master Apr 19, 2022
ChristopherChudzicki added a commit that referenced this pull request Apr 19, 2022
This is a followup to #32, adding typescript definitions for those changes
ChristopherChudzicki added a commit that referenced this pull request Apr 19, 2022
This is a followup to #32, adding typescript definitions for those changes
ChristopherChudzicki added a commit that referenced this pull request Apr 23, 2022
This is a followup to #32, adding typescript definitions for those changes
@sritchie sritchie deleted the sritchie/new_dev branch December 27, 2022 16:18
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.

3 participants