From 3d464b8eab9330311d6c95fb626b23666f114e01 Mon Sep 17 00:00:00 2001 From: Unknower Date: Sun, 22 Oct 2023 22:11:20 -0400 Subject: [PATCH] bug fixes and improvements --- src/app.ts | 25 ++++++++++---- src/components/VLMClaimPoint.component.ts | 25 ++++++++++---- src/components/VLMImage.component.ts | 17 ++++----- src/components/VLMModel.component.ts | 41 ++++++++++------------ src/components/VLMNFT.component.ts | 21 +++++++++--- src/components/VLMSound.component.ts | 36 +++++++++++-------- src/components/VLMVideo.component.ts | 24 +++++++------ src/logic/VLMClaimPoint.logic.ts | 42 ++++++++++++----------- src/logic/VLMImage.logic.ts | 30 +++++++--------- src/logic/VLMModel.logic.ts | 25 ++++++-------- src/logic/VLMNFT.logic.ts | 2 +- src/logic/VLMScene.logic.ts | 2 ++ src/logic/VLMSound.logic.ts | 36 +++++++++---------- src/logic/VLMVideo.logic.ts | 42 +++++++++++------------ 14 files changed, 199 insertions(+), 169 deletions(-) diff --git a/src/app.ts b/src/app.ts index 023116e..91d42c9 100644 --- a/src/app.ts +++ b/src/app.ts @@ -3,15 +3,17 @@ import { VLMEnvironment } from "./environment"; import { VLMSessionManager } from "./logic/VLMSession.logic"; import { VLMEventListeners } from "./logic/VLMSystemListeners.logic"; import { VLMLogManager } from "./logic/VLMLogging"; -import { VLMWidget } from "./components/VLMWidget.component"; import { VLMWidgetManager } from "./logic/VLMWidget.logic"; +import { VLMNotificationManager } from "./logic/VLMNotification.logic"; +import { VLMEventManager } from "./logic/VLMSystemEvents.logic"; +import { VLMWidget } from "./components/VLMWidget.component"; import { VLMVideo } from "./components/VLMVideo.component"; import { VLMImage } from "./components/VLMImage.component"; import { VLMNFT } from "./components/VLMNFT.component"; import { VLMSound } from "./components/VLMSound.component"; -import { VLMNotificationManager } from "./logic"; -import { VLMEventManager } from "./logic/VLMSystemEvents.logic"; import { VLMSceneInitEvent } from "./components/VLMSystemEvents.component"; +import { VLMModel } from "./components/VLMModel.component"; +import { VLMClaimPoint } from "./components/VLMClaimPoint.component"; import { configurePaths } from "./shared/paths"; /** @@ -97,6 +99,10 @@ export abstract class VLM { configs: VLMImage.configs, instances: VLMImage.instances }, + models: { + configs: VLMModel.configs, + instances: VLMModel.instances + }, nfts: { configs: VLMNFT.configs, instances: VLMNFT.instances @@ -106,6 +112,9 @@ export abstract class VLM { instances: VLMSound.instances, systems: VLMSound.systems }, + claimPoints: { + configs: VLMClaimPoint.configs, + }, widgets: { configs: VLMWidget.configs } @@ -117,16 +126,20 @@ export abstract class VLM { export type VLMStorage = { video: { configs: VLMVideo.DCLConfig[], - instances: VLMVideo.DCLInstanceConfig, + instances: VLMVideo.DCLInstanceConfig[], systems: VLMVideo.VLMVideoSystem }, image: { configs: VLMImage.DCLConfig[], - instances: VLMImage.DCLInstanceConfig + instances: VLMImage.DCLInstanceConfig[] + }, + models: { + configs: VLMModel.DCLConfig[], + instances: VLMModel.DCLInstanceConfig[] }, nft: { configs: VLMNFT.DCLConfig[], - instances: VLMNFT.DCLInstanceConfig + instances: VLMNFT.DCLInstanceConfig[] }, sound: { configs: VLMSound.DCLConfig[], diff --git a/src/components/VLMClaimPoint.component.ts b/src/components/VLMClaimPoint.component.ts index 9139adf..be7db8d 100644 --- a/src/components/VLMClaimPoint.component.ts +++ b/src/components/VLMClaimPoint.component.ts @@ -56,6 +56,15 @@ export namespace VLMClaimPoint { this.hoverText = config?.hoverText; this.requestInProgress = false; + configs[this.sk] = this; + if (this.customId) { + configs[this.customId] = configs[this.sk]; + } + + if (this.customRendering) { + return; + } + this.add(); this.generateClaimItem(); @@ -68,19 +77,15 @@ export namespace VLMClaimPoint { this.updateTransform(config.position, config.scale, config.rotation); - configs[this.sk] = this; - - if (this.customId) { - configs[this.customId] = configs[this.sk]; - } } add: CallableFunction = () => { try { - if (this.isAddedToEngine()) { + if (this.isAddedToEngine() || this.customRendering || !this.enabled) { return; - } else if (this.parent) { + } + if (this.parent) { this.updateParent(this.parent); } else { engine.addEntity(this); @@ -194,6 +199,9 @@ export namespace VLMClaimPoint { generateClaimItem: CallableFunction = () => { const objThis = this; + if (!objThis.enabled) { + return + } this.claimItemEntity.setParent(objThis); if (this.properties.type == ClaimPointType.MODEL && this.properties.modelSrc) { this.claimItemEntity.addComponentOrReplace(new GLTFShape(`${getModelPath()}${this.properties.modelSrc}`)); @@ -227,6 +235,9 @@ export namespace VLMClaimPoint { generateStandardBooth: CallableFunction = () => { const objThis = this; + if (!objThis.enabled) { + return + } this.kioskEntities.topEntity = this.kioskEntities.topEntity || new Entity("Claim Point Top"); this.kioskEntities.glassEntity = this.kioskEntities.glassEntity || new Entity("Claim Point Glass"); this.kioskEntities.baseEntity = this.kioskEntities.baseEntity || new Entity("Claim Point Mid Section"); diff --git a/src/components/VLMImage.component.ts b/src/components/VLMImage.component.ts index 54a7f8e..3e88731 100644 --- a/src/components/VLMImage.component.ts +++ b/src/components/VLMImage.component.ts @@ -47,9 +47,9 @@ export namespace VLMImage { this.isTransparent = config.isTransparent; this.clickEvent = config.clickEvent; - configs[this.sk] = this; this.updateTexture(config); + configs[this.sk] = this; if (this.customId) { configs[this.customId] = configs[this.sk]; } @@ -284,12 +284,7 @@ export namespace VLMImage { this.addComponentOrReplace(config); this.updateTransform(this.position, this.scale, this.rotation); this.updateDefaultClickEvent(config.clickEvent); - - if (this.parent && this.enabled && !this.customRendering) { - this.updateParent(this.parent); - } else if (this.enabled) { - this.add(); - } + this.add(); if (this.customId) { instances[this.customId] = instances[this.sk]; @@ -301,11 +296,13 @@ export namespace VLMImage { add: CallableFunction = () => { try { - if (this.isAddedToEngine()) { + if (this.isAddedToEngine() || this.customRendering || !configs[this.configId].enabled || !this.enabled) { return; - } else if (this.parent) { + } + + if (this.parent) { this.updateParent(this.parent); - } else { + } else if (this.enabled) { engine.addEntity(this); } } catch (error) { diff --git a/src/components/VLMModel.component.ts b/src/components/VLMModel.component.ts index c57e6f6..232e25b 100644 --- a/src/components/VLMModel.component.ts +++ b/src/components/VLMModel.component.ts @@ -1,7 +1,6 @@ import { VLMClickEvent } from "./VLMClickEvent.component"; -import { Emissive, SimpleTransform, Transformable } from "../shared/interfaces"; +import { SimpleTransform, Transformable } from "../shared/interfaces"; import { includes } from "../utils"; -import { VLMBase } from "./VLMBaseConfig.component"; import { getEntityByName } from "../shared/entity"; import { getModelPath } from "../shared/paths"; @@ -28,13 +27,12 @@ export namespace VLMModel { this.sk = config.sk; this.customId = config.customId; this.customRendering = !!config.customRendering; - this.parent = config.parent; - this.enabled = config.enabled; - this.modelSrc = config.modelSrc; - this.clickEvent = config.clickEvent; + this.parent = config?.parent; + this.enabled = config?.enabled; + this.modelSrc = config?.modelSrc; + this.clickEvent = config?.clickEvent; configs[this.sk] = this; - if (this.customId) { configs[this.customId] = configs[this.sk]; } @@ -159,9 +157,6 @@ export namespace VLMModel { this.instanceIds.push(config.sk); } new DCLInstanceConfig(this, config); - if (config.customId) { - instances[config.customId] = instances[config.sk]; - } }; deleteInstance: CallableFunction = (instanceId: string) => { @@ -223,11 +218,11 @@ export namespace VLMModel { this.customRendering = instance?.customRendering; this.configId = config?.sk; this.position = instance?.position; - this.scale = instance.scale; - this.rotation = instance.rotation; - this.enabled = instance.enabled; - this.clickEvent = instance.clickEvent; - this.defaultClickEvent = config.clickEvent; + this.scale = instance?.scale; + this.rotation = instance?.rotation; + this.enabled = instance?.enabled; + this.clickEvent = instance?.clickEvent; + this.defaultClickEvent = config?.clickEvent; instances[this.sk] = this; log("VLM - CREATING INSTANCE - Step 3", instances && instances[this.sk]) const model = new GLTFShape(`${getModelPath()}${config.modelSrc}`); @@ -235,11 +230,9 @@ export namespace VLMModel { this.updateTransform(this.position, this.scale, this.rotation); this.updateDefaultClickEvent(config.clickEvent); - if (this.parent && this.enabled && !this.customRendering) { - this.updateParent(this.parent); - } else if (this.enabled) { - this.add(); - } + + this.add(); + if (this.customId) { instances[this.customId] = instances[this.sk]; @@ -251,11 +244,13 @@ export namespace VLMModel { add: CallableFunction = () => { try { - if (this.isAddedToEngine()) { + if (this.isAddedToEngine() || this.customRendering || !configs[this.configId].enabled || !this.enabled) { return; - } else if (this.parent) { + } + + if (this.parent) { this.updateParent(this.parent); - } else { + } else if (this.enabled) { engine.addEntity(this); } } catch (error) { diff --git a/src/components/VLMNFT.component.ts b/src/components/VLMNFT.component.ts index c8f12d5..6901d2a 100644 --- a/src/components/VLMNFT.component.ts +++ b/src/components/VLMNFT.component.ts @@ -34,7 +34,7 @@ export namespace VLMNFT { this.contractAddress = config.contractAddress; this.withCollisions = config.withCollisions || false; this.tokenId = config.tokenId || 0; - this.enabled = config.enabled || true; + this.enabled = config.enabled; configs[this.sk] = this; if (this.customId) { @@ -186,7 +186,7 @@ export namespace VLMNFT { this.scale = instance.scale; this.rotation = instance.rotation; this.configId = config.sk; - this.enabled = config.enabled || instance.enabled; + this.enabled = instance.enabled; this.withCollisions = typeof instance.withCollisions === "boolean" ? instance.withCollisions : config.withCollisions; this.addComponentOrReplace(shape); this.updateTransform(this.position, this.scale, this.rotation); @@ -199,7 +199,20 @@ export namespace VLMNFT { } add: CallableFunction = () => { - engine.addEntity(this); + try { + if (this.customRendering || !configs[this.configId].enabled || !this.enabled) { + return; + } + if (this.isAddedToEngine()) { + return; + } else if (this.parent) { + this.updateParent(this.parent); + } else if (this.enabled) { + engine.addEntity(this); + } + } catch (error) { + throw error; + } }; delete: CallableFunction = () => { @@ -259,5 +272,5 @@ export namespace VLMNFT { this.addComponentOrReplace(newShape); }; } - export class VLMInstanceConfig extends DCLInstanceConfig {} + export class VLMInstanceConfig extends DCLInstanceConfig { } } diff --git a/src/components/VLMSound.component.ts b/src/components/VLMSound.component.ts index 5f72108..d8a8b65 100644 --- a/src/components/VLMSound.component.ts +++ b/src/components/VLMSound.component.ts @@ -1,6 +1,6 @@ import { getEntityByName } from "../shared/entity"; import { VLMBase } from "./VLMBaseConfig.component"; -import { Audible, HasPlaylist, Playable, SimpleTransform, Transformable } from "../shared/interfaces"; +import { Audible, Playable, SimpleTransform, Transformable } from "../shared/interfaces"; import { getSoundPath } from "../shared/paths"; import { includes } from "../utils"; @@ -54,15 +54,18 @@ export namespace VLMSound { } else if (config.sourceType === SourceType.CLIP || config.sourceType === SourceType.LOOP) { this.audioClip = new AudioClip(`${getSoundPath()}${this.audioSrc}`); } + this.updateVolume(this.volume); - VLMSound.configs[this.sk] = this; + configs[this.sk] = this; if (this.customId) { - VLMSound.configs[this.customId] = VLMSound.configs[this.sk]; + configs[this.customId] = configs[this.sk]; } + if (this.customRendering || !config.instances || config.instances.length < 1) { return; } + config.instances.forEach((instance: VLMInstanceConfig) => { this.createInstance(instance); }); @@ -119,9 +122,6 @@ export namespace VLMSound { this.instanceIds.push(config.sk); } new DCLInstanceConfig(this, config); - if (config.customId) { - instances[config.customId] = instances[config.sk]; - } }; removeInstance: CallableFunction = (instanceId: string) => { @@ -303,7 +303,7 @@ export namespace VLMSound { init: CallableFunction = (config: DCLConfig, instance: VLMInstanceConfig) => { try { this.sk = instance?.sk; - this.enabled = instance?.enabled && config.enabled; + this.enabled = instance?.enabled; this.parent = instance?.parent || config.parent; this.position = instance?.position; this.scale = instance?.scale; @@ -330,26 +330,32 @@ export namespace VLMSound { source.playing = this.enabled; } - VLMSound.instances[this.sk] = this; + instances[this.sk] = this; + + if (config.customId) { + instances[this.customId] = instances[this.sk]; + } if (config.sourceType < SourceType.STREAM) { this.updateTransform(this.position, this.scale, this.rotation); } - if (this.enabled) { - this.add(); - } + this.add(); + } catch (e) { throw e; } }; + add: CallableFunction = () => { try { + if (this.isAddedToEngine() || this.customRendering || !configs[this.configId].enabled || !this.enabled) { + return; + } - const parent = this.parent || VLMSound.configs[this.configId].parent; - if (parent) { - this.updateParent(parent); - } else if (VLMSound.configs[this.configId]?.enabled && this.enabled && !this.isAddedToEngine()) { + if (this.parent) { + this.updateParent(this.parent); + } else if (this.enabled) { engine.addEntity(this); } } catch (error) { diff --git a/src/components/VLMVideo.component.ts b/src/components/VLMVideo.component.ts index b7f148d..9cb3084 100644 --- a/src/components/VLMVideo.component.ts +++ b/src/components/VLMVideo.component.ts @@ -85,7 +85,7 @@ export namespace VLMVideo { configs[this.customId] = configs[this.sk]; } - if (this.customRendering) { + if (this.customRendering || !config.instances || config.instances.length < 1) { return; } @@ -450,18 +450,22 @@ export namespace VLMVideo { this.correctUvs(config.textureMode === SourceTypes.IMAGE); - if (this.enabled) { - this.add(); - } + this.add(); } add: CallableFunction = () => { - const parent = this.parent || configs[this.configId].parent; - const hidden = !configs[this.configId].enabled || configs[this.configId].textureMode === SourceTypes.NONE; - if (parent) { - this.updateParent(parent); - } else if (!this.isAddedToEngine() && !hidden) { - engine.addEntity(this); //// SDK SPECIFIC //// + try { + if (this.isAddedToEngine() || this.customRendering || !configs[this.configId].enabled || !this.enabled) { + return; + } + + if (this.parent) { + this.updateParent(this.parent); + } else if (this.enabled) { + engine.addEntity(this); + } + } catch (error) { + throw error; } }; diff --git a/src/logic/VLMClaimPoint.logic.ts b/src/logic/VLMClaimPoint.logic.ts index db01dd6..3b2d545 100644 --- a/src/logic/VLMClaimPoint.logic.ts +++ b/src/logic/VLMClaimPoint.logic.ts @@ -1,4 +1,4 @@ -import { VLMClaimPoint, VLMNotification } from "../components"; +import { VLMClaimPoint } from "../components"; import { VLMNotificationManager } from "./VLMNotification.logic"; import messages from "../messages/giveaway"; @@ -10,7 +10,7 @@ export abstract class VLMClaimPointManager { return; } claimPoints.forEach((claimPoint: VLMClaimPoint.VLMConfig) => { - new VLMClaimPoint.DCLConfig(claimPoint); + this.create(claimPoint); }); } catch (error) { throw error; @@ -19,9 +19,6 @@ export abstract class VLMClaimPointManager { static create: CallableFunction = (config: VLMClaimPoint.VLMConfig) => { try { - if (!config.enabled) { - return; - } new VLMClaimPoint.DCLConfig(config); } catch (error) { throw error; @@ -30,38 +27,38 @@ export abstract class VLMClaimPointManager { static update: CallableFunction = (config: VLMClaimPoint.VLMConfig, property: string, id: string) => { try { - const claimPoint = VLMClaimPoint.configs[config.sk]; + const storedConfig = VLMClaimPoint.configs[config.sk]; - if (!claimPoint) { + const { position, scale, rotation } = config; + if (!config || (!storedConfig && !config.enabled)) { return; + } else if (!storedConfig && config.enabled) { + this.create(config) + return this.update(config, property, id); } - const { position, scale, rotation } = config; - switch (property) { case "enabled": - if (!claimPoint.enabled) { - claimPoint.remove(config.sk); - } else if (claimPoint) { - claimPoint.add(config.sk); - } else { - new VLMClaimPoint.DCLConfig(config); + if (!config.enabled) { + this.remove(config.sk); + } else if (storedConfig) { + this.add(config.sk); } break; case "transform": - claimPoint.updateTransform(position, scale, rotation, config.properties); + storedConfig.updateTransform(position, scale, rotation, config.properties); break; case "properties": - claimPoint.updateProperties(config.properties); + storedConfig.updateProperties(config.properties); break; case "customId": - claimPoint.updateCustomId(config.customId); + storedConfig.updateCustomId(config.customId); break; case "customRendering": - claimPoint.updateCustomRendering(config.customRendering); + storedConfig.updateCustomRendering(config.customRendering); break; case "parent": - claimPoint.updateParent(config.parent); + storedConfig.updateParent(config.parent); break; } } catch (error) { @@ -109,6 +106,10 @@ export abstract class VLMClaimPointManager { } }; + static add: CallableFunction = (id: string) => { + VLMClaimPoint.configs[id].add(); + }; + static delete: CallableFunction = (id: string) => { VLMClaimPoint.configs[id].delete(); }; @@ -116,4 +117,5 @@ export abstract class VLMClaimPointManager { static remove: CallableFunction = (id: string) => { VLMClaimPoint.configs[id].remove(); }; + } diff --git a/src/logic/VLMImage.logic.ts b/src/logic/VLMImage.logic.ts index 2b80870..065d95a 100644 --- a/src/logic/VLMImage.logic.ts +++ b/src/logic/VLMImage.logic.ts @@ -3,7 +3,7 @@ import { VLMImage } from "../components/VLMImage.component"; export abstract class VLMImageManager { static init: CallableFunction = (images: VLMImage.VLMConfig[]) => { try { - if (!images) { + if (!images.length) { return; } images.forEach((image: VLMImage.VLMConfig) => { @@ -16,9 +16,6 @@ export abstract class VLMImageManager { static create: CallableFunction = (config: VLMImage.VLMConfig) => { try { - if (!config.enabled) { - return; - } new VLMImage.DCLConfig(config); } catch (error) { throw error; @@ -39,41 +36,40 @@ export abstract class VLMImageManager { static update: CallableFunction = (config: VLMImage.VLMConfig | any, property: string, id: string) => { try { - const image: VLMImage.DCLConfig = VLMImage.configs[config.sk || id]; + const storedConfig: VLMImage.DCLConfig = VLMImage.configs[config.sk || id]; - if (!config || (!image && !config.enabled)) { + if (!config || (!storedConfig && !config.enabled)) { return; - } else if (!image && config.enabled) { - new VLMImage.DCLConfig(config); + } else if (!storedConfig && config.enabled) { + this.create(config) + return this.update(config, property, id); } switch (property) { case "enabled": if (!config.enabled) { this.remove(config.sk); - } else if (image) { + } else if (storedConfig) { this.add(config.sk); - } else { - new VLMImage.DCLConfig(config); } break; case "imageSrc": - image.updateTexture(config); + storedConfig.updateTexture(config); break; case "emission": - image.emissiveIntensity = config.emission; + storedConfig.emissiveIntensity = config.emission; break; case "clickEvent": - image.updateClickEvent(config.clickEvent); + storedConfig.updateClickEvent(config.clickEvent); break; case "isTransparent": - image.updateTransparency(config.isTransparent); + storedConfig.updateTransparency(config.isTransparent); break; case "parent": - image.updateParent(config.parent); + storedConfig.updateParent(config.parent); break; case "customId": - image.updateCustomId(config.customId); + storedConfig.updateCustomId(config.customId); break; } } catch (error) { diff --git a/src/logic/VLMModel.logic.ts b/src/logic/VLMModel.logic.ts index 0f8d07b..159ee90 100644 --- a/src/logic/VLMModel.logic.ts +++ b/src/logic/VLMModel.logic.ts @@ -16,9 +16,6 @@ export abstract class VLMModelManager { static create: CallableFunction = (config: VLMModel.VLMConfig) => { try { - if (!config.enabled) { - return; - } new VLMModel.DCLConfig(config); } catch (error) { throw error; @@ -37,13 +34,13 @@ export abstract class VLMModelManager { } }; - static update: CallableFunction = (config: VLMModel.VLMConfig | any, property: string, id: string) => { + static update: CallableFunction = (config: VLMModel.VLMConfig, property: string, id: string) => { try { - const model: VLMModel.DCLConfig = VLMModel.configs[config.sk || id]; + let storedConfig: VLMModel.DCLConfig = VLMModel.configs[config.sk]; - if (!config || (!model && !config.enabled)) { + if (!config || (!storedConfig && !config.enabled)) { return; - } else if (!model && config.enabled) { + } else if (!storedConfig && config.enabled) { new VLMModel.DCLConfig(config); } @@ -51,23 +48,21 @@ export abstract class VLMModelManager { case "enabled": if (!config.enabled) { this.remove(config.sk); - } else if (model) { + } else if (storedConfig) { this.add(config.sk); - } else { - new VLMModel.DCLConfig(config); } break; case "modelSrc": - model.updateModelSrc(config.modelSrc); + storedConfig.updateModelSrc(config.modelSrc); break; case "clickEvent": - model.updateClickEvent(config.clickEvent); + storedConfig.updateClickEvent(config.clickEvent); break; case "parent": - model.updateParent(config.parent); + storedConfig.updateParent(config.parent); break; case "customId": - model.updateCustomId(config.customId); + storedConfig.updateCustomId(config.customId); break; } } catch (error) { @@ -78,7 +73,7 @@ export abstract class VLMModelManager { static updateInstance: CallableFunction = (instanceConfig: VLMModel.VLMInstanceConfig, property: string, id: string) => { try { const instance = VLMModel.instances[instanceConfig.sk], - configId = instance.configId, + configId = instance?.configId, config = VLMModel.configs[configId]; if (!config) { diff --git a/src/logic/VLMNFT.logic.ts b/src/logic/VLMNFT.logic.ts index 1b0ec7c..187b1ee 100644 --- a/src/logic/VLMNFT.logic.ts +++ b/src/logic/VLMNFT.logic.ts @@ -6,7 +6,7 @@ export abstract class VLMNFTManager { static init: CallableFunction = (nftFrames: VLMNFT.DCLConfig[]) => { try { - if (!nftFrames) { + if (!nftFrames.length) { return; } nftFrames.forEach((nftFrame: VLMNFT.DCLConfig) => { diff --git a/src/logic/VLMScene.logic.ts b/src/logic/VLMScene.logic.ts index 35d84f7..5cb66d5 100644 --- a/src/logic/VLMScene.logic.ts +++ b/src/logic/VLMScene.logic.ts @@ -115,6 +115,7 @@ export abstract class VLMSceneManager { static updateSceneElement: CallableFunction = (message: VLMSceneMessage) => { try { + log(`VLM VLMScene.logic updateSceneElement`, message) if (message.instance) { return this.updateSceneElementInstance(message); } else if (message.setting) { @@ -140,6 +141,7 @@ export abstract class VLMSceneManager { VLMWidgetManager.update(message.elementData, message.user); break; case "claimpoint": + log("VLM - Update Claim Point", message.elementData) VLMClaimPointManager.update(message.elementData, message.property, message.id); break; } diff --git a/src/logic/VLMSound.logic.ts b/src/logic/VLMSound.logic.ts index 5b68035..d5b9694 100644 --- a/src/logic/VLMSound.logic.ts +++ b/src/logic/VLMSound.logic.ts @@ -6,15 +6,12 @@ export abstract class VLMSoundManager { return; } sounds.forEach((sound: VLMSound.VLMConfig) => { - new VLMSound.DCLConfig(sound); + this.create(sound); }); }; static create: CallableFunction = (config: VLMSound.VLMConfig) => { try { - if (!config.enabled) { - return; - } new VLMSound.DCLConfig(config); } catch (error) { throw error; @@ -29,36 +26,37 @@ export abstract class VLMSoundManager { VLMSound.configs[soundId].createInstance(instance); }; - static update: CallableFunction = (soundConfig: VLMSound.VLMConfig | any, property: string, id: string) => { - const sound: VLMSound.DCLConfig = VLMSound.configs[soundConfig.sk]; + static update: CallableFunction = (config: VLMSound.VLMConfig | any, property: string, id: string) => { + const storedConfig: VLMSound.DCLConfig = VLMSound.configs[config.sk]; - if (!soundConfig || (!sound && !soundConfig.enabled)) { + if (!config || (!storedConfig && !config.enabled)) { return; - } else if (!sound && soundConfig.enabled) { - new VLMSound.DCLConfig(soundConfig); + } else if (!storedConfig && config.enabled) { + this.create(config) + return this.update(config, property, id); } switch (property) { case "enabled": - if (!soundConfig.enabled) { - this.remove(soundConfig.sk); - } else if (sound) { - this.add(soundConfig.sk); + if (!config.enabled) { + this.remove(config.sk); + } else if (storedConfig) { + this.add(config.sk); } break; case "sourceType": - sound.updateSourceType(soundConfig.sourceType); + storedConfig.updateSourceType(config.sourceType); break; case "audioSrc": - sound.updateSource(soundConfig.audioSrc); + storedConfig.updateSource(config.audioSrc); break; case "volume": - sound.updateVolume(soundConfig.volume); + storedConfig.updateVolume(config.volume); break; case "properties": - sound.updateParent(soundConfig.parent); - sound.updateCustomId(soundConfig.customId); - sound.updateCustomRendering(soundConfig.customRendering); + storedConfig.updateParent(config.parent); + storedConfig.updateCustomId(config.customId); + storedConfig.updateCustomRendering(config.customRendering); break; } }; diff --git a/src/logic/VLMVideo.logic.ts b/src/logic/VLMVideo.logic.ts index 52ab5d7..85ea681 100644 --- a/src/logic/VLMVideo.logic.ts +++ b/src/logic/VLMVideo.logic.ts @@ -21,9 +21,6 @@ export abstract class VLMVideoManager { static create: CallableFunction = (config: VLMVideo.VLMConfig) => { try { - if (!config.enabled) { - return; - } new VLMVideo.DCLConfig(config); } catch (error) { throw error; @@ -44,58 +41,59 @@ export abstract class VLMVideoManager { static update: CallableFunction = (config: VLMVideo.VLMConfig, property: string, id: string) => { try { - const video: VLMVideo.DCLConfig = VLMVideo.configs[id || config.sk]; + const storedConfig: VLMVideo.DCLConfig = VLMVideo.configs[id || config.sk]; - if (!config || (!video && !config.enabled)) { + if (!config || (!storedConfig && !config.enabled)) { return; - } else if (!video && config.enabled) { - new VLMVideo.DCLConfig(config); + } else if (!storedConfig && config.enabled) { + this.create(config) + return this.update(config, property, id); } switch (property) { case "enabled": if (!config.enabled) { this.remove(config.sk); - } else if (video) { + } else if (storedConfig) { this.add(config.sk); } break; case "liveSrc": - video.liveSrc = config.liveSrc; + storedConfig.liveSrc = config.liveSrc; break; case "enableLiveStream": - video.updateOnAirState(config.enableLiveStream); + storedConfig.updateOnAirState(config.enableLiveStream); break; case "playlist": - video.updatePlaylist(config.playlist); + storedConfig.updatePlaylist(config.playlist); break; case "volume": - video.updateVolume(config.volume); + storedConfig.updateVolume(config.volume); break; case "emission": - video.emissiveIntensity = config.emission || 0; + storedConfig.emissiveIntensity = config.emission || 0; break; case "offType": - video.updateOffType(config.offType); + storedConfig.updateOffType(config.offType); break; case "clickEvent": - video.updateClickEvent(config.clickEvent); + storedConfig.updateClickEvent(config.clickEvent); break; case "properties": - video.updateParent(config.parent); - video.updateCustomId(config.customId); - video.updateCustomRendering(config.customRendering); + storedConfig.updateParent(config.parent); + storedConfig.updateCustomId(config.customId); + storedConfig.updateCustomRendering(config.customRendering); case "offImageSrc": - video.updateOffImage(config.offImageSrc); + storedConfig.updateOffImage(config.offImageSrc); break; case "parent": - video.updateParent(config.parent); + storedConfig.updateParent(config.parent); break; case "customId": - video.updateCustomId(config.customId); + storedConfig.updateCustomId(config.customId); break; case "customRendering": - video.updateCustomRendering(config.customRendering); + storedConfig.updateCustomRendering(config.customRendering); break; } } catch (error) {