Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props = {}) {
const {id} = props;
this.id = id || uid(this.constructor.name);
this.display = true; // whether to display the object at all
this.position = new Vector3();
this.rotation = new Vector3();
this.scale = new Vector3(1, 1, 1);
this.matrix = new Matrix4();
this.userData = {};
this.props = {};
this._setScenegraphNodeProps(props);
}
constructor(props = {}) {
const {id} = props;
this.id = id || uid(this.constructor.name);
this.display = true; // whether to display the object at all
this.position = new Vector3();
this.rotation = new Vector3();
this.scale = new Vector3(1, 1, 1);
this.matrix = new Matrix4();
this.userData = {};
this.props = {};
this._setScenegraphNodeProps(props);
}
constructor(props = {}) {
const {id} = props;
this.id = id || uid(this.constructor.name);
this.display = true; // whether to display the object at all
this.position = new Vector3();
this.rotation = new Vector3();
this.scale = new Vector3(1, 1, 1);
this.matrix = new Matrix4();
this.userData = {};
this.props = {};
this._setScenegraphNodeProps(props);
}
getDirectionalUniforms(directional) {
const {color, direction} = directional;
// Normalize lighting direction vector
const dir = new Vector3(direction.x, direction.y, direction.z)
.normalize()
.scale(-1, -1, -1);
return {
directionalColor: [color.r, color.g, color.b],
lightingDirection: [dir.x, dir.y, dir.z]
};
}
function getCulling(p, planes) {
const outDirs = [];
p = new Vector3(p);
for (const dir in planes) {
const plane = planes[dir];
if (p.dot(plane.normal) > plane.distance) {
outDirs.push(dir);
}
}
return outDirs.length ? outDirs : null;
}
function getCulling(p, planes) {
let outDir = null;
p = new Vector3(p);
for (const dir in planes) {
const plane = planes[dir];
if (p.dot(plane.normal) > plane.distance) {
outDir = dir;
break;
}
}
return outDir;
}
constructor(center = [0, 0, 0], radius = 0.0) {
this.radius = -0;
this.center = new Vector3();
this.fromCenterRadius(center, radius);
}
constructor(normal = [0, 0, 1], distance = 0) {
this.normal = new Vector3();
this.distance = -0;
this.fromNormalDistance(normal, distance);
}
export function getClosestPointOnLine({ p, p1, p2, clampToLine = true }) {
const lineVector = new Vector3(p2).subtract(p1);
const pointVector = new Vector3(p).subtract(p1);
let dotProduct = lineVector.dot(pointVector);
if (clampToLine) {
dotProduct = clamp(dotProduct, 0, 1);
}
return lineVector.lerp(dotProduct);
}
export function getClosestPointOnLine({ p, p1, p2, clampToLine = true }) {
const lineVector = new Vector3(p2).subtract(p1);
const pointVector = new Vector3(p).subtract(p1);
let dotProduct = lineVector.dot(pointVector);
if (clampToLine) {
dotProduct = clamp(dotProduct, 0, 1);
}
return lineVector.lerp(dotProduct);
}