mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +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 { toUniqueId } from '@blitzkit/core';
|
||||||
import { NodeIO } from '@gltf-transform/core';
|
import { NodeIO } from '@gltf-transform/core';
|
||||||
import { ALL_EXTENSIONS } from '@gltf-transform/extensions';
|
import { ALL_EXTENSIONS } from '@gltf-transform/extensions';
|
||||||
import draco3d from 'draco3dgltf';
|
|
||||||
import { readdir } from 'fs/promises';
|
import { readdir } from 'fs/promises';
|
||||||
import { extractModel } from '../core/blitz/extractModel';
|
import { extractModel } from '../core/blitz/extractModel';
|
||||||
import { readXMLDVPL } from '../core/blitz/readXMLDVPL';
|
import { readXMLDVPL } from '../core/blitz/readXMLDVPL';
|
||||||
@@ -15,12 +14,7 @@ import { TankParameters } from './tankIcons';
|
|||||||
export async function tankModels() {
|
export async function tankModels() {
|
||||||
console.log('Building tank models...');
|
console.log('Building tank models...');
|
||||||
|
|
||||||
const nodeIO = new NodeIO()
|
const nodeIO = new NodeIO().registerExtensions(ALL_EXTENSIONS);
|
||||||
.registerExtensions(ALL_EXTENSIONS)
|
|
||||||
.registerDependencies({
|
|
||||||
'draco3d.decoder': await draco3d.createDecoderModule(),
|
|
||||||
'draco3d.encoder': await draco3d.createEncoderModule(),
|
|
||||||
});
|
|
||||||
const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
|
const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
|
||||||
(nations) => nations.filter((nation) => nation !== 'common'),
|
(nations) => nations.filter((nation) => nation !== 'common'),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
VertexAttribute,
|
VertexAttribute,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
import { Document, Material, Node, Scene } from '@gltf-transform/core';
|
import { Document, Material, Node, Scene } from '@gltf-transform/core';
|
||||||
import { KHRDracoMeshCompression } from '@gltf-transform/extensions';
|
|
||||||
import { dedup, prune } from '@gltf-transform/functions';
|
import { dedup, prune } from '@gltf-transform/functions';
|
||||||
import { times } from 'lodash-es';
|
import { times } from 'lodash-es';
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
@@ -294,15 +293,5 @@ export async function extractModel(data: string, path: string) {
|
|||||||
|
|
||||||
await document.transform(prune({ keepAttributes: true }), dedup());
|
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;
|
return document;
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@ import { asset } from '@blitzkit/core';
|
|||||||
import { type ObjectMap, useLoader } from '@react-three/fiber';
|
import { type ObjectMap, useLoader } from '@react-three/fiber';
|
||||||
import { Mesh, MeshStandardMaterial } from 'three';
|
import { Mesh, MeshStandardMaterial } from 'three';
|
||||||
import { type GLTF, GLTFLoader } from 'three-stdlib';
|
import { type GLTF, GLTFLoader } from 'three-stdlib';
|
||||||
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
|
||||||
|
|
||||||
const cache: Record<
|
const cache: Record<
|
||||||
number,
|
number,
|
||||||
@@ -13,16 +12,7 @@ const cache: Record<
|
|||||||
> = {};
|
> = {};
|
||||||
|
|
||||||
export function useModel(id: number) {
|
export function useModel(id: number) {
|
||||||
const gltf = useLoader(
|
const gltf = useLoader(GLTFLoader, asset(`3d/tanks/models/${id}.glb`));
|
||||||
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);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!cache[id]) {
|
if (!cache[id]) {
|
||||||
cache[id] = {
|
cache[id] = {
|
||||||
|
|||||||
Reference in new issue
Block a user