scans and ref image

This commit is contained in:
wass08
2026-01-29 09:38:24 +09:00
parent a1a0e78384
commit c94f661bf9
20 changed files with 688 additions and 7 deletions
@@ -0,0 +1,23 @@
import { loadAssetUrl } from '@pascal-app/core'
import { useEffect, useState } from 'react'
/**
* Resolves an asset:// URL to a blob URL for use with Three.js loaders.
* Returns null while loading or if resolution fails.
*/
export function useAssetUrl(url: string): string | null {
const [resolved, setResolved] = useState<string | null>(null)
useEffect(() => {
let cancelled = false
setResolved(null)
loadAssetUrl(url).then((result) => {
if (!cancelled) setResolved(result)
})
return () => {
cancelled = true
}
}, [url])
return resolved
}
@@ -0,0 +1,19 @@
import { useGLTF } from "@react-three/drei"
import { useThree } from "@react-three/fiber"
import { KTX2Loader } from "three/examples/jsm/Addons.js"
import { MeshoptDecoder } from "three/examples/jsm/libs/meshopt_decoder.module.js"
const ktx2LoaderInstance = new KTX2Loader()
ktx2LoaderInstance.setTranscoderPath('https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master/basis/')
const useGLTFKTX2 = (path: string) => {
const gl = useThree((state) => state.gl)
return useGLTF(path, true, true, (loader) => {
ktx2LoaderInstance.detectSupport(gl)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
loader.setKTX2Loader(ktx2LoaderInstance as any)
loader.setMeshoptDecoder(MeshoptDecoder)
})
}
export { useGLTFKTX2 }