michael-f-bryan / arcs Goto Github PK
View Code? Open in Web Editor NEWA Rust CAD System
Home Page: https://michael-f-bryan.github.io/arcs
License: Apache License 2.0
A Rust CAD System
Home Page: https://michael-f-bryan.github.io/arcs
License: Apache License 2.0
Thanks for your work on this library, I have been playing around with it and I would like to see it develop further. I was hoping to contribute to it but some guidance would be helpful.
I'm looking to implement a grid, was wondering what your thoughts were regarding how it should be done, should it be another primitive type or should it be described as a window style? Or some other way?
To be a CAD program our WebAssembly demo actually needs to draw things.
There should be a toolbar with buttons to enter specific "drawing modes". When you are in a mode the corresponding button stays pressed (letting the user know which mode they're in) and things like click events get passed to that mode.
For now we'll want to implement a formal mode system, with modes for:
The standard way to implement these modes is with some sort of state machine. I prefer trait objects over enums or strongly typed state machines because they scale more easily and are easier to work with.
pub trait Mode {
fn on_mouse_down(&mut self, args: MouseDownArgs, world: &mut World) -> Transition {
Transition::DoNothing
}
fn on_mouse_move(&mut self, args: MouseMoveArgs, world: &mut World) -> Transition {
Transition::DoNothing
}
}
pub enum Transition {
DoNothing,
ChangeState(Box<dyn Mode>),
}
(note: this is a big task and will probably require breaking into a dozen smaller issues along the way)
yarn start
currently fails. I assume the module is either missing or no longer exists:
error[E0432]: unresolved import `arcs::render`
--> src/app.rs:6:5
|
6 | render::{Renderer, Viewport},
| ^^^^^^ could not find `render` in `arcs`
error[E0433]: failed to resolve: could not find `render` in `arcs`
--> src/app.rs:61:15
|
61 | arcs::render::to_drawing_coordinates(
| ^^^^^^ could not find `render` in `arcs`
I can't seem to run the example, I get a panic during rendering. This project seems like something i'd like to help contribute to maybe one day. Need to get up to speed with Rust
arcs-master\target\debug\examples> .\render_to_image.exe thread 'main' panicked at 'Render context dropped without finish() call', C:\Users\jasin\.cargo\registry\src\github.com-1ecc6299db9ec823\piet-direct2d-0.1.0\src\lib.rs:475:9
We need to make sure the demo's canvas rendering logic is correct.
A good smoke test would be to:
(0, 0)
with a pixels_per_drawing_unit
of 1.0
World
at the equivalent spot in Drawing Space (cartesian coordinates who's origin is completely unrelated to the world)Can you add info as to how to download and develop this as local copy?
(Sorry I'm Rust newbie)
So explain what to download, where to place it, what to call (cargo build etc.), how to import.
How does this compare/relate to the FreeCAD project?
This follows on from #9 (comment):
I would like to add to this another mode for selecting or picking already drawn geometry.
This is probably the most used functionality and can probably also be implemented as a mode.
As an algorithm for finding things under the mouse cursor we have the most important thing already, as we can do a quick sort of all
DrawingObjects
whoseBoundingBox
contains theMousePosition
inWorldSpace
and do some fine-grained checks afterwards
We need an interactive mode which lets us mark an object as selected and move them around the drawing by clicking and dragging.
This will necessitate a couple new concepts on top of #9:
Selected
component (see specs::storage::NullStorage
)SelectMode
itself#12 introduced aabb_quadtree
as a mechanism for doing lookups based on location (i.e. "which items are within 5mm of P?"), but its API doesn't really line up with how we'd like to use it.
At some point in time we should implement our own quadtree (or N-tree or whatever).
This issue can be used as a list of useful links for implementation, and a wish list based on arcs
' needs.
Hey just read the article that was on hacker news, linked to here I think: http://adventures.michaelfbryan.com/posts/ecs-outside-of-games/
Looked at the code, looks like these lines are likely what's slowing things down:
arcs/arcs/src/render/renderer.rs
Lines 253 to 258 in 42d5a77
And it looks like this gets used here?
arcs/arcs/src/render/renderer.rs
Lines 151 to 168 in 42d5a77
So it looks like that calculate function has a high likelihood of running in the hot loop. Apologies for the questions, I'm not very proficient in rust.
We have some experience with this in our graphics engine (C++). A few suggestions:
That's most of what comes to mind. Hopefully it helps. Happy to chat further. Cheers!
This line:
max_by_key(rest, |p| line_segment.perpendicular_distance_to(*p))
ultimately calls Vector2D.length() for each point, which takes the square root, an expensive operation. That's not really necessary -- the max of the square will give you the same answer.
You could make square_perpendicular_distance_to() which uses square_length() which uses Vector2D.square_length().
For long lists you could probably do even better by preparing a rotation matrix that would make the line segment horizontal -- then you only need to consider the Y values of the rotated points to see which is farthest from the (horizontal) line.
I made a rough prototype of a possible bezier implementation. Here is the beautified adapted output of the render_to_image
example:
From a design standpoint I had the following ideas for implementation:
crates.io
I could find only support quadratic and cubic bezier curves. I assume this is modelled after the SVG spec, which only supports cubic and quadratic beziers.Are there any caveats with a generic implementation over an array of Points you can think of @Michael-F-Bryan ?
At the moment we're reimplementing a lot of basic geometry math with Vector
and BoundingBox
. Is it worth reusing primitive types from an existing geometry library?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.