Skip to content

Commit

Permalink
v1.3.9 Bug Correction Editor + Sky with ceiling
Browse files Browse the repository at this point in the history
  • Loading branch information
adizanni committed Mar 14, 2022
1 parent 09f4b88 commit 538ffe6
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 276 deletions.
351 changes: 176 additions & 175 deletions dist/floor3d-card.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "floor3d-card",
"version": "1.3.8",
"version": "1.3.9",
"description": "Lovelace floor3d-card",
"keywords": [
"home-assistant",
Expand Down
2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const CARD_VERSION = '1.3.8';
export const CARD_VERSION = '1.3.9';
174 changes: 76 additions & 98 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@ export class Floor3dCardEditor extends LitElement implements LovelaceCardEditor
.configObject=${config}
.configAttribute=${'type3d'}
.ignoreNull=${false}
.configIndex=${index}
fixedMenuPosition
naturalMenuWidth
@closed=${(ev) => ev.stopPropagation()}
Expand Down Expand Up @@ -2099,7 +2100,9 @@ export class Floor3dCardEditor extends LitElement implements LovelaceCardEditor
const config = this._configArray[index];
const visible: boolean = config.type3d ? config.type3d === 'cover' : false;
if (visible) {
config.cover = { ...config.cover };
if (!config.cover) {
Object.defineProperty(config, 'cover', { configurable: true, writable: true });
}
}
return html`
${visible
Expand Down Expand Up @@ -2411,159 +2414,134 @@ export class Floor3dCardEditor extends LitElement implements LovelaceCardEditor
}

private _typeChanged(ev): void {

if (!this._config || !this.hass) {
return;
}

const target = ev.target;

if (target.configObject[target.configAttribute] == target.value) {
return;
}

let initialtype3d: string = target.configObject[target.configAttribute];

this._valueChanged(ev);

console.log('Type3D changed start');

if (target.configObject.colorcondition) {

const { colorcondition, ...newobject } = target.configObject;

if (target.configObject[initialtype3d]) {

const entityArray = this._configArray;

const newentityArray: any = [];

entityArray.forEach((entity, index) => {

if (ev.target.configIndex == index) {

let newobject;

switch (initialtype3d) {

case 'light':
const { light, ...lightObject } = ev.target.configObject;
newobject = lightObject;
break;
case 'room':
let { room, ...roomObject } = ev.target.configObject;
newobject = roomObject;
break;
case 'color':
let { colorcondition, ...colorObject } = ev.target.configObject;
newobject = colorObject;
break;
case 'hide':
let { hide, ...hideObject } = ev.target.configObject;
newobject = hideObject;
break;
case 'show':
let { show, ...showObject } = ev.target.configObject;
newobject = showObject;
break;
case 'door':
let { door, ...doorObject } = ev.target.configObject;
newobject = doorObject;
break;
case 'gesture':
let { gesture, ...gestureObject } = ev.target.configObject;
newobject = gestureObject;
break;
case 'camera':
let { camera, ...cameraObject } = ev.target.configObject;
newobject = cameraObject;
break;
case 'text':
let { text, ...textObject } = ev.target.configObject;
newobject = textObject;
break;
case 'rotate':
let { rotate, ...rotateObject } = ev.target.configObject;
newobject = rotateObject;
break;
case 'cover':
let { cover, ...coverObject } = ev.target.configObject;
newobject = coverObject;
break;
}
console.log(newobject);
newentityArray.push(newobject);
} else {
newentityArray.push(entity);
}
});

delete target.configObject.colorcondition;
this._configArray = newentityArray;
}

if (ev.target.optionTgt.color) {
ev.target.optionTgt.color.visible = false;
}

if (target.configObject.hide) {
delete target.configObject.hide;
}
if (ev.target.optionTgt.hide) {
ev.target.optionTgt.hide.visible = false;
}

if (target.configObject.show) {
delete target.configObject.show;
}
if (ev.target.optionTgt.show) {
ev.target.optionTgt.show.visible = false;
}

if (target.configObject.room) {
delete target.configObject.room;
}
if (ev.target.optionTgt.room) {
ev.target.optionTgt.room.visible = false;
}

if (target.configObject.door) {
delete target.configObject.door;
}
if (ev.target.optionTgt.door) {
ev.target.optionTgt.door.visible = false;
}

if (target.configObject.text) {
delete target.configObject.text;
}
if (ev.target.optionTgt.text) {
ev.target.optionTgt.text.visible = false;
}

if (target.configObject.cover) {
delete target.configObject.cover;
}
if (ev.target.optionTgt.cover) {
ev.target.optionTgt.cover.visible = false;
}

if (target.configObject.gesture) {
delete target.configObject.gesture;
}
if (ev.target.optionTgt.gesture) {
ev.target.optionTgt.gesture.visible = false;
}

if (target.configObject.rotate) {
delete target.configObject.rotate;
}
if (ev.target.optionTgt.rotate) {
ev.target.optionTgt.rotate.visible = false;
}

if (target.configObject.camera) {
delete target.configObject.camera;
}
if (ev.target.optionTgt.camera) {
ev.target.optionTgt.camera.visible = false;
}

if (target.configObject.light) {
delete target.configObject.light;
}
if (ev.target.optionTgt.light) {
ev.target.optionTgt.light.visible = false;
}

if (target.value == 'color') {
if (ev.target.optionTgt) {
ev.target.optionTgt.color.visible = true;
}
}

if (target.value == 'rotate') {
if (ev.target.optionTgt) {
ev.target.optionTgt.rotate.visible = true;
}
}

if (target.value == 'light') {
if (ev.target.optionTgt) {
ev.target.optionTgt.light.visible = true;
}
}

if (target.value == 'hide') {
if (ev.target.optionTgt) {
ev.target.optionTgt.hide.visible = true;
}
}

if (target.value == 'show') {
if (ev.target.optionTgt) {
ev.target.optionTgt.show.visible = true;
}
}

if (target.value == 'text') {
if (ev.target.optionTgt) {
ev.target.optionTgt.text.visible = true;
}
}

if (target.value == 'room') {
if (ev.target.optionTgt) {
ev.target.optionTgt.room.visible = true;
}
}

if (target.value == 'camera') {
if (ev.target.optionTgt) {
ev.target.optionTgt.camera.visible = true;
}
}

if (target.value == 'gesture') {
if (ev.target.optionTgt) {
ev.target.optionTgt.gesture.visible = true;
}
}

if (target.value == 'door') {
if (ev.target.optionTgt) {
ev.target.optionTgt.door.visible = true;
}
}

console.log('Type3D changed end');
}

Expand Down
2 changes: 1 addition & 1 deletion src/floor3d-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ export class Floor3dCard extends LitElement {
if (this._config.shadow && this._config.shadow == 'yes') {
console.log('Shadow On');
this._renderer.shadowMap.enabled = true;
this._renderer.shadowMap.type = THREE.BasicShadowMap;
this._renderer.shadowMap.type = THREE.PCFSoftShadowMap;
this._renderer.shadowMap.autoUpdate = false;
} else {
console.log('Shadow Off');
Expand Down
8 changes: 8 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ export function createObjectGroupConfigArray(config): Floor3dCardConfig[] {
{ entity: entityConfig.entity, objects: [{ object_id: entityConfig.object_id }] },
);
configArray.push(objectConfig);
} else {
if (entityConfig.entity != '') {
throw new Error('Object is empty for entity' + entityConfig.entity);
}
}
} else {
if (entityConfig.entity != '') {
throw new Error('Object is empty for entity' + entityConfig.entity);
}
}
}
Expand Down

0 comments on commit 538ffe6

Please sign in to comment.