Use overlay instead of entity to display tablet Web content

This commit is contained in:
David Rowe 2016-12-01 21:32:57 +13:00
parent a75d0b3fe8
commit 0136534954

View file

@ -65,36 +65,34 @@ WebTablet = function (url, width, dpi, clientOnly) {
parentJointIndex: -2 parentJointIndex: -2
}, clientOnly); }, clientOnly);
var WEB_ENTITY_REDUCTION_FACTOR = {x: 0.78, y: 0.85}; var WEB_OVERLAY_SCALE_FACTOR = { x: 2, y: 1.6 };
var WEB_ENTITY_Z_OFFSET = -0.01; var WEB_OVERLAY_Z_OFFSET = -0.01;
var webEntityRotation = Quat.multiply(spawnInfo.rotation, Quat.angleAxis(180, Y_AXIS)); var webOverlayRotation = Quat.multiply(spawnInfo.rotation, Quat.angleAxis(180, Y_AXIS));
var webEntityPosition = Vec3.sum(spawnInfo.position, Vec3.multiply(WEB_ENTITY_Z_OFFSET, Quat.getFront(webEntityRotation))); var webOverlayPosition = Vec3.sum(spawnInfo.position, Vec3.multiply(WEB_OVERLAY_Z_OFFSET, Quat.getFront(webOverlayRotation)));
this.webEntityID = Entities.addEntity({ this.webOverlayID = Overlays.addOverlay("web3d", {
name: "web", url: url,
type: "Web", dimensions: { x: WIDTH * WEB_OVERLAY_SCALE_FACTOR.x, y: HEIGHT * WEB_OVERLAY_SCALE_FACTOR.y },
sourceUrl: url, position: webOverlayPosition,
dimensions: {x: WIDTH * WEB_ENTITY_REDUCTION_FACTOR.x, rotation: webOverlayRotation,
y: HEIGHT * WEB_ENTITY_REDUCTION_FACTOR.y, resolution: { x: 480, y: 640 },
z: 0.1}, color: { red: 255, green: 255, blue: 255 },
position: webEntityPosition,
rotation: webEntityRotation,
shapeType: "box",
dpi: DPI,
parentID: this.tabletEntityID, parentID: this.tabletEntityID,
parentJointIndex: -1 parentJointIndex: -1
}, clientOnly); });
this.state = "idle"; this.state = "idle";
}; };
WebTablet.prototype.destroy = function () { WebTablet.prototype.destroy = function () {
Entities.deleteEntity(this.webEntityID); Overlays.deleteOverlay(this.webOverlayID);
Entities.deleteEntity(this.tabletEntityID); Entities.deleteEntity(this.tabletEntityID);
}; };
WebTablet.prototype.pickle = function () { WebTablet.prototype.pickle = function () {
return JSON.stringify({webEntityID: this.webEntityID, tabletEntityID: this.tabletEntityID}); return JSON.stringify({ webOverlayID: this.webOverlayID, tabletEntityID: this.tabletEntityID });
}; };
WebTablet.unpickle = function (string) { WebTablet.unpickle = function (string) {
if (!string) { if (!string) {