Skip to content

Commit

Permalink
Remove unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
digisomni committed Sep 27, 2024
1 parent 0e9df71 commit f1d6339
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 42 deletions.
1 change: 0 additions & 1 deletion src/modules/entity/components/components/ModelComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export class ModelComponent extends MeshComponent {
if (scene) {
LightManager.applyLightProperties(meshes, scene);
}

// Script Handling
if (scene) {
ScriptManager.executeScriptsOnMeshes(meshes, scene);
Expand Down
44 changes: 3 additions & 41 deletions src/modules/scene/ScriptManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ export class ScriptManager {
mesh.actionManager = new ActionManager(scene);
}

let script: string = meshMetadata.vircadia_script ?? '';
const script: string = meshMetadata.vircadia_script ?? '';

if (!script) {
script = this.getDefaultScript();
continue;
}

try {
// Wrap the script execution in a setTimeout to ensure the mesh is fully initialized
setTimeout(() => {
this.executeWithContext(script, { mesh, BABYLON, scene });
this.executeWithContext(script, { BABYLON, mesh, scene });
Log.debug(
Log.types.ENTITIES,
`Executed script for mesh ${mesh.name}.`
Expand All @@ -60,44 +60,6 @@ export class ScriptManager {
}
}

private static getDefaultScript(): string {
return `
if (mesh && mesh.actionManager) {
mesh.isPickable = true;
console.info('Mesh action manager: ' + mesh.actionManager + ', mesh is pickable: ' + mesh.isPickable);
// Hover to scale
try {
mesh.actionManager.registerAction(
new BABYLON.ExecuteCodeAction(
BABYLON.ActionManager.OnPointerOverTrigger,
function() {
console.info('Hovering over ' + mesh.name);
mesh.scaling = new BABYLON.Vector3(1.2, 1.2, 1.2);
}
)
);
mesh.actionManager.registerAction(
new BABYLON.ExecuteCodeAction(
BABYLON.ActionManager.OnPointerOutTrigger,
function() {
console.info('Hovering left ' + mesh.name);
mesh.scaling = BABYLON.Vector3.One();
}
)
);
console.log("Interactive script attached to " + mesh.name);
} catch (error) {
console.error("Failed to register hover actions for " + mesh.name + ": " + error);
}
} else {
console.warn("Mesh or action manager not available for " + (mesh ? mesh.name : "unknown mesh"));
}
`;
}

private static transpile(script: string): string {
Log.debug(Log.types.ENTITIES, `Transpiling script: ${script}`);

Expand Down

0 comments on commit f1d6339

Please # to comment.