Skip to content

Vector3Like

Vector3Like = Vector3d | [number, number, number] | [number, number] | { x: number; y: number; z?: number; }

Any value that can be interpreted as a 3D vector.

Most API methods that accept a direction or displacement take a Vector3Like, letting you pass either a Vector3d instance or a plain [x, y, z] tuple.

let { Transformation } = SketchUpApi;
// Rotation accepts a Vector3Like for the axis,
// so both of these do the same thing:
let spinA = Transformation.rotation(
[0, 0, 0],
[0, 0, 1],
Math.PI / 2
);
let spinB = Transformation.rotation(
new SketchUpApi.Point3d(0, 0, 0),
new SketchUpApi.Vector3d(0, 0, 1),
Math.PI / 2
);
console.log(spinA.xaxis.toArray());
// => [0, 1, 0]
console.log(spinB.xaxis.toArray());
// => [0, 1, 0]

Vector3d