@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
42 lines (41 loc) • 992 B
JavaScript
;
import { NamedFunction3 } from "./_Base";
export class maxLengthVector2 extends NamedFunction3 {
static type() {
return "maxLengthVector2";
}
func(src, maxLength, target) {
target.copy(src);
const length = target.length();
if (length > maxLength) {
target.normalize().multiplyScalar(maxLength);
}
return target;
}
}
export class maxLengthVector3 extends NamedFunction3 {
static type() {
return "maxLengthVector3";
}
func(src, maxLength, target) {
target.copy(src);
const length = target.length();
if (length > maxLength) {
target.normalize().multiplyScalar(maxLength);
}
return target;
}
}
export class maxLengthVector4 extends NamedFunction3 {
static type() {
return "maxLengthVector4";
}
func(src, maxLength, target) {
target.copy(src);
const length = target.length();
if (length > maxLength) {
target.normalize().multiplyScalar(maxLength);
}
return target;
}
}