@bendyline/molen-client 0.0.9 → 0.0.10

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/text.mjs ADDED
@@ -0,0 +1,62 @@
1
+ import * as THREE from "three";
2
+ import { buildTextMesh, buildTextMesh as buildTextMesh$1, loadFontLibrary, vectorFontSchema, vectorFontSchema as vectorFontSchema$1 } from "@bendyline/molen-materials/text";
3
+ import { Font } from "three/addons/loaders/FontLoader.js";
4
+ //#region src/text.ts
5
+ /** Three.js adapter and offline outline compiler for the shared font engine. */
6
+ /** Compile typeface JSON (including TTFLoader output) once, then store the result in a pack.
7
+ * Node and browser compatible; no canvas or OS font dependency. Does not fetch a font.
8
+ */
9
+ function compileVectorFont(data, options) {
10
+ const segments = options.curveSegments ?? 6;
11
+ if (!Number.isInteger(segments) || segments < 2 || segments > 32) throw new Error("curveSegments must be 2–32");
12
+ const font = new Font(data);
13
+ const glyphs = {};
14
+ const round = (value) => Math.round(value * 1e6) / 1e6;
15
+ for (const char of new Set(Array.from(options.characters ?? Object.keys(data.glyphs).join("")))) {
16
+ const glyph = data.glyphs[char];
17
+ if (!glyph) continue;
18
+ const geometry = new THREE.ShapeGeometry(font.generateShapes(char, 1), segments);
19
+ const position = geometry.getAttribute("position");
20
+ const points = [];
21
+ for (let i = 0; i < position.count; i++) points.push(round(position.getX(i)), round(position.getY(i)));
22
+ glyphs[char] = {
23
+ advance: round(glyph.ha / data.resolution),
24
+ positions: points,
25
+ indices: Array.from(geometry.index?.array ?? [])
26
+ };
27
+ geometry.dispose();
28
+ }
29
+ const metrics = data;
30
+ return vectorFontSchema$1.parse({
31
+ format: "molen/vector-font@1",
32
+ id: options.id,
33
+ family: data.familyName,
34
+ weight: options.weight ?? 400,
35
+ style: options.style ?? "normal",
36
+ ascent: round((metrics.ascender ?? data.boundingBox.yMax) / data.resolution),
37
+ descent: round((metrics.descender ?? data.boundingBox.yMin) / data.resolution),
38
+ lineHeight: round(((metrics.ascender ?? data.boundingBox.yMax) - (metrics.descender ?? data.boundingBox.yMin)) / data.resolution),
39
+ glyphs,
40
+ kerning: options.kerning ?? {}
41
+ });
42
+ }
43
+ /** Caller owns/disposes the geometry and chooses its material, color, transform and batching. */
44
+ function createTextGeometry(text, fonts, options = {}) {
45
+ const data = buildTextMesh$1(text, fonts, options);
46
+ const geometry = new THREE.BufferGeometry();
47
+ geometry.setAttribute("position", new THREE.BufferAttribute(data.positions, 3));
48
+ geometry.setIndex(new THREE.BufferAttribute(data.indices, 1));
49
+ geometry.computeVertexNormals();
50
+ geometry.computeBoundingBox();
51
+ geometry.computeBoundingSphere();
52
+ geometry.userData.textLayout = {
53
+ text: data.text,
54
+ width: data.width,
55
+ height: data.height,
56
+ missingGlyphs: data.missingGlyphs,
57
+ truncated: data.truncated
58
+ };
59
+ return geometry;
60
+ }
61
+ //#endregion
62
+ export { buildTextMesh, compileVectorFont, createTextGeometry, loadFontLibrary, vectorFontSchema };
@@ -1,4 +1,4 @@
1
- import { n as ModelSignals, t as ModelSignalVisual } from "./model-signals-DVlLyP-w.mjs";
1
+ import { n as ModelSignals, t as ModelSignalVisual } from "./model-signals-BpeXhsim.mjs";
2
2
  import { VehicleInteriorSpec, VehicleSpec } from "@bendyline/molen-schema";
3
3
  import { Object3D } from "three";
4
4
 
@@ -1,10 +1,13 @@
1
- import { t as createModelSignalVisual } from "./model-signals-Dp5OV-Y0.mjs";
1
+ import { t as createModelSignalVisual } from "./model-signals-DLgvjBeZ.mjs";
2
2
  //#region src/vehicle-interior.ts
3
3
  /** Vehicle convenience wrapper around the platform's model-signal binding system. */
4
4
  function createVehicleInteriorVisual(model, spec) {
5
5
  const visual = createModelSignalVisual(model, spec);
6
6
  return {
7
7
  ...visual,
8
+ get missingSignals() {
9
+ return visual.missingSignals;
10
+ },
8
11
  missingNodes: [...new Set([...spec.nodes.filter((name) => !model.getObjectByName(name)), ...visual.missingNodes])]
9
12
  };
10
13
  }
@@ -1,5 +1,5 @@
1
- import { t as ModelSignalVisual } from "./model-signals-DVlLyP-w.mjs";
2
- import { a as VehicleCameraPose, i as VehicleCameraOptions, n as VehicleInteriorVisual, o as vehicleCameraPose, r as createVehicleInteriorVisual, t as VehicleInteriorSignals } from "./vehicle-interior-GWcXnvXS.mjs";
1
+ import { t as ModelSignalVisual } from "./model-signals-BpeXhsim.mjs";
2
+ import { a as VehicleCameraPose, i as VehicleCameraOptions, n as VehicleInteriorVisual, o as vehicleCameraPose, r as createVehicleInteriorVisual, t as VehicleInteriorSignals } from "./vehicle-interior-BgcC750p.mjs";
3
3
  import { VehicleData, VehiclePlacement } from "@bendyline/molen-schema";
4
4
  import * as THREE from "three";
5
5
 
@@ -9,7 +9,7 @@ interface VehicleVisual {
9
9
  interior?: VehicleInteriorVisual;
10
10
  /** The visual's exterior `animation` bindings, posed from the same signals as the interior. */
11
11
  animation?: ModelSignalVisual;
12
- update(steer: number, wheelAngle: number, signals?: VehicleInteriorSignals): void;
12
+ update(steer: number, wheelAngle: number, signals?: VehicleInteriorSignals, timeSeconds?: number): void;
13
13
  dispose(): void;
14
14
  }
15
15
  /**
package/dist/vehicles.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as createModelSignalVisual } from "./model-signals-Dp5OV-Y0.mjs";
2
- import { t as createVehicleInteriorVisual } from "./vehicle-interior-vJQsRLQy.mjs";
1
+ import { t as createModelSignalVisual } from "./model-signals-DLgvjBeZ.mjs";
2
+ import { t as createVehicleInteriorVisual } from "./vehicle-interior-DfpZwWEh.mjs";
3
3
  import * as THREE from "three";
4
4
  import { mergeGeometries } from "three/addons/utils/BufferGeometryUtils.js";
5
5
  //#region src/vehicle-camera.ts
@@ -84,7 +84,7 @@ function createVehicleVisual(model, vehicle) {
84
84
  object: model,
85
85
  interior,
86
86
  animation,
87
- update(steer, angle, signals) {
87
+ update(steer, angle, signals, timeSeconds) {
88
88
  const roll = signals?.bodyRoll ?? 0;
89
89
  const pitch = signals?.bodyPitch ?? 0;
90
90
  const lean = Number.isFinite(roll) && Number.isFinite(pitch) && (roll !== 0 || pitch !== 0);
@@ -105,8 +105,8 @@ function createVehicleVisual(model, vehicle) {
105
105
  wheelAngle: angle,
106
106
  ...signals
107
107
  };
108
- interior?.update(telemetry);
109
- animation?.update(telemetry);
108
+ interior?.update(telemetry, timeSeconds);
109
+ animation?.update(telemetry, timeSeconds);
110
110
  },
111
111
  dispose() {
112
112
  const geometries = /* @__PURE__ */ new Set();
@@ -0,0 +1,126 @@
1
+ import * as THREE from "three";
2
+ //#region src/three/webgpu-ambient-occlusion.ts
3
+ async function createWebGpuAmbientOcclusion(renderer, scene, camera, options = {}) {
4
+ const [webgpu, tsl, gtao] = await Promise.all([
5
+ import("three/webgpu"),
6
+ import("three/tsl"),
7
+ import("three/addons/tsl/display/GTAONode.js")
8
+ ]);
9
+ const { abs, clamp, colorToDirection, directionToColor, float, Fn, max, mix, mrt, normalView, output, perspectiveDepthToViewZ, rtt, sample, screenUV, select, texture, uniform, uv, vec2, vec4 } = tsl;
10
+ const depthTexture = new THREE.DepthTexture(1, 1);
11
+ if (renderer.reversedDepthBuffer) depthTexture.type = THREE.FloatType;
12
+ const target = new webgpu.RenderTarget(1, 1, {
13
+ count: 2,
14
+ samples: renderer.samples,
15
+ type: THREE.HalfFloatType,
16
+ depthTexture
17
+ });
18
+ target.textures[0].name = "output";
19
+ const normalTexture = target.textures[1];
20
+ normalTexture.name = "normal";
21
+ normalTexture.type = THREE.UnsignedByteType;
22
+ const normals = mrt({
23
+ output,
24
+ normal: directionToColor(normalView)
25
+ });
26
+ const image = texture(target.textures[0]);
27
+ const depth = texture(depthTexture);
28
+ const packed = texture(normalTexture);
29
+ const normal = sample((uv) => colorToDirection(packed.sample(uv)));
30
+ const lens = camera;
31
+ const nearPlane = uniform(lens.near);
32
+ const farPlane = uniform(lens.far);
33
+ const reach = uniform(options.reach ?? 250);
34
+ const meters = (stored) => perspectiveDepthToViewZ(stored, nearPlane, farPlane).negate();
35
+ const viewDepth = (at) => meters(depth.sample(at).r);
36
+ const sceneDepth = sample((uv) => {
37
+ const d = depth.sample(uv).r;
38
+ return vec4(select(meters(d).greaterThan(reach), float(1), d));
39
+ });
40
+ const occlusion = gtao.ao(sceneDepth, normal, camera);
41
+ occlusion.resolutionScale = .5;
42
+ occlusion.radius.value = options.radius ?? 3;
43
+ occlusion.scale.value = 2.5;
44
+ occlusion.distanceFallOff.value = .6;
45
+ occlusion.samples.value = 8;
46
+ const raw = occlusion.getTextureNode();
47
+ const texel = uniform(new THREE.Vector2(1, 1));
48
+ const cleaned = rtt(Fn(() => {
49
+ const at = uv();
50
+ const middle = viewDepth(at).toVar();
51
+ const sum = float(0).toVar();
52
+ const total = float(0).toVar();
53
+ for (const y of [
54
+ -1.5,
55
+ 0,
56
+ 1.5
57
+ ]) for (const x of [
58
+ -1.5,
59
+ 0,
60
+ 1.5
61
+ ]) {
62
+ const tap = at.add(texel.mul(vec2(x, y)));
63
+ const there = viewDepth(tap).toVar();
64
+ const weight = float((x === 0 ? 1 : 2) * (y === 0 ? 1 : 2)).mul(clamp(float(1).sub(abs(there.sub(middle)).div(middle.mul(.08))), 0, 1)).mul(there.lessThanEqual(reach).select(float(1), float(0)));
65
+ sum.addAssign(raw.sample(tap).r.mul(weight));
66
+ total.addAssign(weight);
67
+ }
68
+ return vec4(select(total.greaterThan(0), sum.div(max(total, 1e-4)), float(1)), 0, 0, 1);
69
+ })(), 1, 1);
70
+ const fade = float(1).sub(meters(depth.r).smoothstep(reach.mul(.67), reach));
71
+ const shade = mix(float(1), cleaned.sample(screenUV).r, fade.mul(options.strength ?? .85));
72
+ const pipeline = new webgpu.RenderPipeline(renderer);
73
+ pipeline.outputNode = vec4(image.rgb.mul(shade), image.a);
74
+ const copy = new webgpu.RenderPipeline(renderer);
75
+ copy.outputNode = image;
76
+ const size = new THREE.Vector2();
77
+ const intoTarget = (use) => {
78
+ const previousTarget = renderer.getRenderTarget();
79
+ const previousMrt = renderer.getMRT();
80
+ try {
81
+ renderer.setRenderTarget(target);
82
+ renderer.setMRT(normals);
83
+ return use();
84
+ } finally {
85
+ renderer.setRenderTarget(previousTarget);
86
+ renderer.setMRT(previousMrt);
87
+ }
88
+ };
89
+ return {
90
+ compile: (object) => intoTarget(() => renderer.compileAsync(object, camera, scene)),
91
+ render(sky, occlude = true) {
92
+ renderer.getDrawingBufferSize(size);
93
+ nearPlane.value = lens.near;
94
+ farPlane.value = lens.far;
95
+ if (target.width !== size.x || target.height !== size.y) {
96
+ target.setSize(size.x, size.y);
97
+ cleaned.setSize(Math.ceil(size.x / 2), Math.ceil(size.y / 2));
98
+ texel.value.set(1 / Math.max(1, Math.round(size.x / 2)), 1 / Math.max(1, Math.round(size.y / 2)));
99
+ }
100
+ const autoClear = renderer.autoClear;
101
+ try {
102
+ intoTarget(() => {
103
+ renderer.autoClear = true;
104
+ if (sky) {
105
+ renderer.render(sky.scene, sky.camera);
106
+ renderer.autoClear = false;
107
+ renderer.clearDepth();
108
+ }
109
+ renderer.render(scene, camera);
110
+ });
111
+ } finally {
112
+ renderer.autoClear = autoClear;
113
+ }
114
+ (occlude ? pipeline : copy).render();
115
+ },
116
+ dispose() {
117
+ pipeline.dispose();
118
+ copy.dispose();
119
+ occlusion.dispose();
120
+ cleaned.dispose();
121
+ target.dispose();
122
+ }
123
+ };
124
+ }
125
+ //#endregion
126
+ export { createWebGpuAmbientOcclusion };
@@ -1,5 +1,7 @@
1
1
  import { n as installWebGpuTimestampGuard } from "./webgpu-frame-timer-Xnuq1Hld.mjs";
2
- import { CanvasTarget, WebGPUBackend, WebGPURenderer } from "three/webgpu";
2
+ import { instanceIndex, objectGroup } from "three/tsl";
3
+ import * as WebGPU from "three/webgpu";
4
+ import { CanvasTarget, StorageBufferNode, WebGPUBackend, WebGPURenderer } from "three/webgpu";
3
5
  //#region src/three/webgpu-depth-bias.ts
4
6
  const guardedBackends = /* @__PURE__ */ new WeakSet();
5
7
  /**
@@ -122,6 +124,38 @@ function listenWeakly(ref, material, geometry) {
122
124
  };
123
125
  }
124
126
  //#endregion
127
+ //#region src/three/webgpu-shared-instancing.ts
128
+ const patched = /* @__PURE__ */ new WeakSet();
129
+ /**
130
+ * Give every InstancedMesh drawn with one material the same shader. Three reads an InstancedMesh's
131
+ * matrices from a uniform array declared with the batch's instance count and named after its node,
132
+ * so each batch compiled a WGSL module and a GPU pipeline of its own. Streaming worldgen's plant
133
+ * batches in flight made hundreds a minute, and those created mid-frame, synchronously, stalled the
134
+ * browser's GPU process for seconds. A runtime-sized storage buffer under one name makes the shader
135
+ * text identical, and three's pipeline cache serves every batch after the first; matrices upload
136
+ * when the attribute's version changes, as vertex buffers do. Each batch still builds its node
137
+ * state on the CPU, since three keys that by mesh. (Sharing that state across meshes, each render
138
+ * object binding its own mesh's buffers, broke the WebGPU scene optimizer's render bundles: whole
139
+ * buildings stopped drawing.) Applies to WebGPU backends only; the matrices of the previous frame
140
+ * (velocity) keep three's own path.
141
+ */
142
+ function installWebGpuSharedInstancing(three) {
143
+ const prototype = three.InstanceNode?.prototype;
144
+ const Storage = three.StorageBufferNode;
145
+ const { instanceIndex, objectGroup } = three;
146
+ if (!prototype || patched.has(prototype) || typeof prototype._createInstanceMatrixNode !== "function") return;
147
+ patched.add(prototype);
148
+ const create = prototype._createInstanceMatrixNode;
149
+ prototype._createInstanceMatrixNode = function(assignBuffer, builder) {
150
+ if (!assignBuffer || builder.renderer?.backend?.isWebGPUBackend !== true) return create.call(this, assignBuffer, builder);
151
+ const matrices = this.instanceMatrix;
152
+ const node = new Storage(matrices, "mat4", Math.max(matrices.count, 1));
153
+ node.name = "instanceMatrices";
154
+ node.groupNode = objectGroup;
155
+ return node.element(instanceIndex);
156
+ };
157
+ }
158
+ //#endregion
125
159
  //#region src/three/webgpu-driver.ts
126
160
  /** Loaded only by the asynchronous backend factory, never by a legacy WebGL-only viewer. */
127
161
  async function createWebGpuDriver(options) {
@@ -144,6 +178,12 @@ async function createWebGpuDriver(options) {
144
178
  installWebGpuTimestampGuard(renderer);
145
179
  installWebGpuDepthBiasGuard(renderer);
146
180
  installWebGpuRenderObjectRelease(renderer);
181
+ installWebGpuSharedInstancing({
182
+ InstanceNode: Reflect.get(WebGPU, "InstanceNode"),
183
+ StorageBufferNode,
184
+ instanceIndex,
185
+ objectGroup
186
+ });
147
187
  renderer.getContext();
148
188
  if (options.canvas !== void 0) {
149
189
  const previousTarget = renderer.getCanvasTarget();
@@ -85,6 +85,8 @@ var WebGpuSceneOptimizer = class {
85
85
  matrixSamples = /* @__PURE__ */ new WeakMap();
86
86
  restoreRefresh;
87
87
  materialSamples = /* @__PURE__ */ new Map();
88
+ /** The render each material last refreshed a replayed object in; see the constructor. */
89
+ refreshed = /* @__PURE__ */ new WeakMap();
88
90
  videoMaterials = /* @__PURE__ */ new WeakSet();
89
91
  materialStates = /* @__PURE__ */ new WeakMap();
90
92
  constructor(renderer) {
@@ -94,9 +96,14 @@ var WebGpuSceneOptimizer = class {
94
96
  const refresh = nodes.needsRefresh;
95
97
  nodes.needsRefresh = (object) => {
96
98
  const group = object.bundle;
97
- if (group !== null && this.groups.has(group) && group.eligible && group.version === group.recordedVersion && !renderer.shadowMap.enabled && !renderer.getMRT()?.has("velocity")) {
99
+ if (group !== null && this.groups.has(group) && group.eligible && group.version === group.recordedVersion && !renderer.getMRT()?.has("velocity")) {
98
100
  const monitor = object.getMonitor();
99
- if (!monitor.hasNode && !monitor.hasAnimation && monitor.renderObjects.has(object)) return false;
101
+ const material = object.material;
102
+ if (!monitor.hasAnimation && (monitor.hasNode ? material.userData.bundleStatic === true : monitor.renderObjects.has(object))) {
103
+ const renderId = nodes.nodeFrame.renderId;
104
+ if (this.refreshed.get(material) === renderId) return false;
105
+ this.refreshed.set(material, renderId);
106
+ }
100
107
  }
101
108
  return refresh.call(nodes, object);
102
109
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/molen-client",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -29,6 +29,10 @@
29
29
  "audio"
30
30
  ],
31
31
  "exports": {
32
+ "./text": {
33
+ "types": "./dist/text.d.mts",
34
+ "default": "./dist/text.mjs"
35
+ },
32
36
  ".": {
33
37
  "types": "./dist/index.d.mts",
34
38
  "default": "./dist/index.mjs"
@@ -57,6 +61,10 @@
57
61
  "types": "./dist/markers.d.mts",
58
62
  "default": "./dist/markers.mjs"
59
63
  },
64
+ "./instruments": {
65
+ "types": "./dist/instruments.d.mts",
66
+ "default": "./dist/instruments.mjs"
67
+ },
60
68
  "./audio": {
61
69
  "types": "./dist/audio.d.mts",
62
70
  "default": "./dist/audio.mjs"
@@ -67,9 +75,9 @@
67
75
  "NOTICE.md"
68
76
  ],
69
77
  "dependencies": {
70
- "zod": "^4.6.5",
71
- "@bendyline/molen-materials": "0.0.8",
72
- "@bendyline/molen-schema": "0.0.7"
78
+ "@bendyline/molen-materials": "0.0.9",
79
+ "@bendyline/molen-schema": "0.0.8",
80
+ "zod": "^4.6.5"
73
81
  },
74
82
  "peerDependencies": {
75
83
  "@types/three": ">=0.184.0 <0.187.0",
@@ -1,17 +0,0 @@
1
- import { ModelSignalSource, ModelSignalSpec } from "@bendyline/molen-schema";
2
- import { Object3D } from "three";
3
-
4
- //#region src/model-signals.d.ts
5
- type ModelSignals = Readonly<Record<string, number | undefined>>;
6
- interface ModelSignalVisual {
7
- readonly missingNodes: readonly string[];
8
- update(signals: ModelSignals): void;
9
- /** Restore authored transforms before removing or replacing bindings. */
10
- reset(): void;
11
- }
12
- /** Read data only: no expressions, evaluation, prototype traversal, or simulation writes. */
13
- declare function readModelSignals(sources: Readonly<Record<string, ModelSignalSource>> | undefined, readComponent: (name: string) => unknown): ModelSignals;
14
- /** Model-agnostic; moves existing geometry without creating a cockpit or changing physics. */
15
- declare function createModelSignalVisual(model: Object3D, spec: ModelSignalSpec): ModelSignalVisual;
16
- //#endregion
17
- export { readModelSignals as i, ModelSignals as n, createModelSignalVisual as r, ModelSignalVisual as t };
@@ -1,73 +0,0 @@
1
- //#region src/model-signals.ts
2
- /** Read data only: no expressions, evaluation, prototype traversal, or simulation writes. */
3
- function readModelSignals(sources, readComponent) {
4
- const signals = Object.create(null);
5
- for (const [name, source] of Object.entries(sources ?? {})) {
6
- let value = readComponent(source.component);
7
- for (const part of source.path) {
8
- if (value === null || typeof value !== "object" || !Object.hasOwn(value, part)) {
9
- value = void 0;
10
- break;
11
- }
12
- value = value[part];
13
- }
14
- if (typeof value === "boolean") signals[name] = Number(value);
15
- else if (typeof value === "number" && Number.isFinite(value)) signals[name] = value;
16
- }
17
- return signals;
18
- }
19
- /**
20
- * A binding's displacement for a signal, before its limits: linear in the signal, or along its
21
- * keyframed curve, which holds its end values outside the keys. Exported for tests.
22
- */
23
- function modelSignalDisplacement(binding, signal) {
24
- const keys = binding.keys;
25
- if (keys === void 0) return signal * (binding.scale ?? 1) + (binding.offset ?? 0);
26
- const first = keys[0];
27
- const last = keys[keys.length - 1];
28
- if (first === void 0 || last === void 0) return 0;
29
- if (signal <= first[0]) return first[1];
30
- if (signal >= last[0]) return last[1];
31
- let index = 1;
32
- while (index < keys.length - 1 && signal > (keys[index]?.[0] ?? Infinity)) index++;
33
- const [x0, y0] = keys[index - 1] ?? first;
34
- const [x1, y1] = keys[index] ?? last;
35
- let f = (signal - x0) / (x1 - x0);
36
- if (binding.ease === "smooth") f = f * f * (3 - 2 * f);
37
- return y0 + (y1 - y0) * f;
38
- }
39
- /** Model-agnostic; moves existing geometry without creating a cockpit or changing physics. */
40
- function createModelSignalVisual(model, spec) {
41
- const nodes = /* @__PURE__ */ new Map();
42
- model.traverse((node) => {
43
- const matches = nodes.get(node.name) ?? [];
44
- matches.push(node);
45
- nodes.set(node.name, matches);
46
- });
47
- const missingNodes = [...new Set(spec.bindings.map((b) => b.node))].filter((name) => !nodes.has(name));
48
- const bindings = spec.bindings.flatMap((binding) => (nodes.get(binding.node) ?? []).map((node) => {
49
- node.matrixAutoUpdate = true;
50
- return {
51
- binding,
52
- node,
53
- rest: node[binding.property][binding.axis]
54
- };
55
- }));
56
- return {
57
- missingNodes,
58
- update(signals) {
59
- for (const { binding, node, rest } of bindings) {
60
- const signal = signals[binding.source];
61
- if (signal === void 0 || !Number.isFinite(signal)) continue;
62
- const value = modelSignalDisplacement(binding, signal);
63
- if (!Number.isFinite(value)) continue;
64
- node[binding.property][binding.axis] = rest + Math.max(binding.min ?? -Infinity, Math.min(binding.max ?? Infinity, value));
65
- }
66
- },
67
- reset() {
68
- for (const { binding, node, rest } of bindings) node[binding.property][binding.axis] = rest;
69
- }
70
- };
71
- }
72
- //#endregion
73
- export { readModelSignals as n, createModelSignalVisual as t };