Skip to content

Commit

Permalink
add hotspot code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch-Shi committed Nov 18, 2020
1 parent 717bd99 commit e5a6f01
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
Binary file added Babylonjs/model/pic/C4_1_b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Babylonjs/model/pic/C4_2_b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Babylonjs/model/pic/bg.jpg
Binary file not shown.
20 changes: 15 additions & 5 deletions Babylonjs/script/controlscript/modelcontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ function hotSpot(modelname,picnum){
name = "1"
// let CoT = new BABYLON.TransformNode("root");
let advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("GUI", true, scene);
let mesh = scene.getTransformNodeByID("root");
//let mesh = scene.getTransformNodeByID(`${modelname}4_${picnum}`);
//let mesh = scene.getTransformNodeByID("root");
let mesh = scene.getTransformNodeByID(`${modelname}4_${picnum}`);
console.log(mesh)
// let hotSpotButton = BABYLON.GUI.Button.CreateImageOnlyButton(`HS_${name}`,`model/pic/btn${name}.jpg`)
let hotSpotButton = BABYLON.GUI.Button.CreateImageOnlyButton(`HS_${modelname}_${picnum}`,`model/pic/${modelname}4_${picnum}.png`)
hotSpotButton.width = "36px";
hotSpotButton.height = "36px";
hotSpotButton.width = "112px";
hotSpotButton.height = "27px";
hotSpotButton.thickness = 0;
advancedTexture.addControl(hotSpotButton);
hotSpotButton.linkWithMesh(mesh);
Expand All @@ -71,9 +71,19 @@ function hotSpot(modelname,picnum){
let modelHotSpotArr=['A','B','C'];
function initHotSpot(){
for(let i =0;i<modelHotSpotArr.length;i++){
for(let j=0;j<6;j++){
if(modelHotSpotArr[i]=='C')
{
for(let j=0;j<6;j++){
hotSpot(modelHotSpotArr[i],j+1)
}
hotSpot(modelHotSpotArr[i],'1_b')
hotSpot(modelHotSpotArr[i],'2_b')
}else{
for(let j=0;j<6;j++){
hotSpot(modelHotSpotArr[i],j+1)
}
}

}
}

Expand Down
4 changes: 2 additions & 2 deletions Babylonjs/script/controlscript/svganim.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,8 @@ function initscene() {
// setTimeout( ()=> {
initCamera();
initAnim(nextModelAnim);
loadPic();
initHotSpot()
// loadPic();
// initHotSpot()
// hotSpot();
// },1000)
// setTimeout(()=>{mouseEvenTimeOut = false},2000)
Expand Down

0 comments on commit e5a6f01

Please sign in to comment.