mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: remove draco
This commit is contained in:
1 parent
970d93e7e0
commit
48dd9bec2a
3 files changed
+2
-29
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import { toUniqueId } from '@blitzkit/core';
|
||||
import { NodeIO } from '@gltf-transform/core';
|
||||
import { ALL_EXTENSIONS } from '@gltf-transform/extensions';
|
||||
import draco3d from 'draco3dgltf';
|
||||
import { readdir } from 'fs/promises';
|
||||
import { extractModel } from '../core/blitz/extractModel';
|
||||
import { readXMLDVPL } from '../core/blitz/readXMLDVPL';
|
||||
@@ -15,12 +14,7 @@ import { TankParameters } from './tankIcons';
|
||||
export async function tankModels() {
|
||||
console.log('Building tank models...');
|
||||
|
||||
const nodeIO = new NodeIO()
|
||||
.registerExtensions(ALL_EXTENSIONS)
|
||||
.registerDependencies({
|
||||
'draco3d.decoder': await draco3d.createDecoderModule(),
|
||||
'draco3d.encoder': await draco3d.createEncoderModule(),
|
||||
});
|
||||
const nodeIO = new NodeIO().registerExtensions(ALL_EXTENSIONS);
|
||||
const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
|
||||
(nations) => nations.filter((nation) => nation !== 'common'),
|
||||
);
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
VertexAttribute,
|
||||
} from '@blitzkit/core';
|
||||
import { Document, Material, Node, Scene } from '@gltf-transform/core';
|
||||
import { KHRDracoMeshCompression } from '@gltf-transform/extensions';
|
||||
import { dedup, prune } from '@gltf-transform/functions';
|
||||
import { times } from 'lodash-es';
|
||||
import { dirname } from 'path';
|
||||
@@ -294,15 +293,5 @@ export async function extractModel(data: string, path: string) {
|
||||
|
||||
await document.transform(prune({ keepAttributes: true }), dedup());
|
||||
|
||||
document
|
||||
.createExtension(KHRDracoMeshCompression)
|
||||
.setRequired(true)
|
||||
.setEncoderOptions({
|
||||
method: KHRDracoMeshCompression.EncoderMethod.EDGEBREAKER,
|
||||
encodeSpeed: 0,
|
||||
decodeSpeed: 0,
|
||||
quantizationVolume: 'scene',
|
||||
});
|
||||
|
||||
return document;
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import { asset } from '@blitzkit/core';
|
||||
import { type ObjectMap, useLoader } from '@react-three/fiber';
|
||||
import { Mesh, MeshStandardMaterial } from 'three';
|
||||
import { type GLTF, GLTFLoader } from 'three-stdlib';
|
||||
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
||||
|
||||
const cache: Record<
|
||||
number,
|
||||
@@ -13,16 +12,7 @@ const cache: Record<
|
||||
> = {};
|
||||
|
||||
export function useModel(id: number) {
|
||||
const gltf = useLoader(
|
||||
GLTFLoader,
|
||||
asset(`3d/tanks/models/${id}.glb`),
|
||||
(loader) => {
|
||||
const dracoLoader = new DRACOLoader();
|
||||
dracoLoader.setDecoderPath('https://www.gstatic.com/draco/v1/decoders/');
|
||||
// @ts-ignore
|
||||
loader.setDRACOLoader(dracoLoader);
|
||||
},
|
||||
);
|
||||
const gltf = useLoader(GLTFLoader, asset(`3d/tanks/models/${id}.glb`));
|
||||
|
||||
if (!cache[id]) {
|
||||
cache[id] = {
|
||||
|
||||
Reference in new issue
Block a user