Go-to for Virtual realityGo-to for Marketing
2,613 posts · Joined Sep 2015 · 📍 Frisco, TX, United States

Hi All!
After Matterport removed access to their unannounced 3rd Party API (that I found and have been using), they have now been adding in the infrastructure to provide it.
All user accounts have 'flags' -- which are enabled features. Beta Testers receive additional flags. For instance, when "we" were testing Mattertag Links, those who were beta testers received the flag: 'mattertag_links'.
Here are all of my flags:
"vrworkshop", "labels", "panospheres", "mattertag_links", "billing_tab_hidden", "tag_links", "fastly_v2_urls", "model_settings", "floorplan", "zooming", "workshop_webgl", "list_signed_urls_default_3", "show360views", "showcase_tiling", "showcase_vr", "ws_zooming", "mattertags", "img_multi_dl"
Now, there's a new flag:
"showcase_sdk"
I've scanned through Showcase to see where this flag fits in -- and here's the SDK. Basically, Matterport is curating what features it will provide access to and in doing that, making the SDK a LOT more straightfoward. Essentially, everything that MatterPlus does this will allow.
115: [function(t, e, i) {
"use strict";
function n(t, e) {
this.messenger = new o(t, e)
}
var r = t("./PostMessageType"),
o = t("./postmessage"),
a = t("./VersionInfo"),
s = t("events").EventEmitter;
n.prototype = Object.create(s.prototype), n.prototype.bindEvents = function() {
this.messenger.on(r.ACTION, this.onMessageReceived.bind(this))
}, n.prototype.waitForConnection = function() {
var t = new Promise(function(t, e) {
this.messenger.on(r.CONNECT, function(e) {
this.onConnectionReceived(e), t(e.sdkVersion)
}.bind(this))
}.bind(this));
return t
}, n.prototype.onConnectionReceived = function(t) {
this.acceptConnection(t) && (this.messenger.removeAllListeners(r.CONNECT), this.bindEvents())
}, n.prototype.acceptConnection = function(t) {
this.messenger.setTarget(t.source, t.origin);
var e;
if (a.supported.indexOf(t.sdkVersion) === -1) {
if (a.deprecated.indexOf(t.sdkVersion) === -1) return this.messenger.send({
type: r.REJECT,
toId: t.fromId,
reason: "This version of the SDK isn't supported. Get the latest version here: http://www.matterport.com"
}), this.messenger.setTarget(), !1;
e = "This version of the SDK is being deprecated. Please see http://www.matterport.com for more info"
}
return this.messenger.send({
type: r.ACCEPT,
toId: t.fromId,
warning: e
}), !0
}, n.prototype.onMessageReceived = function(t) {
var e = this;
t.onDone = function(i) {
i.toId = t.fromId, i.uid = t.uid, i.type = r.RESPONSE, e.messenger.send(i)
}, this.emit(r.ACTION, t)
}, n.prototype.sendEvent = function(t, e) {
this.messenger.send({
type: r.EVENT,
eventType: t,
eventData: e
})
}, e.exports = n
}, {
"./PostMessageType": 116,
"./VersionInfo": 119,
"./postmessage": 121,
events: 157
}],
116: [function(t, e, i) {
"use strict";
e.exports = Object.freeze({
CONNECT: "postmessage.connect",
ACCEPT: "postmessage.accept",
REJECT: "postmessage.reject",
ACTION: "postmessage.action",
RESPONSE: "postmessage.response",
EVENT: "postmessage.event"
})
}, {}],
117: [function(t, e, i) {
"use strict";
e.exports = Object.freeze({
MOVE: "sdk.move",
ENTER_PANO: "sdk.enterpano",
MODEL_LOADED: "sdk.modelloaded"
})
}, {}],
118: [function(t, e, i) {
"use strict";
e.exports = Object.freeze({
FLY: "transition.fly",
FADEOUT: "transition.fade",
INSTANT: "transition.instant"
})
}, {}],
119: [function(t, e, i) {
"use strict";
e.exports = {
current: "1.0",
supported: ["1.0"],
deprecated: [],
isSupported: function(t) {
return this.supported.indexOf(t) !== -1
},
isDeprecated: function(t) {
return this.deprecated.indexOf(t) !== -1
},
isValid: function(t) {
return this.isSupported(t) || this.isDeprecated(t)
}
}
}, {}],
120: [function(t, e, i) {
(function(i) {
"use strict";
function n(t, e, i) {
t && (t = t.toLowerCase().trim());
var n = new A.UP.clone,
r = Math.PI / 3,
o = Math.PI / 2;
switch (t) {
case "left":
i.copy(e), i.applyAxisAngle(n, o);
break;
case "right":
i.copy(e), i.applyAxisAngle(n, -o);
break;
case "forwardleft":
i.copy(e), i.applyAxisAngle(n, r);
break;
case "forwardright":
i.copy(e), i.applyAxisAngle(n, -r);
break;
case "forward":
default:
i.copy(e)
}
return i
}
function r(t, e) {
if (t) {
var i = {
pano: t,
lookAtPoint: null,
duration: null,
maxDistanceOverride: null,
skipWarpingCheck: !1
};
this.player.flyToPano(i, function() {
e && e({
success: !0,
message: "Transition complete."
})
})
} else E.warn("Automation -> clickPanoObject: Unable to find pano."), e && e({
success: !1,
error: "Unable to find pano."
})
}
function o(t, e) {
var i = this.findRankedPano(t, e);
return i >= 0 ? this.handleToObject : (E.warn("Automation -> findRankedPanoObject: Unable to find nearby pano."), null)
}
function a(t, e) {
var i = this.findRankedMattertag(t, e);
return i >= 0 ? this.handleToObject : (E.warn("Automation -> findRankedMattertagObject: Unable to find nearby Mattertag."), null)
}
function s(t, e) {
e.copy(A.FORWARD), t.getDirection(e)
}
function l(t) {
var e = function(t) {
return t.alignmentType !== g.ALIGNED ? null : {
x: t.position.x,
y: t.position.y,
z: t.position.z
}
};
return {
panos: t.panos.list.map(function(t, i) {
return {
uuid: t.id,
aligned: t.alignmentType === g.ALIGNED,
neighbourUUIDs: t.neighbourUUIDs.slice(),
position: e(t)
}
})
}
}
var h = t("three"),
c = t("./ApiHost"),
u = t("../util/logger"),
d = t("../util/math"),
p = t("../enum/ModelManagerEvents"),
f = t("./PostMessageType"),
g = t("../enum/AlignmentType"),
m = t("../enum/Direction"),
v = t("./TransitionStyles"),
A = t("../enum/Vectors"),
y = t("../enum/Viewmode"),
C = t("../enum/WarpStyle"),
I = (t("../enum/Keys"), t("../enum/PlayerEvents")),
b = t("../sdk/SdkEvents"),
A = t("../enum/Vectors"),
w = t("../enum/ControlEvents"),
x = t("../settings"),
E = new u(i),
T = function() {
var t = function t() {
t.playerDirection.copy(t.player.mode === y.FLOORPLAN ? A.UP : A.FORWARD), t.player.getDirection(t.playerDirection), t.projectVectors();
var e = t.playerDirection.angleTo(t.lastFacingDirection);
t.angleTravelled += Math.abs(e), t.angleTravelled >= Math.abs(t.angle) ? (t.active = !1, t.onDone && t.onDone()) : (t.lastFacingDirection.copy(t.playerDirection), window.setTimeout(t, 4))
};
return t.active = !1, t.angle = 0, t.angleTravelled = 0, t.playerDirection = new h.Vector3, t.lastFacingDirection = new h.Vector3, t.onDone = null, t.player = null, t.start = function(e, i, n, r) {
t.active = !0, e && i && (i = 0), t.angle = e || i, t.xAngle = e, t.yAngle = i, t.angleTravelled = 0, t.playerDirection.copy(n.mode === y.FLOORPLAN ? A.UP : A.FORWARD), n.getDirection(t.playerDirection), t.lastFacingDirection.copy(t.playerDirection), t.projectVectors(), t.onDone = r, t.player = n, t()
}, t.projectVectors = function() {
t.xAngle && (t.playerDirection.projectOnPlane(A.UP), t.lastFacingDirection.projectOnPlane(A.UP))
}, t
}(),
M = function() {
var t = new h.Vector3;
return function(e) {
e ? (t.copy(e.position), t.add(e.discPosition), d.projectPositionToCanvas(t, this.player.camera, t), this.click(t.x, t.y)) : E.warn("Automation -> clickMattertagObject: Unable to find Mattertag.")
}
}(),
S = function() {
return this.player.mode === y.PANORAMA ? x.insideLookLimitUp : this.player.mode === y.DOLLHOUSE ? 90 - h.Math.radToDeg(x.dollhouseDefault.minPolarAngle) : null
},
_ = function() {
return this.player.mode === y.PANORAMA ? x.insideLookLimitDown : this.player.mode === y.DOLLHOUSE ? 90 - h.Math.radToDeg(x.dollhouseDefault.maxPolarAngle) : null
},
P = function(t) {
var e = new h.Vector3;
return function(t) {
var i = this.player.getDirection();
e.copy(i);
var n = e.y;
e.y = 0, e.normalize();
var r = h.Math.radToDeg(e.angleTo(i)) * (n < 0 ? -1 : 1);
if (this.player.mode !== y.DOLLHOUSE && this.player.mode !== y.PANORAMA) return 0 !== t && E.warn("Cannot rotate in y direction when in " + this.player.mode + " mode"), 0;
this.player.mode === y.DOLLHOUSE && (r = -r);
var o = S.call(this) - .1,
a = _.call(this) + .1,
s = r + t;
s > o ? s = o : s < a && (s = a);
var l = s - r;
return t > 0 && l < .01 && (l = 0), t < 0 && l > -.01 && (l = 0), l
}
}(),
L = null;
e.exports = {
init: function(t, e, i) {
R.init(t, e), L = new Promise(function(t, i) {
e.on(I.Ready, function() {
t()
})
}.bind(this));
var n = new c(window, window.location.protocol + "//" + window.location.host),
r = n.waitForConnection();
r.then(function(t) {
n.on(f.ACTION, R.onMessageReceive.bind(R))
}), e.on(I.Move, function() {
var t = Date.now(),
i = new h.Euler;
return function() {
if (!(Date.now() - t < 100)) {
i.setFromQuaternion(e.quaternion);
var r = {
position: {
x: e.position.x,
y: e.position.y,
z: e.position.z
},
rotation: {
x: i.x,
y: i.y,
z: i.z
},
pano: e.currentPano ? e.currentPano.id : null,
mode: e.mode
};
n.sendEvent(b.MOVE, {
state: r
}), t = Date.now()
}
}
}()), i.on(p.ActiveModelChanged, function(t) {
function e(t) {
var e, i = t.newPano.id;
t.oldPano && (e = t.oldPano.id), i !== e && n.sendEvent(b.ENTER_PANO, {
oldPano: e,
newPano: i
})
}
var i = t.model,
o = t.oldModel;
R.model = i, r.then(function() {
n.sendEvent(b.MODEL_LOADED, {
metadata: l(i)
})
}), o && o.panos.forEach(function(t) {
t.removeEventListener("enter", e)
}), i.panos.forEach(function(t) {
t.on("enter", e)
})
})
}
};
var R = {
director: null,
player: null,
model: null,
init: function(t, e) {
this.director = t, this.player = e
},
handleToObject: {},
objectToHandle: {},
handleCount: 0,
onMessageReceive: function(t) {
if (t) {
var e = t.targetFunction,
i = t.params,
n = t.onDone;
e && this[e] && this[e](i, n)
}
},
waitForInit: function(t, e) {
L.then(e.bind({
success: !0,
message: "Init complete."
}))
},
moveToPano: function(t, e) {
var i = new h.Euler(0, 0, 0, "YXZ"),
n = new h.Quaternion;
return function(t, e) {
var r = t.pano,
o = t.rotation,
a = t.transition;
if (!this.model) return e({
success: !1,
error: "The model has not been loaded yet"
});
var s = this.model.panos.get(r);
if (!s) return e({
success: !1,
error: r + " does not exist in this model"
});
o.x = h.Math.degToRad(o.x), o.y = h.Math.degToRad(o.y), i.set(o.x, o.y, 0);
var l = {
success: !0,
message: r
};
if (a === v.FADEOUT) n.setFromEuler(i), this.player.warpToPano(s, n, null, null, C.BLACK, null, null, e.bind(this, l));
else {
var c, u;
a === v.INSTANT && (c = 0, u = 0);
var d = A.FORWARD.clone().applyEuler(i).add(s.position);
this.player.flyToPano({
pano: s,
lookAtPoint: d,
duration: c,
aimDuration: u
}, e.bind(this, l))
}
}
}(),
moveInDirection: function(t, e) {
var i = t.direction;
this.player.flyLocalDirection(A.clone()), e({
success: !0,
message: "moved " + i
})
},
findRankedPano: function(t, e) {
var i = new h.Vector3,
r = new h.Vector3;
return function(t, e) {
s(this.player, r), n(e, r, i);
var o = this.player.rankedPanoInDirection(t, i);
if (o) {
var a = this.objectToHandle[o.id];
return a || (this.objectToHandle[o.id] = a = this.handleCount++, this.handleToObject[a] = o), a
}
return E.warn("Automation -> findRankedPano: Unable to find nearby pano."), -1
}
}(),
findRankedMattertag: function(t, e) {
var i = new h.Vector3,
r = new h.Vector3;
return function(t, e) {
s(this.player, r), n(e, r, i);
var o = this.player.rankedMattertagInDirection(t, i);
if (o) {
var a = this.objectToHandle[o.sid];
return a || (this.objectToHandle[o.sid] = a = this.handleCount++, this.handleToObject[a] = o), a
}
return E.warn("Automation -> findRankedMattertag: Unable to find nearby Mattertag."), -1
}
}(),
clickNearestMattertag: function(t) {
this.clickRankedMattertag(0, t)
},
clickRankedMattertag: function(t, e) {
var i = a.call(this, t, e);
i && M.call(this, i)
},
clickNearestPano: function(t, e) {
this.clickRankedPano(0, t, e)
},
clickRankedPano: function(t, e, i) {
var n = o.call(this, t, e);
n ? r.call(this, n, i) : i(null)
},
clickPano: function(t, e) {
var i = this.handleTable[t];
i ? r.call(this, i, e) : e(null)
},
rotateDirection: function() {
return function(t, e) {
var i = t.direction,
n = t.angle;
if (!T.active) {
var r = 0,
o = 0,
a = 0,
s = 0;
if (!n || isNaN(n)) return E.warn("Automation -> rotateDirection: Invalid rotation angle."), void(e && e({
success: !1,
error: "Invalid rotation angle."
}));
if (i === m.RIGHT || i === m.LEFT) i === m.RIGHT && (n = -n), r = n > 0 ? -1 : 1, a = n;
else {
if (i !== m.UP && i !== m.DOWN) return E.warn("Automation -> rotateDirection: Invalid direction for rotation: " + i), void(e && e({
success: !1,
error: "Invalid direction for rotation."
}));
i === m.DOWN && (n = -n), n = P.call(this, n), o = n > 0 ? 1 : -1, s = n
}
n = h.Math.degToRad(n), a = h.Math.degToRad(a), s = h.Math.degToRad(s);
var l = this.player.controls[this.player.mode];
l.startRotating(r, o), T.start(a, s, this.player, l.stopRotating.bind(l, !0))
}
}
}(),
rotate: function() {
var t = new h.Vector3,
e = new h.Vector3;
return function(i, n) {
var r = i.xAngle,
o = i.yAngle;
if (!T.active) {
if (r = r || 0, o = o || 0, isNaN(r) || isNaN(o)) return E.warn("Automation -> rotate: Invalid rotation angle."), void(n && n({
success: !1,
error: "Invalid rotation angle."
}));
Math.abs(r) < .01 && (r = 0), Math.abs(o) < .01 && (o = 0), o = P.call(this, o), r = -r, o = h.Math.degToRad(o), r = h.Math.degToRad(r), t.copy(this.player.mode === y.FLOORPLAN ? A.UP : A.FORWARD), this.player.getDirection(t), e.copy(t).applyAxisAngle(A.UP, r), e.applyAxisAngle(A.RIGHT, o);
var a = (t.angleTo(e), r > 0 ? -1 : r < 0 ? 1 : 0),
s = o > 0 ? 1 : o < 0 ? -1 : 0;
Math.abs(r) > Math.abs(o) ? s *= Math.abs(o / r) : Math.abs(o) > Math.abs(r) && (a *= Math.abs(r / o));
var l = this.player.controls[this.player.mode];
l.startRotating(a, s), T.start(r, o, this.player, l.stopRotating.bind(l, !0))
}
}
}(),
panCamera: function(t, e) {
function i(t) {
r.removeAllListeners(w.AutoPanComplete), r.removeAllListeners(w.AutoPanInterrupt), e({
success: !0,
message: t
})
}
if (this.player.mode !== y.DOLLHOUSE && this.player.mode !== y.FLOORPLAN) return e({
success: !1,
error: "camera panning is not available in the current mode: " + this.player.mode
});
var n = t.position,
r = this.player.control;
if (r.setAutoPanPosition(n.x, n.z), r.autoPan = !0, r.autoPanPosition.x !== n.x || r.autoPanPosition.y !== n.y) {
var o = function(t, e) {
return "(" + t + "," + e + ")"
},
a = "The point " + o(n.x, n.z) + " is outside the bounds for the current model. ";
a += "The point was clamped to " + o(r.autoPanPosition.x, r.autoPanPosition.z), console.warn(a)
}
r.on(w.AutoPanComplete, i.bind(this, !1)), r.on(w.AutoPanInterrupt, i.bind(this, !0))
},
click: function(t, e) {
var i = t.x,
n = t.y,
r = t.percentage;
r === !0 && (i = i / 100 * window.innerWidth, n = n / 100 * window.innerHeight), this.player.handleInputStart(i, n), this.player.updateIntersect(), this.player.handleInputEnd(i, n)
},
mouseOver: function(t, e) {
var i = t.x,
n = t.y,
r = t.percentage;
r === !0 && (i = i / 100 * window.innerWidth, n = n / 100 * window.innerHeight), this.player.handleInputMove(i, n), this.player.updateIntersect()
},
moveToMode: function(t, e) {
function i(t) {
e(t ? {
success: !1,
error: "Failed to load new mode: " + t
} : {
success: !0,
message: "Moved to new mode: " + n
})
}
var n = t.mode;
n === y.PANORAMA || n === y.DOLLHOUSE || n === y.FLOORPLAN ? this.director.changeMode(n).then(function() {
i()
}, function(t) {
i(t)
}) : e({
success: !1,
error: "Invalid mode selection"
})
}
}
}).call(this, "/js/sdk/automation.js")
}
After Matterport removed access to their unannounced 3rd Party API (that I found and have been using), they have now been adding in the infrastructure to provide it.
All user accounts have 'flags' -- which are enabled features. Beta Testers receive additional flags. For instance, when "we" were testing Mattertag Links, those who were beta testers received the flag: 'mattertag_links'.
Here are all of my flags:
"vrworkshop", "labels", "panospheres", "mattertag_links", "billing_tab_hidden", "tag_links", "fastly_v2_urls", "model_settings", "floorplan", "zooming", "workshop_webgl", "list_signed_urls_default_3", "show360views", "showcase_tiling", "showcase_vr", "ws_zooming", "mattertags", "img_multi_dl"
Now, there's a new flag:
"showcase_sdk"
I've scanned through Showcase to see where this flag fits in -- and here's the SDK. Basically, Matterport is curating what features it will provide access to and in doing that, making the SDK a LOT more straightfoward. Essentially, everything that MatterPlus does this will allow.
115: [function(t, e, i) {
"use strict";
function n(t, e) {
this.messenger = new o(t, e)
}
var r = t("./PostMessageType"),
o = t("./postmessage"),
a = t("./VersionInfo"),
s = t("events").EventEmitter;
n.prototype = Object.create(s.prototype), n.prototype.bindEvents = function() {
this.messenger.on(r.ACTION, this.onMessageReceived.bind(this))
}, n.prototype.waitForConnection = function() {
var t = new Promise(function(t, e) {
this.messenger.on(r.CONNECT, function(e) {
this.onConnectionReceived(e), t(e.sdkVersion)
}.bind(this))
}.bind(this));
return t
}, n.prototype.onConnectionReceived = function(t) {
this.acceptConnection(t) && (this.messenger.removeAllListeners(r.CONNECT), this.bindEvents())
}, n.prototype.acceptConnection = function(t) {
this.messenger.setTarget(t.source, t.origin);
var e;
if (a.supported.indexOf(t.sdkVersion) === -1) {
if (a.deprecated.indexOf(t.sdkVersion) === -1) return this.messenger.send({
type: r.REJECT,
toId: t.fromId,
reason: "This version of the SDK isn't supported. Get the latest version here: http://www.matterport.com"
}), this.messenger.setTarget(), !1;
e = "This version of the SDK is being deprecated. Please see http://www.matterport.com for more info"
}
return this.messenger.send({
type: r.ACCEPT,
toId: t.fromId,
warning: e
}), !0
}, n.prototype.onMessageReceived = function(t) {
var e = this;
t.onDone = function(i) {
i.toId = t.fromId, i.uid = t.uid, i.type = r.RESPONSE, e.messenger.send(i)
}, this.emit(r.ACTION, t)
}, n.prototype.sendEvent = function(t, e) {
this.messenger.send({
type: r.EVENT,
eventType: t,
eventData: e
})
}, e.exports = n
}, {
"./PostMessageType": 116,
"./VersionInfo": 119,
"./postmessage": 121,
events: 157
}],
116: [function(t, e, i) {
"use strict";
e.exports = Object.freeze({
CONNECT: "postmessage.connect",
ACCEPT: "postmessage.accept",
REJECT: "postmessage.reject",
ACTION: "postmessage.action",
RESPONSE: "postmessage.response",
EVENT: "postmessage.event"
})
}, {}],
117: [function(t, e, i) {
"use strict";
e.exports = Object.freeze({
MOVE: "sdk.move",
ENTER_PANO: "sdk.enterpano",
MODEL_LOADED: "sdk.modelloaded"
})
}, {}],
118: [function(t, e, i) {
"use strict";
e.exports = Object.freeze({
FLY: "transition.fly",
FADEOUT: "transition.fade",
INSTANT: "transition.instant"
})
}, {}],
119: [function(t, e, i) {
"use strict";
e.exports = {
current: "1.0",
supported: ["1.0"],
deprecated: [],
isSupported: function(t) {
return this.supported.indexOf(t) !== -1
},
isDeprecated: function(t) {
return this.deprecated.indexOf(t) !== -1
},
isValid: function(t) {
return this.isSupported(t) || this.isDeprecated(t)
}
}
}, {}],
120: [function(t, e, i) {
(function(i) {
"use strict";
function n(t, e, i) {
t && (t = t.toLowerCase().trim());
var n = new A.UP.clone,
r = Math.PI / 3,
o = Math.PI / 2;
switch (t) {
case "left":
i.copy(e), i.applyAxisAngle(n, o);
break;
case "right":
i.copy(e), i.applyAxisAngle(n, -o);
break;
case "forwardleft":
i.copy(e), i.applyAxisAngle(n, r);
break;
case "forwardright":
i.copy(e), i.applyAxisAngle(n, -r);
break;
case "forward":
default:
i.copy(e)
}
return i
}
function r(t, e) {
if (t) {
var i = {
pano: t,
lookAtPoint: null,
duration: null,
maxDistanceOverride: null,
skipWarpingCheck: !1
};
this.player.flyToPano(i, function() {
e && e({
success: !0,
message: "Transition complete."
})
})
} else E.warn("Automation -> clickPanoObject: Unable to find pano."), e && e({
success: !1,
error: "Unable to find pano."
})
}
function o(t, e) {
var i = this.findRankedPano(t, e);
return i >= 0 ? this.handleToObject : (E.warn("Automation -> findRankedPanoObject: Unable to find nearby pano."), null)
}
function a(t, e) {
var i = this.findRankedMattertag(t, e);
return i >= 0 ? this.handleToObject : (E.warn("Automation -> findRankedMattertagObject: Unable to find nearby Mattertag."), null)
}
function s(t, e) {
e.copy(A.FORWARD), t.getDirection(e)
}
function l(t) {
var e = function(t) {
return t.alignmentType !== g.ALIGNED ? null : {
x: t.position.x,
y: t.position.y,
z: t.position.z
}
};
return {
panos: t.panos.list.map(function(t, i) {
return {
uuid: t.id,
aligned: t.alignmentType === g.ALIGNED,
neighbourUUIDs: t.neighbourUUIDs.slice(),
position: e(t)
}
})
}
}
var h = t("three"),
c = t("./ApiHost"),
u = t("../util/logger"),
d = t("../util/math"),
p = t("../enum/ModelManagerEvents"),
f = t("./PostMessageType"),
g = t("../enum/AlignmentType"),
m = t("../enum/Direction"),
v = t("./TransitionStyles"),
A = t("../enum/Vectors"),
y = t("../enum/Viewmode"),
C = t("../enum/WarpStyle"),
I = (t("../enum/Keys"), t("../enum/PlayerEvents")),
b = t("../sdk/SdkEvents"),
A = t("../enum/Vectors"),
w = t("../enum/ControlEvents"),
x = t("../settings"),
E = new u(i),
T = function() {
var t = function t() {
t.playerDirection.copy(t.player.mode === y.FLOORPLAN ? A.UP : A.FORWARD), t.player.getDirection(t.playerDirection), t.projectVectors();
var e = t.playerDirection.angleTo(t.lastFacingDirection);
t.angleTravelled += Math.abs(e), t.angleTravelled >= Math.abs(t.angle) ? (t.active = !1, t.onDone && t.onDone()) : (t.lastFacingDirection.copy(t.playerDirection), window.setTimeout(t, 4))
};
return t.active = !1, t.angle = 0, t.angleTravelled = 0, t.playerDirection = new h.Vector3, t.lastFacingDirection = new h.Vector3, t.onDone = null, t.player = null, t.start = function(e, i, n, r) {
t.active = !0, e && i && (i = 0), t.angle = e || i, t.xAngle = e, t.yAngle = i, t.angleTravelled = 0, t.playerDirection.copy(n.mode === y.FLOORPLAN ? A.UP : A.FORWARD), n.getDirection(t.playerDirection), t.lastFacingDirection.copy(t.playerDirection), t.projectVectors(), t.onDone = r, t.player = n, t()
}, t.projectVectors = function() {
t.xAngle && (t.playerDirection.projectOnPlane(A.UP), t.lastFacingDirection.projectOnPlane(A.UP))
}, t
}(),
M = function() {
var t = new h.Vector3;
return function(e) {
e ? (t.copy(e.position), t.add(e.discPosition), d.projectPositionToCanvas(t, this.player.camera, t), this.click(t.x, t.y)) : E.warn("Automation -> clickMattertagObject: Unable to find Mattertag.")
}
}(),
S = function() {
return this.player.mode === y.PANORAMA ? x.insideLookLimitUp : this.player.mode === y.DOLLHOUSE ? 90 - h.Math.radToDeg(x.dollhouseDefault.minPolarAngle) : null
},
_ = function() {
return this.player.mode === y.PANORAMA ? x.insideLookLimitDown : this.player.mode === y.DOLLHOUSE ? 90 - h.Math.radToDeg(x.dollhouseDefault.maxPolarAngle) : null
},
P = function(t) {
var e = new h.Vector3;
return function(t) {
var i = this.player.getDirection();
e.copy(i);
var n = e.y;
e.y = 0, e.normalize();
var r = h.Math.radToDeg(e.angleTo(i)) * (n < 0 ? -1 : 1);
if (this.player.mode !== y.DOLLHOUSE && this.player.mode !== y.PANORAMA) return 0 !== t && E.warn("Cannot rotate in y direction when in " + this.player.mode + " mode"), 0;
this.player.mode === y.DOLLHOUSE && (r = -r);
var o = S.call(this) - .1,
a = _.call(this) + .1,
s = r + t;
s > o ? s = o : s < a && (s = a);
var l = s - r;
return t > 0 && l < .01 && (l = 0), t < 0 && l > -.01 && (l = 0), l
}
}(),
L = null;
e.exports = {
init: function(t, e, i) {
R.init(t, e), L = new Promise(function(t, i) {
e.on(I.Ready, function() {
t()
})
}.bind(this));
var n = new c(window, window.location.protocol + "//" + window.location.host),
r = n.waitForConnection();
r.then(function(t) {
n.on(f.ACTION, R.onMessageReceive.bind(R))
}), e.on(I.Move, function() {
var t = Date.now(),
i = new h.Euler;
return function() {
if (!(Date.now() - t < 100)) {
i.setFromQuaternion(e.quaternion);
var r = {
position: {
x: e.position.x,
y: e.position.y,
z: e.position.z
},
rotation: {
x: i.x,
y: i.y,
z: i.z
},
pano: e.currentPano ? e.currentPano.id : null,
mode: e.mode
};
n.sendEvent(b.MOVE, {
state: r
}), t = Date.now()
}
}
}()), i.on(p.ActiveModelChanged, function(t) {
function e(t) {
var e, i = t.newPano.id;
t.oldPano && (e = t.oldPano.id), i !== e && n.sendEvent(b.ENTER_PANO, {
oldPano: e,
newPano: i
})
}
var i = t.model,
o = t.oldModel;
R.model = i, r.then(function() {
n.sendEvent(b.MODEL_LOADED, {
metadata: l(i)
})
}), o && o.panos.forEach(function(t) {
t.removeEventListener("enter", e)
}), i.panos.forEach(function(t) {
t.on("enter", e)
})
})
}
};
var R = {
director: null,
player: null,
model: null,
init: function(t, e) {
this.director = t, this.player = e
},
handleToObject: {},
objectToHandle: {},
handleCount: 0,
onMessageReceive: function(t) {
if (t) {
var e = t.targetFunction,
i = t.params,
n = t.onDone;
e && this[e] && this[e](i, n)
}
},
waitForInit: function(t, e) {
L.then(e.bind({
success: !0,
message: "Init complete."
}))
},
moveToPano: function(t, e) {
var i = new h.Euler(0, 0, 0, "YXZ"),
n = new h.Quaternion;
return function(t, e) {
var r = t.pano,
o = t.rotation,
a = t.transition;
if (!this.model) return e({
success: !1,
error: "The model has not been loaded yet"
});
var s = this.model.panos.get(r);
if (!s) return e({
success: !1,
error: r + " does not exist in this model"
});
o.x = h.Math.degToRad(o.x), o.y = h.Math.degToRad(o.y), i.set(o.x, o.y, 0);
var l = {
success: !0,
message: r
};
if (a === v.FADEOUT) n.setFromEuler(i), this.player.warpToPano(s, n, null, null, C.BLACK, null, null, e.bind(this, l));
else {
var c, u;
a === v.INSTANT && (c = 0, u = 0);
var d = A.FORWARD.clone().applyEuler(i).add(s.position);
this.player.flyToPano({
pano: s,
lookAtPoint: d,
duration: c,
aimDuration: u
}, e.bind(this, l))
}
}
}(),
moveInDirection: function(t, e) {
var i = t.direction;
this.player.flyLocalDirection(A.clone()), e({
success: !0,
message: "moved " + i
})
},
findRankedPano: function(t, e) {
var i = new h.Vector3,
r = new h.Vector3;
return function(t, e) {
s(this.player, r), n(e, r, i);
var o = this.player.rankedPanoInDirection(t, i);
if (o) {
var a = this.objectToHandle[o.id];
return a || (this.objectToHandle[o.id] = a = this.handleCount++, this.handleToObject[a] = o), a
}
return E.warn("Automation -> findRankedPano: Unable to find nearby pano."), -1
}
}(),
findRankedMattertag: function(t, e) {
var i = new h.Vector3,
r = new h.Vector3;
return function(t, e) {
s(this.player, r), n(e, r, i);
var o = this.player.rankedMattertagInDirection(t, i);
if (o) {
var a = this.objectToHandle[o.sid];
return a || (this.objectToHandle[o.sid] = a = this.handleCount++, this.handleToObject[a] = o), a
}
return E.warn("Automation -> findRankedMattertag: Unable to find nearby Mattertag."), -1
}
}(),
clickNearestMattertag: function(t) {
this.clickRankedMattertag(0, t)
},
clickRankedMattertag: function(t, e) {
var i = a.call(this, t, e);
i && M.call(this, i)
},
clickNearestPano: function(t, e) {
this.clickRankedPano(0, t, e)
},
clickRankedPano: function(t, e, i) {
var n = o.call(this, t, e);
n ? r.call(this, n, i) : i(null)
},
clickPano: function(t, e) {
var i = this.handleTable[t];
i ? r.call(this, i, e) : e(null)
},
rotateDirection: function() {
return function(t, e) {
var i = t.direction,
n = t.angle;
if (!T.active) {
var r = 0,
o = 0,
a = 0,
s = 0;
if (!n || isNaN(n)) return E.warn("Automation -> rotateDirection: Invalid rotation angle."), void(e && e({
success: !1,
error: "Invalid rotation angle."
}));
if (i === m.RIGHT || i === m.LEFT) i === m.RIGHT && (n = -n), r = n > 0 ? -1 : 1, a = n;
else {
if (i !== m.UP && i !== m.DOWN) return E.warn("Automation -> rotateDirection: Invalid direction for rotation: " + i), void(e && e({
success: !1,
error: "Invalid direction for rotation."
}));
i === m.DOWN && (n = -n), n = P.call(this, n), o = n > 0 ? 1 : -1, s = n
}
n = h.Math.degToRad(n), a = h.Math.degToRad(a), s = h.Math.degToRad(s);
var l = this.player.controls[this.player.mode];
l.startRotating(r, o), T.start(a, s, this.player, l.stopRotating.bind(l, !0))
}
}
}(),
rotate: function() {
var t = new h.Vector3,
e = new h.Vector3;
return function(i, n) {
var r = i.xAngle,
o = i.yAngle;
if (!T.active) {
if (r = r || 0, o = o || 0, isNaN(r) || isNaN(o)) return E.warn("Automation -> rotate: Invalid rotation angle."), void(n && n({
success: !1,
error: "Invalid rotation angle."
}));
Math.abs(r) < .01 && (r = 0), Math.abs(o) < .01 && (o = 0), o = P.call(this, o), r = -r, o = h.Math.degToRad(o), r = h.Math.degToRad(r), t.copy(this.player.mode === y.FLOORPLAN ? A.UP : A.FORWARD), this.player.getDirection(t), e.copy(t).applyAxisAngle(A.UP, r), e.applyAxisAngle(A.RIGHT, o);
var a = (t.angleTo(e), r > 0 ? -1 : r < 0 ? 1 : 0),
s = o > 0 ? 1 : o < 0 ? -1 : 0;
Math.abs(r) > Math.abs(o) ? s *= Math.abs(o / r) : Math.abs(o) > Math.abs(r) && (a *= Math.abs(r / o));
var l = this.player.controls[this.player.mode];
l.startRotating(a, s), T.start(r, o, this.player, l.stopRotating.bind(l, !0))
}
}
}(),
panCamera: function(t, e) {
function i(t) {
r.removeAllListeners(w.AutoPanComplete), r.removeAllListeners(w.AutoPanInterrupt), e({
success: !0,
message: t
})
}
if (this.player.mode !== y.DOLLHOUSE && this.player.mode !== y.FLOORPLAN) return e({
success: !1,
error: "camera panning is not available in the current mode: " + this.player.mode
});
var n = t.position,
r = this.player.control;
if (r.setAutoPanPosition(n.x, n.z), r.autoPan = !0, r.autoPanPosition.x !== n.x || r.autoPanPosition.y !== n.y) {
var o = function(t, e) {
return "(" + t + "," + e + ")"
},
a = "The point " + o(n.x, n.z) + " is outside the bounds for the current model. ";
a += "The point was clamped to " + o(r.autoPanPosition.x, r.autoPanPosition.z), console.warn(a)
}
r.on(w.AutoPanComplete, i.bind(this, !1)), r.on(w.AutoPanInterrupt, i.bind(this, !0))
},
click: function(t, e) {
var i = t.x,
n = t.y,
r = t.percentage;
r === !0 && (i = i / 100 * window.innerWidth, n = n / 100 * window.innerHeight), this.player.handleInputStart(i, n), this.player.updateIntersect(), this.player.handleInputEnd(i, n)
},
mouseOver: function(t, e) {
var i = t.x,
n = t.y,
r = t.percentage;
r === !0 && (i = i / 100 * window.innerWidth, n = n / 100 * window.innerHeight), this.player.handleInputMove(i, n), this.player.updateIntersect()
},
moveToMode: function(t, e) {
function i(t) {
e(t ? {
success: !1,
error: "Failed to load new mode: " + t
} : {
success: !0,
message: "Moved to new mode: " + n
})
}
var n = t.mode;
n === y.PANORAMA || n === y.DOLLHOUSE || n === y.FLOORPLAN ? this.director.changeMode(n).then(function() {
i()
}, function(t) {
i(t)
}) : e({
success: !1,
error: "Invalid mode selection"
})
}
}
}).call(this, "/js/sdk/automation.js")
}
