@needle-tools/gltf-progressive 1.0.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/examples/@needle-tools-gltf-progressive.min.js +3 -0
- package/examples/modelviewer.html +27 -0
- package/package.json +28 -0
- package/src/extension.ts +768 -0
- package/src/index.ts +14 -0
- package/src/loaders.ts +49 -0
- package/src/lods_manager.ts +387 -0
- package/src/plugins/index.ts +2 -0
- package/src/plugins/modelviewer.ts +113 -0
- package/src/plugins/plugin.ts +21 -0
- package/src/utils.ts +41 -0
- package/tsconfig.json +33 -0
- package/vite.config.ts +69 -0
package/vite.config.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// vite.config.ts
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import { transform } from 'esbuild';
|
|
5
|
+
|
|
6
|
+
// https://vitejs.dev/guide/build.html#library-mode
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// @ts-ignore sorry not sure how to fix this
|
|
10
|
+
export default defineConfig(() => {
|
|
11
|
+
|
|
12
|
+
console.log("########################################### Begin Build")
|
|
13
|
+
|
|
14
|
+
// const isLightMode = process.argv.includes('--light');
|
|
15
|
+
const clearOutputDirectory = process.argv.includes('--noclear') === false;
|
|
16
|
+
|
|
17
|
+
let postfix = "";
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
plugins: [
|
|
21
|
+
// ...getPluginsForLibrary({
|
|
22
|
+
// light: isLightMode
|
|
23
|
+
// })
|
|
24
|
+
],
|
|
25
|
+
build: {
|
|
26
|
+
emptyOutDir: clearOutputDirectory,
|
|
27
|
+
lib: {
|
|
28
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
29
|
+
name: 'needle-tools-gltf-progressive',
|
|
30
|
+
formats: ['es', 'esm', 'cjs'],
|
|
31
|
+
fileName: (format) => ({
|
|
32
|
+
es: `@needle-tools-gltf-progressive${postfix}.js`,
|
|
33
|
+
esm: `@needle-tools-gltf-progressive${postfix}.min.js`,
|
|
34
|
+
cjs: `@needle-tools-gltf-progressive${postfix}.umd.cjs`,
|
|
35
|
+
}[format]),
|
|
36
|
+
},
|
|
37
|
+
rollupOptions: {
|
|
38
|
+
external: ["three",
|
|
39
|
+
"three/examples/jsm/loaders/GLTFLoader.js",
|
|
40
|
+
"three/examples/jsm/libs/meshopt_decoder.module.js",
|
|
41
|
+
"three/examples/jsm/loaders/DRACOLoader.js",
|
|
42
|
+
"three/examples/jsm/loaders/KTX2Loader.js",
|
|
43
|
+
],
|
|
44
|
+
output: {
|
|
45
|
+
plugins: [minifyEs()],
|
|
46
|
+
// prevent rollup from generating separate chunks
|
|
47
|
+
manualChunks: _ => "needle-tools-gltf-progressive"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// https://github.com/vitejs/vite/issues/6555
|
|
56
|
+
function minifyEs() {
|
|
57
|
+
return {
|
|
58
|
+
name: 'minifyEs',
|
|
59
|
+
renderChunk: {
|
|
60
|
+
order: 'post',
|
|
61
|
+
async handler(code, chunk, outputOptions) {
|
|
62
|
+
if (outputOptions.format === 'es' && chunk.fileName.endsWith('.min.js')) {
|
|
63
|
+
return await transform(code, { minify: true });
|
|
64
|
+
}
|
|
65
|
+
return code;
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|