Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
auto load first scene if scene is not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshu committed Aug 8, 2017
1 parent 2d26b17 commit feaa788
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dist/vue-krpano.common.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/vue-krpano.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-krpano",
"version": "1.5.1",
"version": "1.5.2",
"description": "",
"main": "dist/vue-krpano.common.js",
"scripts": {
Expand Down
34 changes: 19 additions & 15 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ let config = {
},
...krpanoProps
},
data(){
data() {
return {
createLock: false,
krpanoObjId: "krpano_" + Math.floor(Math.random() * (100000 - 100 + 1) + 100)
};
},
methods: {
createPano(){
createPano() {

if (!this.createLock && !this.krpanoObj) {
this.createLock = true;
Expand All @@ -57,40 +57,44 @@ let config = {
fakedevice: this.fakedevice,
passQueryParameters: this.passQueryParameters,
webglsettings: this.webglsettings,
onready(krpanoObj){
onready(krpanoObj) {
vm.krpanoObj = krpanoObj;
vm.krpanoObj.hooks = vm.hooks;
vm.log("pano created");
vm.$emit("panoCreated", vm.krpanoObj);
vm.createLock = false;
},
onerror(msg){
onerror(msg) {
vm.$emit("panoError", msg);
vm.createLock = false;
}
});
}
},
removePano(){
removePano() {
if (this.krpanoObj) {
removepano(this.krpanoObj.id);
this.log("pano removed");
delete this.krpanoObj;
}
},
loadScene(){
loadScene() {
let scene = this.scene;
if (this.krpanoObj && scene) {
let str = `if(scene[${scene}]===null,
if (this.krpanoObj) {
if (scene) {
let str = `if(scene[${scene}]===null,
loadscene(get(scene[0].name),null,MERGE,BLEND(0.5)),
loadscene(${scene},null,MERGE,BLEND(0.5)))`;
this.krpanoObj.call(str);
this.krpanoObj.call(str);
this.log("scene changed: " + scene);
this.$emit("sceneChanged", scene);

this.log("scene changed: " + scene);
this.$emit("sceneChanged", scene);
} else {
this.krpanoObj.call("loadscene(get(scene[0].name),null,MERGE,BLEND(0.5))");
}
}
},
log(content){
log(content) {
if (this.debug) {
if (this.krpanoObj) {
content = "[" + this.krpanoObj.id + "] " + content;
Expand All @@ -100,7 +104,7 @@ let config = {
}
},
watch: {
xml(newXml){
xml(newXml) {
if (this.krpanoObj && newXml) {
this.krpanoObj.call(`loadpano(${newXml},null,IGNOREKEEP)`);
this.$emit("xmlChanged", newXml);
Expand All @@ -111,10 +115,10 @@ let config = {
this.loadScene();
}
},
created(){
created() {
this.$on(["panoCreated", "xmlChanged"], this.loadScene);
},
beforeDestroy(){
beforeDestroy() {
this.removePano();
}
};
Expand Down

0 comments on commit feaa788

Please sign in to comment.