From ed5669fe93fff0b6246b77ff5a252f3d89cecab3 Mon Sep 17 00:00:00 2001 From: yinsx Date: Mon, 5 Jan 2026 16:50:05 +0800 Subject: [PATCH] 1 --- examples/global-demo.html | 12 ++++++++--- index copy.html | 42 +++++++++++++++++++++++++++++++++++++++ vite.config.js | 4 ++-- 3 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 index copy.html diff --git a/examples/global-demo.html b/examples/global-demo.html index 749d170..860ade3 100644 --- a/examples/global-demo.html +++ b/examples/global-demo.html @@ -20,9 +20,15 @@ env: { hdrPath: '/hdr/my.env', intensity: 1.2, rotationY: 0.3 }, }; - console.log(window.faceSDK , window.faceSDK.kernel); - + console.log(window.faceSDK, window.faceSDK && window.faceSDK.kernel); + const kernel = window.faceSDK && window.faceSDK.kernel; + if (!kernel) { + console.error('SDK 全局构建未正确加载,请检查脚本地址是否可访问'); + } + + if (!kernel) return; + kernel.init(config); @@ -46,4 +52,4 @@ - \ No newline at end of file + diff --git a/index copy.html b/index copy.html new file mode 100644 index 0000000..b8305bc --- /dev/null +++ b/index copy.html @@ -0,0 +1,42 @@ + + + + + + 3D模型展示SDK - TS版 + + + +
+ +
+ + + + diff --git a/vite.config.js b/vite.config.js index e4432c2..b3a2c76 100644 --- a/vite.config.js +++ b/vite.config.js @@ -10,8 +10,8 @@ export default defineConfig({ lib: { entry: 'src/main.ts', name: 'kernel', - formats: ['esm'], - fileName: () => 'assets/index.js', + formats: ['es', 'iife'], + fileName: (format) => format === 'es' ? 'assets/index.js' : 'assets/index.global.js', }, target: 'esnext', outDir: 'dist',