diff --git a/bindings/raylib_math_api.json b/bindings/raylib_math_api.json index 3cd9177..7dd1586 100644 --- a/bindings/raylib_math_api.json +++ b/bindings/raylib_math_api.json @@ -1 +1 @@ -[{"name":"Clamp","returnType":"float","params":[{"name":"value","type":"float"},{"name":"min","type":"float"},{"name":"max","type":"float"}],"description":""},{"name":"Lerp","returnType":"float","params":[{"name":"start","type":"float"},{"name":"end","type":"float"},{"name":"amount","type":"float"}],"description":""},{"name":"Normalize","returnType":"float","params":[{"name":"value","type":"float"},{"name":"start","type":"float"},{"name":"end","type":"float"}],"description":""},{"name":"Remap","returnType":"float","params":[{"name":"value","type":"float"},{"name":"inputStart","type":"float"},{"name":"inputEnd","type":"float"},{"name":"outputStart","type":"float"},{"name":"outputEnd","type":"float"}],"description":""},{"name":"Wrap","returnType":"float","params":[{"name":"value","type":"float"},{"name":"min","type":"float"},{"name":"max","type":"float"}],"description":""},{"name":"FloatEquals","returnType":"int","params":[{"name":"x","type":"float"},{"name":"y","type":"float"}],"description":""},{"name":"Vector2Zero","returnType":"Vector2","params":[],"description":""},{"name":"Vector2One","returnType":"Vector2","params":[],"description":""},{"name":"Vector2Add","returnType":"Vector2","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":""},{"name":"Vector2AddValue","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"add","type":"float"}],"description":""},{"name":"Vector2Subtract","returnType":"Vector2","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":""},{"name":"Vector2SubtractValue","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"sub","type":"float"}],"description":""},{"name":"Vector2Length","returnType":"float","params":[{"name":"v","type":"Vector2"}],"description":""},{"name":"Vector2LengthSqr","returnType":"float","params":[{"name":"v","type":"Vector2"}],"description":""},{"name":"Vector2DotProduct","returnType":"float","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":""},{"name":"Vector2Distance","returnType":"float","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":""},{"name":"Vector2DistanceSqr","returnType":"float","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":""},{"name":"Vector2Angle","returnType":"float","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":""},{"name":"Vector2LineAngle","returnType":"float","params":[{"name":"start","type":"Vector2"},{"name":"end","type":"Vector2"}],"description":""},{"name":"Vector2Scale","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"scale","type":"float"}],"description":""},{"name":"Vector2Multiply","returnType":"Vector2","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":""},{"name":"Vector2Negate","returnType":"Vector2","params":[{"name":"v","type":"Vector2"}],"description":""},{"name":"Vector2Divide","returnType":"Vector2","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":""},{"name":"Vector2Normalize","returnType":"Vector2","params":[{"name":"v","type":"Vector2"}],"description":""},{"name":"Vector2Transform","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"mat","type":"Matrix"}],"description":""},{"name":"Vector2Lerp","returnType":"Vector2","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"},{"name":"amount","type":"float"}],"description":""},{"name":"Vector2Reflect","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"normal","type":"Vector2"}],"description":""},{"name":"Vector2Rotate","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"angle","type":"float"}],"description":""},{"name":"Vector2MoveTowards","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"target","type":"Vector2"},{"name":"maxDistance","type":"float"}],"description":""},{"name":"Vector2Invert","returnType":"Vector2","params":[{"name":"v","type":"Vector2"}],"description":""},{"name":"Vector2Clamp","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"min","type":"Vector2"},{"name":"max","type":"Vector2"}],"description":""},{"name":"Vector2ClampValue","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"min","type":"float"},{"name":"max","type":"float"}],"description":""},{"name":"Vector2Equals","returnType":"int","params":[{"name":"p","type":"Vector2"},{"name":"q","type":"Vector2"}],"description":""},{"name":"Vector3Zero","returnType":"Vector3","params":[],"description":""},{"name":"Vector3One","returnType":"Vector3","params":[],"description":""},{"name":"Vector3Add","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3AddValue","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"add","type":"float"}],"description":""},{"name":"Vector3Subtract","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3SubtractValue","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"sub","type":"float"}],"description":""},{"name":"Vector3Scale","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"scalar","type":"float"}],"description":""},{"name":"Vector3Multiply","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3CrossProduct","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3Perpendicular","returnType":"Vector3","params":[{"name":"v","type":"Vector3"}],"description":""},{"name":"Vector3Length","returnType":"float","params":[{"name":"v","type":"const Vector3"}],"description":""},{"name":"Vector3LengthSqr","returnType":"float","params":[{"name":"v","type":"const Vector3"}],"description":""},{"name":"Vector3DotProduct","returnType":"float","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3Distance","returnType":"float","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3DistanceSqr","returnType":"float","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3Angle","returnType":"float","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3Negate","returnType":"Vector3","params":[{"name":"v","type":"Vector3"}],"description":""},{"name":"Vector3Divide","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3Normalize","returnType":"Vector3","params":[{"name":"v","type":"Vector3"}],"description":""},{"name":"Vector3OrthoNormalize","returnType":"void","params":[{"name":"v1","type":"Vector3 *"},{"name":"v2","type":"Vector3 *"}],"description":""},{"name":"Vector3Transform","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"mat","type":"Matrix"}],"description":""},{"name":"Vector3RotateByQuaternion","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"q","type":"Quaternion"}],"description":""},{"name":"Vector3RotateByAxisAngle","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"axis","type":"Vector3"},{"name":"angle","type":"float"}],"description":""},{"name":"Vector3Lerp","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"},{"name":"amount","type":"float"}],"description":""},{"name":"Vector3Reflect","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"normal","type":"Vector3"}],"description":""},{"name":"Vector3Min","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3Max","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":""},{"name":"Vector3Barycenter","returnType":"Vector3","params":[{"name":"p","type":"Vector3"},{"name":"a","type":"Vector3"},{"name":"b","type":"Vector3"},{"name":"c","type":"Vector3"}],"description":""},{"name":"Vector3Unproject","returnType":"Vector3","params":[{"name":"source","type":"Vector3"},{"name":"projection","type":"Matrix"},{"name":"view","type":"Matrix"}],"description":""},{"name":"Vector3ToFloatV","returnType":"float3","params":[{"name":"v","type":"Vector3"}],"description":""},{"name":"Vector3Invert","returnType":"Vector3","params":[{"name":"v","type":"Vector3"}],"description":""},{"name":"Vector3Clamp","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"min","type":"Vector3"},{"name":"max","type":"Vector3"}],"description":""},{"name":"Vector3ClampValue","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"min","type":"float"},{"name":"max","type":"float"}],"description":""},{"name":"Vector3Equals","returnType":"int","params":[{"name":"p","type":"Vector3"},{"name":"q","type":"Vector3"}],"description":""},{"name":"Vector3Refract","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"n","type":"Vector3"},{"name":"r","type":"float"}],"description":""},{"name":"MatrixDeterminant","returnType":"float","params":[{"name":"mat","type":"Matrix"}],"description":""},{"name":"MatrixTrace","returnType":"float","params":[{"name":"mat","type":"Matrix"}],"description":""},{"name":"MatrixTranspose","returnType":"Matrix","params":[{"name":"mat","type":"Matrix"}],"description":""},{"name":"MatrixInvert","returnType":"Matrix","params":[{"name":"mat","type":"Matrix"}],"description":""},{"name":"MatrixIdentity","returnType":"Matrix","params":[],"description":""},{"name":"MatrixAdd","returnType":"Matrix","params":[{"name":"left","type":"Matrix"},{"name":"right","type":"Matrix"}],"description":""},{"name":"MatrixSubtract","returnType":"Matrix","params":[{"name":"left","type":"Matrix"},{"name":"right","type":"Matrix"}],"description":""},{"name":"MatrixMultiply","returnType":"Matrix","params":[{"name":"left","type":"Matrix"},{"name":"right","type":"Matrix"}],"description":""},{"name":"MatrixTranslate","returnType":"Matrix","params":[{"name":"x","type":"float"},{"name":"y","type":"float"},{"name":"z","type":"float"}],"description":""},{"name":"MatrixRotate","returnType":"Matrix","params":[{"name":"axis","type":"Vector3"},{"name":"angle","type":"float"}],"description":""},{"name":"MatrixRotateX","returnType":"Matrix","params":[{"name":"angle","type":"float"}],"description":""},{"name":"MatrixRotateY","returnType":"Matrix","params":[{"name":"angle","type":"float"}],"description":""},{"name":"MatrixRotateZ","returnType":"Matrix","params":[{"name":"angle","type":"float"}],"description":""},{"name":"MatrixRotateXYZ","returnType":"Matrix","params":[{"name":"angle","type":"Vector3"}],"description":""},{"name":"MatrixRotateZYX","returnType":"Matrix","params":[{"name":"angle","type":"Vector3"}],"description":""},{"name":"MatrixScale","returnType":"Matrix","params":[{"name":"x","type":"float"},{"name":"y","type":"float"},{"name":"z","type":"float"}],"description":""},{"name":"MatrixFrustum","returnType":"Matrix","params":[{"name":"left","type":"double"},{"name":"right","type":"double"},{"name":"bottom","type":"double"},{"name":"top","type":"double"},{"name":"near","type":"double"},{"name":"far","type":"double"}],"description":""},{"name":"MatrixPerspective","returnType":"Matrix","params":[{"name":"fovy","type":"double"},{"name":"aspect","type":"double"},{"name":"near","type":"double"},{"name":"far","type":"double"}],"description":""},{"name":"MatrixOrtho","returnType":"Matrix","params":[{"name":"left","type":"double"},{"name":"right","type":"double"},{"name":"bottom","type":"double"},{"name":"top","type":"double"},{"name":"near","type":"double"},{"name":"far","type":"double"}],"description":""},{"name":"MatrixLookAt","returnType":"Matrix","params":[{"name":"eye","type":"Vector3"},{"name":"target","type":"Vector3"},{"name":"up","type":"Vector3"}],"description":""},{"name":"MatrixToFloatV","returnType":"float16","params":[{"name":"mat","type":"Matrix"}],"description":""},{"name":"QuaternionAdd","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"}],"description":""},{"name":"QuaternionAddValue","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"},{"name":"add","type":"float"}],"description":""},{"name":"QuaternionSubtract","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"}],"description":""},{"name":"QuaternionSubtractValue","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"},{"name":"sub","type":"float"}],"description":""},{"name":"QuaternionIdentity","returnType":"Quaternion","params":[],"description":""},{"name":"QuaternionLength","returnType":"float","params":[{"name":"q","type":"Quaternion"}],"description":""},{"name":"QuaternionNormalize","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"}],"description":""},{"name":"QuaternionInvert","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"}],"description":""},{"name":"QuaternionMultiply","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"}],"description":""},{"name":"QuaternionScale","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"},{"name":"mul","type":"float"}],"description":""},{"name":"QuaternionDivide","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"}],"description":""},{"name":"QuaternionLerp","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"},{"name":"amount","type":"float"}],"description":""},{"name":"QuaternionNlerp","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"},{"name":"amount","type":"float"}],"description":""},{"name":"QuaternionSlerp","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"},{"name":"amount","type":"float"}],"description":""},{"name":"QuaternionFromVector3ToVector3","returnType":"Quaternion","params":[{"name":"from","type":"Vector3"},{"name":"to","type":"Vector3"}],"description":""},{"name":"QuaternionFromMatrix","returnType":"Quaternion","params":[{"name":"mat","type":"Matrix"}],"description":""},{"name":"QuaternionToMatrix","returnType":"Matrix","params":[{"name":"q","type":"Quaternion"}],"description":""},{"name":"QuaternionFromAxisAngle","returnType":"Quaternion","params":[{"name":"axis","type":"Vector3"},{"name":"angle","type":"float"}],"description":""},{"name":"QuaternionToAxisAngle","returnType":"void","params":[{"name":"q","type":"Quaternion"},{"name":"outAxis","type":"Vector3 *"},{"name":"outAngle","type":"float *"}],"description":""},{"name":"QuaternionFromEuler","returnType":"Quaternion","params":[{"name":"pitch","type":"float"},{"name":"yaw","type":"float"},{"name":"roll","type":"float"}],"description":""},{"name":"QuaternionToEuler","returnType":"Vector3","params":[{"name":"q","type":"Quaternion"}],"description":""},{"name":"QuaternionTransform","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"},{"name":"mat","type":"Matrix"}],"description":""},{"name":"QuaternionEquals","returnType":"int","params":[{"name":"p","type":"Quaternion"},{"name":"q","type":"Quaternion"}],"description":""}] \ No newline at end of file +[{"name":"Clamp","returnType":"float","params":[{"name":"value","type":"float"},{"name":"min","type":"float"},{"name":"max","type":"float"}],"description":"Clamp float value"},{"name":"Lerp","returnType":"float","params":[{"name":"start","type":"float"},{"name":"end","type":"float"},{"name":"amount","type":"float"}],"description":"Calculate linear interpolation between two floats"},{"name":"Normalize","returnType":"float","params":[{"name":"value","type":"float"},{"name":"start","type":"float"},{"name":"end","type":"float"}],"description":"Normalize input value within input range"},{"name":"Remap","returnType":"float","params":[{"name":"value","type":"float"},{"name":"inputStart","type":"float"},{"name":"inputEnd","type":"float"},{"name":"outputStart","type":"float"},{"name":"outputEnd","type":"float"}],"description":"Remap input value within input range to output range"},{"name":"Wrap","returnType":"float","params":[{"name":"value","type":"float"},{"name":"min","type":"float"},{"name":"max","type":"float"}],"description":"Wrap input value from min to max"},{"name":"FloatEquals","returnType":"int","params":[{"name":"x","type":"float"},{"name":"y","type":"float"}],"description":"Check whether two given floats are almost equal"},{"name":"Vector2Zero","returnType":"Vector2","params":[],"description":"Vector with components value 0.0f"},{"name":"Vector2One","returnType":"Vector2","params":[],"description":"Vector with components value 1.0f"},{"name":"Vector2Add","returnType":"Vector2","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":"Add two vectors (v1 + v2)"},{"name":"Vector2AddValue","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"add","type":"float"}],"description":"Add vector and float value"},{"name":"Vector2Subtract","returnType":"Vector2","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":"Subtract two vectors (v1 - v2)"},{"name":"Vector2SubtractValue","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"sub","type":"float"}],"description":"Subtract vector by float value"},{"name":"Vector2Length","returnType":"float","params":[{"name":"v","type":"Vector2"}],"description":"Calculate vector length"},{"name":"Vector2LengthSqr","returnType":"float","params":[{"name":"v","type":"Vector2"}],"description":"Calculate vector square length"},{"name":"Vector2DotProduct","returnType":"float","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":"Calculate two vectors dot product"},{"name":"Vector2Distance","returnType":"float","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":"Calculate distance between two vectors"},{"name":"Vector2DistanceSqr","returnType":"float","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":"Calculate square distance between two vectors"},{"name":"Vector2Angle","returnType":"float","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":"Calculate angle between two vectors\nNOTE: Angle is calculated from origin point (0, 0)"},{"name":"Vector2LineAngle","returnType":"float","params":[{"name":"start","type":"Vector2"},{"name":"end","type":"Vector2"}],"description":"Calculate angle defined by a two vectors line\nNOTE: Parameters need to be normalized\nCurrent implementation should be aligned with glm::angle"},{"name":"Vector2Scale","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"scale","type":"float"}],"description":"Scale vector (multiply by value)"},{"name":"Vector2Multiply","returnType":"Vector2","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":"Multiply vector by vector"},{"name":"Vector2Negate","returnType":"Vector2","params":[{"name":"v","type":"Vector2"}],"description":"Negate vector"},{"name":"Vector2Divide","returnType":"Vector2","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"}],"description":"Divide vector by vector"},{"name":"Vector2Normalize","returnType":"Vector2","params":[{"name":"v","type":"Vector2"}],"description":"Normalize provided vector"},{"name":"Vector2Transform","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"mat","type":"Matrix"}],"description":"Transforms a Vector2 by a given Matrix"},{"name":"Vector2Lerp","returnType":"Vector2","params":[{"name":"v1","type":"Vector2"},{"name":"v2","type":"Vector2"},{"name":"amount","type":"float"}],"description":"Calculate linear interpolation between two vectors"},{"name":"Vector2Reflect","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"normal","type":"Vector2"}],"description":"Calculate reflected vector to normal"},{"name":"Vector2Rotate","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"angle","type":"float"}],"description":"Rotate vector by angle"},{"name":"Vector2MoveTowards","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"target","type":"Vector2"},{"name":"maxDistance","type":"float"}],"description":"Move Vector towards target"},{"name":"Vector2Invert","returnType":"Vector2","params":[{"name":"v","type":"Vector2"}],"description":"Invert the given vector"},{"name":"Vector2Clamp","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"min","type":"Vector2"},{"name":"max","type":"Vector2"}],"description":"Clamp the components of the vector between\nmin and max values specified by the given vectors"},{"name":"Vector2ClampValue","returnType":"Vector2","params":[{"name":"v","type":"Vector2"},{"name":"min","type":"float"},{"name":"max","type":"float"}],"description":"Clamp the magnitude of the vector between two min and max values"},{"name":"Vector2Equals","returnType":"int","params":[{"name":"p","type":"Vector2"},{"name":"q","type":"Vector2"}],"description":"Check whether two given vectors are almost equal"},{"name":"Vector3Zero","returnType":"Vector3","params":[],"description":"Vector with components value 0.0f"},{"name":"Vector3One","returnType":"Vector3","params":[],"description":"Vector with components value 1.0f"},{"name":"Vector3Add","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Add two vectors"},{"name":"Vector3AddValue","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"add","type":"float"}],"description":"Add vector and float value"},{"name":"Vector3Subtract","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Subtract two vectors"},{"name":"Vector3SubtractValue","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"sub","type":"float"}],"description":"Subtract vector by float value"},{"name":"Vector3Scale","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"scalar","type":"float"}],"description":"Multiply vector by scalar"},{"name":"Vector3Multiply","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Multiply vector by vector"},{"name":"Vector3CrossProduct","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Calculate two vectors cross product"},{"name":"Vector3Perpendicular","returnType":"Vector3","params":[{"name":"v","type":"Vector3"}],"description":"Calculate one vector perpendicular vector"},{"name":"Vector3Length","returnType":"float","params":[{"name":"v","type":"const Vector3"}],"description":"Calculate vector length"},{"name":"Vector3LengthSqr","returnType":"float","params":[{"name":"v","type":"const Vector3"}],"description":"Calculate vector square length"},{"name":"Vector3DotProduct","returnType":"float","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Calculate two vectors dot product"},{"name":"Vector3Distance","returnType":"float","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Calculate distance between two vectors"},{"name":"Vector3DistanceSqr","returnType":"float","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Calculate square distance between two vectors"},{"name":"Vector3Angle","returnType":"float","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Calculate angle between two vectors"},{"name":"Vector3Negate","returnType":"Vector3","params":[{"name":"v","type":"Vector3"}],"description":"Negate provided vector (invert direction)"},{"name":"Vector3Divide","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Divide vector by vector"},{"name":"Vector3Normalize","returnType":"Vector3","params":[{"name":"v","type":"Vector3"}],"description":"Normalize provided vector"},{"name":"Vector3OrthoNormalize","returnType":"void","params":[{"name":"v1","type":"Vector3 *"},{"name":"v2","type":"Vector3 *"}],"description":"Orthonormalize provided vectors\nMakes vectors normalized and orthogonal to each other\nGram-Schmidt function implementation"},{"name":"Vector3Transform","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"mat","type":"Matrix"}],"description":"Transforms a Vector3 by a given Matrix"},{"name":"Vector3RotateByQuaternion","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"q","type":"Quaternion"}],"description":"Transform a vector by quaternion rotation"},{"name":"Vector3RotateByAxisAngle","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"axis","type":"Vector3"},{"name":"angle","type":"float"}],"description":"Rotates a vector around an axis"},{"name":"Vector3Lerp","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"},{"name":"amount","type":"float"}],"description":"Calculate linear interpolation between two vectors"},{"name":"Vector3Reflect","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"normal","type":"Vector3"}],"description":"Calculate reflected vector to normal"},{"name":"Vector3Min","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Get min value for each pair of components"},{"name":"Vector3Max","returnType":"Vector3","params":[{"name":"v1","type":"Vector3"},{"name":"v2","type":"Vector3"}],"description":"Get max value for each pair of components"},{"name":"Vector3Barycenter","returnType":"Vector3","params":[{"name":"p","type":"Vector3"},{"name":"a","type":"Vector3"},{"name":"b","type":"Vector3"},{"name":"c","type":"Vector3"}],"description":"Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c)\nNOTE: Assumes P is on the plane of the triangle"},{"name":"Vector3Unproject","returnType":"Vector3","params":[{"name":"source","type":"Vector3"},{"name":"projection","type":"Matrix"},{"name":"view","type":"Matrix"}],"description":"Projects a Vector3 from screen space into object space\nNOTE: We are avoiding calling other raymath functions despite available"},{"name":"Vector3ToFloatV","returnType":"float3","params":[{"name":"v","type":"Vector3"}],"description":"Get Vector3 as float array"},{"name":"Vector3Invert","returnType":"Vector3","params":[{"name":"v","type":"Vector3"}],"description":"Invert the given vector"},{"name":"Vector3Clamp","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"min","type":"Vector3"},{"name":"max","type":"Vector3"}],"description":"Clamp the components of the vector between\nmin and max values specified by the given vectors"},{"name":"Vector3ClampValue","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"min","type":"float"},{"name":"max","type":"float"}],"description":"Clamp the magnitude of the vector between two values"},{"name":"Vector3Equals","returnType":"int","params":[{"name":"p","type":"Vector3"},{"name":"q","type":"Vector3"}],"description":"Check whether two given vectors are almost equal"},{"name":"Vector3Refract","returnType":"Vector3","params":[{"name":"v","type":"Vector3"},{"name":"n","type":"Vector3"},{"name":"r","type":"float"}],"description":"Compute the direction of a refracted ray where v specifies the\nnormalized direction of the incoming ray, n specifies the\nnormalized normal vector of the interface of two optical media,\nand r specifies the ratio of the refractive index of the medium\nfrom where the ray comes to the refractive index of the medium\non the other side of the surface"},{"name":"MatrixDeterminant","returnType":"float","params":[{"name":"mat","type":"Matrix"}],"description":"Compute matrix determinant"},{"name":"MatrixTrace","returnType":"float","params":[{"name":"mat","type":"Matrix"}],"description":"Get the trace of the matrix (sum of the values along the diagonal)"},{"name":"MatrixTranspose","returnType":"Matrix","params":[{"name":"mat","type":"Matrix"}],"description":"Transposes provided matrix"},{"name":"MatrixInvert","returnType":"Matrix","params":[{"name":"mat","type":"Matrix"}],"description":"Invert provided matrix"},{"name":"MatrixIdentity","returnType":"Matrix","params":[],"description":"Get identity matrix"},{"name":"MatrixAdd","returnType":"Matrix","params":[{"name":"left","type":"Matrix"},{"name":"right","type":"Matrix"}],"description":"Add two matrices"},{"name":"MatrixSubtract","returnType":"Matrix","params":[{"name":"left","type":"Matrix"},{"name":"right","type":"Matrix"}],"description":"Subtract two matrices (left - right)"},{"name":"MatrixMultiply","returnType":"Matrix","params":[{"name":"left","type":"Matrix"},{"name":"right","type":"Matrix"}],"description":"Get two matrix multiplication\nNOTE: When multiplying matrices... the order matters!"},{"name":"MatrixTranslate","returnType":"Matrix","params":[{"name":"x","type":"float"},{"name":"y","type":"float"},{"name":"z","type":"float"}],"description":"Get translation matrix"},{"name":"MatrixRotate","returnType":"Matrix","params":[{"name":"axis","type":"Vector3"},{"name":"angle","type":"float"}],"description":"Create rotation matrix from axis and angle\nNOTE: Angle should be provided in radians"},{"name":"MatrixRotateX","returnType":"Matrix","params":[{"name":"angle","type":"float"}],"description":"Get x-rotation matrix\nNOTE: Angle must be provided in radians"},{"name":"MatrixRotateY","returnType":"Matrix","params":[{"name":"angle","type":"float"}],"description":"Get y-rotation matrix\nNOTE: Angle must be provided in radians"},{"name":"MatrixRotateZ","returnType":"Matrix","params":[{"name":"angle","type":"float"}],"description":"Get z-rotation matrix\nNOTE: Angle must be provided in radians"},{"name":"MatrixRotateXYZ","returnType":"Matrix","params":[{"name":"angle","type":"Vector3"}],"description":"Get xyz-rotation matrix\nNOTE: Angle must be provided in radians"},{"name":"MatrixRotateZYX","returnType":"Matrix","params":[{"name":"angle","type":"Vector3"}],"description":"Get zyx-rotation matrix\nNOTE: Angle must be provided in radians"},{"name":"MatrixScale","returnType":"Matrix","params":[{"name":"x","type":"float"},{"name":"y","type":"float"},{"name":"z","type":"float"}],"description":"Get scaling matrix"},{"name":"MatrixFrustum","returnType":"Matrix","params":[{"name":"left","type":"double"},{"name":"right","type":"double"},{"name":"bottom","type":"double"},{"name":"top","type":"double"},{"name":"near","type":"double"},{"name":"far","type":"double"}],"description":"Get perspective projection matrix"},{"name":"MatrixPerspective","returnType":"Matrix","params":[{"name":"fovy","type":"double"},{"name":"aspect","type":"double"},{"name":"near","type":"double"},{"name":"far","type":"double"}],"description":"Get perspective projection matrix\nNOTE: Fovy angle must be provided in radians"},{"name":"MatrixOrtho","returnType":"Matrix","params":[{"name":"left","type":"double"},{"name":"right","type":"double"},{"name":"bottom","type":"double"},{"name":"top","type":"double"},{"name":"near","type":"double"},{"name":"far","type":"double"}],"description":"Get orthographic projection matrix"},{"name":"MatrixLookAt","returnType":"Matrix","params":[{"name":"eye","type":"Vector3"},{"name":"target","type":"Vector3"},{"name":"up","type":"Vector3"}],"description":"Get camera look-at matrix (view matrix)"},{"name":"MatrixToFloatV","returnType":"float16","params":[{"name":"mat","type":"Matrix"}],"description":"Get float array of matrix data"},{"name":"QuaternionAdd","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"}],"description":"Add two quaternions"},{"name":"QuaternionAddValue","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"},{"name":"add","type":"float"}],"description":"Add quaternion and float value"},{"name":"QuaternionSubtract","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"}],"description":"Subtract two quaternions"},{"name":"QuaternionSubtractValue","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"},{"name":"sub","type":"float"}],"description":"Subtract quaternion and float value"},{"name":"QuaternionIdentity","returnType":"Quaternion","params":[],"description":"Get identity quaternion"},{"name":"QuaternionLength","returnType":"float","params":[{"name":"q","type":"Quaternion"}],"description":"Computes the length of a quaternion"},{"name":"QuaternionNormalize","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"}],"description":"Normalize provided quaternion"},{"name":"QuaternionInvert","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"}],"description":"Invert provided quaternion"},{"name":"QuaternionMultiply","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"}],"description":"Calculate two quaternion multiplication"},{"name":"QuaternionScale","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"},{"name":"mul","type":"float"}],"description":"Scale quaternion by float value"},{"name":"QuaternionDivide","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"}],"description":"Divide two quaternions"},{"name":"QuaternionLerp","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"},{"name":"amount","type":"float"}],"description":"Calculate linear interpolation between two quaternions"},{"name":"QuaternionNlerp","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"},{"name":"amount","type":"float"}],"description":"Calculate slerp-optimized interpolation between two quaternions"},{"name":"QuaternionSlerp","returnType":"Quaternion","params":[{"name":"q1","type":"Quaternion"},{"name":"q2","type":"Quaternion"},{"name":"amount","type":"float"}],"description":"Calculates spherical linear interpolation between two quaternions"},{"name":"QuaternionFromVector3ToVector3","returnType":"Quaternion","params":[{"name":"from","type":"Vector3"},{"name":"to","type":"Vector3"}],"description":"Calculate quaternion based on the rotation from one vector to another"},{"name":"QuaternionFromMatrix","returnType":"Quaternion","params":[{"name":"mat","type":"Matrix"}],"description":"Get a quaternion for a given rotation matrix"},{"name":"QuaternionToMatrix","returnType":"Matrix","params":[{"name":"q","type":"Quaternion"}],"description":"Get a matrix for a given quaternion"},{"name":"QuaternionFromAxisAngle","returnType":"Quaternion","params":[{"name":"axis","type":"Vector3"},{"name":"angle","type":"float"}],"description":"Get rotation quaternion for an angle and axis\nNOTE: Angle must be provided in radians"},{"name":"QuaternionToAxisAngle","returnType":"void","params":[{"name":"q","type":"Quaternion"},{"name":"outAxis","type":"Vector3 *"},{"name":"outAngle","type":"float *"}],"description":"Get the rotation angle and axis for a given quaternion"},{"name":"QuaternionFromEuler","returnType":"Quaternion","params":[{"name":"pitch","type":"float"},{"name":"yaw","type":"float"},{"name":"roll","type":"float"}],"description":"Get the quaternion equivalent to Euler angles\nNOTE: Rotation order is ZYX"},{"name":"QuaternionToEuler","returnType":"Vector3","params":[{"name":"q","type":"Quaternion"}],"description":"Get the Euler angles equivalent to quaternion (roll, pitch, yaw)\nNOTE: Angles are returned in a Vector3 struct in radians"},{"name":"QuaternionTransform","returnType":"Quaternion","params":[{"name":"q","type":"Quaternion"},{"name":"mat","type":"Matrix"}],"description":"Transform a quaternion given a transformation matrix"},{"name":"QuaternionEquals","returnType":"int","params":[{"name":"p","type":"Quaternion"},{"name":"q","type":"Quaternion"}],"description":"Check whether two given quaternions are almost equal"}] \ No newline at end of file diff --git a/bindings/src/index.ts b/bindings/src/index.ts index a9c59a9..fa34866 100644 --- a/bindings/src/index.ts +++ b/bindings/src/index.ts @@ -4,13 +4,10 @@ import { ApiDescription, ApiFunction } from "./api"; import { RayLibHeader } from "./raylib-header"; function parseMathHeader(): RayLibFunction[] { - return readFileSync("thirdparty/raylib/src/raymath.h", 'utf8') - .split("\n") - .filter(x => x.startsWith("RMAPI")) - .map(inputString => { - const matches = inputString.match(/^RMAPI\s+([\w<>]+)\s+([\w<>]+)\((.*)\)$/); - if(!matches) throw new Error("Unable to match " + inputString) - const args = matches[3].split(',').filter(x => x !== 'void').map(arg => { + const i = readFileSync("thirdparty/raylib/src/raymath.h", 'utf8') + const m = [...i.matchAll(/((?:\/\/ .+\n)*)RMAPI\s+([\w<>]+)\s+([\w<>]+)\((.*)\)/gm)] + const res = m.map(groups => { + const args = groups[4].split(',').filter(x => x !== 'void').map(arg => { arg = arg.trim().replace(" *", "* ") const frags = arg.split(' ') const name = frags.pop() @@ -18,27 +15,30 @@ function parseMathHeader(): RayLibFunction[] { return { name: name || "", type: type } }) + const comments = groups[1].split('\n').map(x => x.replace("// ","")).join('\n').trim() return { - name: matches[2], - returnType: matches[1], + name: groups[3], + returnType: groups[2], params: args, - description: "" + description: comments } - }); + }) + return res; } function main(){ - - const mathApi = parseMathHeader(); - writeFileSync("bindings/raylib_math_api.json", JSON.stringify(mathApi)) - + + // Load the pre-generated raylib api const api = JSON.parse(readFileSync("thirdparty/raylib/parser/output/raylib_api.json", 'utf8')) + api.functions.push({ name: "SetModelMaterial", description: "Replace material in slot materialIndex", returnType: "void", params: [{type: "Model *",name:"model"},{type:"int",name:"materialIndex"},{type:"Material",name:"material"}] }) + const mathApi = parseMathHeader(); + writeFileSync("bindings/raylib_math_api.json", JSON.stringify(mathApi)) mathApi.forEach(x => api.functions.push(x)) const apiDesc = new ApiDescription(api) diff --git a/doc/auto-complete.png b/doc/auto-complete.png new file mode 100644 index 0000000..9d3c991 Binary files /dev/null and b/doc/auto-complete.png differ diff --git a/examples/bunnymark.js b/examples/bunnymark.js index 91faa59..2ffcb06 100644 --- a/examples/bunnymark.js +++ b/examples/bunnymark.js @@ -42,15 +42,19 @@ while (!windowShouldClose()) // Detect window close button or ESC key } // Update bunnies + const width = getScreenWidth() + const height = getScreenHeight() for (let i = 0; i < bunniesCount; i++) { - bunnies[i].position.x += bunnies[i].speed.x; - bunnies[i].position.y += bunnies[i].speed.y; + const bunny = bunnies[i] - if (((bunnies[i].position.x + texBunny.width/2) > getScreenWidth()) || - ((bunnies[i].position.x + texBunny.width/2) < 0)) bunnies[i].speed.x *= -1; - if (((bunnies[i].position.y + texBunny.height/2) > getScreenHeight()) || - ((bunnies[i].position.y + texBunny.height/2 - 40) < 0)) bunnies[i].speed.y *= -1; + bunny.position.x += bunny.speed.x; + bunny.position.y += bunny.speed.y; + + if (((bunny.position.x + texBunny.width/2) > width) || + ((bunny.position.x + texBunny.width/2) < 0)) bunny.speed.x *= -1; + if (((bunny.position.y + texBunny.height/2) > height) || + ((bunny.position.y + texBunny.height/2 - 40) < 0)) bunny.speed.y *= -1; } //---------------------------------------------------------------------------------- @@ -62,13 +66,14 @@ while (!windowShouldClose()) // Detect window close button or ESC key for (let i = 0; i < bunniesCount; i++) { + const bunny = bunnies[i] // NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS), // a draw call is launched and buffer starts being filled again; // before issuing a draw call, updated vertex data from internal CPU buffer is send to GPU... // Process of sending data is costly and it could happen that GPU data has not been completely // processed for drawing while new data is tried to be sent (updating current in-use buffers) // it could generates a stall and consequently a frame drop, limiting the number of drawn bunnies - drawTexture(texBunny, bunnies[i].position.x, bunnies[i].position.y, bunnies[i].color); + drawTexture(texBunny, bunny.position.x, bunny.position.y, bunny.color); } drawRectangle(0, 0, screenWidth, 40, BLACK); diff --git a/examples/lib.raylib.d.ts b/examples/lib.raylib.d.ts index efeb351..05d892c 100644 --- a/examples/lib.raylib.d.ts +++ b/examples/lib.raylib.d.ts @@ -1121,221 +1121,244 @@ declare function setMusicPan(music: Music, pan: number): void; declare function getMusicTimeLength(music: Music): number; /** Get current music time played (in seconds) */ declare function getMusicTimePlayed(music: Music): number; -/** */ +/** Clamp float value */ declare function clamp(value: number, min: number, max: number): number; -/** */ +/** Calculate linear interpolation between two floats */ declare function lerp(start: number, end: number, amount: number): number; -/** */ +/** Normalize input value within input range */ declare function normalize(value: number, start: number, end: number): number; -/** */ +/** Remap input value within input range to output range */ declare function remap(value: number, inputStart: number, inputEnd: number, outputStart: number, outputEnd: number): number; -/** */ +/** Wrap input value from min to max */ declare function wrap(value: number, min: number, max: number): number; -/** */ +/** Check whether two given floats are almost equal */ declare function floatEquals(x: number, y: number): number; -/** */ +/** Vector with components value 0.0f */ declare function vector2Zero(): Vector2; -/** */ +/** Vector with components value 1.0f */ declare function vector2One(): Vector2; -/** */ +/** Add two vectors (v1 + v2) */ declare function vector2Add(v1: Vector2, v2: Vector2): Vector2; -/** */ +/** Add vector and float value */ declare function vector2AddValue(v: Vector2, add: number): Vector2; -/** */ +/** Subtract two vectors (v1 - v2) */ declare function vector2Subtract(v1: Vector2, v2: Vector2): Vector2; -/** */ +/** Subtract vector by float value */ declare function vector2SubtractValue(v: Vector2, sub: number): Vector2; -/** */ +/** Calculate vector length */ declare function vector2Length(v: Vector2): number; -/** */ +/** Calculate vector square length */ declare function vector2LengthSqr(v: Vector2): number; -/** */ +/** Calculate two vectors dot product */ declare function vector2DotProduct(v1: Vector2, v2: Vector2): number; -/** */ +/** Calculate distance between two vectors */ declare function vector2Distance(v1: Vector2, v2: Vector2): number; -/** */ +/** Calculate square distance between two vectors */ declare function vector2DistanceSqr(v1: Vector2, v2: Vector2): number; -/** */ +/** Calculate angle between two vectors +NOTE: Angle is calculated from origin point (0, 0) */ declare function vector2Angle(v1: Vector2, v2: Vector2): number; -/** */ +/** Calculate angle defined by a two vectors line +NOTE: Parameters need to be normalized +Current implementation should be aligned with glm::angle */ declare function vector2LineAngle(start: Vector2, end: Vector2): number; -/** */ +/** Scale vector (multiply by value) */ declare function vector2Scale(v: Vector2, scale: number): Vector2; -/** */ +/** Multiply vector by vector */ declare function vector2Multiply(v1: Vector2, v2: Vector2): Vector2; -/** */ +/** Negate vector */ declare function vector2Negate(v: Vector2): Vector2; -/** */ +/** Divide vector by vector */ declare function vector2Divide(v1: Vector2, v2: Vector2): Vector2; -/** */ +/** Normalize provided vector */ declare function vector2Normalize(v: Vector2): Vector2; -/** */ +/** Transforms a Vector2 by a given Matrix */ declare function vector2Transform(v: Vector2, mat: Matrix): Vector2; -/** */ +/** Calculate linear interpolation between two vectors */ declare function vector2Lerp(v1: Vector2, v2: Vector2, amount: number): Vector2; -/** */ +/** Calculate reflected vector to normal */ declare function vector2Reflect(v: Vector2, normal: Vector2): Vector2; -/** */ +/** Rotate vector by angle */ declare function vector2Rotate(v: Vector2, angle: number): Vector2; -/** */ +/** Move Vector towards target */ declare function vector2MoveTowards(v: Vector2, target: Vector2, maxDistance: number): Vector2; -/** */ +/** Invert the given vector */ declare function vector2Invert(v: Vector2): Vector2; -/** */ +/** Clamp the components of the vector between +min and max values specified by the given vectors */ declare function vector2Clamp(v: Vector2, min: Vector2, max: Vector2): Vector2; -/** */ +/** Clamp the magnitude of the vector between two min and max values */ declare function vector2ClampValue(v: Vector2, min: number, max: number): Vector2; -/** */ +/** Check whether two given vectors are almost equal */ declare function vector2Equals(p: Vector2, q: Vector2): number; -/** */ +/** Vector with components value 0.0f */ declare function vector3Zero(): Vector3; -/** */ +/** Vector with components value 1.0f */ declare function vector3One(): Vector3; -/** */ +/** Add two vectors */ declare function vector3Add(v1: Vector3, v2: Vector3): Vector3; -/** */ +/** Add vector and float value */ declare function vector3AddValue(v: Vector3, add: number): Vector3; -/** */ +/** Subtract two vectors */ declare function vector3Subtract(v1: Vector3, v2: Vector3): Vector3; -/** */ +/** Subtract vector by float value */ declare function vector3SubtractValue(v: Vector3, sub: number): Vector3; -/** */ +/** Multiply vector by scalar */ declare function vector3Scale(v: Vector3, scalar: number): Vector3; -/** */ +/** Multiply vector by vector */ declare function vector3Multiply(v1: Vector3, v2: Vector3): Vector3; -/** */ +/** Calculate two vectors cross product */ declare function vector3CrossProduct(v1: Vector3, v2: Vector3): Vector3; -/** */ +/** Calculate one vector perpendicular vector */ declare function vector3Perpendicular(v: Vector3): Vector3; -/** */ +/** Calculate vector length */ declare function vector3Length(v: Vector3): number; -/** */ +/** Calculate vector square length */ declare function vector3LengthSqr(v: Vector3): number; -/** */ +/** Calculate two vectors dot product */ declare function vector3DotProduct(v1: Vector3, v2: Vector3): number; -/** */ +/** Calculate distance between two vectors */ declare function vector3Distance(v1: Vector3, v2: Vector3): number; -/** */ +/** Calculate square distance between two vectors */ declare function vector3DistanceSqr(v1: Vector3, v2: Vector3): number; -/** */ +/** Calculate angle between two vectors */ declare function vector3Angle(v1: Vector3, v2: Vector3): number; -/** */ +/** Negate provided vector (invert direction) */ declare function vector3Negate(v: Vector3): Vector3; -/** */ +/** Divide vector by vector */ declare function vector3Divide(v1: Vector3, v2: Vector3): Vector3; -/** */ +/** Normalize provided vector */ declare function vector3Normalize(v: Vector3): Vector3; -/** */ +/** Transforms a Vector3 by a given Matrix */ declare function vector3Transform(v: Vector3, mat: Matrix): Vector3; -/** */ +/** Transform a vector by quaternion rotation */ declare function vector3RotateByQuaternion(v: Vector3, q: Vector4): Vector3; -/** */ +/** Rotates a vector around an axis */ declare function vector3RotateByAxisAngle(v: Vector3, axis: Vector3, angle: number): Vector3; -/** */ +/** Calculate linear interpolation between two vectors */ declare function vector3Lerp(v1: Vector3, v2: Vector3, amount: number): Vector3; -/** */ +/** Calculate reflected vector to normal */ declare function vector3Reflect(v: Vector3, normal: Vector3): Vector3; -/** */ +/** Get min value for each pair of components */ declare function vector3Min(v1: Vector3, v2: Vector3): Vector3; -/** */ +/** Get max value for each pair of components */ declare function vector3Max(v1: Vector3, v2: Vector3): Vector3; -/** */ +/** Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c) +NOTE: Assumes P is on the plane of the triangle */ declare function vector3Barycenter(p: Vector3, a: Vector3, b: Vector3, c: Vector3): Vector3; -/** */ +/** Projects a Vector3 from screen space into object space +NOTE: We are avoiding calling other raymath functions despite available */ declare function vector3Unproject(source: Vector3, projection: Matrix, view: Matrix): Vector3; -/** */ +/** Invert the given vector */ declare function vector3Invert(v: Vector3): Vector3; -/** */ +/** Clamp the components of the vector between +min and max values specified by the given vectors */ declare function vector3Clamp(v: Vector3, min: Vector3, max: Vector3): Vector3; -/** */ +/** Clamp the magnitude of the vector between two values */ declare function vector3ClampValue(v: Vector3, min: number, max: number): Vector3; -/** */ +/** Check whether two given vectors are almost equal */ declare function vector3Equals(p: Vector3, q: Vector3): number; -/** */ +/** Compute the direction of a refracted ray where v specifies the +normalized direction of the incoming ray, n specifies the +normalized normal vector of the interface of two optical media, +and r specifies the ratio of the refractive index of the medium +from where the ray comes to the refractive index of the medium +on the other side of the surface */ declare function vector3Refract(v: Vector3, n: Vector3, r: number): Vector3; -/** */ +/** Compute matrix determinant */ declare function matrixDeterminant(mat: Matrix): number; -/** */ +/** Get the trace of the matrix (sum of the values along the diagonal) */ declare function matrixTrace(mat: Matrix): number; -/** */ +/** Transposes provided matrix */ declare function matrixTranspose(mat: Matrix): Matrix; -/** */ +/** Invert provided matrix */ declare function matrixInvert(mat: Matrix): Matrix; -/** */ +/** Get identity matrix */ declare function matrixIdentity(): Matrix; -/** */ +/** Add two matrices */ declare function matrixAdd(left: Matrix, right: Matrix): Matrix; -/** */ +/** Subtract two matrices (left - right) */ declare function matrixSubtract(left: Matrix, right: Matrix): Matrix; -/** */ +/** Get two matrix multiplication +NOTE: When multiplying matrices... the order matters! */ declare function matrixMultiply(left: Matrix, right: Matrix): Matrix; -/** */ +/** Get translation matrix */ declare function matrixTranslate(x: number, y: number, z: number): Matrix; -/** */ +/** Create rotation matrix from axis and angle +NOTE: Angle should be provided in radians */ declare function matrixRotate(axis: Vector3, angle: number): Matrix; -/** */ +/** Get x-rotation matrix +NOTE: Angle must be provided in radians */ declare function matrixRotateX(angle: number): Matrix; -/** */ +/** Get y-rotation matrix +NOTE: Angle must be provided in radians */ declare function matrixRotateY(angle: number): Matrix; -/** */ +/** Get z-rotation matrix +NOTE: Angle must be provided in radians */ declare function matrixRotateZ(angle: number): Matrix; -/** */ +/** Get xyz-rotation matrix +NOTE: Angle must be provided in radians */ declare function matrixRotateXYZ(angle: Vector3): Matrix; -/** */ +/** Get zyx-rotation matrix +NOTE: Angle must be provided in radians */ declare function matrixRotateZYX(angle: Vector3): Matrix; -/** */ +/** Get scaling matrix */ declare function matrixScale(x: number, y: number, z: number): Matrix; -/** */ +/** Get perspective projection matrix */ declare function matrixFrustum(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix; -/** */ +/** Get perspective projection matrix +NOTE: Fovy angle must be provided in radians */ declare function matrixPerspective(fovy: number, aspect: number, near: number, far: number): Matrix; -/** */ +/** Get orthographic projection matrix */ declare function matrixOrtho(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix; -/** */ +/** Get camera look-at matrix (view matrix) */ declare function matrixLookAt(eye: Vector3, target: Vector3, up: Vector3): Matrix; -/** */ +/** Add two quaternions */ declare function quaternionAdd(q1: Vector4, q2: Vector4): Vector4; -/** */ +/** Add quaternion and float value */ declare function quaternionAddValue(q: Vector4, add: number): Vector4; -/** */ +/** Subtract two quaternions */ declare function quaternionSubtract(q1: Vector4, q2: Vector4): Vector4; -/** */ +/** Subtract quaternion and float value */ declare function quaternionSubtractValue(q: Vector4, sub: number): Vector4; -/** */ +/** Get identity quaternion */ declare function quaternionIdentity(): Vector4; -/** */ +/** Computes the length of a quaternion */ declare function quaternionLength(q: Vector4): number; -/** */ +/** Normalize provided quaternion */ declare function quaternionNormalize(q: Vector4): Vector4; -/** */ +/** Invert provided quaternion */ declare function quaternionInvert(q: Vector4): Vector4; -/** */ +/** Calculate two quaternion multiplication */ declare function quaternionMultiply(q1: Vector4, q2: Vector4): Vector4; -/** */ +/** Scale quaternion by float value */ declare function quaternionScale(q: Vector4, mul: number): Vector4; -/** */ +/** Divide two quaternions */ declare function quaternionDivide(q1: Vector4, q2: Vector4): Vector4; -/** */ +/** Calculate linear interpolation between two quaternions */ declare function quaternionLerp(q1: Vector4, q2: Vector4, amount: number): Vector4; -/** */ +/** Calculate slerp-optimized interpolation between two quaternions */ declare function quaternionNlerp(q1: Vector4, q2: Vector4, amount: number): Vector4; -/** */ +/** Calculates spherical linear interpolation between two quaternions */ declare function quaternionSlerp(q1: Vector4, q2: Vector4, amount: number): Vector4; -/** */ +/** Calculate quaternion based on the rotation from one vector to another */ declare function quaternionFromVector3ToVector3(from: Vector3, to: Vector3): Vector4; -/** */ +/** Get a quaternion for a given rotation matrix */ declare function quaternionFromMatrix(mat: Matrix): Vector4; -/** */ +/** Get a matrix for a given quaternion */ declare function quaternionToMatrix(q: Vector4): Matrix; -/** */ +/** Get rotation quaternion for an angle and axis +NOTE: Angle must be provided in radians */ declare function quaternionFromAxisAngle(axis: Vector3, angle: number): Vector4; -/** */ +/** Get the quaternion equivalent to Euler angles +NOTE: Rotation order is ZYX */ declare function quaternionFromEuler(pitch: number, yaw: number, roll: number): Vector4; -/** */ +/** Get the Euler angles equivalent to quaternion (roll, pitch, yaw) +NOTE: Angles are returned in a Vector3 struct in radians */ declare function quaternionToEuler(q: Vector4): Vector3; -/** */ +/** Transform a quaternion given a transformation matrix */ declare function quaternionTransform(q: Vector4, mat: Matrix): Vector4; -/** */ +/** Check whether two given quaternions are almost equal */ declare function quaternionEquals(p: Vector4, q: Vector4): number; /** Light Gray */ declare var LIGHTGRAY: Color; diff --git a/generate-bindings.js b/generate-bindings.js index 67f1e1e..0d81e8b 100644 --- a/generate-bindings.js +++ b/generate-bindings.js @@ -897,31 +897,28 @@ const fs_1 = __webpack_require__(/*! fs */ "fs"); const api_1 = __webpack_require__(/*! ./api */ "./src/api.ts"); const raylib_header_1 = __webpack_require__(/*! ./raylib-header */ "./src/raylib-header.ts"); function parseMathHeader() { - return (0, fs_1.readFileSync)("thirdparty/raylib/src/raymath.h", 'utf8') - .split("\n") - .filter(x => x.startsWith("RMAPI")) - .map(inputString => { - const matches = inputString.match(/^RMAPI\s+([\w<>]+)\s+([\w<>]+)\((.*)\)$/); - if (!matches) - throw new Error("Unable to match " + inputString); - const args = matches[3].split(',').filter(x => x !== 'void').map(arg => { + const i = (0, fs_1.readFileSync)("thirdparty/raylib/src/raymath.h", 'utf8'); + const m = [...i.matchAll(/((?:\/\/ .+\n)*)RMAPI\s+([\w<>]+)\s+([\w<>]+)\((.*)\)/gm)]; + const res = m.map(groups => { + const args = groups[4].split(',').filter(x => x !== 'void').map(arg => { arg = arg.trim().replace(" *", "* "); const frags = arg.split(' '); const name = frags.pop(); const type = frags.join(' ').replace("*", " *"); return { name: name || "", type: type }; }); + const comments = groups[1].split('\n').map(x => x.replace("// ", "")).join('\n').trim(); return { - name: matches[2], - returnType: matches[1], + name: groups[3], + returnType: groups[2], params: args, - description: "" + description: comments }; }); + return res; } function main() { - const mathApi = parseMathHeader(); - (0, fs_1.writeFileSync)("bindings/raylib_math_api.json", JSON.stringify(mathApi)); + // Load the pre-generated raylib api const api = JSON.parse((0, fs_1.readFileSync)("thirdparty/raylib/parser/output/raylib_api.json", 'utf8')); api.functions.push({ name: "SetModelMaterial", @@ -929,6 +926,8 @@ function main() { returnType: "void", params: [{ type: "Model *", name: "model" }, { type: "int", name: "materialIndex" }, { type: "Material", name: "material" }] }); + const mathApi = parseMathHeader(); + (0, fs_1.writeFileSync)("bindings/raylib_math_api.json", JSON.stringify(mathApi)); mathApi.forEach(x => api.functions.push(x)); const apiDesc = new api_1.ApiDescription(api); const core = new raylib_header_1.RayLibHeader("raylib_core", apiDesc); diff --git a/readme.md b/readme.md index 2f7f086..2e6f35f 100644 --- a/readme.md +++ b/readme.md @@ -5,6 +5,9 @@ Javascript bindings for raylib in a single ~3mb executable ## What is this? rayjs is small ES2020 compliant Javascript interpreter based on [QuickJS](https://bellard.org/quickjs/) with bindings for [Raylib](https://www.raylib.com/). You can use it to develop desktop games with Javascript. +## What this is not +rayjs is not a binding for NodeJS nor is it running in the browser (yet). It's comes with its own Javascript engine (QuickJS) similar to how NodeJS comes with the V8 engine. That makes it much easier to run and distribute rayjs programs as all you need to run a program / game is the small rayjs executable. No installation, no dlls or additional files are needed. + ## Features * Compiles into a single, small executable without any dependencies for easy distribution * Use modern Javascript features like classes or async/await @@ -43,6 +46,26 @@ rayjs will run code in three different modes The directory of the main Javascript module will also be the working directory of the app. Modules and resources will be loaded relative to it. +## API support + +The following raylib APIs are supported so far (with a few exceptions): + +- core (no VR support yet) +- shapes +- textures +- text (no support for GlyphInfo yet) +- models +- shaders +- audio +- raymath + +Similar to including a header in C and for your convenience, all types/functions are provided globally. They are additionally available in a module called 'raylib' + +## Auto-Complete / Intellisense + +rayjs comes with full auto-complete support in the form of the definitions file `lib.raylib.d.ts`. These will work with Typescript and Javascript. For most editors (e.g. Visual Studio Code) it should be enough to put them in the project folder. +![](doc/auto-complete.png) + ## Building Here are some basic steps if you want to compile rayjs yourself. You should use CMake for building. **Please note that QuickJS needs Mingw in order to compile correctly on Windows** @@ -53,6 +76,8 @@ git clone https://github.com/mode777/rayjs.git git submodule update --init --recursive ``` + + ### Build with cmake Make sure you have cmake installed and in your path. ```bash @@ -64,5 +89,5 @@ make ``` ## Performance -QuickJS is one of the [faster JS interpreters](https://bellard.org/quickjs/bench.html). I'm getting about 13000 bunnys in bunnmark before dropping any frames on my 2020 Macbook Air M1 which seems pretty good. +QuickJS is one of the [faster JS interpreters](https://bellard.org/quickjs/bench.html). I'm getting about 13000 bunnys in the unmodified bunnmark before dropping any frames on my 2020 Macbook Air M1 which seems pretty good. ![Bunnymark](doc/bunny.png)