Introduce a typescript 3d calculation library

Hey guys,

I’d like to take the chance here to share with you a typescript npm package Open3d!

It is a very good supplementary 3d vector math, matrix etc. library that helps you solve very basic vector calculations like “find the closest point on a line”, “get intersection of two lines”, “project a point on a plane”, “rotate the line around an axis and scale by two times” etc.

When I work with babylonjs, I often find implementing this kind of basic stuff very cumbersome, and this package aims to solve those as a toolbox! I recommend it a lot when you just want to start a simple app with babylonjs that requires some calculation.

Cheers!
Chen

7 Likes

Thanks this is a great contribution to the OSS community!

2 Likes

Hello!
I’m definitelly going to try it out!
Thank you!

1 Like

I believe the library is intended to be used with any framework, so there are no dependencies on BJS at all, that’s why he chose no to use BJS.Vector3, because a lot of functions from this library can be already found in BJS.

EDIT: So it would not make sense to create this library and use BJS dependecies :stuck_out_tongue:

1 Like

@ccc159 I think, you forgot to rename this one to conform the naming convention. :hugs:
image

Haha correct! I did it intentionally though. Because I want to only use it internally and do not expose it publicly. But typescript doesn’t have something similar like internal modifier in C#. This is then what I came up with. It’s indeed not nice…

Yes @roland answered it correctly. It’s not bound to BJS, but rather independent and can be used for other purposes.

Wouldn’t private or protected fit your needs?

If I mark private or protected it can be only accessed within the class or its children classes. In my case I want to access it in my own project but from other classes, which is what internal does in C#. Don’t know a good solution for that yet…

That’s a valid point. So far I have been aware of the performance issue and only write O(1) complexity functions which would be trivial in terms of computation, as all of them up to now are just linear algebra implementations. And I will be strict in this regard when further developing this library. Thanks for pointing out!

2 Likes

Ok, I get it, maybe then leave it public and correct the name, if it is public :smiley: Sometimes I just don’t get why is TS so limiting in so many aspects even these days. For example multiple inheritance is quite a hell to implement, comparing to C# :smiley:

You’re right. If it’s public, it’s public :sweat_smile: I’ll change this in the next release! Thanks for testing!

One suggestion. More functions could be made static, so one could simply call
Open3d.Intersection.LineLine(Line1, Line2)
or/and
Open3d.Intersection.LineLine(Vector3d line1Start, Vector3d line1End, Vector3d line2Start, Vector3d line2End) (obviously because TS is so limiting the methods name needs to be changed as well)

I think, it could be a pretty cool and lightweight 3d math library if stuffed with some more convenience methods.

Thanks for sharing and keep us posted on the new versions!

R.