123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674 |
- var settings = {};
- settings["onstart"] = "trace('on start...')";
- settings["view.hlookat"] = 30;
- const house ={
- // curr_id:2,
- idx:0,
- // direction:'D4',
- nextId:null,
- isLoading:false,
- numLoaded:0,
- mode:'menu',
- is_auto_play:false,
- texture:{
- id:-1,
- curr:null,
- next:null,
- isloading:false,
- },
- config:{
- lat_step:10,
- lon_step:10,
- },
- title:"瑶里景区",
- src:[
- {id:1,name:"guzhen",title:'千年古镇',view:{lat: -1.7857185363769528,lon: -25.542864990234374},
- direction:[
- {id:2,name:'F',angle:{lat: -10, lon: 16.3},offset:180},
- {id:3,name:'R',angle:{lat: -13.7, lon: 75.3},offset:-70},
- {id:6,name:'B',angle:{lat: -13.7, lon: 75.3},offset:-70},
- {id:7,name:'L',angle:{lat: -13.7, lon: 75.3},offset:-70}
- ],
- // D1:{id:2,angle:{lat: -10, lon: 16.3},offset:180},
- // D2:{id:3,angle:{lat: -13.7, lon: 75.3},offset:-70},
- // D3:{id:6,angle:{lat: -13.7, lon: 75.3},offset:-70},
- // D4:{id:7,angle:{lat: -13.7, lon: 75.3},offset:-70},
- spots:[
- {name:'按1跳转至仿明清古桥',position:{x:135.02634001646553,y: -18.541531481188343,z: -256},rotation:{x:0,y:0,z:0}},
- {name:'按2跳转至服务区',position:{x: 255.99999999999997, y: -2.243401100489121, z: 40.86223734613961},rotation:{x:Math.PI/2,y:-Math.PI/3,z:Math.PI/2}},
- {name:'按3跳转至古城墙',position:{x: -256, y: -28.249801117197098, z: -1.42468348463467},rotation:{x:Math.PI/2,y:-Math.PI/6,z:Math.PI/2}},
- {name:'按4跳转至古树',position:{x: -79.95672966662912, y: -44.97558105439687, z: 256},rotation:{x:0,y:0,z:0}}
- ]
- },
- {id:2,name:"fangmingqingguqiao",title:'仿明清古桥',parent:1,view:{lat:-4.907144165039063,lon: 188.2071454},
- direction:[
- {id:null,name:'F'},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- ]
- },
- {id:3,name:"fuwuqu",title:'服务区',parent:1,view:{lat: -7.47857208 ,lon: 172.3500193},
- direction:[
- {id:4,name:'F',angle:{lat: -13.6, lon: 54},offset:180},
- {id:2,name:'B',angle:{lat: 2.7, lon: 16.7},offset:90},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- // {positio}
- {name:'按1跳转至程氏祠堂',position:{x: 255.99999999999997, y: -23.59033674128833, z: -13.384937948055738},rotation:{x:Math.PI/2,y:-Math.PI/6,z:Math.PI/2}},
- {name:'按2跳转至仿明清古桥',position:{x: -256, y: -28.566268036285038, z: -8.3744418975616},rotation:{x:Math.PI/2,y:-Math.PI/6,z:Math.PI/2}}
- ]
- },
- {id:4,name:"chengshicitang",title:'程氏祠堂',parent:3,view:{lat: -5.6571446 ,lon: 181.8857138},
- // D1:{id:5,angle:{lat: 0, lon: 13.5},offset:0},
- direction:[
- {id:5,name:'F',angle:{lat: 0, lon: 13.5},offset:0},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- {name:'按1跳转至陈毅居',position:{x: -255.99999999999997, y: -118.98430403698123, z: 4.6933538825472105},rotation:{x:Math.PI/2,y:-Math.PI/6,z:Math.PI/2}}
- ]
- },
- {id:5,name:"chenyiju",title:'陈毅居',parent:4,view:{lat: -14.0142883 ,lon:12.064304},
- direction:[
- {id:null,name:'F'},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- ]
- },
- {id:6,name:"guchengqiang",title:'古城墙',parent:1,view:{lat: -3.7285663 ,lon: -122.8285818},
- direction:[
- {id:null,name:'F'},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- ]
- },
- {id:7,name:"gushu",title:'古树',parent:1,view:{lat: -5.22857 ,lon:136.4571441},
- direction:[
- {id:null,name:'F'},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- ]
- },
- {id:8,name:"shoupiaochu",title:'售票处',view:{lat: -3.1928558 ,lon: 166.885716},
- // D1:{id:9,angle:{lat: -4.5, lon: -48},offset:-90},
- direction:[
- {id:9,name:'F',angle:{lat: -4.5, lon: -48},offset:-90},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- // {positio}
- {name:'按1跳转至仙人桥',position:{x: 32.05692316713218, y: -35.18905393081038, z: 256},rotation:{x:Math.PI/3,y:0,z:0}}
- ]
-
- },
- {id:9,name:"xianrenqiao",title:'仙人桥',parent:8,view:{lat: -18.621429 ,lon: 113.74286},
- // D1:{id:10,angle:{lat: 3.8, lon: -15},offset:-90},
- // D2:{id:11,angle:{lat: 3.8, lon: -15},offset:-90},
- direction:[
- {id:10,name:'F',angle:{lat: 3.8, lon: -15},offset:-90},
- {id:11,name:'B',angle:{lat: 3.8, lon: -15},offset:-90},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- {name:'按1跳转至南山瀑布',position:{x: -199.9938263054937, y: -59.49100505623731, z: 255.99999999999},rotation:{x:0,y:0,z:0}},
- {name:'按2跳转至仙女潭',position:{x: 130.25832756640813, y: -50.445126890140514, z: -256},rotation:{x:0,y:0,z:0}}
- ]
- },
- {id:10,name:"nanshanpubu",title:'南山瀑布',parent:9,view:{lat: -17.6571424484 ,lon: 163.35000},
- direction:[
- {id:null,name:'F'},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- ]
- },
- {id:11,name:"xiannvtan",title:'仙女潭',parent:9,view:{lat: -19.157145 ,lon: 40.564288},
- // D1:{id:12,angle:{lat: -2.8, lon: 17},offset:180},
- direction:[
- {id:12,name:'F',angle:{lat: -2.8, lon: 17},offset:180},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- {name:'按1跳转至开天辟地',position:{x: -209.73725040251847, y: -61.80104200737105, z: 256},rotation:{x:0,y:0,z:0}}
- ]
- },
- {id:12,name:"kaitianpidi",title:'开天辟地',parent:11,view:{lat: -14.9785 ,lon:214.242847},
- direction:[
- {id:null,name:'F'},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- ]
- },
- {id:13,name:"yaolihangpai",title:'瑶里航拍',view:{lat: -20.12143 ,lon: 121.24286255},
- // D1:{id:14,angle:{lat: 1.4, lon: 80},offset:180},
- // D2:{id:15,angle:{lat: 1.4, lon: 80},offset:180},
- // D3:{id:16,angle:{lat: 1.4, lon: 80},offset:180},
- // D4:{id:17,angle:{lat: 1.4, lon: 80},offset:180},
- direction:[
- {id:14,name:'F',angle:{lat: 1.4, lon: 80},offset:180},
- {id:15,name:'B',angle:{lat: 1.4, lon: 80},offset:180},
- {id:16,name:'L',angle:{lat: 1.4, lon: 80},offset:180},
- {id:17,name:'R',angle:{lat: 1.4, lon: 80},offset:180}
- ],
- spots:[
- {name:'按1跳转至瑶里航拍1',position:{x: -139.41044044624903, y: -68.33152420782919, z: 256},rotation:{x:0,y:0,z:0}},
- {name:'按2跳转至瑶里航拍2',position:{x: -256, y: -12.727990822231067, z: -110.34632793606},rotation:{x:Math.PI/2,y:-Math.PI/2,z:Math.PI/2}},
- {name:'按3跳转至瑶里航拍3',position:{x: 77.52461071027368, y: -31.160905545817563, z: -255.9999},rotation:{x:0,y:0,z:0}},
- {name:'按4跳转至瑶里航拍4',position:{x: 256, y: -46.42406470850259, z: 145.978111780317},rotation:{x:0,y:Math.PI/2,z:0}}
- ]
- },
- {id:14,name:"yaolihangpai1",title:'瑶里航拍1',parent:13,view:{lat: -11.442856979 ,lon: 110.1},
- direction:[
- {id:null,name:'F'},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- ]
- },
- {id:15,name:"yaolihangpai2",title:'瑶里航拍2',parent:13,view:{lat: -8.55 ,lon: 245.52856979},
- direction:[
- {id:null,name:'F'},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- ]
- },
- {id:16,name:"yaolihangpai3",title:'瑶里航拍3',parent:13,view:{lat:-18.407143 ,lon: 319.1357},
- direction:[
- {id:null,name:'F'},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- ]
- },
- {id:17,name:"yaolihangpai4",title:'瑶里航拍4',parent:13,view:{lat:-25.15764 ,lon: 39},
- direction:[
- {id:null,name:'F'},
- {id:null,name:'B'},
- {id:null,name:'L'},
- {id:null,name:'R'}
- ],
- spots:[
- ]
- },
- ],
- direction:[
- {id:1,name:"F",at:{x:0,y:0,z:-1}},
- {id:2,name:"B",at:{x:0,y:0,z:1}},
- {id:3,name:"L",at:{x:-1,y:0,z:0}},
- {id:4,name:"R",at:{x:1,y:0,z:0}}
- ],
- playList:{
- idx:0,
- orders:[
- {id:1},{id:2},{id:3},{id:4},{id:5},{id:6},{id:7},{id:8},{id:9},{id:10},{id:11},{id:12},
- {id:13},{id:14},{id:15},{id:16},{id:17}
- ]
- },
- menuList:[
- {id:1},{id:2},{id:3},{id:4},{id:5},{id:6},{id:7},{id:8},{id:9},{id:10},{id:11},{id:12},{id:13}
- ],
- menu_control_select:-1,
- zoom:{
- direction:0,
- step:30,
- is_selected:false,
- factor:1,
- status:'x0.9'
- },
- rotation:{
- is_auto:false,
- }
- }
- embedpano({ id: "krpanoSWFObject_",swf:"lib/tour.swf", xml:"js/tour.xml", target:"pano", html5:"auto", mobilescale:1.0,
- passQueryParameters:true, onready: krpanoReady, vars:settings});
- function krpanoReady(krpano){
- // var krpano = document.getElementById('krpanoSWFObject_');
- window.krpano = krpano
- changeTourMode()
- }
- function changeTourMode(){
- if(house.mode==='menu'){
- }else{
- }
- }
- function onKeyEvent(e){
- console.log('dccc')
- console.log(e)
- }
- init();
- animate();
- function init() {
- const queryString = window.location.search;
- const urlParams = new URLSearchParams(queryString);
- const panoId = urlParams.get('id')?urlParams.get('id'):0
- house.idx = panoId
- const backurl = urlParams.get('backurl')?urlParams.get('backurl'):'yaoli.html'
- house.backurl = backurl
- const scene_name = 'scene_' + house.src[house.idx ].name
- changeScene(scene_name)
- initMenu()
-
- document.addEventListener('mousedown', onPointerStart, false);
- document.addEventListener('mousemove', onPointerMove, false);
- document.addEventListener('mouseup', onPointerUp, false);
- document.addEventListener('wheel', onDocumentMouseWheel, false);
- document.addEventListener('touchstart', onPointerStart, false);
- document.addEventListener('touchmove', onPointerMove, false);
- document.addEventListener('touchend', onPointerUp, false);
-
- }
- // function updateDirection(){
- // for(let d of house.src[house.idx].direction){
-
- // switch(d.name){
- // case 'F':
- // if(d.id!=null){
- // document.getElementById("directionTop").innerHTML = house.src[d.id-1].title
- // // document.getElementById("directionTop").style.visibility = true
- // document.getElementById("direct_top").style.color = '#ffffff'
- // document.getElementById("direct_top_img").src = './yaoimages/direction_top.png'
- // }else{
- // document.getElementById("directionTop").innerHTML = ''
- // // document.getElementById("directionTop").style.visibility = false
- // document.getElementById("direct_top").style.color = '#c1c1c1'
- // document.getElementById("direct_top_img").src = './yaoimages/direction_top_disable.png'
- // }
- // break
- // case 'B':
- // if(d.id!=null){
- // document.getElementById("directionLeft").innerHTML = house.src[d.id-1].title
- // document.getElementById("direct_left").style.color = '#ffffff'
- // document.getElementById("direct_left_img").src = './yaoimages/direction_left.png'
- // }else{
- // document.getElementById("directionLeft").innerHTML = ''
- // document.getElementById("direct_left").style.color = '#c1c1c1'
- // document.getElementById("direct_left_img").src = './yaoimages/direction_left_disable.png'
- // }
- // break
- // case 'L':
- // if(d.id!=null){
- // document.getElementById("directionBottom").innerHTML = house.src[d.id-1].title
- // document.getElementById("direct_bottom").style.color = '#ffffff'
- // document.getElementById("direct_bottom_img").src = './yaoimages/direction_bottom.png'
- // }else{
- // document.getElementById("directionBottom").innerHTML = ''
- // document.getElementById("direct_bottom").style.color = '#c1c1c1'
- // document.getElementById("direct_bottom_img").src = './yaoimages/direction_bottom_disable.png'
- // }
- // break
- // case 'R':
- // if(d.id!=null){
- // document.getElementById("directionRight").innerHTML = house.src[d.id-1].title
- // document.getElementById("direct_right").style.color = '#ffffff'
- // document.getElementById("direct_right_img").src = './yaoimages/direction_right.png'
- // }else{
- // document.getElementById("directionRight").innerHTML = ''
- // document.getElementById("direct_right").style.color = '#c1c1c1'
- // document.getElementById("direct_right_img").src = './yaoimages/direction_right_disable.png'
- // }
- // break
- // default:
- // break
- // }
- // }
- // // }
- // changeSpots()
- // }
- // function directionBack(){
- // const parent_id = house.src[house.idx].parent
- // if(parent_id){
- // const idx = getIdxFromId(parent_id)
- // changeTexture(idx)
- // }
- // }
- // function createText(textWord){
- // let canvas = document.getElementById('textCanvas')
- // // let canvas = document.createElement('canvas')
- // canvas.width = 320
- // canvas.height = 60
- // let ctx = canvas.getContext('2d')
- // ctx.fillStyle = "#fffff0";
- // // // ctx.font = 'normal 24pt "Microsoft Yahei"'
- // // // // const name = clientZhou.country[clientZhou.idx].name
- // // // ctx.fillText(name, 120, 60)
- // // // let textWord = clientZhou.country[clientZhou.idx].description
- // ctx.font = 'normal 24pt "Microsoft Yahei"'
- // let len = parseInt(textWord.length / 35)
- // const offset = (320 - 30*parseInt(textWord.length))/2
- // for (let i = 0; i < (len + 1); i++) {
- // let space = (320 - 40*parseInt(textWord.length))/2
- // if (i === len) {
- // space = textWord.length - len * 35
- // }
- // let word = textWord.substr(i * 20, space)
- // ctx.fillText(word, offset, 15+35*(i+1))
- // }
- // let url = canvas.toDataURL('image/png')
- // let texture = new THREE.TextureLoader().load( url);
- // const tmaterial = new THREE.SpriteMaterial( {map:texture,transparent : true,opacity:1, side: THREE.DoubleSide} );
- // let text_plane2 = new THREE.Sprite( tmaterial );
- // text_plane2.scale.set(32,10,1);
- // // text_plane.position.set(30,30,30)
- // return text_plane2;
- // }
- function initMenu(){
- var menu=document.getElementById("menu");
- while (menu.firstChild) {
- menu.removeChild(menu.firstChild);
- }
- let mid = 0
- for(let item of house.menuList){
- const dpano = document.createElement("div");
- dpano.className = 'pano'
- // dpano.attr({'data-id':item.id})
- for(let i in house.src){
- if(house.src[i].id===item.id){
- mid = i
- break
- }
- }
- dpano.setAttribute('data-id',mid);
- const title = document.createElement("div");
- title.className = 'title'
- title.innerHTML = house.src[mid].title
- const thumb = document.createElement("div");
- thumb.className = 'thumb'
- // thumb.innerHTML = house.src[i].name
- const img=document.createElement("img");
- img.src= './thumb1k/'+house.src[mid].name + '1k_f.jpg';
- thumb.appendChild(img);
- dpano.appendChild(title);
- dpano.appendChild(thumb);
- menu.appendChild(dpano);
- }
- const ddiv = document.createElement("div");
- ddiv.innerHTML='-'
- ddiv.className = 'panoEnd'
- menu.appendChild(ddiv);
- var menuTitle=document.getElementById("menuTitle");
- menuTitle.innerHTML = house.title
- displayMenuNone()
- // house.menu_control_select = 0
- // const firstChild = document.getElementById('menu').firstChild
- // firstChild.className = 'panoSelect'
- // document.getElementById('menu').scrollLeft = 0
- }
- function displayMenu(){
- house.mode = 'menu'
- document.getElementById("menu").style.display='flex';
- //
- document.getElementById("menuTitle").style.display='flex';
- document.getElementById("menuControl").style.display='flex';
- document.getElementById("wholeDirection").style.display='none';
- const control = krpano.get("control");
- control.keybaccelerate =0
- krpano.set("control",control);
- }
- function displayMenuNone(){
- house.mode = 'full'
- document.getElementById("menu").style.display='none';
- // document.getElementById("menuTip").style.display='none';
- document.getElementById("menuTitle").style.display='none';
- document.getElementById("menuControl").style.display='none';
- document.getElementById("wholeDirection").style.display='flex';
- document.getElementById("menuTip").style.display='flex';
- setTimeout( function(){
- document.getElementById("menuTip").style.display='none';
- }, 5000 );
- house.zoom.is_selected = false
- house.zoom.status = 'zoom'
- document.getElementById('zoom').src="./yaoimages/zoomin.png"
- document.getElementById('zoom_title').innerHTML='放大'
- const control = krpano.get("control");
- control.keybaccelerate =0.5
- krpano.set("control",control);
- }
- // function doubleDelay(doubleCallback,callback,p){
- // timeId = setTimeout( function(){
- // if(Date.now()-delta<400){
- // for(let i in timeIds){
- // clearTimeout(timeIds[i])
- // }
- // // walkOn(d)
- // if(doubleCallback){
- // // doubleCallback()
- // }
- // }else{
- // // lookDirection(2)
- // callback(p)
- // }
- // }, 400 );
- // timeIds.push(timeId)
- // }
- function onKeyDown(e){
- // key_down_frequency++
- // delta = Date.now()
- // if(key_down_frequency>LONG_PRESS_TIMES){
- // switch(e.keyCode){
- // case 38://ArrowUp
- // lat +=1.5
- // break
- // case 40: //ArrowDown
- // lat -=1.5
- // break
- // case 37: //ArrowLeft
- // lon -= 1.5
- // break
- // case 39://ArrowRight
- // lon += 1.5
- // break
- // case 13://Enter
- // house.is_auto_play = true
- // break
- // default:
- // break
- // }
- // }
- }
- function arrowUp(){
- if(house.mode==='full'){
- // doubleDelay(walkingCamera,lookDirection,2)
- }else if(house.mode==='menu'){
- const nodess = document.getElementById("menu").childNodes;
- for(let i =0;i<nodess.length-1;i++){
- if(nodess[i].className==='panoSelect'){
- nodess[i].className = 'pano'
- }
- }
- switch(house.menu_control_select){
- case -1:
- case 0:
- // zoom
- house.menu_control_select = 1
- house.zoom.status = 'x1'
- house.zoom.is_selected = true
- document.getElementById('zoom').src="./yaoimages/zoomin_click.png"
- document.getElementById('zoom_title').innerHTML='x1'
- break
- case 1:
- // rotation
- console.log('house.zoom.status=',house.zoom.status)
- if(house.zoom.status==='zoom'||house.zoom.status==='x1'||house.zoom.status==='x0.9'){
- house.menu_control_select = 2
- house.rotation.is_auto = true
- document.getElementById('auto_rotation').src="./yaoimages/auto_rotation_click.png"
- house.zoom.is_selected = false
- house.zoom.status = 'zoom'
- document.getElementById('zoom').src="./yaoimages/zoomin.png"
- document.getElementById('zoom_title').innerHTML='放大'
- }
-
- break
- default:
- break
- }
- }
- }
- function arrowDown(){
- if(house.mode==='full'){
- // doubleDelay(null,lookDirection,1)
- }else if(house.mode==='menu'){
- if(house.rotation.is_auto==true){
- house.rotation.is_auto==false
- document.getElementById('auto_rotation').src="./yaoimages/auto_rotation.png"
- }
- const nodess = document.getElementById("menu").childNodes;
- for(let i =0;i<nodess.length-1;i++){
- if(nodess[i].className==='panoSelect'){
- nodess[i].className = 'pano'
- }
- }
- switch(house.menu_control_select){
- case -1:
- case 1:
- // menu
- if(house.zoom.status==='zoom'||house.zoom.status==='x0.9'||house.zoom.status==='x1'){
- house.menu_control_select = 0
- const firstChild = document.getElementById('menu').firstChild
- firstChild.className = 'panoSelect'
- document.getElementById('menu').scrollLeft = 0
- house.zoom.is_selected = false
- house.zoom.status = 'zoom'
- document.getElementById('zoom').src="./yaoimages/zoomin.png"
- document.getElementById('zoom_title').innerHTML='放大'
- }
- break
- case 2:
- // zoom
- house.menu_control_select = 1
- house.zoom.is_selected = true
- house.zoom.status = 'x1'
- document.getElementById('zoom').src="./yaoimages/zoomin_click.png"
- document.getElementById('zoom_title').innerHTML='x1'
- break
- default:
- break
- }
- }
- }
- function arrowLeft(){
- if(house.mode==='full'){
- }else if(house.mode==='menu'){
- let pano_select = -1
- const nodess = document.getElementById("menu").childNodes;
- for(let i =0;i<nodess.length-1;i++){
- if(nodess[i].className==='panoSelect'){
- pano_select=i===0?nodess.length -2:i-1
- nodess[i].className = 'pano'
- nodess[pano_select].className = 'panoSelect'
- const fromLeft = document.getElementById('menu').scrollLeft
- const toLeft = 270*pano_select;
- const coords = {x: fromLeft, y: 0} // Start at (0, 0)
- const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
- .to({x: toLeft, y: 200}, 1000) // Move to (300, 200) in 1 second.
- .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
- .onUpdate(() => {
- // Called after tween.js updates 'coords'.
- // Move 'box' to the position described by 'coords' with a CSS translation.
- document.getElementById('menu').scrollLeft = coords.x
- })
- .start() // Start the tween immediately.
- i = nodess.length
-
- }
- }
- }
- }
- function arrowRight(){
- if(house.mode==='full'){
- }else if(house.mode==='menu'){
- let pano_select = -1
- const nodess = document.getElementById("menu").childNodes;
- for(let i =0;i<nodess.length-1;i++){
- if(nodess[i].className==='panoSelect'){
- pano_select=nodess.length-2===i?0:i+1
- // document.getElementById('menu').scrollLeft =270*pano_select;
- const fromLeft = document.getElementById('menu').scrollLeft
- const toLeft = 270*pano_select;
- const coords = {x: fromLeft, y: 0} // Start at (0, 0)
- const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
- .to({x: toLeft, y: 200}, 1000) // Move to (300, 200) in 1 second.
- .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
- .onUpdate(() => {
- // Called after tween.js updates 'coords'.
- // Move 'box' to the position described by 'coords' with a CSS translation.
- document.getElementById('menu').scrollLeft = coords.x
- })
- .start() // Start the tween immediately.
- nodess[i].className = 'pano'
- nodess[pano_select].className = 'panoSelect'
- i = nodess.length
- }
- }
- }
- }
- window.onMenuEvent= function(){
- changeMode()
- // if(model==='full'){
- // }else if(model==='menu'){
- // }
- }
- function onKeyUp(e){
- // if(key_down_frequency<LONG_PRESS_TIMES){
-
- // }
- // key_down_frequency = 0
- }
- function onPointerStart(event) {
- // isUserInteracting = true;
- // if(is_pc){
- // // pauseEvent(event)
- // }
- // var clientX = event.clientX || event.touches[0].clientX;
- // var clientY = event.clientY || event.touches[0].clientY;
- // onMouseDownMouseX = clientX;
- // onMouseDownMouseY = clientY;
- // onMouseDownLon = lon;
- // onMouseDownLat = lat;
- }
- function onPointerMove(event) {
- // if (isUserInteracting === true) {
- // var clientX = event.clientX || (typeof(event.touches)!=='undefined'?event.touches[0].clientX:0);
- // var clientY = event.clientY || (typeof(event.touches)!=='undefined'?event.touches[0].clientY:0);
- // // lon = (onMouseDownMouseX - clientX) * 0.1 + onMouseDownLon;
- // // lat = (clientY - onMouseDownMouseY) * 0.1 + onMouseDownLat;
- // if(model==='full'){
- // lon = (onMouseDownMouseX - clientX) * 0.075 + onMouseDownLon;
- // lat = (clientY - onMouseDownMouseY) * 0.075 + onMouseDownLat;
- // }else if(model==='menu'){
- // const deltaX = (onMouseDownMouseX - clientX) * 0.031
- // const fromLeft = document.getElementById('menu').scrollLeft
- // const toLeft = fromLeft + deltaX
- // document.getElementById('menu').scrollLeft = toLeft
- // }
- // }
- }
- function onPointerUp() {
- // isUserInteracting = false;
- // mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
- // mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
-
- // onRay()
- }
- function onRay() {
- // update the picking ray with the camera and mouse position
- // raycaster.setFromCamera( mouse, camera );
- // // calculate objects intersecting the picking ray
- // const intersects = raycaster.intersectObjects( scene.children );
- // if(intersects.length>0){
- // // console.log(intersects[0])
- // }
- }
- function onDocumentMouseWheel(event) {
- // var fov = camera.fov + event.deltaY * 0.05;
- // camera.fov = THREE.MathUtils.clamp(fov, 15, 75);
- // camera.updateProjectionMatrix();
- }
- function IsPC(){
- var userAgentInfo = navigator.userAgent;
- var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
- var flag = true;
- for (var v = 0; v < Agents.length; v++) {
- if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
- }
- return flag;
- }
- //------------------------------------------
- function walkOn(d){
- // // const arr = ['F','B','L','R']
- // let next_d = d
- // if(typeof(d) == 'string'){
- // for(let dd of house.src[house.idx].direction){
- // if(dd.name===d){
- // next_d = dd
- // break
- // }
- // }
- // }
- // const nextId = next_d
- // if(nextId&&!house.isLoading){
- // const idx = getIdxFromId(nextId.id)
- // // changeTexture(idx)
- // preChangeTexture(idx)
- // }else{
- // moveNull()
- // }
- }
- //------------------------------------------------------
- function preChangeTexture(idx){
- // if(idx>=0){
- // for(let i=spotGroup.children.length-1;i>=0;i--){
- // spotGroup.remove(spotGroup.children[i])
- // }
-
- // house.numLoaded = 0
- // house.isLoading = true
- // // document.getElementById('tip').style.display = 'flex'
-
- // preUpdateFaceTexture(idx,'f')
- // preUpdateFaceTexture(idx,'b')
- // preUpdateFaceTexture(idx,'l')
- // preUpdateFaceTexture(idx,'r')
- // preUpdateFaceTexture(idx,'u')
- // preUpdateFaceTexture(idx,'d')
- // }
- }
- function preUpdateFaceTexture(idx, face){
- // const imgPath = house.src[idx].name +"1k_"+face+'.jpg'
- // // load a resource
- // loader.load(
- // // resource URL
- // imgPath,
- // // onLoad callback
- // function ( texture ) {
- // house.numLoaded++
- // updateFaceMaterial(texture,face)
- // if(house.numLoaded===mesh.material.length){
- // house.numLoaded = 0
- // // updateFaceCamera(texture,idx,face)
- // // changeTexture(idx)
- // changeTexture2k(idx)
- // }
- // },
- // // onProgress callback currently not supported
- // undefined,
- // // onError callback
- // function ( err ) {
- // console.error( 'An error happened.' );
- // }
- // );
- }
- function changeTexture2k(idx){
- // for(let i=spotGroup.children.length-1;i>=0;i--){
- // spotGroup.remove(spotGroup.children[i])
- // }
- // house.numLoaded = 0
- // house.isLoading = true
- // // document.getElementById('tip').style.display = 'flex'
- // updateFaceTexture2k(idx,'f')
- // updateFaceTexture2k(idx,'b')
- // updateFaceTexture2k(idx,'l')
- // updateFaceTexture2k(idx,'r')
- // updateFaceTexture2k(idx,'u')
- // updateFaceTexture2k(idx,'d')
- }
- function updateFaceTexture2k(idx, face){
- // const imgPath = house.src[idx].name +"2k_"+face+'.jpg'
- // // load a resource
- // loader.load(
- // // resource URL
- // imgPath,
- // // onLoad callback
- // function ( texture ) {
- // house.numLoaded++
- // updateFaceMaterial(texture,face)
- // if(house.numLoaded===mesh.material.length){
- // house.numLoaded=0
- // // updateFaceCamera(texture,idx,face)
- // changeTexture(idx)
- // }
- // },
- // // onProgress callback currently not supported
- // undefined,
- // // onError callback
- // function ( err ) {
- // console.error( 'An error happened.' );
- // }
- // );
- }
- function changeTexture(idx){
- // for(let i=spotGroup.children.length-1;i>=0;i--){
- // spotGroup.remove(spotGroup.children[i])
- // }
- // house.numLoaded = 0
- // house.isLoading = true
- // // document.getElementById('tip').style.display = 'flex'
- // updateFaceTexture(idx,'f')
- // updateFaceTexture(idx,'b')
- // updateFaceTexture(idx,'l')
- // updateFaceTexture(idx,'r')
- // updateFaceTexture(idx,'u')
- // updateFaceTexture(idx,'d')
- }
- function updateFaceTexture(idx, face){
- // const imgPath = house.src[idx].name +"8k_"+face+'.jpg'
- // // load a resource
- // loader.load(
- // // resource URL
- // imgPath,
- // // onLoad callback
- // function ( texture ) {
- // house.numLoaded++
- // updateFaceMaterial(texture,face)
- // if(house.numLoaded===mesh.material.length){
- // updateFaceCamera(texture,idx,face)
- // }
- // },
- // // onProgress callback currently not supported
- // undefined,
- // // onError callback
- // function ( err ) {
- // console.error( 'An error happened.' );
- // }
- // );
- }
- function updateFaceMaterial(texture,face){
- // for(let i=0;i<mesh.material.length;i++){
- // if(mesh.material[i].name===face){
- // mesh.material[i].map.dispose()
- // mesh.material[i].map = texture
- // mesh.material[i].map.needsUpdate = true;
- // i=mesh.material.length
- // }
- // }
- }
- function range360(a){
- while(a>180){
- a -=360
- }
- while(a<-180){
- a +=360
- }
- return a
- }
- function moveNull(){
- // const coords = {x: camera.fov, y: 0} // Start at (0, 0)
- // const fov = camera.fov-5
- // const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
- // .to({x:fov,y:0}, 400) // Move to (300, 200) in 1 second.
- // .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
- // .onUpdate((e,t) => {
- // camera.fov = coords.x
- // camera.updateProjectionMatrix();
- // })
- // .onComplete(()=>{
- // moveNullBack()
- // })
- // .start() // Start the tween immediately.
- }
- function moveNullBack(){
- // lookZoom(5,400)
- }
- function lookZoom(z=5,t=600){
- // const fromX = camera.fov
- // const coords = {x: fromX, y: 0} // Start at (0, 0)
- // const toX = camera.fov + z
- // const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
- // .to({x:toX,y:0}, t) // Move to (300, 200) in 1 second.
- // .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
- // .onUpdate((e,t) => {
- // camera.fov = coords.x
- // camera.updateProjectionMatrix();
- // })
- // .start() // Start the tween immediately.
- }
- // direction 1/up 2/down 3/left 4/right
- function lookDirection(d=1){
- // const fromX = d===1||d===2?lat:lon
- // const coords = {x: fromX, y: 0} // Start at (0, 0)
- // const toX = d===1?lat-house.config.lat_step:d===2?lat+house.config.lat_step:d===3?lon-house.config.lon_step:lon+house.config.lon_step
- // const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
- // .to({x:toX,y:0}, 600) // Move to (300, 200) in 1 second.
- // .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
- // .onUpdate((e,t) => {
- // if(d===1||d===2){
- // lat = coords.x
- // }else{
- // lon = coords.x
- // }
-
- // })
- // .start() // Start the tween immediately.
- }
- function updateMapPoint(){
- // const idx = house.idx
- // let id = -1
- // var points=document.getElementById("redPoints");
- // while (points.firstChild) {
- // points.removeChild(points.firstChild);
- // }
- // // points.remove();
- // if(house.src[idx].D1){
- // id = house.src[idx].D1.id - 1
- // createMapPoint(id)
- // }
- // if(house.src[idx].D2){
- // id = house.src[idx].D2.id - 1
- // createMapPoint(id)
- // }
- // if(house.src[idx].D3){
- // id = house.src[idx].D3.id - 1
- // createMapPoint(id)
- // }
- // if(house.src[idx].D4){
- // id = house.src[idx].D4.id - 1
- // createMapPoint(id)
- // }
- }
- function createMapPoint(id){
- // const top = house.src[id].home.T
- // const right = house.src[id].home.D2
-
- // const img=document.createElement("img");
- // img.src="panos/redPoint.png";
- // img.style.position = 'absolute'
- // img.style.top = top +15+ 'px';
- // img.style.right = right-5+ 'px';
- // img.style.width = 8+ 'px';
- // img.style.height = 8+ 'px';
- // const points=document.getElementById("redPoints");
- // points.appendChild(img);
- }
- function getIdxFromId(id){
- let idx = -1
- for(const item in house.src){
- if(house.src[item].id===id){
- idx = item
- break
- }
- }
- return idx
- }
- function animate() {
- requestAnimationFrame(animate);
- TWEEN.update()
- // update();
- }
- function update() {
- // // controls.update();
- // if (isUserInteracting === false) {
- // // lon += 0.1;
- // }
- // if(house.is_auto_play){
- // // if(lon>360&&!house.texture.isloading){
- // if(lon>360&&!house.isloading){
- // lon = 0
- // // house.idx++
- // // if(house.idx>=house.src.length){
- // // house.idx = 0
- // // }
- // house.playList.idx++
- // if(house.playList.idx>=house.playList.orders.length){
- // house.playList.idx = 0
- // }
- // for(let i in house.src){
- // if(house.src[i].id===house.playList.orders[house.playList.idx].id){
- // house.idx = i
- // break
- // }
- // }
- // // house.idx = house.playList.orders[house.playList.idx].id-1
- // autoUpdateMaterial(house.idx)
- // }else{
- // lon += 0.2;
- // }
- // }
- // lat = Math.max(-85, Math.min(85, lat));
- // phi = THREE.MathUtils.degToRad(90 - lat);
- // theta = THREE.MathUtils.degToRad(lon);
- // camera.target.x = 512 * Math.sin(phi) * Math.cos(theta);
- // camera.target.y = 512 * Math.cos(phi);
- // camera.target.z = 512 * Math.sin(phi) * Math.sin(theta);
- // // updateHome()
- // camera.lookAt(camera.target);
-
- // renderer.render(scene, camera);
- }
- window.onBackEvent= function(){
-
- }
- var btn = new tvSysBtnBind({
- id: "Jdoc",
- className: "ctrlBtn",
- currentClass: "current",
- keyRemoveDefault: false,
- effect: "base",
- currentIndex: 0,
- onLoad: function(e) {
- // console.log(e);
- },
- onPress:function() {
- var keyCode = this.event.keyCode;
- // console.log('keyCode:'+keyCode)
- switch (keyCode) {
- case 37: // left
- // reloadData();
- arrowLeft()
- break;
- case 39: // right
- arrowRight()
- break;
- case 38: //up
- arrowUp()
- break;
- case 40: //down
- arrowDown()
- break;
- // case 13: //enter
-
- // break;
- case 33: //chanel +
-
- break;
- case 34: //chanel -
-
- break;
- case 48: //0
- // console.log('ddddd')
- // displayMenu()
- break;
- case 49://1
- walkingOn('F')
- break
- case 50://2
- walkingOn('B')
- break
- case 51://3
- walkingOn('L')
- break
- case 52://4
- walkingOn('R')
- case 52: //4
- break;
- case 53: //5
-
- break;
- case 54: //6
- break;
- case 55: //7
- break;
- case 57: //9
- changeMode()
- break;
- default:
- break;
- }
- playAudio()
- },
- onEnterPress: function() {
- changeMode()
- },
- onBack: function() {
- if(house.is_auto_play){
- house.is_auto_play = false
- }else{
- if(house.mode==='menu'){
-
- displayMenuNone()
- }else{
- // window.location.href="index2.html?id="+house.idx
- const url = "index.html?id="+house.idx +"&backurl="+house.backurl
- window.location.href = url
- // VrBrowserToJS.vrBrowerExit()
- }
- }
-
- }
- });
- //----------------------------------------------
- function makeZoom(tfov){
- var fov = Number( krpano.get("view.fov") );
- const t_fov = tfov
- // krpano.set("view.fov", fov);
- console.log('fov',fov,'tfov',tfov)
- const coords= {x:fov}
- const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
- .to({x:t_fov}, 500) // Move to (300, 200) in 1 second.
- .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
- .onUpdate((e,t) => {
- // camera.fov = coords.x
- // camera.updateProjectionMatrix();
- krpano.set("view.fov", coords.x);
- })
- .onComplete(()=>{
- })
- .start() // Start the tween immediately.
- }
- // function zoomOut(){
- // makeZoom(75)
- // }
- // function zoomIn(){
- // makeZoom(30)
- // }
- function makeRotationAuto(is_auto){
- krpano.set('autorotate.enabled',is_auto)
- }
- function changeScene(scene_name){
- krpano.call("loadscene("+scene_name+",null,MERGE,BLEND(1));");
- updateDirection()
- changeAudio()
- }
- function changeMode(){
- if(house.mode==='full'){
- fullMode()
- }else{
- menuMode()
- }
- }
- function menuMode(){
- if(house.mode=='menu'){
- if(house.menu_control_select==0||house.menu_control_select == -1){
- displayMenuNone()
- let pano_select = -1
- const nodess = document.getElementById("menu").childNodes;
- for(let i =0;i<nodess.length;i++){
- if(nodess[i].className==='panoSelect'){
- pano_select=nodess[i].getAttribute('data-id')
- i = nodess.length
- house.idx = pano_select
- }
- }
- // autoUpdateMaterial(house.idx)
- const scene_name = 'scene_'+house.src[house.idx].name
- changeScene(scene_name)
- }else if(house.menu_control_select==1){ // zoom
- let zoom_title = 0
- let zoom_image = 0
- switch(house.zoom.status){
- case 'zoom':
- zoom_title = '放大'
- house.zoom.status = 'x0.9'
- house.zoom.direction = 1
- house.zoom.factor = 1 // 1.5
- zoom_image="./yaoimages/zoomin.png"
- house.menu_control_select=0
- break
- case 'x0.9':
- zoom_title = 'x1'
- house.zoom.status = 'x1'
- house.zoom.direction = 1
- house.zoom.factor = 1 // 1.5
- zoom_image="./yaoimages/zoomin_click.png"
- break
- case 'x1':
- zoom_title = 'x1.5'
- house.zoom.status = 'x1.5'
- house.zoom.direction = 1
- house.zoom.factor = 1.5 // 1.5
- zoom_image="./yaoimages/zoomin_click.png"
- break
- case 'x1.5':
- zoom_title = 'x2'
- house.zoom.status = 'x2'
- house.zoom.direction = 1
- house.zoom.factor = 2
- house.zoom.is_selected = false // 1
- zoom_image="./yaoimages/zoomout_click.png"
- break
- case 'x2':
- zoom_title = 'x1.5'
- house.zoom.status = 'x-1.5'
- house.zoom.direction = -1
- house.zoom.factor = 1.5
- house.zoom.is_selected = false // 1
- zoom_image="./yaoimages/zoomout_click.png"
- break
- case 'x-1.5':
- zoom_title = 'x1'
- house.zoom.status = 'zoom'
- house.zoom.direction = -1
- house.zoom.factor = 1
- house.zoom.is_selected = false // 1
- zoom_image="./yaoimages/zoomout_click.png"
- break
- case 'x-1':
- zoom_title = 'zoom'
- house.zoom.status = 'zoom'
- house.zoom.direction = 0
- house.zoom.factor = 1
- house.zoom.is_selected = false // 1
- zoom_image="./yaoimages/zoomout_click.png"
- break
- default:
- break
- }
-
- document.getElementById('zoom_title').innerHTML=zoom_title
- document.getElementById('zoom').src=zoom_image
- let fov = house.zoom.factor==1?120:house.zoom.factor==2?30:75
- console.log('fov',fov)
- makeZoom(fov)
- }else if(house.menu_control_select==2){ //rotation
- displayMenuNone()
- house.is_auto_play = true
- house.menu_control_select=0
- makeRotationAuto(true)
- }else{
- }
-
- }
- }
- function fullMode(){
- if(house.is_auto_play){
- house.is_auto_play = false
- if(house.rotation.is_auto==true){
- house.rotation.is_auto==false
- document.getElementById('auto_rotation').src="./yaoimages/auto_rotation.png"
- }
- makeRotationAuto(false)
- }
- const nodess = document.getElementById("menu").childNodes;
- for(let i =0;i<nodess.length-1;i++){
- if(nodess[i].getAttribute('data-id')===house.idx){
- nodess[i].className = 'panoSelect'
- const fromLeft = document.getElementById('menu').scrollLeft
- const toLeft = 270*i;
- const coords = {x: fromLeft, y: 0} // Start at (0, 0)
- const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
- .to({x: toLeft, y: 200}, 1000) // Move to (300, 200) in 1 second.
- .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
- .onUpdate(() => {
- // Called after tween.js updates 'coords'.
- // Move 'box' to the position described by 'coords' with a CSS translation.
- document.getElementById('menu').scrollLeft = coords.x
- })
- .start() // Start the tween immediately.
-
- } else{
- nodess[i].className = 'pano'
- }
- }
- displayMenu()
- }
- function updateDirection(){
- for(let d of house.src[house.idx].direction){
-
- switch(d.name){
- case 'F':
- if(d.id!=null){
- document.getElementById("directionTop").innerHTML = house.src[d.id-1].title
- document.getElementById("direct_top").style.color = '#ffffff'
- document.getElementById("direct_top_img").src = './yaoimages/direction_top.png'
- }else{
- document.getElementById("directionTop").innerHTML = ''
- document.getElementById("direct_top").style.color = '#c1c1c1'
- document.getElementById("direct_top_img").src = './yaoimages/direction_top_disable.png'
- }
- break
- case 'B':
- if(d.id!=null){
- document.getElementById("directionLeft").innerHTML = house.src[d.id-1].title
- document.getElementById("direct_left").style.color = '#ffffff'
- document.getElementById("direct_left_img").src = './yaoimages/direction_left.png'
- }else{
- document.getElementById("directionLeft").innerHTML = ''
- document.getElementById("direct_left").style.color = '#c1c1c1'
- document.getElementById("direct_left_img").src = './yaoimages/direction_left_disable.png'
- }
- break
- case 'L':
- if(d.id!=null){
- document.getElementById("directionBottom").innerHTML = house.src[d.id-1].title
- document.getElementById("direct_bottom").style.color = '#ffffff'
- document.getElementById("direct_bottom_img").src = './yaoimages/direction_bottom.png'
- }else{
- document.getElementById("directionBottom").innerHTML = ''
- document.getElementById("direct_bottom").style.color = '#c1c1c1'
- document.getElementById("direct_bottom_img").src = './yaoimages/direction_bottom_disable.png'
- }
- break
- case 'R':
- if(d.id!=null){
- document.getElementById("directionRight").innerHTML = house.src[d.id-1].title
- document.getElementById("direct_right").style.color = '#ffffff'
- document.getElementById("direct_right_img").src = './yaoimages/direction_right.png'
- }else{
- document.getElementById("directionRight").innerHTML = ''
- document.getElementById("direct_right").style.color = '#c1c1c1'
- document.getElementById("direct_right_img").src = './yaoimages/direction_right_disable.png'
- }
- break
- default:
- break
- }
- }
- // }
- }
- function walkingOn(d){
- let next_d = d
- if(typeof(d) == 'string'){
- for(let dd of house.src[house.idx].direction){
- if(dd.name===d){
- next_d = dd
- break
- }
- }
- }
- if(next_d&&typeof(next_d.id)!='undefined'&&next_d.id){
- house.idx = next_d.id - 1
- const scene_name = 'scene_' + house.src[house.idx].name
- changeScene(scene_name)
- }else{
- console.log('no walking')
- }
- }
- function changeAudio(){
- const bgAudio = document.getElementById('bgAudio')
- switch(house.src[house.idx].name){
- case 'fangmingqingguqiao':
- bgAudio.src="./audio/fangmingqingshigongqiao.mp3"
- break
- case 'chengshicitang':
- bgAudio.src="./audio/chenshizongci.mp3"
- break
- default:
- bgAudio.src="./audio/bg.mp3"
- break
- }
- }
- function playAudio(){
- const bgAudio = document.getElementById('bgAudio')
- if(bgAudio.paused){
- bgAudio.play()
- }
- }
|