1.9 KiB
IScriptFactory.vector4
Parça 10/11 · önceki · sonraki
default Vector4d vector4(Vector4d v)
Copy a 4D vector.
matrix3
default Matrix3d matrix3()
Create an identity 3x3 matrix.
var v = mappet.vector3(0, 0, 1); var rotation = mappet.matrix3();
rotation.rotY(Math.PI / 2); rotation.transform(v);
c.send("Final point is: " + v);
matrix3
default Matrix3d matrix3(Matrix3d m)
Copy a 3x3 matrix.
matrix4
default Matrix4d matrix4()
Create an identity 4x4 matrix.
var v = mappet.vector4(0, 0, 1, 1); var rotation = mappet.matrix4();
rotation.rotY(Math.PI / 2);
var translation = mappet.matrix4();
translation.setTranslation(mappet.vector3(0, 4, 0)); rotation.mul(translation); rotation.transform(v);
c.send("Final point is: " + v.x + ", " + v.y + ", " + v.z);
matrix4
default Matrix4d matrix4(Matrix4d m)
Copy a 4x4 matrix.
box
default ScriptBox box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
Create a bounding box.
function main(c) { var subject = c.getSubject(); var subjectPosition = subject.getPosition(); var box = mappet.box(-10, 4, -10, 10, 6, 10); if (box.contains(subjectPosition)){ c.send("the player in in the box") } }
isPointInBounds
boolean isPointInBounds(java.lang.Object point, java.lang.Object bound1, java.lang.Object bound2)
Determines whether a point is located inside a bounding volume specified by two corners. This method works with different vector types (2D, 3D, and 4D).
var pos = c.getSubject().getPosition(); var point = mappet.vector3(pos.x, pos.y, pos.z); var bound1 = mappet.vector3(0, 0, 0); var bound2 = mappet.vector3(10, 10, 10); var isInside = mappet.isPointInBounds(point, bound1, bound2);