reze-engine 0.69.2 → 0.69.3

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/engine.js CHANGED
@@ -274,6 +274,7 @@ const CAST_SUBJECT_VEC4S = MAX_EFFECT_SUBJECTS * EFFECT_SUBJECT_VEC4S;
274
274
  const CAST_ANCHOR_VEC4S = MAX_EFFECT_ANCHORS * MAX_EFFECT_SUBJECTS * 3;
275
275
  const CAST_TRAIL_BASE = EFFECT_TRAIL_BASE;
276
276
  const CAST_VEC4S = CAST_TRAIL_BASE + MAX_EFFECT_ANCHORS * MAX_EFFECT_SUBJECTS * TRAIL_SAMPLES;
277
+ const isBoneValue = (v) => typeof v === "object" && v !== null && "bone" in v;
277
278
  export const DEFAULT_BLOOM_OPTIONS = {
278
279
  enabled: true,
279
280
  threshold: 0.7,
@@ -680,8 +681,10 @@ const TEXTURE_EXTENSION_GUESSES = [".png", ".jpg", ".jpeg", ".bmp", ".tga", ".dd
680
681
  * darken every authored colour by the transfer curve twice.
681
682
  */
682
683
  function paramValue(p, given) {
684
+ if (p.kind === "bone")
685
+ return isBoneValue(given) ? given : { bone: typeof p.value === "string" ? p.value : "", model: null };
683
686
  if (given !== undefined)
684
- return given;
687
+ return p.kind === "int" && typeof given === "number" ? Math.round(given) : given;
685
688
  if (p.kind === "color" && typeof p.value === "string") {
686
689
  const n = parseInt(p.value.slice(1), 16);
687
690
  return { x: ((n >> 16) & 255) / 255, y: ((n >> 8) & 255) / 255, z: (n & 255) / 255 };
@@ -4103,7 +4106,19 @@ export class Engine {
4103
4106
  // KIND comes from the declaration, never from the runtime type of the
4104
4107
  // value: a caller handing a number to a colour must not silently turn a
4105
4108
  // vec3f field into an f32 and shift every field after it.
4106
- const isVec = p.kind === "color" || p.kind === "vec3";
4109
+ if (p.kind === "bone") {
4110
+ // Three fields the engine fills each frame — where the bone is, the way
4111
+ // it points, and whether this rig has it — read through rzBone_NAME().
4112
+ for (const [field, vec] of [[p.name, true], [`${p.name}__fwd`, true], [`${p.name}__ok`, false]]) {
4113
+ const align = vec ? 16 : 4;
4114
+ const offset = Math.ceil(cursor / align) * align;
4115
+ layout.set(field, { offset: offset / 4, comps: vec ? 3 : 1 });
4116
+ fields.push(` ${field}: ${vec ? "vec3f" : "f32"},`);
4117
+ cursor = offset + (vec ? 12 : 4);
4118
+ }
4119
+ continue;
4120
+ }
4121
+ const isVec = p.kind === "color" || p.kind === "vec3" || p.kind === "point";
4107
4122
  const align = isVec ? 16 : 4;
4108
4123
  const offset = Math.ceil(cursor / align) * align;
4109
4124
  layout.set(p.name, { offset: offset / 4, comps: isVec ? 3 : 1 });
@@ -4111,16 +4126,34 @@ export class Engine {
4111
4126
  cursor = offset + (isVec ? 12 : 4);
4112
4127
  }
4113
4128
  const paramsData = new Float32Array(Math.max(4, Math.ceil(cursor / 16) * 4));
4129
+ const paramBindings = new Map();
4114
4130
  for (const [name, value] of entries) {
4115
4131
  const slot = layout.get(name);
4132
+ // A bone, and a point that follows someone, are resolved every frame;
4133
+ // their fields start empty and the first evaluation fills them.
4134
+ if (isBoneValue(value)) {
4135
+ paramBindings.set(name, value);
4136
+ continue;
4137
+ }
4116
4138
  if (typeof value === "number")
4117
4139
  paramsData[slot.offset] = value;
4118
4140
  else {
4141
+ if ("model" in value && value.model)
4142
+ paramBindings.set(name, value);
4119
4143
  paramsData[slot.offset] = value.x;
4120
4144
  paramsData[slot.offset + 1] = value.y;
4121
4145
  paramsData[slot.offset + 2] = value.z;
4122
4146
  }
4123
4147
  }
4148
+ // rzBone_NAME() for each bone dial: its own struct rather than RzAnchor, so
4149
+ // the accessor stands in every module a params block is spliced into.
4150
+ const bones = d.params.filter((p) => p.kind === "bone");
4151
+ const boneWgsl = bones.length
4152
+ ? "struct RzBoneParam { pos: vec3f, fwd: vec3f, valid: bool, }\n" +
4153
+ bones
4154
+ .map((p) => `fn rzBone_${p.name}() -> RzBoneParam { return RzBoneParam(params.${p.name}, params.${p.name}__fwd, params.${p.name}__ok > 0.5); }\n`)
4155
+ .join("")
4156
+ : "";
4124
4157
  /**
4125
4158
  * The params block, at whatever binding the pass asking has free.
4126
4159
  *
@@ -4130,7 +4163,7 @@ export class Engine {
4130
4163
  * has no empty struct, and a binding nothing reads is a layout mismatch.
4131
4164
  */
4132
4165
  const paramsWgsl = (binding) => entries.length
4133
- ? `struct EffectParams {\n${fields.join("\n")}\n}\n@group(0) @binding(${binding}) var<uniform> params: EffectParams;\n`
4166
+ ? `struct EffectParams {\n${fields.join("\n")}\n}\n@group(0) @binding(${binding}) var<uniform> params: EffectParams;\n${boneWgsl}`
4134
4167
  : "";
4135
4168
  const paramsDecl = paramsWgsl(EFFECT_PARAMS_BINDING);
4136
4169
  // ── Compile with validation captured, not thrown at the console. Line
@@ -4334,6 +4367,8 @@ export class Engine {
4334
4367
  paramLayout: layout,
4335
4368
  paramsBuffer,
4336
4369
  paramsData,
4370
+ paramBindings,
4371
+ paramTracks: new Map(),
4337
4372
  hasMirror: d.mirror,
4338
4373
  stepped: d.stepped,
4339
4374
  hasBackground,
@@ -4365,6 +4400,7 @@ export class Engine {
4365
4400
  // scheduling it is something a caller does afterwards, and an install
4366
4401
  // that silently began at zero would look like a compile that failed.
4367
4402
  influence: 1,
4403
+ influenceTrack: null,
4368
4404
  window: null,
4369
4405
  weight: 1,
4370
4406
  sim: { start: null, time: null },
@@ -5889,17 +5925,179 @@ export class Engine {
5889
5925
  const fx = this.effects[index];
5890
5926
  if (!fx || !fx.paramsBuffer)
5891
5927
  return;
5892
- const slot = fx.paramLayout.get(name);
5893
- if (!slot)
5928
+ // A keyed dial is its track's: the frame writes it only when the sampled
5929
+ // value changes, so a plain value written over it would stick until then.
5930
+ if (fx.paramTracks.has(name))
5894
5931
  return;
5895
- if (typeof value === "number")
5896
- fx.paramsData[slot.offset] = value;
5897
- else {
5898
- fx.paramsData[slot.offset] = value.x;
5899
- fx.paramsData[slot.offset + 1] = value.y;
5900
- fx.paramsData[slot.offset + 2] = value.z;
5932
+ if (this.writeEffectParam(fx, name, value))
5933
+ this.device.queue.writeBuffer(fx.paramsBuffer, 0, fx.paramsData);
5934
+ // A bone, or a point that now follows someone, lands on the next frame's
5935
+ // evaluation; resolving it now as well means a paused scene shows it too.
5936
+ if (fx.paramBindings.has(name))
5937
+ this.evaluateEffectParams();
5938
+ }
5939
+ /** One dial into the instance's block, by its declared kind. Returns whether
5940
+ * the block changed — a bone changes only its binding, which the frame's
5941
+ * evaluation writes. */
5942
+ writeEffectParam(fx, name, value) {
5943
+ const decl = fx.paramDecls.find((p) => p.name === name);
5944
+ const slot = fx.paramLayout.get(name);
5945
+ if (!decl || !slot)
5946
+ return false;
5947
+ if (decl.kind === "bone") {
5948
+ if (isBoneValue(value))
5949
+ fx.paramBindings.set(name, value);
5950
+ return false;
5901
5951
  }
5902
- this.device.queue.writeBuffer(fx.paramsBuffer, 0, fx.paramsData);
5952
+ if (isBoneValue(value))
5953
+ return false;
5954
+ if (typeof value === "number") {
5955
+ fx.paramsData[slot.offset] = decl.kind === "int" ? Math.round(value) : value;
5956
+ return true;
5957
+ }
5958
+ if (decl.kind === "point" && "model" in value && value.model)
5959
+ fx.paramBindings.set(name, value);
5960
+ else
5961
+ fx.paramBindings.delete(name);
5962
+ fx.paramsData[slot.offset] = value.x;
5963
+ fx.paramsData[slot.offset + 1] = value.y;
5964
+ fx.paramsData[slot.offset + 2] = value.z;
5965
+ return true;
5966
+ }
5967
+ /**
5968
+ * Drive one dial from keys on the transport — the clock the effect's strips
5969
+ * run on, so a key at a clip's start lands at the clip's start in the editor,
5970
+ * a scrub and an export alike. Null, or no keys, gives the dial back to
5971
+ * setEffectParam.
5972
+ *
5973
+ * Numbers, whole numbers, colours, vectors and points travel between keys,
5974
+ * straight or eased; switches, lists and bones hold until the next key. A
5975
+ * track lives on the instance, so an install builds fresh ones and the host
5976
+ * pushes its tracks again, as it does a schedule.
5977
+ */
5978
+ setEffectParamTrack(index, name, keys) {
5979
+ const fx = this.effects[index];
5980
+ const decl = fx?.paramDecls.find((p) => p.name === name);
5981
+ if (!fx || !decl)
5982
+ return false;
5983
+ if (!keys || keys.length === 0) {
5984
+ fx.paramTracks.delete(name);
5985
+ return true;
5986
+ }
5987
+ const holds = decl.kind === "bool" || decl.kind === "enum" || decl.kind === "bone";
5988
+ const bones = [];
5989
+ const sorted = [...keys].sort((a, b) => a.time - b.time);
5990
+ const track = [];
5991
+ for (const k of sorted) {
5992
+ let v;
5993
+ if (decl.kind === "bone") {
5994
+ if (!isBoneValue(k.value))
5995
+ continue;
5996
+ v = bones.push(k.value) - 1;
5997
+ }
5998
+ else if (typeof k.value === "number")
5999
+ v = k.value;
6000
+ else if (isBoneValue(k.value))
6001
+ continue;
6002
+ else
6003
+ v = [k.value.x, k.value.y, k.value.z];
6004
+ track.push({
6005
+ t: k.time,
6006
+ v,
6007
+ e: holds ? "hold" : (k.ease ?? "linear"),
6008
+ ...(!holds && k.curve && k.ease !== "hold" ? { b: k.curve } : {}),
6009
+ });
6010
+ }
6011
+ fx.paramTracks.set(name, { keys: track, bones, last: null });
6012
+ this.evaluateEffectParams();
6013
+ return true;
6014
+ }
6015
+ /**
6016
+ * Every effect's keyed dials at this transport time, then every bone and
6017
+ * followed point where it stands now — once a frame, after the schedules, so
6018
+ * each mount reads this frame's values. One upload per effect, and only for
6019
+ * one whose block moved.
6020
+ */
6021
+ evaluateEffectParams() {
6022
+ let transport = null;
6023
+ for (const fx of this.effects) {
6024
+ if (!fx.paramsBuffer)
6025
+ continue;
6026
+ let dirty = false;
6027
+ for (const [name, track] of fx.paramTracks) {
6028
+ transport ?? (transport = this.transportTime());
6029
+ const v = sampleParamTrack(track.keys, transport);
6030
+ if (v === null || !paramChanged(v, track.last))
6031
+ continue;
6032
+ track.last = v;
6033
+ const decl = fx.paramDecls.find((p) => p.name === name);
6034
+ if (decl?.kind === "bone") {
6035
+ const bone = typeof v === "number" ? track.bones[v] : undefined;
6036
+ if (bone)
6037
+ fx.paramBindings.set(name, bone);
6038
+ }
6039
+ else if (typeof v === "number") {
6040
+ dirty = this.writeEffectParam(fx, name, v) || dirty;
6041
+ }
6042
+ else {
6043
+ const held = fx.paramBindings.get(name);
6044
+ const model = held && !isBoneValue(held) ? held.model : undefined;
6045
+ dirty = this.writeEffectParam(fx, name, { x: v[0], y: v[1], z: v[2], ...(model ? { model } : {}) }) || dirty;
6046
+ }
6047
+ }
6048
+ if (fx.paramBindings.size)
6049
+ dirty = this.resolveParamBindings(fx) || dirty;
6050
+ if (dirty)
6051
+ this.device.queue.writeBuffer(fx.paramsBuffer, 0, fx.paramsData);
6052
+ }
6053
+ }
6054
+ /** Bones and followed points into the block, where they stand this frame. */
6055
+ resolveParamBindings(fx) {
6056
+ const d = fx.paramsData;
6057
+ let moved = false;
6058
+ const put = (offset, x, y, z) => {
6059
+ if (d[offset] === x && d[offset + 1] === y && d[offset + 2] === z)
6060
+ return;
6061
+ d[offset] = x;
6062
+ d[offset + 1] = y;
6063
+ d[offset + 2] = z;
6064
+ moved = true;
6065
+ };
6066
+ const first = () => this.castSubjectNames(fx.subjects)[0] ?? null;
6067
+ for (const [name, value] of fx.paramBindings) {
6068
+ const slot = fx.paramLayout.get(name);
6069
+ if (!slot)
6070
+ continue;
6071
+ const inst = this.modelInstances.get((value.model ?? first()) ?? "");
6072
+ if (isBoneValue(value)) {
6073
+ const fwdSlot = fx.paramLayout.get(`${name}__fwd`);
6074
+ const okSlot = fx.paramLayout.get(`${name}__ok`);
6075
+ const pos = inst?.model.getBoneWorldPosition(value.bone) ?? null;
6076
+ const ok = pos ? 1 : 0;
6077
+ if (okSlot && d[okSlot.offset] !== ok) {
6078
+ d[okSlot.offset] = ok;
6079
+ moved = true;
6080
+ }
6081
+ if (!inst || !pos)
6082
+ continue;
6083
+ const m = inst.model;
6084
+ // Model space into the world, as the cast's own anchors go.
6085
+ pos.setXYZ(pos.x * m.scale, pos.y * m.scale, pos.z * m.scale);
6086
+ Quat.rotateVecInto(m.rotation, pos, pos);
6087
+ put(slot.offset, pos.x + m.position.x, pos.y + m.position.y, pos.z + m.position.z);
6088
+ const fwd = m.getBoneWorldForward(value.bone);
6089
+ if (fwd && fwdSlot) {
6090
+ Quat.rotateVecInto(m.rotation, fwd, fwd);
6091
+ put(fwdSlot.offset, fwd.x, fwd.y, fwd.z);
6092
+ }
6093
+ }
6094
+ else if (inst) {
6095
+ // A followed point: the offset from where she stands.
6096
+ const m = inst.model;
6097
+ put(slot.offset, m.position.x + value.x, m.position.y + value.y, m.position.z + value.z);
6098
+ }
6099
+ }
6100
+ return moved;
5903
6101
  }
5904
6102
  /**
5905
6103
  * How much of one instance is showing, 0..1.
@@ -5935,6 +6133,29 @@ export class Engine {
5935
6133
  // same number would mean two things.
5936
6134
  fx.influence = Math.min(1, Math.max(0, influence));
5937
6135
  }
6136
+ /**
6137
+ * Influence from keys on the transport, the way a dial is keyed: a fade in is
6138
+ * a key at 0 and a key at 1, eased by its curve. Null or no keys gives it
6139
+ * back to setEffectInfluence. It shapes the level the strips ramp toward.
6140
+ */
6141
+ setEffectInfluenceTrack(index, keys) {
6142
+ const fx = this.effects[index];
6143
+ if (!fx)
6144
+ return;
6145
+ const track = [];
6146
+ for (const k of keys ?? []) {
6147
+ if (typeof k.value !== "number")
6148
+ continue;
6149
+ track.push({
6150
+ t: k.time,
6151
+ v: k.value,
6152
+ ...(k.ease ? { e: k.ease } : {}),
6153
+ ...(k.curve && k.ease !== "hold" ? { b: k.curve } : {}),
6154
+ });
6155
+ }
6156
+ track.sort((a, b) => a.t - b.t);
6157
+ fx.influenceTrack = track.length ? track : null;
6158
+ }
5938
6159
  getEffectInfluence(index) {
5939
6160
  return this.effects[index]?.influence ?? 0;
5940
6161
  }
@@ -6022,11 +6243,13 @@ export class Engine {
6022
6243
  const transport = this.transportTime();
6023
6244
  for (const fx of this.effects) {
6024
6245
  fx.simReset = false;
6246
+ const keyed = fx.influenceTrack ? sampleParamTrack(fx.influenceTrack, transport) : null;
6247
+ const level = typeof keyed === "number" ? Math.min(1, Math.max(0, keyed)) : fx.influence;
6025
6248
  if (!fx.window || fx.window.length === 0) {
6026
- fx.weight = fx.influence;
6249
+ fx.weight = level;
6027
6250
  continue;
6028
6251
  }
6029
- const at = effectState(fx.window, fx.influence, transport);
6252
+ const at = effectState(fx.window, level, transport);
6030
6253
  fx.weight = at.weight;
6031
6254
  // The particles and the grid carry state from frame to frame, so they get
6032
6255
  // more than a clock: a restart on entering a window or going back in one,
@@ -15457,6 +15680,9 @@ export class Engine {
15457
15680
  // caller so that playback, the export loop and a warm-up pass cannot
15458
15681
  // disagree about when an effect is alive — none of them has to remember it.
15459
15682
  this.evaluateEffectSchedules();
15683
+ // The dials' keys and the bones and points they follow, on this frame —
15684
+ // after the schedules, before anything reads an effect's block.
15685
+ this.evaluateEffectParams();
15460
15686
  this.stepSim(encoder, deltaTime);
15461
15687
  this.stepParticles(encoder, deltaTime);
15462
15688
  // Before the scene pass, which READS the slots this writes. Same buffer,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_DEPTH_OF_FIELD_OPTIONS, DEFAULT_VIEW_TRANSFORM, DEFAULT_COLOR_GRADING, type ColorGradingOptions, type StageGradeLut, type SceneFog, type StageCastShadow, type SceneFogLayer, type EngineStats, type EngineOptions, type BloomOptions, type DepthOfFieldOptions, type ViewTransformOptions, type ViewTransformName, type LoadModelFromFilesOptions, type MaterialPreset, type MaterialPresetMap, type ModelTransform, type SceneLight, RENDERING_LAYER_DEFAULT, RENDERING_LAYER_CHARACTER, type ModelAttachment, type SceneAovs, type LightProbe, type ReflectionProbeRegion, type PixelFilterType, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectResult, type ViewLut, type CullDiagnostics, type MidiNote, } from "./engine";
1
+ export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_DEPTH_OF_FIELD_OPTIONS, DEFAULT_VIEW_TRANSFORM, DEFAULT_COLOR_GRADING, type ColorGradingOptions, type StageGradeLut, type SceneFog, type StageCastShadow, type SceneFogLayer, type EngineStats, type EngineOptions, type BloomOptions, type DepthOfFieldOptions, type ViewTransformOptions, type ViewTransformName, type LoadModelFromFilesOptions, type MaterialPreset, type MaterialPresetMap, type ModelTransform, type SceneLight, RENDERING_LAYER_DEFAULT, RENDERING_LAYER_CHARACTER, type ModelAttachment, type SceneAovs, type LightProbe, type ReflectionProbeRegion, type PixelFilterType, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectPointValue, type EffectBoneValue, type EffectParamKey, type EffectResult, type ViewLut, type CullDiagnostics, type MidiNote, } from "./engine";
2
2
  export { parsePmxFolderInput, pmxFileAtRelativePath, type PmxFolderInputResult } from "./folder-upload";
3
3
  export { parseMidi } from "./midi-loader";
4
4
  export { parseHDR, type HdrImage } from "./hdr";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,qBAAqB,EACrB,8BAA8B,EAC9B,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB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AAA"}
@@ -24,10 +24,19 @@
24
24
  */
25
25
  /** A parameter value: a scalar, or a vector for the vec3 params. */
26
26
  export type ParamValue = number | [number, number, number];
27
+ /** How the way INTO a key runs: straight, eased in and out, or held at the
28
+ * previous key's value and stepped on arrival. Absent is linear. */
29
+ export type ParamEase = "linear" | "ease" | "hold";
27
30
  export type ParamKey = {
28
31
  /** Seconds on the SCENE clock — the same clock an export steps. */
29
32
  t: number;
30
33
  v: ParamValue;
34
+ /** The segment from the previous key to this one — VMD's rule, where a key
35
+ * carries the curve that arrives at it. */
36
+ e?: ParamEase;
37
+ /** That segment as a bezier — x1, y1, x2, y2 in 0..1, VMD's own curve — in
38
+ * place of `e` when it is not a hold. */
39
+ b?: [number, number, number, number];
31
40
  };
32
41
  /**
33
42
  * The value at `t`.
@@ -1 +1 @@
1
- {"version":3,"file":"param-track.d.ts","sourceRoot":"","sources":["../src/param-track.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,oEAAoE;AACpE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAE1D,MAAM,MAAM,QAAQ,GAAG;IACrB,mEAAmE;IACnE,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,UAAU,CAAA;CACd,CAAA;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CA0B/E;AAED;;+EAE+E;AAC/E,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI,EAAE,CAAC,EAAE,UAAU,GAAG,IAAI,GAAG,OAAO,CAIhF"}
1
+ {"version":3,"file":"param-track.d.ts","sourceRoot":"","sources":["../src/param-track.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,oEAAoE;AACpE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAE1D;qEACqE;AACrE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAElD,MAAM,MAAM,QAAQ,GAAG;IACrB,mEAAmE;IACnE,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,UAAU,CAAA;IACb;gDAC4C;IAC5C,CAAC,CAAC,EAAE,SAAS,CAAA;IACb;8CAC0C;IAC1C,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC,CAAA;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAkC/E;AAED;;+EAE+E;AAC/E,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI,EAAE,CAAC,EAAE,UAAU,GAAG,IAAI,GAAG,OAAO,CAIhF"}
@@ -1,27 +1,4 @@
1
- /**
2
- * A material parameter over time.
3
- *
4
- * The other half of step 5: dissolve, teleport, a look that changes on a beat.
5
- * The per-material channel already exists — setStyleParam writes straight into
6
- * the style uniform — so what was missing was only a way to drive it from the
7
- * scene clock rather than from whenever a caller happened to fire.
8
- *
9
- * WHY THE SAMPLING LIVES HERE, alone in its own file: everything else in this
10
- * feature needs a GPU, and this does not. Keeping it pure is what lets the
11
- * interpolation be tested exhaustively in a headless suite, which matters
12
- * because it is the part with edge cases — the ends, a single key, keys at the
13
- * same instant.
14
- *
15
- * NOT bezier. Bone animation has curves because a VMD carries them and a body
16
- * needs ease; a material parameter is a dial, and a dial that needs shaping can
17
- * be shaped by placing more keys. If eased segments are ever wanted, they
18
- * belong as a property ON a key, not as a second sampler.
19
- *
20
- * DETERMINISTIC BY CONSTRUCTION: the value is a pure function of the scene
21
- * clock, so an offline export stepping frame by frame produces exactly what
22
- * playback did. Anything read from wall time would not, which is the same rule
23
- * the score and audio interfaces already follow.
24
- */
1
+ import { bezierInterpolate } from "./animation";
25
2
  const lerp = (a, b, k) => a + (b - a) * k;
26
3
  /**
27
4
  * The value at `t`.
@@ -59,7 +36,16 @@ export function sampleParamTrack(keys, t) {
59
36
  // by the zero span would be a NaN written into a uniform every frame.
60
37
  if (span <= 0)
61
38
  return b.v;
62
- const k = (t - a.t) / span;
39
+ if (b.e === "hold")
40
+ return a.v;
41
+ const u = (t - a.t) / span;
42
+ // Smoothstep: no jump in speed at either key, which is what makes a dial
43
+ // that eases between two values read as a move rather than as a ramp.
44
+ const k = b.b
45
+ ? bezierInterpolate(b.b[0], b.b[2], b.b[1], b.b[3], u)
46
+ : b.e === "ease"
47
+ ? u * u * (3 - 2 * u)
48
+ : u;
63
49
  if (typeof a.v === "number" && typeof b.v === "number")
64
50
  return lerp(a.v, b.v, k);
65
51
  // Mixed scalar and vector keys are an authoring mistake, not something to
@@ -45,11 +45,12 @@ export type EffectParamOption = {
45
45
  */
46
46
  export type EffectParamDecl = {
47
47
  name: string;
48
- kind: "float" | "color" | "vec3" | "bool" | "enum";
49
- /** Numbers for float/vec3, 0 or 1 for bool, the option's index for enum;
50
- * `#rrggbb` for a colour, which the host converts. */
48
+ kind: "float" | "color" | "vec3" | "bool" | "enum" | "int" | "point" | "bone";
49
+ /** Numbers for float/vec3/int/point, 0 or 1 for bool, the option's index for
50
+ * enum, a bone's NAME for bone; `#rrggbb` for a colour, which the host
51
+ * converts. */
51
52
  value: number | [number, number, number] | string;
52
- /** float only, and only when the author gave a range. */
53
+ /** float and int only, and only when the author gave a range. */
53
54
  min?: number;
54
55
  max?: number;
55
56
  /** enum only: the choices, in index order. */
@@ -1 +1 @@
1
- {"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../../src/shaders/directives.ts"],"names":[],"mappings":"AA8BA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAA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AAE,MAAM,GAAG,IAAI,CAAA;IACrB;;;;;;;;OAQG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;IACd,oEAAoE;IACpE,QAAQ,EAAE,OAAO,CAAA;IACjB;;;;;;;4CAOwC;IACxC,MAAM,EAAE;QAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IACjE;;;;;;;;;;;;;OAaG;IACH,MAAM,EAAE,OAAO,CAAA;IACf;;;;;;;OAOG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;;;;;;;;;;;;OAaG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAuBD;;;+BAG+B;AAC/B,eAAO,MAAM,cAAc,QAAmC,CAAA;AAG9D;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QAA8B,CAAA;AAmCzD,MAAM,MAAM,eAAe,GAAG;IAAE,UAAU,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAEhF,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAmT7D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpD"}
@@ -193,6 +193,45 @@ export function parseDirectives(wgsl) {
193
193
  d.params.push({ name, kind: "bool", value: on ? 1 : 0, ...labels });
194
194
  return;
195
195
  }
196
+ if (kind === "int") {
197
+ // A count: strands, rows, petals. One f32 in the shader like a
198
+ // slider, but whole — the host steps it and a key never lands between.
199
+ const v = num(rest[0]);
200
+ if (v === null || !Number.isInteger(v)) {
201
+ errors.push(`${at}: #param int ${name} needs a whole-number default`);
202
+ return;
203
+ }
204
+ const lo = num(rest[1]);
205
+ const hi = num(rest[2]);
206
+ if ((rest[1] !== undefined) !== (rest[2] !== undefined) || (rest[1] !== undefined && (lo === null || hi === null))) {
207
+ errors.push(`${at}: #param int ${name} takes both a min and a max, or neither`);
208
+ return;
209
+ }
210
+ d.params.push({ name, kind: "int", value: v, ...(lo !== null && hi !== null ? { min: lo, max: hi } : {}), ...labels });
211
+ return;
212
+ }
213
+ if (kind === "point") {
214
+ // A place in the world, in world units — set by dragging it in the
215
+ // scene, and able to follow a character. One vec3f in the shader.
216
+ const v = rest.slice(0, 3).map(num);
217
+ if (rest.length !== 3 || v.some((x) => x === null)) {
218
+ errors.push(`${at}: #param point ${name} needs three numbers, a position like "0 10 0"`);
219
+ return;
220
+ }
221
+ d.params.push({ name, kind: "point", value: v, ...labels });
222
+ return;
223
+ }
224
+ if (kind === "bone") {
225
+ // A bone of a character, picked by the host: read as rzBone_NAME(),
226
+ // a position, a forward and whether that rig has it. The default is
227
+ // the bone's name; whose bone it is, the host decides.
228
+ if (rest.length !== 1) {
229
+ errors.push(`${at}: #param bone ${name} needs one bone name, like 右手首`);
230
+ return;
231
+ }
232
+ d.params.push({ name, kind: "bone", value: rest[0], ...labels });
233
+ return;
234
+ }
196
235
  if (kind === "enum") {
197
236
  // Each choice is `id` or `id|中文`; a leading `*` marks the default,
198
237
  // else the first is.
@@ -250,7 +289,7 @@ export function parseDirectives(wgsl) {
250
289
  d.params.push({ name, kind: "float", value: v, ...(lo !== null && hi !== null ? { min: lo, max: hi } : {}), ...labels });
251
290
  return;
252
291
  }
253
- errors.push(`${at}: #param kind must be float, color, vec3, bool or enum`);
292
+ errors.push(`${at}: #param kind must be float, int, color, vec3, point, bone, bool or enum`);
254
293
  return;
255
294
  }
256
295
  case "halfres":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reze-engine",
3
- "version": "0.69.2",
3
+ "version": "0.69.3",
4
4
  "description": "A lightweight WebGPU engine for real-time 3D MMD/PMX model rendering",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",