@aura3d/assets 1.3.2 → 1.4.0
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/AGENTS.md +46 -0
- package/dist/GLTFLoader.js +1 -0
- package/dist/GLTFLoader.js.map +1 -1
- package/dist/GLTFRenderResources.d.ts.map +1 -1
- package/dist/GLTFRenderResources.js +68 -16
- package/dist/GLTFRenderResources.js.map +1 -1
- package/dist/KTX2BasisTextureTranscoder.js +1 -0
- package/dist/KTX2BasisTextureTranscoder.js.map +1 -1
- package/package.json +4 -4
- package/src/GLTFLoader.ts +1 -0
- package/src/GLTFRenderResources.ts +82 -16
- package/src/KTX2BasisTextureTranscoder.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aura3d/assets",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"main": "./dist/index.js",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@aura3d/animation": "1.
|
|
19
|
-
"@aura3d/rendering": "1.
|
|
20
|
-
"@aura3d/scene": "1.
|
|
18
|
+
"@aura3d/animation": "1.4.0",
|
|
19
|
+
"@aura3d/rendering": "1.4.0",
|
|
20
|
+
"@aura3d/scene": "1.4.0"
|
|
21
21
|
},
|
|
22
22
|
"sideEffects": false
|
|
23
23
|
}
|
package/src/GLTFLoader.ts
CHANGED
|
@@ -4022,6 +4022,7 @@ function serializeGLTFAsset(
|
|
|
4022
4022
|
joints: mesh.joints.map((joint) => [...joint] as const),
|
|
4023
4023
|
weights: mesh.weights.map((weight) => [...weight] as const),
|
|
4024
4024
|
morphTargets: mesh.morphTargets.map((target) => ({
|
|
4025
|
+
...(target.name ? { name: target.name } : {}),
|
|
4025
4026
|
positions: target.positions.map((position) => [...position] as const),
|
|
4026
4027
|
normals: target.normals.map((normal) => [...normal] as const),
|
|
4027
4028
|
tangents: target.tangents.map((tangent) => [...tangent] as const)
|
|
@@ -417,6 +417,7 @@ export async function createGLTFRenderResources(
|
|
|
417
417
|
geometryLibrary.set(mesh.name, createGeometry(mesh, materialForMesh(asset, mesh, options.materialVariant)));
|
|
418
418
|
if (mesh.morphTargets.length > 0) {
|
|
419
419
|
morphTargetLibrary.set(mesh.name, mesh.morphTargets.map((target) => ({
|
|
420
|
+
...(target.name ? { name: target.name } : {}),
|
|
420
421
|
positions: target.positions,
|
|
421
422
|
normals: target.normals,
|
|
422
423
|
tangents: target.tangents
|
|
@@ -1383,21 +1384,65 @@ async function createMaterial(
|
|
|
1383
1384
|
): Promise<Material> {
|
|
1384
1385
|
const renderState = renderStateForGLTFMaterial(material, renderStateOverrides);
|
|
1385
1386
|
if (options.skinned && !material.unlit) {
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1387
|
+
const [
|
|
1388
|
+
baseColorTexture,
|
|
1389
|
+
normalTexture,
|
|
1390
|
+
metallicRoughnessTexture,
|
|
1391
|
+
occlusionTexture,
|
|
1392
|
+
emissiveTexture,
|
|
1393
|
+
clearcoatTexture,
|
|
1394
|
+
clearcoatNormalTexture,
|
|
1395
|
+
sheenColorTexture,
|
|
1396
|
+
sheenRoughnessTexture,
|
|
1397
|
+
transmissionTexture,
|
|
1398
|
+
iridescenceTexture,
|
|
1399
|
+
iridescenceThicknessTexture,
|
|
1400
|
+
anisotropyTexture,
|
|
1401
|
+
volumeThicknessTexture
|
|
1402
|
+
] = await Promise.all([
|
|
1403
|
+
material.baseColorTexture
|
|
1404
|
+
? createTextureBinding(asset, material.baseColorTexture, "srgb", getTexture, "u_baseColorTexture")
|
|
1405
|
+
: Promise.resolve(undefined),
|
|
1406
|
+
material.normalTexture
|
|
1407
|
+
? createTextureBinding(asset, material.normalTexture, "linear", getTexture, "u_normalTexture", createNormalSampler(asset, material))
|
|
1408
|
+
: Promise.resolve(undefined),
|
|
1409
|
+
material.metallicRoughnessTexture
|
|
1410
|
+
? createTextureBinding(asset, material.metallicRoughnessTexture, "linear", getTexture, "u_metallicRoughnessTexture")
|
|
1411
|
+
: Promise.resolve(undefined),
|
|
1412
|
+
material.occlusionTexture
|
|
1413
|
+
? createTextureBinding(asset, material.occlusionTexture, "linear", getTexture, "u_occlusionTexture")
|
|
1414
|
+
: Promise.resolve(undefined),
|
|
1415
|
+
material.emissiveTexture
|
|
1416
|
+
? createTextureBinding(asset, material.emissiveTexture, "srgb", getTexture, "u_emissiveTexture")
|
|
1417
|
+
: Promise.resolve(undefined),
|
|
1418
|
+
material.clearcoat?.texture
|
|
1419
|
+
? createTextureBinding(asset, material.clearcoat.texture, "linear", getTexture, "u_clearcoatTexture")
|
|
1420
|
+
: Promise.resolve(undefined),
|
|
1421
|
+
material.clearcoat?.normalTexture
|
|
1422
|
+
? createTextureBinding(asset, material.clearcoat.normalTexture, "linear", getTexture, "u_clearcoatNormalTexture", createNormalSamplerForInfo(asset, material.clearcoat.normalTexture))
|
|
1423
|
+
: Promise.resolve(undefined),
|
|
1424
|
+
material.sheen?.colorTexture
|
|
1425
|
+
? createTextureBinding(asset, material.sheen.colorTexture, "srgb", getTexture, "u_sheenColorTexture")
|
|
1426
|
+
: Promise.resolve(undefined),
|
|
1427
|
+
material.sheen?.roughnessTexture
|
|
1428
|
+
? createTextureBinding(asset, material.sheen.roughnessTexture, "linear", getTexture, "u_sheenRoughnessTexture")
|
|
1429
|
+
: Promise.resolve(undefined),
|
|
1430
|
+
material.transmission?.texture
|
|
1431
|
+
? createTextureBinding(asset, material.transmission.texture, "linear", getTexture, "u_transmissionTexture")
|
|
1432
|
+
: Promise.resolve(undefined),
|
|
1433
|
+
material.iridescence?.texture
|
|
1434
|
+
? createTextureBinding(asset, material.iridescence.texture, "linear", getTexture, "u_iridescenceTexture")
|
|
1435
|
+
: Promise.resolve(undefined),
|
|
1436
|
+
material.iridescence?.thicknessTexture
|
|
1437
|
+
? createTextureBinding(asset, material.iridescence.thicknessTexture, "linear", getTexture, "u_iridescenceThicknessTexture")
|
|
1438
|
+
: Promise.resolve(undefined),
|
|
1439
|
+
material.anisotropy?.texture
|
|
1440
|
+
? createTextureBinding(asset, material.anisotropy.texture, "linear", getTexture, "u_anisotropyTexture")
|
|
1441
|
+
: Promise.resolve(undefined),
|
|
1442
|
+
material.volume?.thicknessTexture
|
|
1443
|
+
? createTextureBinding(asset, material.volume.thicknessTexture, "linear", getTexture, "u_volumeThicknessTexture")
|
|
1444
|
+
: Promise.resolve(undefined)
|
|
1445
|
+
]);
|
|
1401
1446
|
const runtimeMaterial = new SkinnedLitMaterial({
|
|
1402
1447
|
name: material.name,
|
|
1403
1448
|
renderState,
|
|
@@ -1416,6 +1461,15 @@ async function createMaterial(
|
|
|
1416
1461
|
roughness: material.roughnessFactor,
|
|
1417
1462
|
emissiveColor: material.emissiveFactor,
|
|
1418
1463
|
emissiveStrength: material.emissiveStrength,
|
|
1464
|
+
clearcoatTexture,
|
|
1465
|
+
clearcoatNormalTexture,
|
|
1466
|
+
sheenColorTexture,
|
|
1467
|
+
sheenRoughnessTexture,
|
|
1468
|
+
transmissionTexture,
|
|
1469
|
+
iridescenceTexture,
|
|
1470
|
+
iridescenceThicknessTexture,
|
|
1471
|
+
anisotropyTexture,
|
|
1472
|
+
volumeThicknessTexture,
|
|
1419
1473
|
...pbrExtensionScalarOptions(material)
|
|
1420
1474
|
});
|
|
1421
1475
|
applyAlphaCutoff(runtimeMaterial, material);
|
|
@@ -1540,7 +1594,15 @@ async function createMaterial(
|
|
|
1540
1594
|
}
|
|
1541
1595
|
|
|
1542
1596
|
function createDefaultGLTFMaterial(mesh: GLTFMeshAsset, options: { readonly instanced?: boolean; readonly skinned?: boolean } = {}): Material {
|
|
1543
|
-
|
|
1597
|
+
// Use a neutral light-gray base color instead of glTF-spec white ([1,1,1,1])
|
|
1598
|
+
// so missing-material fallbacks do not blow out as bright white artifacts.
|
|
1599
|
+
const defaults = {
|
|
1600
|
+
name: mesh.material,
|
|
1601
|
+
baseColor: [0.76, 0.74, 0.72, 1] as const,
|
|
1602
|
+
metallic: 0,
|
|
1603
|
+
roughness: 0.85,
|
|
1604
|
+
environmentIntensity: DEFAULT_PBR_ENVIRONMENT_INTENSITY
|
|
1605
|
+
} as const;
|
|
1544
1606
|
if (options.skinned) {
|
|
1545
1607
|
return new SkinnedLitMaterial(defaults);
|
|
1546
1608
|
}
|
|
@@ -1603,6 +1665,10 @@ function requiresTransparentRenderState(material: GLTFMaterialAsset): boolean {
|
|
|
1603
1665
|
function isEffectivelyOpaqueBlendMaterial(material: GLTFMaterialAsset): boolean {
|
|
1604
1666
|
if (material.alphaMode !== "BLEND") return false;
|
|
1605
1667
|
if (material.baseColorFactor[3] < BLEND_OPAQUE_ALPHA_THRESHOLD) return false;
|
|
1668
|
+
// Conservative: if a baseColorTexture is present, retain blending — the texture may
|
|
1669
|
+
// carry per-texel alpha that we cannot inspect here. Flattening would depth-sort it
|
|
1670
|
+
// as opaque and cause ghosting / overlay artifacts.
|
|
1671
|
+
if (material.baseColorTexture) return false;
|
|
1606
1672
|
if (materialHasTransmissionOrVolume(material)) return false;
|
|
1607
1673
|
return true;
|
|
1608
1674
|
}
|
|
@@ -76,6 +76,7 @@ async function parseTextureLevels(
|
|
|
76
76
|
await installNodeLoadersGLFileHooks();
|
|
77
77
|
const { parse, BasisLoader } = await loadLoadersGLModules();
|
|
78
78
|
const parsed = await parse(source.slice(0), BasisLoader, {
|
|
79
|
+
// worker:false is required: worker mode resolves transcoder module URLs to dev-only /node_modules paths and the Node file hooks on globalThis.loaders only exist on the main thread.
|
|
79
80
|
worker: false,
|
|
80
81
|
CDN: defaultLoadersGLCdn(),
|
|
81
82
|
modules: defaultLoadersGLModules(),
|