@ludicon/spark.js 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/package.json +2 -2
- package/src/three-gltf.js +38 -14
package/README.md
CHANGED
|
@@ -92,17 +92,17 @@ Load an image and encode it to a compressed GPU texture.
|
|
|
92
92
|
|
|
93
93
|
- A channel mask indicating the number of channels in your input: `"rgba"`, `"rgb"`, `"rg"` or `"r"`, the actual format is selected based on the device capabilities.
|
|
94
94
|
|
|
95
|
-
- An explicit WebGPU BC, ETC or ASTC format name, or an abbreviated form such as `"bc7"` or `"astc"`. Note
|
|
95
|
+
- An explicit WebGPU BC, ETC or ASTC format name, or an abbreviated form such as `"bc7"` or `"astc"`. Note: only 4x4 LDR formats are supported.
|
|
96
96
|
|
|
97
97
|
- If you specify `auto`, the input texture is analyzed to detect the necessary number of channels. This has some overhead, it's always recommended to specify the format through one of the other methods.
|
|
98
98
|
|
|
99
99
|
Default: `rgb`.
|
|
100
100
|
|
|
101
101
|
- **`alpha`**
|
|
102
|
-
Hint for the format selector. When
|
|
102
|
+
Hint for the automatic format selector. When no explicit format is provided, the format is assumed to be `"rgb"`. Supplying `alpha: true` will default to "rgba" instead.
|
|
103
103
|
|
|
104
104
|
- **`mips`** or **`generateMipmaps`** (`boolean`)
|
|
105
|
-
Whether to generate mipmaps.
|
|
105
|
+
Whether to generate mipmaps. Mipmaps are generated with a basic box filter in linear space. Default: `false`.
|
|
106
106
|
|
|
107
107
|
- **`srgb`** (`boolean`)
|
|
108
108
|
Whether to encode the image using an as sRGB format. This also affects mipmap generation. The `srgb` mode can also be inferred from the `format`. Default: `false`.
|
|
@@ -115,7 +115,8 @@ Load an image and encode it to a compressed GPU texture.
|
|
|
115
115
|
|
|
116
116
|
#### Returns
|
|
117
117
|
|
|
118
|
-
- `Promise<GPUTexture>`
|
|
118
|
+
- `Promise<GPUTexture>`
|
|
119
|
+
A promise resolving to the encoded WebGPU texture.
|
|
119
120
|
|
|
120
121
|
|
|
121
122
|
## Integration with three.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ludicon/spark.js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Real-Time GPU Texture Codecs for the Web",
|
|
5
5
|
"main": "dist/spark.esm.js",
|
|
6
6
|
"module": "dist/spark.esm.js",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"vite": "^7.0.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"three": "
|
|
70
|
+
"three": ">=0.180.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependenciesMeta": {
|
|
73
73
|
"three": {
|
package/src/three-gltf.js
CHANGED
|
@@ -70,34 +70,58 @@ class GLTFSparkPlugin {
|
|
|
70
70
|
assignTexture(materialDef.pbrMetallicRoughness?.metallicRoughnessTexture?.index, Channel.G | Channel.B)
|
|
71
71
|
|
|
72
72
|
// KHR_materials_anisotropy - RG contains direction, B contains strength.
|
|
73
|
-
|
|
73
|
+
const anisotropyDef = materialDef.extensions?.KHR_materials_anisotropy
|
|
74
|
+
if (anisotropyDef) {
|
|
75
|
+
assignTexture(anisotropyDef.anisotropyTexture?.index, Channel.RGB)
|
|
76
|
+
}
|
|
74
77
|
|
|
75
78
|
// KHR_materials_clearcoat
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
const clearcoatDef = materialDef.extensions?.KHR_materials_clearcoat
|
|
80
|
+
if (clearcoatDef) {
|
|
81
|
+
assignTexture(clearcoatDef.clearcoatTexture?.index, Channel.RGB, THREE.SRGBColorSpace)
|
|
82
|
+
assignTexture(clearcoatDef.clearcoatRoughnessTexture?.index, Channel.R)
|
|
83
|
+
assignTexture(clearcoatDef.clearcoatNormalTexture?.index, Channel.RG, THREE.NoColorSpace, true)
|
|
84
|
+
}
|
|
79
85
|
|
|
80
86
|
// KHR_materials_diffuse_transmission
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
const diffuseTransmissionDef = materialDef.extensions?.KHR_materials_diffuse_transmission
|
|
88
|
+
if (diffuseTransmissionDef) {
|
|
89
|
+
assignTexture(diffuseTransmissionDef.diffuseTransmissionTexture?.index, Channel.A)
|
|
90
|
+
assignTexture(diffuseTransmissionDef.diffuseTransmissionColorTexture?.index, Channel.RGB, THREE.SRGBColorSpace)
|
|
91
|
+
}
|
|
83
92
|
|
|
84
93
|
// KHR_materials_iridescence
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
const iridescenceDef = materialDef.extensions?.KHR_materials_iridescence
|
|
95
|
+
if (iridescenceDef) {
|
|
96
|
+
assignTexture(iridescenceDef.iridescenceTexture?.index, Channel.R)
|
|
97
|
+
assignTexture(iridescenceDef.iridescenceThicknessTexture?.index, Channel.G)
|
|
98
|
+
}
|
|
87
99
|
|
|
88
100
|
// KHR_materials_sheen
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
const sheenDef = materialDef.extensions?.KHR_materials_sheen
|
|
102
|
+
if (sheenDef) {
|
|
103
|
+
assignTexture(sheenDef.sheenColorTexture?.index, Channel.RGB, THREE.SRGBColorSpace)
|
|
104
|
+
assignTexture(sheenDef.sheenRoughnessTextureIndex?.index, Channel.A)
|
|
105
|
+
}
|
|
91
106
|
|
|
92
107
|
// KHR_materials_specular
|
|
93
|
-
|
|
94
|
-
|
|
108
|
+
const specularDef = materialDef.extensions?.KHR_materials_specular
|
|
109
|
+
if (specularDef) {
|
|
110
|
+
assignTexture(specularDef.specularTexture?.index, Channel.RGB, THREE.SRGBColorSpace)
|
|
111
|
+
assignTexture(specularDef.specularColorTexture?.index, Channel.A)
|
|
112
|
+
}
|
|
95
113
|
|
|
96
114
|
// KHR_materials_transmission
|
|
97
|
-
|
|
115
|
+
const transmissionDef = materialDef.extensions?.KHR_materials_transmission
|
|
116
|
+
if (transmissionDef) {
|
|
117
|
+
assignTexture(transmissionDef.transmissionTexture?.index, Channel.R)
|
|
118
|
+
}
|
|
98
119
|
|
|
99
120
|
// KHR_materials_volume
|
|
100
|
-
|
|
121
|
+
const volumeDef = materialDef.extensions?.KHR_materials_volume
|
|
122
|
+
if (volumeDef) {
|
|
123
|
+
assignTexture(volumeDef.thicknessTexture?.index, Channel.G)
|
|
124
|
+
}
|
|
101
125
|
}
|
|
102
126
|
|
|
103
127
|
this.textureColorSpaces = textureColorSpaces
|