Skip to content

Commit

Permalink
update: add working wave.func
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Jan 16, 2025
1 parent 01cc463 commit 83fc6fd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
25 changes: 19 additions & 6 deletions dist/components/ThreeDEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,14 +791,27 @@ class ThreeDEditor extends _react.default.Component {
enableColorScheme: true
}, this.renderWaveOrThreejsEditorModal()));
}
doWaveFunc(funcStr) {
if (!this.WaveComponent || !this.WaveComponent.wave) {
console.error("Wave component not initialized");
return;
}
const {
wave
} = this.WaveComponent;
try {
// eslint-disable-next-line no-new-func
const func = new Function("wave", `return wave.${funcStr}`);
func(wave);
wave.render();
} catch (error) {
alert("Error executing wave function: " + error.message);
console.error("Error executing wave function:", error);
}
}
handleSetCameraToFitCell() {
alert("Setting camera to fit cell"); // eslint-disable-line no-alert
this.WaveComponent.wave.adjustCamerasAndOrbitControlsToCell();
}
doWaveFunc(func_str) {
alert("Executing function: " + func_str); // eslint-disable-line no-alert
const func = eval(func_str); // eslint-disable-line no-eval
this.WaveComponent.wave.doFunc(func);
this.WaveComponent.wave.rebuildScene();
}
}
exports.ThreeDEditor = ThreeDEditor;
Expand Down
26 changes: 19 additions & 7 deletions src/components/ThreeDEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -785,15 +785,27 @@ export class ThreeDEditor extends React.Component {
}
};

handleSetCameraToFitCell() {
alert("Setting camera to fit cell"); // eslint-disable-line no-alert
this.WaveComponent.wave.adjustCamerasAndOrbitControlsToCell();
doWaveFunc(funcStr) {
if (!this.WaveComponent || !this.WaveComponent.wave) {
console.error("Wave component not initialized");
return;
}

const { wave } = this.WaveComponent;
try {
// eslint-disable-next-line no-new-func
const func = new Function("wave", `return wave.${funcStr}`);
func(wave);
wave.render();
} catch (error) {
alert("Error executing wave function: " + error.message);
console.error("Error executing wave function:", error);
}
}

doWaveFunc(func_str) {
alert("Executing function: " + func_str); // eslint-disable-line no-alert
const func = eval(func_str); // eslint-disable-line no-eval
this.WaveComponent.wave.doFunc(func);
handleSetCameraToFitCell() {
this.WaveComponent.wave.adjustCamerasAndOrbitControlsToCell();
this.WaveComponent.wave.rebuildScene();
}
}

Expand Down

0 comments on commit 83fc6fd

Please sign in to comment.