feat: integrate Draco compression for GLB models and implement encryption for secure loading

- Added DRACOLoader to starter.js for handling compressed GLB models.
- Created a createGltfLoader function to initialize GLTFLoader with DRACOLoader.
- Implemented dracoModels plugin in vite.config.js to compress GLB models during build.
- Introduced model_loader.js for loading encrypted GLB models with WebCrypto.
- Developed encryptModels plugin to encrypt GLB files, ensuring no clear models are exposed.
- Updated asset handling to remove uncompressed GLB files post-build.
This commit is contained in:
2026-10-28 10:00:09 +01:00
parent f539e4e185
commit 24df94cdc3
9 changed files with 805 additions and 5 deletions
+10 -2
View File
@@ -2,6 +2,9 @@ import { defineConfig } from 'vite';
import path from 'path';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import { ViteMinifyPlugin } from 'vite-plugin-minify'
import dracoModels from './vite-plugins/draco-models.js';
// Cifratura dei modelli, pronta ma non attiva: vedi vite-plugins/encrypt-models.js.
// import encryptModels from './vite-plugins/encrypt-models.js';
export default defineConfig({
// Il configuratore è servito da Laravel sotto /configuratore/ (stessa origine dell'API):
@@ -26,11 +29,16 @@ export default defineConfig({
viteStaticCopy({
targets: [
{
src: 'assets',
dest: ''
// I modelli 3D non vengono copiati così come sono: li comprime dracoModels.
src: ['assets/*', '!assets/models'],
dest: 'assets'
}
]
}),
dracoModels({
modelsDir: path.resolve(__dirname, 'src/assets/models'),
cacheDir: path.resolve(__dirname, 'node_modules/.cache/draco-models'),
}),
ViteMinifyPlugin({
minify: {
removeComments: true,