@galacean/engine-core 2.0.0-alpha.14 → 2.0.0-alpha.15

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/module.js CHANGED
@@ -22290,1378 +22290,1390 @@ PrimitiveMesh._sphereSeedCells = new Float32Array([
22290
22290
  PrimitiveMesh._sphereEdgeIdx = 0;
22291
22291
  PrimitiveMesh._spherePoleIdx = 0;
22292
22292
 
22293
- function _is_native_reflect_construct() {
22294
- // Since Reflect.construct can't be properly polyfilled, some
22295
- // implementations (e.g. core-js@2) don't set the correct internal slots.
22296
- // Those polyfills don't allow us to subclass built-ins, so we need to
22297
- // use our fallback implementation.
22298
- try {
22299
- // If the internal slots aren't set, this throws an error similar to
22300
- // TypeError: this is not a Boolean object.
22301
- var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
22302
- } catch (_) {}
22303
- return (_is_native_reflect_construct = function() {
22304
- return !!result;
22305
- })();
22306
- }
22307
-
22308
- function _construct(Parent, args, Class) {
22309
- if (_is_native_reflect_construct()) _construct = Reflect.construct;
22310
- else {
22311
- _construct = function construct(Parent, args, Class) {
22312
- var a = [null];
22313
- a.push.apply(a, args);
22314
- var Constructor = Function.bind.apply(Parent, a);
22315
- var instance = new Constructor();
22316
-
22317
- if (Class) _set_prototype_of(instance, Class.prototype);
22318
-
22319
- return instance;
22320
- };
22321
- }
22322
-
22323
- return _construct.apply(null, arguments);
22324
- }
22325
-
22326
- var ComponentCloner = /*#__PURE__*/ function() {
22327
- function ComponentCloner() {}
22328
- /**
22329
- * Clone component.
22330
- * @param source - Clone source
22331
- * @param target - Clone target
22332
- */ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot, deepInstanceMap) {
22333
- var cloneModes = CloneManager.getCloneMode(source.constructor);
22334
- for(var k in source){
22335
- CloneManager.cloneProperty(source, target, k, cloneModes[k], srcRoot, targetRoot, deepInstanceMap);
22293
+ /**
22294
+ * @internal
22295
+ * Utility functions for remapping Entity/Component references during cloning.
22296
+ */ var CloneUtils = /*#__PURE__*/ function() {
22297
+ function CloneUtils() {}
22298
+ CloneUtils.remapEntity = function remapEntity(srcRoot, targetRoot, entity) {
22299
+ var paths = CloneUtils._tempRemapPath;
22300
+ var success = CloneUtils._getEntityHierarchyPath(srcRoot, entity, paths);
22301
+ return success ? CloneUtils._getEntityByHierarchyPath(targetRoot, paths) : entity;
22302
+ };
22303
+ CloneUtils.remapComponent = function remapComponent(srcRoot, targetRoot, component) {
22304
+ var _CloneUtils__getEntityByHierarchyPath;
22305
+ var paths = CloneUtils._tempRemapPath;
22306
+ var success = CloneUtils._getEntityHierarchyPath(srcRoot, component.entity, paths);
22307
+ return success ? (_CloneUtils__getEntityByHierarchyPath = CloneUtils._getEntityByHierarchyPath(targetRoot, paths)) == null ? void 0 : _CloneUtils__getEntityByHierarchyPath.getComponent(component.constructor) : component;
22308
+ };
22309
+ CloneUtils._getEntityHierarchyPath = function _getEntityHierarchyPath(rootEntity, searchEntity, inversePath) {
22310
+ inversePath.length = 0;
22311
+ while(searchEntity !== rootEntity){
22312
+ var parent = searchEntity.parent;
22313
+ if (!parent) {
22314
+ return false;
22315
+ }
22316
+ inversePath.push(searchEntity.siblingIndex);
22317
+ searchEntity = parent;
22336
22318
  }
22337
- if (source._cloneTo) {
22338
- source._cloneTo(target, srcRoot, targetRoot);
22319
+ return true;
22320
+ };
22321
+ CloneUtils._getEntityByHierarchyPath = function _getEntityByHierarchyPath(rootEntity, inversePath) {
22322
+ var entity = rootEntity;
22323
+ for(var i = inversePath.length - 1; i >= 0; i--){
22324
+ entity = entity.children[inversePath[i]];
22339
22325
  }
22326
+ return entity;
22340
22327
  };
22341
- return ComponentCloner;
22328
+ return CloneUtils;
22342
22329
  }();
22330
+ CloneUtils._tempRemapPath = [];
22343
22331
 
22344
22332
  /**
22345
- * The entity modify flags.
22346
- */ var EntityModifyFlags = /*#__PURE__*/ function(EntityModifyFlags) {
22347
- /** The parent changes. */ EntityModifyFlags[EntityModifyFlags["Parent"] = 1] = "Parent";
22348
- /** The child changes. */ EntityModifyFlags[EntityModifyFlags["Child"] = 2] = "Child";
22349
- return EntityModifyFlags;
22350
- }({});
22351
-
22352
- /**
22353
- * Entity, be used as components container.
22354
- */ var Entity = /*#__PURE__*/ function(EngineObject) {
22355
- _inherits(Entity, EngineObject);
22356
- function Entity(engine, name) {
22357
- for(var _len = arguments.length, components = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
22358
- components[_key - 2] = arguments[_key];
22359
- }
22333
+ * Skin used for skinned mesh renderer.
22334
+ */ var Skin = /*#__PURE__*/ function(EngineObject) {
22335
+ _inherits(Skin, EngineObject);
22336
+ function Skin(name) {
22360
22337
  var _this;
22361
- _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._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----------------------------------------------------------------
22362
- _this._invModelMatrix = new Matrix();
22363
- _this.name = name != null ? name : "Entity";
22364
- for(var i = 0, n = components.length; i < n; i++){
22365
- _this.addComponent(components[i]);
22366
- }
22367
- !_this._transform && _this.addComponent(Transform);
22368
- _this._inverseWorldMatFlag = _this.registerWorldChangeFlag();
22338
+ _this = EngineObject.call(this, null) || this, _this.name = name, _this.inverseBindMatrices = new Array(), _this._updatedManager = new UpdateFlagManager(), _this._bones = new Array(), _this._updateMark = -1, _this.joints = [];
22369
22339
  return _this;
22370
22340
  }
22371
- var _proto = Entity.prototype;
22372
- /**
22373
- * Add component based on the component type.
22374
- * @param type - The type of the component
22375
- * @param args - The arguments of the component
22376
- * @returns The component which has been added
22377
- */ _proto.addComponent = function addComponent(type) {
22378
- for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
22379
- args[_key - 1] = arguments[_key];
22380
- }
22381
- ComponentsDependencies._addCheck(this, type);
22382
- var component = _construct(type, [].concat([
22383
- this
22384
- ], args));
22385
- this._components.push(component);
22386
- // @todo: temporary solution
22387
- if (_instanceof(component, Transform)) this._setTransform(component);
22388
- component._setActive(true, ActiveChangeFlag.All);
22389
- return component;
22390
- };
22341
+ var _proto = Skin.prototype;
22391
22342
  /**
22392
- * Get component which match the type.
22393
- * @param type - The type of the component
22394
- * @returns The first component which match type
22395
- */ _proto.getComponent = function getComponent(type) {
22396
- var components = this._components;
22397
- for(var i = 0, n = components.length; i < n; i++){
22398
- var component = components[i];
22399
- if (_instanceof(component, type)) {
22400
- return component;
22401
- }
22343
+ * @internal
22344
+ */ _proto._updateSkinMatrices = function _updateSkinMatrices(renderer) {
22345
+ if (this._updateMark === renderer.engine.time.frameCount) {
22346
+ return;
22402
22347
  }
22403
- return null;
22404
- };
22405
- /**
22406
- * Get components which match the type.
22407
- * @param type - The type of the component
22408
- * @param results - The components which match type
22409
- * @returns The components which match type
22410
- */ _proto.getComponents = function getComponents(type, results) {
22411
- results.length = 0;
22412
- var components = this._components;
22413
- for(var i = 0, n = components.length; i < n; i++){
22414
- var component = components[i];
22415
- if (_instanceof(component, type)) {
22416
- results.push(component);
22348
+ var _this = this, bones = _this.bones, bindMatrices = _this.inverseBindMatrices, skinMatrices = _this._skinMatrices;
22349
+ var _this_rootBone;
22350
+ var worldToLocal = ((_this_rootBone = this.rootBone) != null ? _this_rootBone : renderer.entity).getInvModelMatrix();
22351
+ for(var i = bones.length - 1; i >= 0; i--){
22352
+ var bone = bones[i];
22353
+ var offset = i * 16;
22354
+ if (bone) {
22355
+ Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, skinMatrices, offset);
22356
+ } else {
22357
+ skinMatrices.set(bindMatrices[i].elements, offset);
22417
22358
  }
22359
+ Utils._floatMatrixMultiply(worldToLocal, skinMatrices, offset, skinMatrices, offset);
22418
22360
  }
22419
- return results;
22420
- };
22421
- /**
22422
- * Get the components which match the type of the entity and it's children.
22423
- * @param type - The component type
22424
- * @param results - The components collection
22425
- * @returns The components collection which match the type
22426
- */ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
22427
- results.length = 0;
22428
- this._getComponentsInChildren(type, results);
22429
- return results;
22430
- };
22431
- _proto.addChild = function addChild(indexOrChild, child) {
22432
- var index;
22433
- if (typeof indexOrChild === "number") {
22434
- index = indexOrChild;
22435
- } else {
22436
- index = undefined;
22437
- child = indexOrChild;
22438
- }
22439
- child._setParent(this, index);
22440
- };
22441
- /**
22442
- * Remove child entity.
22443
- * @param child - The child entity which want to be removed
22444
- */ _proto.removeChild = function removeChild(child) {
22445
- if (child._parent !== this) return;
22446
- child._setParent(null);
22447
- };
22448
- /**
22449
- * @deprecated Please use `children` property instead.
22450
- * Find child entity by index.
22451
- * @param index - The index of the child entity
22452
- * @returns The component which be found
22453
- */ _proto.getChild = function getChild(index) {
22454
- return this._children[index];
22361
+ this._updateMark = renderer.engine.time.frameCount;
22455
22362
  };
22456
22363
  /**
22457
- * Find entity by name.
22458
- * @param name - The name of the entity which want to be found
22459
- * @returns The component which be found
22460
- */ _proto.findByName = function findByName(name) {
22461
- if (name === this.name) {
22462
- return this;
22364
+ * @internal
22365
+ */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
22366
+ // Clone rootBone
22367
+ var rootBone = this.rootBone;
22368
+ if (rootBone) {
22369
+ target.rootBone = CloneUtils.remapEntity(srcRoot, targetRoot, rootBone);
22463
22370
  }
22464
- var children = this._children;
22465
- for(var i = 0, n = children.length; i < n; i++){
22466
- var target = children[i].findByName(name);
22467
- if (target) {
22468
- return target;
22371
+ // Clone bones
22372
+ var bones = this.bones;
22373
+ if (bones.length > 0) {
22374
+ var boneCount = bones.length;
22375
+ var destBones = new Array(boneCount);
22376
+ for(var i = 0; i < boneCount; i++){
22377
+ destBones[i] = CloneUtils.remapEntity(srcRoot, targetRoot, bones[i]);
22469
22378
  }
22379
+ target.bones = destBones;
22470
22380
  }
22471
- return null;
22472
- };
22473
- /**
22474
- * Find the entity by path.
22475
- * @param path - The path of the entity eg: /entity
22476
- * @returns The component which be found
22477
- */ _proto.findByPath = function findByPath(path) {
22478
- var splits = path.split("/").filter(Boolean);
22479
- if (!splits.length) {
22480
- return this;
22481
- }
22482
- return Entity._findChildByName(this, 0, splits, 0);
22483
- };
22484
- /**
22485
- * Create child entity.
22486
- * @param name - The child entity's name
22487
- * @returns The child entity
22488
- */ _proto.createChild = function createChild(name) {
22489
- var transform = this._transform;
22490
- var child = transform ? new Entity(this.engine, name, transform.constructor) : new Entity(this.engine, name);
22491
- child.layer = this.layer;
22492
- child.parent = this;
22493
- return child;
22494
- };
22495
- /**
22496
- * Clear children entities.
22497
- */ _proto.clearChildren = function clearChildren() {
22498
- var children = this._children;
22499
- for(var i = children.length - 1; i >= 0; i--){
22500
- var child = children[i];
22501
- child._parent = null;
22502
- var activeChangeFlag = ActiveChangeFlag.None;
22503
- child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
22504
- child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
22505
- activeChangeFlag && child._processInActive(activeChangeFlag);
22506
- Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
22507
- }
22508
- children.length = 0;
22509
- };
22510
- /**
22511
- * Clone this entity include children and components.
22512
- * @returns Cloned entity
22513
- */ _proto.clone = function clone() {
22514
- var cloneEntity = this._createCloneEntity();
22515
- this._parseCloneEntity(this, cloneEntity, this, cloneEntity, new Map());
22516
- return cloneEntity;
22517
22381
  };
22382
+ _create_class(Skin, [
22383
+ {
22384
+ key: "rootBone",
22385
+ get: /**
22386
+ * Root bone.
22387
+ */ function get() {
22388
+ return this._rootBone;
22389
+ },
22390
+ set: function set(value) {
22391
+ if (this._rootBone !== value) {
22392
+ this._updatedManager.dispatch(1, value);
22393
+ this._rootBone = value;
22394
+ }
22395
+ }
22396
+ },
22397
+ {
22398
+ key: "bones",
22399
+ get: /**
22400
+ * Bones of the skin.
22401
+ */ function get() {
22402
+ return this._bones;
22403
+ },
22404
+ set: function set(value) {
22405
+ var bones = this._bones;
22406
+ var _value_length;
22407
+ var boneCount = (_value_length = value == null ? void 0 : value.length) != null ? _value_length : 0;
22408
+ var lastBoneCount = bones.length;
22409
+ bones.length = boneCount;
22410
+ for(var i = 0; i < boneCount; i++){
22411
+ bones[i] = value[i];
22412
+ }
22413
+ if (lastBoneCount !== boneCount) {
22414
+ this._skinMatrices = new Float32Array(boneCount * 16);
22415
+ this._updatedManager.dispatch(0, boneCount);
22416
+ }
22417
+ }
22418
+ },
22419
+ {
22420
+ key: "skeleton",
22421
+ get: /** @deprecated Please use `rootBone` instead. */ function get() {
22422
+ var _this_rootBone;
22423
+ return (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.name;
22424
+ },
22425
+ set: function set(value) {
22426
+ var rootBone = this._rootBone;
22427
+ if (rootBone) {
22428
+ rootBone.name = value;
22429
+ }
22430
+ }
22431
+ }
22432
+ ]);
22433
+ return Skin;
22434
+ }(EngineObject);
22435
+ __decorate([
22436
+ deepClone
22437
+ ], Skin.prototype, "inverseBindMatrices", void 0);
22438
+ __decorate([
22439
+ ignoreClone
22440
+ ], Skin.prototype, "_skinMatrices", void 0);
22441
+ __decorate([
22442
+ ignoreClone
22443
+ ], Skin.prototype, "_updatedManager", void 0);
22444
+ __decorate([
22445
+ ignoreClone
22446
+ ], Skin.prototype, "_rootBone", void 0);
22447
+ __decorate([
22448
+ ignoreClone
22449
+ ], Skin.prototype, "_bones", void 0);
22450
+ __decorate([
22451
+ ignoreClone
22452
+ ], Skin.prototype, "_updateMark", void 0);
22453
+ var SkinUpdateFlag = /*#__PURE__*/ function(SkinUpdateFlag) {
22454
+ SkinUpdateFlag[SkinUpdateFlag["BoneCountChanged"] = 0] = "BoneCountChanged";
22455
+ SkinUpdateFlag[SkinUpdateFlag["RootBoneChanged"] = 1] = "RootBoneChanged";
22456
+ return SkinUpdateFlag;
22457
+ }({});
22458
+
22459
+ /**
22460
+ * SkinnedMeshRenderer.
22461
+ */ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer) {
22462
+ _inherits(SkinnedMeshRenderer, MeshRenderer);
22463
+ function SkinnedMeshRenderer(entity) {
22464
+ var _this;
22465
+ _this = MeshRenderer.call(this, entity) || this, _this._localBounds = new BoundingBox(), _this._jointDataCreateCache = new Vector2(-1, -1);
22466
+ _this._skin = null;
22467
+ var rhi = _this.entity.engine._hardwareRenderer;
22468
+ var maxVertexUniformVectors = rhi.renderStates.getParameter(rhi.gl.MAX_VERTEX_UNIFORM_VECTORS);
22469
+ // Limit size to 256 to avoid some problem:
22470
+ // For renderer is "Apple GPU", when uniform is large than 256 the skeleton matrix array access in shader very slow in Safari or WKWebview. This may be a apple bug, Chrome and Firefox is OK!
22471
+ // For renderer is "ANGLE (AMD, AMD Radeon(TM) Graphics Direct3011 vs_5_0 ps_5_0, D3011)", compile shader si very slow because of max uniform is 4096.
22472
+ maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
22473
+ _this._maxVertexUniformVectors = maxVertexUniformVectors;
22474
+ _this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_this);
22475
+ _this._onSkinUpdated = _this._onSkinUpdated.bind(_this);
22476
+ var localBounds = _this._localBounds;
22477
+ // @ts-ignore
22478
+ localBounds.min._onValueChanged = _this._onLocalBoundsChanged;
22479
+ // @ts-ignore
22480
+ localBounds.max._onValueChanged = _this._onLocalBoundsChanged;
22481
+ return _this;
22482
+ }
22483
+ var _proto = SkinnedMeshRenderer.prototype;
22518
22484
  /**
22519
- * Listen for changes in the world pose of this `Entity`.
22520
- * @returns Change flag
22521
- */ _proto.registerWorldChangeFlag = function registerWorldChangeFlag() {
22522
- return this._updateFlagManager.createFlag(BoolUpdateFlag);
22485
+ * @internal
22486
+ */ _proto._onDestroy = function _onDestroy() {
22487
+ var _this__jointTexture;
22488
+ MeshRenderer.prototype._onDestroy.call(this);
22489
+ this._jointDataCreateCache = null;
22490
+ this._skin = null;
22491
+ this._blendShapeWeights = null;
22492
+ this._localBounds = null;
22493
+ (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
22494
+ this._jointTexture = null;
22523
22495
  };
22524
22496
  /**
22525
22497
  * @internal
22526
- */ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
22527
- this._isTemplate = true;
22528
- this._templateResource = templateResource;
22529
- };
22530
- _proto._createCloneEntity = function _createCloneEntity() {
22531
- var componentConstructors = Entity._tempComponentConstructors;
22532
- var components = this._components;
22533
- for(var i = 0, n = components.length; i < n; i++){
22534
- componentConstructors[i] = components[i].constructor;
22535
- }
22536
- var cloneEntity = _construct(Entity, [].concat([
22537
- this.engine,
22538
- this.name
22539
- ], componentConstructors));
22540
- componentConstructors.length = 0;
22541
- var templateResource = this._templateResource;
22542
- if (templateResource) {
22543
- cloneEntity._templateResource = templateResource;
22544
- templateResource._addReferCount(1);
22545
- }
22546
- cloneEntity.layer = this.layer;
22547
- cloneEntity._isActive = this._isActive;
22548
- var srcChildren = this._children;
22549
- for(var i1 = 0, n1 = srcChildren.length; i1 < n1; i1++){
22550
- cloneEntity.addChild(srcChildren[i1]._createCloneEntity());
22498
+ */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
22499
+ MeshRenderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
22500
+ if (this.skin) {
22501
+ target._applySkin(null, target.skin);
22551
22502
  }
22552
- return cloneEntity;
22503
+ this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
22553
22504
  };
22554
- _proto._parseCloneEntity = function _parseCloneEntity(src, target, srcRoot, targetRoot, deepInstanceMap) {
22555
- var srcChildren = src._children;
22556
- var targetChildren = target._children;
22557
- for(var i = 0, n = srcChildren.length; i < n; i++){
22558
- this._parseCloneEntity(srcChildren[i], targetChildren[i], srcRoot, targetRoot, deepInstanceMap);
22505
+ _proto._update = function _update(context) {
22506
+ var skin = this.skin;
22507
+ if ((skin == null ? void 0 : skin.bones.length) > 0) {
22508
+ skin._updateSkinMatrices(this);
22559
22509
  }
22560
- var components = src._components;
22561
- for(var i1 = 0, n1 = components.length; i1 < n1; i1++){
22562
- ComponentCloner.cloneComponent(components[i1], target._components[i1], srcRoot, targetRoot, deepInstanceMap);
22510
+ var shaderData = this.shaderData;
22511
+ var mesh = this.mesh;
22512
+ var blendShapeManager = mesh._blendShapeManager;
22513
+ blendShapeManager._updateShaderData(shaderData, this);
22514
+ var bones = skin == null ? void 0 : skin.bones;
22515
+ if (bones) {
22516
+ var bsUniformOccupiesCount = blendShapeManager._uniformOccupiesCount;
22517
+ var boneCount = bones.length;
22518
+ var boneDataCreateCache = this._jointDataCreateCache;
22519
+ var boneCountChange = boneCount !== boneDataCreateCache.x;
22520
+ if (boneCountChange || bsUniformOccupiesCount !== boneDataCreateCache.y) {
22521
+ // directly use max joint count to avoid shader recompile
22522
+ var remainUniformJointCount = Math.ceil((this._maxVertexUniformVectors - (SkinnedMeshRenderer._baseVertexUniformVectorCount + bsUniformOccupiesCount)) / 4);
22523
+ if (boneCount > remainUniformJointCount) {
22524
+ var engine = this.engine;
22525
+ if (engine._hardwareRenderer.canIUseMoreJoints) {
22526
+ if (boneCountChange) {
22527
+ var _this__jointTexture;
22528
+ (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
22529
+ this._jointTexture = new Texture2D(engine, 4, boneCount, TextureFormat.R32G32B32A32, false, false);
22530
+ this._jointTexture.filterMode = TextureFilterMode.Point;
22531
+ this._jointTexture.isGCIgnored = true;
22532
+ }
22533
+ shaderData.disableMacro("RENDERER_JOINTS_NUM");
22534
+ shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
22535
+ shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
22536
+ } else {
22537
+ Logger.error("component's joints count(" + boneCount + ") greater than device's MAX_VERTEX_UNIFORM_VECTORS number " + this._maxVertexUniformVectors + ", and don't support jointTexture in this device. suggest joint count less than " + remainUniformJointCount + ".", this);
22538
+ }
22539
+ } else {
22540
+ var _this__jointTexture1;
22541
+ (_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
22542
+ shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
22543
+ shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
22544
+ shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, skin._skinMatrices);
22545
+ }
22546
+ boneDataCreateCache.set(boneCount, bsUniformOccupiesCount);
22547
+ }
22548
+ if (this._jointTexture) {
22549
+ this._jointTexture.setPixelBuffer(skin._skinMatrices);
22550
+ }
22563
22551
  }
22552
+ MeshRenderer.prototype._update.call(this, context);
22564
22553
  };
22565
22554
  /**
22566
- * Destroy self.
22567
- */ _proto.destroy = function destroy() {
22568
- EngineObject.prototype.destroy.call(this);
22569
- if (!this._destroyed) {
22570
- return;
22571
- }
22572
- if (this._templateResource) {
22573
- this._isTemplate || this._templateResource._addReferCount(-1);
22574
- this._templateResource = null;
22575
- }
22576
- var components = this._components;
22577
- for(var i = components.length - 1; i >= 0; i--){
22578
- components[i].destroy();
22579
- }
22580
- this._components.length = 0;
22581
- var children = this._children;
22582
- while(children.length > 0){
22583
- children[0].destroy();
22555
+ * @internal
22556
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
22557
+ var _this_skin;
22558
+ var rootBone = (_this_skin = this.skin) == null ? void 0 : _this_skin.rootBone;
22559
+ if (rootBone) {
22560
+ BoundingBox.transform(this._localBounds, this._transformEntity.transform.worldMatrix, worldBounds);
22561
+ } else {
22562
+ MeshRenderer.prototype._updateBounds.call(this, worldBounds);
22584
22563
  }
22585
- if (this._isRoot) {
22586
- this._scene.removeRootEntity(this);
22564
+ };
22565
+ _proto._checkBlendShapeWeightLength = function _checkBlendShapeWeightLength() {
22566
+ var mesh = this._mesh;
22567
+ var newBlendShapeCount = mesh ? mesh.blendShapeCount : 0;
22568
+ var lastBlendShapeWeights = this._blendShapeWeights;
22569
+ if (lastBlendShapeWeights) {
22570
+ var lastBlendShapeWeightsCount = lastBlendShapeWeights.length;
22571
+ if (lastBlendShapeWeightsCount !== newBlendShapeCount) {
22572
+ var newBlendShapeWeights = new Float32Array(newBlendShapeCount);
22573
+ if (newBlendShapeCount > lastBlendShapeWeightsCount) {
22574
+ newBlendShapeWeights.set(lastBlendShapeWeights);
22575
+ } else {
22576
+ for(var i = 0; i < newBlendShapeCount; i++){
22577
+ newBlendShapeWeights[i] = lastBlendShapeWeights[i];
22578
+ }
22579
+ }
22580
+ this._blendShapeWeights = newBlendShapeWeights;
22581
+ }
22587
22582
  } else {
22588
- this._setParent(null);
22583
+ this._blendShapeWeights = new Float32Array(newBlendShapeCount);
22589
22584
  }
22590
- this.isActive = false;
22591
22585
  };
22592
- /**
22593
- * @internal
22594
- */ _proto._removeComponent = function _removeComponent(component) {
22595
- ComponentsDependencies._removeCheck(this, component.constructor);
22596
- var components = this._components;
22597
- components.splice(components.indexOf(component), 1);
22598
- };
22599
- /**
22600
- * @internal
22601
- */ _proto._addScript = function _addScript(script) {
22602
- script._entityScriptsIndex = this._scripts.length;
22603
- this._scripts.add(script);
22604
- };
22605
- /**
22606
- * @internal
22607
- */ _proto._removeScript = function _removeScript(script) {
22608
- var replaced = this._scripts.deleteByIndex(script._entityScriptsIndex);
22609
- replaced && (replaced._entityScriptsIndex = script._entityScriptsIndex);
22610
- script._entityScriptsIndex = -1;
22586
+ _proto._onLocalBoundsChanged = function _onLocalBoundsChanged() {
22587
+ this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
22611
22588
  };
22612
- /**
22613
- * @internal
22614
- */ _proto._removeFromParent = function _removeFromParent() {
22615
- var oldParent = this._parent;
22616
- if (oldParent != null) {
22617
- Entity._removeFromChildren(oldParent._children, this);
22618
- this._parent = null;
22619
- oldParent._dispatchModify(EntityModifyFlags.Child, oldParent);
22589
+ _proto._onSkinUpdated = function _onSkinUpdated(type, value) {
22590
+ switch(type){
22591
+ case SkinUpdateFlag.BoneCountChanged:
22592
+ var shaderData = this.shaderData;
22593
+ if (value > 0) {
22594
+ shaderData.enableMacro("RENDERER_HAS_SKIN");
22595
+ shaderData.setInt(SkinnedMeshRenderer._jointCountProperty, value);
22596
+ } else {
22597
+ shaderData.disableMacro("RENDERER_HAS_SKIN");
22598
+ }
22599
+ break;
22600
+ case SkinUpdateFlag.RootBoneChanged:
22601
+ this._setTransformEntity(value);
22602
+ this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
22603
+ break;
22620
22604
  }
22621
22605
  };
22622
- /**
22623
- * @internal
22624
- */ _proto._processActive = function _processActive(activeChangeFlag) {
22625
- if (this._activeChangedComponents) {
22626
- throw "Note: can't set the 'main inActive entity' active in hierarchy, if the operation is in main inActive entity or it's children script's onDisable Event.";
22606
+ _proto._applySkin = function _applySkin(lastSkin, value) {
22607
+ var _lastSkin_bones, _value_bones;
22608
+ var _lastSkin_bones_length;
22609
+ var lastSkinBoneCount = (_lastSkin_bones_length = lastSkin == null ? void 0 : (_lastSkin_bones = lastSkin.bones) == null ? void 0 : _lastSkin_bones.length) != null ? _lastSkin_bones_length : 0;
22610
+ var _lastSkin_rootBone;
22611
+ var lastRootBone = (_lastSkin_rootBone = lastSkin == null ? void 0 : lastSkin.rootBone) != null ? _lastSkin_rootBone : this.entity;
22612
+ lastSkin == null ? void 0 : lastSkin._updatedManager.removeListener(this._onSkinUpdated);
22613
+ var _value_bones_length;
22614
+ var skinBoneCount = (_value_bones_length = value == null ? void 0 : (_value_bones = value.bones) == null ? void 0 : _value_bones.length) != null ? _value_bones_length : 0;
22615
+ var _value_rootBone;
22616
+ var rootBone = (_value_rootBone = value == null ? void 0 : value.rootBone) != null ? _value_rootBone : this.entity;
22617
+ value == null ? void 0 : value._updatedManager.addListener(this._onSkinUpdated);
22618
+ if (lastSkinBoneCount !== skinBoneCount) {
22619
+ this._onSkinUpdated(SkinUpdateFlag.BoneCountChanged, skinBoneCount);
22627
22620
  }
22628
- this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
22629
- this._setActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
22630
- this._setActiveComponents(true, activeChangeFlag);
22631
- };
22632
- /**
22633
- * @internal
22634
- */ _proto._processInActive = function _processInActive(activeChangeFlag) {
22635
- if (this._activeChangedComponents) {
22636
- throw "Note: can't set the 'main active entity' inActive in hierarchy, if the operation is in main active entity or it's children script's onEnable Event.";
22621
+ if (lastRootBone !== rootBone) {
22622
+ this._onSkinUpdated(SkinUpdateFlag.RootBoneChanged, rootBone);
22637
22623
  }
22638
- this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
22639
- this._setInActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
22640
- this._setActiveComponents(false, activeChangeFlag);
22641
- };
22642
- /**
22643
- * @internal
22644
- */ _proto._setParentChange = function _setParentChange() {
22645
- this._transform._parentChange();
22646
- this._dispatchModify(EntityModifyFlags.Parent, this);
22647
- };
22648
- /**
22649
- * @internal
22650
- */ _proto._registerModifyListener = function _registerModifyListener(onChange) {
22651
- (this._modifyFlagManager || (this._modifyFlagManager = new UpdateFlagManager())).addListener(onChange);
22652
- };
22653
- /**
22654
- * @internal
22655
- */ _proto._unRegisterModifyListener = function _unRegisterModifyListener(onChange) {
22656
- var _this__modifyFlagManager;
22657
- (_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.removeListener(onChange);
22658
- };
22659
- _proto._dispatchModify = function _dispatchModify(flag, param) {
22660
- var _this__modifyFlagManager;
22661
- (_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.dispatch(flag, param);
22662
- };
22663
- _proto._addToChildrenList = function _addToChildrenList(index, child) {
22664
- Entity._addToChildren(this._children, child, index);
22665
- this._dispatchModify(EntityModifyFlags.Child, this);
22666
22624
  };
22667
- _proto._setParent = function _setParent(parent, siblingIndex) {
22668
- var oldParent = this._parent;
22669
- if (parent !== oldParent) {
22670
- if (this._isRoot) {
22671
- Entity._removeFromChildren(this._scene._rootEntities, this);
22672
- this._isRoot = false;
22673
- } else {
22674
- this._removeFromParent();
22675
- }
22676
- this._parent = parent;
22677
- if (parent) {
22678
- this._isRoot = false;
22679
- parent._addToChildrenList(siblingIndex, this);
22680
- var oldScene = this._scene;
22681
- var parentScene = parent._scene;
22682
- var inActiveChangeFlag = ActiveChangeFlag.None;
22683
- if (!parent._isActiveInHierarchy) {
22684
- this._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
22625
+ _create_class(SkinnedMeshRenderer, [
22626
+ {
22627
+ key: "skin",
22628
+ get: /**
22629
+ * Skin of the SkinnedMeshRenderer.
22630
+ */ function get() {
22631
+ return this._skin;
22632
+ },
22633
+ set: function set(value) {
22634
+ var lastSkin = this._skin;
22635
+ if (lastSkin !== value) {
22636
+ this._applySkin(lastSkin, value);
22637
+ this._skin = value;
22685
22638
  }
22686
- if (parent._isActiveInScene) {
22687
- // cross scene should inActive first and then active
22688
- this._isActiveInScene && oldScene !== parentScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
22639
+ }
22640
+ },
22641
+ {
22642
+ key: "blendShapeWeights",
22643
+ get: /**
22644
+ * The weights of the BlendShapes.
22645
+ * @remarks Array index is BlendShape index.
22646
+ */ function get() {
22647
+ this._checkBlendShapeWeightLength();
22648
+ return this._blendShapeWeights;
22649
+ },
22650
+ set: function set(value) {
22651
+ this._checkBlendShapeWeightLength();
22652
+ var blendShapeWeights = this._blendShapeWeights;
22653
+ if (value.length <= blendShapeWeights.length) {
22654
+ blendShapeWeights.set(value);
22689
22655
  } else {
22690
- this._isActiveInScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
22691
- }
22692
- inActiveChangeFlag && this._processInActive(inActiveChangeFlag);
22693
- if (oldScene !== parentScene) {
22694
- Entity._traverseSetOwnerScene(this, parentScene);
22695
- }
22696
- var activeChangeFlag = ActiveChangeFlag.None;
22697
- if (this._isActive) {
22698
- if (parent._isActiveInHierarchy) {
22699
- !this._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
22700
- }
22701
- if (parent._isActiveInScene) {
22702
- (!this._isActiveInScene || oldScene !== parentScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
22656
+ for(var i = 0, n = blendShapeWeights.length; i < n; i++){
22657
+ blendShapeWeights[i] = value[i];
22703
22658
  }
22704
22659
  }
22705
- activeChangeFlag && this._processActive(activeChangeFlag);
22706
- } else {
22707
- var inActiveChangeFlag1 = ActiveChangeFlag.None;
22708
- this._isActiveInHierarchy && (inActiveChangeFlag1 |= ActiveChangeFlag.Hierarchy);
22709
- this._isActiveInScene && (inActiveChangeFlag1 |= ActiveChangeFlag.Scene);
22710
- inActiveChangeFlag1 && this._processInActive(inActiveChangeFlag1);
22711
- if (oldParent) {
22712
- Entity._traverseSetOwnerScene(this, null);
22660
+ }
22661
+ },
22662
+ {
22663
+ key: "localBounds",
22664
+ get: /**
22665
+ * Local bounds.
22666
+ */ function get() {
22667
+ return this._localBounds;
22668
+ },
22669
+ set: function set(value) {
22670
+ if (this._localBounds !== value) {
22671
+ this._localBounds.copyFrom(value);
22713
22672
  }
22714
22673
  }
22715
- this._setParentChange();
22716
- } else {
22717
- if (parent && siblingIndex !== undefined) {
22718
- this.siblingIndex = siblingIndex;
22674
+ },
22675
+ {
22676
+ key: "rootBone",
22677
+ get: /**
22678
+ * @deprecated use {@link SkinnedMeshRenderer.skin.rootBone} instead.
22679
+ */ function get() {
22680
+ return this.skin.rootBone;
22681
+ },
22682
+ set: function set(value) {
22683
+ this.skin.rootBone = value;
22719
22684
  }
22720
- }
22721
- };
22722
- _proto._getComponentsInChildren = function _getComponentsInChildren(type, results) {
22723
- for(var i = this._components.length - 1; i >= 0; i--){
22724
- var component = this._components[i];
22725
- if (_instanceof(component, type)) {
22726
- results.push(component);
22685
+ },
22686
+ {
22687
+ key: "bones",
22688
+ get: /**
22689
+ * @deprecated use {@link SkinnedMeshRenderer.skin.bones} instead.
22690
+ */ function get() {
22691
+ return this.skin.bones;
22692
+ },
22693
+ set: function set(value) {
22694
+ this.skin.bones = value;
22727
22695
  }
22728
22696
  }
22729
- for(var i1 = this._children.length - 1; i1 >= 0; i1--){
22730
- this._children[i1]._getComponentsInChildren(type, results);
22731
- }
22732
- };
22733
- _proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
22734
- var activeChangedComponents = this._activeChangedComponents;
22735
- for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
22736
- activeChangedComponents[i]._setActive(isActive, activeChangeFlag);
22737
- }
22738
- this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
22739
- this._activeChangedComponents = null;
22740
- };
22741
- _proto._setActiveInHierarchy = function _setActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
22742
- activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = true);
22743
- activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = true);
22744
- var components = this._components;
22745
- for(var i = 0, n = components.length; i < n; i++){
22746
- var component = components[i];
22747
- (component.enabled || !component._awoken) && activeChangedComponents.push(component);
22748
- }
22749
- var children = this._children;
22750
- for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
22751
- var child = children[i1];
22752
- child.isActive && child._setActiveInHierarchy(activeChangedComponents, activeChangeFlag);
22753
- }
22754
- };
22755
- _proto._setInActiveInHierarchy = function _setInActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
22756
- activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = false);
22757
- activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = false);
22758
- var components = this._components;
22759
- for(var i = 0, n = components.length; i < n; i++){
22760
- var component = components[i];
22761
- component.enabled && activeChangedComponents.push(component);
22762
- }
22763
- var children = this._children;
22764
- for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
22765
- var child = children[i1];
22766
- child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
22767
- }
22768
- };
22769
- _proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
22770
- target = Math.min(target, sibling.length - 1);
22771
- if (target < 0) {
22772
- throw "Sibling index " + target + " should large than 0";
22697
+ ]);
22698
+ return SkinnedMeshRenderer;
22699
+ }(MeshRenderer);
22700
+ // @TODO: different shader type should use different count, not always 48
22701
+ /** @internal */ SkinnedMeshRenderer._baseVertexUniformVectorCount = 48;
22702
+ SkinnedMeshRenderer._jointCountProperty = ShaderProperty.getByName("renderer_JointCount");
22703
+ SkinnedMeshRenderer._jointSamplerProperty = ShaderProperty.getByName("renderer_JointSampler");
22704
+ SkinnedMeshRenderer._jointMatrixProperty = ShaderProperty.getByName("renderer_JointMatrix");
22705
+ __decorate([
22706
+ ignoreClone
22707
+ ], SkinnedMeshRenderer.prototype, "_condensedBlendShapeWeights", void 0);
22708
+ __decorate([
22709
+ deepClone
22710
+ ], SkinnedMeshRenderer.prototype, "_localBounds", void 0);
22711
+ __decorate([
22712
+ ignoreClone
22713
+ ], SkinnedMeshRenderer.prototype, "_jointDataCreateCache", void 0);
22714
+ __decorate([
22715
+ ignoreClone
22716
+ ], SkinnedMeshRenderer.prototype, "_blendShapeWeights", void 0);
22717
+ __decorate([
22718
+ ignoreClone
22719
+ ], SkinnedMeshRenderer.prototype, "_maxVertexUniformVectors", void 0);
22720
+ __decorate([
22721
+ ignoreClone
22722
+ ], SkinnedMeshRenderer.prototype, "_jointTexture", void 0);
22723
+ __decorate([
22724
+ deepClone
22725
+ ], SkinnedMeshRenderer.prototype, "_skin", void 0);
22726
+ __decorate([
22727
+ ignoreClone
22728
+ ], SkinnedMeshRenderer.prototype, "_onLocalBoundsChanged", null);
22729
+ __decorate([
22730
+ ignoreClone
22731
+ ], SkinnedMeshRenderer.prototype, "_onSkinUpdated", null);
22732
+
22733
+ /**
22734
+ * @internal
22735
+ */ var BasicResources = /*#__PURE__*/ function() {
22736
+ function BasicResources(engine) {
22737
+ this.engine = engine;
22738
+ // prettier-ignore
22739
+ var vertices = new Float32Array([
22740
+ -1,
22741
+ -1,
22742
+ 0,
22743
+ 1,
22744
+ 3,
22745
+ -1,
22746
+ 2,
22747
+ 1,
22748
+ -1,
22749
+ 3,
22750
+ 0,
22751
+ -1
22752
+ ]); // left-top
22753
+ // prettier-ignore
22754
+ var flipYVertices = new Float32Array([
22755
+ 3,
22756
+ -1,
22757
+ 2,
22758
+ 0,
22759
+ -1,
22760
+ -1,
22761
+ 0,
22762
+ 0,
22763
+ -1,
22764
+ 3,
22765
+ 0,
22766
+ 2
22767
+ ]); // left-top
22768
+ var blitMaterial = new Material(engine, Shader.find("blit"));
22769
+ blitMaterial._addReferCount(1);
22770
+ blitMaterial.renderState.depthState.enabled = false;
22771
+ blitMaterial.renderState.depthState.writeEnabled = false;
22772
+ var blitScreenMaterial = new Material(engine, Shader.find("blit-screen"));
22773
+ blitScreenMaterial._addReferCount(1);
22774
+ blitScreenMaterial.renderState.depthState.enabled = false;
22775
+ blitScreenMaterial.renderState.depthState.writeEnabled = false;
22776
+ this.blitMaterial = blitMaterial;
22777
+ this.blitScreenMaterial = blitScreenMaterial;
22778
+ this.blitMesh = this._createBlitMesh(engine, vertices);
22779
+ this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
22780
+ // Create white and magenta textures
22781
+ var whitePixel = new Uint8Array([
22782
+ 255,
22783
+ 255,
22784
+ 255,
22785
+ 255
22786
+ ]);
22787
+ this.whiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R8G8B8A8, whitePixel, true);
22788
+ this.whiteTextureCube = this._create1x1Texture(engine, 1, TextureFormat.R8G8B8A8, whitePixel, true);
22789
+ var isWebGL2 = engine._hardwareRenderer.isWebGL2;
22790
+ if (isWebGL2) {
22791
+ this.whiteTexture2DArray = this._create1x1Texture(engine, 2, TextureFormat.R8G8B8A8, whitePixel, true);
22792
+ var whitePixel32 = new Uint32Array([
22793
+ 255,
22794
+ 255,
22795
+ 255,
22796
+ 255
22797
+ ]);
22798
+ this.uintWhiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R32G32B32A32_UInt, whitePixel32, false);
22773
22799
  }
22774
- if (this._siblingIndex !== target) {
22775
- var oldIndex = this._siblingIndex;
22776
- if (target < oldIndex) {
22777
- for(var i = oldIndex; i >= target; i--){
22778
- var child = i == target ? this : sibling[i - 1];
22779
- sibling[i] = child;
22780
- child._siblingIndex = i;
22800
+ this.spriteDefaultMaterial = this._create2DMaterial(engine, Shader.find("Sprite"));
22801
+ this.textDefaultMaterial = this._create2DMaterial(engine, Shader.find("Text"));
22802
+ this.spriteMaskDefaultMaterial = this._createSpriteMaskMaterial(engine);
22803
+ this.meshMagentaMaterial = this._createMagentaMaterial(engine, "unlit");
22804
+ this.particleMagentaMaterial = this._createMagentaMaterial(engine, "particle-shader");
22805
+ }
22806
+ var _proto = BasicResources.prototype;
22807
+ /**
22808
+ * @internal
22809
+ */ _proto._getBlinnPhongMaterial = function _getBlinnPhongMaterial() {
22810
+ return this._blinnPhongMaterial || (this._blinnPhongMaterial = new BlinnPhongMaterial(this.engine));
22811
+ };
22812
+ /**
22813
+ * @internal
22814
+ */ _proto._initialize = function _initialize() {
22815
+ var _this = this;
22816
+ return new Promise(function(resolve, reject) {
22817
+ PrefilteredDFG.create(_this.engine).then(function(texture) {
22818
+ _this._prefilteredDFGTexture = texture;
22819
+ resolve(_this);
22820
+ }).catch(reject);
22821
+ });
22822
+ };
22823
+ _proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
22824
+ var mesh = new ModelMesh(engine);
22825
+ mesh._addReferCount(1);
22826
+ mesh.setVertexElements([
22827
+ new VertexElement("POSITION_UV", 0, VertexElementFormat.Vector4, 0)
22828
+ ]);
22829
+ var buffer = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static, true);
22830
+ mesh.setVertexBufferBinding(buffer, 16);
22831
+ mesh.addSubMesh(0, 3, MeshTopology.Triangles);
22832
+ engine.resourceManager.addContentRestorer(new (/*#__PURE__*/ function(ContentRestorer) {
22833
+ _inherits(_class, ContentRestorer);
22834
+ function _class() {
22835
+ return ContentRestorer.call(this, mesh) || this;
22836
+ }
22837
+ var _proto = _class.prototype;
22838
+ _proto.restoreContent = function restoreContent() {
22839
+ buffer.setData(buffer.data);
22840
+ };
22841
+ return _class;
22842
+ }(ContentRestorer))());
22843
+ return mesh;
22844
+ };
22845
+ _proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel, isSRGBColorSpace) {
22846
+ var texture;
22847
+ switch(type){
22848
+ case 0:
22849
+ var texture2D = new Texture2D(engine, 1, 1, format, false, isSRGBColorSpace);
22850
+ texture2D.setPixelBuffer(pixel);
22851
+ texture = texture2D;
22852
+ break;
22853
+ case 2:
22854
+ var texture2DArray = new Texture2DArray(engine, 1, 1, 1, format, false, isSRGBColorSpace);
22855
+ texture2DArray.setPixelBuffer(0, pixel);
22856
+ texture = texture2DArray;
22857
+ break;
22858
+ case 1:
22859
+ var textureCube = new TextureCube(engine, 1, format, false, isSRGBColorSpace);
22860
+ for(var i = 0; i < 6; i++){
22861
+ textureCube.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
22781
22862
  }
22782
- } else {
22783
- for(var i1 = oldIndex; i1 <= target; i1++){
22784
- var child1 = i1 == target ? this : sibling[i1 + 1];
22785
- sibling[i1] = child1;
22786
- child1._siblingIndex = i1;
22863
+ texture = textureCube;
22864
+ break;
22865
+ default:
22866
+ throw "Invalid texture type";
22867
+ }
22868
+ texture.isGCIgnored = true;
22869
+ engine.resourceManager.addContentRestorer(new (/*#__PURE__*/ function(ContentRestorer) {
22870
+ _inherits(_class, ContentRestorer);
22871
+ function _class() {
22872
+ return ContentRestorer.call(this, texture) || this;
22873
+ }
22874
+ var _proto = _class.prototype;
22875
+ _proto.restoreContent = function restoreContent() {
22876
+ switch(type){
22877
+ case 0:
22878
+ this.resource.setPixelBuffer(pixel);
22879
+ break;
22880
+ case 2:
22881
+ this.resource.setPixelBuffer(0, pixel);
22882
+ break;
22883
+ case 1:
22884
+ for(var i = 0; i < 6; i++){
22885
+ this.resource.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
22886
+ }
22887
+ break;
22787
22888
  }
22889
+ };
22890
+ return _class;
22891
+ }(ContentRestorer))());
22892
+ return texture;
22893
+ };
22894
+ _proto._create2DMaterial = function _create2DMaterial(engine, shader) {
22895
+ var material = new Material(engine, shader);
22896
+ var renderState = material.renderState;
22897
+ var target = renderState.blendState.targetBlendState;
22898
+ target.enabled = true;
22899
+ target.sourceColorBlendFactor = BlendFactor.SourceAlpha;
22900
+ target.destinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
22901
+ target.sourceAlphaBlendFactor = BlendFactor.One;
22902
+ target.destinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
22903
+ target.colorBlendOperation = target.alphaBlendOperation = BlendOperation.Add;
22904
+ renderState.depthState.writeEnabled = false;
22905
+ renderState.rasterState.cullMode = CullMode.Off;
22906
+ renderState.renderQueueType = RenderQueueType.Transparent;
22907
+ material.isGCIgnored = true;
22908
+ return material;
22909
+ };
22910
+ _proto._createMagentaMaterial = function _createMagentaMaterial(engine, shaderName) {
22911
+ var material = new Material(engine, Shader.find(shaderName));
22912
+ material.isGCIgnored = true;
22913
+ material.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
22914
+ return material;
22915
+ };
22916
+ _proto._createSpriteMaskMaterial = function _createSpriteMaskMaterial(engine) {
22917
+ var material = new Material(engine, Shader.find("SpriteMask"));
22918
+ material.isGCIgnored = true;
22919
+ return material;
22920
+ };
22921
+ BasicResources.getMaskInteractionRenderStates = function getMaskInteractionRenderStates(maskInteraction) {
22922
+ var visibleInsideMask = maskInteraction === SpriteMaskInteraction.VisibleInsideMask;
22923
+ var renderStates;
22924
+ var compareFunction;
22925
+ if (visibleInsideMask) {
22926
+ renderStates = BasicResources._maskReadInsideRenderStates;
22927
+ if (renderStates) {
22928
+ return renderStates;
22929
+ }
22930
+ BasicResources._maskReadInsideRenderStates = renderStates = {};
22931
+ compareFunction = CompareFunction.LessEqual;
22932
+ } else {
22933
+ renderStates = BasicResources._maskReadOutsideRenderStates;
22934
+ if (renderStates) {
22935
+ return renderStates;
22936
+ }
22937
+ BasicResources._maskReadOutsideRenderStates = renderStates = {};
22938
+ compareFunction = CompareFunction.Greater;
22939
+ }
22940
+ renderStates[RenderStateElementKey.StencilStateEnabled] = true;
22941
+ renderStates[RenderStateElementKey.StencilStateWriteMask] = 0x00;
22942
+ renderStates[RenderStateElementKey.StencilStateReferenceValue] = 1;
22943
+ renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = compareFunction;
22944
+ renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = compareFunction;
22945
+ return renderStates;
22946
+ };
22947
+ BasicResources.getMaskTypeRenderStates = function getMaskTypeRenderStates(maskType) {
22948
+ var isIncrement = maskType === RenderQueueMaskType.Increment;
22949
+ var renderStates;
22950
+ var passOperation;
22951
+ if (isIncrement) {
22952
+ renderStates = BasicResources._maskWriteIncrementRenderStates;
22953
+ if (renderStates) {
22954
+ return renderStates;
22955
+ }
22956
+ BasicResources._maskWriteIncrementRenderStates = renderStates = {};
22957
+ passOperation = StencilOperation.IncrementSaturate;
22958
+ } else {
22959
+ renderStates = BasicResources._maskWriteDecrementRenderStates;
22960
+ if (renderStates) {
22961
+ return renderStates;
22962
+ }
22963
+ BasicResources._maskWriteDecrementRenderStates = renderStates = {};
22964
+ passOperation = StencilOperation.DecrementSaturate;
22965
+ }
22966
+ renderStates[RenderStateElementKey.StencilStateEnabled] = true;
22967
+ renderStates[RenderStateElementKey.StencilStatePassOperationFront] = passOperation;
22968
+ renderStates[RenderStateElementKey.StencilStatePassOperationBack] = passOperation;
22969
+ renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = CompareFunction.Always;
22970
+ renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = CompareFunction.Always;
22971
+ var failStencilOperation = StencilOperation.Keep;
22972
+ renderStates[RenderStateElementKey.StencilStateFailOperationFront] = failStencilOperation;
22973
+ renderStates[RenderStateElementKey.StencilStateFailOperationBack] = failStencilOperation;
22974
+ renderStates[RenderStateElementKey.StencilStateZFailOperationFront] = failStencilOperation;
22975
+ renderStates[RenderStateElementKey.StencilStateZFailOperationBack] = failStencilOperation;
22976
+ renderStates[RenderStateElementKey.BlendStateColorWriteMask0] = ColorWriteMask.None;
22977
+ renderStates[RenderStateElementKey.DepthStateEnabled] = false;
22978
+ renderStates[RenderStateElementKey.RasterStateCullMode] = CullMode.Off;
22979
+ return renderStates;
22980
+ };
22981
+ _create_class(BasicResources, [
22982
+ {
22983
+ key: "prefilteredDFGTexture",
22984
+ get: function get() {
22985
+ return this._prefilteredDFGTexture;
22986
+ }
22987
+ }
22988
+ ]);
22989
+ return BasicResources;
22990
+ }();
22991
+ BasicResources._maskReadInsideRenderStates = null;
22992
+ BasicResources._maskReadOutsideRenderStates = null;
22993
+ BasicResources._maskWriteIncrementRenderStates = null;
22994
+ BasicResources._maskWriteDecrementRenderStates = null;
22995
+
22996
+ function _is_native_reflect_construct() {
22997
+ // Since Reflect.construct can't be properly polyfilled, some
22998
+ // implementations (e.g. core-js@2) don't set the correct internal slots.
22999
+ // Those polyfills don't allow us to subclass built-ins, so we need to
23000
+ // use our fallback implementation.
23001
+ try {
23002
+ // If the internal slots aren't set, this throws an error similar to
23003
+ // TypeError: this is not a Boolean object.
23004
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
23005
+ } catch (_) {}
23006
+ return (_is_native_reflect_construct = function() {
23007
+ return !!result;
23008
+ })();
23009
+ }
23010
+
23011
+ function _construct(Parent, args, Class) {
23012
+ if (_is_native_reflect_construct()) _construct = Reflect.construct;
23013
+ else {
23014
+ _construct = function construct(Parent, args, Class) {
23015
+ var a = [null];
23016
+ a.push.apply(a, args);
23017
+ var Constructor = Function.bind.apply(Parent, a);
23018
+ var instance = new Constructor();
23019
+
23020
+ if (Class) _set_prototype_of(instance, Class.prototype);
23021
+
23022
+ return instance;
23023
+ };
23024
+ }
23025
+
23026
+ return _construct.apply(null, arguments);
23027
+ }
23028
+
23029
+ var ComponentCloner = /*#__PURE__*/ function() {
23030
+ function ComponentCloner() {}
23031
+ /**
23032
+ * Clone component.
23033
+ * @param source - Clone source
23034
+ * @param target - Clone target
23035
+ */ ComponentCloner.cloneComponent = function cloneComponent(source, target, srcRoot, targetRoot, deepInstanceMap) {
23036
+ var cloneModes = CloneManager.getCloneMode(source.constructor);
23037
+ for(var k in source){
23038
+ CloneManager.cloneProperty(source, target, k, cloneModes[k], srcRoot, targetRoot, deepInstanceMap);
23039
+ }
23040
+ if (source._cloneTo) {
23041
+ source._cloneTo(target, srcRoot, targetRoot);
23042
+ }
23043
+ };
23044
+ return ComponentCloner;
23045
+ }();
23046
+
23047
+ /**
23048
+ * The entity modify flags.
23049
+ */ var EntityModifyFlags = /*#__PURE__*/ function(EntityModifyFlags) {
23050
+ /** The parent changes. */ EntityModifyFlags[EntityModifyFlags["Parent"] = 1] = "Parent";
23051
+ /** The child changes. */ EntityModifyFlags[EntityModifyFlags["Child"] = 2] = "Child";
23052
+ return EntityModifyFlags;
23053
+ }({});
23054
+
23055
+ /**
23056
+ * Entity, be used as components container.
23057
+ */ var Entity = /*#__PURE__*/ function(EngineObject) {
23058
+ _inherits(Entity, EngineObject);
23059
+ function Entity(engine, name) {
23060
+ for(var _len = arguments.length, components = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
23061
+ components[_key - 2] = arguments[_key];
23062
+ }
23063
+ var _this;
23064
+ _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._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----------------------------------------------------------------
23065
+ _this._invModelMatrix = new Matrix();
23066
+ _this.name = name != null ? name : "Entity";
23067
+ for(var i = 0, n = components.length; i < n; i++){
23068
+ _this.addComponent(components[i]);
23069
+ }
23070
+ !_this._transform && _this.addComponent(Transform);
23071
+ _this._inverseWorldMatFlag = _this.registerWorldChangeFlag();
23072
+ return _this;
23073
+ }
23074
+ var _proto = Entity.prototype;
23075
+ /**
23076
+ * Add component based on the component type.
23077
+ * @param type - The type of the component
23078
+ * @param args - The arguments of the component
23079
+ * @returns The component which has been added
23080
+ */ _proto.addComponent = function addComponent(type) {
23081
+ for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
23082
+ args[_key - 1] = arguments[_key];
23083
+ }
23084
+ ComponentsDependencies._addCheck(this, type);
23085
+ var component = _construct(type, [].concat([
23086
+ this
23087
+ ], args));
23088
+ this._components.push(component);
23089
+ // @todo: temporary solution
23090
+ if (_instanceof(component, Transform)) this._setTransform(component);
23091
+ component._setActive(true, ActiveChangeFlag.All);
23092
+ return component;
23093
+ };
23094
+ /**
23095
+ * Get component which match the type.
23096
+ * @param type - The type of the component
23097
+ * @returns The first component which match type
23098
+ */ _proto.getComponent = function getComponent(type) {
23099
+ var components = this._components;
23100
+ for(var i = 0, n = components.length; i < n; i++){
23101
+ var component = components[i];
23102
+ if (_instanceof(component, type)) {
23103
+ return component;
23104
+ }
23105
+ }
23106
+ return null;
23107
+ };
23108
+ /**
23109
+ * Get components which match the type.
23110
+ * @param type - The type of the component
23111
+ * @param results - The components which match type
23112
+ * @returns The components which match type
23113
+ */ _proto.getComponents = function getComponents(type, results) {
23114
+ results.length = 0;
23115
+ var components = this._components;
23116
+ for(var i = 0, n = components.length; i < n; i++){
23117
+ var component = components[i];
23118
+ if (_instanceof(component, type)) {
23119
+ results.push(component);
22788
23120
  }
22789
23121
  }
22790
- };
22791
- _proto._setTransform = function _setTransform(value) {
22792
- var _this__transform;
22793
- (_this__transform = this._transform) == null ? void 0 : _this__transform.destroy();
22794
- this._transform = value;
23122
+ return results;
23123
+ };
23124
+ /**
23125
+ * Get the components which match the type of the entity and it's children.
23126
+ * @param type - The component type
23127
+ * @param results - The components collection
23128
+ * @returns The components collection which match the type
23129
+ */ _proto.getComponentsIncludeChildren = function getComponentsIncludeChildren(type, results) {
23130
+ results.length = 0;
23131
+ this._getComponentsInChildren(type, results);
23132
+ return results;
23133
+ };
23134
+ _proto.addChild = function addChild(indexOrChild, child) {
23135
+ var index;
23136
+ if (typeof indexOrChild === "number") {
23137
+ index = indexOrChild;
23138
+ } else {
23139
+ index = undefined;
23140
+ child = indexOrChild;
23141
+ }
23142
+ child._setParent(this, index);
23143
+ };
23144
+ /**
23145
+ * Remove child entity.
23146
+ * @param child - The child entity which want to be removed
23147
+ */ _proto.removeChild = function removeChild(child) {
23148
+ if (child._parent !== this) return;
23149
+ child._setParent(null);
23150
+ };
23151
+ /**
23152
+ * @deprecated Please use `children` property instead.
23153
+ * Find child entity by index.
23154
+ * @param index - The index of the child entity
23155
+ * @returns The component which be found
23156
+ */ _proto.getChild = function getChild(index) {
23157
+ return this._children[index];
23158
+ };
23159
+ /**
23160
+ * Find entity by name.
23161
+ * @param name - The name of the entity which want to be found
23162
+ * @returns The component which be found
23163
+ */ _proto.findByName = function findByName(name) {
23164
+ if (name === this.name) {
23165
+ return this;
23166
+ }
22795
23167
  var children = this._children;
22796
23168
  for(var i = 0, n = children.length; i < n; i++){
22797
- var _children_i_transform;
22798
- (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._parentChange();
23169
+ var target = children[i].findByName(name);
23170
+ if (target) {
23171
+ return target;
23172
+ }
22799
23173
  }
23174
+ return null;
22800
23175
  };
22801
23176
  /**
22802
- * @deprecated
22803
- */ _proto.getInvModelMatrix = function getInvModelMatrix() {
22804
- if (this._inverseWorldMatFlag.flag) {
22805
- Matrix.invert(this._transform.worldMatrix, this._invModelMatrix);
22806
- this._inverseWorldMatFlag.flag = false;
23177
+ * Find the entity by path.
23178
+ * @param path - The path of the entity eg: /entity
23179
+ * @returns The component which be found
23180
+ */ _proto.findByPath = function findByPath(path) {
23181
+ var splits = path.split("/").filter(Boolean);
23182
+ if (!splits.length) {
23183
+ return this;
22807
23184
  }
22808
- return this._invModelMatrix;
23185
+ return Entity._findChildByName(this, 0, splits, 0);
22809
23186
  };
22810
23187
  /**
22811
- * @internal
22812
- */ Entity._findChildByName = function _findChildByName(entity, childIndex, paths, pathIndex) {
22813
- var searchPath = paths[pathIndex];
22814
- var isEndPath = pathIndex === paths.length - 1;
22815
- var children = entity._children;
22816
- for(var n = children.length; childIndex < n; childIndex++){
22817
- var child = children[childIndex];
22818
- if (child.name === searchPath) {
22819
- // Search success if end path, or downward search
22820
- return isEndPath ? child : Entity._findChildByName(child, 0, paths, pathIndex + 1);
22821
- }
22822
- }
22823
- // Search failed if first path, or upward search
22824
- return pathIndex === 0 ? null : Entity._findChildByName(entity.parent, entity.siblingIndex + 1, paths, pathIndex - 1);
23188
+ * Create child entity.
23189
+ * @param name - The child entity's name
23190
+ * @returns The child entity
23191
+ */ _proto.createChild = function createChild(name) {
23192
+ var transform = this._transform;
23193
+ var child = transform ? new Entity(this.engine, name, transform.constructor) : new Entity(this.engine, name);
23194
+ child.layer = this.layer;
23195
+ child.parent = this;
23196
+ return child;
22825
23197
  };
22826
23198
  /**
22827
- * @internal
22828
- */ Entity._traverseSetOwnerScene = function _traverseSetOwnerScene(entity, scene) {
22829
- entity._scene = scene;
22830
- var children = entity._children;
23199
+ * Clear children entities.
23200
+ */ _proto.clearChildren = function clearChildren() {
23201
+ var children = this._children;
22831
23202
  for(var i = children.length - 1; i >= 0; i--){
22832
- this._traverseSetOwnerScene(children[i], scene);
23203
+ var child = children[i];
23204
+ child._parent = null;
23205
+ var activeChangeFlag = ActiveChangeFlag.None;
23206
+ child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
23207
+ child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
23208
+ activeChangeFlag && child._processInActive(activeChangeFlag);
23209
+ Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
22833
23210
  }
23211
+ children.length = 0;
22834
23212
  };
22835
23213
  /**
22836
- * @internal
22837
- */ Entity._getEntityHierarchyPath = function _getEntityHierarchyPath(rootEntity, searchEntity, inversePath) {
22838
- inversePath.length = 0;
22839
- while(searchEntity !== rootEntity){
22840
- var parent = searchEntity.parent;
22841
- if (!parent) {
22842
- return false;
22843
- }
22844
- inversePath.push(searchEntity.siblingIndex);
22845
- searchEntity = parent;
22846
- }
22847
- return true;
23214
+ * Clone this entity include children and components.
23215
+ * @returns Cloned entity
23216
+ */ _proto.clone = function clone() {
23217
+ var cloneEntity = this._createCloneEntity();
23218
+ this._parseCloneEntity(this, cloneEntity, this, cloneEntity, new Map());
23219
+ return cloneEntity;
22848
23220
  };
22849
23221
  /**
22850
- * @internal
22851
- */ Entity._getEntityByHierarchyPath = function _getEntityByHierarchyPath(rootEntity, inversePath) {
22852
- var entity = rootEntity;
22853
- for(var i = inversePath.length - 1; i >= 0; i--){
22854
- entity = entity.children[inversePath[i]];
22855
- }
22856
- return entity;
23222
+ * Listen for changes in the world pose of this `Entity`.
23223
+ * @returns Change flag
23224
+ */ _proto.registerWorldChangeFlag = function registerWorldChangeFlag() {
23225
+ return this._updateFlagManager.createFlag(BoolUpdateFlag);
22857
23226
  };
22858
23227
  /**
22859
23228
  * @internal
22860
- */ Entity._removeFromChildren = function _removeFromChildren(children, entity) {
22861
- var count = children.length - 1;
22862
- for(var i = entity._siblingIndex; i < count; i++){
22863
- var child = children[i + 1];
22864
- children[i] = child;
22865
- child._siblingIndex = i;
22866
- }
22867
- children.length = count;
22868
- entity._siblingIndex = -1;
23229
+ */ _proto._markAsTemplate = function _markAsTemplate(templateResource) {
23230
+ this._isTemplate = true;
23231
+ this._templateResource = templateResource;
22869
23232
  };
22870
- /**
22871
- * @internal
22872
- */ Entity._addToChildren = function _addToChildren(children, entity, index) {
22873
- var childCount = children.length;
22874
- children.length = childCount + 1;
22875
- if (index === undefined) {
22876
- children[childCount] = entity;
22877
- entity._siblingIndex = childCount;
22878
- } else {
22879
- if (index < 0 || index > childCount) {
22880
- throw "The index " + index + " is out of child list bounds " + childCount;
22881
- }
22882
- for(var i = childCount; i > index; i--){
22883
- var swapChild = children[i - 1];
22884
- swapChild._siblingIndex = i;
22885
- children[i] = swapChild;
22886
- }
22887
- entity._siblingIndex = index;
22888
- children[index] = entity;
23233
+ _proto._createCloneEntity = function _createCloneEntity() {
23234
+ var componentConstructors = Entity._tempComponentConstructors;
23235
+ var components = this._components;
23236
+ for(var i = 0, n = components.length; i < n; i++){
23237
+ componentConstructors[i] = components[i].constructor;
23238
+ }
23239
+ var cloneEntity = _construct(Entity, [].concat([
23240
+ this.engine,
23241
+ this.name
23242
+ ], componentConstructors));
23243
+ componentConstructors.length = 0;
23244
+ var templateResource = this._templateResource;
23245
+ if (templateResource) {
23246
+ cloneEntity._templateResource = templateResource;
23247
+ templateResource._addReferCount(1);
23248
+ }
23249
+ cloneEntity.layer = this.layer;
23250
+ cloneEntity._isActive = this._isActive;
23251
+ var srcChildren = this._children;
23252
+ for(var i1 = 0, n1 = srcChildren.length; i1 < n1; i1++){
23253
+ cloneEntity.addChild(srcChildren[i1]._createCloneEntity());
22889
23254
  }
23255
+ return cloneEntity;
22890
23256
  };
22891
- _create_class(Entity, [
22892
- {
22893
- key: "transform",
22894
- get: /**
22895
- * The transform of this entity.
22896
- */ function get() {
22897
- return this._transform;
22898
- }
22899
- },
22900
- {
22901
- key: "isActive",
22902
- get: /**
22903
- * Whether to activate locally.
22904
- */ function get() {
22905
- return this._isActive;
22906
- },
22907
- set: function set(value) {
22908
- if (value !== this._isActive) {
22909
- this._isActive = value;
22910
- if (value) {
22911
- var parent = this._parent;
22912
- var activeChangeFlag = ActiveChangeFlag.None;
22913
- if (this._isRoot && this._scene._isActiveInEngine) {
22914
- activeChangeFlag |= ActiveChangeFlag.All;
22915
- } else {
22916
- (parent == null ? void 0 : parent._isActiveInHierarchy) && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
22917
- (parent == null ? void 0 : parent._isActiveInScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
22918
- }
22919
- activeChangeFlag && this._processActive(activeChangeFlag);
22920
- } else {
22921
- var activeChangeFlag1 = ActiveChangeFlag.None;
22922
- this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
22923
- this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
22924
- activeChangeFlag1 && this._processInActive(activeChangeFlag1);
22925
- }
22926
- }
22927
- }
22928
- },
22929
- {
22930
- key: "isActiveInHierarchy",
22931
- get: /**
22932
- * Whether it is active in the hierarchy.
22933
- */ function get() {
22934
- return this._isActiveInHierarchy;
22935
- }
22936
- },
22937
- {
22938
- key: "parent",
22939
- get: /**
22940
- * The parent entity.
22941
- */ function get() {
22942
- return this._parent;
22943
- },
22944
- set: function set(value) {
22945
- this._setParent(value);
22946
- }
22947
- },
22948
- {
22949
- key: "children",
22950
- get: /**
22951
- * The children entities
22952
- */ function get() {
22953
- return this._children;
22954
- }
22955
- },
22956
- {
22957
- key: "childCount",
22958
- get: /**
22959
- * @deprecated Please use `children.length` property instead.
22960
- * Number of the children entities
22961
- */ function get() {
22962
- return this._children.length;
22963
- }
22964
- },
22965
- {
22966
- key: "scene",
22967
- get: /**
22968
- * The scene the entity belongs to.
22969
- */ function get() {
22970
- return this._scene;
22971
- }
22972
- },
22973
- {
22974
- key: "siblingIndex",
22975
- get: /**
22976
- * The sibling index.
22977
- */ function get() {
22978
- return this._siblingIndex;
22979
- },
22980
- set: function set(value) {
22981
- if (this._siblingIndex === -1) {
22982
- throw "The entity " + this.name + " is not in the hierarchy";
22983
- }
22984
- if (this._isRoot) {
22985
- this._setSiblingIndex(this._scene._rootEntities, value);
22986
- } else {
22987
- var parent = this._parent;
22988
- this._setSiblingIndex(parent._children, value);
22989
- parent._dispatchModify(EntityModifyFlags.Child, parent);
22990
- }
22991
- }
23257
+ _proto._parseCloneEntity = function _parseCloneEntity(src, target, srcRoot, targetRoot, deepInstanceMap) {
23258
+ var srcChildren = src._children;
23259
+ var targetChildren = target._children;
23260
+ for(var i = 0, n = srcChildren.length; i < n; i++){
23261
+ this._parseCloneEntity(srcChildren[i], targetChildren[i], srcRoot, targetRoot, deepInstanceMap);
23262
+ }
23263
+ var components = src._components;
23264
+ for(var i1 = 0, n1 = components.length; i1 < n1; i1++){
23265
+ ComponentCloner.cloneComponent(components[i1], target._components[i1], srcRoot, targetRoot, deepInstanceMap);
22992
23266
  }
22993
- ]);
22994
- return Entity;
22995
- }(EngineObject);
22996
- /** @internal */ Entity._tempComponentConstructors = [];
22997
-
22998
- /**
22999
- * Skin used for skinned mesh renderer.
23000
- */ var Skin = /*#__PURE__*/ function(EngineObject) {
23001
- _inherits(Skin, EngineObject);
23002
- function Skin(name) {
23003
- var _this;
23004
- _this = EngineObject.call(this, null) || this, _this.name = name, _this.inverseBindMatrices = new Array(), _this._updatedManager = new UpdateFlagManager(), _this._bones = new Array(), _this._updateMark = -1, _this.joints = [];
23005
- return _this;
23006
- }
23007
- var _proto = Skin.prototype;
23267
+ };
23008
23268
  /**
23009
- * @internal
23010
- */ _proto._updateSkinMatrices = function _updateSkinMatrices(renderer) {
23011
- if (this._updateMark === renderer.engine.time.frameCount) {
23269
+ * Destroy self.
23270
+ */ _proto.destroy = function destroy() {
23271
+ EngineObject.prototype.destroy.call(this);
23272
+ if (!this._destroyed) {
23012
23273
  return;
23013
23274
  }
23014
- var _this = this, bones = _this.bones, bindMatrices = _this.inverseBindMatrices, skinMatrices = _this._skinMatrices;
23015
- var _this_rootBone;
23016
- var worldToLocal = ((_this_rootBone = this.rootBone) != null ? _this_rootBone : renderer.entity).getInvModelMatrix();
23017
- for(var i = bones.length - 1; i >= 0; i--){
23018
- var bone = bones[i];
23019
- var offset = i * 16;
23020
- if (bone) {
23021
- Utils._floatMatrixMultiply(bone.transform.worldMatrix, bindMatrices[i].elements, 0, skinMatrices, offset);
23022
- } else {
23023
- skinMatrices.set(bindMatrices[i].elements, offset);
23024
- }
23025
- Utils._floatMatrixMultiply(worldToLocal, skinMatrices, offset, skinMatrices, offset);
23275
+ if (this._templateResource) {
23276
+ this._isTemplate || this._templateResource._addReferCount(-1);
23277
+ this._templateResource = null;
23026
23278
  }
23027
- this._updateMark = renderer.engine.time.frameCount;
23279
+ var components = this._components;
23280
+ for(var i = components.length - 1; i >= 0; i--){
23281
+ components[i].destroy();
23282
+ }
23283
+ this._components.length = 0;
23284
+ var children = this._children;
23285
+ while(children.length > 0){
23286
+ children[0].destroy();
23287
+ }
23288
+ if (this._isRoot) {
23289
+ this._scene.removeRootEntity(this);
23290
+ } else {
23291
+ this._setParent(null);
23292
+ }
23293
+ this.isActive = false;
23028
23294
  };
23029
23295
  /**
23030
23296
  * @internal
23031
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
23032
- var paths = new Array();
23033
- // Clone rootBone
23034
- var rootBone = this.rootBone;
23035
- if (rootBone) {
23036
- var success = Entity._getEntityHierarchyPath(srcRoot, rootBone, paths);
23037
- target.rootBone = success ? Entity._getEntityByHierarchyPath(targetRoot, paths) : rootBone;
23038
- }
23039
- // Clone bones
23040
- var bones = this.bones;
23041
- if (bones.length > 0) {
23042
- var boneCount = bones.length;
23043
- var destBones = new Array(boneCount);
23044
- for(var i = 0; i < boneCount; i++){
23045
- var bone = bones[i];
23046
- var success1 = Entity._getEntityHierarchyPath(srcRoot, bone, paths);
23047
- destBones[i] = success1 ? Entity._getEntityByHierarchyPath(targetRoot, paths) : bone;
23048
- }
23049
- target.bones = destBones;
23050
- }
23297
+ */ _proto._removeComponent = function _removeComponent(component) {
23298
+ ComponentsDependencies._removeCheck(this, component.constructor);
23299
+ var components = this._components;
23300
+ components.splice(components.indexOf(component), 1);
23051
23301
  };
23052
- _create_class(Skin, [
23053
- {
23054
- key: "rootBone",
23055
- get: /**
23056
- * Root bone.
23057
- */ function get() {
23058
- return this._rootBone;
23059
- },
23060
- set: function set(value) {
23061
- if (this._rootBone !== value) {
23062
- this._updatedManager.dispatch(1, value);
23063
- this._rootBone = value;
23064
- }
23065
- }
23066
- },
23067
- {
23068
- key: "bones",
23069
- get: /**
23070
- * Bones of the skin.
23071
- */ function get() {
23072
- return this._bones;
23073
- },
23074
- set: function set(value) {
23075
- var bones = this._bones;
23076
- var _value_length;
23077
- var boneCount = (_value_length = value == null ? void 0 : value.length) != null ? _value_length : 0;
23078
- var lastBoneCount = bones.length;
23079
- bones.length = boneCount;
23080
- for(var i = 0; i < boneCount; i++){
23081
- bones[i] = value[i];
23082
- }
23083
- if (lastBoneCount !== boneCount) {
23084
- this._skinMatrices = new Float32Array(boneCount * 16);
23085
- this._updatedManager.dispatch(0, boneCount);
23086
- }
23087
- }
23088
- },
23089
- {
23090
- key: "skeleton",
23091
- get: /** @deprecated Please use `rootBone` instead. */ function get() {
23092
- var _this_rootBone;
23093
- return (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.name;
23094
- },
23095
- set: function set(value) {
23096
- var rootBone = this._rootBone;
23097
- if (rootBone) {
23098
- rootBone.name = value;
23099
- }
23100
- }
23101
- }
23102
- ]);
23103
- return Skin;
23104
- }(EngineObject);
23105
- __decorate([
23106
- deepClone
23107
- ], Skin.prototype, "inverseBindMatrices", void 0);
23108
- __decorate([
23109
- ignoreClone
23110
- ], Skin.prototype, "_skinMatrices", void 0);
23111
- __decorate([
23112
- ignoreClone
23113
- ], Skin.prototype, "_updatedManager", void 0);
23114
- __decorate([
23115
- ignoreClone
23116
- ], Skin.prototype, "_rootBone", void 0);
23117
- __decorate([
23118
- ignoreClone
23119
- ], Skin.prototype, "_bones", void 0);
23120
- __decorate([
23121
- ignoreClone
23122
- ], Skin.prototype, "_updateMark", void 0);
23123
- var SkinUpdateFlag = /*#__PURE__*/ function(SkinUpdateFlag) {
23124
- SkinUpdateFlag[SkinUpdateFlag["BoneCountChanged"] = 0] = "BoneCountChanged";
23125
- SkinUpdateFlag[SkinUpdateFlag["RootBoneChanged"] = 1] = "RootBoneChanged";
23126
- return SkinUpdateFlag;
23127
- }({});
23128
-
23129
- /**
23130
- * SkinnedMeshRenderer.
23131
- */ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer) {
23132
- _inherits(SkinnedMeshRenderer, MeshRenderer);
23133
- function SkinnedMeshRenderer(entity) {
23134
- var _this;
23135
- _this = MeshRenderer.call(this, entity) || this, _this._localBounds = new BoundingBox(), _this._jointDataCreateCache = new Vector2(-1, -1);
23136
- _this._skin = null;
23137
- var rhi = _this.entity.engine._hardwareRenderer;
23138
- var maxVertexUniformVectors = rhi.renderStates.getParameter(rhi.gl.MAX_VERTEX_UNIFORM_VECTORS);
23139
- // Limit size to 256 to avoid some problem:
23140
- // For renderer is "Apple GPU", when uniform is large than 256 the skeleton matrix array access in shader very slow in Safari or WKWebview. This may be a apple bug, Chrome and Firefox is OK!
23141
- // For renderer is "ANGLE (AMD, AMD Radeon(TM) Graphics Direct3011 vs_5_0 ps_5_0, D3011)", compile shader si very slow because of max uniform is 4096.
23142
- maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
23143
- _this._maxVertexUniformVectors = maxVertexUniformVectors;
23144
- _this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_this);
23145
- _this._onSkinUpdated = _this._onSkinUpdated.bind(_this);
23146
- var localBounds = _this._localBounds;
23147
- // @ts-ignore
23148
- localBounds.min._onValueChanged = _this._onLocalBoundsChanged;
23149
- // @ts-ignore
23150
- localBounds.max._onValueChanged = _this._onLocalBoundsChanged;
23151
- return _this;
23152
- }
23153
- var _proto = SkinnedMeshRenderer.prototype;
23154
23302
  /**
23155
23303
  * @internal
23156
- */ _proto._onDestroy = function _onDestroy() {
23157
- var _this__jointTexture;
23158
- MeshRenderer.prototype._onDestroy.call(this);
23159
- this._jointDataCreateCache = null;
23160
- this._skin = null;
23161
- this._blendShapeWeights = null;
23162
- this._localBounds = null;
23163
- (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
23164
- this._jointTexture = null;
23304
+ */ _proto._addScript = function _addScript(script) {
23305
+ script._entityScriptsIndex = this._scripts.length;
23306
+ this._scripts.add(script);
23165
23307
  };
23166
23308
  /**
23167
23309
  * @internal
23168
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
23169
- MeshRenderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
23170
- if (this.skin) {
23171
- target._applySkin(null, target.skin);
23172
- }
23173
- this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
23310
+ */ _proto._removeScript = function _removeScript(script) {
23311
+ var replaced = this._scripts.deleteByIndex(script._entityScriptsIndex);
23312
+ replaced && (replaced._entityScriptsIndex = script._entityScriptsIndex);
23313
+ script._entityScriptsIndex = -1;
23174
23314
  };
23175
- _proto._update = function _update(context) {
23176
- var skin = this.skin;
23177
- if ((skin == null ? void 0 : skin.bones.length) > 0) {
23178
- skin._updateSkinMatrices(this);
23315
+ /**
23316
+ * @internal
23317
+ */ _proto._removeFromParent = function _removeFromParent() {
23318
+ var oldParent = this._parent;
23319
+ if (oldParent != null) {
23320
+ Entity._removeFromChildren(oldParent._children, this);
23321
+ this._parent = null;
23322
+ oldParent._dispatchModify(EntityModifyFlags.Child, oldParent);
23179
23323
  }
23180
- var shaderData = this.shaderData;
23181
- var mesh = this.mesh;
23182
- var blendShapeManager = mesh._blendShapeManager;
23183
- blendShapeManager._updateShaderData(shaderData, this);
23184
- var bones = skin == null ? void 0 : skin.bones;
23185
- if (bones) {
23186
- var bsUniformOccupiesCount = blendShapeManager._uniformOccupiesCount;
23187
- var boneCount = bones.length;
23188
- var boneDataCreateCache = this._jointDataCreateCache;
23189
- var boneCountChange = boneCount !== boneDataCreateCache.x;
23190
- if (boneCountChange || bsUniformOccupiesCount !== boneDataCreateCache.y) {
23191
- // directly use max joint count to avoid shader recompile
23192
- var remainUniformJointCount = Math.ceil((this._maxVertexUniformVectors - (SkinnedMeshRenderer._baseVertexUniformVectorCount + bsUniformOccupiesCount)) / 4);
23193
- if (boneCount > remainUniformJointCount) {
23194
- var engine = this.engine;
23195
- if (engine._hardwareRenderer.canIUseMoreJoints) {
23196
- if (boneCountChange) {
23197
- var _this__jointTexture;
23198
- (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
23199
- this._jointTexture = new Texture2D(engine, 4, boneCount, TextureFormat.R32G32B32A32, false, false);
23200
- this._jointTexture.filterMode = TextureFilterMode.Point;
23201
- this._jointTexture.isGCIgnored = true;
23202
- }
23203
- shaderData.disableMacro("RENDERER_JOINTS_NUM");
23204
- shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
23205
- shaderData.setTexture(SkinnedMeshRenderer._jointSamplerProperty, this._jointTexture);
23206
- } else {
23207
- Logger.error("component's joints count(" + boneCount + ") greater than device's MAX_VERTEX_UNIFORM_VECTORS number " + this._maxVertexUniformVectors + ", and don't support jointTexture in this device. suggest joint count less than " + remainUniformJointCount + ".", this);
23208
- }
23209
- } else {
23210
- var _this__jointTexture1;
23211
- (_this__jointTexture1 = this._jointTexture) == null ? void 0 : _this__jointTexture1.destroy();
23212
- shaderData.disableMacro("RENDERER_USE_JOINT_TEXTURE");
23213
- shaderData.enableMacro("RENDERER_JOINTS_NUM", remainUniformJointCount.toString());
23214
- shaderData.setFloatArray(SkinnedMeshRenderer._jointMatrixProperty, skin._skinMatrices);
23215
- }
23216
- boneDataCreateCache.set(boneCount, bsUniformOccupiesCount);
23217
- }
23218
- if (this._jointTexture) {
23219
- this._jointTexture.setPixelBuffer(skin._skinMatrices);
23220
- }
23324
+ };
23325
+ /**
23326
+ * @internal
23327
+ */ _proto._processActive = function _processActive(activeChangeFlag) {
23328
+ if (this._activeChangedComponents) {
23329
+ throw "Note: can't set the 'main inActive entity' active in hierarchy, if the operation is in main inActive entity or it's children script's onDisable Event.";
23221
23330
  }
23222
- MeshRenderer.prototype._update.call(this, context);
23331
+ this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
23332
+ this._setActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
23333
+ this._setActiveComponents(true, activeChangeFlag);
23223
23334
  };
23224
23335
  /**
23225
23336
  * @internal
23226
- */ _proto._updateBounds = function _updateBounds(worldBounds) {
23227
- var _this_skin;
23228
- var rootBone = (_this_skin = this.skin) == null ? void 0 : _this_skin.rootBone;
23229
- if (rootBone) {
23230
- BoundingBox.transform(this._localBounds, this._transformEntity.transform.worldMatrix, worldBounds);
23231
- } else {
23232
- MeshRenderer.prototype._updateBounds.call(this, worldBounds);
23337
+ */ _proto._processInActive = function _processInActive(activeChangeFlag) {
23338
+ if (this._activeChangedComponents) {
23339
+ throw "Note: can't set the 'main active entity' inActive in hierarchy, if the operation is in main active entity or it's children script's onEnable Event.";
23233
23340
  }
23341
+ this._activeChangedComponents = this._scene._componentsManager.getActiveChangedTempList();
23342
+ this._setInActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
23343
+ this._setActiveComponents(false, activeChangeFlag);
23234
23344
  };
23235
- _proto._checkBlendShapeWeightLength = function _checkBlendShapeWeightLength() {
23236
- var mesh = this._mesh;
23237
- var newBlendShapeCount = mesh ? mesh.blendShapeCount : 0;
23238
- var lastBlendShapeWeights = this._blendShapeWeights;
23239
- if (lastBlendShapeWeights) {
23240
- var lastBlendShapeWeightsCount = lastBlendShapeWeights.length;
23241
- if (lastBlendShapeWeightsCount !== newBlendShapeCount) {
23242
- var newBlendShapeWeights = new Float32Array(newBlendShapeCount);
23243
- if (newBlendShapeCount > lastBlendShapeWeightsCount) {
23244
- newBlendShapeWeights.set(lastBlendShapeWeights);
23345
+ /**
23346
+ * @internal
23347
+ */ _proto._setParentChange = function _setParentChange() {
23348
+ this._transform._parentChange();
23349
+ this._dispatchModify(EntityModifyFlags.Parent, this);
23350
+ };
23351
+ /**
23352
+ * @internal
23353
+ */ _proto._registerModifyListener = function _registerModifyListener(onChange) {
23354
+ (this._modifyFlagManager || (this._modifyFlagManager = new UpdateFlagManager())).addListener(onChange);
23355
+ };
23356
+ /**
23357
+ * @internal
23358
+ */ _proto._unRegisterModifyListener = function _unRegisterModifyListener(onChange) {
23359
+ var _this__modifyFlagManager;
23360
+ (_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.removeListener(onChange);
23361
+ };
23362
+ _proto._dispatchModify = function _dispatchModify(flag, param) {
23363
+ var _this__modifyFlagManager;
23364
+ (_this__modifyFlagManager = this._modifyFlagManager) == null ? void 0 : _this__modifyFlagManager.dispatch(flag, param);
23365
+ };
23366
+ _proto._addToChildrenList = function _addToChildrenList(index, child) {
23367
+ Entity._addToChildren(this._children, child, index);
23368
+ this._dispatchModify(EntityModifyFlags.Child, this);
23369
+ };
23370
+ _proto._setParent = function _setParent(parent, siblingIndex) {
23371
+ var oldParent = this._parent;
23372
+ if (parent !== oldParent) {
23373
+ if (this._isRoot) {
23374
+ Entity._removeFromChildren(this._scene._rootEntities, this);
23375
+ this._isRoot = false;
23376
+ } else {
23377
+ this._removeFromParent();
23378
+ }
23379
+ this._parent = parent;
23380
+ if (parent) {
23381
+ this._isRoot = false;
23382
+ parent._addToChildrenList(siblingIndex, this);
23383
+ var oldScene = this._scene;
23384
+ var parentScene = parent._scene;
23385
+ var inActiveChangeFlag = ActiveChangeFlag.None;
23386
+ if (!parent._isActiveInHierarchy) {
23387
+ this._isActiveInHierarchy && (inActiveChangeFlag |= ActiveChangeFlag.Hierarchy);
23388
+ }
23389
+ if (parent._isActiveInScene) {
23390
+ // cross scene should inActive first and then active
23391
+ this._isActiveInScene && oldScene !== parentScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
23245
23392
  } else {
23246
- for(var i = 0; i < newBlendShapeCount; i++){
23247
- newBlendShapeWeights[i] = lastBlendShapeWeights[i];
23393
+ this._isActiveInScene && (inActiveChangeFlag |= ActiveChangeFlag.Scene);
23394
+ }
23395
+ inActiveChangeFlag && this._processInActive(inActiveChangeFlag);
23396
+ if (oldScene !== parentScene) {
23397
+ Entity._traverseSetOwnerScene(this, parentScene);
23398
+ }
23399
+ var activeChangeFlag = ActiveChangeFlag.None;
23400
+ if (this._isActive) {
23401
+ if (parent._isActiveInHierarchy) {
23402
+ !this._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
23403
+ }
23404
+ if (parent._isActiveInScene) {
23405
+ (!this._isActiveInScene || oldScene !== parentScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
23248
23406
  }
23249
23407
  }
23250
- this._blendShapeWeights = newBlendShapeWeights;
23408
+ activeChangeFlag && this._processActive(activeChangeFlag);
23409
+ } else {
23410
+ var inActiveChangeFlag1 = ActiveChangeFlag.None;
23411
+ this._isActiveInHierarchy && (inActiveChangeFlag1 |= ActiveChangeFlag.Hierarchy);
23412
+ this._isActiveInScene && (inActiveChangeFlag1 |= ActiveChangeFlag.Scene);
23413
+ inActiveChangeFlag1 && this._processInActive(inActiveChangeFlag1);
23414
+ if (oldParent) {
23415
+ Entity._traverseSetOwnerScene(this, null);
23416
+ }
23251
23417
  }
23418
+ this._setParentChange();
23252
23419
  } else {
23253
- this._blendShapeWeights = new Float32Array(newBlendShapeCount);
23420
+ if (parent && siblingIndex !== undefined) {
23421
+ this.siblingIndex = siblingIndex;
23422
+ }
23254
23423
  }
23255
23424
  };
23256
- _proto._onLocalBoundsChanged = function _onLocalBoundsChanged() {
23257
- this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
23425
+ _proto._getComponentsInChildren = function _getComponentsInChildren(type, results) {
23426
+ for(var i = this._components.length - 1; i >= 0; i--){
23427
+ var component = this._components[i];
23428
+ if (_instanceof(component, type)) {
23429
+ results.push(component);
23430
+ }
23431
+ }
23432
+ for(var i1 = this._children.length - 1; i1 >= 0; i1--){
23433
+ this._children[i1]._getComponentsInChildren(type, results);
23434
+ }
23258
23435
  };
23259
- _proto._onSkinUpdated = function _onSkinUpdated(type, value) {
23260
- switch(type){
23261
- case SkinUpdateFlag.BoneCountChanged:
23262
- var shaderData = this.shaderData;
23263
- if (value > 0) {
23264
- shaderData.enableMacro("RENDERER_HAS_SKIN");
23265
- shaderData.setInt(SkinnedMeshRenderer._jointCountProperty, value);
23266
- } else {
23267
- shaderData.disableMacro("RENDERER_HAS_SKIN");
23268
- }
23269
- break;
23270
- case SkinUpdateFlag.RootBoneChanged:
23271
- this._setTransformEntity(value);
23272
- this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
23273
- break;
23436
+ _proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
23437
+ var activeChangedComponents = this._activeChangedComponents;
23438
+ for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
23439
+ activeChangedComponents[i]._setActive(isActive, activeChangeFlag);
23274
23440
  }
23441
+ this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
23442
+ this._activeChangedComponents = null;
23275
23443
  };
23276
- _proto._applySkin = function _applySkin(lastSkin, value) {
23277
- var _lastSkin_bones, _value_bones;
23278
- var _lastSkin_bones_length;
23279
- var lastSkinBoneCount = (_lastSkin_bones_length = lastSkin == null ? void 0 : (_lastSkin_bones = lastSkin.bones) == null ? void 0 : _lastSkin_bones.length) != null ? _lastSkin_bones_length : 0;
23280
- var _lastSkin_rootBone;
23281
- var lastRootBone = (_lastSkin_rootBone = lastSkin == null ? void 0 : lastSkin.rootBone) != null ? _lastSkin_rootBone : this.entity;
23282
- lastSkin == null ? void 0 : lastSkin._updatedManager.removeListener(this._onSkinUpdated);
23283
- var _value_bones_length;
23284
- var skinBoneCount = (_value_bones_length = value == null ? void 0 : (_value_bones = value.bones) == null ? void 0 : _value_bones.length) != null ? _value_bones_length : 0;
23285
- var _value_rootBone;
23286
- var rootBone = (_value_rootBone = value == null ? void 0 : value.rootBone) != null ? _value_rootBone : this.entity;
23287
- value == null ? void 0 : value._updatedManager.addListener(this._onSkinUpdated);
23288
- if (lastSkinBoneCount !== skinBoneCount) {
23289
- this._onSkinUpdated(SkinUpdateFlag.BoneCountChanged, skinBoneCount);
23444
+ _proto._setActiveInHierarchy = function _setActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
23445
+ activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = true);
23446
+ activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = true);
23447
+ var components = this._components;
23448
+ for(var i = 0, n = components.length; i < n; i++){
23449
+ var component = components[i];
23450
+ (component.enabled || !component._awoken) && activeChangedComponents.push(component);
23290
23451
  }
23291
- if (lastRootBone !== rootBone) {
23292
- this._onSkinUpdated(SkinUpdateFlag.RootBoneChanged, rootBone);
23452
+ var children = this._children;
23453
+ for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
23454
+ var child = children[i1];
23455
+ child.isActive && child._setActiveInHierarchy(activeChangedComponents, activeChangeFlag);
23293
23456
  }
23294
23457
  };
23295
- _create_class(SkinnedMeshRenderer, [
23296
- {
23297
- key: "skin",
23298
- get: /**
23299
- * Skin of the SkinnedMeshRenderer.
23300
- */ function get() {
23301
- return this._skin;
23302
- },
23303
- set: function set(value) {
23304
- var lastSkin = this._skin;
23305
- if (lastSkin !== value) {
23306
- this._applySkin(lastSkin, value);
23307
- this._skin = value;
23308
- }
23309
- }
23310
- },
23311
- {
23312
- key: "blendShapeWeights",
23313
- get: /**
23314
- * The weights of the BlendShapes.
23315
- * @remarks Array index is BlendShape index.
23316
- */ function get() {
23317
- this._checkBlendShapeWeightLength();
23318
- return this._blendShapeWeights;
23319
- },
23320
- set: function set(value) {
23321
- this._checkBlendShapeWeightLength();
23322
- var blendShapeWeights = this._blendShapeWeights;
23323
- if (value.length <= blendShapeWeights.length) {
23324
- blendShapeWeights.set(value);
23325
- } else {
23326
- for(var i = 0, n = blendShapeWeights.length; i < n; i++){
23327
- blendShapeWeights[i] = value[i];
23328
- }
23329
- }
23330
- }
23331
- },
23332
- {
23333
- key: "localBounds",
23334
- get: /**
23335
- * Local bounds.
23336
- */ function get() {
23337
- return this._localBounds;
23338
- },
23339
- set: function set(value) {
23340
- if (this._localBounds !== value) {
23341
- this._localBounds.copyFrom(value);
23342
- }
23343
- }
23344
- },
23345
- {
23346
- key: "rootBone",
23347
- get: /**
23348
- * @deprecated use {@link SkinnedMeshRenderer.skin.rootBone} instead.
23349
- */ function get() {
23350
- return this.skin.rootBone;
23351
- },
23352
- set: function set(value) {
23353
- this.skin.rootBone = value;
23354
- }
23355
- },
23356
- {
23357
- key: "bones",
23358
- get: /**
23359
- * @deprecated use {@link SkinnedMeshRenderer.skin.bones} instead.
23360
- */ function get() {
23361
- return this.skin.bones;
23362
- },
23363
- set: function set(value) {
23364
- this.skin.bones = value;
23458
+ _proto._setInActiveInHierarchy = function _setInActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
23459
+ activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = false);
23460
+ activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = false);
23461
+ var components = this._components;
23462
+ for(var i = 0, n = components.length; i < n; i++){
23463
+ var component = components[i];
23464
+ component.enabled && activeChangedComponents.push(component);
23465
+ }
23466
+ var children = this._children;
23467
+ for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
23468
+ var child = children[i1];
23469
+ child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
23470
+ }
23471
+ };
23472
+ _proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
23473
+ target = Math.min(target, sibling.length - 1);
23474
+ if (target < 0) {
23475
+ throw "Sibling index " + target + " should large than 0";
23476
+ }
23477
+ if (this._siblingIndex !== target) {
23478
+ var oldIndex = this._siblingIndex;
23479
+ if (target < oldIndex) {
23480
+ for(var i = oldIndex; i >= target; i--){
23481
+ var child = i == target ? this : sibling[i - 1];
23482
+ sibling[i] = child;
23483
+ child._siblingIndex = i;
23484
+ }
23485
+ } else {
23486
+ for(var i1 = oldIndex; i1 <= target; i1++){
23487
+ var child1 = i1 == target ? this : sibling[i1 + 1];
23488
+ sibling[i1] = child1;
23489
+ child1._siblingIndex = i1;
23490
+ }
23365
23491
  }
23366
23492
  }
23367
- ]);
23368
- return SkinnedMeshRenderer;
23369
- }(MeshRenderer);
23370
- // @TODO: different shader type should use different count, not always 48
23371
- /** @internal */ SkinnedMeshRenderer._baseVertexUniformVectorCount = 48;
23372
- SkinnedMeshRenderer._jointCountProperty = ShaderProperty.getByName("renderer_JointCount");
23373
- SkinnedMeshRenderer._jointSamplerProperty = ShaderProperty.getByName("renderer_JointSampler");
23374
- SkinnedMeshRenderer._jointMatrixProperty = ShaderProperty.getByName("renderer_JointMatrix");
23375
- __decorate([
23376
- ignoreClone
23377
- ], SkinnedMeshRenderer.prototype, "_condensedBlendShapeWeights", void 0);
23378
- __decorate([
23379
- deepClone
23380
- ], SkinnedMeshRenderer.prototype, "_localBounds", void 0);
23381
- __decorate([
23382
- ignoreClone
23383
- ], SkinnedMeshRenderer.prototype, "_jointDataCreateCache", void 0);
23384
- __decorate([
23385
- ignoreClone
23386
- ], SkinnedMeshRenderer.prototype, "_blendShapeWeights", void 0);
23387
- __decorate([
23388
- ignoreClone
23389
- ], SkinnedMeshRenderer.prototype, "_maxVertexUniformVectors", void 0);
23390
- __decorate([
23391
- ignoreClone
23392
- ], SkinnedMeshRenderer.prototype, "_jointTexture", void 0);
23393
- __decorate([
23394
- deepClone
23395
- ], SkinnedMeshRenderer.prototype, "_skin", void 0);
23396
- __decorate([
23397
- ignoreClone
23398
- ], SkinnedMeshRenderer.prototype, "_onLocalBoundsChanged", null);
23399
- __decorate([
23400
- ignoreClone
23401
- ], SkinnedMeshRenderer.prototype, "_onSkinUpdated", null);
23402
-
23403
- /**
23404
- * @internal
23405
- */ var BasicResources = /*#__PURE__*/ function() {
23406
- function BasicResources(engine) {
23407
- this.engine = engine;
23408
- // prettier-ignore
23409
- var vertices = new Float32Array([
23410
- -1,
23411
- -1,
23412
- 0,
23413
- 1,
23414
- 3,
23415
- -1,
23416
- 2,
23417
- 1,
23418
- -1,
23419
- 3,
23420
- 0,
23421
- -1
23422
- ]); // left-top
23423
- // prettier-ignore
23424
- var flipYVertices = new Float32Array([
23425
- 3,
23426
- -1,
23427
- 2,
23428
- 0,
23429
- -1,
23430
- -1,
23431
- 0,
23432
- 0,
23433
- -1,
23434
- 3,
23435
- 0,
23436
- 2
23437
- ]); // left-top
23438
- var blitMaterial = new Material(engine, Shader.find("blit"));
23439
- blitMaterial._addReferCount(1);
23440
- blitMaterial.renderState.depthState.enabled = false;
23441
- blitMaterial.renderState.depthState.writeEnabled = false;
23442
- var blitScreenMaterial = new Material(engine, Shader.find("blit-screen"));
23443
- blitScreenMaterial._addReferCount(1);
23444
- blitScreenMaterial.renderState.depthState.enabled = false;
23445
- blitScreenMaterial.renderState.depthState.writeEnabled = false;
23446
- this.blitMaterial = blitMaterial;
23447
- this.blitScreenMaterial = blitScreenMaterial;
23448
- this.blitMesh = this._createBlitMesh(engine, vertices);
23449
- this.flipYBlitMesh = this._createBlitMesh(engine, flipYVertices);
23450
- // Create white and magenta textures
23451
- var whitePixel = new Uint8Array([
23452
- 255,
23453
- 255,
23454
- 255,
23455
- 255
23456
- ]);
23457
- this.whiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R8G8B8A8, whitePixel, true);
23458
- this.whiteTextureCube = this._create1x1Texture(engine, 1, TextureFormat.R8G8B8A8, whitePixel, true);
23459
- var isWebGL2 = engine._hardwareRenderer.isWebGL2;
23460
- if (isWebGL2) {
23461
- this.whiteTexture2DArray = this._create1x1Texture(engine, 2, TextureFormat.R8G8B8A8, whitePixel, true);
23462
- var whitePixel32 = new Uint32Array([
23463
- 255,
23464
- 255,
23465
- 255,
23466
- 255
23467
- ]);
23468
- this.uintWhiteTexture2D = this._create1x1Texture(engine, 0, TextureFormat.R32G32B32A32_UInt, whitePixel32, false);
23493
+ };
23494
+ _proto._setTransform = function _setTransform(value) {
23495
+ var _this__transform;
23496
+ (_this__transform = this._transform) == null ? void 0 : _this__transform.destroy();
23497
+ this._transform = value;
23498
+ var children = this._children;
23499
+ for(var i = 0, n = children.length; i < n; i++){
23500
+ var _children_i_transform;
23501
+ (_children_i_transform = children[i].transform) == null ? void 0 : _children_i_transform._parentChange();
23469
23502
  }
23470
- this.spriteDefaultMaterial = this._create2DMaterial(engine, Shader.find("Sprite"));
23471
- this.textDefaultMaterial = this._create2DMaterial(engine, Shader.find("Text"));
23472
- this.spriteMaskDefaultMaterial = this._createSpriteMaskMaterial(engine);
23473
- this.meshMagentaMaterial = this._createMagentaMaterial(engine, "unlit");
23474
- this.particleMagentaMaterial = this._createMagentaMaterial(engine, "particle-shader");
23475
- }
23476
- var _proto = BasicResources.prototype;
23503
+ };
23477
23504
  /**
23478
- * @internal
23479
- */ _proto._getBlinnPhongMaterial = function _getBlinnPhongMaterial() {
23480
- return this._blinnPhongMaterial || (this._blinnPhongMaterial = new BlinnPhongMaterial(this.engine));
23505
+ * @deprecated
23506
+ */ _proto.getInvModelMatrix = function getInvModelMatrix() {
23507
+ if (this._inverseWorldMatFlag.flag) {
23508
+ Matrix.invert(this._transform.worldMatrix, this._invModelMatrix);
23509
+ this._inverseWorldMatFlag.flag = false;
23510
+ }
23511
+ return this._invModelMatrix;
23481
23512
  };
23482
23513
  /**
23483
23514
  * @internal
23484
- */ _proto._initialize = function _initialize() {
23485
- var _this = this;
23486
- return new Promise(function(resolve, reject) {
23487
- PrefilteredDFG.create(_this.engine).then(function(texture) {
23488
- _this._prefilteredDFGTexture = texture;
23489
- resolve(_this);
23490
- }).catch(reject);
23491
- });
23492
- };
23493
- _proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
23494
- var mesh = new ModelMesh(engine);
23495
- mesh._addReferCount(1);
23496
- mesh.setVertexElements([
23497
- new VertexElement("POSITION_UV", 0, VertexElementFormat.Vector4, 0)
23498
- ]);
23499
- var buffer = new Buffer(engine, BufferBindFlag.VertexBuffer, vertices, BufferUsage.Static, true);
23500
- mesh.setVertexBufferBinding(buffer, 16);
23501
- mesh.addSubMesh(0, 3, MeshTopology.Triangles);
23502
- engine.resourceManager.addContentRestorer(new (/*#__PURE__*/ function(ContentRestorer) {
23503
- _inherits(_class, ContentRestorer);
23504
- function _class() {
23505
- return ContentRestorer.call(this, mesh) || this;
23515
+ */ Entity._findChildByName = function _findChildByName(entity, childIndex, paths, pathIndex) {
23516
+ var searchPath = paths[pathIndex];
23517
+ var isEndPath = pathIndex === paths.length - 1;
23518
+ var children = entity._children;
23519
+ for(var n = children.length; childIndex < n; childIndex++){
23520
+ var child = children[childIndex];
23521
+ if (child.name === searchPath) {
23522
+ // Search success if end path, or downward search
23523
+ return isEndPath ? child : Entity._findChildByName(child, 0, paths, pathIndex + 1);
23506
23524
  }
23507
- var _proto = _class.prototype;
23508
- _proto.restoreContent = function restoreContent() {
23509
- buffer.setData(buffer.data);
23510
- };
23511
- return _class;
23512
- }(ContentRestorer))());
23513
- return mesh;
23514
- };
23515
- _proto._create1x1Texture = function _create1x1Texture(engine, type, format, pixel, isSRGBColorSpace) {
23516
- var texture;
23517
- switch(type){
23518
- case 0:
23519
- var texture2D = new Texture2D(engine, 1, 1, format, false, isSRGBColorSpace);
23520
- texture2D.setPixelBuffer(pixel);
23521
- texture = texture2D;
23522
- break;
23523
- case 2:
23524
- var texture2DArray = new Texture2DArray(engine, 1, 1, 1, format, false, isSRGBColorSpace);
23525
- texture2DArray.setPixelBuffer(0, pixel);
23526
- texture = texture2DArray;
23527
- break;
23528
- case 1:
23529
- var textureCube = new TextureCube(engine, 1, format, false, isSRGBColorSpace);
23530
- for(var i = 0; i < 6; i++){
23531
- textureCube.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
23532
- }
23533
- texture = textureCube;
23534
- break;
23535
- default:
23536
- throw "Invalid texture type";
23537
23525
  }
23538
- texture.isGCIgnored = true;
23539
- engine.resourceManager.addContentRestorer(new (/*#__PURE__*/ function(ContentRestorer) {
23540
- _inherits(_class, ContentRestorer);
23541
- function _class() {
23542
- return ContentRestorer.call(this, texture) || this;
23543
- }
23544
- var _proto = _class.prototype;
23545
- _proto.restoreContent = function restoreContent() {
23546
- switch(type){
23547
- case 0:
23548
- this.resource.setPixelBuffer(pixel);
23549
- break;
23550
- case 2:
23551
- this.resource.setPixelBuffer(0, pixel);
23552
- break;
23553
- case 1:
23554
- for(var i = 0; i < 6; i++){
23555
- this.resource.setPixelBuffer(TextureCubeFace.PositiveX + i, pixel);
23556
- }
23557
- break;
23558
- }
23559
- };
23560
- return _class;
23561
- }(ContentRestorer))());
23562
- return texture;
23563
- };
23564
- _proto._create2DMaterial = function _create2DMaterial(engine, shader) {
23565
- var material = new Material(engine, shader);
23566
- var renderState = material.renderState;
23567
- var target = renderState.blendState.targetBlendState;
23568
- target.enabled = true;
23569
- target.sourceColorBlendFactor = BlendFactor.SourceAlpha;
23570
- target.destinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
23571
- target.sourceAlphaBlendFactor = BlendFactor.One;
23572
- target.destinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
23573
- target.colorBlendOperation = target.alphaBlendOperation = BlendOperation.Add;
23574
- renderState.depthState.writeEnabled = false;
23575
- renderState.rasterState.cullMode = CullMode.Off;
23576
- renderState.renderQueueType = RenderQueueType.Transparent;
23577
- material.isGCIgnored = true;
23578
- return material;
23526
+ // Search failed if first path, or upward search
23527
+ return pathIndex === 0 ? null : Entity._findChildByName(entity.parent, entity.siblingIndex + 1, paths, pathIndex - 1);
23579
23528
  };
23580
- _proto._createMagentaMaterial = function _createMagentaMaterial(engine, shaderName) {
23581
- var material = new Material(engine, Shader.find(shaderName));
23582
- material.isGCIgnored = true;
23583
- material.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
23584
- return material;
23529
+ /**
23530
+ * @internal
23531
+ */ Entity._traverseSetOwnerScene = function _traverseSetOwnerScene(entity, scene) {
23532
+ entity._scene = scene;
23533
+ var children = entity._children;
23534
+ for(var i = children.length - 1; i >= 0; i--){
23535
+ this._traverseSetOwnerScene(children[i], scene);
23536
+ }
23585
23537
  };
23586
- _proto._createSpriteMaskMaterial = function _createSpriteMaskMaterial(engine) {
23587
- var material = new Material(engine, Shader.find("SpriteMask"));
23588
- material.isGCIgnored = true;
23589
- return material;
23538
+ /**
23539
+ * @internal
23540
+ */ Entity._removeFromChildren = function _removeFromChildren(children, entity) {
23541
+ var count = children.length - 1;
23542
+ for(var i = entity._siblingIndex; i < count; i++){
23543
+ var child = children[i + 1];
23544
+ children[i] = child;
23545
+ child._siblingIndex = i;
23546
+ }
23547
+ children.length = count;
23548
+ entity._siblingIndex = -1;
23590
23549
  };
23591
- BasicResources.getMaskInteractionRenderStates = function getMaskInteractionRenderStates(maskInteraction) {
23592
- var visibleInsideMask = maskInteraction === SpriteMaskInteraction.VisibleInsideMask;
23593
- var renderStates;
23594
- var compareFunction;
23595
- if (visibleInsideMask) {
23596
- renderStates = BasicResources._maskReadInsideRenderStates;
23597
- if (renderStates) {
23598
- return renderStates;
23599
- }
23600
- BasicResources._maskReadInsideRenderStates = renderStates = {};
23601
- compareFunction = CompareFunction.LessEqual;
23550
+ /**
23551
+ * @internal
23552
+ */ Entity._addToChildren = function _addToChildren(children, entity, index) {
23553
+ var childCount = children.length;
23554
+ children.length = childCount + 1;
23555
+ if (index === undefined) {
23556
+ children[childCount] = entity;
23557
+ entity._siblingIndex = childCount;
23602
23558
  } else {
23603
- renderStates = BasicResources._maskReadOutsideRenderStates;
23604
- if (renderStates) {
23605
- return renderStates;
23559
+ if (index < 0 || index > childCount) {
23560
+ throw "The index " + index + " is out of child list bounds " + childCount;
23606
23561
  }
23607
- BasicResources._maskReadOutsideRenderStates = renderStates = {};
23608
- compareFunction = CompareFunction.Greater;
23562
+ for(var i = childCount; i > index; i--){
23563
+ var swapChild = children[i - 1];
23564
+ swapChild._siblingIndex = i;
23565
+ children[i] = swapChild;
23566
+ }
23567
+ entity._siblingIndex = index;
23568
+ children[index] = entity;
23609
23569
  }
23610
- renderStates[RenderStateElementKey.StencilStateEnabled] = true;
23611
- renderStates[RenderStateElementKey.StencilStateWriteMask] = 0x00;
23612
- renderStates[RenderStateElementKey.StencilStateReferenceValue] = 1;
23613
- renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = compareFunction;
23614
- renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = compareFunction;
23615
- return renderStates;
23616
23570
  };
23617
- BasicResources.getMaskTypeRenderStates = function getMaskTypeRenderStates(maskType) {
23618
- var isIncrement = maskType === RenderQueueMaskType.Increment;
23619
- var renderStates;
23620
- var passOperation;
23621
- if (isIncrement) {
23622
- renderStates = BasicResources._maskWriteIncrementRenderStates;
23623
- if (renderStates) {
23624
- return renderStates;
23571
+ _create_class(Entity, [
23572
+ {
23573
+ key: "transform",
23574
+ get: /**
23575
+ * The transform of this entity.
23576
+ */ function get() {
23577
+ return this._transform;
23625
23578
  }
23626
- BasicResources._maskWriteIncrementRenderStates = renderStates = {};
23627
- passOperation = StencilOperation.IncrementSaturate;
23628
- } else {
23629
- renderStates = BasicResources._maskWriteDecrementRenderStates;
23630
- if (renderStates) {
23631
- return renderStates;
23579
+ },
23580
+ {
23581
+ key: "isActive",
23582
+ get: /**
23583
+ * Whether to activate locally.
23584
+ */ function get() {
23585
+ return this._isActive;
23586
+ },
23587
+ set: function set(value) {
23588
+ if (value !== this._isActive) {
23589
+ this._isActive = value;
23590
+ if (value) {
23591
+ var parent = this._parent;
23592
+ var activeChangeFlag = ActiveChangeFlag.None;
23593
+ if (this._isRoot && this._scene._isActiveInEngine) {
23594
+ activeChangeFlag |= ActiveChangeFlag.All;
23595
+ } else {
23596
+ (parent == null ? void 0 : parent._isActiveInHierarchy) && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
23597
+ (parent == null ? void 0 : parent._isActiveInScene) && (activeChangeFlag |= ActiveChangeFlag.Scene);
23598
+ }
23599
+ activeChangeFlag && this._processActive(activeChangeFlag);
23600
+ } else {
23601
+ var activeChangeFlag1 = ActiveChangeFlag.None;
23602
+ this._isActiveInHierarchy && (activeChangeFlag1 |= ActiveChangeFlag.Hierarchy);
23603
+ this._isActiveInScene && (activeChangeFlag1 |= ActiveChangeFlag.Scene);
23604
+ activeChangeFlag1 && this._processInActive(activeChangeFlag1);
23605
+ }
23606
+ }
23632
23607
  }
23633
- BasicResources._maskWriteDecrementRenderStates = renderStates = {};
23634
- passOperation = StencilOperation.DecrementSaturate;
23635
- }
23636
- renderStates[RenderStateElementKey.StencilStateEnabled] = true;
23637
- renderStates[RenderStateElementKey.StencilStatePassOperationFront] = passOperation;
23638
- renderStates[RenderStateElementKey.StencilStatePassOperationBack] = passOperation;
23639
- renderStates[RenderStateElementKey.StencilStateCompareFunctionFront] = CompareFunction.Always;
23640
- renderStates[RenderStateElementKey.StencilStateCompareFunctionBack] = CompareFunction.Always;
23641
- var failStencilOperation = StencilOperation.Keep;
23642
- renderStates[RenderStateElementKey.StencilStateFailOperationFront] = failStencilOperation;
23643
- renderStates[RenderStateElementKey.StencilStateFailOperationBack] = failStencilOperation;
23644
- renderStates[RenderStateElementKey.StencilStateZFailOperationFront] = failStencilOperation;
23645
- renderStates[RenderStateElementKey.StencilStateZFailOperationBack] = failStencilOperation;
23646
- renderStates[RenderStateElementKey.BlendStateColorWriteMask0] = ColorWriteMask.None;
23647
- renderStates[RenderStateElementKey.DepthStateEnabled] = false;
23648
- renderStates[RenderStateElementKey.RasterStateCullMode] = CullMode.Off;
23649
- return renderStates;
23650
- };
23651
- _create_class(BasicResources, [
23608
+ },
23652
23609
  {
23653
- key: "prefilteredDFGTexture",
23654
- get: function get() {
23655
- return this._prefilteredDFGTexture;
23610
+ key: "isActiveInHierarchy",
23611
+ get: /**
23612
+ * Whether it is active in the hierarchy.
23613
+ */ function get() {
23614
+ return this._isActiveInHierarchy;
23615
+ }
23616
+ },
23617
+ {
23618
+ key: "parent",
23619
+ get: /**
23620
+ * The parent entity.
23621
+ */ function get() {
23622
+ return this._parent;
23623
+ },
23624
+ set: function set(value) {
23625
+ this._setParent(value);
23626
+ }
23627
+ },
23628
+ {
23629
+ key: "children",
23630
+ get: /**
23631
+ * The children entities
23632
+ */ function get() {
23633
+ return this._children;
23634
+ }
23635
+ },
23636
+ {
23637
+ key: "childCount",
23638
+ get: /**
23639
+ * @deprecated Please use `children.length` property instead.
23640
+ * Number of the children entities
23641
+ */ function get() {
23642
+ return this._children.length;
23643
+ }
23644
+ },
23645
+ {
23646
+ key: "scene",
23647
+ get: /**
23648
+ * The scene the entity belongs to.
23649
+ */ function get() {
23650
+ return this._scene;
23651
+ }
23652
+ },
23653
+ {
23654
+ key: "siblingIndex",
23655
+ get: /**
23656
+ * The sibling index.
23657
+ */ function get() {
23658
+ return this._siblingIndex;
23659
+ },
23660
+ set: function set(value) {
23661
+ if (this._siblingIndex === -1) {
23662
+ throw "The entity " + this.name + " is not in the hierarchy";
23663
+ }
23664
+ if (this._isRoot) {
23665
+ this._setSiblingIndex(this._scene._rootEntities, value);
23666
+ } else {
23667
+ var parent = this._parent;
23668
+ this._setSiblingIndex(parent._children, value);
23669
+ parent._dispatchModify(EntityModifyFlags.Child, parent);
23670
+ }
23656
23671
  }
23657
23672
  }
23658
23673
  ]);
23659
- return BasicResources;
23660
- }();
23661
- BasicResources._maskReadInsideRenderStates = null;
23662
- BasicResources._maskReadOutsideRenderStates = null;
23663
- BasicResources._maskWriteIncrementRenderStates = null;
23664
- BasicResources._maskWriteDecrementRenderStates = null;
23674
+ return Entity;
23675
+ }(EngineObject);
23676
+ /** @internal */ Entity._tempComponentConstructors = [];
23665
23677
 
23666
23678
  var ObjectPool = /*#__PURE__*/ function() {
23667
23679
  function ObjectPool(type) {
@@ -29026,6 +29038,184 @@ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
29026
29038
  return PointerMethods;
29027
29039
  }({});
29028
29040
 
29041
+ /**
29042
+ * Signal is a typed event mechanism for Galacean Engine.
29043
+ * @typeParam T - Tuple type of the signal arguments
29044
+ */ var Signal = /*#__PURE__*/ function() {
29045
+ function Signal() {
29046
+ this._listeners = new SafeLoopArray();
29047
+ }
29048
+ var _proto = Signal.prototype;
29049
+ _proto.on = function on(fnOrTarget, targetOrMethodName) {
29050
+ for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
29051
+ args[_key - 2] = arguments[_key];
29052
+ }
29053
+ this._addListener.apply(this, [].concat([
29054
+ fnOrTarget,
29055
+ targetOrMethodName,
29056
+ false
29057
+ ], args));
29058
+ };
29059
+ _proto.once = function once(fnOrTarget, targetOrMethodName) {
29060
+ for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
29061
+ args[_key - 2] = arguments[_key];
29062
+ }
29063
+ this._addListener.apply(this, [].concat([
29064
+ fnOrTarget,
29065
+ targetOrMethodName,
29066
+ true
29067
+ ], args));
29068
+ };
29069
+ _proto.off = function off(fnOrTarget, targetOrMethodName) {
29070
+ if (typeof fnOrTarget === "function") {
29071
+ var target = targetOrMethodName != null ? targetOrMethodName : null;
29072
+ this._listeners.findAndRemove(function(listener) {
29073
+ if (listener.fn === fnOrTarget && listener.target === target) {
29074
+ listener.destroyed = true;
29075
+ return true;
29076
+ }
29077
+ return false;
29078
+ });
29079
+ } else {
29080
+ var target1 = fnOrTarget;
29081
+ var methodName = targetOrMethodName;
29082
+ this._listeners.findAndRemove(function(listener) {
29083
+ if (listener.target === target1 && listener.methodName === methodName) {
29084
+ listener.destroyed = true;
29085
+ return true;
29086
+ }
29087
+ return false;
29088
+ });
29089
+ }
29090
+ };
29091
+ /**
29092
+ * Remove all listeners, or all listeners for a specific target.
29093
+ * @param target - If provided, only remove listeners bound to this target
29094
+ */ _proto.removeAll = function removeAll(target) {
29095
+ if (target !== undefined) {
29096
+ this._listeners.findAndRemove(function(listener) {
29097
+ if (listener.target === target) {
29098
+ return listener.destroyed = true;
29099
+ }
29100
+ return false;
29101
+ });
29102
+ } else {
29103
+ this._listeners.findAndRemove(function(listener) {
29104
+ return listener.destroyed = true;
29105
+ });
29106
+ }
29107
+ };
29108
+ /**
29109
+ * Invoke the signal, calling all listeners in order.
29110
+ * @param args - Arguments to pass to each listener
29111
+ */ _proto.invoke = function invoke() {
29112
+ var _this, _loop = function(i, n) {
29113
+ var listener = listeners[i];
29114
+ if (listener.destroyed) return "continue";
29115
+ if (listener.methodName && listener.target.destroyed) {
29116
+ listener.destroyed = true;
29117
+ _this._listeners.findAndRemove(function(l) {
29118
+ return l === listener;
29119
+ });
29120
+ return "continue";
29121
+ }
29122
+ listener.fn.apply(listener.target, args);
29123
+ if (listener.once) {
29124
+ listener.destroyed = true;
29125
+ _this._listeners.findAndRemove(function(l) {
29126
+ return l === listener;
29127
+ });
29128
+ }
29129
+ };
29130
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
29131
+ args[_key] = arguments[_key];
29132
+ }
29133
+ var listeners = this._listeners.getLoopArray();
29134
+ for(var i = 0, n = listeners.length; i < n; i++)_this = this, _loop(i);
29135
+ };
29136
+ /**
29137
+ * @internal
29138
+ * Clone listeners to target signal, remapping entity/component references.
29139
+ */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
29140
+ var listeners = this._listeners.getLoopArray();
29141
+ for(var i = 0, n = listeners.length; i < n; i++){
29142
+ var listener = listeners[i];
29143
+ if (listener.destroyed || !listener.methodName) continue;
29144
+ var clonedTarget = CloneUtils.remapComponent(srcRoot, targetRoot, listener.target);
29145
+ if (clonedTarget) {
29146
+ var clonedArgs = this._cloneArguments(listener.arguments, srcRoot, targetRoot);
29147
+ if (listener.once) {
29148
+ var _target;
29149
+ (_target = target).once.apply(_target, [].concat([
29150
+ clonedTarget,
29151
+ listener.methodName
29152
+ ], clonedArgs));
29153
+ } else {
29154
+ var _target1;
29155
+ (_target1 = target).on.apply(_target1, [].concat([
29156
+ clonedTarget,
29157
+ listener.methodName
29158
+ ], clonedArgs));
29159
+ }
29160
+ }
29161
+ }
29162
+ };
29163
+ _proto._cloneArguments = function _cloneArguments(args, srcRoot, targetRoot) {
29164
+ if (!args || args.length === 0) return [];
29165
+ var len = args.length;
29166
+ var clonedArgs = new Array(len);
29167
+ for(var i = 0; i < len; i++){
29168
+ var arg = args[i];
29169
+ if (_instanceof(arg, Entity)) {
29170
+ clonedArgs[i] = CloneUtils.remapEntity(srcRoot, targetRoot, arg);
29171
+ } else if (_instanceof(arg, Component)) {
29172
+ clonedArgs[i] = CloneUtils.remapComponent(srcRoot, targetRoot, arg);
29173
+ } else {
29174
+ clonedArgs[i] = arg;
29175
+ }
29176
+ }
29177
+ return clonedArgs;
29178
+ };
29179
+ _proto._addListener = function _addListener(fnOrTarget, targetOrMethodName, once) {
29180
+ for(var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){
29181
+ args[_key - 3] = arguments[_key];
29182
+ }
29183
+ if (typeof fnOrTarget === "function") {
29184
+ this._listeners.push({
29185
+ fn: fnOrTarget,
29186
+ target: targetOrMethodName != null ? targetOrMethodName : null,
29187
+ once: once
29188
+ });
29189
+ } else {
29190
+ var _target, _target1;
29191
+ var target = fnOrTarget;
29192
+ var methodName = targetOrMethodName;
29193
+ var fn = args.length > 0 ? function() {
29194
+ for(var _len = arguments.length, signalArgs = new Array(_len), _key = 0; _key < _len; _key++){
29195
+ signalArgs[_key] = arguments[_key];
29196
+ }
29197
+ return (_target = target)[methodName].apply(_target, [].concat(args, signalArgs));
29198
+ } : function() {
29199
+ for(var _len = arguments.length, signalArgs = new Array(_len), _key = 0; _key < _len; _key++){
29200
+ signalArgs[_key] = arguments[_key];
29201
+ }
29202
+ return (_target1 = target)[methodName].apply(_target1, [].concat(signalArgs));
29203
+ };
29204
+ this._listeners.push({
29205
+ fn: fn,
29206
+ target: target,
29207
+ once: once,
29208
+ methodName: methodName,
29209
+ arguments: args
29210
+ });
29211
+ }
29212
+ };
29213
+ return Signal;
29214
+ }();
29215
+ __decorate([
29216
+ ignoreClone
29217
+ ], Signal.prototype, "_listeners", void 0);
29218
+
29029
29219
  /**
29030
29220
  * Loader abstract class.
29031
29221
  */ var Loader = /*#__PURE__*/ function() {
@@ -38337,5 +38527,5 @@ __decorate([
38337
38527
 
38338
38528
  Polyfill.registerPolyfill();
38339
38529
 
38340
- export { AmbientLight, AmbientOcclusion, AmbientOcclusionQuality, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorCondition, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorControllerParameter, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AntiAliasing, AssetPromise, AssetType, AudioClip, AudioManager, AudioSource, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BatchUtils, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, Blitter, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferAsset, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraModifyFlags, CameraType, Canvas, CapsuleColliderShape, CharRenderInfo, CharacterController, CircleShape, ClearableObjectPool, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, Collision, CollisionDetectionMode, ColorOverLifetimeModule, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContactPoint, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DisorderedArray, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EntityModifyFlags, EventDispatcher, FinalPass, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, JSONAsset, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, LayerPathMask, Light, Loader, Logger, MSAASamples, MainModule, Material, Mesh, MeshColliderShape, MeshColliderShapeCookingFlag, MeshRenderer, MeshShape, MeshTopology, ModelMesh, OverflowMode, PBRMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerEventData, PointerEventEmitter, PointerPhase, PostProcess, PostProcessEffect, PostProcessEffectBoolParameter, PostProcessEffectColorParameter, PostProcessEffectEnumParameter, PostProcessEffectFloatParameter, PostProcessEffectParameter, PostProcessEffectTextureParameter, PostProcessEffectVector2Parameter, PostProcessEffectVector3Parameter, PostProcessEffectVector4Parameter, PostProcessManager, PostProcessPass, PostProcessPassEvent, PostProcessUberPass, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RefractionMode, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueFlags, RenderQueueType, RenderState, RenderStateElementKey, RenderTarget, RenderTargetBlendState, Renderer, RendererUpdateFlags, RenderingStatistics, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, SafeLoopArray, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderDataGroup, ShaderFactory, ShaderLanguage, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, SimpleSpriteAssembler, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SlicedSpriteAssembler, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteModifyFlags, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubFont, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextAsset, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureUtils, TextureWrapMode, TiledSpriteAssembler, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, TrailTextureMode, Transform, TransformModifyFlags, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, XRManager, assignmentClone, deepClone, dependentComponents, ignoreClone, registerPointerEventEmitter, request, resourceLoader, shallowClone };
38530
+ export { AmbientLight, AmbientOcclusion, AmbientOcclusionQuality, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorCondition, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorControllerParameter, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AntiAliasing, AssetPromise, AssetType, AudioClip, AudioManager, AudioSource, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BatchUtils, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, Blitter, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferAsset, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraModifyFlags, CameraType, Canvas, CapsuleColliderShape, CharRenderInfo, CharacterController, CircleShape, ClearableObjectPool, CloneManager, CloneUtils, Collider, ColliderShape, ColliderShapeUpAxis, Collision, CollisionDetectionMode, ColorOverLifetimeModule, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContactPoint, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DisorderedArray, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EntityModifyFlags, EventDispatcher, FinalPass, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, JSONAsset, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, LayerPathMask, Light, Loader, Logger, MSAASamples, MainModule, Material, Mesh, MeshColliderShape, MeshColliderShapeCookingFlag, MeshRenderer, MeshShape, MeshTopology, ModelMesh, OverflowMode, PBRMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerEventData, PointerEventEmitter, PointerPhase, PostProcess, PostProcessEffect, PostProcessEffectBoolParameter, PostProcessEffectColorParameter, PostProcessEffectEnumParameter, PostProcessEffectFloatParameter, PostProcessEffectParameter, PostProcessEffectTextureParameter, PostProcessEffectVector2Parameter, PostProcessEffectVector3Parameter, PostProcessEffectVector4Parameter, PostProcessManager, PostProcessPass, PostProcessPassEvent, PostProcessUberPass, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RefractionMode, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueFlags, RenderQueueType, RenderState, RenderStateElementKey, RenderTarget, RenderTargetBlendState, Renderer, RendererUpdateFlags, RenderingStatistics, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, SafeLoopArray, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderDataGroup, ShaderFactory, ShaderLanguage, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Signal, SimpleSpriteAssembler, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SlicedSpriteAssembler, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteModifyFlags, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubFont, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextAsset, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureUtils, TextureWrapMode, TiledSpriteAssembler, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, TrailTextureMode, Transform, TransformModifyFlags, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, XRManager, assignmentClone, deepClone, dependentComponents, ignoreClone, registerPointerEventEmitter, request, resourceLoader, shallowClone };
38341
38531
  //# sourceMappingURL=module.js.map