Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ for (const neoConfig of neoStandardConfigs) {
// Add TypeScript type checking configs
if (Array.isArray(typeCheckingConfigs)) {
for (const tsConfig of typeCheckingConfigs) {
// @ts-expect-error untyped lib
config.push({
...tsConfig,
files: ['**/*.{ts,mts,cts,tsx}'],
ignores: [
...(tsConfig.ignores || []),
integratedExamplesPath
]
})
Expand Down
4 changes: 2 additions & 2 deletions examples/integrated/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.172.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.172.0/examples/jsm/",
"three": "https://unpkg.com/three@0.180.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.180.0/examples/jsm/",
"@monogrid/gainmap-js": "https://unpkg.com/@monogrid/gainmap-js/dist/decode.js"
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/integrated/ktx.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.172.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.172.0/examples/jsm/",
"three": "https://unpkg.com/three@0.180.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.180.0/examples/jsm/",
"@monogrid/gainmap-js": "https://unpkg.com/@monogrid/gainmap-js/dist/decode.js"
}
}
Expand Down
4,673 changes: 2,320 additions & 2,353 deletions package-lock.json

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,44 +107,44 @@
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
"@playwright/test": "^1.51.1",
"@rollup/plugin-commonjs": "^26.0.1",
"@playwright/test": "^1.56.1",
"@rollup/plugin-commonjs": "^28.0.9",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@rollup/plugin-typescript": "^12.3.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^13.0.0",
"@semantic-release/commit-analyzer": "^13.0.1",
"@semantic-release/git": "github:semantic-release/git",
"@semantic-release/github": "^10.1.3",
"@semantic-release/npm": "^12.0.1",
"@semantic-release/release-notes-generator": "^14.0.1",
"@types/node": "^20.14.9",
"@types/three": "^0.176.0",
"concurrently": "^8.2.2",
"conventional-changelog-conventionalcommits": "^8.0.0",
"@semantic-release/github": "^12.0.0",
"@semantic-release/npm": "^13.1.1",
"@semantic-release/release-notes-generator": "^14.1.0",
"@types/node": "^22.18.12",
"@types/three": "^0.180.0",
"concurrently": "^9.2.1",
"conventional-changelog-conventionalcommits": "^9.1.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^9.16.0",
"eslint": "^9.38.0",
"eslint-config-mdcs": "^5.0.0",
"eslint-plugin-html": "^8.0.0",
"eslint-plugin-html": "^8.1.3",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^16.0.0",
"neostandard": "^0.12.1",
"nyc": "^17.0.0",
"rollup": "^4.20.0",
"eslint-plugin-unused-imports": "^4.3.0",
"globals": "^16.4.0",
"neostandard": "^0.12.2",
"nyc": "^17.1.0",
"rollup": "^4.52.5",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-delete": "^3.0.1",
"rollup-plugin-istanbul": "^5.0.0",
"rollup-plugin-license": "^3.5.2",
"semantic-release": "^24.0.0",
"servez": "^2.2.3",
"sharp": "^0.33.4",
"three": "^0.176.0",
"typedoc": "^0.28.0",
"rollup-plugin-license": "^3.6.0",
"semantic-release": "^25.0.1",
"servez": "^2.3.2",
"sharp": "^0.34.4",
"three": "^0.180.0",
"typedoc": "^0.28.14",
"typedoc-github-wiki-theme": "^2.1.0",
"typedoc-plugin-markdown": "^4.2.3",
"typescript": "^5.5.4"
"typedoc-plugin-markdown": "^4.9.0",
"typescript": "~5.9.0"
},
"peerDependencies": {
"three": ">= 0.159.0"
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.decodeonly.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import istanbul from 'rollup-plugin-istanbul'
import license from 'rollup-plugin-license'

// @ts-expect-error tsc + rollup fight each other
import pkgJSON from './package.json' assert { type: 'json' }
import pkgJSON from './package.json' with { type: 'json' }

const { author, name, version } = pkgJSON

Expand Down
2 changes: 1 addition & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import istanbul from 'rollup-plugin-istanbul'
import license from 'rollup-plugin-license'

// @ts-expect-error tsc + rollup fight each other
import pkgJSON from './package.json' assert { type: 'json' }
import pkgJSON from './package.json' with { type: 'json' }

const { author, name, version } = pkgJSON

Expand Down
28 changes: 20 additions & 8 deletions src/core/QuadRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ import {
TextureDataType,
TypedArray,
UnsignedByteType,
UnsignedInt248Type,
UnsignedInt5999Type,
UnsignedInt101111Type,
UnsignedIntType,
UnsignedShort4444Type,
UnsignedShort5551Type,
UnsignedShortType,
UVMapping,
WebGLRenderer,
WebGLRenderTarget
Expand All @@ -36,14 +42,20 @@ import { QuadRendererTextureOptions } from './types'
* @group Utility
*/
export type TextureDataTypeToBufferType<TType extends TextureDataType> =
TType extends typeof UnsignedByteType ? Uint8ClampedArray :
TType extends typeof HalfFloatType ? Uint16Array :
TType extends typeof UnsignedIntType ? Uint32Array :
TType extends typeof ByteType ? Int8Array :
TType extends typeof ShortType ? Int16Array :
TType extends typeof IntType ? Int32Array :
TType extends typeof FloatType ? Float32Array :
never
TType extends typeof UnsignedByteType ? Uint8ClampedArray<ArrayBuffer> :
TType extends typeof ByteType ? Int8Array<ArrayBuffer> :
TType extends typeof ShortType ? Int16Array<ArrayBuffer> :
TType extends typeof UnsignedShortType ? Uint16Array<ArrayBuffer> :
TType extends typeof IntType ? Int32Array<ArrayBuffer> :
TType extends typeof UnsignedIntType ? Uint32Array<ArrayBuffer> :
TType extends typeof FloatType ? Float32Array<ArrayBuffer> :
TType extends typeof HalfFloatType ? Uint16Array<ArrayBuffer> :
TType extends typeof UnsignedShort4444Type ? Uint16Array<ArrayBuffer> :
TType extends typeof UnsignedShort5551Type ? Uint16Array<ArrayBuffer> :
TType extends typeof UnsignedInt248Type ? Uint32Array<ArrayBuffer> :
TType extends typeof UnsignedInt5999Type ? Uint32Array<ArrayBuffer> :
TType extends typeof UnsignedInt101111Type ? Uint32Array<ArrayBuffer> :
never

export type QuadRendererOptions<TType extends TextureDataType, TMaterial extends Material> = {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/decode/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { MPFExtractor } from './utils/MPFExtractor'
*
* const { sdr, gainMap, metadata } = extractGainmapFromJPEG(jpegFile)
*/
export const extractGainmapFromJPEG = async (jpegFile: Uint8Array) => {
export const extractGainmapFromJPEG = async (jpegFile: Uint8Array<ArrayBuffer>) => {
const metadata = extractXMP(jpegFile)
if (!metadata) throw new XMPMetadataNotFoundError('Gain map XMP metadata not found')

Expand Down
6 changes: 3 additions & 3 deletions src/decode/loaders/HDRJPGLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export class HDRJPGLoader extends LoaderBase<string> {
*/
if (typeof jpeg === 'string') throw new Error('Invalid buffer, received [string], was expecting [ArrayBuffer]')
const jpegBuffer = new Uint8Array(jpeg)
let sdrJPEG: Uint8Array
let gainMapJPEG: Uint8Array | undefined
let sdrJPEG: Uint8Array<ArrayBuffer>
let gainMapJPEG: Uint8Array<ArrayBuffer> | undefined
let metadata: GainMapMetadata
try {
const extractionResult = await extractGainmapFromJPEG(jpegBuffer)
Expand Down Expand Up @@ -115,7 +115,7 @@ export class HDRJPGLoader extends LoaderBase<string> {

// solves #16
try {
await this.render(quadRenderer, metadata, sdrJPEG, gainMapJPEG)
await this.render(quadRenderer, metadata, sdrJPEG.buffer, gainMapJPEG?.buffer)
} catch (error) {
this.manager.itemError(url)
if (typeof onError === 'function') onError(error)
Expand Down
2 changes: 1 addition & 1 deletion src/decode/utils/MPFExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class MPFExtractor {
}
}

extract (imageArrayBuffer: Uint8Array) {
extract (imageArrayBuffer: Uint8Array<ArrayBuffer>) {
return new Promise<Blob[]>((resolve, reject) => {
const debug = this.options.debug

Expand Down
2 changes: 1 addition & 1 deletion src/encode/compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const compress = async (params: CompressParameters): Promise<CompressedIm

let imageBitmapSource: ImageBitmapSource
if ((source instanceof Uint8Array || source instanceof Uint8ClampedArray) && 'sourceMimeType' in params) {
imageBitmapSource = new Blob([source], { type: params.sourceMimeType })
imageBitmapSource = new Blob([source as (Uint8Array<ArrayBuffer> | Uint8ClampedArray<ArrayBuffer>)], { type: params.sourceMimeType })
} else if (source instanceof ImageData) {
imageBitmapSource = source
} else {
Expand Down
28 changes: 28 additions & 0 deletions src/encode/find-texture-min-max.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import {
AlphaFormat,
ClampToEdgeWrapping,
ColorSpace,
DataTexture,
DataUtils,
DepthFormat,
DepthStencilFormat,
FloatType,
NearestFilter,
RedFormat,
RedIntegerFormat,
RGBAFormat,
RGBAIntegerFormat,
RGBFormat,
RGBIntegerFormat,
RGFormat,
RGIntegerFormat,
ShaderMaterial,
Vector2,
WebGLRenderer,
Expand Down Expand Up @@ -76,6 +87,23 @@ void main() {
*/
export const findTextureMinMax = (image: EXR | RGBE | DataTexture, mode: 'min' | 'max' = 'max', renderer?: WebGLRenderer) => {
const srcTex = getDataTexture(image)

// check if texture has a valid format
if (
srcTex.format !== AlphaFormat &&
srcTex.format !== RGBFormat &&
srcTex.format !== RGBAFormat &&
srcTex.format !== DepthFormat &&
srcTex.format !== DepthStencilFormat &&
srcTex.format !== RedFormat &&
srcTex.format !== RedIntegerFormat &&
srcTex.format !== RGFormat &&
srcTex.format !== RGIntegerFormat &&
srcTex.format !== RGBIntegerFormat &&
srcTex.format !== RGBAIntegerFormat
) {
throw new Error('Unsupported texture format')
}
const cellSize = 2

const mat = new ShaderMaterial({
Expand Down
1 change: 0 additions & 1 deletion src/encode/materials/GainMapEncoderMaterial.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NoBlending, ShaderMaterial, Texture, Vector3 } from 'three'

// eslint-disable-next-line unused-imports/no-unused-imports
import { GainMapMetadata } from '../../core/types' // needed for docs
import { GainmapEncodingParameters } from '../types'

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sdr":{"metadata":{"version":4.6,"type":"Texture","generator":"Texture.toJSON"},"uuid":"55327fab-b82f-4596-92f7-3477261b561a","name":"","image":"28892867-3d10-4beb-899d-055d9994648f","mapping":300,"channel":0,"repeat":[1,1],"offset":[0,0],"center":[0,0],"rotation":0,"wrap":[1001,1001],"format":1023,"internalFormat":null,"type":1009,"colorSpace":"srgb","minFilter":1008,"magFilter":1006,"anisotropy":1,"flipY":true,"generateMipmaps":true,"premultiplyAlpha":false,"unpackAlignment":4},"gainMap":{"metadata":{"version":4.6,"type":"Texture","generator":"Texture.toJSON"},"uuid":"faa11cf8-81f1-436b-92e6-62526490046a","name":"","image":"369e2641-90ff-4df5-966d-86e5eda0610f","mapping":300,"channel":0,"repeat":[1,1],"offset":[0,0],"center":[0,0],"rotation":0,"wrap":[1001,1001],"format":1023,"internalFormat":null,"type":1009,"colorSpace":"srgb-linear","minFilter":1008,"magFilter":1006,"anisotropy":1,"flipY":true,"generateMipmaps":true,"premultiplyAlpha":false,"unpackAlignment":4},"offsetHdr":[0.015625,0.015625,0.015625],"offsetSdr":[0.015625,0.015625,0.015625],"gainMapMin":[0,0,0],"gainMapMax":[15.9993,15.9993,15.9993],"gamma":[1,1,1],"hdrCapacityMin":0,"hdrCapacityMax":15.9993,"maxDisplayBoost":65504.20944752219}
{"sdr":{"metadata":{"version":4.7,"type":"Texture","generator":"Texture.toJSON"},"uuid":"55327fab-b82f-4596-92f7-3477261b561a","name":"","image":"28892867-3d10-4beb-899d-055d9994648f","mapping":300,"channel":0,"repeat":[1,1],"offset":[0,0],"center":[0,0],"rotation":0,"wrap":[1001,1001],"format":1023,"internalFormat":null,"type":1009,"colorSpace":"srgb","minFilter":1008,"magFilter":1006,"anisotropy":1,"flipY":true,"generateMipmaps":true,"premultiplyAlpha":false,"unpackAlignment":4},"gainMap":{"metadata":{"version":4.7,"type":"Texture","generator":"Texture.toJSON"},"uuid":"faa11cf8-81f1-436b-92e6-62526490046a","name":"","image":"369e2641-90ff-4df5-966d-86e5eda0610f","mapping":300,"channel":0,"repeat":[1,1],"offset":[0,0],"center":[0,0],"rotation":0,"wrap":[1001,1001],"format":1023,"internalFormat":null,"type":1009,"colorSpace":"srgb-linear","minFilter":1008,"magFilter":1006,"anisotropy":1,"flipY":true,"generateMipmaps":true,"premultiplyAlpha":false,"unpackAlignment":4},"offsetHdr":[0.015625,0.015625,0.015625],"offsetSdr":[0.015625,0.015625,0.015625],"gainMapMin":[0,0,0],"gainMapMax":[15.9993,15.9993,15.9993],"gamma":[1,1,1],"hdrCapacityMin":0,"hdrCapacityMax":15.9993,"maxDisplayBoost":65504.20944752219}
1 change: 0 additions & 1 deletion tests/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export declare global {
// eslint-disable-next-line unused-imports/no-unused-vars
interface Window {
collectIstanbulCoverage: (coverageJSON: string) => void
__coverage__: Record<string, unknown>
Expand Down