@gltf-transform/core
Advanced tools
Comparing version 3.7.5 to 3.8.0
@@ -7,5 +7,5 @@ import type { mat4, vec3, vec4 } from '../constants.js'; | ||
static eq(a: number[], b: number[], tolerance?: number): boolean; | ||
static decodeNormalizedInt(c: number, componentType: GLTF.AccessorComponentType): number; | ||
static decodeNormalizedInt(i: number, componentType: GLTF.AccessorComponentType): number; | ||
/** @deprecated Renamed to {@link MathUtils.decodeNormalizedInt}. */ | ||
static denormalize(c: number, componentType: GLTF.AccessorComponentType): number; | ||
static denormalize(i: number, componentType: GLTF.AccessorComponentType): number; | ||
static encodeNormalizedInt(f: number, componentType: GLTF.AccessorComponentType): number; | ||
@@ -12,0 +12,0 @@ /** @deprecated Renamed to {@link MathUtils.encodeNormalizedInt}. */ |
{ | ||
"name": "@gltf-transform/core", | ||
"version": "3.7.5", | ||
"version": "3.8.0", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
@@ -55,3 +55,3 @@ "homepage": "https://gltf-transform.dev/", | ||
}, | ||
"gitHead": "bf05150bcaa3df7add9c86ba8ffaffae3fdd94a7" | ||
"gitHead": "94ea01f4c998c85cb25d56a057f7326d36a81786" | ||
} |
@@ -363,3 +363,3 @@ import { Nullable, PropertyType, TypedArray } from '../constants.js'; | ||
if (normalized) { | ||
this._out = (c: number): number => MathUtils.decodeNormalizedInt(c, this.get('componentType')); | ||
this._out = (i: number): number => MathUtils.decodeNormalizedInt(i, this.get('componentType')); | ||
this._in = (f: number): number => MathUtils.encodeNormalizedInt(f, this.get('componentType')); | ||
@@ -366,0 +366,0 @@ } else { |
@@ -22,15 +22,16 @@ import { determinant, getRotation } from 'gl-matrix/mat4'; | ||
public static decodeNormalizedInt(c: number, componentType: GLTF.AccessorComponentType): number { | ||
// TODO(v4): Compare performance if we replace the switch with individual functions. | ||
public static decodeNormalizedInt(i: number, componentType: GLTF.AccessorComponentType): number { | ||
// Hardcode enums from accessor.ts to avoid a circular dependency. | ||
switch (componentType) { | ||
case 5126: | ||
return c; | ||
case 5123: | ||
return c / 65535.0; | ||
case 5121: | ||
return c / 255.0; | ||
case 5122: | ||
return Math.max(c / 32767.0, -1.0); | ||
case 5120: | ||
return Math.max(c / 127.0, -1.0); | ||
case 5126: // FLOAT | ||
return i; | ||
case 5123: // UNSIGNED_SHORT | ||
return i / 65535.0; | ||
case 5121: // UNSIGNED_BYTE | ||
return i / 255.0; | ||
case 5122: // SHORT | ||
return Math.max(i / 32767.0, -1.0); | ||
case 5120: // BYTE | ||
return Math.max(i / 127.0, -1.0); | ||
default: | ||
@@ -42,18 +43,20 @@ throw new Error('Invalid component type.'); | ||
/** @deprecated Renamed to {@link MathUtils.decodeNormalizedInt}. */ | ||
public static denormalize(c: number, componentType: GLTF.AccessorComponentType): number { | ||
return MathUtils.decodeNormalizedInt(c, componentType); | ||
public static denormalize(i: number, componentType: GLTF.AccessorComponentType): number { | ||
return MathUtils.decodeNormalizedInt(i, componentType); | ||
} | ||
// TODO(v4): Compare performance if we replace the switch with individual functions. | ||
// TODO(v4): Consider clamping to [0, 1] or [-1, 1] here. | ||
public static encodeNormalizedInt(f: number, componentType: GLTF.AccessorComponentType): number { | ||
// Hardcode enums from accessor.ts to avoid a circular dependency. | ||
switch (componentType) { | ||
case 5126: | ||
case 5126: // FLOAT | ||
return f; | ||
case 5123: | ||
case 5123: // UNSIGNED_SHORT | ||
return Math.round(f * 65535.0); | ||
case 5121: | ||
case 5121: // UNSIGNED_BYTE | ||
return Math.round(f * 255.0); | ||
case 5122: | ||
case 5122: // SHORT | ||
return Math.round(f * 32767.0); | ||
case 5120: | ||
case 5120: // BYTE | ||
return Math.round(f * 127.0); | ||
@@ -60,0 +63,0 @@ default: |
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 too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1523519
11790