Merge pull request #14325 from huffman/fix/new-model-dynamic

Fix new models not obeying dynamic checkbox
This commit is contained in:
Jeff Clinton 2018-11-08 10:22:12 -08:00 committed by GitHub
commit 62e3e87ba6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -484,23 +484,28 @@ var toolBar = (function () {
originalProperties[key] = newProperties[key];
}
}
function createNewEntity(properties) {
var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS;
function createNewEntity(requestedProperties) {
var dimensions = requestedProperties.dimensions ? requestedProperties.dimensions : DEFAULT_DIMENSIONS;
var position = getPositionToCreateEntity();
var entityID = null;
var properties = {};
applyProperties(properties, DEFAULT_ENTITY_PROPERTIES.All);
var type = properties.type;
var type = requestedProperties.type;
if (type == "Box" || type == "Sphere") {
applyProperties(properties, DEFAULT_ENTITY_PROPERTIES.Shape);
} else if (type == "Image") {
properties.type = "Model";
requestedProperties.type = "Model";
applyProperties(properties, DEFAULT_ENTITY_PROPERTIES.Image);
} else {
applyProperties(properties, DEFAULT_ENTITY_PROPERTIES[type]);
}
// We apply the requested properties first so that they take priority over any default properties.
applyProperties(properties, requestedProperties);
if (position !== null && position !== undefined) {
var direction;
@ -845,41 +850,18 @@ var toolBar = (function () {
addButton("newCubeButton", function () {
createNewEntity({
type: "Box",
dimensions: DEFAULT_DIMENSIONS,
color: {
red: 255,
green: 0,
blue: 0
}
});
});
addButton("newSphereButton", function () {
createNewEntity({
type: "Sphere",
dimensions: DEFAULT_DIMENSIONS,
color: {
red: 255,
green: 0,
blue: 0
}
});
});
addButton("newLightButton", function () {
createNewEntity({
type: "Light",
isSpotlight: false,
color: {
red: 150,
green: 150,
blue: 150
},
constantAttenuation: 1,
linearAttenuation: 0,
quadraticAttenuation: 0,
exponent: 0,
cutoff: 180 // in degrees
});
});