Skip to content

Commit eab4264

Browse files
authored
Merge pull request #1378 from ccnmtl/fix-parsurf-story-formulas
Fix parsurf story formulas/reactivity
2 parents 9f0974a + a3e6b11 commit eab4264

File tree

4 files changed

+172
-191
lines changed

4 files changed

+172
-191
lines changed

media/src/stories/Blank.svelte

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,3 @@
66
This is Story Mode. It is in development. Choose a topic to learn more
77
theory, see guided examples, and try out exercises.
88
</p>
9-
10-
{#if animate}
11-
<p>animate found</p>
12-
{:else}
13-
<p>No animate.</p>
14-
{/if}

media/src/stories/FluxIntegral.svelte

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
1818
import { tickTock } from '../stores';
1919
import { demoObjects } from '../states.svelte';
20+
import { mathToJSFunction } from '../objects/mathutils';
2021
2122
let { scene, render, animate } = $props();
2223
@@ -227,14 +228,8 @@
227228
const B = math.parse(currentSurface.params.b);
228229
return B.evaluate();
229230
});
230-
let v0 = $derived.by(() => {
231-
const C = math.parse(currentSurface.params.c);
232-
return (u) => C.evaluate({ u: u });
233-
});
234-
let v1 = $derived.by(() => {
235-
const D = math.parse(currentSurface.params.d);
236-
return (u) => D.evaluate({ u: u });
237-
});
231+
let v0 = $derived(mathToJSFunction(currentSurface.params.c, ['u']));
232+
let v1 = $derived(mathToJSFunction(currentSurface.params.d, ['u']));
238233
239234
let geo = $state();
240235
let geoDown = $state();
@@ -393,16 +388,12 @@
393388
let out;
394389
// const obj = exampleSurfaces.find((o) => o.uuid === uuid);
395390
if (currentSurface) {
396-
const { x, y, z, a, b, c, d } = currentSurface.params;
397-
const [X, Y, Z, A, B, C, D] = [x, y, z, a, b, c, d].map((w) =>
398-
math.parse(w).compile(),
391+
const { x, y, z } = currentSurface.params;
392+
const [X, Y, Z] = [x, y, z].map((w) =>
393+
mathToJSFunction(w, ['u', 'v']),
399394
);
400395
401-
out = (u, v) => [
402-
X.evaluate({ u, v }),
403-
Y.evaluate({ u, v }),
404-
Z.evaluate({ u, v }),
405-
];
396+
out = (u, v) => [X(u, v), Y(u, v), Z(u, v)];
406397
// u0 = A.evaluate();
407398
// u1 = B.evaluate();
408399
// v0 = (u) => C.evaluate({ u });

media/src/stories/PathIntegral.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@
125125
// console.log(segs.geometry);
126126
scene.add(wall);
127127
128+
let ceilingVisible = $state(true);
129+
$effect(() => {
130+
ceiling.visible = ceilingVisible;
131+
});
132+
128133
$effect(() => {
129134
ceiling.geometry?.dispose();
130135
ceiling.geometry = new ParametricGeometry(
@@ -342,7 +347,7 @@
342347
<label class="switch box box-3">
343348
<input
344349
type="checkbox"
345-
bind:checked={ceiling.visible}
350+
bind:checked={ceilingVisible}
346351
onchange={render}
347352
/>
348353
<span class="slider round"></span>

0 commit comments

Comments
 (0)