@gltf-transform/extensions
Advanced tools
Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.3
@@ -7,4 +7,2 @@ import { Extension, PropertyType, ReaderContext, WriterContext } from '@gltf-transform/core'; | ||
* | ||
* [[include:_VENDOR_EXTENSIONS.md]] | ||
* | ||
* GPU instancing allows engines to render many copies of a single mesh at once using a small number | ||
@@ -11,0 +9,0 @@ * of draw calls. Instancing is particularly useful for things like trees, grass, road signs, etc. |
@@ -15,5 +15,9 @@ import type { GLTF, TypedArray } from '@gltf-transform/core'; | ||
export declare enum MeshoptFilter { | ||
/** No filter — quantize only. */ | ||
NONE = "NONE", | ||
/** Four 8- or 16-bit normalized values. */ | ||
OCTAHEDRAL = "OCTAHEDRAL", | ||
/** Four 16-bit normalized values. */ | ||
QUATERNION = "QUATERNION", | ||
/** K single-precision floating point values. */ | ||
EXPONENTIAL = "EXPONENTIAL" | ||
@@ -20,0 +24,0 @@ } |
@@ -10,4 +10,2 @@ import { Extension, PropertyType, ReaderContext, WriterContext } from '@gltf-transform/core'; | ||
* | ||
* [[include:_VENDOR_EXTENSIONS.md]] | ||
* | ||
* Meshopt compression (based on the [meshoptimizer](https://github.com/zeux/meshoptimizer) | ||
@@ -14,0 +12,0 @@ * library) offers a lightweight decoder with very fast runtime decompression, and is |
@@ -6,4 +6,2 @@ import { Extension, PropertyType, ReaderContext, WriterContext } from '@gltf-transform/core'; | ||
* | ||
* [[include:_VENDOR_EXTENSIONS.md]] | ||
* | ||
* AVIF offers greatly reduced transmission size, but | ||
@@ -10,0 +8,0 @@ * [requires browser support](https://caniuse.com/avif). Like PNG and JPEG, an AVIF image is |
@@ -6,4 +6,2 @@ import { Extension, PropertyType, ReaderContext, WriterContext } from '@gltf-transform/core'; | ||
* | ||
* [[include:_VENDOR_EXTENSIONS.md]] | ||
* | ||
* WebP offers greatly reduced transmission size, but | ||
@@ -10,0 +8,0 @@ * [requires browser support](https://caniuse.com/webp). Like PNG and JPEG, a WebP image is |
@@ -36,6 +36,2 @@ import { ExtensionProperty, IProperty, Nullable, PropertyType, vec3 } from '@gltf-transform/core'; | ||
setColor(color: vec3): this; | ||
/** Light color; sRGB hexadecimal color. */ | ||
getColorHex(): number; | ||
/** Light color; sRGB hexadecimal color. */ | ||
setColorHex(hex: number): this; | ||
/********************************************************************************************** | ||
@@ -80,3 +76,3 @@ * INTENSITY. | ||
/** | ||
* Angle, in radians, from centre of spotlight where falloff begins. Must be ≥ 0 and | ||
* Angle, in radians, from centre of spotlight where falloff begins. Must be >= 0 and | ||
* < outerConeAngle. | ||
@@ -86,3 +82,3 @@ */ | ||
/** | ||
* Angle, in radians, from centre of spotlight where falloff begins. Must be ≥ 0 and | ||
* Angle, in radians, from centre of spotlight where falloff begins. Must be >= 0 and | ||
* < outerConeAngle. | ||
@@ -93,3 +89,3 @@ */ | ||
* Angle, in radians, from centre of spotlight where falloff ends. Must be > innerConeAngle and | ||
* ≤ PI / 2.0. | ||
* <= PI / 2.0. | ||
*/ | ||
@@ -99,3 +95,3 @@ getOuterConeAngle(): number; | ||
* Angle, in radians, from centre of spotlight where falloff ends. Must be > innerConeAngle and | ||
* ≤ PI / 2.0. | ||
* <= PI / 2.0. | ||
*/ | ||
@@ -102,0 +98,0 @@ setOuterConeAngle(angle: number): this; |
@@ -12,4 +12,2 @@ import { ExtensionProperty, IProperty, Nullable, PropertyType, Texture, TextureInfo } from '@gltf-transform/core'; | ||
* {@link KHRMaterialsAnisotropy}. | ||
* | ||
* [[include:_UNRATIFIED_EXTENSIONS.md]] | ||
*/ | ||
@@ -16,0 +14,0 @@ export declare class Anisotropy extends ExtensionProperty<IAnisotropy> { |
@@ -7,4 +7,2 @@ import { Extension, ReaderContext, WriterContext } from '@gltf-transform/core'; | ||
* | ||
* [[include:_UNRATIFIED_EXTENSIONS.md]] | ||
* | ||
* This extension defines the anisotropic property of a material as observable with brushed metals | ||
@@ -11,0 +9,0 @@ * for instance. An asymmetric specular lobe model is introduced to allow for such phenomena. The |
@@ -29,6 +29,2 @@ import { ExtensionProperty, IProperty, Nullable, PropertyType, Texture, TextureInfo, vec3, vec4 } from '@gltf-transform/core'; | ||
setDiffuseFactor(factor: vec4): this; | ||
/** Diffuse; sRGB hexadecimal color. */ | ||
getDiffuseHex(): number; | ||
/** Diffuse; sRGB hexadecimal color. */ | ||
setDiffuseHex(hex: number): this; | ||
/** | ||
@@ -35,0 +31,0 @@ * Diffuse texture; sRGB. Alternative to baseColorTexture, used within the |
@@ -26,8 +26,4 @@ import { ExtensionProperty, IProperty, Nullable, PropertyType, Texture, TextureInfo, vec3 } from '@gltf-transform/core'; | ||
getSheenColorFactor(): vec3; | ||
/** Sheen; hex color in sRGB colorspace. */ | ||
getSheenColorHex(): number; | ||
/** Sheen; linear multiplier. */ | ||
setSheenColorFactor(factor: vec3): this; | ||
/** Sheen; hex color in sRGB colorspace. */ | ||
setSheenColorHex(hex: number): this; | ||
/** | ||
@@ -34,0 +30,0 @@ * Sheen color texture, in sRGB colorspace. |
@@ -32,6 +32,2 @@ import { ExtensionProperty, IProperty, Nullable, PropertyType, Texture, TextureInfo, vec3 } from '@gltf-transform/core'; | ||
setSpecularColorFactor(factor: vec3): this; | ||
/** Specular color; sRGB hexadecimal color. See {@link Specular.getSpecularTexture getSpecularTexture} */ | ||
getSpecularColorHex(): number; | ||
/** Specular color; sRGB hexadecimal color. See {@link Specular.getSpecularTexture getSpecularTexture} */ | ||
setSpecularColorHex(hex: number): this; | ||
/** | ||
@@ -38,0 +34,0 @@ * Specular texture; linear multiplier. Configures the strength of the specular reflection in |
@@ -46,3 +46,3 @@ import { Extension, ReaderContext, WriterContext } from '@gltf-transform/core'; | ||
* .setAttenuationDistance(1.0) | ||
* .setAttenuationColorHex(0xFFEEEE); | ||
* .setAttenuationColorFactor([1, 0.5, 0.5]); | ||
* | ||
@@ -49,0 +49,0 @@ * // Attach the property to a Material. |
@@ -73,13 +73,3 @@ import { ExtensionProperty, IProperty, Nullable, PropertyType, Texture, TextureInfo, vec3 } from '@gltf-transform/core'; | ||
setAttenuationColor(color: vec3): this; | ||
/** | ||
* Color (sRGB) that white light turns into due to absorption when reaching the attenuation | ||
* distance. | ||
*/ | ||
getAttenuationColorHex(): number; | ||
/** | ||
* Color (sRGB) that white light turns into due to absorption when reaching the attenuation | ||
* distance. | ||
*/ | ||
setAttenuationColorHex(hex: number): this; | ||
} | ||
export {}; |
@@ -37,6 +37,6 @@ import { Extension, PropertyType, ReaderContext, WriterContext } from '@gltf-transform/core'; | ||
* compress the image data first, then pass the `.ktx2` payload to {@link Texture.setImage}. The | ||
* glTF-Transform CLI has functions to help with this, or any similar KTX2-capable | ||
* glTF Transform CLI has functions to help with this, or any similar KTX2-capable | ||
* utility will work. | ||
* | ||
* When the `KHR_texture_basisu` extension is added to a file by glTF-Transform, the extension | ||
* When the `KHR_texture_basisu` extension is added to a file by glTF Transform, the extension | ||
* should always be required. This tool does not support writing assets that "fall back" to optional | ||
@@ -43,0 +43,0 @@ * PNG or JPEG image data. |
{ | ||
"name": "@gltf-transform/extensions", | ||
"version": "4.0.0-alpha.1", | ||
"version": "4.0.0-alpha.3", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
"homepage": "https://gltf-transform.donmccurdy.com/extensions.html", | ||
"homepage": "https://gltf-transform.dev/extensions.html", | ||
"description": "Adds extension support to @gltf-transform/core", | ||
"author": "Don McCurdy <dm@donmccurdy.com>", | ||
"license": "MIT", | ||
"funding": "https://github.com/sponsors/donmccurdy", | ||
"type": "module", | ||
"sideEffects": false, | ||
"exports": { | ||
"types": "./dist/extensions.d.ts", | ||
"require": "./dist/extensions.cjs", | ||
"default": "./dist/extensions.modern.js" | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/index.cjs", | ||
"default": "./dist/index.modern.js" | ||
}, | ||
"types": "./dist/extensions.d.ts", | ||
"main": "./dist/extensions.cjs", | ||
"module": "./dist/extensions.modern.js", | ||
"source": "./src/extensions.ts", | ||
"types": "./dist/index.d.ts", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.modern.js", | ||
"source": "./src/index.ts", | ||
"browserslist": [ | ||
@@ -26,5 +27,4 @@ "defaults", | ||
"scripts": { | ||
"dist": "microbundle --format modern,cjs", | ||
"watch": "microbundle watch --format modern,cjs", | ||
"watch:debug": "microbundle watch --format modern,cjs --no-compress" | ||
"dist": "microbundle --format modern,cjs --no-compress", | ||
"watch": "microbundle watch --format modern,cjs --no-compress" | ||
}, | ||
@@ -39,4 +39,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@gltf-transform/core": "^4.0.0-alpha.1", | ||
"ktx-parse": "^0.5.0" | ||
"@gltf-transform/core": "^4.0.0-alpha.3", | ||
"ktx-parse": "^0.6.0" | ||
}, | ||
@@ -49,3 +49,3 @@ "files": [ | ||
], | ||
"gitHead": "fb71aa67ca90f719b2d8d2d8fc759c49d5f9aa45" | ||
"gitHead": "f4c8a697fb8301f721edc4fb57aea30a42db1f77" | ||
} |
@@ -7,14 +7,36 @@ # @gltf-transform/extensions | ||
Part of the glTF-Transform project. | ||
Part of the glTF Transform project. | ||
- GitHub: https://github.com/donmccurdy/glTF-Transform | ||
- Project Documentation: https://gltf-transform.donmccurdy.com/ | ||
- Package Documentation: https://gltf-transform.donmccurdy.com/extensions | ||
- Project Documentation: https://gltf-transform.dev/ | ||
- Package Documentation: https://gltf-transform.dev/extensions | ||
## Credits | ||
See [*Credits*](https://gltf-transform.donmccurdy.com/credits). | ||
See [*Credits*](https://gltf-transform.dev/credits). | ||
<h2>Commercial Use</h2> | ||
<p> | ||
<b>Using glTF Transform for a personal project?</b> That's great! Sponsorship is neither expected nor required. Feel | ||
free to share screenshots if you've made something you're excited about — I enjoy seeing those! | ||
</p> | ||
<p> | ||
<b>Using glTF Transform in for-profit work?</b> That's wonderful! Your support is important to keep glTF Transform | ||
maintained, independent, and open source under MIT License. Please consider a | ||
<a href="https://gltf-transform.dev/pro" target="_blank">subscription</a> | ||
or | ||
<a href="https://github.com/sponsors/donmccurdy" target="_blank">GitHub sponsorship</a>. | ||
</p> | ||
<p> | ||
<i> | ||
Learn more in the | ||
<a href="https://gltf-transform.dev/pro" target="_blank"> glTF Transform Pro </a> FAQs</i | ||
>. | ||
</p> | ||
## License | ||
Copyright 2023, MIT License. |
@@ -17,4 +17,2 @@ import { Extension, PropertyType, ReaderContext, WriterContext } from '@gltf-transform/core'; | ||
* | ||
* [[include:_VENDOR_EXTENSIONS.md]] | ||
* | ||
* GPU instancing allows engines to render many copies of a single mesh at once using a small number | ||
@@ -21,0 +19,0 @@ * of draw calls. Instancing is particularly useful for things like trees, grass, road signs, etc. |
@@ -19,5 +19,9 @@ import type { GLTF, TypedArray } from '@gltf-transform/core'; | ||
export enum MeshoptFilter { | ||
/** No filter — quantize only. */ | ||
NONE = 'NONE', | ||
/** Four 8- or 16-bit normalized values. */ | ||
OCTAHEDRAL = 'OCTAHEDRAL', | ||
/** Four 16-bit normalized values. */ | ||
QUATERNION = 'QUATERNION', | ||
/** K single-precision floating point values. */ | ||
EXPONENTIAL = 'EXPONENTIAL', | ||
@@ -24,0 +28,0 @@ } |
@@ -11,2 +11,3 @@ import { PreparedAccessor, MeshoptFilter, MeshoptMode } from './constants.js'; | ||
Primitive, | ||
PropertyType, | ||
Root, | ||
@@ -27,3 +28,3 @@ TypedArray, | ||
mode: MeshoptMode, | ||
filterOptions: { filter: MeshoptFilter; bits?: number } | ||
filterOptions: { filter: MeshoptFilter; bits?: number }, | ||
): PreparedAccessor { | ||
@@ -41,3 +42,3 @@ const { filter, bits } = filterOptions as { filter: MeshoptFilter; bits: number }; | ||
if (filter !== MeshoptFilter.NONE) { | ||
let array = accessor.getNormalized() ? denormalizeArray(accessor) : new Float32Array(result.array); | ||
let array = accessor.getNormalized() ? decodeNormalizedIntArray(accessor) : new Float32Array(result.array); | ||
@@ -89,3 +90,3 @@ switch (filter) { | ||
function denormalizeArray(attribute: Accessor): Float32Array { | ||
function decodeNormalizedIntArray(attribute: Accessor): Float32Array { | ||
const componentType = attribute.getComponentType(); | ||
@@ -148,2 +149,3 @@ const srcArray = attribute.getArray()!; | ||
const refKey = (ref.getAttributes().key || '') as string; | ||
const isDelta = ref.getParent().propertyType === PropertyType.PRIMITIVE_TARGET; | ||
@@ -161,9 +163,13 @@ // Indices. | ||
// quantization for these attributes. | ||
// - NORMAL and TANGENT attributes use Octahedral filters, but deltas in morphs do not. | ||
// - When specifying bit depth for vertex attributes, check the defaults in `quantize.ts` | ||
// and overrides in `meshopt.ts`. Don't store deltas at higher precision than base. | ||
if (refName === 'attributes') { | ||
if (refKey === 'POSITION') return { filter: MeshoptFilter.NONE }; | ||
if (refKey === 'TEXCOORD_0') return { filter: MeshoptFilter.NONE }; | ||
if (refKey === 'NORMAL') return { filter: MeshoptFilter.OCTAHEDRAL, bits: 8 }; | ||
if (refKey === 'TANGENT') return { filter: MeshoptFilter.OCTAHEDRAL, bits: 8 }; | ||
if (refKey.startsWith('JOINTS_')) return { filter: MeshoptFilter.NONE }; | ||
if (refKey.startsWith('WEIGHTS_')) return { filter: MeshoptFilter.NONE }; | ||
if (refKey === 'NORMAL' || refKey === 'TANGENT') { | ||
return isDelta ? { filter: MeshoptFilter.NONE } : { filter: MeshoptFilter.OCTAHEDRAL, bits: 8 }; | ||
} | ||
} | ||
@@ -170,0 +176,0 @@ |
@@ -35,4 +35,2 @@ import { | ||
* | ||
* [[include:_VENDOR_EXTENSIONS.md]] | ||
* | ||
* Meshopt compression (based on the [meshoptimizer](https://github.com/zeux/meshoptimizer) | ||
@@ -39,0 +37,0 @@ * library) offers a lightweight decoder with very fast runtime decompression, and is |
@@ -61,4 +61,2 @@ import { | ||
* | ||
* [[include:_VENDOR_EXTENSIONS.md]] | ||
* | ||
* AVIF offers greatly reduced transmission size, but | ||
@@ -65,0 +63,0 @@ * [requires browser support](https://caniuse.com/avif). Like PNG and JPEG, an AVIF image is |
@@ -36,3 +36,3 @@ import { | ||
view.getUint8(offset + 3), | ||
]) | ||
]), | ||
); | ||
@@ -67,4 +67,2 @@ const chunkByteLength = view.getUint32(offset + 4, true); | ||
* | ||
* [[include:_VENDOR_EXTENSIONS.md]] | ||
* | ||
* WebP offers greatly reduced transmission size, but | ||
@@ -71,0 +69,0 @@ * [requires browser support](https://caniuse.com/webp). Like PNG and JPEG, a WebP image is |
@@ -63,6 +63,7 @@ import { Accessor, bbox, GLTF, Primitive, TypedArray } from '@gltf-transform/core'; | ||
const encoder = new encoderModule.Encoder(); | ||
const builder = new encoderModule.MeshBuilder(); | ||
const mesh = new encoderModule.Mesh(); | ||
const encoder = new encoderModule.ExpertEncoder(mesh); | ||
const attributeIDs: { [key: string]: number } = {}; | ||
@@ -90,3 +91,3 @@ const dracoBuffer = new encoderModule.DracoInt8Array(); | ||
attribute.getElementSize(), | ||
attribute.getArray()! | ||
attribute.getArray()!, | ||
); | ||
@@ -98,3 +99,3 @@ | ||
if (options.quantizationVolume === 'mesh' || semantic !== 'POSITION') { | ||
encoder.SetAttributeQuantization(encoderModule[attributeEnum], options.quantizationBits[attributeEnum]); | ||
encoder.SetAttributeQuantization(attributeID, options.quantizationBits[attributeEnum]); | ||
} else if (typeof options.quantizationVolume === 'object') { | ||
@@ -105,10 +106,10 @@ const { quantizationVolume } = options; | ||
quantizationVolume.max[1] - quantizationVolume.min[1], | ||
quantizationVolume.max[2] - quantizationVolume.min[2] | ||
quantizationVolume.max[2] - quantizationVolume.min[2], | ||
); | ||
encoder.SetAttributeExplicitQuantization( | ||
encoderModule[attributeEnum], | ||
attributeID, | ||
options.quantizationBits[attributeEnum], | ||
attribute.getElementSize(), | ||
quantizationVolume.min, | ||
range | ||
range, | ||
); | ||
@@ -128,3 +129,4 @@ } else { | ||
// Preserve vertex order for primitives with morph targets. | ||
// TODO(cleanup): Use edgebreaker without deduplication if possible. | ||
// See https://github.com/google/draco/issues/929. | ||
if (options.method === EncoderMethod.SEQUENTIAL || hasMorphTargets || hasSparseAttributes) { | ||
@@ -136,3 +138,4 @@ encoder.SetEncodingMethod(encoderModule.MESH_SEQUENTIAL_ENCODING); | ||
const byteLength = encoder.EncodeMeshToDracoBuffer(mesh, dracoBuffer); | ||
// Encode, preserving vertex order for primitives with morph targets and sparse accessors. | ||
const byteLength = encoder.EncodeToDracoBuffer(!(hasMorphTargets || hasSparseAttributes), dracoBuffer); | ||
if (byteLength <= 0) throw new EncodingError('Error applying Draco compression.'); | ||
@@ -145,14 +148,5 @@ | ||
const prevNumVertices = prim.getAttribute('POSITION')!.getCount(); | ||
const numVertices = encoder.GetNumberOfEncodedPoints(); | ||
const numIndices = encoder.GetNumberOfEncodedFaces() * 3; | ||
if ((hasMorphTargets || hasSparseAttributes) && numVertices !== prevNumVertices) { | ||
throw new EncodingError( | ||
'Compression reduced vertex count unexpectedly, corrupting mesh data.' + | ||
' Applying the "weld" function before compression may resolve the issue.' + | ||
' See: https://github.com/google/draco/issues/929' | ||
); | ||
} | ||
encoderModule.destroy(dracoBuffer); | ||
@@ -186,3 +180,3 @@ encoderModule.destroy(mesh); | ||
itemSize: number, | ||
array: TypedArray | ||
array: TypedArray, | ||
): number { | ||
@@ -189,0 +183,0 @@ switch (componentType) { |
import { ExtensionProperty, IProperty, Nullable, PropertyType, vec3 } from '@gltf-transform/core'; | ||
import { ColorUtils } from '@gltf-transform/core'; | ||
import { KHR_LIGHTS_PUNCTUAL } from '../constants.js'; | ||
@@ -70,14 +69,2 @@ | ||
/** Light color; sRGB hexadecimal color. */ | ||
public getColorHex(): number { | ||
return ColorUtils.factorToHex(this.getColor()); | ||
} | ||
/** Light color; sRGB hexadecimal color. */ | ||
public setColorHex(hex: number): this { | ||
const color = this.getColor().slice() as vec3; | ||
ColorUtils.hexToFactor(hex, color); | ||
return this.setColor(color); | ||
} | ||
/********************************************************************************************** | ||
@@ -144,3 +131,3 @@ * INTENSITY. | ||
/** | ||
* Angle, in radians, from centre of spotlight where falloff begins. Must be ≥ 0 and | ||
* Angle, in radians, from centre of spotlight where falloff begins. Must be >= 0 and | ||
* < outerConeAngle. | ||
@@ -153,3 +140,3 @@ */ | ||
/** | ||
* Angle, in radians, from centre of spotlight where falloff begins. Must be ≥ 0 and | ||
* Angle, in radians, from centre of spotlight where falloff begins. Must be >= 0 and | ||
* < outerConeAngle. | ||
@@ -163,3 +150,3 @@ */ | ||
* Angle, in radians, from centre of spotlight where falloff ends. Must be > innerConeAngle and | ||
* ≤ PI / 2.0. | ||
* <= PI / 2.0. | ||
*/ | ||
@@ -172,3 +159,3 @@ public getOuterConeAngle(): number { | ||
* Angle, in radians, from centre of spotlight where falloff ends. Must be > innerConeAngle and | ||
* ≤ PI / 2.0. | ||
* <= PI / 2.0. | ||
*/ | ||
@@ -175,0 +162,0 @@ public setOuterConeAngle(angle: number): this { |
@@ -24,4 +24,2 @@ import { | ||
* {@link KHRMaterialsAnisotropy}. | ||
* | ||
* [[include:_UNRATIFIED_EXTENSIONS.md]] | ||
*/ | ||
@@ -28,0 +26,0 @@ export class Anisotropy extends ExtensionProperty<IAnisotropy> { |
@@ -17,4 +17,2 @@ import { Extension, GLTF, ReaderContext, WriterContext } from '@gltf-transform/core'; | ||
* | ||
* [[include:_UNRATIFIED_EXTENSIONS.md]] | ||
* | ||
* This extension defines the anisotropic property of a material as observable with brushed metals | ||
@@ -21,0 +19,0 @@ * for instance. An asymmetric specular lobe model is introduced to allow for such phenomena. The |
import { | ||
ColorUtils, | ||
ExtensionProperty, | ||
@@ -68,13 +67,2 @@ IProperty, | ||
/** Diffuse; sRGB hexadecimal color. */ | ||
public getDiffuseHex(): number { | ||
return ColorUtils.factorToHex(this.getDiffuseFactor()); | ||
} | ||
/** Diffuse; sRGB hexadecimal color. */ | ||
public setDiffuseHex(hex: number): this { | ||
const factor = this.getDiffuseFactor().slice() as vec4; | ||
return this.setDiffuseFactor(ColorUtils.hexToFactor(hex, factor)); | ||
} | ||
/** | ||
@@ -81,0 +69,0 @@ * Diffuse texture; sRGB. Alternative to baseColorTexture, used within the |
import { | ||
ColorUtils, | ||
ExtensionProperty, | ||
@@ -60,7 +59,2 @@ IProperty, | ||
/** Sheen; hex color in sRGB colorspace. */ | ||
public getSheenColorHex(): number { | ||
return ColorUtils.factorToHex(this.getSheenColorFactor()); | ||
} | ||
/** Sheen; linear multiplier. */ | ||
@@ -71,8 +65,2 @@ public setSheenColorFactor(factor: vec3): this { | ||
/** Sheen; hex color in sRGB colorspace. */ | ||
public setSheenColorHex(hex: number): this { | ||
const factor = this.getSheenColorFactor().slice() as vec3; | ||
return this.set('sheenColorFactor', ColorUtils.hexToFactor(hex, factor)); | ||
} | ||
/** | ||
@@ -79,0 +67,0 @@ * Sheen color texture, in sRGB colorspace. |
import { | ||
ColorUtils, | ||
ExtensionProperty, | ||
@@ -75,13 +74,2 @@ IProperty, | ||
/** Specular color; sRGB hexadecimal color. See {@link Specular.getSpecularTexture getSpecularTexture} */ | ||
public getSpecularColorHex(): number { | ||
return ColorUtils.factorToHex(this.getSpecularColorFactor()); | ||
} | ||
/** Specular color; sRGB hexadecimal color. See {@link Specular.getSpecularTexture getSpecularTexture} */ | ||
public setSpecularColorHex(hex: number): this { | ||
const factor = this.getSpecularColorFactor().slice() as vec3; | ||
return this.set('specularColorFactor', ColorUtils.hexToFactor(hex, factor)); | ||
} | ||
/** | ||
@@ -88,0 +76,0 @@ * Specular texture; linear multiplier. Configures the strength of the specular reflection in |
@@ -57,3 +57,3 @@ import { Extension, GLTF, ReaderContext, WriterContext, vec3, MathUtils } from '@gltf-transform/core'; | ||
* .setAttenuationDistance(1.0) | ||
* .setAttenuationColorHex(0xFFEEEE); | ||
* .setAttenuationColorFactor([1, 0.5, 0.5]); | ||
* | ||
@@ -60,0 +60,0 @@ * // Attach the property to a Material. |
import { | ||
ColorUtils, | ||
ExtensionProperty, | ||
@@ -130,19 +129,2 @@ IProperty, | ||
} | ||
/** | ||
* Color (sRGB) that white light turns into due to absorption when reaching the attenuation | ||
* distance. | ||
*/ | ||
public getAttenuationColorHex(): number { | ||
return ColorUtils.factorToHex(this.getAttenuationColor()); | ||
} | ||
/** | ||
* Color (sRGB) that white light turns into due to absorption when reaching the attenuation | ||
* distance. | ||
*/ | ||
public setAttenuationColorHex(hex: number): this { | ||
const factor = this.getAttenuationColor().slice() as vec3; | ||
return this.set('attenuationColor', ColorUtils.hexToFactor(hex, factor)); | ||
} | ||
} |
@@ -108,6 +108,6 @@ import { read as readKTX, KHR_DF_MODEL_ETC1S, KHR_DF_MODEL_UASTC } from 'ktx-parse'; | ||
* compress the image data first, then pass the `.ktx2` payload to {@link Texture.setImage}. The | ||
* glTF-Transform CLI has functions to help with this, or any similar KTX2-capable | ||
* glTF Transform CLI has functions to help with this, or any similar KTX2-capable | ||
* utility will work. | ||
* | ||
* When the `KHR_texture_basisu` extension is added to a file by glTF-Transform, the extension | ||
* When the `KHR_texture_basisu` extension is added to a file by glTF Transform, the extension | ||
* should always be required. This tool does not support writing assets that "fall back" to optional | ||
@@ -114,0 +114,0 @@ * PNG or JPEG image data. |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1621155
21759
1
42
1
+ Addedktx-parse@0.6.0(transitive)
- Removedktx-parse@0.5.0(transitive)
Updatedktx-parse@^0.6.0