A Defold native extension that combines the math functions that avoid allocations from Justin Walsh's xmath and Indiesoft LLC's defold-scene3d.
All functions take an output vector (or quaternion, or matrix) as their first argument, and change the vector's values in place instead of allocating a new vector.
- setv.get_position
- setv.get_world_position
- setv.get_rotation
- setv.get_world_rotation
- setv.get_scale
- setv.get_world_scale
- setv.world_to_local_position
- setv.world_to_local_transform
- setv.add
- setv.sub
- setv.mul
- setv.div
- setv.cross
- setv.mul_per_elem
- setv.normalize
- setv.rotate
- setv.vector
- setv.quat_conj
- setv.quat_axis_angle
- setv.quat_basis
- setv.quat_from_to
- setv.quat_rotation_x
- setv.quat_rotation_y
- setv.quat_rotation_z
- setv.quat
- setv.lerp
- setv.slerp
- setv.matrix_axis_angle
- setv.matrix_from_quat
- setv.matrix_frustum
- setv.matrix_inv
- setv.matrix_look_at
- setv.matrix_orthographic
- setv.matrix_ortho_inv
- setv.matrix_perspective
- setv.matrix_rotation_x
- setv.matrix_rotation_y
- setv.matrix_rotation_z
- setv.matrix_translation
- setv.matrix
- Edit game.project
- Add dependency
https://github.com/thinknathan/def-setv/archive/main.zip
for the current version- Or add a specific release
This extension includes types for use with TypeScript + Defold.
- Install these types
yarn add git+https://git@github.com/thinknathan/def-setv.git#^1.0.0 -D
# or
npm install git+https://git@github.com/thinknathan/def-setv.git#^1.0.0 --save-dev
- Add
def-setv
totypes
intsconfig.json
{
"compilerOptions": {
"types": [
+ "def-setv",
],
}
}
- Add
node_modules/@types
totypeRoots
intsconfig.json
if it's not already there
{
"compilerOptions": {
"typeRoots": [
+ "node_modules/@types",
],
}
}
MIT
Comments are adapted from Defold's code comments.