Socket
Socket
Sign inDemoInstall

@shapediver/viewer.shared.math

Package Overview
Dependencies
Maintainers
5
Versions
203
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 2.12.0 to 2.12.1

33

dist/implementation/Box.js

@@ -112,15 +112,30 @@ "use strict";

}
setFromAttributeArray(array, stride, bytes, matrix = gl_matrix_1.mat4.create()) {
let transformedArray = [];
setFromAttributeArray(array, stride, bytes, matrix) {
const length = (Math.floor(array.length / 3) * 3);
const byteStride = (stride && stride !== bytes) ? +stride : 3;
const min = [Infinity, Infinity, Infinity];
const max = [-Infinity, -Infinity, -Infinity];
let x, y, z;
const point = gl_matrix_1.vec4.create();
for (let i = 0; i < length; i += byteStride) {
let point = gl_matrix_1.vec4.transformMat4(gl_matrix_1.vec4.create(), gl_matrix_1.vec4.fromValues(array[i], array[i + 1], array[i + 2], 1), matrix);
transformedArray.push([point[0] / point[3], point[1] / point[3], point[2] / point[3]]);
if (matrix) {
gl_matrix_1.vec4.transformMat4(point, [array[i], array[i + 1], array[i + 2], 1], matrix);
x = point[0] / point[3];
y = point[1] / point[3];
z = point[2] / point[3];
}
else {
x = array[i];
y = array[i + 1];
z = array[i + 2];
}
min[0] = Math.min(min[0], x);
min[1] = Math.min(min[1], y);
min[2] = Math.min(min[2], z);
max[0] = Math.max(max[0], x);
max[1] = Math.max(max[1], y);
max[2] = Math.max(max[2], z);
}
let x_coords = transformedArray.map(p => p[0]);
let y_coords = transformedArray.map(p => p[1]);
let z_coords = transformedArray.map(p => p[2]);
this.min = gl_matrix_1.vec3.fromValues(Math.min(...x_coords), Math.min(...y_coords), Math.min(...z_coords));
this.max = gl_matrix_1.vec3.fromValues(Math.max(...x_coords), Math.max(...y_coords), Math.max(...z_coords));
this.min = gl_matrix_1.vec3.fromValues(min[0], min[1], min[2]);
this.max = gl_matrix_1.vec3.fromValues(max[0], max[1], max[2]);
return this;

@@ -127,0 +142,0 @@ }

{
"name": "@shapediver/viewer.shared.math",
"version": "2.12.0",
"version": "2.12.1",
"description": "",

@@ -42,6 +42,6 @@ "keywords": [],

"dependencies": {
"@shapediver/viewer.shared.services": "2.12.0",
"@shapediver/viewer.shared.services": "2.12.1",
"gl-matrix": "3.3.0"
},
"gitHead": "4453bb1d704facd5722ffd81518e54b5453d991f"
"gitHead": "31075d983f502a133848594f8eab91130f6aeae2"
}

@@ -136,17 +136,34 @@ import { mat4, vec3, vec4 } from 'gl-matrix'

public setFromAttributeArray(array: Int8Array | Uint8Array | Int16Array | Uint16Array | Uint32Array | Float32Array, stride?: number, bytes?: number, matrix: mat4 = mat4.create()): IBox {
let transformedArray = [];
public setFromAttributeArray(array: Int8Array | Uint8Array | Int16Array | Uint16Array | Uint32Array | Float32Array, stride?: number, bytes?: number, matrix?: mat4): IBox {
const length = (Math.floor(array.length / 3) * 3);
const byteStride = (stride && stride !== bytes) ? +stride : 3;
const min = [Infinity, Infinity, Infinity];
const max = [-Infinity, -Infinity, -Infinity];
let x, y, z;
const point = vec4.create();
for (let i = 0; i < length; i += byteStride) {
let point = vec4.transformMat4(vec4.create(), vec4.fromValues(array[i], array[i + 1], array[i + 2], 1), matrix);
transformedArray.push([point[0] / point[3], point[1] / point[3], point[2] / point[3]]);
if(matrix) {
vec4.transformMat4(point, [array[i], array[i + 1], array[i + 2], 1], matrix);
x = point[0] / point[3];
y = point[1] / point[3];
z = point[2] / point[3];
} else {
x = array[i];
y = array[i + 1];
z = array[i + 2];
}
min[0] = Math.min(min[0], x);
min[1] = Math.min(min[1], y);
min[2] = Math.min(min[2], z);
max[0] = Math.max(max[0], x);
max[1] = Math.max(max[1], y);
max[2] = Math.max(max[2], z);
}
let x_coords = transformedArray.map(p => p[0]);
let y_coords = transformedArray.map(p => p[1]);
let z_coords = transformedArray.map(p => p[2]);
this.min = vec3.fromValues(Math.min(...x_coords), Math.min(...y_coords), Math.min(...z_coords));
this.max = vec3.fromValues(Math.max(...x_coords), Math.max(...y_coords), Math.max(...z_coords));
this.min = vec3.fromValues(min[0], min[1], min[2]);
this.max = vec3.fromValues(max[0], max[1], max[2]);

@@ -153,0 +170,0 @@ return this;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc