@playcanvas/web-components 0.14.0 → 0.15.0

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/pwc.cjs CHANGED
@@ -877,6 +877,23 @@ class AppElement extends AsyncElement {
877
877
  if (this._loadingBar && !this._bar) {
878
878
  this._bar = new LoadingBar(this);
879
879
  }
880
+ // Upgrade the subtree before reading anything out of it. A subtree cloned from a
881
+ // <template> arrives entirely unupgraded - template content lives in an inert document,
882
+ // where custom element definitions are never looked up - and appending the clone upgrades
883
+ // its elements in tree order, this one before its descendants. The module query below would
884
+ // otherwise find plain HTMLElements with no _getLoadPromise to call, and the boot would die
885
+ // there, leaving the element permanently unready: no canvas, no entities, no application.
886
+ //
887
+ // Upgrading is the fix here rather than skipping whatever has not upgraded, because a
888
+ // <pc-module> is the one child that nothing else ever builds on its own behalf - skipping
889
+ // it would drop the wasm module the app asked for, silently and only for cloned apps.
890
+ // Upgrading runs each descendant's connectedCallback synchronously, a few lines earlier
891
+ // than the parser's path runs them but into the same state they see there: no application
892
+ // yet and _hierarchyReady false, so they defer to the sweeps below. A descendant that
893
+ // disconnects this element from there is caught by the generation check after the await,
894
+ // as any other disconnect is. An already-upgraded subtree - every other insertion path -
895
+ // is left completely untouched.
896
+ customElements.upgrade(this);
880
897
  // Get all pc-module elements that are direct children of the pc-app element
881
898
  const moduleElements = this.querySelectorAll(':scope > pc-module');
882
899
  // Wait for all modules to load
@@ -1728,6 +1745,30 @@ class EntityBaseElement extends AsyncElement {
1728
1745
  }
1729
1746
  }
1730
1747
 
1748
+ /**
1749
+ * Creates and parents the entities of every descendant `<pc-entity>` of `root`, in two passes so
1750
+ * that no parent's existence depends on document order. Called wherever a subtree could not build
1751
+ * itself: an element inserted into an application that is already running, and a `<pc-node>` whose
1752
+ * children waited for it to bind.
1753
+ *
1754
+ * Descendants that are not yet custom elements are skipped, because there is nothing useful to do
1755
+ * for them and reaching for `_createEntity` would throw. A subtree cloned from a `<template>`
1756
+ * arrives entirely unupgraded — template content lives in an inert document, where custom element
1757
+ * definitions are never looked up — and appending the clone upgrades its elements in tree order,
1758
+ * an element before its descendants. So a sweep from an element's own `connectedCallback` sees
1759
+ * plain `HTMLElement`s below it. Each becomes an `EntityElement` moments later and its own
1760
+ * `connectedCallback` creates and parents it, by which time the ancestor it parents under has its
1761
+ * entity — the same guarantee tree order gives this sweep.
1762
+ *
1763
+ * @param root - The element whose descendant entities to build.
1764
+ * @param app - The application to create the entities in.
1765
+ * @internal
1766
+ */
1767
+ const buildDescendantEntities = (root, app) => {
1768
+ const children = Array.from(root.querySelectorAll('pc-entity')).filter((child) => child instanceof EntityElement);
1769
+ children.forEach((child) => child._createEntity(app));
1770
+ children.forEach((child) => child._buildHierarchy(app));
1771
+ };
1731
1772
  /**
1732
1773
  * The EntityElement interface provides properties and methods for manipulating
1733
1774
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/ | `<pc-entity>`} elements.
@@ -1876,13 +1917,7 @@ class EntityElement extends EntityBaseElement {
1876
1917
  this._createEntity(app);
1877
1918
  this._buildHierarchy(app);
1878
1919
  // Handle any child entities that might exist
1879
- const childEntities = this.querySelectorAll('pc-entity');
1880
- childEntities.forEach((child) => {
1881
- child._createEntity(app);
1882
- });
1883
- childEntities.forEach((child) => {
1884
- child._buildHierarchy(app);
1885
- });
1920
+ buildDescendantEntities(this, app);
1886
1921
  }
1887
1922
  }
1888
1923
  disconnectedCallback() {
@@ -4869,6 +4904,879 @@ class ElementComponentElement extends ComponentElement {
4869
4904
  }
4870
4905
  customElements.define('pc-element', ElementComponentElement);
4871
4906
 
4907
+ /**
4908
+ * The JointComponentElement interface provides properties and methods for manipulating
4909
+ * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-joint/ | `<pc-joint>`} elements.
4910
+ * The JointComponentElement interface also inherits the properties and methods of the
4911
+ * {@link HTMLElement} interface.
4912
+ *
4913
+ * The entity holding the joint is not itself constrained. Its world transform defines the joint
4914
+ * frame — the anchor point and axes the constraint operates about — with the local X axis as the
4915
+ * primary axis: a hinge rotates about it, a slider translates along it and a ball joint twists
4916
+ * about it. The constrained bodies are referenced by `entity-a` and `entity-b`, both of which need
4917
+ * a rigid body component; leaving `entity-b` empty constrains `entity-a` to a fixed point in world
4918
+ * space. The underlying engine component is in alpha, so its API may change.
4919
+ *
4920
+ * @fires {CustomEvent} break - Fired when the impulse on the joint exceeds `break-impulse` and the
4921
+ * constraint breaks. A broken joint no longer constrains its bodies; calling `refreshFrames()` on
4922
+ * the underlying component re-attaches it. Bubbles and is composed.
4923
+ *
4924
+ * @category Components
4925
+ */
4926
+ class JointComponentElement extends ComponentElement {
4927
+ /**
4928
+ * The spring damping of the joint per angular axis.
4929
+ */
4930
+ _angularDamping = new playcanvas.Vec3(1, 1, 1);
4931
+ /**
4932
+ * The rest angle of the joint's angular springs.
4933
+ */
4934
+ _angularEquilibrium = new playcanvas.Vec3();
4935
+ /**
4936
+ * The rotation limits of the joint about its X axis.
4937
+ */
4938
+ _angularLimitsX = new playcanvas.Vec2();
4939
+ /**
4940
+ * The rotation limits of the joint about its Y axis.
4941
+ */
4942
+ _angularLimitsY = new playcanvas.Vec2();
4943
+ /**
4944
+ * The rotation limits of the joint about its Z axis.
4945
+ */
4946
+ _angularLimitsZ = new playcanvas.Vec2();
4947
+ /**
4948
+ * The rotational degree of freedom of the joint about its X axis.
4949
+ */
4950
+ _angularMotionX = 'locked';
4951
+ /**
4952
+ * The rotational degree of freedom of the joint about its Y axis.
4953
+ */
4954
+ _angularMotionY = 'locked';
4955
+ /**
4956
+ * The rotational degree of freedom of the joint about its Z axis.
4957
+ */
4958
+ _angularMotionZ = 'locked';
4959
+ /**
4960
+ * The spring stiffness of the joint per angular axis.
4961
+ */
4962
+ _angularStiffness = new playcanvas.Vec3();
4963
+ /**
4964
+ * The impulse above which the joint breaks.
4965
+ */
4966
+ _breakImpulse = Infinity;
4967
+ /**
4968
+ * Whether collision is enabled between the constrained bodies.
4969
+ */
4970
+ _enableCollision = false;
4971
+ /**
4972
+ * Whether the joint's limits are enforced.
4973
+ */
4974
+ _enableLimits = false;
4975
+ /**
4976
+ * The reference to the entity providing the first constrained body.
4977
+ */
4978
+ _entityA = '';
4979
+ /**
4980
+ * The reference to the entity providing the second constrained body.
4981
+ */
4982
+ _entityB = '';
4983
+ /**
4984
+ * The rotation or travel limits of the joint.
4985
+ */
4986
+ _limits = new playcanvas.Vec2(-45, 45);
4987
+ /**
4988
+ * The spring damping of the joint per linear axis.
4989
+ */
4990
+ _linearDamping = new playcanvas.Vec3(1, 1, 1);
4991
+ /**
4992
+ * The rest point of the joint's linear springs.
4993
+ */
4994
+ _linearEquilibrium = new playcanvas.Vec3();
4995
+ /**
4996
+ * The translation limits of the joint along its X axis.
4997
+ */
4998
+ _linearLimitsX = new playcanvas.Vec2();
4999
+ /**
5000
+ * The translation limits of the joint along its Y axis.
5001
+ */
5002
+ _linearLimitsY = new playcanvas.Vec2();
5003
+ /**
5004
+ * The translation limits of the joint along its Z axis.
5005
+ */
5006
+ _linearLimitsZ = new playcanvas.Vec2();
5007
+ /**
5008
+ * The linear degree of freedom of the joint along its X axis.
5009
+ */
5010
+ _linearMotionX = 'locked';
5011
+ /**
5012
+ * The linear degree of freedom of the joint along its Y axis.
5013
+ */
5014
+ _linearMotionY = 'locked';
5015
+ /**
5016
+ * The linear degree of freedom of the joint along its Z axis.
5017
+ */
5018
+ _linearMotionZ = 'locked';
5019
+ /**
5020
+ * The spring stiffness of the joint per linear axis.
5021
+ */
5022
+ _linearStiffness = new playcanvas.Vec3();
5023
+ /**
5024
+ * The maximum torque or force of the joint's motor.
5025
+ */
5026
+ _maxMotorForce = 0;
5027
+ /**
5028
+ * The target speed of the joint's motor.
5029
+ */
5030
+ _motorSpeed = 0;
5031
+ /**
5032
+ * The maximum swing of the joint around the joint frame's Y axis.
5033
+ */
5034
+ _swingLimitY = 45;
5035
+ /**
5036
+ * The maximum swing of the joint around the joint frame's Z axis.
5037
+ */
5038
+ _swingLimitZ = 45;
5039
+ /**
5040
+ * The maximum twist of the joint about its primary axis.
5041
+ */
5042
+ _twistLimit = 20;
5043
+ /**
5044
+ * The type of the joint.
5045
+ */
5046
+ _type = 'fixed';
5047
+ /** @ignore */
5048
+ constructor() {
5049
+ super('joint');
5050
+ }
5051
+ getInitialComponentData() {
5052
+ return {
5053
+ angularDamping: this._angularDamping,
5054
+ angularEquilibrium: this._angularEquilibrium,
5055
+ angularLimitsX: this._angularLimitsX,
5056
+ angularLimitsY: this._angularLimitsY,
5057
+ angularLimitsZ: this._angularLimitsZ,
5058
+ angularMotionX: this._angularMotionX,
5059
+ angularMotionY: this._angularMotionY,
5060
+ angularMotionZ: this._angularMotionZ,
5061
+ angularStiffness: this._angularStiffness,
5062
+ breakImpulse: this._breakImpulse,
5063
+ enableCollision: this._enableCollision,
5064
+ enableLimits: this._enableLimits,
5065
+ entityA: getEntity(this._entityA),
5066
+ entityB: getEntity(this._entityB),
5067
+ limits: this._limits,
5068
+ linearDamping: this._linearDamping,
5069
+ linearEquilibrium: this._linearEquilibrium,
5070
+ linearLimitsX: this._linearLimitsX,
5071
+ linearLimitsY: this._linearLimitsY,
5072
+ linearLimitsZ: this._linearLimitsZ,
5073
+ linearMotionX: this._linearMotionX,
5074
+ linearMotionY: this._linearMotionY,
5075
+ linearMotionZ: this._linearMotionZ,
5076
+ linearStiffness: this._linearStiffness,
5077
+ maxMotorForce: this._maxMotorForce,
5078
+ motorSpeed: this._motorSpeed,
5079
+ swingLimitY: this._swingLimitY,
5080
+ swingLimitZ: this._swingLimitZ,
5081
+ twistLimit: this._twistLimit,
5082
+ type: this._type
5083
+ };
5084
+ }
5085
+ _onBreak() {
5086
+ this.dispatchEvent(new CustomEvent('break', { bubbles: true, composed: true }));
5087
+ }
5088
+ initComponent() {
5089
+ const component = this.component;
5090
+ if (!component) {
5091
+ return;
5092
+ }
5093
+ // A host readiness cycle can re-run this against the same surviving component instance,
5094
+ // so the off/on pair keeps the subscription single either way. Component removal destroys
5095
+ // the instance and its listeners with it, so there is no disconnect-side teardown.
5096
+ component.off('break', this._onBreak, this);
5097
+ component.on('break', this._onBreak, this);
5098
+ }
5099
+ /**
5100
+ * Gets the underlying PlayCanvas joint component.
5101
+ * @returns The joint component.
5102
+ */
5103
+ get component() {
5104
+ return super.component;
5105
+ }
5106
+ /**
5107
+ * Sets the spring damping of a 6dof joint per angular axis, used on axes with a non-zero
5108
+ * angular-stiffness.
5109
+ * @param value - The angular spring damping.
5110
+ */
5111
+ set angularDamping(value) {
5112
+ this._angularDamping = value;
5113
+ if (this.component) {
5114
+ this.component.angularDamping = value;
5115
+ }
5116
+ }
5117
+ /**
5118
+ * Gets the spring damping of the joint per angular axis.
5119
+ * @returns The angular spring damping.
5120
+ */
5121
+ get angularDamping() {
5122
+ return this._angularDamping;
5123
+ }
5124
+ /**
5125
+ * Sets the rest angle of a 6dof joint's angular springs in degrees per axis, used on axes with
5126
+ * a non-zero angular-stiffness.
5127
+ * @param value - The angular spring rest angles.
5128
+ */
5129
+ set angularEquilibrium(value) {
5130
+ this._angularEquilibrium = value;
5131
+ if (this.component) {
5132
+ this.component.angularEquilibrium = value;
5133
+ }
5134
+ }
5135
+ /**
5136
+ * Gets the rest angle of the joint's angular springs.
5137
+ * @returns The angular spring rest angles.
5138
+ */
5139
+ get angularEquilibrium() {
5140
+ return this._angularEquilibrium;
5141
+ }
5142
+ /**
5143
+ * Sets the lower and upper rotation limit of a 6dof joint about its X axis in degrees, used
5144
+ * when angular-motion-x is limited.
5145
+ * @param value - The X axis rotation limits.
5146
+ */
5147
+ set angularLimitsX(value) {
5148
+ this._angularLimitsX = value;
5149
+ if (this.component) {
5150
+ this.component.angularLimitsX = value;
5151
+ }
5152
+ }
5153
+ /**
5154
+ * Gets the rotation limits of the joint about its X axis.
5155
+ * @returns The X axis rotation limits.
5156
+ */
5157
+ get angularLimitsX() {
5158
+ return this._angularLimitsX;
5159
+ }
5160
+ /**
5161
+ * Sets the lower and upper rotation limit of a 6dof joint about its Y axis in degrees, used
5162
+ * when angular-motion-y is limited.
5163
+ * @param value - The Y axis rotation limits.
5164
+ */
5165
+ set angularLimitsY(value) {
5166
+ this._angularLimitsY = value;
5167
+ if (this.component) {
5168
+ this.component.angularLimitsY = value;
5169
+ }
5170
+ }
5171
+ /**
5172
+ * Gets the rotation limits of the joint about its Y axis.
5173
+ * @returns The Y axis rotation limits.
5174
+ */
5175
+ get angularLimitsY() {
5176
+ return this._angularLimitsY;
5177
+ }
5178
+ /**
5179
+ * Sets the lower and upper rotation limit of a 6dof joint about its Z axis in degrees, used
5180
+ * when angular-motion-z is limited.
5181
+ * @param value - The Z axis rotation limits.
5182
+ */
5183
+ set angularLimitsZ(value) {
5184
+ this._angularLimitsZ = value;
5185
+ if (this.component) {
5186
+ this.component.angularLimitsZ = value;
5187
+ }
5188
+ }
5189
+ /**
5190
+ * Gets the rotation limits of the joint about its Z axis.
5191
+ * @returns The Z axis rotation limits.
5192
+ */
5193
+ get angularLimitsZ() {
5194
+ return this._angularLimitsZ;
5195
+ }
5196
+ /**
5197
+ * Sets how a 6dof joint constrains rotation about its X axis. Can be `locked`, `limited` or
5198
+ * `free`. Defaults to `locked`.
5199
+ * @param value - The X axis rotational degree of freedom.
5200
+ */
5201
+ set angularMotionX(value) {
5202
+ this._angularMotionX = value;
5203
+ if (this.component) {
5204
+ this.component.angularMotionX = value;
5205
+ }
5206
+ }
5207
+ /**
5208
+ * Gets how the joint constrains rotation about its X axis.
5209
+ * @returns The X axis rotational degree of freedom.
5210
+ */
5211
+ get angularMotionX() {
5212
+ return this._angularMotionX;
5213
+ }
5214
+ /**
5215
+ * Sets how a 6dof joint constrains rotation about its Y axis. Can be `locked`, `limited` or
5216
+ * `free`. Defaults to `locked`.
5217
+ * @param value - The Y axis rotational degree of freedom.
5218
+ */
5219
+ set angularMotionY(value) {
5220
+ this._angularMotionY = value;
5221
+ if (this.component) {
5222
+ this.component.angularMotionY = value;
5223
+ }
5224
+ }
5225
+ /**
5226
+ * Gets how the joint constrains rotation about its Y axis.
5227
+ * @returns The Y axis rotational degree of freedom.
5228
+ */
5229
+ get angularMotionY() {
5230
+ return this._angularMotionY;
5231
+ }
5232
+ /**
5233
+ * Sets how a 6dof joint constrains rotation about its Z axis. Can be `locked`, `limited` or
5234
+ * `free`. Defaults to `locked`.
5235
+ * @param value - The Z axis rotational degree of freedom.
5236
+ */
5237
+ set angularMotionZ(value) {
5238
+ this._angularMotionZ = value;
5239
+ if (this.component) {
5240
+ this.component.angularMotionZ = value;
5241
+ }
5242
+ }
5243
+ /**
5244
+ * Gets how the joint constrains rotation about its Z axis.
5245
+ * @returns The Z axis rotational degree of freedom.
5246
+ */
5247
+ get angularMotionZ() {
5248
+ return this._angularMotionZ;
5249
+ }
5250
+ /**
5251
+ * Sets the spring stiffness of a 6dof joint per angular axis, where 0 disables the spring on
5252
+ * that axis.
5253
+ * @param value - The angular spring stiffness.
5254
+ */
5255
+ set angularStiffness(value) {
5256
+ this._angularStiffness = value;
5257
+ if (this.component) {
5258
+ this.component.angularStiffness = value;
5259
+ }
5260
+ }
5261
+ /**
5262
+ * Gets the spring stiffness of the joint per angular axis.
5263
+ * @returns The angular spring stiffness.
5264
+ */
5265
+ get angularStiffness() {
5266
+ return this._angularStiffness;
5267
+ }
5268
+ /**
5269
+ * Sets the impulse in newton seconds above which the joint breaks. Defaults to `Infinity`,
5270
+ * which makes the joint unbreakable.
5271
+ * @param value - The break impulse.
5272
+ */
5273
+ set breakImpulse(value) {
5274
+ this._breakImpulse = value;
5275
+ if (this.component) {
5276
+ this.component.breakImpulse = value;
5277
+ }
5278
+ }
5279
+ /**
5280
+ * Gets the impulse above which the joint breaks.
5281
+ * @returns The break impulse.
5282
+ */
5283
+ get breakImpulse() {
5284
+ return this._breakImpulse;
5285
+ }
5286
+ /**
5287
+ * Sets whether collision is enabled between the two constrained bodies.
5288
+ * @param value - Whether collision is enabled.
5289
+ */
5290
+ set enableCollision(value) {
5291
+ this._enableCollision = value;
5292
+ if (this.component) {
5293
+ this.component.enableCollision = value;
5294
+ }
5295
+ }
5296
+ /**
5297
+ * Gets whether collision is enabled between the two constrained bodies.
5298
+ * @returns Whether collision is enabled.
5299
+ */
5300
+ get enableCollision() {
5301
+ return this._enableCollision;
5302
+ }
5303
+ /**
5304
+ * Sets whether the limits of a hinge, slider or ball joint are enforced.
5305
+ * @param value - Whether the limits are enforced.
5306
+ */
5307
+ set enableLimits(value) {
5308
+ this._enableLimits = value;
5309
+ if (this.component) {
5310
+ this.component.enableLimits = value;
5311
+ }
5312
+ }
5313
+ /**
5314
+ * Gets whether the limits of the joint are enforced.
5315
+ * @returns Whether the limits are enforced.
5316
+ */
5317
+ get enableLimits() {
5318
+ return this._enableLimits;
5319
+ }
5320
+ /**
5321
+ * Sets the reference (CSS selector, element id or entity name) to the `<pc-entity>` providing
5322
+ * the first constrained body. The reference resolves when it is set, so an entity created
5323
+ * later is picked up by setting the attribute again.
5324
+ * @param value - The first body's entity reference.
5325
+ */
5326
+ set entityA(value) {
5327
+ this._entityA = value;
5328
+ if (this.component) {
5329
+ this.component.entityA = getEntity(value);
5330
+ }
5331
+ }
5332
+ /**
5333
+ * Gets the reference to the `<pc-entity>` providing the first constrained body.
5334
+ * @returns The first body's entity reference.
5335
+ */
5336
+ get entityA() {
5337
+ return this._entityA;
5338
+ }
5339
+ /**
5340
+ * Sets the reference (CSS selector, element id or entity name) to the `<pc-entity>` providing
5341
+ * the second constrained body, or empty to constrain the first body to a fixed point in world
5342
+ * space. The reference resolves when it is set, so an entity created later is picked up by
5343
+ * setting the attribute again.
5344
+ * @param value - The second body's entity reference.
5345
+ */
5346
+ set entityB(value) {
5347
+ this._entityB = value;
5348
+ if (this.component) {
5349
+ this.component.entityB = getEntity(value);
5350
+ }
5351
+ }
5352
+ /**
5353
+ * Gets the reference to the `<pc-entity>` providing the second constrained body.
5354
+ * @returns The second body's entity reference.
5355
+ */
5356
+ get entityB() {
5357
+ return this._entityB;
5358
+ }
5359
+ /**
5360
+ * Sets the lower and upper limit of a hinge joint's rotation in degrees, or a slider joint's
5361
+ * travel in meters, applied when enable-limits is set.
5362
+ * @param value - The rotation or travel limits.
5363
+ */
5364
+ set limits(value) {
5365
+ this._limits = value;
5366
+ if (this.component) {
5367
+ this.component.limits = value;
5368
+ }
5369
+ }
5370
+ /**
5371
+ * Gets the rotation or travel limits of the joint.
5372
+ * @returns The rotation or travel limits.
5373
+ */
5374
+ get limits() {
5375
+ return this._limits;
5376
+ }
5377
+ /**
5378
+ * Sets the spring damping of a 6dof joint per linear axis, used on axes with a non-zero
5379
+ * linear-stiffness.
5380
+ * @param value - The linear spring damping.
5381
+ */
5382
+ set linearDamping(value) {
5383
+ this._linearDamping = value;
5384
+ if (this.component) {
5385
+ this.component.linearDamping = value;
5386
+ }
5387
+ }
5388
+ /**
5389
+ * Gets the spring damping of the joint per linear axis.
5390
+ * @returns The linear spring damping.
5391
+ */
5392
+ get linearDamping() {
5393
+ return this._linearDamping;
5394
+ }
5395
+ /**
5396
+ * Sets the rest point of a 6dof joint's linear springs in meters per axis, used on axes with a
5397
+ * non-zero linear-stiffness.
5398
+ * @param value - The linear spring rest points.
5399
+ */
5400
+ set linearEquilibrium(value) {
5401
+ this._linearEquilibrium = value;
5402
+ if (this.component) {
5403
+ this.component.linearEquilibrium = value;
5404
+ }
5405
+ }
5406
+ /**
5407
+ * Gets the rest point of the joint's linear springs.
5408
+ * @returns The linear spring rest points.
5409
+ */
5410
+ get linearEquilibrium() {
5411
+ return this._linearEquilibrium;
5412
+ }
5413
+ /**
5414
+ * Sets the lower and upper translation limit of a 6dof joint along its X axis in meters, used
5415
+ * when linear-motion-x is limited.
5416
+ * @param value - The X axis translation limits.
5417
+ */
5418
+ set linearLimitsX(value) {
5419
+ this._linearLimitsX = value;
5420
+ if (this.component) {
5421
+ this.component.linearLimitsX = value;
5422
+ }
5423
+ }
5424
+ /**
5425
+ * Gets the translation limits of the joint along its X axis.
5426
+ * @returns The X axis translation limits.
5427
+ */
5428
+ get linearLimitsX() {
5429
+ return this._linearLimitsX;
5430
+ }
5431
+ /**
5432
+ * Sets the lower and upper translation limit of a 6dof joint along its Y axis in meters, used
5433
+ * when linear-motion-y is limited.
5434
+ * @param value - The Y axis translation limits.
5435
+ */
5436
+ set linearLimitsY(value) {
5437
+ this._linearLimitsY = value;
5438
+ if (this.component) {
5439
+ this.component.linearLimitsY = value;
5440
+ }
5441
+ }
5442
+ /**
5443
+ * Gets the translation limits of the joint along its Y axis.
5444
+ * @returns The Y axis translation limits.
5445
+ */
5446
+ get linearLimitsY() {
5447
+ return this._linearLimitsY;
5448
+ }
5449
+ /**
5450
+ * Sets the lower and upper translation limit of a 6dof joint along its Z axis in meters, used
5451
+ * when linear-motion-z is limited.
5452
+ * @param value - The Z axis translation limits.
5453
+ */
5454
+ set linearLimitsZ(value) {
5455
+ this._linearLimitsZ = value;
5456
+ if (this.component) {
5457
+ this.component.linearLimitsZ = value;
5458
+ }
5459
+ }
5460
+ /**
5461
+ * Gets the translation limits of the joint along its Z axis.
5462
+ * @returns The Z axis translation limits.
5463
+ */
5464
+ get linearLimitsZ() {
5465
+ return this._linearLimitsZ;
5466
+ }
5467
+ /**
5468
+ * Sets how a 6dof joint constrains translation along its X axis. Can be `locked`, `limited` or
5469
+ * `free`. Defaults to `locked`.
5470
+ * @param value - The X axis linear degree of freedom.
5471
+ */
5472
+ set linearMotionX(value) {
5473
+ this._linearMotionX = value;
5474
+ if (this.component) {
5475
+ this.component.linearMotionX = value;
5476
+ }
5477
+ }
5478
+ /**
5479
+ * Gets how the joint constrains translation along its X axis.
5480
+ * @returns The X axis linear degree of freedom.
5481
+ */
5482
+ get linearMotionX() {
5483
+ return this._linearMotionX;
5484
+ }
5485
+ /**
5486
+ * Sets how a 6dof joint constrains translation along its Y axis. Can be `locked`, `limited` or
5487
+ * `free`. Defaults to `locked`.
5488
+ * @param value - The Y axis linear degree of freedom.
5489
+ */
5490
+ set linearMotionY(value) {
5491
+ this._linearMotionY = value;
5492
+ if (this.component) {
5493
+ this.component.linearMotionY = value;
5494
+ }
5495
+ }
5496
+ /**
5497
+ * Gets how the joint constrains translation along its Y axis.
5498
+ * @returns The Y axis linear degree of freedom.
5499
+ */
5500
+ get linearMotionY() {
5501
+ return this._linearMotionY;
5502
+ }
5503
+ /**
5504
+ * Sets how a 6dof joint constrains translation along its Z axis. Can be `locked`, `limited` or
5505
+ * `free`. Defaults to `locked`.
5506
+ * @param value - The Z axis linear degree of freedom.
5507
+ */
5508
+ set linearMotionZ(value) {
5509
+ this._linearMotionZ = value;
5510
+ if (this.component) {
5511
+ this.component.linearMotionZ = value;
5512
+ }
5513
+ }
5514
+ /**
5515
+ * Gets how the joint constrains translation along its Z axis.
5516
+ * @returns The Z axis linear degree of freedom.
5517
+ */
5518
+ get linearMotionZ() {
5519
+ return this._linearMotionZ;
5520
+ }
5521
+ /**
5522
+ * Sets the spring stiffness of a 6dof joint per linear axis, where 0 disables the spring on
5523
+ * that axis.
5524
+ * @param value - The linear spring stiffness.
5525
+ */
5526
+ set linearStiffness(value) {
5527
+ this._linearStiffness = value;
5528
+ if (this.component) {
5529
+ this.component.linearStiffness = value;
5530
+ }
5531
+ }
5532
+ /**
5533
+ * Gets the spring stiffness of the joint per linear axis.
5534
+ * @returns The linear spring stiffness.
5535
+ */
5536
+ get linearStiffness() {
5537
+ return this._linearStiffness;
5538
+ }
5539
+ /**
5540
+ * Sets the maximum torque in newton meters of a hinge joint's motor, or the maximum force in
5541
+ * newtons of a slider joint's motor, where 0 disables the motor.
5542
+ * @param value - The maximum motor torque or force.
5543
+ */
5544
+ set maxMotorForce(value) {
5545
+ this._maxMotorForce = value;
5546
+ if (this.component) {
5547
+ this.component.maxMotorForce = value;
5548
+ }
5549
+ }
5550
+ /**
5551
+ * Gets the maximum torque or force of the joint's motor.
5552
+ * @returns The maximum motor torque or force.
5553
+ */
5554
+ get maxMotorForce() {
5555
+ return this._maxMotorForce;
5556
+ }
5557
+ /**
5558
+ * Sets the target speed of a hinge joint's motor in degrees per second, or a slider joint's
5559
+ * motor in meters per second, active while max-motor-force is greater than 0.
5560
+ * @param value - The motor's target speed.
5561
+ */
5562
+ set motorSpeed(value) {
5563
+ this._motorSpeed = value;
5564
+ if (this.component) {
5565
+ this.component.motorSpeed = value;
5566
+ }
5567
+ }
5568
+ /**
5569
+ * Gets the target speed of the joint's motor.
5570
+ * @returns The motor's target speed.
5571
+ */
5572
+ get motorSpeed() {
5573
+ return this._motorSpeed;
5574
+ }
5575
+ /**
5576
+ * Sets the maximum swing of a ball joint around the joint frame's Y axis in degrees, applied
5577
+ * when enable-limits is set.
5578
+ * @param value - The Y axis swing limit.
5579
+ */
5580
+ set swingLimitY(value) {
5581
+ this._swingLimitY = value;
5582
+ if (this.component) {
5583
+ this.component.swingLimitY = value;
5584
+ }
5585
+ }
5586
+ /**
5587
+ * Gets the maximum swing of the joint around the joint frame's Y axis.
5588
+ * @returns The Y axis swing limit.
5589
+ */
5590
+ get swingLimitY() {
5591
+ return this._swingLimitY;
5592
+ }
5593
+ /**
5594
+ * Sets the maximum swing of a ball joint around the joint frame's Z axis in degrees, applied
5595
+ * when enable-limits is set.
5596
+ * @param value - The Z axis swing limit.
5597
+ */
5598
+ set swingLimitZ(value) {
5599
+ this._swingLimitZ = value;
5600
+ if (this.component) {
5601
+ this.component.swingLimitZ = value;
5602
+ }
5603
+ }
5604
+ /**
5605
+ * Gets the maximum swing of the joint around the joint frame's Z axis.
5606
+ * @returns The Z axis swing limit.
5607
+ */
5608
+ get swingLimitZ() {
5609
+ return this._swingLimitZ;
5610
+ }
5611
+ /**
5612
+ * Sets the maximum twist of a ball joint about its primary axis in degrees, applied when
5613
+ * enable-limits is set.
5614
+ * @param value - The twist limit.
5615
+ */
5616
+ set twistLimit(value) {
5617
+ this._twistLimit = value;
5618
+ if (this.component) {
5619
+ this.component.twistLimit = value;
5620
+ }
5621
+ }
5622
+ /**
5623
+ * Gets the maximum twist of the joint about its primary axis.
5624
+ * @returns The twist limit.
5625
+ */
5626
+ get twistLimit() {
5627
+ return this._twistLimit;
5628
+ }
5629
+ /**
5630
+ * Sets the type of the joint. Can be `fixed`, `ball`, `hinge`, `slider` or `6dof`. Defaults to
5631
+ * `fixed`.
5632
+ * @param value - The joint type.
5633
+ */
5634
+ set type(value) {
5635
+ this._type = value;
5636
+ if (this.component) {
5637
+ this.component.type = value;
5638
+ }
5639
+ }
5640
+ /**
5641
+ * Gets the type of the joint.
5642
+ * @returns The joint type.
5643
+ */
5644
+ get type() {
5645
+ return this._type;
5646
+ }
5647
+ static get observedAttributes() {
5648
+ return [
5649
+ ...super.observedAttributes,
5650
+ 'angular-damping',
5651
+ 'angular-equilibrium',
5652
+ 'angular-limits-x',
5653
+ 'angular-limits-y',
5654
+ 'angular-limits-z',
5655
+ 'angular-motion-x',
5656
+ 'angular-motion-y',
5657
+ 'angular-motion-z',
5658
+ 'angular-stiffness',
5659
+ 'break-impulse',
5660
+ 'enable-collision',
5661
+ 'enable-limits',
5662
+ 'entity-a',
5663
+ 'entity-b',
5664
+ 'limits',
5665
+ 'linear-damping',
5666
+ 'linear-equilibrium',
5667
+ 'linear-limits-x',
5668
+ 'linear-limits-y',
5669
+ 'linear-limits-z',
5670
+ 'linear-motion-x',
5671
+ 'linear-motion-y',
5672
+ 'linear-motion-z',
5673
+ 'linear-stiffness',
5674
+ 'max-motor-force',
5675
+ 'motor-speed',
5676
+ 'swing-limit-y',
5677
+ 'swing-limit-z',
5678
+ 'twist-limit',
5679
+ 'type'
5680
+ ];
5681
+ }
5682
+ attributeChangedCallback(name, _oldValue, newValue) {
5683
+ super.attributeChangedCallback(name, _oldValue, newValue);
5684
+ switch (name) {
5685
+ case 'angular-damping':
5686
+ this.angularDamping = parseVec3(newValue, playcanvas.Vec3.ONE, name);
5687
+ break;
5688
+ case 'angular-equilibrium':
5689
+ this.angularEquilibrium = parseVec3(newValue, playcanvas.Vec3.ZERO, name);
5690
+ break;
5691
+ case 'angular-limits-x':
5692
+ this.angularLimitsX = parseVec2(newValue, playcanvas.Vec2.ZERO, name);
5693
+ break;
5694
+ case 'angular-limits-y':
5695
+ this.angularLimitsY = parseVec2(newValue, playcanvas.Vec2.ZERO, name);
5696
+ break;
5697
+ case 'angular-limits-z':
5698
+ this.angularLimitsZ = parseVec2(newValue, playcanvas.Vec2.ZERO, name);
5699
+ break;
5700
+ case 'angular-motion-x':
5701
+ this.angularMotionX = parseEnum(newValue, ['locked', 'limited', 'free'], 'locked', name);
5702
+ break;
5703
+ case 'angular-motion-y':
5704
+ this.angularMotionY = parseEnum(newValue, ['locked', 'limited', 'free'], 'locked', name);
5705
+ break;
5706
+ case 'angular-motion-z':
5707
+ this.angularMotionZ = parseEnum(newValue, ['locked', 'limited', 'free'], 'locked', name);
5708
+ break;
5709
+ case 'angular-stiffness':
5710
+ this.angularStiffness = parseVec3(newValue, playcanvas.Vec3.ZERO, name);
5711
+ break;
5712
+ case 'break-impulse':
5713
+ this.breakImpulse = parseNumber(newValue, Infinity, name);
5714
+ break;
5715
+ case 'enable-collision':
5716
+ this.enableCollision = parseBool(newValue, false);
5717
+ break;
5718
+ case 'enable-limits':
5719
+ this.enableLimits = parseBool(newValue, false);
5720
+ break;
5721
+ case 'entity-a':
5722
+ this.entityA = newValue ?? '';
5723
+ break;
5724
+ case 'entity-b':
5725
+ this.entityB = newValue ?? '';
5726
+ break;
5727
+ case 'limits':
5728
+ this.limits = parseVec2(newValue, new playcanvas.Vec2(-45, 45), name);
5729
+ break;
5730
+ case 'linear-damping':
5731
+ this.linearDamping = parseVec3(newValue, playcanvas.Vec3.ONE, name);
5732
+ break;
5733
+ case 'linear-equilibrium':
5734
+ this.linearEquilibrium = parseVec3(newValue, playcanvas.Vec3.ZERO, name);
5735
+ break;
5736
+ case 'linear-limits-x':
5737
+ this.linearLimitsX = parseVec2(newValue, playcanvas.Vec2.ZERO, name);
5738
+ break;
5739
+ case 'linear-limits-y':
5740
+ this.linearLimitsY = parseVec2(newValue, playcanvas.Vec2.ZERO, name);
5741
+ break;
5742
+ case 'linear-limits-z':
5743
+ this.linearLimitsZ = parseVec2(newValue, playcanvas.Vec2.ZERO, name);
5744
+ break;
5745
+ case 'linear-motion-x':
5746
+ this.linearMotionX = parseEnum(newValue, ['locked', 'limited', 'free'], 'locked', name);
5747
+ break;
5748
+ case 'linear-motion-y':
5749
+ this.linearMotionY = parseEnum(newValue, ['locked', 'limited', 'free'], 'locked', name);
5750
+ break;
5751
+ case 'linear-motion-z':
5752
+ this.linearMotionZ = parseEnum(newValue, ['locked', 'limited', 'free'], 'locked', name);
5753
+ break;
5754
+ case 'linear-stiffness':
5755
+ this.linearStiffness = parseVec3(newValue, playcanvas.Vec3.ZERO, name);
5756
+ break;
5757
+ case 'max-motor-force':
5758
+ this.maxMotorForce = parseNumber(newValue, 0, name);
5759
+ break;
5760
+ case 'motor-speed':
5761
+ this.motorSpeed = parseNumber(newValue, 0, name);
5762
+ break;
5763
+ case 'swing-limit-y':
5764
+ this.swingLimitY = parseNumber(newValue, 45, name);
5765
+ break;
5766
+ case 'swing-limit-z':
5767
+ this.swingLimitZ = parseNumber(newValue, 45, name);
5768
+ break;
5769
+ case 'twist-limit':
5770
+ this.twistLimit = parseNumber(newValue, 20, name);
5771
+ break;
5772
+ case 'type':
5773
+ this.type = parseEnum(newValue, ['fixed', 'ball', 'hinge', 'slider', '6dof'], 'fixed', name);
5774
+ break;
5775
+ }
5776
+ }
5777
+ }
5778
+ customElements.define('pc-joint', JointComponentElement);
5779
+
4872
5780
  /**
4873
5781
  * The LayoutChildComponentElement interface provides properties and methods for manipulating
4874
5782
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-layoutchild/ | `<pc-layoutchild>`} elements.
@@ -11295,13 +12203,7 @@ class NodeElement extends EntityBaseElement {
11295
12203
  if (!app) {
11296
12204
  return;
11297
12205
  }
11298
- const childEntities = this.querySelectorAll('pc-entity');
11299
- childEntities.forEach((child) => {
11300
- child._createEntity(app);
11301
- });
11302
- childEntities.forEach((child) => {
11303
- child._buildHierarchy(app);
11304
- });
12206
+ buildDescendantEntities(this, app);
11305
12207
  }
11306
12208
  /**
11307
12209
  * Applies every override that is explicitly set, capturing the authored value it displaces.
@@ -12288,6 +13190,7 @@ exports.ElementComponentElement = ElementComponentElement;
12288
13190
  exports.EntityBaseElement = EntityBaseElement;
12289
13191
  exports.EntityElement = EntityElement;
12290
13192
  exports.GSplatComponentElement = GSplatComponentElement;
13193
+ exports.JointComponentElement = JointComponentElement;
12291
13194
  exports.LayoutChildComponentElement = LayoutChildComponentElement;
12292
13195
  exports.LayoutGroupComponentElement = LayoutGroupComponentElement;
12293
13196
  exports.LightComponentElement = LightComponentElement;