我们可以添加热点给模型添加点击高亮,也可以自己写脚本控制模型高亮
const button1 = document.getElementById('btn1');
const button2 = document.getElementById('btn2');
Hydreigon.ModelViewer.create(document.body, {
"autoStart": true,
"scenes": [{
"url": "https://hydreigon-publish.cdn.bcebos.com/sdk-index/assets/model/RobotExpressive.glb",
"offset": [0, -10, 0]
}]
}).then(app => {
app.addEventListener('mount', () => {
const leftHand = Hydreigon.ModelViewer.findChildByName(app.model.scene, 'Hand.L_0');
const rightHand = Hydreigon.ModelViewer.findChildByName(app.model.scene, 'Hand.R_0');
const id1 = Symbol();
const id2 = Symbol();
button1.onclick = () => {
let time = 0;
app.logicLoop.remove(id1);
app.logicLoop.add(() => {
time += Math.PI / 1000 * 50 / 3;
Hydreigon.ModelViewer.emissiveMesh(leftHand, time, [1, 1, 0]);
if (time >= Math.PI * 3) {
app.logicLoop.remove(id1);
}
}, id1);
};
button2.onclick = () => {
let time = 0;
app.logicLoop.remove(id2);
app.logicLoop.add(() => {
time += Math.PI / 1000 * 50 / 3;
Hydreigon.ModelViewer.emissiveMesh(rightHand, time, [0, 1, 1]);
if (time >= Math.PI * 3) {
app.logicLoop.remove(id2);
}
}, id2);
};
});
});