While functionally it seems to be completely ok (although I currently can't remember the case where vec3 would be needed in Gideros, but I don't exclude the possibility that it might) but you are not utilizing the power of Gideros provided OOP approach.
While you do it right in the constructor, assigning x,y and z to the self as instance properties, you then go completely other way around and plugin your own method through metatable and do not reuse the self instance properties at all.
It could all be as easy as:
Vector3 = Core.class()function Vector3:init(x, y, z)
self.x = x
self.y = y
self.z = z
endfunction Vector3:toString()return self.x .. "," .. self.y .. "," .. self.z
endfunction Vector3:add(b)iftype(b)=="number"then
self.x = self.x + b
self.y = self.y + b
self.z = self.z + b
else
self.x = self.x + b.x
self.y = self.y + b.y
self.z = self.z + b.z
endendfunction Vector3:getLenght()returnmath.sqrt(self.x*self.x + self.y*self.y + self.z*self.z)end--etc
Thank you! 3D vectors want to use in a small engine, rotation of a 3D shape. as flash old technology (flash7). Again, I am new, gideros saw 3 days ago) and Lua is also seen. mainly programmed in flash.soon I'll show 3D shape )
I'm really interested in this, Vector3 would be really useful and should be native imho, especially for v2 of Gideros.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
Comments
but you are not utilizing the power of Gideros provided OOP approach.
While you do it right in the constructor, assigning x,y and z to the self as instance properties, you then go completely other way around and plugin your own method through metatable and do not reuse the self instance properties at all.
It could all be as easy as:
3D vectors want to use in a small engine, rotation of a 3D shape. as flash old technology (flash7). Again, I am new, gideros saw 3 days ago) and Lua is also seen. mainly programmed in flash.soon I'll show 3D shape )
Likes: SinisterSoft
http://www.globalcorp.org.ru/img/magicdrugs.jpg
but for some reason became interested in 3D
https://deluxepixel.com
Likes: SinisterSoft