diff --git a/assets/百叶1.glb b/assets/百叶1.glb new file mode 100644 index 0000000..da9daf3 Binary files /dev/null and b/assets/百叶1.glb differ diff --git a/assets/百叶2.glb b/assets/百叶2.glb new file mode 100644 index 0000000..dc62dd4 Binary files /dev/null and b/assets/百叶2.glb differ diff --git a/assets/百叶3.glb b/assets/百叶3.glb new file mode 100644 index 0000000..9d58ad8 Binary files /dev/null and b/assets/百叶3.glb differ diff --git a/assets/百叶4.glb b/assets/百叶4.glb new file mode 100644 index 0000000..1a9b6b4 Binary files /dev/null and b/assets/百叶4.glb differ diff --git a/examples/btn_热点.png b/examples/btn_热点.png new file mode 100644 index 0000000..704efe7 Binary files /dev/null and b/examples/btn_热点.png differ diff --git a/examples/global-demo.html b/examples/global-demo.html index 304b183..9dfcdf1 100644 --- a/examples/global-demo.html +++ b/examples/global-demo.html @@ -62,6 +62,29 @@ sdkKernel.on('model:click', (data) => { console.log('模型点击事件', data); }); + sdkKernel.on('all:ready', (data) => { + console.log('所有模块加载完,', data); + sdkKernel.material.apply({ + target: 'Material__2', + attribute: 'alpha', + value: 0.5, + }); + + + sdkKernel.hotspot.render([ + { + id: "h1", + name: "卷帘门", + meshName: "Valve_01", + icon: "https://bpic.588ku.com/element_pic/20/06/30/d1046b01afc0b9586844350d131f4daf.jpg!/fw/253/quality/90/unsharp/true/compress/true", + offset: [25, 25, 0], + radius: 20, + color: "#21c7ff", + payload: { type: "valve", code: "A" }, + }, + ]); + }); + }
- - + // const config = { + // container: document.querySelector('#renderDom'), + // modelUrlList: ['/assets/model.glb'], + // env: { envPath: '/assets/hdr.env', intensity: 1.2, rotationY: 0.3, background: false }, + // }; - - + + kernel.on('model:loaded', (data) => { + console.log('模型加载完成', data); + // 隐藏进度条 + const progressContainer = document.getElementById('progress-container'); + if (progressContainer) { + progressContainer.style.display = 'none'; + } + + + + }); + + kernel.on('all:ready', (data) => { + console.log('所有模块加载完,', data); + kernel.material.apply({ + target: 'Material__2', + attribute: 'alpha', + value: 0.5, + }); + + + kernel.hotspot.render([ + { + id: "h1", + name: "卷帘门", + meshName: "Valve_01", + icon: "./btn_热点.png", + offset: [25, 25, 0], + radius: 20, + color: "#21c7ff", + payload: { type: "valve", code: "A" }, + }, + ]); + }); + + + kernel.on('model:click', (data) => { + console.log('模型点击事件', data); + console.log(data); + + }); + + kernel.on('hotspot:click', (data) => { + console.log('热点被点击:', data); + const { id, name } = data + if (name === "卷帘门") { + kernel.door.toggle({ upY: 28, downY: 0, speed: 12 }); + + // Y轴剖切,只作用于卷帘门网格,保留下方,剖掉上方 + const clipHeight = 28; // 调整这个值找到合适的剖切高度 + console.log('设置剖切:', clipHeight); + kernel.clipping.setY(clipHeight, true, ['Box005.001', 'Box006.001']); + } + }); + + + // 添加模型到场景 + await kernel.model.add('/models/car.glb'); + + // 销毁模型 + kernel.model.destroy('car'); + + // 替换模型 + await kernel.model.replace('car', '/models/new-car.glb'); + + +diff --git a/examples/module-demo.html b/examples/module-demo.html index bdf2c33..6da9084 100644 --- a/examples/module-demo.html +++ b/examples/module-demo.html @@ -2,70 +2,185 @@
- - -
+ + +
+