fix: harden item and baked scene rendering (#522)
This commit is contained in:
@@ -525,7 +525,7 @@ export function GlbScene({
|
||||
_camBox.setFromObject(object)
|
||||
} else {
|
||||
bookmarkNode = rootNode
|
||||
_camBox.setFromObject(gltf.scene)
|
||||
_camBox.setFromObject(rootNode ?? gltf.scene)
|
||||
}
|
||||
|
||||
const bookmark = (bookmarkNode?.userData as PascalExtras | undefined)?.camera
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import { useGLTF } from '@react-three/drei'
|
||||
import { useThree } from '@react-three/fiber'
|
||||
import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js'
|
||||
import { ensureKtx2Support, ktx2Loader } from '../lib/ktx2-loader'
|
||||
import { configureKtx2Support } from '../lib/ktx2-loader'
|
||||
|
||||
const useGLTFKTX2 = (path: string): ReturnType<typeof useGLTF> => {
|
||||
const gl = useThree((state) => state.gl)
|
||||
|
||||
return useGLTF(path, true, true, (loader) => {
|
||||
if (ensureKtx2Support(gl)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
loader.setKTX2Loader(ktx2Loader as any)
|
||||
}
|
||||
configureKtx2Support(loader, gl)
|
||||
loader.setMeshoptDecoder(MeshoptDecoder)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ export {
|
||||
collectIsolationSubtree,
|
||||
isIsolationActive,
|
||||
} from './lib/isolation'
|
||||
export { ensureKtx2Support } from './lib/ktx2-loader'
|
||||
export { configureKtx2Support, ensureKtx2Support } from './lib/ktx2-loader'
|
||||
export { GRID_LAYER, OVERLAY_LAYER, SCENE_LAYER, ZONE_LAYER } from './lib/layers'
|
||||
export {
|
||||
applyMaterialPresetToMaterials,
|
||||
|
||||
@@ -162,6 +162,15 @@ export function ensureKtx2Support(renderer: unknown): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
export function configureKtx2Support<T>(
|
||||
loader: { setKTX2Loader: (ktx2: T) => unknown },
|
||||
renderer: unknown,
|
||||
): boolean {
|
||||
if (!ensureKtx2Support(renderer)) return false
|
||||
loader.setKTX2Loader(ktx2Loader as unknown as T)
|
||||
return true
|
||||
}
|
||||
|
||||
export function isKtx2Url(url: string): boolean {
|
||||
return url.toLowerCase().endsWith('.ktx2')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user