修改
This commit is contained in:
39
examples/global-demo.html
Normal file
39
examples/global-demo.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SDK 全局挂载加载示例</title>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="renderDom"></canvas>
|
||||
|
||||
<!-- 非模块化:使用全局构建产物,加载后可通过 window.faceSDK.kernel 调用 -->
|
||||
<!-- 部署后把 src 改成实际访问路径,如 https://doc.zguiy.com/sdk/zt/assets/index.global.js -->
|
||||
<script src="https://sdk.zguiy.com/zt/assets/index.js"></script>
|
||||
<script>
|
||||
const config = {
|
||||
container: 'renderDom',
|
||||
modelUrlList: ['./public/model/model.glb'],
|
||||
env: { hdrPath: '/hdr/my.env', intensity: 1.2, rotationY: 0.3 },
|
||||
onSuccess: () => console.log('SDK initialized (global)'),
|
||||
onError: (err) => console.error('SDK init error', err),
|
||||
};
|
||||
|
||||
function startSdk() {
|
||||
const kernel = window.faceSDK && window.faceSDK.kernel;
|
||||
if (!kernel) {
|
||||
console.error('SDK kernel not loaded');
|
||||
return;
|
||||
}
|
||||
kernel.init(config);
|
||||
}
|
||||
|
||||
if (document.readyState === 'complete') {
|
||||
startSdk();
|
||||
} else {
|
||||
window.addEventListener('load', startSdk);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
26
examples/module-demo.html
Normal file
26
examples/module-demo.html
Normal file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SDK 模块化加载示例</title>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="renderDom"></canvas>
|
||||
|
||||
<!-- 模块化:Dev 使用 /src/main.ts,构建后改为 /assets/index.js -->
|
||||
<script type="module">
|
||||
import { kernel } from 'https://sdk.zguiy.com/zt/assets/index.js';
|
||||
|
||||
const config = {
|
||||
container: 'renderDom',
|
||||
modelUrlList: ['/public/model/model.glb'],
|
||||
env: '/public/model/model.glb',
|
||||
onSuccess: () => console.log('SDK initialized (module)'),
|
||||
onError: (err) => console.error('SDK init error', err),
|
||||
};
|
||||
|
||||
kernel.init(config);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
5
examples/public/config/animator.json
Normal file
5
examples/public/config/animator.json
Normal file
@ -0,0 +1,5 @@
|
||||
[
|
||||
{}
|
||||
|
||||
|
||||
]
|
||||
BIN
examples/public/favicon.ico
Normal file
BIN
examples/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
examples/public/hdr/hdr.env
Normal file
BIN
examples/public/hdr/hdr.env
Normal file
Binary file not shown.
BIN
examples/public/hdr/sanGiuseppeBridge.env
Normal file
BIN
examples/public/hdr/sanGiuseppeBridge.env
Normal file
Binary file not shown.
BIN
examples/public/model/model.glb
Normal file
BIN
examples/public/model/model.glb
Normal file
Binary file not shown.
BIN
examples/public/shuziren.png
Normal file
BIN
examples/public/shuziren.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
21
index.html
21
index.html
@ -20,9 +20,9 @@
|
||||
<canvas id="renderDom"></canvas>
|
||||
</div>
|
||||
|
||||
<script type="module">
|
||||
import { kernel } from '/src/main.ts';
|
||||
|
||||
<!-- 模块化加载(Dev 下通过 Vite,构建后 postbuild 会替换为 /assets/index.js) -->
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
<script>
|
||||
const config = {
|
||||
container: 'renderDom',
|
||||
modelUrlList: ["/model/model.glb"],
|
||||
@ -32,7 +32,20 @@
|
||||
onError: (err) => console.error('SDK init error', err),
|
||||
};
|
||||
|
||||
kernel.init(config);
|
||||
function startSdk() {
|
||||
const kernel = window.faceSDK && window.faceSDK.kernel;
|
||||
if (!kernel) {
|
||||
console.error('SDK kernel not loaded');
|
||||
return;
|
||||
}
|
||||
kernel.init(config);
|
||||
}
|
||||
|
||||
if (document.readyState === 'complete') {
|
||||
startSdk();
|
||||
} else {
|
||||
window.addEventListener('load', startSdk);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user