Hello everyone,
I have encountered a strange issue where if I click a button that tweens the camera, parts of the scene disappear and the PC console says “Error loading scripts” with the browser console telling me this:
Any help would be massively appreciated. I am left absolutely clueless as to why this happens because I have an almost identical script linked to the button below, yet it works just fine.
And finally, here are the scripts. The first one works just fine, the second one doesn’t apparently:
var ToBottomRight = pc.createScript('toBottomRight');
// initialize code called once per entity
ToBottomRight.prototype.initialize = function() {
this.entity.element.on('click', this.onPress, this);
};
// update code called every frame
ToBottomRight.prototype.onPress = function(dt) {
var Camera = this.app.root.findByName('Camera');
this.app.root.findByName('Schriftzug_THWS').enabled=false;
this.app.root.findByName('Ausstellungsstuecke').enabled=true;
this.app.root.findByName('Gelaende').enabled=false;
var screens = this.app.root.findByTag('InfoScreen');
for(var i = 0; i < screens.length; i++) {
var CurrentScreen = screens[i];
this.tween = CurrentScreen.tween(CurrentScreen.getLocalPosition())
.to(new pc.Vec3(-12877.759, -31000, 2986.441), 1, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
}
this.tween = Camera.tween(Camera.getLocalPosition())
.to(new pc.Vec3(6.394, 2, -17.175), 2, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
this.tween = Camera.tween(Camera.getEulerAngles())
.rotate({x: 0, y: -90, z: 0}, 2, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
setTimeout(function(){
var Headset = this.app.root.findByName('HTC-Vive');
var LaptopGeoVis = this.app.root.findByName('LaptopGeoVis');
var SmartphoneGeoVis = this.app.root.findByName('SmartphoneGeoVis');
var DrohneGeoVis = this.app.root.findByName('DrohneGeoVis');
var DrohneVerm = this.app.root.findByName('DrohneVerm');
var LaptopVerm = this.app.root.findByName('LaptopVerm');
var Massband = this.app.root.findByName('Massband');
var Sparks01 = this.app.root.findByName('sparks01');
var Sparks02 = this.app.root.findByName('sparks02');
var Sparks03 = this.app.root.findByName('sparks03');
var Sparks04 = this.app.root.findByName('sparks04');
var Sparks05 = this.app.root.findByName('sparks05');
var Sparks06 = this.app.root.findByName('sparks06');
var Sparks07 = this.app.root.findByName('sparks07');
this.app.fire("floatOn");
this.tween = Headset.tween(Headset.getLocalPosition())
.to(new pc.Vec3(-1.313, 0.2, -1.037), 1, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
this.tween = LaptopGeoVis.tween(LaptopGeoVis.getLocalPosition())
.to(new pc.Vec3(-1.313, 0.2, -1.037), 1, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
this.tween = SmartphoneGeoVis.tween(SmartphoneGeoVis.getLocalPosition())
.to(new pc.Vec3(-1.313, 0.2, -1.037), 1, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
this.tween = DrohneGeoVis.tween(DrohneGeoVis.getLocalPosition())
.to(new pc.Vec3(-1.313, 0.2, -1.037), 1, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
this.tween = DrohneVerm.tween(DrohneVerm.getLocalPosition())
.to(new pc.Vec3(-1.313, 0.2, -1.037), 1, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
this.tween = LaptopVerm.tween(LaptopVerm.getLocalPosition())
.to(new pc.Vec3(-1.313, 0.2, -1.037), 1, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
this.tween = Massband.tween(Massband.getLocalPosition())
.to(new pc.Vec3(-1.313, 0.2, -1.037), 1, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
setTimeout(function(){
Sparks01.enabled=false;
Sparks02.enabled=false;
Sparks03.enabled=false;
Sparks04.enabled=false;
Sparks05.enabled=false;
Sparks06.enabled=false;
Sparks07.enabled=false;
}.bind(this), 1000);
}.bind(this), 1000);
};
var ToTopRight = pc.createScript('toTopRight');
// initialize code called once per entity
ToTopRight.prototype.initialize = function() {
this.entity.element.on('click', this.onPress, this);
};
// update code called every frame
ToTopRight.prototype.onPress = function(dt) {
var Camera = this.app.root.findByName('Camera');
this.app.root.findByName('Schriftzug_THWS').enabled=false;
this.app.root.findByName('Ausstellungsstuecke').enabled=false;
this.app.root.findByName('Gelaende').enabled=false;
this.tween = Camera.tween(Camera.getLocalPosition())
.to(new pc.Vec3(6.394, 8, -17.175), 2, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
this.tween = Camera.tween(Camera.getEulerAngles())
.rotate({x: 0, y: -90, z: 0}, 2, pc.QuadraticInOut)
.delay(0.0)
.loop(false)
.yoyo(false);
this.tween.start();
setTimeout(function(){
this.app.fire("floatOn");
}.bind(this), 1000);
};
Thanks in advance for any help and finally, here’s a published build: