preview camera button in edit.js script

This commit is contained in:
Thijs Wenker 2015-11-04 03:24:32 +01:00
parent d7279e4c88
commit d60661ff8a
3 changed files with 30 additions and 7 deletions

View file

@ -301,12 +301,12 @@ var toolBar = (function() {
});
newCameraButton = toolBar.addTool({
imageURL: toolIconUrl + "polyvox.svg",
imageURL: toolIconUrl + "light.svg",
subImage: {
x: 0,
y: 0,
width: 256,
height: 256
y: Tool.IMAGE_WIDTH,
width: Tool.IMAGE_WIDTH,
height: Tool.IMAGE_HEIGHT
},
width: toolWidth,
height: toolHeight,
@ -1640,6 +1640,11 @@ PropertiesTool = function(opts) {
pushCommandForSelections();
selectionManager._update();
}
} else if (data.action == "previewCamera") {
if (selectionManager.hasSelection()) {
Camera.mode = "camera entity";
Camera.cameraEntity = selectionManager.selections[0];
}
} else if (data.action == "rescaleDimensions") {
var multiplier = data.percentage / 100;
if (selectionManager.hasSelection()) {

View file

@ -382,7 +382,7 @@
var elHyperlinkHref = document.getElementById("property-hyperlink-href");
var elHyperlinkDescription = document.getElementById("property-hyperlink-description");
var elPreviewCameraButton = document.getElementById("preview-camera-button");
if (window.EventBridge !== undefined) {
EventBridge.scriptEventReceived.connect(function(data) {
@ -931,6 +931,12 @@
action: "centerAtmosphereToZone",
}));
});
elPreviewCameraButton.addEventListener("click", function() {
EventBridge.emitWebEvent(JSON.stringify({
type: "action",
action: "previewCamera"
}));
});
window.onblur = function() {
// Fake a change event
@ -1032,7 +1038,7 @@
<div class="section-header">
<label>Spacial Properites</label>
<label>Spacial Properties</label>
</div>
<div class="property">
@ -1044,6 +1050,7 @@
<div>
<input type="button" id="move-selection-to-grid" value="Selection to Grid">
<input type="button" id="move-all-to-grid" value="All to Grid">
<input type="button" id="preview-camera-button" value="Preview Camera">
</div>
</div>
</div>

View file

@ -204,7 +204,7 @@ EntityPropertyDialogBox = (function () {
array.push({ label: "Collisions Will Move:", type: "checkbox", value: properties.collisionsWillMove });
index++;
array.push({ label: "Collision Sound URL:", value: properties.collisionSoundURL });
index++;
index++;
array.push({ label: "Lifetime:", value: properties.lifetime.toFixed(decimals) });
index++;
@ -260,6 +260,12 @@ EntityPropertyDialogBox = (function () {
array.push({ label: "Cutoff (in degrees):", value: properties.cutoff });
index++;
}
if (properties.type == "Camera") {
array.push({ label: "", type: "inlineButton", buttonLabel: "Preview Camera", name: "previewCamera" });
index++;
}
array.push({ button: "Cancel" });
index++;
@ -268,6 +274,11 @@ EntityPropertyDialogBox = (function () {
};
Window.inlineButtonClicked.connect(function (name) {
if (name == "previewCamera") {
Camera.mode = "camera entity";
Camera.cameraEntity = propertiesForEditedEntity.id;
}
if (name == "resetDimensions") {
Window.reloadNonBlockingForm([
{ value: propertiesForEditedEntity.naturalDimensions.x.toFixed(decimals), oldIndex: dimensionX },