When i Play my experience
After Publishing the experience it is not working
This is My Program beScript.onStart = function () {
this.status = "idle";
this.lastCompleted = "";
this.sequenceStep = 0;
this.clicked = false;
};
beScript.onStop = function () {
};
beScript.execute = function (context) {
// not used
};
beScript.onAllUIClick = function (iEvent) {
var buttonName = iEvent.sender.name;
if (buttonName == "DisassembleAllAssembleAll") {
if (this.status !== "idle") {
console.log("[INFO1]: Interrupting current sequence. Resetting to idle.");
this.status = "idle";
this.sequenceStep = 0;
}
if (this.lastCompleted === "" || this.lastCompleted === "AssembleAll") {
for (var i = 0; i < this.inSteps.length; i++) {
var row = this.inSteps[i];
row.finalrotation = row.DPoint.getRotation();
row.initialrotation = row.APoint.getRotation();
row.Model.Motion.goTo(row.DPoint);
row.Model.setRotation(row.finalrotation);
}
this.status = "disassemble_all";
this.lastCompleted = "DisassembleAll";
console.log("[DEBUG1]: lastCompleted before DisassembleAll: " + this.lastCompleted + ", status: " + this.status);
} else if (this.lastCompleted === "DisassembleAll" || this.lastCompleted === "AssembleInSequence") {
for (var i = 0; i < this.inSteps.length; i++) {
var row = this.inSteps[i];
row.Model.Motion.goTo(row.APoint);
row.Model.setRotation(row.initialrotation);
}
this.status = "assemble_all";
}
}
else if (buttonName === "AssembleInSequence") {
if (this.status === "idle" && this.lastCompleted === "DisassembleAll") {
this.inSteps[0].Model.Motion.goTo(this.inAssyPivot);
this.status = "assemble_seq";
this.sequenceStep = 1;
console.log("[INFO2]: AssembleInSequence: Step 1 started " + this.inSteps[0].Model.getName() + " moving to " + this.inAssyPivot.getName());
} else if (this.status === "assemble_seq") {
var foundRow = this.inSteps.find(row => row.Step === (this.sequenceStep + 1));
if (foundRow !== undefined) {
foundRow.Model.Motion.goTo(this.inAssyPivot);
this.sequenceStep++;
console.log("[INFO3]: AssembleInSequence: Step " + this.sequenceStep + " started. " + foundRow.Model.getName() + " moving to " + this.inAssyPivot.getName());
}
}
}
else if (buttonName === "DisassembleInSequence") {
if (this.status === "idle" && (this.lastCompleted === "AssembleAll" || this.lastCompleted === "AssembleInSequence")) {
var lastStep = this.inSteps[this.inSteps.length - 1].Step;
this.inSteps[this.inSteps.length - 1].Model.Motion.goTo(this.inAssyPivot);
console.log("[INFO4]: DisassembleInSequence: Step " + lastStep + " started. " + this.inSteps[this.inSteps.length - 1].Model.getName() + " moving to " + this.inAssyPivot.getName());
this.status = "disassemble_seq";
this.sequenceStep = lastStep;
} else if (this.status === "disassemble_seq") {
var foundRow = this.inSteps.find(row => row.Step === this.sequenceStep - 1);
if (foundRow !== undefined) {
foundRow.Model.Motion.goTo(this.inAssyPivot);
console.log("[INFO5]: DisassembleInSequence: Step " + (this.sequenceStep - 1) + " started. " + foundRow.Model.getName() + " moving to " + this.inAssyPivot.getName());
this.sequenceStep--;
}
}
}
};
beScript.onAllMotionHasReached = function (iEvent) {
var actor = iEvent.actor;
var target = iEvent.targetActor;
if (this.status === "disassemble_all") {
if (actor === this.inSteps[this.inSteps.length - 1].Model && target === this.inSteps[this.inSteps.length - 1].DPoint) {
this.status = "idle";
this.lastCompleted = "DisassembleAll";
}
}
else if (this.status === "assemble_all") {
if (actor === this.inSteps[this.inSteps.length - 1].Model && target === this.inSteps[this.inSteps.length - 1].APoint) {
this.status = "idle";
this.lastCompleted = "AssembleAll";
}
}
else if (this.status === "assemble_seq") {
var foundRow = this.inSteps.find(row => row.Model === actor && row.Step === this.sequenceStep);
if (foundRow !== undefined) {
if (target === this.inAssyPivot) {
foundRow.Model.Motion.goTo(foundRow.APoint);
if (foundRow.initialrotation instanceof DSMath.Vector3D) {
foundRow.Model.setRotation(foundRow.initialrotation);
}
console.log("[INFO8]: assemble_seq: Step " + this.sequenceStep + " moving to " + foundRow.APoint.getName());
} else {
if (this.sequenceStep < 59) {
this.sequenceStep++;
} else {
this.status = "idle";
this.lastCompleted = "AssembleAll";
}
}
}
}
else if (this.status === "disassemble_seq") {
var foundRow = this.inSteps.find(row => row.Model === actor && row.Step === this.sequenceStep);
if (foundRow !== undefined) {
if (target === this.inAssyPivot) {
foundRow.Model.Motion.goTo(foundRow.DPoint);
if (foundRow.finalrotation instanceof DSMath.Vector3D) {
foundRow.Model.setRotation(foundRow.finalrotation);
}
console.log("[INFO9]: disassemble_seq: Step " + this.sequenceStep + " moving to " + foundRow.DPoint.getName());
} else {
if (this.sequenceStep > 1) {
this.sequenceStep--;
} else {
this.status = "idle";
this.lastCompleted = "DisassembleAll";
}
}
}
}
};
Please suggest an alternate method to use getRotation() and Set Rotation() inside Creative Experience ?