fix: normalize exported texture filenames
This commit is contained in:
@@ -7,8 +7,10 @@ import { useLoader } from '@react-three/fiber'
|
||||
import { CanvasTexture, Mesh, TextureLoader } from 'three'
|
||||
import type { Material, Object3D, Texture } from 'three'
|
||||
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
|
||||
import { normalizeTextureFilename } from '@/lib/asset-naming'
|
||||
|
||||
export interface ModelStats {
|
||||
childObjects: number
|
||||
drawCalls: number
|
||||
materials: number
|
||||
meshes: number
|
||||
@@ -55,7 +57,8 @@ function resolveAssetUrl(requestedUrl: string, assetUrls: Record<string, string>
|
||||
|
||||
function getOpacityMapEntries(assetUrls: Record<string, string>) {
|
||||
return Object.entries(assetUrls).reduce<OpacityMapEntry[]>((entries, [filename, url]) => {
|
||||
const match = filename.toLowerCase().match(/^opacity(?:[_-](.+))?\.(png|jpe?g|webp)$/)
|
||||
const normalizedFilename = normalizeTextureFilename(filename) || filename
|
||||
const match = normalizedFilename.toLowerCase().match(/^opacity(?:[_-](.+))?\.(png|jpe?g|webp)$/)
|
||||
|
||||
if (!match) return entries
|
||||
|
||||
@@ -188,6 +191,7 @@ function getModelStats(scene: Object3D, assetUrls: Record<string, string>): Mode
|
||||
})
|
||||
|
||||
return {
|
||||
childObjects: scene.children.length,
|
||||
drawCalls,
|
||||
materials: materials.size,
|
||||
meshes,
|
||||
|
||||
Reference in New Issue
Block a user