Vector3.setScalar()

Set the x, y and/or z values from the scalars given as parameters

Parameters

NameTypeDescription
1xnumber | nullValue of the X axis
2ynumber | null | undefinedValue of the Y axis
3znumber | null | undefinedValue of the Z axis

Return value

Vector3

Usage

import {Vector3} from '@lcluber/type6js';


// set from scalars
let vector = new Vector3(1,1,1);
console.log(vector); //(1,1,1)
vector.setScalar(2,2,2);
console.log(vector); //(2,2,2)

// set x axis only
let vector = new Vector3(3);
console.log(vector); //(3,0,0)
vector.setScalar(2);
console.log(vector); //(2,0,0)

// set y axis only
let vector = new Vector3(null, 3, null);
console.log(vector); //(0,3,0)
vector.setScalar(null,2, null);
console.log(vector); //(0,2,0)

// set z axis only
let vector = new Vector3(null, null, 3);
console.log(vector); //(0,0,3)
vector.setScalar(null, null, 2);
console.log(vector); //(0,0,2)