@zephyr3d/editor 0.3.0 → 0.3.1
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/README.md +143 -0
- package/dist/assets/{index-BaUzUcND.js → index-IISR7uQv.js} +1 -1
- package/dist/assistant/zephyr-types-index.json +1 -1
- package/dist/index.html +2 -2
- package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
- package/dist/modules/zephyr3d_imgui.js +3 -3
- package/dist/modules/zephyr3d_imgui.js.map +1 -1
- package/dist/modules/zephyr3d_scene.js +1439 -1439
- package/dist/modules/zephyr3d_scene.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/bindgroup_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/buffer_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/commandqueue.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/uploadringbuffer.js.map +1 -1
- package/dist/vendor/zephyr3d/imgui/dist/imgui_impl.js.map +1 -1
- package/dist/vendor/zephyr3d/imgui/dist/renderer.js +3 -3
- package/dist/vendor/zephyr3d/imgui/dist/renderer.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js +135 -135
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/controller.js +146 -146
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/spring/spring_system.js +75 -75
- package/dist/vendor/zephyr3d/scene/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js +184 -184
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/material.js +288 -288
- package/dist/vendor/zephyr3d/scene/dist/material/material.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resource_manager.js +93 -93
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resources.js +3 -3
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/types.js +22 -22
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/types.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/blueprint/material/ir.js +489 -489
- package/dist/vendor/zephyr3d/scene/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/types.js +4 -4
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,16 +4,16 @@ import { simulate, applyAngleLimits, applyResult } from './solver.js';
|
|
|
4
4
|
import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
5
5
|
|
|
6
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
|
|
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
17
|
*/ class JointDynamicsSystemController {
|
|
18
18
|
_config;
|
|
19
19
|
_pointsR = [];
|
|
@@ -53,14 +53,14 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
53
53
|
constructor(config){
|
|
54
54
|
this._config = config;
|
|
55
55
|
}
|
|
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.
|
|
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.
|
|
64
64
|
*/ initialize(rootTransform, rootPoints, pointTransforms, colliders, grabbers, flatPlanes) {
|
|
65
65
|
this._rootTransform = rootTransform;
|
|
66
66
|
this._pointTransforms = pointTransforms;
|
|
@@ -150,11 +150,11 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
150
150
|
}
|
|
151
151
|
this._initialized = true;
|
|
152
152
|
}
|
|
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`.
|
|
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`.
|
|
158
158
|
*/ step(deltaTime) {
|
|
159
159
|
if (!this._initialized || !this._rootTransform) {
|
|
160
160
|
return;
|
|
@@ -229,10 +229,10 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
229
229
|
this._previousRootPosition = rootPos;
|
|
230
230
|
this._previousRootRotation = rootRot;
|
|
231
231
|
}
|
|
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.
|
|
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.
|
|
236
236
|
*/ getResults() {
|
|
237
237
|
const transformRots = this._pointTransforms.map((t)=>t.getWorldRotation());
|
|
238
238
|
const transformLocalRots = this._pointTransforms.map((t)=>t.getLocalRotation());
|
|
@@ -242,10 +242,10 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
242
242
|
rotation: o.rotation
|
|
243
243
|
}));
|
|
244
244
|
}
|
|
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.
|
|
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.
|
|
249
249
|
*/ warp() {
|
|
250
250
|
if (!this._rootTransform) {
|
|
251
251
|
return;
|
|
@@ -253,10 +253,10 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
253
253
|
this._previousRootPosition = this._rootTransform.getWorldPosition();
|
|
254
254
|
this._previousRootRotation = this._rootTransform.getWorldRotation();
|
|
255
255
|
}
|
|
256
|
-
/**
|
|
257
|
-
* Resets all physics state.
|
|
258
|
-
* Each simulated point is snapped back to the current transform position and grab state
|
|
259
|
-
* is cleared.
|
|
256
|
+
/**
|
|
257
|
+
* Resets all physics state.
|
|
258
|
+
* Each simulated point is snapped back to the current transform position and grab state
|
|
259
|
+
* is cleared.
|
|
260
260
|
*/ reset() {
|
|
261
261
|
for(let i = 0; i < this._pointsRW.length; i++){
|
|
262
262
|
const pos = this._pointTransforms[i].getWorldPosition();
|
|
@@ -266,10 +266,10 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
266
266
|
}
|
|
267
267
|
this._fakeWaveCounter = 0;
|
|
268
268
|
}
|
|
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.
|
|
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.
|
|
273
273
|
*/ releasePoint(index) {
|
|
274
274
|
if (index < 0 || index >= this._pointsR.length) {
|
|
275
275
|
return;
|
|
@@ -280,10 +280,10 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
280
280
|
this._pointsRW[index].positionPrevious = pos.clone();
|
|
281
281
|
this._pointsRW[index].grabberIndex = -1;
|
|
282
282
|
}
|
|
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.
|
|
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.
|
|
287
287
|
*/ fixPoint(index) {
|
|
288
288
|
if (index < 0 || index >= this._pointsR.length) {
|
|
289
289
|
return;
|
|
@@ -291,9 +291,9 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
291
291
|
this._pointsR[index].weight = 0;
|
|
292
292
|
this._pointsRW[index].grabberIndex = -1;
|
|
293
293
|
}
|
|
294
|
-
/**
|
|
295
|
-
* Returns whether a point is fixed to animation (`weight = 0`).
|
|
296
|
-
* @param index - Point index.
|
|
294
|
+
/**
|
|
295
|
+
* Returns whether a point is fixed to animation (`weight = 0`).
|
|
296
|
+
* @param index - Point index.
|
|
297
297
|
*/ isPointFixed(index) {
|
|
298
298
|
if (index < 0 || index >= this._pointsR.length) {
|
|
299
299
|
return false;
|
|
@@ -303,34 +303,34 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
303
303
|
/** Gets the total number of physics points. */ get pointCount() {
|
|
304
304
|
return this._pointsR.length;
|
|
305
305
|
}
|
|
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.
|
|
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.
|
|
310
310
|
*/ fadeIn(seconds) {
|
|
311
311
|
this._fadeState = 'in';
|
|
312
312
|
this._fadeTimer = 0;
|
|
313
313
|
this._fadeDuration = seconds;
|
|
314
314
|
}
|
|
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.
|
|
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.
|
|
319
319
|
*/ fadeOut(seconds) {
|
|
320
320
|
this._fadeState = 'out';
|
|
321
321
|
this._fadeTimer = 0;
|
|
322
322
|
this._fadeDuration = seconds;
|
|
323
323
|
}
|
|
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.
|
|
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.
|
|
328
328
|
*/ setWindForce(wind) {
|
|
329
329
|
this._config.windForce = wind;
|
|
330
330
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Enable/disable broad-phase pruning for runtime performance comparison
|
|
333
|
-
* @param enabled - `true` to enable broad-phase, `false` to disable.
|
|
331
|
+
/**
|
|
332
|
+
* Enable/disable broad-phase pruning for runtime performance comparison
|
|
333
|
+
* @param enabled - `true` to enable broad-phase, `false` to disable.
|
|
334
334
|
*/ setBroadPhaseEnabled(enabled) {
|
|
335
335
|
this._config.enableBroadPhase = enabled;
|
|
336
336
|
}
|
|
@@ -340,23 +340,23 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
340
340
|
set blendRatio(value) {
|
|
341
341
|
this._config.blendRatio = clamp01(value);
|
|
342
342
|
}
|
|
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.
|
|
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.
|
|
348
348
|
*/ setPaused(paused) {
|
|
349
349
|
this._isPaused = paused;
|
|
350
350
|
}
|
|
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.
|
|
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.
|
|
360
360
|
*/ setColliderEnabledAt(index, enabled) {
|
|
361
361
|
if (index >= 0 && index < this._collidersRW.length) {
|
|
362
362
|
this._collidersRW[index].enabled = enabled ? 1 : 0;
|
|
@@ -364,12 +364,12 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
364
364
|
}
|
|
365
365
|
return false;
|
|
366
366
|
}
|
|
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.
|
|
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.
|
|
373
373
|
*/ setColliderEnabled(handle, enabled) {
|
|
374
374
|
const index = this._getColliderIndex(handle);
|
|
375
375
|
if (index === -1) {
|
|
@@ -377,11 +377,11 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
377
377
|
}
|
|
378
378
|
return this.setColliderEnabledAt(index, enabled);
|
|
379
379
|
}
|
|
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.
|
|
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.
|
|
385
385
|
*/ addCollider(r, transform) {
|
|
386
386
|
const id = this._nextColliderHandleId++;
|
|
387
387
|
this._collidersR.push(r);
|
|
@@ -394,10 +394,10 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
394
394
|
id
|
|
395
395
|
};
|
|
396
396
|
}
|
|
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.
|
|
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.
|
|
401
401
|
*/ removeCollider(handle) {
|
|
402
402
|
const index = this._getColliderIndex(handle);
|
|
403
403
|
if (index === -1) {
|
|
@@ -405,10 +405,10 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
405
405
|
}
|
|
406
406
|
return this.removeColliderAt(index);
|
|
407
407
|
}
|
|
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.
|
|
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.
|
|
412
412
|
*/ removeColliderAt(index) {
|
|
413
413
|
if (index < 0 || index >= this._collidersR.length) {
|
|
414
414
|
return false;
|
|
@@ -420,11 +420,11 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
420
420
|
this._rebuildColliderHandleMap();
|
|
421
421
|
return true;
|
|
422
422
|
}
|
|
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.
|
|
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.
|
|
428
428
|
*/ setFlatPlaneEnabledAt(index, enabled) {
|
|
429
429
|
if (index < 0 || index >= this._flatPlaneAll.length) {
|
|
430
430
|
return false;
|
|
@@ -433,11 +433,11 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
433
433
|
this._rebuildActiveFlatPlanes();
|
|
434
434
|
return true;
|
|
435
435
|
}
|
|
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.
|
|
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.
|
|
441
441
|
*/ setFlatPlaneEnabled(handle, enabled) {
|
|
442
442
|
const index = this._getFlatPlaneIndex(handle);
|
|
443
443
|
if (index === -1) {
|
|
@@ -445,11 +445,11 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
445
445
|
}
|
|
446
446
|
return this.setFlatPlaneEnabledAt(index, enabled);
|
|
447
447
|
}
|
|
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.
|
|
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.
|
|
453
453
|
*/ addFlatPlane(up, position) {
|
|
454
454
|
const id = this._nextFlatPlaneHandleId++;
|
|
455
455
|
const normal = Vector3.normalize(up);
|
|
@@ -466,10 +466,10 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
466
466
|
id
|
|
467
467
|
};
|
|
468
468
|
}
|
|
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.
|
|
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.
|
|
473
473
|
*/ removeFlatPlane(handle) {
|
|
474
474
|
const index = this._getFlatPlaneIndex(handle);
|
|
475
475
|
if (index === -1) {
|
|
@@ -477,10 +477,10 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
477
477
|
}
|
|
478
478
|
return this.removeFlatPlaneAt(index);
|
|
479
479
|
}
|
|
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.
|
|
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.
|
|
484
484
|
*/ removeFlatPlaneAt(index) {
|
|
485
485
|
if (index < 0 || index >= this._flatPlaneAll.length) {
|
|
486
486
|
return false;
|
|
@@ -492,14 +492,14 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
492
492
|
this._rebuildActiveFlatPlanes();
|
|
493
493
|
return true;
|
|
494
494
|
}
|
|
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.
|
|
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.
|
|
503
503
|
*/ setGrabberEnabledAt(index, enabled) {
|
|
504
504
|
if (index >= 0 && index < this._grabbersRW.length) {
|
|
505
505
|
this._grabbersRW[index].enabled = enabled ? 1 : 0;
|
|
@@ -510,11 +510,11 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
510
510
|
}
|
|
511
511
|
return false;
|
|
512
512
|
}
|
|
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.
|
|
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.
|
|
518
518
|
*/ setGrabberEnabled(handle, enabled) {
|
|
519
519
|
const index = this._getGrabberIndex(handle);
|
|
520
520
|
if (index === -1) {
|
|
@@ -522,12 +522,12 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
522
522
|
}
|
|
523
523
|
return this.setGrabberEnabledAt(index, enabled);
|
|
524
524
|
}
|
|
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.
|
|
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.
|
|
531
531
|
*/ addGrabber(r, transform, enabled = false) {
|
|
532
532
|
const id = this._nextGrabberHandleId++;
|
|
533
533
|
this._grabbersR.push(r);
|
|
@@ -543,10 +543,10 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
543
543
|
id
|
|
544
544
|
};
|
|
545
545
|
}
|
|
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.
|
|
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.
|
|
550
550
|
*/ removeGrabber(handle) {
|
|
551
551
|
const index = this._getGrabberIndex(handle);
|
|
552
552
|
if (index === -1) {
|
|
@@ -554,12 +554,12 @@ import { Vector3, Quaternion, Matrix4x4, clamp01 } from '@zephyr3d/base';
|
|
|
554
554
|
}
|
|
555
555
|
return this.removeGrabberAt(index);
|
|
556
556
|
}
|
|
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.
|
|
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.
|
|
563
563
|
*/ removeGrabberAt(index) {
|
|
564
564
|
if (index < 0 || index >= this._grabbersR.length) {
|
|
565
565
|
return false;
|