🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@shapediver/viewer.shared.math

Package Overview
Dependencies
Maintainers
5
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shapediver/viewer.shared.math - npm Package Compare versions

Comparing version

to
3.9.1

6

dist/implementation/Box.d.ts

@@ -1,4 +0,4 @@

import { mat4, vec3 } from 'gl-matrix';
import { IBox } from '../interfaces/IBox';
import { ISphere } from '../interfaces/ISphere';
import { mat4, vec3 } from "gl-matrix";
import { IBox } from "../interfaces/IBox";
import { ISphere } from "../interfaces/ISphere";
export declare class Box implements IBox {

@@ -5,0 +5,0 @@ private _min;

@@ -15,3 +15,4 @@ "use strict";

this._boundingSphereState = {
min: gl_matrix_1.vec3.create(), max: gl_matrix_1.vec3.create()
min: gl_matrix_1.vec3.create(),
max: gl_matrix_1.vec3.create(),
};

@@ -24,9 +25,21 @@ }

const invdirx = 1 / direction[0], invdiry = 1 / direction[1], invdirz = 1 / direction[2];
txmin = invdirx >= 0 ? (this.min[0] - origin[0]) * invdirx : (this.max[0] - origin[0]) * invdirx;
txmax = invdirx >= 0 ? (this.max[0] - origin[0]) * invdirx : (this.min[0] - origin[0]) * invdirx;
txmin =
invdirx >= 0
? (this.min[0] - origin[0]) * invdirx
: (this.max[0] - origin[0]) * invdirx;
txmax =
invdirx >= 0
? (this.max[0] - origin[0]) * invdirx
: (this.min[0] - origin[0]) * invdirx;
tmin = txmin;
tmax = txmax;
tymin = invdiry >= 0 ? (this.min[1] - origin[1]) * invdiry : (this.max[1] - origin[1]) * invdiry;
tymax = invdiry >= 0 ? (this.max[1] - origin[1]) * invdiry : (this.min[1] - origin[1]) * invdiry;
if ((tmin > tymax) || (tymin > tmax))
tymin =
invdiry >= 0
? (this.min[1] - origin[1]) * invdiry
: (this.max[1] - origin[1]) * invdiry;
tymax =
invdiry >= 0
? (this.max[1] - origin[1]) * invdiry
: (this.min[1] - origin[1]) * invdiry;
if (tmin > tymax || tymin > tmax)
return null;

@@ -39,5 +52,11 @@ // These lines also handle the case where tmin or tmax is NaN

tmax = tymax;
tzmin = invdirz >= 0 ? (this.min[2] - origin[2]) * invdirz : (this.max[2] - origin[2]) * invdirz;
tzmax = invdirz >= 0 ? (this.max[2] - origin[2]) * invdirz : (this.min[2] - origin[2]) * invdirz;
if ((tmin > tzmax) || (tzmin > tmax))
tzmin =
invdirz >= 0
? (this.min[2] - origin[2]) * invdirz
: (this.max[2] - origin[2]) * invdirz;
tzmax =
invdirz >= 0
? (this.max[2] - origin[2]) * invdirz
: (this.min[2] - origin[2]) * invdirz;
if (tmin > tzmax || tzmin > tmax)
return null;

@@ -53,14 +72,16 @@ if (tzmin > tmin || tmin !== tmin)

}
;
intersects(origin, direction) {
return this.intersect(origin, direction) === null ? false : true;
}
;
get boundingSphere() {
if (!(this._boundingSphereState.min[0] === this.min[0] && this._boundingSphereState.min[1] === this.min[1] && this._boundingSphereState.min[2] === this.min[2] &&
this._boundingSphereState.max[0] === this.max[0] && this._boundingSphereState.max[1] === this.max[1] && this._boundingSphereState.max[2] === this.max[2])) {
if (!(this._boundingSphereState.min[0] === this.min[0] &&
this._boundingSphereState.min[1] === this.min[1] &&
this._boundingSphereState.min[2] === this.min[2] &&
this._boundingSphereState.max[0] === this.max[0] &&
this._boundingSphereState.max[1] === this.max[1] &&
this._boundingSphereState.max[2] === this.max[2])) {
this._boundingSphere.setFromBox(this);
this._boundingSphereState = {
min: gl_matrix_1.vec3.clone(this.min),
max: gl_matrix_1.vec3.clone(this.max)
max: gl_matrix_1.vec3.clone(this.max),
};

@@ -106,5 +127,10 @@ }

containsPoint(point) {
return point[0] < this.min[0] || point[0] > this.max[0] ||
point[1] < this.min[1] || point[1] > this.max[1] ||
point[2] < this.min[2] || point[2] > this.max[2] ? false : true;
return point[0] < this.min[0] ||
point[0] > this.max[0] ||
point[1] < this.min[1] ||
point[1] > this.max[1] ||
point[2] < this.min[2] ||
point[2] > this.max[2]
? false
: true;
}

@@ -118,4 +144,4 @@ clampPoint(point) {

setFromAttributeArray(array, stride, bytes, matrix) {
const length = (Math.floor(array.length / 3) * 3);
const byteStride = (stride && stride !== bytes) ? +stride : 3;
const length = Math.floor(array.length / 3) * 3;
const byteStride = stride && stride !== bytes ? +stride : 3;
const min = [Infinity, Infinity, Infinity];

@@ -164,4 +190,8 @@ const max = [-Infinity, -Infinity, -Infinity];

isEmpty() {
return this.min[0] === Infinity && this.min[1] === Infinity && this.min[2] === Infinity &&
this.max[0] === -Infinity && this.max[1] === -Infinity && this.max[2] === -Infinity;
return (this.min[0] === Infinity &&
this.min[1] === Infinity &&
this.min[2] === Infinity &&
this.max[0] === -Infinity &&
this.max[1] === -Infinity &&
this.max[2] === -Infinity);
}

@@ -168,0 +198,0 @@ reset() {

@@ -1,3 +0,3 @@

import { IPlane } from '../interfaces/IPlane';
import { mat4, vec3 } from 'gl-matrix';
import { mat4, vec3 } from "gl-matrix";
import { IPlane } from "../interfaces/IPlane";
export declare class Plane implements IPlane {

@@ -4,0 +4,0 @@ private _normal;

@@ -1,4 +0,4 @@

import { mat4, vec3 } from 'gl-matrix';
import { IBox } from '../interfaces/IBox';
import { ISphere } from '../interfaces/ISphere';
import { mat4, vec3 } from "gl-matrix";
import { IBox } from "../interfaces/IBox";
import { ISphere } from "../interfaces/ISphere";
export declare class Sphere implements ISphere {

@@ -5,0 +5,0 @@ private _center;

@@ -29,5 +29,11 @@ "use strict";

this._center = gl_matrix_1.vec3.transformMat4(gl_matrix_1.vec3.create(), this._center, matrix);
const scaleXSq = matrix[0] * matrix[0] + matrix[1] * matrix[1] + matrix[2] * matrix[2];
const scaleYSq = matrix[4] * matrix[4] + matrix[5] * matrix[5] + matrix[6] * matrix[6];
const scaleZSq = matrix[8] * matrix[8] + matrix[9] * matrix[9] + matrix[10] * matrix[10];
const scaleXSq = matrix[0] * matrix[0] +
matrix[1] * matrix[1] +
matrix[2] * matrix[2];
const scaleYSq = matrix[4] * matrix[4] +
matrix[5] * matrix[5] +
matrix[6] * matrix[6];
const scaleZSq = matrix[8] * matrix[8] +
matrix[9] * matrix[9] +
matrix[10] * matrix[10];
const maxScaleOnAxis = Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));

@@ -41,3 +47,4 @@ this.radius = this.radius * maxScaleOnAxis;

containsPoint(point) {
return (gl_matrix_1.vec3.squaredDistance(point, this.center) <= (this.radius * this.radius));
return (gl_matrix_1.vec3.squaredDistance(point, this.center) <=
this.radius * this.radius);
}

@@ -44,0 +51,0 @@ clampPoint(point) {

@@ -1,3 +0,3 @@

import { vec3 } from 'gl-matrix';
import { ISpherical } from '../interfaces/ISpherical';
import { vec3 } from "gl-matrix";
import { ISpherical } from "../interfaces/ISpherical";
export declare class Spherical implements ISpherical {

@@ -4,0 +4,0 @@ private _radius;

@@ -1,3 +0,3 @@

import { mat4, vec3 } from 'gl-matrix';
import { ITriangle } from '../interfaces/ITriangle';
import { mat4, vec3 } from "gl-matrix";
import { ITriangle } from "../interfaces/ITriangle";
export declare class Triangle implements ITriangle {

@@ -4,0 +4,0 @@ private _v0;

@@ -40,3 +40,5 @@ "use strict";

const t = f * gl_matrix_1.vec3.dot(edge2, q);
return t > EPSILON ? gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), direction, gl_matrix_1.vec3.fromValues(t, t, t)), origin) : null;
return t > EPSILON
? gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), direction, gl_matrix_1.vec3.fromValues(t, t, t)), origin)
: null;
}

@@ -43,0 +45,0 @@ reset() {

@@ -1,13 +0,13 @@

import { Box } from './implementation/Box';
import { Plane } from './implementation/Plane';
import { Sphere } from './implementation/Sphere';
import { Spherical } from './implementation/Spherical';
import { Triangle } from './implementation/Triangle';
import { IBox } from './interfaces/IBox';
import { IGeometry } from './interfaces/IGeometry';
import { IPlane } from './interfaces/IPlane';
import { ISphere } from './interfaces/ISphere';
import { ISpherical } from './interfaces/ISpherical';
import { ITriangle } from './interfaces/ITriangle';
export { IBox, ISphere, ISpherical, IPlane, ITriangle, IGeometry, Box, Sphere, Spherical, Plane, Triangle };
import { Box } from "./implementation/Box";
import { Plane } from "./implementation/Plane";
import { Sphere } from "./implementation/Sphere";
import { Spherical } from "./implementation/Spherical";
import { Triangle } from "./implementation/Triangle";
import { IBox } from "./interfaces/IBox";
import { IGeometry } from "./interfaces/IGeometry";
import { IPlane } from "./interfaces/IPlane";
import { ISphere } from "./interfaces/ISphere";
import { ISpherical } from "./interfaces/ISpherical";
import { ITriangle } from "./interfaces/ITriangle";
export { IBox, ISphere, ISpherical, IPlane, ITriangle, IGeometry, Box, Sphere, Spherical, Plane, Triangle, };
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import { mat4 } from 'gl-matrix';
import { mat4 } from "gl-matrix";
export interface IGeometry {

@@ -3,0 +3,0 @@ applyMatrix(matrix: mat4): IGeometry;

{
"name": "@shapediver/viewer.shared.math",
"version": "3.9.0",
"description": "",
"keywords": [],
"author": "Michael Oppitz <michael@shapediver.com>",
"license": "polyform-noncommercial-1.0.0",
"main": "dist/index.js",
"directories": {
"test": "__tests__"
},
"files": [
"package.json",
"dist/",
"README.md",
"LICENSE"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/shapediver/Viewer.git"
},
"scripts": {
"check": "tsc --noEmit",
"build": "bash ../../scripts/building/build.sh",
"build-watch": "bash ../../scripts/building/build-watch.sh",
"build-dep": "bash ../../scripts/building/build-dep.sh"
},
"bugs": {
"url": "https://github.com/shapediver/Viewer/issues"
},
"homepage": "https://github.com/shapediver/Viewer#readme",
"typings": "dist/index.d.ts",
"jest": {
"preset": "ts-jest",
"testEnvironment": "node"
},
"dependencies": {
"@shapediver/viewer.shared.services": "3.9.0",
"gl-matrix": "3.3.0"
},
"gitHead": "da9892981b62bf47cbae0605a8439dd1fc1dbc27"
"name": "@shapediver/viewer.shared.math",
"version": "3.9.1",
"description": "",
"keywords": [],
"author": "Michael Oppitz <michael@shapediver.com>",
"license": "polyform-noncommercial-1.0.0",
"main": "dist/index.js",
"directories": {
"test": "__tests__"
},
"files": [
"package.json",
"dist/",
"README.md",
"LICENSE"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/shapediver/Viewer.git"
},
"scripts": {
"check": "tsc --noEmit",
"build": "bash ../../scripts/building/build.sh",
"build-watch": "bash ../../scripts/building/build-watch.sh",
"build-dep": "bash ../../scripts/building/build-dep.sh"
},
"bugs": {
"url": "https://github.com/shapediver/Viewer/issues"
},
"homepage": "https://github.com/shapediver/Viewer#readme",
"typings": "dist/index.d.ts",
"jest": {
"preset": "ts-jest",
"testEnvironment": "node"
},
"dependencies": {
"@shapediver/viewer.shared.services": "3.9.1",
"gl-matrix": "3.3.0"
},
"gitHead": "d1c3fab987b43a71529204c094035bf210a2e1d9"
}
# `@shapediver/viewer.shared.math`
This package is part of the [`@shapediver/viewer`](https://www.npmjs.com/package/@shapediver/viewer), you can find all information [here](https://viewer.shapediver.com/v3/latest/api/index.html).
This package is part of the [`@shapediver/viewer`](https://www.npmjs.com/package/@shapediver/viewer), you can find all information [here](https://viewer.shapediver.com/v3/latest/api/index.html).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet