@gltf-transform/core
Advanced tools
Comparing version 4.0.0-alpha.6 to 4.0.0-alpha.7
@@ -81,3 +81,2 @@ import { Nullable, PropertyType, TypedArray } from '../constants.js'; | ||
protected getDefaults(): Nullable<IAccessor>; | ||
copy(other: this, resolve?: <T extends import("./property.js").Property<import("./property.js").IProperty>>(t: T) => T): this; | ||
/********************************************************************************************** | ||
@@ -84,0 +83,0 @@ * Static. |
{ | ||
"name": "@gltf-transform/core", | ||
"version": "4.0.0-alpha.6", | ||
"version": "4.0.0-alpha.7", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
@@ -54,3 +54,3 @@ "homepage": "https://gltf-transform.dev/", | ||
}, | ||
"gitHead": "b61933b39454b514f3f06a3d99cbaf10de675792" | ||
"gitHead": "ae33e33ea1ff07be469b019ec50b67361af7a478" | ||
} |
@@ -48,12 +48,6 @@ import { PlatformIO } from './platform-io.js'; | ||
protected async readURI(uri: string, type: 'view' | 'text'): Promise<Uint8Array | string> { | ||
// TODO(cleanup): The @ts-ignore rules below are necessary for typedoc, but not for normal | ||
// compilation with microbundle. Clean this up when possible. | ||
switch (type) { | ||
case 'view': | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return Deno.readFile(uri); | ||
case 'text': | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return Deno.readTextFile(uri); | ||
@@ -60,0 +54,0 @@ } |
@@ -6,3 +6,2 @@ import { Nullable, PropertyType, TypedArray } from '../constants.js'; | ||
import { ExtensibleProperty, IExtensibleProperty } from './extensible-property.js'; | ||
import { COPY_IDENTITY } from './property.js'; | ||
@@ -150,15 +149,2 @@ interface IAccessor extends IExtensibleProperty { | ||
/** @internal Inbound transform to normalized representation, if applicable. */ | ||
private _in = MathUtils.identity; | ||
/** @internal Outbound transform from normalized representation, if applicable. */ | ||
private _out = MathUtils.identity; | ||
public copy(other: this, resolve = COPY_IDENTITY): this { | ||
super.copy(other, resolve); | ||
this._in = other._in; | ||
this._out = other._out; | ||
return this; | ||
} | ||
/********************************************************************************************** | ||
@@ -220,7 +206,13 @@ * Static. | ||
public getMinNormalized(target: number[]): number[] { | ||
const normalized = this.getNormalized(); | ||
const elementSize = this.getElementSize(); | ||
const componentType = this.getComponentType(); | ||
this.getMin(target); | ||
for (let j = 0; j < elementSize; j++) target[j] = this._out(target[j]); | ||
if (normalized) { | ||
for (let j = 0; j < elementSize; j++) { | ||
target[j] = MathUtils.decodeNormalizedInt(target[j], componentType); | ||
} | ||
} | ||
@@ -235,3 +227,3 @@ return target; | ||
public getMin(target: number[]): number[] { | ||
const array = this.get('array'); | ||
const array = this.getArray()!; | ||
const count = this.getCount(); | ||
@@ -244,3 +236,3 @@ const elementSize = this.getElementSize(); | ||
for (let j = 0; j < elementSize; j++) { | ||
const value = array![i + j]; | ||
const value = array[i + j]; | ||
if (Number.isFinite(value)) { | ||
@@ -261,7 +253,13 @@ target[j] = Math.min(target[j], value); | ||
public getMaxNormalized(target: number[]): number[] { | ||
const normalized = this.getNormalized(); | ||
const elementSize = this.getElementSize(); | ||
const componentType = this.getComponentType(); | ||
this.getMax(target); | ||
for (let j = 0; j < elementSize; j++) target[j] = this._out(target[j]); | ||
if (normalized) { | ||
for (let j = 0; j < elementSize; j++) { | ||
target[j] = MathUtils.decodeNormalizedInt(target[j], componentType); | ||
} | ||
} | ||
@@ -366,13 +364,3 @@ return target; | ||
public setNormalized(normalized: boolean): this { | ||
this.set('normalized', normalized); | ||
if (normalized) { | ||
this._out = (i: number): number => MathUtils.decodeNormalizedInt(i, this.get('componentType')); | ||
this._in = (f: number): number => MathUtils.encodeNormalizedInt(f, this.get('componentType')); | ||
} else { | ||
this._out = MathUtils.identity; | ||
this._in = MathUtils.identity; | ||
} | ||
return this; | ||
return this.set('normalized', normalized); | ||
} | ||
@@ -390,3 +378,10 @@ | ||
const elementSize = this.getElementSize(); | ||
return this._out(this.get('array')![index * elementSize]); | ||
const componentType = this.getComponentType(); | ||
const array = this.getArray()!; | ||
if (this.getNormalized()) { | ||
return MathUtils.decodeNormalizedInt(array[index * elementSize], componentType); | ||
} | ||
return array[index * elementSize]; | ||
} | ||
@@ -399,3 +394,12 @@ | ||
public setScalar(index: number, x: number): this { | ||
this.get('array')![index * this.getElementSize()] = this._in(x); | ||
const elementSize = this.getElementSize(); | ||
const componentType = this.getComponentType(); | ||
const array = this.getArray()!; | ||
if (this.getNormalized()) { | ||
array[index * elementSize] = MathUtils.encodeNormalizedInt(x, componentType); | ||
} else { | ||
array[index * elementSize] = x; | ||
} | ||
return this; | ||
@@ -409,7 +413,15 @@ } | ||
public getElement(index: number, target: number[]): number[] { | ||
const normalized = this.getNormalized(); | ||
const elementSize = this.getElementSize(); | ||
const array = this.get('array')!; | ||
const componentType = this.getComponentType(); | ||
const array = this.getArray()!; | ||
for (let i = 0; i < elementSize; i++) { | ||
target[i] = this._out(array[index * elementSize + i]); | ||
if (normalized) { | ||
target[i] = MathUtils.decodeNormalizedInt(array[index * elementSize + i], componentType); | ||
} else { | ||
target[i] = array[index * elementSize + i]; | ||
} | ||
} | ||
return target; | ||
@@ -423,7 +435,15 @@ } | ||
public setElement(index: number, value: number[]): this { | ||
const normalized = this.getNormalized(); | ||
const elementSize = this.getElementSize(); | ||
const array = this.get('array')!; | ||
const componentType = this.getComponentType(); | ||
const array = this.getArray()!; | ||
for (let i = 0; i < elementSize; i++) { | ||
array![index * elementSize + i] = this._in(value[i]); | ||
if (normalized) { | ||
array[index * elementSize + i] = MathUtils.encodeNormalizedInt(value[i], componentType); | ||
} else { | ||
array[index * elementSize + i] = value[i]; | ||
} | ||
} | ||
return this; | ||
@@ -430,0 +450,0 @@ } |
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
2218027
30807
22352