@galacean/engine-core 2.0.0-alpha.44 → 2.0.0-alpha.46

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 (238) hide show
  1. package/dist/main.js +105 -30
  2. package/dist/main.js.map +1 -1
  3. package/dist/module.js +105 -30
  4. package/dist/module.js.map +1 -1
  5. package/package.json +3 -3
  6. package/types/2d/atlas/FontAtlas.d.ts +23 -1
  7. package/types/2d/atlas/SpriteAtlas.d.ts +8 -0
  8. package/types/2d/sprite/Sprite.d.ts +27 -1
  9. package/types/2d/sprite/SpriteMask.d.ts +43 -0
  10. package/types/2d/sprite/SpriteRenderer.d.ts +29 -0
  11. package/types/2d/text/CharInfo.d.ts +20 -1
  12. package/types/2d/text/CharRenderInfo.d.ts +15 -1
  13. package/types/2d/text/Font.d.ts +10 -0
  14. package/types/2d/text/SubFont.d.ts +35 -1
  15. package/types/2d/text/TextRenderer.d.ts +53 -0
  16. package/types/2d/text/TextUtils.d.ts +89 -1
  17. package/types/Background.d.ts +17 -0
  18. package/types/BasicResources.d.ts +52 -0
  19. package/types/Camera.d.ts +71 -1
  20. package/types/Canvas.d.ts +13 -0
  21. package/types/Component.d.ts +33 -0
  22. package/types/ComponentsDependencies.d.ts +38 -1
  23. package/types/ComponentsManager.d.ts +17 -0
  24. package/types/Engine.d.ts +106 -2
  25. package/types/Entity.d.ts +91 -1
  26. package/types/Polyfill.d.ts +12 -1
  27. package/types/RenderPipeline/BasicRenderPipeline.d.ts +3 -0
  28. package/types/RenderPipeline/BatcherManager.d.ts +23 -1
  29. package/types/RenderPipeline/CullingResults.d.ts +17 -1
  30. package/types/RenderPipeline/DepthOnlyPass.d.ts +18 -1
  31. package/types/RenderPipeline/InstanceBuffer.d.ts +28 -1
  32. package/types/RenderPipeline/MaskManager.d.ts +36 -1
  33. package/types/RenderPipeline/OpaqueTexturePass.d.ts +16 -1
  34. package/types/RenderPipeline/PipelineUtils.d.ts +11 -1
  35. package/types/RenderPipeline/PrimitiveChunk.d.ts +27 -1
  36. package/types/RenderPipeline/PrimitiveChunkManager.d.ts +16 -1
  37. package/types/RenderPipeline/RenderContext.d.ts +46 -1
  38. package/types/RenderPipeline/RenderElement.d.ts +9 -0
  39. package/types/RenderPipeline/RenderQueue.d.ts +23 -1
  40. package/types/RenderPipeline/RenderTargetPool.d.ts +17 -1
  41. package/types/RenderPipeline/SubPrimitiveChunk.d.ts +14 -1
  42. package/types/RenderPipeline/VertexArea.d.ts +10 -1
  43. package/types/RenderPipeline/VertexMergeBatcher.d.ts +11 -1
  44. package/types/RenderPipeline/enums/RenderQueueMaskType.d.ts +9 -1
  45. package/types/RenderPipeline/index.d.ts +2 -0
  46. package/types/Renderer.d.ts +58 -0
  47. package/types/Scene.d.ts +28 -0
  48. package/types/SceneManager.d.ts +13 -0
  49. package/types/Script.d.ts +40 -0
  50. package/types/SystemInfo.d.ts +10 -0
  51. package/types/Transform.d.ts +19 -0
  52. package/types/UpdateFlag.d.ts +3 -0
  53. package/types/UpdateFlagManager.d.ts +41 -1
  54. package/types/Utils.d.ts +20 -0
  55. package/types/VirtualCamera.d.ts +16 -1
  56. package/types/animation/AnimationClip.d.ts +5 -0
  57. package/types/animation/AnimationClipCurveBinding.d.ts +16 -1
  58. package/types/animation/Animator.d.ts +25 -0
  59. package/types/animation/AnimatorController.d.ts +17 -0
  60. package/types/animation/AnimatorControllerLayer.d.ts +9 -0
  61. package/types/animation/AnimatorControllerParameter.d.ts +4 -0
  62. package/types/animation/AnimatorState.d.ts +44 -0
  63. package/types/animation/AnimatorStateInstance.d.ts +8 -0
  64. package/types/animation/AnimatorStateMachine.d.ts +14 -0
  65. package/types/animation/AnimatorStateTransition.d.ts +9 -0
  66. package/types/animation/AnimatorStateTransitionCollection.d.ts +23 -1
  67. package/types/animation/StateMachineScript.d.ts +2 -0
  68. package/types/animation/animationCurve/AnimationArrayCurve.d.ts +39 -0
  69. package/types/animation/animationCurve/AnimationBoolCurve.d.ts +39 -0
  70. package/types/animation/animationCurve/AnimationColorCurve.d.ts +39 -0
  71. package/types/animation/animationCurve/AnimationCurve.d.ts +8 -0
  72. package/types/animation/animationCurve/AnimationFloatArrayCurve.d.ts +38 -0
  73. package/types/animation/animationCurve/AnimationFloatCurve.d.ts +39 -0
  74. package/types/animation/animationCurve/AnimationQuaternionCurve.d.ts +41 -0
  75. package/types/animation/animationCurve/AnimationRectCurve.d.ts +18 -0
  76. package/types/animation/animationCurve/AnimationRefCurve.d.ts +18 -0
  77. package/types/animation/animationCurve/AnimationStringCurve.d.ts +39 -0
  78. package/types/animation/animationCurve/AnimationVector2Curve.d.ts +39 -0
  79. package/types/animation/animationCurve/AnimationVector3Curve.d.ts +43 -0
  80. package/types/animation/animationCurve/AnimationVector4Curve.d.ts +39 -0
  81. package/types/animation/animationCurve/interfaces/IAnimationCurveCalculator.d.ts +18 -1
  82. package/types/animation/enums/AnimatorStatePlayState.d.ts +8 -1
  83. package/types/animation/internal/AnimationCurveLayerOwner.d.ts +15 -1
  84. package/types/animation/internal/AnimationEventHandler.d.ts +8 -1
  85. package/types/animation/internal/AnimatorLayerData.d.ts +28 -1
  86. package/types/animation/internal/AnimatorStateData.d.ts +14 -1
  87. package/types/animation/internal/AnimatorStatePlayData.d.ts +27 -1
  88. package/types/animation/internal/AnimatorTempValue.d.ts +12 -1
  89. package/types/animation/internal/animationCurveOwner/AnimationCurveOwner.d.ts +39 -0
  90. package/types/animation/internal/animationCurveOwner/assembler/BlendShapeWeightsAnimationCurveOwnerAssembler.d.ts +12 -1
  91. package/types/animation/internal/animationCurveOwner/assembler/IAnimationCurveOwnerAssembler.d.ts +10 -1
  92. package/types/animation/internal/animationCurveOwner/assembler/PositionAnimationCurveOwnerAssembler.d.ts +13 -1
  93. package/types/animation/internal/animationCurveOwner/assembler/RotationAnimationCurveOwnerAssembler.d.ts +13 -1
  94. package/types/animation/internal/animationCurveOwner/assembler/ScaleAnimationCurveOwnerAssembler.d.ts +13 -1
  95. package/types/animation/internal/animationCurveOwner/assembler/UniversalAnimationCurveOwnerAssembler.d.ts +23 -1
  96. package/types/asset/GraphicsResource.d.ts +10 -0
  97. package/types/asset/IReferable.d.ts +8 -0
  98. package/types/asset/ReferResource.d.ts +28 -0
  99. package/types/asset/RenderingStatistics.d.ts +8 -0
  100. package/types/asset/ResourceManager.d.ts +94 -4
  101. package/types/audio/AudioClip.d.ts +8 -0
  102. package/types/audio/AudioManager.d.ts +14 -0
  103. package/types/audio/AudioSource.d.ts +17 -0
  104. package/types/base/EngineObject.d.ts +4 -0
  105. package/types/base/Time.d.ts +13 -0
  106. package/types/clone/CloneDecorators.d.ts +20 -0
  107. package/types/clone/CloneUtil.d.ts +30 -1
  108. package/types/clone/ComponentCloner.d.ts +11 -1
  109. package/types/enums/CameraType.d.ts +9 -1
  110. package/types/env-probe/CubeProbe.d.ts +2 -0
  111. package/types/graphic/Buffer.d.ts +10 -0
  112. package/types/graphic/BufferUtil.d.ts +5 -0
  113. package/types/graphic/IndexBufferBinding.d.ts +4 -0
  114. package/types/graphic/Mesh.d.ts +54 -0
  115. package/types/graphic/Primitive.d.ts +50 -1
  116. package/types/graphic/TransformFeedback.d.ts +46 -1
  117. package/types/graphic/TransformFeedbackPrimitive.d.ts +67 -1
  118. package/types/graphic/TransformFeedbackSimulator.d.ts +55 -1
  119. package/types/graphic/VertexBufferBinding.d.ts +4 -0
  120. package/types/input/InputManager.d.ts +19 -0
  121. package/types/input/enums/PointerButton.d.ts +8 -0
  122. package/types/input/keyboard/KeyboardManager.d.ts +41 -1
  123. package/types/input/pointer/Pointer.d.ts +36 -0
  124. package/types/input/pointer/PointerEventData.d.ts +4 -0
  125. package/types/input/pointer/PointerManager.d.ts +58 -0
  126. package/types/input/pointer/emitter/IHitResult.d.ts +11 -1
  127. package/types/input/pointer/emitter/PhysicsPointerEventEmitter.d.ts +20 -1
  128. package/types/input/wheel/WheelManager.d.ts +34 -1
  129. package/types/lighting/AmbientLight.d.ts +9 -0
  130. package/types/lighting/DirectLight.d.ts +17 -0
  131. package/types/lighting/Light.d.ts +2 -0
  132. package/types/lighting/LightManager.d.ts +57 -0
  133. package/types/lighting/PointLight.d.ts +17 -0
  134. package/types/lighting/SpotLight.d.ts +17 -0
  135. package/types/lighting/ambientOcclusion/AmbientOcclusion.d.ts +4 -0
  136. package/types/lighting/ambientOcclusion/ScalableAmbientObscurancePass.d.ts +38 -1
  137. package/types/material/BaseMaterial.d.ts +4 -0
  138. package/types/material/Material.d.ts +2 -0
  139. package/types/mesh/BlendShape.d.ts +13 -0
  140. package/types/mesh/BlendShapeFrame.d.ts +7 -0
  141. package/types/mesh/BlendShapeManager.d.ts +101 -1
  142. package/types/mesh/MeshRenderer.d.ts +37 -0
  143. package/types/mesh/ModelMesh.d.ts +18 -0
  144. package/types/mesh/PrimitiveMesh.d.ts +28 -0
  145. package/types/mesh/PrimitiveMeshRestorer.d.ts +107 -0
  146. package/types/mesh/Skin.d.ts +10 -0
  147. package/types/mesh/SkinnedMeshRenderer.d.ts +21 -0
  148. package/types/particle/ParticleBufferUtils.d.ts +26 -1
  149. package/types/particle/ParticleGenerator.d.ts +102 -0
  150. package/types/particle/ParticleRenderer.d.ts +55 -0
  151. package/types/particle/ParticleTransformFeedbackSimulator.d.ts +52 -1
  152. package/types/particle/enums/ParticleRandomSubSeeds.d.ts +25 -1
  153. package/types/particle/enums/attributes/BillboardParticleVertexAttribute.d.ts +6 -1
  154. package/types/particle/enums/attributes/ParticleFeedbackVertexAttribute.d.ts +8 -1
  155. package/types/particle/enums/attributes/ParticleInstanceVertexAttribute.d.ts +17 -1
  156. package/types/particle/modules/ColorOverLifetimeModule.d.ts +12 -0
  157. package/types/particle/modules/CustomDataModule.d.ts +5 -0
  158. package/types/particle/modules/EmissionModule.d.ts +28 -0
  159. package/types/particle/modules/ForceOverLifetimeModule.d.ts +16 -1
  160. package/types/particle/modules/LimitVelocityOverLifetimeModule.d.ts +20 -1
  161. package/types/particle/modules/MainModule.d.ts +33 -1
  162. package/types/particle/modules/NoiseModule.d.ts +12 -1
  163. package/types/particle/modules/ParticleCompositeCurve.d.ts +37 -0
  164. package/types/particle/modules/ParticleCurve.d.ts +28 -0
  165. package/types/particle/modules/ParticleGeneratorModule.d.ts +7 -0
  166. package/types/particle/modules/ParticleGradient.d.ts +16 -0
  167. package/types/particle/modules/RotationOverLifetimeModule.d.ts +12 -0
  168. package/types/particle/modules/SizeOverLifetimeModule.d.ts +16 -0
  169. package/types/particle/modules/SubEmitter.d.ts +3 -0
  170. package/types/particle/modules/SubEmittersModule.d.ts +17 -0
  171. package/types/particle/modules/TextureSheetAnimationModule.d.ts +14 -1
  172. package/types/particle/modules/VelocityOverLifetimeModule.d.ts +28 -1
  173. package/types/particle/modules/shape/BaseShape.d.ts +33 -1
  174. package/types/particle/modules/shape/BoxShape.d.ts +13 -1
  175. package/types/particle/modules/shape/CircleShape.d.ts +13 -0
  176. package/types/particle/modules/shape/ConeShape.d.ts +13 -0
  177. package/types/particle/modules/shape/HemisphereShape.d.ts +13 -0
  178. package/types/particle/modules/shape/MeshShape.d.ts +17 -0
  179. package/types/particle/modules/shape/ShapeUtils.d.ts +13 -1
  180. package/types/particle/modules/shape/SphereShape.d.ts +13 -0
  181. package/types/physics/CharacterController.d.ts +21 -0
  182. package/types/physics/Collider.d.ts +39 -0
  183. package/types/physics/Collision.d.ts +3 -0
  184. package/types/physics/DynamicCollider.d.ts +14 -0
  185. package/types/physics/PhysicsMaterial.d.ts +3 -0
  186. package/types/physics/PhysicsScene.d.ts +51 -0
  187. package/types/physics/StaticCollider.d.ts +5 -0
  188. package/types/physics/enums/ColliderShapeChangeFlag.d.ts +8 -1
  189. package/types/physics/enums/HingeJointFlag.d.ts +14 -1
  190. package/types/physics/joint/HingeJoint.d.ts +4 -0
  191. package/types/physics/joint/Joint.d.ts +20 -0
  192. package/types/physics/joint/JointLimits.d.ts +3 -0
  193. package/types/physics/joint/JointMotor.d.ts +3 -0
  194. package/types/physics/shape/ColliderShape.d.ts +17 -0
  195. package/types/physics/shape/MeshColliderShape.d.ts +4 -0
  196. package/types/postProcess/FinalPass.d.ts +19 -1
  197. package/types/postProcess/PostProcess.d.ts +2 -0
  198. package/types/postProcess/PostProcessEffect.d.ts +4 -0
  199. package/types/postProcess/PostProcessEffectParameter.d.ts +4 -0
  200. package/types/postProcess/PostProcessManager.d.ts +43 -0
  201. package/types/postProcess/effects/BloomEffect.d.ts +25 -0
  202. package/types/postProcess/effects/TonemappingEffect.d.ts +3 -0
  203. package/types/renderingHardwareInterface/IPlatformTransformFeedback.d.ts +36 -1
  204. package/types/renderingHardwareInterface/IPlatformTransformFeedbackPrimitive.d.ts +40 -1
  205. package/types/shader/Shader.d.ts +22 -0
  206. package/types/shader/ShaderBlockProperty.d.ts +19 -1
  207. package/types/shader/ShaderData.d.ts +29 -0
  208. package/types/shader/ShaderFactory.d.ts +23 -0
  209. package/types/shader/ShaderMacro.d.ts +15 -0
  210. package/types/shader/ShaderMacroCollection.d.ts +57 -1
  211. package/types/shader/ShaderMacroProcessor.d.ts +72 -1
  212. package/types/shader/ShaderPass.d.ts +38 -0
  213. package/types/shader/ShaderProgram.d.ts +91 -1
  214. package/types/shader/ShaderProgramMap.d.ts +20 -1
  215. package/types/shader/ShaderProperty.d.ts +17 -0
  216. package/types/shader/ShaderTagKey.d.ts +2 -0
  217. package/types/shader/ShaderUniform.d.ts +49 -1
  218. package/types/shader/ShaderUniformBlock.d.ts +9 -1
  219. package/types/shader/enums/ConstantBufferBindingPoint.d.ts +7 -1
  220. package/types/shader/state/BlendState.d.ts +14 -0
  221. package/types/shader/state/DepthState.d.ts +14 -0
  222. package/types/shader/state/RasterState.d.ts +17 -0
  223. package/types/shader/state/RenderState.d.ts +11 -0
  224. package/types/shader/state/StencilState.d.ts +13 -0
  225. package/types/shadow/CascadedShadowCasterPass.d.ts +5 -0
  226. package/types/shadow/ShadowSliceData.d.ts +13 -1
  227. package/types/shadow/ShadowUtils.d.ts +43 -1
  228. package/types/sky/Sky.d.ts +9 -0
  229. package/types/texture/RenderTarget.d.ts +21 -0
  230. package/types/texture/Texture.d.ts +21 -0
  231. package/types/texture/Texture2D.d.ts +4 -0
  232. package/types/texture/Texture2DArray.d.ts +4 -0
  233. package/types/texture/TextureCube.d.ts +4 -0
  234. package/types/texture/TextureUtils.d.ts +16 -1
  235. package/types/trail/TrailRenderer.d.ts +5 -0
  236. package/types/ui/IUICanvas.d.ts +16 -1
  237. package/types/utils/DisorderedArray.d.ts +2 -0
  238. package/types/xr/XRManager.d.ts +28 -0
package/dist/main.js CHANGED
@@ -5022,10 +5022,25 @@ registerDefaultCloneMode(Component, CloneMode.Remap);
5022
5022
  };
5023
5023
  /**
5024
5024
  * @internal
5025
- */ ComponentsDependencies._removeCheck = function _removeCheck(entity, type) {
5025
+ */ ComponentsDependencies._hasDependencies = function _hasDependencies(type) {
5026
+ while(type !== Component){
5027
+ if (ComponentsDependencies._dependenciesMap.has(type)) {
5028
+ return true;
5029
+ }
5030
+ type = Object.getPrototypeOf(type);
5031
+ }
5032
+ return false;
5033
+ };
5034
+ /**
5035
+ * @internal
5036
+ */ ComponentsDependencies._removeCheck = function _removeCheck(entity, type, replace) {
5026
5037
  var components = entity._components;
5027
5038
  var n = components.length;
5028
5039
  while(type !== Component){
5040
+ // The replacement still satisfies this type and all of its base types
5041
+ if (replace && (replace === type || _instanceof(replace.prototype, type))) {
5042
+ return;
5043
+ }
5029
5044
  var count = 0;
5030
5045
  for(var i = 0; i < n; i++){
5031
5046
  if (_instanceof(components[i], type) && ++count > 1) return;
@@ -5142,6 +5157,7 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
5142
5157
 
5143
5158
  /**
5144
5159
  * Used to implement transformation related functions.
5160
+ * @remarks A `Transform` subclass must not declare component dependencies.
5145
5161
  */ var Transform = /*#__PURE__*/ function(Component) {
5146
5162
  _inherits(Transform, Component);
5147
5163
  function Transform(entity) {
@@ -5171,6 +5187,13 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
5171
5187
  return _this;
5172
5188
  }
5173
5189
  var _proto = Transform.prototype;
5190
+ _proto.destroy = function destroy() {
5191
+ var entity = this._entity;
5192
+ if (entity.transform === this && !entity.destroyed) {
5193
+ throw "Transform cannot be destroyed directly; replace it by adding another Transform-compatible component";
5194
+ }
5195
+ Component.prototype.destroy.call(this);
5196
+ };
5174
5197
  /**
5175
5198
  * Set local position by X, Y, Z value.
5176
5199
  * @param x - X coordinate
@@ -5309,22 +5332,35 @@ registerDefaultCloneMode(UpdateFlag, CloneMode.Ignore);
5309
5332
  return isInvert;
5310
5333
  };
5311
5334
  /**
5335
+ * @internal
5336
+ */ _proto._copyLocalPoseFrom = function _copyLocalPoseFrom(source) {
5337
+ var _this = this, position = _this._position, rotation = _this._rotation, rotationQuaternion = _this._rotationQuaternion, scale = _this._scale;
5338
+ //@ts-ignore
5339
+ position._onValueChanged = rotation._onValueChanged = scale._onValueChanged = null;
5340
+ //@ts-ignore
5341
+ rotationQuaternion._onValueChanged = null;
5342
+ position.copyFrom(source._position);
5343
+ scale.copyFrom(source._scale);
5344
+ rotation.copyFrom(source._rotation);
5345
+ rotationQuaternion.copyFrom(source._rotationQuaternion);
5346
+ //@ts-ignore
5347
+ position._onValueChanged = this._onPositionChanged;
5348
+ //@ts-ignore
5349
+ rotation._onValueChanged = this._onRotationChanged;
5350
+ //@ts-ignore
5351
+ rotationQuaternion._onValueChanged = this._onRotationQuaternionChanged;
5352
+ //@ts-ignore
5353
+ scale._onValueChanged = this._onScaleChanged;
5354
+ this._localUniformScaling = source._localUniformScaling;
5355
+ var rotationDirtyBits = 1 | 2;
5356
+ this._dirtyFlag = this._dirtyFlag & ~rotationDirtyBits | source._dirtyFlag & rotationDirtyBits;
5357
+ this._setDirtyFlagTrue(64);
5358
+ this._updateAllWorldFlag(444);
5359
+ };
5360
+ /**
5312
5361
  * @inheritdoc
5313
5362
  */ _proto._onClone = function _onClone(target) {
5314
- var position = target._position, rotation = target._rotation, scale = target._scale;
5315
- // @ts-ignore
5316
- position._onValueChanged = rotation._onValueChanged = scale._onValueChanged = null;
5317
- position.copyFrom(this.position);
5318
- rotation.copyFrom(this.rotation);
5319
- scale.copyFrom(this.scale);
5320
- // @ts-ignore
5321
- position._onValueChanged = target._onPositionChanged;
5322
- // @ts-ignore
5323
- rotation._onValueChanged = target._onRotationChanged;
5324
- // @ts-ignore
5325
- scale._onValueChanged = target._onScaleChanged;
5326
- // When cloning, other components may obtain properties such as `rotationQuaternion` in the constructor, local related dirty flags need to be corrected
5327
- target._setDirtyFlagTrue(2 | 64);
5363
+ target._copyLocalPoseFrom(this);
5328
5364
  };
5329
5365
  _proto._onLocalMatrixChanging = function _onLocalMatrixChanging() {
5330
5366
  this._setDirtyFlagFalse(64);
@@ -6175,10 +6211,27 @@ function _construct(Parent, args, Class) {
6175
6211
  _this = EngineObject.call(this, engine) || this, /** The layer the entity belongs to. */ _this.layer = Layer.Layer0, /** @internal */ _this._isActiveInHierarchy = false, /** @internal */ _this._isActiveInScene = false, /** @internal */ _this._components = [], /** @internal */ _this._scripts = new DisorderedArray(), /** @internal */ _this._scriptsVersion = 0, /** @internal */ _this._children = [], /** @internal */ _this._isRoot = false, /** @internal */ _this._isActive = true, /** @internal */ _this._siblingIndex = -1, /** @internal */ _this._isTemplate = false, /** @internal */ _this._updateFlagManager = new UpdateFlagManager(), _this._parent = null, //--------------------------------------------------------------deprecated----------------------------------------------------------------
6176
6212
  _this._invModelMatrix = new engineMath.Matrix();
6177
6213
  _this.name = name != null ? name : "Entity";
6178
- for(var i = 0, n = components.length; i < n; i++){
6179
- _this.addComponent(components[i]);
6214
+ var transformType = Transform;
6215
+ var n = components.length;
6216
+ for(var i = n - 1; i >= 0; i--){
6217
+ var componentType = components[i];
6218
+ if (Entity._isTransformType(componentType)) {
6219
+ transformType = componentType;
6220
+ break;
6221
+ }
6222
+ }
6223
+ Entity._checkTransformDependencies(transformType);
6224
+ var transform = new transformType(_this);
6225
+ // Constructors may add components, but Transform always owns slot zero
6226
+ _this._components.unshift(transform);
6227
+ _this._transform = transform;
6228
+ transform._setActive(true, ActiveChangeFlag.All);
6229
+ for(var i1 = 0; i1 < n; i1++){
6230
+ var componentType1 = components[i1];
6231
+ if (!Entity._isTransformType(componentType1)) {
6232
+ _this.addComponent(componentType1);
6233
+ }
6180
6234
  }
6181
- !_this._transform && _this.addComponent(Transform);
6182
6235
  _this._inverseWorldMatFlag = _this.registerWorldChangeFlag();
6183
6236
  return _this;
6184
6237
  }
@@ -6192,13 +6245,21 @@ function _construct(Parent, args, Class) {
6192
6245
  for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
6193
6246
  args[_key - 1] = arguments[_key];
6194
6247
  }
6195
- ComponentsDependencies._addCheck(this, type);
6248
+ var isTransform = Entity._isTransformType(type);
6249
+ if (isTransform) {
6250
+ Entity._checkTransformDependencies(type);
6251
+ ComponentsDependencies._removeCheck(this, this._transform.constructor, type);
6252
+ } else {
6253
+ ComponentsDependencies._addCheck(this, type);
6254
+ }
6196
6255
  var component = _construct(type, [].concat([
6197
6256
  this
6198
6257
  ], args));
6199
- this._components.push(component);
6200
- // @todo: temporary solution
6201
- if (_instanceof(component, Transform)) this._setTransform(component);
6258
+ if (isTransform) {
6259
+ this._replaceTransform(component);
6260
+ } else {
6261
+ this._components.push(component);
6262
+ }
6202
6263
  component._setActive(true, ActiveChangeFlag.All);
6203
6264
  return component;
6204
6265
  };
@@ -6346,6 +6407,7 @@ function _construct(Parent, args, Class) {
6346
6407
  _proto._createCloneEntity = function _createCloneEntity(cloneMap) {
6347
6408
  var componentConstructors = Entity._tempComponentConstructors;
6348
6409
  var components = this._components;
6410
+ componentConstructors.length = components.length;
6349
6411
  for(var i = 0, n = components.length; i < n; i++){
6350
6412
  componentConstructors[i] = components[i].constructor;
6351
6413
  }
@@ -6413,9 +6475,13 @@ function _construct(Parent, args, Class) {
6413
6475
  /**
6414
6476
  * @internal
6415
6477
  */ _proto._removeComponent = function _removeComponent(component) {
6416
- ComponentsDependencies._removeCheck(this, component.constructor);
6417
6478
  var components = this._components;
6418
- components.splice(components.indexOf(component), 1);
6479
+ var index = components.indexOf(component);
6480
+ // A replaced Transform is detached from the component slot immediately but
6481
+ // can still reach here later because object destruction may be deferred
6482
+ if (index < 0) return;
6483
+ ComponentsDependencies._removeCheck(this, component.constructor);
6484
+ components.splice(index, 1);
6419
6485
  };
6420
6486
  /**
6421
6487
  * @internal
@@ -6617,15 +6683,16 @@ function _construct(Parent, args, Class) {
6617
6683
  }
6618
6684
  }
6619
6685
  };
6620
- _proto._setTransform = function _setTransform(value) {
6621
- var _this__transform;
6622
- (_this__transform = this._transform) == null ? void 0 : _this__transform.destroy();
6623
- this._transform = value;
6686
+ _proto._replaceTransform = function _replaceTransform(replacement) {
6687
+ var previous = this._transform;
6688
+ replacement._copyLocalPoseFrom(previous);
6689
+ this._components[0] = replacement;
6690
+ this._transform = replacement;
6624
6691
  var children = this._children;
6625
6692
  for(var i = 0, n = children.length; i < n; i++){
6626
- var _children_i_transform;
6627
- (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._parentChange();
6693
+ children[i].transform._parentChange();
6628
6694
  }
6695
+ previous.destroy();
6629
6696
  };
6630
6697
  /**
6631
6698
  * @deprecated
@@ -6636,6 +6703,14 @@ function _construct(Parent, args, Class) {
6636
6703
  }
6637
6704
  return this._invModelMatrix;
6638
6705
  };
6706
+ Entity._isTransformType = function _isTransformType(type) {
6707
+ return type === Transform || _instanceof(type.prototype, Transform);
6708
+ };
6709
+ Entity._checkTransformDependencies = function _checkTransformDependencies(type) {
6710
+ if (ComponentsDependencies._hasDependencies(type)) {
6711
+ throw "Transform-compatible component " + type.name + " cannot declare component dependencies";
6712
+ }
6713
+ };
6639
6714
  /**
6640
6715
  * @internal
6641
6716
  */ Entity._findChildByName = function _findChildByName(entity, childIndex, paths, pathIndex) {