@glissade/scene 0.5.0-pre.3 → 0.5.0-pre.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -133,7 +133,8 @@ declare function pointAtLength(path: PathValue, s: number): Vec2;
133
133
  interface FollowPathProps extends NodeProps {
134
134
  /** the node to move along the path; its position (and rotation, if orient) is owned by this */
135
135
  target: Node;
136
- path: PathValue;
136
+ /** a static PathValue, or a Path node followed LIVE (re-sampled as its `data` morphs) */
137
+ path: PathValue | Path;
137
138
  /** 0→1 position along the path's arc length; default 1 (the end). Track `<id>/progress`. */
138
139
  progress?: PropInit<number>;
139
140
  /** rotate the target to the path tangent — a cursor that points where it heads; default false */
@@ -154,7 +155,8 @@ declare class FollowPath extends Node {
154
155
  constructor(props: FollowPathProps);
155
156
  protected draw(): void;
156
157
  }
157
- /** `children: [route, cursor, followPath(cursor, route, { orient: true })]` — cursor traces the route. */
158
+ /** `children: [route, cursor, followPath(cursor, route, { orient: true })]` — cursor traces the route.
159
+ * Pass the Path *node* to follow it as it morphs; pass a PathValue for a fixed route. */
158
160
  declare function followPath(target: Node, path: PathValue | Path, props?: Omit<FollowPathProps, 'target' | 'path'>): FollowPath;
159
161
  //#endregion
160
162
  //#region src/tokenHighlight.d.ts
package/dist/index.js CHANGED
@@ -355,25 +355,36 @@ var FollowPath = class extends Node {
355
355
  if (typeof props.progress === "function") this.progress.bindSource(props.progress);
356
356
  else if (props.progress !== void 0) this.progress.set(props.progress);
357
357
  this.registerTarget("progress", this.progress);
358
- const sampler = motionPath(props.path, props.samplesPerSegment !== void 0 ? { samplesPerSegment: props.samplesPerSegment } : {});
359
- props.target.position.bindSource(() => sampler.atProgress(this.progress()));
358
+ const sOpts = props.samplesPerSegment !== void 0 ? { samplesPerSegment: props.samplesPerSegment } : {};
359
+ const getPath = props.path instanceof Path ? () => props.path.data() : () => props.path;
360
+ let cachedPath = getPath();
361
+ let cachedSampler = motionPath(cachedPath, sOpts);
362
+ const sampler = () => {
363
+ const pv = getPath();
364
+ if (pv !== cachedPath) {
365
+ cachedPath = pv;
366
+ cachedSampler = motionPath(pv, sOpts);
367
+ }
368
+ return cachedSampler;
369
+ };
370
+ props.target.position.bindSource(() => sampler().atProgress(this.progress()));
360
371
  if (props.orient) {
361
372
  const offset = props.orientOffset ?? 0;
362
373
  props.target.rotation.bindSource(() => {
363
- const t = sampler.tangentAtProgress(this.progress());
374
+ const t = sampler().tangentAtProgress(this.progress());
364
375
  return Math.atan2(t[1], t[0]) * 180 / Math.PI + offset;
365
376
  });
366
377
  }
367
378
  }
368
379
  draw() {}
369
380
  };
370
- /** `children: [route, cursor, followPath(cursor, route, { orient: true })]` — cursor traces the route. */
381
+ /** `children: [route, cursor, followPath(cursor, route, { orient: true })]` — cursor traces the route.
382
+ * Pass the Path *node* to follow it as it morphs; pass a PathValue for a fixed route. */
371
383
  function followPath(target, path, props = {}) {
372
- const pv = path instanceof Path ? path.data() : path;
373
384
  return new FollowPath({
374
385
  ...props,
375
386
  target,
376
- path: pv
387
+ path
377
388
  });
378
389
  }
379
390
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissade/scene",
3
- "version": "0.5.0-pre.3",
3
+ "version": "0.5.0-pre.4",
4
4
  "description": "glissade scene graph: nodes, transforms, DisplayList emission. Renderer-agnostic; zero DOM/Node dependencies.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "yoga-layout": "^3.2.1",
23
- "@glissade/core": "0.5.0-pre.3"
23
+ "@glissade/core": "0.5.0-pre.4"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",