-
-
Notifications
You must be signed in to change notification settings - Fork 455
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
[Enhancement] Points object #548
Comments
It currently doesn't, but I started a branch to include it here: https://github.com/jonobr1/two.js/tree/548-points So far it preliminarily works in SVG and Canvas2D like so: var two = new Two({
type: Two.Types.canvas,
fullscreen: true
}).appendTo(document.body);
var vertices = [];
var i = 0;
while (i < 50) {
var x = Math.random() * two.width;
var y = Math.random() * two.height;
vertices.push(new Two.Vector(x, y));
i++;
}
var points = new Two.Points(vertices);
points.noStroke();
points.fill = 'blue';
points.size = 2;
two.add(points);
two.update(); Still need to implement this for WebGL and add Unit Tests before it'll hit the |
Thanks, I'm going to try that... I believe for points, its color and "width" should be the same as the stroke color and size... |
No, you can change both the Two.js doesn't render 3D so they wont' be spheres, but there are different ways to upload the points information to the GPU so that it's efficient and quite different than how a Two.Path is handled. |
oh ok, that's good too... I'm just used to p5's points... 😅
oooh right, I forgot, Two.js is not 3D... That would be Three.js, right? 😅 |
sorry, closed it on accident... |
The points branch now has WebGL implemented as well. Still need to write tests. |
This is now merged into the |
cool, thanks... So, to be sure... the points object here is constructed by giving it the points x and y positions in an array like this points = two.makePoints(
two.width / 2,
two.height / 2,
two.width / 2 + 20,
two.height / 2,
two.width / 2 + 40,
two.height / 2
); but can also be constructed by giving it an array of vectors? var vertices = [];
for (var i = 0; i < 100; i++) {
var x = Math.random() * two.width;
var y = Math.random() * two.height;
vertices.push(new Two.Vector(x, y));
}
points = two.makePoints(vertices); |
Exactly. I believe |
cool great... then I just need to clone the points branch? or is it now added to the latest release one? |
You can clone the Unfortunately this is blocked up by trying to get the TypeScript types definitions working properly because it alters how the auto-generated documentation operates. So, the current plan is to rewrite Two.js into ES6 compatible classes with getters, setters, and private variables instead of ES5 functional prototypes and |
ok then, I'll clone it... I like the new design btw... I suppose it will be mobile compatible...
oh I see... I haven't used Typescript, I believe... I've seen some examples and are very similar to JS but cleaner and I guess I have used that format, anyways, I wish you luck... thanks for the Points addition... :) |
@jonobr1 The points on the object |
Thanks for sharing and sorry for the delay! This is why I haven't published the package yet. I just updated |
Is there a way to draw a
Two.Path()
shape but only the vertices?The text was updated successfully, but these errors were encountered: