Skip to content

Commit

Permalink
bug fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
MetaverseUnknower committed Oct 23, 2023
1 parent 40f14eb commit 3d464b8
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 169 deletions.
25 changes: 19 additions & 6 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
Expand Down Expand Up @@ -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
Expand All @@ -106,6 +112,9 @@ export abstract class VLM {
instances: VLMSound.instances,
systems: VLMSound.systems
},
claimPoints: {
configs: VLMClaimPoint.configs,
},
widgets: {
configs: VLMWidget.configs
}
Expand All @@ -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[],
Expand Down
25 changes: 18 additions & 7 deletions src/components/VLMClaimPoint.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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}`));
Expand Down Expand Up @@ -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");
Expand Down
17 changes: 7 additions & 10 deletions src/components/VLMImage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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];
Expand All @@ -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) {
Expand Down
41 changes: 18 additions & 23 deletions src/components/VLMModel.component.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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];
}
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -223,23 +218,21 @@ 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}`);
this.addComponentOrReplace(model);
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];
Expand All @@ -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) {
Expand Down
21 changes: 17 additions & 4 deletions src/components/VLMNFT.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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 = () => {
Expand Down Expand Up @@ -259,5 +272,5 @@ export namespace VLMNFT {
this.addComponentOrReplace(newShape);
};
}
export class VLMInstanceConfig extends DCLInstanceConfig {}
export class VLMInstanceConfig extends DCLInstanceConfig { }
}
36 changes: 21 additions & 15 deletions src/components/VLMSound.component.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
Loading

0 comments on commit 3d464b8

Please sign in to comment.