@zephyr3d/scene 0.9.0 → 0.9.2

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.
Files changed (149) hide show
  1. package/dist/animation/animationset.js +135 -133
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/cloth/gpu_cloth_system.js +9 -1
  4. package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
  5. package/dist/animation/fixed_geometry_cache_track.js +5 -1
  6. package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
  7. package/dist/animation/geometry_cache_utils.js +20 -4
  8. package/dist/animation/geometry_cache_utils.js.map +1 -1
  9. package/dist/animation/ik/ik_angle_constraint.js +2 -6
  10. package/dist/animation/ik/ik_angle_constraint.js.map +1 -1
  11. package/dist/animation/ik/two_bone_ik_solver.js +2 -6
  12. package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
  13. package/dist/animation/joint_dynamics/collision.js +60 -12
  14. package/dist/animation/joint_dynamics/collision.js.map +1 -1
  15. package/dist/animation/joint_dynamics/constraints.js +20 -4
  16. package/dist/animation/joint_dynamics/constraints.js.map +1 -1
  17. package/dist/animation/joint_dynamics/controller.js +151 -103
  18. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  19. package/dist/animation/joint_dynamics/solver.js +21 -11
  20. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  21. package/dist/animation/joint_dynamics/types.js +15 -3
  22. package/dist/animation/joint_dynamics/types.js.map +1 -1
  23. package/dist/animation/pca_geometry_cache_track.js +5 -1
  24. package/dist/animation/pca_geometry_cache_track.js.map +1 -1
  25. package/dist/animation/skeleton.js +2 -2
  26. package/dist/animation/skeleton.js.map +1 -1
  27. package/dist/animation/skeleton_modifier.js +2 -6
  28. package/dist/animation/skeleton_modifier.js.map +1 -1
  29. package/dist/animation/spring/spring_system.js +87 -114
  30. package/dist/animation/spring/spring_system.js.map +1 -1
  31. package/dist/app/app.js.map +1 -1
  32. package/dist/app/engine.js +1 -1
  33. package/dist/app/engine.js.map +1 -1
  34. package/dist/app/screen.js +4 -4
  35. package/dist/app/screen.js.map +1 -1
  36. package/dist/app/scriptingsystem.js +24 -1
  37. package/dist/app/scriptingsystem.js.map +1 -1
  38. package/dist/app/scriptregistry.js +165 -144
  39. package/dist/app/scriptregistry.js.map +1 -1
  40. package/dist/asset/assetmanager.js +2 -2
  41. package/dist/asset/assetmanager.js.map +1 -1
  42. package/dist/asset/model.js +3 -3
  43. package/dist/asset/model.js.map +1 -1
  44. package/dist/camera/camera.js +185 -185
  45. package/dist/camera/camera.js.map +1 -1
  46. package/dist/camera/orbit.js.map +1 -1
  47. package/dist/index.d.ts +794 -261
  48. package/dist/index.js +2 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/material/material.js +290 -288
  51. package/dist/material/material.js.map +1 -1
  52. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +13 -26
  53. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  54. package/dist/material/pbrmr.js +1 -11
  55. package/dist/material/pbrmr.js.map +1 -1
  56. package/dist/material/sprite.js +6 -6
  57. package/dist/material/sprite.js.map +1 -1
  58. package/dist/material/terrain-cm.js +2 -2
  59. package/dist/material/terrain-cm.js.map +1 -1
  60. package/dist/posteffect/taa.js +31 -39
  61. package/dist/posteffect/taa.js.map +1 -1
  62. package/dist/render/drawable.js +5 -1
  63. package/dist/render/drawable.js.map +1 -1
  64. package/dist/render/rendergraph/device_pool_allocator.js +29 -3
  65. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  66. package/dist/render/rendergraph/executor.js +283 -33
  67. package/dist/render/rendergraph/executor.js.map +1 -1
  68. package/dist/render/rendergraph/forward_plus_builder.js +338 -108
  69. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  70. package/dist/render/rendergraph/history_resource_manager.js +236 -156
  71. package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  72. package/dist/render/rendergraph/history_resources.js +10 -0
  73. package/dist/render/rendergraph/history_resources.js.map +1 -0
  74. package/dist/render/rendergraph/rendergraph.js +162 -35
  75. package/dist/render/rendergraph/rendergraph.js.map +1 -1
  76. package/dist/render/rendergraph/types.js +36 -16
  77. package/dist/render/rendergraph/types.js.map +1 -1
  78. package/dist/render/rendertarget.js +5 -1
  79. package/dist/render/rendertarget.js.map +1 -1
  80. package/dist/render/screenrendertarget.js +5 -1
  81. package/dist/render/screenrendertarget.js.map +1 -1
  82. package/dist/render/sky.js +4 -4
  83. package/dist/render/sky.js.map +1 -1
  84. package/dist/scene/basesprite.js +2 -2
  85. package/dist/scene/basesprite.js.map +1 -1
  86. package/dist/scene/graph_node.js +1 -1
  87. package/dist/scene/graph_node.js.map +1 -1
  88. package/dist/scene/mesh.js +4 -20
  89. package/dist/scene/mesh.js.map +1 -1
  90. package/dist/scene/particlesys.js +1 -1
  91. package/dist/scene/particlesys.js.map +1 -1
  92. package/dist/scene/scene_node.js +2 -2
  93. package/dist/scene/scene_node.js.map +1 -1
  94. package/dist/scene/script_attachment.js +15 -3
  95. package/dist/scene/script_attachment.js.map +1 -1
  96. package/dist/scene/terrain-cm/terrain-cm.js +3 -3
  97. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  98. package/dist/shadow/shadowmapper.js.map +1 -1
  99. package/dist/shapes/box.js +1 -1
  100. package/dist/shapes/box.js.map +1 -1
  101. package/dist/shapes/capsule.js +0 -3
  102. package/dist/shapes/capsule.js.map +1 -1
  103. package/dist/shapes/cylinder.js +0 -3
  104. package/dist/shapes/cylinder.js.map +1 -1
  105. package/dist/shapes/plane.js +0 -3
  106. package/dist/shapes/plane.js.map +1 -1
  107. package/dist/shapes/tetrahedron.js +3 -9
  108. package/dist/shapes/tetrahedron.js.map +1 -1
  109. package/dist/shapes/torus.js +4 -7
  110. package/dist/shapes/torus.js.map +1 -1
  111. package/dist/utility/blueprint/material/inputs.js +3 -3
  112. package/dist/utility/blueprint/material/inputs.js.map +1 -1
  113. package/dist/utility/blueprint/material/ir.js +493 -493
  114. package/dist/utility/blueprint/material/ir.js.map +1 -1
  115. package/dist/utility/serialization/manager.js +34 -3
  116. package/dist/utility/serialization/manager.js.map +1 -1
  117. package/dist/utility/serialization/scene/animation.js +45 -0
  118. package/dist/utility/serialization/scene/animation.js.map +1 -1
  119. package/dist/utility/serialization/scene/camera.js +53 -0
  120. package/dist/utility/serialization/scene/camera.js.map +1 -1
  121. package/dist/utility/serialization/scene/common.js +10 -0
  122. package/dist/utility/serialization/scene/common.js.map +1 -1
  123. package/dist/utility/serialization/scene/light.js +30 -0
  124. package/dist/utility/serialization/scene/light.js.map +1 -1
  125. package/dist/utility/serialization/scene/material.js +63 -0
  126. package/dist/utility/serialization/scene/material.js.map +1 -1
  127. package/dist/utility/serialization/scene/mesh.js +11 -0
  128. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  129. package/dist/utility/serialization/scene/misc.js +2 -0
  130. package/dist/utility/serialization/scene/misc.js.map +1 -1
  131. package/dist/utility/serialization/scene/node.js +19 -0
  132. package/dist/utility/serialization/scene/node.js.map +1 -1
  133. package/dist/utility/serialization/scene/particle.js +22 -0
  134. package/dist/utility/serialization/scene/particle.js.map +1 -1
  135. package/dist/utility/serialization/scene/primitive.js +33 -0
  136. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  137. package/dist/utility/serialization/scene/scene.js +39 -0
  138. package/dist/utility/serialization/scene/scene.js.map +1 -1
  139. package/dist/utility/serialization/scene/script.js +2 -0
  140. package/dist/utility/serialization/scene/script.js.map +1 -1
  141. package/dist/utility/serialization/scene/sprite.js +6 -0
  142. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  143. package/dist/utility/serialization/scene/terrain.js +9 -0
  144. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  145. package/dist/utility/serialization/scene/water.js +21 -0
  146. package/dist/utility/serialization/scene/water.js.map +1 -1
  147. package/dist/utility/serialization/types.js +5 -1
  148. package/dist/utility/serialization/types.js.map +1 -1
  149. package/package.json +2 -2
@@ -3,8 +3,18 @@ import { buildConstraints, buildSurfaceFaces } from './constraints.js';
3
3
  import { simulate, applyAngleLimits, applyResult } from './solver.js';
4
4
  import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
5
5
 
6
- // High-level orchestrator SPCRJointDynamicsController API
7
- class JointDynamicsSystemController {
6
+ // High-level orchestrator - SPCRJointDynamicsController API
7
+ /**
8
+ * High-level controller for joint dynamics simulation.
9
+ *
10
+ * This class manages the physics simulation for a hierarchy of bones, including constraints,
11
+ * colliders, and grabbers. It provides an API for initializing the system with bone data and
12
+ * transforms, stepping the simulation each frame, and modifying colliders and grabbers at runtime.
13
+ * The controller handles the internal state and logic for blending between animation and physics,
14
+ * applying forces, and enforcing constraints.
15
+ *
16
+ * @public
17
+ */ class JointDynamicsSystemController {
8
18
  _config;
9
19
  _pointsR = [];
10
20
  _pointsRW = [];
@@ -43,14 +53,14 @@ class JointDynamicsSystemController {
43
53
  constructor(config){
44
54
  this._config = config;
45
55
  }
46
- /**
47
- * 初始化物理系统
48
- * @param rootTransform 根骨骼的 transform(用于检测根运动)
49
- * @param rootPoints 骨骼层级的根节点数组(可以有多个根,如裙子的多条链)
50
- * @param pointTransforms 所有物理点的 transform 数组(顺序必须与 BoneNode.index 对应)
51
- * @param colliders 碰撞器数组(球体/胶囊体)
52
- * @param grabbers 抓取器数组(用于鼠标交互等)
53
- * @param flatPlanes 平面限制器数组(如地板,防止穿透)
56
+ /**
57
+ * Initializes the physics system.
58
+ * @param rootTransform - Root bone transform used to detect root motion.
59
+ * @param rootPoints - Root nodes of the bone hierarchy. Multiple roots are allowed.
60
+ * @param pointTransforms - Transform array for all physics points. Order must match `BoneNode.index`.
61
+ * @param colliders - Collider array (spheres/capsules).
62
+ * @param grabbers - Grabber array used for interactions such as mouse dragging.
63
+ * @param flatPlanes - Plane limiters such as the floor to prevent penetration.
54
64
  */ initialize(rootTransform, rootPoints, pointTransforms, colliders, grabbers, flatPlanes) {
55
65
  this._rootTransform = rootTransform;
56
66
  this._pointTransforms = pointTransforms;
@@ -61,7 +71,7 @@ class JointDynamicsSystemController {
61
71
  this._surfaceConstraints = buildSurfaceFaces(rootPoints, this._config.constraintOptions.isLoop);
62
72
  // Flatten bone hierarchy to point list, build parent map
63
73
  const allPoints = [];
64
- const parentMap = new Map(); // child index parent index
74
+ const parentMap = new Map(); // child index -> parent index
65
75
  function walk(node) {
66
76
  allPoints.push(node);
67
77
  for (const c of node.children){
@@ -140,10 +150,11 @@ class JointDynamicsSystemController {
140
150
  }
141
151
  this._initialized = true;
142
152
  }
143
- /**
144
- * 执行一帧物理模拟
145
- * 内部流程:读取当前 transform 运行 Verlet 积分和约束求解 写回 transform
146
- * @param deltaTime 帧间隔时间(秒)。内部会被 subSteps 细分
153
+ /**
154
+ * Advances the simulation by one frame.
155
+ * Internal flow: read current transforms, run Verlet integration and constraint solving,
156
+ * then write the result back to the transforms.
157
+ * @param deltaTime - Frame delta time in seconds. Internally subdivided by `subSteps`.
147
158
  */ step(deltaTime) {
148
159
  if (!this._initialized || !this._rootTransform) {
149
160
  return;
@@ -218,10 +229,10 @@ class JointDynamicsSystemController {
218
229
  this._previousRootPosition = rootPos;
219
230
  this._previousRootRotation = rootRot;
220
231
  }
221
- /**
222
- * 获取所有点的模拟结果(世界坐标位置和旋转)
223
- * 通常不需要手动调用——step() 已经自动写回 transform。
224
- * 适用于需要在不写回 transform 的情况下读取物理结果的场景。
232
+ /**
233
+ * Returns the simulated results for all points as world-space positions and rotations.
234
+ * Usually this does not need to be called manually because `step()` already writes the
235
+ * output back to the transforms.
225
236
  */ getResults() {
226
237
  const transformRots = this._pointTransforms.map((t)=>t.getWorldRotation());
227
238
  const transformLocalRots = this._pointTransforms.map((t)=>t.getLocalRotation());
@@ -231,10 +242,10 @@ class JointDynamicsSystemController {
231
242
  rotation: o.rotation
232
243
  }));
233
244
  }
234
- /**
235
- * 瞬移补偿——在角色传送/瞬移后调用
236
- * 将上一帧的根骨骼位置和旋转设为当前值,
237
- * 使下一帧的根运动增量为零,避免物理点因巨大位移而弹射。
245
+ /**
246
+ * Compensates for teleportation by resetting the previous root transform to the current one.
247
+ * Call this after a character warp or teleport to avoid a large root-motion impulse on the
248
+ * next simulation step.
238
249
  */ warp() {
239
250
  if (!this._rootTransform) {
240
251
  return;
@@ -242,10 +253,10 @@ class JointDynamicsSystemController {
242
253
  this._previousRootPosition = this._rootTransform.getWorldPosition();
243
254
  this._previousRootRotation = this._rootTransform.getWorldRotation();
244
255
  }
245
- /**
246
- * 重置所有物理状态
247
- * 将所有点的模拟位置重置为当前 transform 位置,清除速度和抓取状态。
248
- * 适用于场景切换或需要消除所有物理运动的场景。
256
+ /**
257
+ * Resets all physics state.
258
+ * Each simulated point is snapped back to the current transform position and grab state
259
+ * is cleared.
249
260
  */ reset() {
250
261
  for(let i = 0; i < this._pointsRW.length; i++){
251
262
  const pos = this._pointTransforms[i].getWorldPosition();
@@ -255,10 +266,10 @@ class JointDynamicsSystemController {
255
266
  }
256
267
  this._fakeWaveCounter = 0;
257
268
  }
258
- /**
259
- * 释放固定点为动态点(如脱衣、布料脱落)
260
- * weight 0 改为 1,同时重置该点的模拟状态避免瞬间弹射。
261
- * @param index 点的索引
269
+ /**
270
+ * Releases a fixed point so it becomes dynamic, for example when cloth is detached.
271
+ * The point state is reset to avoid a sudden impulse.
272
+ * @param index - Point index.
262
273
  */ releasePoint(index) {
263
274
  if (index < 0 || index >= this._pointsR.length) {
264
275
  return;
@@ -269,10 +280,10 @@ class JointDynamicsSystemController {
269
280
  this._pointsRW[index].positionPrevious = pos.clone();
270
281
  this._pointsRW[index].grabberIndex = -1;
271
282
  }
272
- /**
273
- * 将动态点重新固定为跟随动画(如重新穿戴)
274
- * weight 1 改为 0,清除抓取状态。
275
- * @param index 点的索引
283
+ /**
284
+ * Fixes a dynamic point back to the animation pose, for example when an item is reattached.
285
+ * The point grab state is cleared.
286
+ * @param index - Point index.
276
287
  */ fixPoint(index) {
277
288
  if (index < 0 || index >= this._pointsR.length) {
278
289
  return;
@@ -280,44 +291,47 @@ class JointDynamicsSystemController {
280
291
  this._pointsR[index].weight = 0;
281
292
  this._pointsRW[index].grabberIndex = -1;
282
293
  }
283
- /**
284
- * 查询某个点是否为固定状态(weight=0,跟随动画)
285
- * @param index 点的索引
294
+ /**
295
+ * Returns whether a point is fixed to animation (`weight = 0`).
296
+ * @param index - Point index.
286
297
  */ isPointFixed(index) {
287
298
  if (index < 0 || index >= this._pointsR.length) {
288
299
  return false;
289
300
  }
290
301
  return this._pointsR[index].weight <= EPSILON;
291
302
  }
292
- /** 获取物理点总数 */ get pointCount() {
303
+ /** Gets the total number of physics points. */ get pointCount() {
293
304
  return this._pointsR.length;
294
305
  }
295
- /**
296
- * 渐入物理——从动画姿态平滑过渡到物理模拟
297
- * blendRatio 1(纯动画)渐变到 0(纯物理)
298
- * @param seconds 过渡时长(秒)
306
+ /**
307
+ * Fades physics in by blending from animation pose to simulation.
308
+ * `blendRatio` moves from `1` (animation only) to `0` (physics only).
309
+ * @param seconds - Transition duration in seconds.
299
310
  */ fadeIn(seconds) {
300
311
  this._fadeState = 'in';
301
312
  this._fadeTimer = 0;
302
313
  this._fadeDuration = seconds;
303
314
  }
304
- /**
305
- * 渐出物理——从物理模拟平滑过渡回动画姿态
306
- * blendRatio 0(纯物理)渐变到 1(纯动画)
307
- * @param seconds 过渡时长(秒)
315
+ /**
316
+ * Fades physics out by blending from simulation back to animation pose.
317
+ * `blendRatio` moves from `0` (physics only) to `1` (animation only).
318
+ * @param seconds - Transition duration in seconds.
308
319
  */ fadeOut(seconds) {
309
320
  this._fadeState = 'out';
310
321
  this._fadeTimer = 0;
311
322
  this._fadeDuration = seconds;
312
323
  }
313
- /**
314
- * 设置全局风力向量
315
- * 风力会按每个点的 windForceScale 和质量进行缩放
316
- * @param wind 风力向量(世界坐标)
324
+ /**
325
+ * Sets the global wind force vector.
326
+ * The final wind contribution is still scaled per point by `windForceScale` and mass.
327
+ * @param wind - Wind vector in world space.
317
328
  */ setWindForce(wind) {
318
329
  this._config.windForce = wind;
319
330
  }
320
- /** Enable/disable broad-phase pruning for runtime performance comparison */ setBroadPhaseEnabled(enabled) {
331
+ /**
332
+ * Enable/disable broad-phase pruning for runtime performance comparison
333
+ * @param enabled - `true` to enable broad-phase, `false` to disable.
334
+ */ setBroadPhaseEnabled(enabled) {
321
335
  this._config.enableBroadPhase = enabled;
322
336
  }
323
337
  /** The blend ratio for the physics simulation */ get blendRatio() {
@@ -326,17 +340,23 @@ class JointDynamicsSystemController {
326
340
  set blendRatio(value) {
327
341
  this._config.blendRatio = clamp01(value);
328
342
  }
329
- /**
330
- * 暂停/恢复物理模拟
331
- * 暂停时仍会跟随根骨骼运动,但不进行力学积分和约束求解
332
- * @param paused true=暂停, false=恢复
343
+ /**
344
+ * Pauses or resumes the physics simulation.
345
+ * While paused, the system still follows root motion but skips force integration and
346
+ * constraint solving.
347
+ * @param paused - `true` to pause, `false` to resume.
333
348
  */ setPaused(paused) {
334
349
  this._isPaused = paused;
335
350
  }
336
- /**
337
- * Enable or disable a collider by current array index.
338
- * Transform state is still read from the collider's TransformAccess each frame.
339
- * Prefer setColliderEnabled(handle, enabled) for runtime-owned colliders.
351
+ /**
352
+ * Enable or disable a collider by current array index.
353
+ * Transform state is still read from the collider's TransformAccess each frame.
354
+ * Prefer setColliderEnabled(handle, enabled) for runtime-owned colliders.
355
+ *
356
+ * @param index - Collider index in the current array. Note that this may change when colliders are added or removed.
357
+ * @param enabled - `true` to enable the collider, `false` to disable it.
358
+ *
359
+ * @returns `true` if the index is valid and the collider was updated, `false` if the index is out of range.
340
360
  */ setColliderEnabledAt(index, enabled) {
341
361
  if (index >= 0 && index < this._collidersRW.length) {
342
362
  this._collidersRW[index].enabled = enabled ? 1 : 0;
@@ -344,9 +364,12 @@ class JointDynamicsSystemController {
344
364
  }
345
365
  return false;
346
366
  }
347
- /**
348
- * Enable or disable a runtime collider by stable handle.
349
- * @returns true if the handle is still valid.
367
+ /**
368
+ * Enable or disable a runtime collider by stable handle.
369
+ *
370
+ * @param handle - Stable handle for the collider to enable or disable.
371
+ * @param enabled - `true` to enable the collider, `false` to disable it.
372
+ * @returns true if the handle is still valid.
350
373
  */ setColliderEnabled(handle, enabled) {
351
374
  const index = this._getColliderIndex(handle);
352
375
  if (index === -1) {
@@ -354,9 +377,11 @@ class JointDynamicsSystemController {
354
377
  }
355
378
  return this.setColliderEnabledAt(index, enabled);
356
379
  }
357
- /**
358
- * Add a collider at runtime.
359
- * @returns A stable handle that remains valid until this collider is removed.
380
+ /**
381
+ * Add a collider at runtime.
382
+ * @param r - Read-only collider data such as shape and size.
383
+ * @param transform - TransformAccess that provides the collider's position and rotation each frame.
384
+ * @returns A stable handle that remains valid until this collider is removed.
360
385
  */ addCollider(r, transform) {
361
386
  const id = this._nextColliderHandleId++;
362
387
  this._collidersR.push(r);
@@ -369,9 +394,10 @@ class JointDynamicsSystemController {
369
394
  id
370
395
  };
371
396
  }
372
- /**
373
- * Remove a collider by stable handle.
374
- * @returns true if the collider existed and was removed.
397
+ /**
398
+ * Remove a collider by stable handle.
399
+ * @param handle - Stable handle for the collider to remove.
400
+ * @returns true if the collider existed and was removed.
375
401
  */ removeCollider(handle) {
376
402
  const index = this._getColliderIndex(handle);
377
403
  if (index === -1) {
@@ -379,9 +405,10 @@ class JointDynamicsSystemController {
379
405
  }
380
406
  return this.removeColliderAt(index);
381
407
  }
382
- /**
383
- * Remove a collider by current array index.
384
- * Prefer removeCollider(handle) for runtime-owned colliders.
408
+ /**
409
+ * Remove a collider by current array index.
410
+ * @param index - Collider index in the current array. Note that this may change when colliders are added or removed.
411
+ * Prefer removeCollider(handle) for runtime-owned colliders.
385
412
  */ removeColliderAt(index) {
386
413
  if (index < 0 || index >= this._collidersR.length) {
387
414
  return false;
@@ -393,9 +420,11 @@ class JointDynamicsSystemController {
393
420
  this._rebuildColliderHandleMap();
394
421
  return true;
395
422
  }
396
- /**
397
- * Enable or disable a flat plane by current array index.
398
- * Prefer setFlatPlaneEnabled(handle, enabled) for runtime-owned flat planes.
423
+ /**
424
+ * Enable or disable a flat plane by current array index.
425
+ * @param index - Flat plane index in the current array. Note that this may change when flat planes are added or removed.
426
+ * @param enabled - `true` to enable the flat plane, `false` to disable it.
427
+ * @returns `true` if the index is valid and the flat plane was updated, `false` if the index is out of range.
399
428
  */ setFlatPlaneEnabledAt(index, enabled) {
400
429
  if (index < 0 || index >= this._flatPlaneAll.length) {
401
430
  return false;
@@ -404,9 +433,11 @@ class JointDynamicsSystemController {
404
433
  this._rebuildActiveFlatPlanes();
405
434
  return true;
406
435
  }
407
- /**
408
- * Enable or disable a runtime flat plane by stable handle.
409
- * @returns true if the handle is still valid.
436
+ /**
437
+ * Enable or disable a runtime flat plane by stable handle.
438
+ * @param handle - Stable handle for the flat plane to enable or disable.
439
+ * @param enabled - `true` to enable the flat plane, `false` to disable it.
440
+ * @returns true if the handle is still valid.
410
441
  */ setFlatPlaneEnabled(handle, enabled) {
411
442
  const index = this._getFlatPlaneIndex(handle);
412
443
  if (index === -1) {
@@ -414,9 +445,11 @@ class JointDynamicsSystemController {
414
445
  }
415
446
  return this.setFlatPlaneEnabledAt(index, enabled);
416
447
  }
417
- /**
418
- * Add a flat plane at runtime.
419
- * @returns A stable handle that remains valid until this flat plane is removed.
448
+ /**
449
+ * Add a flat plane at runtime.
450
+ * @param up - Up direction of the plane. The normal is computed as `Vector3.normalize(up)`.
451
+ * @param position - A point on the plane. The distance is computed as `-Vector3.dot(normal, position)`.
452
+ * @returns A stable handle that remains valid until this flat plane is removed.
420
453
  */ addFlatPlane(up, position) {
421
454
  const id = this._nextFlatPlaneHandleId++;
422
455
  const normal = Vector3.normalize(up);
@@ -433,9 +466,10 @@ class JointDynamicsSystemController {
433
466
  id
434
467
  };
435
468
  }
436
- /**
437
- * Remove a flat plane by stable handle.
438
- * @returns true if the flat plane existed and was removed.
469
+ /**
470
+ * Remove a flat plane by stable handle.
471
+ * @param handle - Stable handle for the flat plane to remove.
472
+ * @returns true if the flat plane existed and was removed.
439
473
  */ removeFlatPlane(handle) {
440
474
  const index = this._getFlatPlaneIndex(handle);
441
475
  if (index === -1) {
@@ -443,9 +477,10 @@ class JointDynamicsSystemController {
443
477
  }
444
478
  return this.removeFlatPlaneAt(index);
445
479
  }
446
- /**
447
- * Remove a flat plane by current array index.
448
- * Prefer removeFlatPlane(handle) for runtime-owned flat planes.
480
+ /**
481
+ * Remove a flat plane by current array index.
482
+ * @param index - Flat plane index in the current array. Note that this may change when flat planes are added or removed.
483
+ * @returns true if the index was valid and the flat plane was removed, false if the index was out of range.
449
484
  */ removeFlatPlaneAt(index) {
450
485
  if (index < 0 || index >= this._flatPlaneAll.length) {
451
486
  return false;
@@ -457,10 +492,14 @@ class JointDynamicsSystemController {
457
492
  this._rebuildActiveFlatPlanes();
458
493
  return true;
459
494
  }
460
- /**
461
- * Enable or disable a grabber by current array index.
462
- * Transform state is still read from the grabber's TransformAccess each frame.
463
- * Prefer setGrabberEnabled(handle, enabled) for runtime-owned grabbers.
495
+ /**
496
+ * Enable or disable a grabber by current array index.
497
+ * Transform state is still read from the grabber's TransformAccess each frame.
498
+ * Prefer setGrabberEnabled(handle, enabled) for runtime-owned grabbers.
499
+ *
500
+ * @param index - Grabber index in the current array. Note that this may change when grabbers are added or removed.
501
+ * @param enabled - `true` to enable the grabber, `false` to disable it.
502
+ * @returns `true` if the index is valid and the grabber was updated, `false` if the index is out of range.
464
503
  */ setGrabberEnabledAt(index, enabled) {
465
504
  if (index >= 0 && index < this._grabbersRW.length) {
466
505
  this._grabbersRW[index].enabled = enabled ? 1 : 0;
@@ -471,9 +510,11 @@ class JointDynamicsSystemController {
471
510
  }
472
511
  return false;
473
512
  }
474
- /**
475
- * Enable or disable a runtime grabber by stable handle.
476
- * @returns true if the handle is still valid.
513
+ /**
514
+ * Enable or disable a runtime grabber by stable handle.
515
+ * @param handle - Stable handle for the grabber to enable or disable.
516
+ * @param enabled - `true` to enable the grabber, `false` to disable it.
517
+ * @returns true if the handle is still valid.
477
518
  */ setGrabberEnabled(handle, enabled) {
478
519
  const index = this._getGrabberIndex(handle);
479
520
  if (index === -1) {
@@ -481,9 +522,12 @@ class JointDynamicsSystemController {
481
522
  }
482
523
  return this.setGrabberEnabledAt(index, enabled);
483
524
  }
484
- /**
485
- * Add a grabber at runtime.
486
- * @returns A stable handle that remains valid until this grabber is removed.
525
+ /**
526
+ * Add a grabber at runtime.
527
+ * @param r - Read-only grabber data such as interaction radius.
528
+ * @param transform - TransformAccess that provides the grabber's position each frame.
529
+ * @param enabled - Whether the grabber starts enabled. The grabber can still be moved by its transform while disabled, but it won't affect any points until enabled.
530
+ * @returns A stable handle that remains valid until this grabber is removed.
487
531
  */ addGrabber(r, transform, enabled = false) {
488
532
  const id = this._nextGrabberHandleId++;
489
533
  this._grabbersR.push(r);
@@ -499,9 +543,10 @@ class JointDynamicsSystemController {
499
543
  id
500
544
  };
501
545
  }
502
- /**
503
- * Remove a grabber by stable handle.
504
- * @returns true if the grabber existed and was removed.
546
+ /**
547
+ * Remove a grabber by stable handle.
548
+ * @param handle - Stable handle for the grabber to remove.
549
+ * @returns true if the grabber existed and was removed.
505
550
  */ removeGrabber(handle) {
506
551
  const index = this._getGrabberIndex(handle);
507
552
  if (index === -1) {
@@ -509,9 +554,12 @@ class JointDynamicsSystemController {
509
554
  }
510
555
  return this.removeGrabberAt(index);
511
556
  }
512
- /**
513
- * Remove a grabber by current array index.
514
- * Prefer removeGrabber(handle) for runtime-owned grabbers.
557
+ /**
558
+ * Remove a grabber by current array index.
559
+ * Prefer removeGrabber(handle) for runtime-owned grabbers.
560
+ *
561
+ * @param index - Grabber index in the current array. Note that this may change when grabbers are added or removed.
562
+ * @returns true if the index was valid and the grabber was removed, false if the index was out of range.
515
563
  */ removeGrabberAt(index) {
516
564
  if (index < 0 || index >= this._grabbersR.length) {
517
565
  return false;