@galacean/engine-core 0.0.0-experimental-2.0-game.17 → 0.0.0-experimental-2.0-game.18

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/main.js CHANGED
@@ -781,10 +781,10 @@ var AssetPromise = /*#__PURE__*/ function() {
781
781
  */ _proto.onProgress = function onProgress(onTaskComplete, onTaskDetail) {
782
782
  var completeProgress = this._taskCompleteProgress;
783
783
  var detailProgress = this._taskDetailProgress;
784
- if (completeProgress) {
784
+ if (completeProgress && onTaskComplete) {
785
785
  onTaskComplete(completeProgress.loaded, completeProgress.total);
786
786
  }
787
- if (detailProgress) {
787
+ if (detailProgress && onTaskDetail) {
788
788
  for(var url in detailProgress){
789
789
  var _detailProgress_url = detailProgress[url], loaded = _detailProgress_url.loaded, total = _detailProgress_url.total;
790
790
  onTaskDetail(url, loaded, total);
@@ -2020,10 +2020,11 @@ SystemInfo._initialize();
2020
2020
  }({});
2021
2021
 
2022
2022
  /**
2023
- * The way to handle the situation where wrapped text is too tall to fit in the height.
2023
+ * The way to handle the situation where the text is too large to fit in the bounds.
2024
2024
  */ var OverflowMode = /*#__PURE__*/ function(OverflowMode) {
2025
2025
  /** Overflow when the text is too tall */ OverflowMode[OverflowMode["Overflow"] = 0] = "Overflow";
2026
2026
  /** Truncate with height when the text is too tall */ OverflowMode[OverflowMode["Truncate"] = 1] = "Truncate";
2027
+ /** Shrink the font size until the text fits within the bounds (both width and height) */ OverflowMode[OverflowMode["Shrink"] = 2] = "Shrink";
2027
2028
  return OverflowMode;
2028
2029
  }({});
2029
2030
 
@@ -2088,7 +2089,8 @@ SystemInfo._initialize();
2088
2089
  TextUtils.measureChar = function measureChar(char, fontString) {
2089
2090
  return TextUtils._measureFontOrChar(fontString, char, true);
2090
2091
  };
2091
- TextUtils.measureTextWithWrap = function measureTextWithWrap(renderer, rendererWidth, rendererHeight, lineSpacing, characterSpacing) {
2092
+ TextUtils.measureTextWithWrap = function measureTextWithWrap(renderer, rendererWidth, rendererHeight, lineSpacing, characterSpacing, uploadCharTexture) {
2093
+ if (uploadCharTexture === void 0) uploadCharTexture = true;
2092
2094
  var subFont = renderer._getSubFont();
2093
2095
  var fontString = subFont.nativeFontString;
2094
2096
  var fontSizeInfo = TextUtils.measureFont(fontString);
@@ -2117,7 +2119,7 @@ SystemInfo._initialize();
2117
2119
  var notFirstLine = false;
2118
2120
  for(var j = 0, m = subText.length; j < m; ++j){
2119
2121
  var char = subText[j];
2120
- var charInfo = TextUtils._getCharInfo(char, fontString, subFont);
2122
+ var charInfo = TextUtils._getCharInfo(char, fontString, subFont, uploadCharTexture);
2121
2123
  var charCode = char.charCodeAt(0);
2122
2124
  var isSpace = charCode === 32;
2123
2125
  if (isSpace && notFirstLine && line.length === 0 && word.length === 0) {
@@ -2246,7 +2248,8 @@ SystemInfo._initialize();
2246
2248
  lineMaxSizes: lineMaxSizes
2247
2249
  };
2248
2250
  };
2249
- TextUtils.measureTextWithoutWrap = function measureTextWithoutWrap(renderer, rendererHeight, lineSpacing, characterSpacing) {
2251
+ TextUtils.measureTextWithoutWrap = function measureTextWithoutWrap(renderer, rendererHeight, lineSpacing, characterSpacing, uploadCharTexture) {
2252
+ if (uploadCharTexture === void 0) uploadCharTexture = true;
2250
2253
  var subFont = renderer._getSubFont();
2251
2254
  var fontString = subFont.nativeFontString;
2252
2255
  var fontSizeInfo = TextUtils.measureFont(fontString);
@@ -2265,7 +2268,7 @@ SystemInfo._initialize();
2265
2268
  var maxAscent = 0;
2266
2269
  var maxDescent = 0;
2267
2270
  for(var j = 0; j < lineLength; ++j){
2268
- var charInfo = TextUtils._getCharInfo(line[j], fontString, subFont);
2271
+ var charInfo = TextUtils._getCharInfo(line[j], fontString, subFont, uploadCharTexture);
2269
2272
  curWidth += charInfo.xAdvance;
2270
2273
  var offsetY = charInfo.offsetY;
2271
2274
  var halfH = charInfo.h * 0.5;
@@ -2293,6 +2296,64 @@ SystemInfo._initialize();
2293
2296
  };
2294
2297
  };
2295
2298
  /**
2299
+ * Measure text in SHRINK overflow mode: keep shrinking the font size until the text fits
2300
+ * within the bounds (both width and height). Mirrors Cocos Creator's `Overflow.SHRINK`.
2301
+ *
2302
+ * @param renderer - The text renderer
2303
+ * @param rendererWidth - The width of the bounds in pixels
2304
+ * @param rendererHeight - The height of the bounds in pixels
2305
+ * @param originalFontSize - The font size set on the renderer (the upper bound, never enlarged)
2306
+ * @param lineSpacing - The line spacing ratio (relative to font size)
2307
+ * @param characterSpacing - The character spacing ratio (relative to font size)
2308
+ * @param enableWrapping - Whether wrapping is enabled
2309
+ * @param applyFontSize - Callback that switches the renderer's sub font to the given font size
2310
+ * @returns The fitted text metrics and the actual font size used for layout
2311
+ */ TextUtils.measureTextWithShrink = function measureTextWithShrink(renderer, rendererWidth, rendererHeight, originalFontSize, lineSpacing, characterSpacing, enableWrapping, applyFontSize) {
2312
+ // During the binary search we only need the text dimensions, so pass `uploadCharTexture=false`
2313
+ // to avoid building GPU font atlases for the intermediate font sizes that won't be used.
2314
+ // The fitted size is then re-measured once with upload=true to populate its atlas. This trades
2315
+ // one extra full measure pass (CPU) for skipping ~log2(size) throwaway atlas textures (GPU);
2316
+ // we can't reuse the search's last measure because its char bitmaps were never cached.
2317
+ var measureAt = function(fontSize, uploadCharTexture) {
2318
+ applyFontSize(fontSize);
2319
+ return enableWrapping ? TextUtils.measureTextWithWrap(renderer, rendererWidth, rendererHeight, lineSpacing * fontSize, characterSpacing * fontSize, uploadCharTexture) : TextUtils.measureTextWithoutWrap(renderer, rendererHeight, lineSpacing * fontSize, characterSpacing * fontSize, uploadCharTexture);
2320
+ };
2321
+ // The content height is `lineHeight * lineCount`; `metrics.height` is clamped to the bounds
2322
+ // unless overflowMode is Overflow, so it can't be used to detect vertical overflow here.
2323
+ var isFit = function(metrics) {
2324
+ return metrics.width <= rendererWidth && metrics.lineHeight * metrics.lines.length <= rendererHeight;
2325
+ };
2326
+ // If the text already fits at the original size, keep it (SHRINK only shrinks, never enlarges).
2327
+ var metrics = measureAt(originalFontSize, false);
2328
+ if (isFit(metrics)) {
2329
+ metrics = measureAt(originalFontSize, true);
2330
+ return {
2331
+ metrics: metrics,
2332
+ fontSize: originalFontSize
2333
+ };
2334
+ }
2335
+ // Binary search for the largest integer font size that fits (measure only, no atlas upload).
2336
+ var low = 1;
2337
+ var high = Math.floor(originalFontSize);
2338
+ var fitFontSize = low;
2339
+ while(low <= high){
2340
+ var mid = low + high >> 1;
2341
+ metrics = measureAt(mid, false);
2342
+ if (isFit(metrics)) {
2343
+ fitFontSize = mid;
2344
+ low = mid + 1;
2345
+ } else {
2346
+ high = mid - 1;
2347
+ }
2348
+ }
2349
+ // Re-measure the fitted size with upload=true so the sub font / atlas correspond to it.
2350
+ metrics = measureAt(fitFontSize, true);
2351
+ return {
2352
+ metrics: metrics,
2353
+ fontSize: fitFontSize
2354
+ };
2355
+ };
2356
+ /**
2296
2357
  * Get native font hash.
2297
2358
  * @param fontName - The font name
2298
2359
  * @param fontSize - The font size
@@ -2409,12 +2470,17 @@ SystemInfo._initialize();
2409
2470
  };
2410
2471
  /**
2411
2472
  * @internal
2412
- */ TextUtils._getCharInfo = function _getCharInfo(char, fontString, font) {
2473
+ */ TextUtils._getCharInfo = function _getCharInfo(char, fontString, font, uploadCharTexture) {
2474
+ if (uploadCharTexture === void 0) uploadCharTexture = true;
2413
2475
  var charInfo = font._getCharInfo(char);
2414
2476
  if (!charInfo) {
2415
2477
  charInfo = TextUtils.measureChar(char, fontString);
2416
- font._uploadCharTexture(charInfo);
2417
- font._addCharInfo(char, charInfo);
2478
+ // SHRINK 的二分阶段只需字符尺寸(measureChar 已给出),传 uploadCharTexture=false 跳过 GPU
2479
+ // 字形图集上传与缓存,避免给用不到的中间字号建字体 atlas 纹理。
2480
+ if (uploadCharTexture) {
2481
+ font._uploadCharTexture(charInfo);
2482
+ font._addCharInfo(char, charInfo);
2483
+ }
2418
2484
  }
2419
2485
  return charInfo;
2420
2486
  };
@@ -11454,6 +11520,14 @@ __decorate([
11454
11520
  this._subFont = font._getSubFont(this.fontSize, this.fontStyle);
11455
11521
  this._subFont.nativeFontString = TextUtils.getNativeFontString(font.name, this.fontSize, this.fontStyle);
11456
11522
  };
11523
+ /**
11524
+ * Switch the sub font to a specific font size, used by the SHRINK overflow measurement.
11525
+ */ _proto._applyFontSizeForShrink = function _applyFontSizeForShrink(fontSize) {
11526
+ var font = this._font;
11527
+ var subFont = font._getSubFont(fontSize, this._fontStyle);
11528
+ subFont.nativeFontString = TextUtils.getNativeFontString(font.name, fontSize, this._fontStyle);
11529
+ this._subFont = subFont;
11530
+ };
11457
11531
  _proto._updatePosition = function _updatePosition() {
11458
11532
  var transform = this.entity.transform;
11459
11533
  var e = transform.worldMatrix.elements;
@@ -11509,12 +11583,26 @@ __decorate([
11509
11583
  }
11510
11584
  };
11511
11585
  _proto._updateLocalData = function _updateLocalData() {
11586
+ var _this = this;
11512
11587
  var _pixelsPerUnit = Engine._pixelsPerUnit;
11513
11588
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
11514
11589
  var charRenderInfos = TextRenderer._charRenderInfos;
11590
+ var rendererWidth = this.width * _pixelsPerUnit;
11591
+ var rendererHeight = this.height * _pixelsPerUnit;
11592
+ var fontSize = this._fontSize;
11593
+ var textMetrics;
11594
+ if (this._overflowMode === OverflowMode.Shrink) {
11595
+ var result = TextUtils.measureTextWithShrink(this, rendererWidth, rendererHeight, this._fontSize, this._lineSpacing, this._characterSpacing, this.enableWrapping, function(size) {
11596
+ return _this._applyFontSizeForShrink(size);
11597
+ });
11598
+ fontSize = result.fontSize;
11599
+ textMetrics = result.metrics;
11600
+ } else {
11601
+ var characterSpacing = this._characterSpacing * fontSize;
11602
+ textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this, rendererWidth, rendererHeight, this._lineSpacing * fontSize, characterSpacing) : TextUtils.measureTextWithoutWrap(this, rendererHeight, this._lineSpacing * fontSize, characterSpacing);
11603
+ }
11515
11604
  var charFont = this._getSubFont();
11516
- var characterSpacing = this._characterSpacing * this._fontSize;
11517
- var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this, this.width * _pixelsPerUnit, this.height * _pixelsPerUnit, this._lineSpacing * this._fontSize, characterSpacing) : TextUtils.measureTextWithoutWrap(this, this.height * _pixelsPerUnit, this._lineSpacing * this._fontSize, characterSpacing);
11605
+ var characterSpacing1 = this._characterSpacing * fontSize;
11518
11606
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
11519
11607
  var charRenderInfoPool = this.engine._charRenderInfoPool;
11520
11608
  var linesLen = lines.length;
@@ -11522,9 +11610,7 @@ __decorate([
11522
11610
  if (linesLen > 0) {
11523
11611
  var horizontalAlignment = this.horizontalAlignment;
11524
11612
  var pixelsPerUnitReciprocal = 1.0 / _pixelsPerUnit;
11525
- var rendererWidth = this._width * _pixelsPerUnit;
11526
11613
  var halfRendererWidth = rendererWidth * 0.5;
11527
- var rendererHeight = this._height * _pixelsPerUnit;
11528
11614
  var halfLineHeight = lineHeight * 0.5;
11529
11615
  var startY = 0;
11530
11616
  var topDiff = lineHeight * 0.5 - lineMaxSizes[0].ascent;
@@ -11534,7 +11620,10 @@ __decorate([
11534
11620
  startY = rendererHeight * 0.5 - halfLineHeight + topDiff;
11535
11621
  break;
11536
11622
  case TextVerticalAlignment.Center:
11537
- startY = height * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
11623
+ // Center the text block (lineHeight * lineCount) within the renderer, independent of
11624
+ // `height` — which equals the renderer height for Truncate/Shrink and would otherwise
11625
+ // push the text upward by (rendererHeight - blockHeight) / 2 when the box is taller.
11626
+ startY = lineHeight * linesLen * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
11538
11627
  break;
11539
11628
  case TextVerticalAlignment.Bottom:
11540
11629
  startY = height - rendererHeight * 0.5 - halfLineHeight - bottomDiff;
@@ -11586,7 +11675,7 @@ __decorate([
11586
11675
  j === firstRow && (minX = Math.min(minX, left));
11587
11676
  maxX = Math.max(maxX, right);
11588
11677
  }
11589
- startX += charInfo.xAdvance + characterSpacing;
11678
+ startX += charInfo.xAdvance + characterSpacing1;
11590
11679
  }
11591
11680
  }
11592
11681
  startY -= lineHeight;
@@ -11642,7 +11731,7 @@ __decorate([
11642
11731
  this._setDirtyFlagTrue(4 | 8);
11643
11732
  };
11644
11733
  _proto._isTextNoVisible = function _isTextNoVisible() {
11645
- return !this._font || this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === OverflowMode.Truncate && this.height <= 0;
11734
+ return !this._font || this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || (this.overflowMode === OverflowMode.Truncate || this.overflowMode === OverflowMode.Shrink) && this.height <= 0;
11646
11735
  };
11647
11736
  _proto._buildChunk = function _buildChunk(textChunk, count) {
11648
11737
  var _this_color = this.color, r = _this_color.r, g = _this_color.g, b = _this_color.b, a = _this_color.a;
@@ -22208,100 +22297,351 @@ __decorate([
22208
22297
  /** The shape of the collider that was hit. */ this.shape = null;
22209
22298
  };
22210
22299
 
22211
- /**
22212
- * Describes a contact point where the collision occurs.
22213
- */ var ContactPoint = function ContactPoint() {
22214
- /** The position of the contact point between the shapes, in world space. */ this.position = new engineMath.Vector3();
22215
- /** The normal of the contacting surfaces at the contact point. The normal direction points from the other shape to the self shape. */ this.normal = new engineMath.Vector3();
22216
- /** The impulse applied at the contact point, in world space. Divide by the simulation time step to get a force value. */ this.impulse = new engineMath.Vector3();
22217
- };
22300
+ function _array_like_to_array(arr, len) {
22301
+ if (len == null || len > arr.length) len = arr.length;
22218
22302
 
22219
- /**
22220
- * Collision information between two shapes when they collide.
22221
- */ var Collision = /*#__PURE__*/ function() {
22222
- function Collision() {}
22223
- var _proto = Collision.prototype;
22224
- /**
22225
- * Get contact points.
22226
- * @param outContacts - The result of contact points
22227
- * @returns The actual count of contact points
22228
- *
22229
- * @remarks To optimize performance, the engine does not modify the length of the array you pass.
22230
- * You need to obtain the actual number of contact points from the function's return value.
22231
- */ _proto.getContacts = function getContacts(outContacts) {
22232
- var nativeCollision = this._nativeCollision;
22233
- var factor = this.shape.id === nativeCollision.shape1Id ? 1 : -1;
22234
- var nativeContactPoints = nativeCollision.getContacts();
22235
- var length = nativeContactPoints.size();
22236
- for(var i = 0; i < length; i++){
22237
- var _outContacts, _i;
22238
- var nativeContractPoint = nativeContactPoints.get(i);
22239
- var contact = (_outContacts = outContacts)[_i = i] || (_outContacts[_i] = new ContactPoint());
22240
- contact.position.copyFrom(nativeContractPoint.position);
22241
- contact.normal.copyFrom(nativeContractPoint.normal).scale(factor);
22242
- contact.impulse.copyFrom(nativeContractPoint.impulse).scale(factor);
22243
- contact.separation = nativeContractPoint.separation;
22244
- }
22245
- return length;
22246
- };
22247
- _create_class(Collision, [
22248
- {
22249
- key: "contactCount",
22250
- get: /**
22251
- * Count of contact points.
22252
- */ function get() {
22253
- return this._nativeCollision.contactCount;
22254
- }
22255
- }
22256
- ]);
22257
- return Collision;
22258
- }();
22303
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
22304
+
22305
+ return arr2;
22306
+ }
22307
+
22308
+ function _unsupported_iterable_to_array(o, minLen) {
22309
+ if (!o) return;
22310
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
22311
+
22312
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22313
+
22314
+ if (n === "Object" && o.constructor) n = o.constructor.name;
22315
+ if (n === "Map" || n === "Set") return Array.from(n);
22316
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
22317
+ }
22318
+
22319
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
22320
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
22321
+
22322
+ if (it) return (it = it.call(o)).next.bind(it);
22323
+ // Fallback for engines without symbol support
22324
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
22325
+ if (it) o = it;
22326
+
22327
+ var i = 0;
22328
+
22329
+ return function() {
22330
+ if (i >= o.length) return { done: true };
22331
+
22332
+ return { done: false, value: o[i++] };
22333
+ };
22334
+ }
22335
+
22336
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
22337
+ }
22259
22338
 
22260
22339
  /**
22261
- * A physics scene is a collection of colliders and constraints which can interact.
22262
- */ var PhysicsScene = /*#__PURE__*/ function() {
22263
- function PhysicsScene(scene) {
22264
- this._restTime = 0;
22265
- this._fixedTimeStep = 1 / 60;
22266
- this._colliders = new DisorderedArray();
22267
- this._gravity = new engineMath.Vector3(0, -9.81, 0);
22268
- this._scene = scene;
22269
- this._setGravity = this._setGravity.bind(this);
22270
- //@ts-ignore
22271
- this._gravity._onValueChanged = this._setGravity;
22272
- var engine = scene.engine;
22273
- if (engine._physicsInitialized) {
22274
- this._nativePhysicsScene = Engine._nativePhysics.createPhysicsScene(engine._nativePhysicsManager);
22275
- }
22340
+ * Script class, used for logic writing.
22341
+ */ var Script = /*#__PURE__*/ function(Component) {
22342
+ _inherits(Script, Component);
22343
+ function Script() {
22344
+ var _this;
22345
+ _this = Component.apply(this, arguments) || this, /** @internal */ _this._started = false, /** @internal */ _this._onStartIndex = -1, /** @internal */ _this._onUpdateIndex = -1, /** @internal */ _this._onLateUpdateIndex = -1, /** @internal */ _this._onPhysicsUpdateIndex = -1, /** @internal */ _this._onPreRenderIndex = -1, /** @internal */ _this._onPostRenderIndex = -1, /** @internal */ _this._entityScriptsIndex = -1;
22346
+ return _this;
22276
22347
  }
22277
- var _proto = PhysicsScene.prototype;
22348
+ var _proto = Script.prototype;
22278
22349
  /**
22279
- * Get whether two colliders can collide with each other.
22280
- * @param layer1 - The first collision layer
22281
- * @param layer2 - The second collision layer
22282
- * @returns Whether the colliders should collide
22283
- */ _proto.getColliderLayerCollision = function getColliderLayerCollision(layer1, layer2) {
22284
- var index1 = Math.log2(layer1);
22285
- var index2 = Math.log2(layer2);
22286
- if (!Number.isInteger(index1) || !Number.isInteger(index1)) {
22287
- throw new Error("Collision layer must be a single layer (Layer.Layer0 to Layer.Layer31)");
22288
- }
22289
- return Engine._nativePhysics.getColliderLayerCollision(index1, index2);
22350
+ * Called when be enabled first time, only once.
22351
+ */ _proto.onAwake = function onAwake() {};
22352
+ /**
22353
+ * Called when be enabled.
22354
+ */ _proto.onEnable = function onEnable() {};
22355
+ /**
22356
+ * Called before the frame-level loop start for the first time, only once.
22357
+ */ _proto.onStart = function onStart() {};
22358
+ /**
22359
+ * The main loop, called frame by frame.
22360
+ * @param deltaTime - The delta time since last frame in seconds
22361
+ */ _proto.onUpdate = function onUpdate(deltaTime) {};
22362
+ /**
22363
+ * Called after the onUpdate finished, called frame by frame.
22364
+ * @param deltaTime - The delta time since last frame in seconds
22365
+ */ _proto.onLateUpdate = function onLateUpdate(deltaTime) {};
22366
+ /**
22367
+ * Called before camera rendering, called per camera.
22368
+ * @param camera - Current camera.
22369
+ */ _proto.onBeginRender = function onBeginRender(camera) {};
22370
+ /**
22371
+ * Called after camera rendering, called per camera.
22372
+ * @param camera - Current camera.
22373
+ */ _proto.onEndRender = function onEndRender(camera) {};
22374
+ /**
22375
+ * Called before physics calculations, the number of times is related to the physical update frequency.
22376
+ */ _proto.onPhysicsUpdate = function onPhysicsUpdate() {};
22377
+ /**
22378
+ * Called when the trigger enter.
22379
+ * @param other - ColliderShape
22380
+ */ _proto.onTriggerEnter = function onTriggerEnter(other) {};
22381
+ /**
22382
+ * Called when the trigger exit.
22383
+ * @param other - ColliderShape
22384
+ */ _proto.onTriggerExit = function onTriggerExit(other) {};
22385
+ /**
22386
+ * Called when the trigger stay.
22387
+ * @remarks onTriggerStay is called every frame while the trigger stay.
22388
+ * @param other - ColliderShape
22389
+ */ _proto.onTriggerStay = function onTriggerStay(other) {};
22390
+ /**
22391
+ * Called when the collision enter.
22392
+ * @param other - The Collision data associated with this collision event
22393
+ * @remarks The Collision data will be invalid after this call, you should copy the data if needed.
22394
+ */ _proto.onCollisionEnter = function onCollisionEnter(other) {};
22395
+ /**
22396
+ * Called when the collision exit.
22397
+ * @param other - The Collision data associated with this collision event
22398
+ * @remarks The Collision data will be invalid after this call, you should copy the data if needed.
22399
+ */ _proto.onCollisionExit = function onCollisionExit(other) {};
22400
+ /**
22401
+ * Called when the collision stay.
22402
+ * @param other - The Collision data associated with this collision event
22403
+ * @remarks The Collision data will be invalid after this call, you should copy the data if needed.
22404
+ */ _proto.onCollisionStay = function onCollisionStay(other) {};
22405
+ /**
22406
+ * Called when the pointer is down while over the ColliderShape.
22407
+ * @param eventData - The pointer event data that triggered this callback
22408
+ */ _proto.onPointerDown = function onPointerDown(eventData) {};
22409
+ /**
22410
+ * Called when the pointer is up while over the ColliderShape.
22411
+ * @param eventData - The pointer event data that triggered this callback
22412
+ */ _proto.onPointerUp = function onPointerUp(eventData) {};
22413
+ /**
22414
+ * Called when the pointer is down and up with the same collider.
22415
+ * @param eventData - The pointer event data that triggered this callback
22416
+ */ _proto.onPointerClick = function onPointerClick(eventData) {};
22417
+ /**
22418
+ * Called when the pointer enters the ColliderShape.
22419
+ * @param eventData - The pointer event data that triggered this callback
22420
+ */ _proto.onPointerEnter = function onPointerEnter(eventData) {};
22421
+ /**
22422
+ * Called when the pointer exits the ColliderShape.
22423
+ * @param eventData - The pointer event data that triggered this callback
22424
+ */ _proto.onPointerExit = function onPointerExit(eventData) {};
22425
+ /**
22426
+ * This function will be called when the pointer is pressed on the collider.
22427
+ * @param eventData - The pointer event data that triggered this callback
22428
+ */ _proto.onPointerBeginDrag = function onPointerBeginDrag(eventData) {};
22429
+ /**
22430
+ * When a drag collision occurs on the pointer, this function will be called every time it moves.
22431
+ * @param eventData - The pointer event data that triggered this callback
22432
+ */ _proto.onPointerDrag = function onPointerDrag(eventData) {};
22433
+ /**
22434
+ * When dragging ends, this function will be called (Dragged object).
22435
+ * @param eventData - The pointer event data that triggered this callback
22436
+ */ _proto.onPointerEndDrag = function onPointerEndDrag(eventData) {};
22437
+ /**
22438
+ * When dragging ends, this function will be called (Receiving object).
22439
+ * @param eventData - The pointer event data that triggered this callback
22440
+ */ _proto.onPointerDrop = function onPointerDrop(eventData) {};
22441
+ /**
22442
+ * Called when be disabled.
22443
+ */ _proto.onDisable = function onDisable() {};
22444
+ /**
22445
+ * Called at the end of the destroyed frame.
22446
+ */ _proto.onDestroy = function onDestroy() {};
22447
+ /**
22448
+ * @internal
22449
+ */ _proto._onAwake = function _onAwake() {
22450
+ this.onAwake();
22290
22451
  };
22291
22452
  /**
22292
- * Set whether two colliders can collide with each other.
22293
- * @param layer1 - The first collision layer
22294
- * @param layer2 - The second collision layer
22295
- * @param isCollide - Whether the colliders should collide
22296
- */ _proto.setColliderLayerCollision = function setColliderLayerCollision(layer1, layer2, isCollide) {
22297
- var index1 = Math.log2(layer1);
22298
- var index2 = Math.log2(layer2);
22299
- if (!Number.isInteger(index1) || !Number.isInteger(index1)) {
22300
- throw new Error("Collision layer must be a single layer (Layer.Layer0 to Layer.Layer31)");
22301
- }
22302
- Engine._nativePhysics.setColliderLayerCollision(index1, index2, isCollide);
22453
+ * @internal
22454
+ */ _proto._onEnable = function _onEnable() {
22455
+ this.onEnable();
22303
22456
  };
22304
- _proto.raycast = function raycast(ray, distanceOrResult, layerMaskOrResult, outHitResult) {
22457
+ /**
22458
+ * @internal
22459
+ */ _proto._onDisable = function _onDisable() {
22460
+ this.onDisable();
22461
+ };
22462
+ /**
22463
+ * @internal
22464
+ */ _proto._onEnableInScene = function _onEnableInScene() {
22465
+ var _this_scene = this.scene, componentsManager = _this_scene._componentsManager;
22466
+ var prototype = Script.prototype;
22467
+ if (!this._started) {
22468
+ componentsManager.addOnStartScript(this);
22469
+ }
22470
+ if (this.onUpdate !== prototype.onUpdate) {
22471
+ componentsManager.addOnUpdateScript(this);
22472
+ }
22473
+ if (this.onLateUpdate !== prototype.onLateUpdate) {
22474
+ componentsManager.addOnLateUpdateScript(this);
22475
+ }
22476
+ if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
22477
+ componentsManager.addOnPhysicsUpdateScript(this);
22478
+ }
22479
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.values(PointerMethods)), _step; !(_step = _iterator()).done;){
22480
+ var pointerMethod = _step.value;
22481
+ if (this[pointerMethod] === prototype[pointerMethod]) {
22482
+ this[pointerMethod] = null;
22483
+ }
22484
+ }
22485
+ this._entity._addScript(this);
22486
+ };
22487
+ /**
22488
+ * @internal
22489
+ */ _proto._onDisableInScene = function _onDisableInScene() {
22490
+ var componentsManager = this.scene._componentsManager;
22491
+ var prototype = Script.prototype;
22492
+ if (!this._started) {
22493
+ componentsManager.removeOnStartScript(this);
22494
+ }
22495
+ if (this.onUpdate !== prototype.onUpdate) {
22496
+ componentsManager.removeOnUpdateScript(this);
22497
+ }
22498
+ if (this.onLateUpdate !== prototype.onLateUpdate) {
22499
+ componentsManager.removeOnLateUpdateScript(this);
22500
+ }
22501
+ if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
22502
+ componentsManager.removeOnPhysicsUpdateScript(this);
22503
+ }
22504
+ this._entity._removeScript(this);
22505
+ };
22506
+ /**
22507
+ * @internal
22508
+ */ _proto._onDestroy = function _onDestroy() {
22509
+ Component.prototype._onDestroy.call(this);
22510
+ this.onDestroy();
22511
+ };
22512
+ return Script;
22513
+ }(Component);
22514
+ __decorate([
22515
+ ignoreClone
22516
+ ], Script.prototype, "_started", void 0);
22517
+ __decorate([
22518
+ ignoreClone
22519
+ ], Script.prototype, "_onStartIndex", void 0);
22520
+ __decorate([
22521
+ ignoreClone
22522
+ ], Script.prototype, "_onUpdateIndex", void 0);
22523
+ __decorate([
22524
+ ignoreClone
22525
+ ], Script.prototype, "_onLateUpdateIndex", void 0);
22526
+ __decorate([
22527
+ ignoreClone
22528
+ ], Script.prototype, "_onPhysicsUpdateIndex", void 0);
22529
+ __decorate([
22530
+ ignoreClone
22531
+ ], Script.prototype, "_onPreRenderIndex", void 0);
22532
+ __decorate([
22533
+ ignoreClone
22534
+ ], Script.prototype, "_onPostRenderIndex", void 0);
22535
+ __decorate([
22536
+ ignoreClone
22537
+ ], Script.prototype, "_entityScriptsIndex", void 0);
22538
+ var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
22539
+ PointerMethods["onPointerDown"] = "onPointerDown";
22540
+ PointerMethods["onPointerUp"] = "onPointerUp";
22541
+ PointerMethods["onPointerClick"] = "onPointerClick";
22542
+ PointerMethods["onPointerEnter"] = "onPointerEnter";
22543
+ PointerMethods["onPointerExit"] = "onPointerExit";
22544
+ PointerMethods["onPointerBeginDrag"] = "onPointerBeginDrag";
22545
+ PointerMethods["onPointerDrag"] = "onPointerDrag";
22546
+ PointerMethods["onPointerEndDrag"] = "onPointerEndDrag";
22547
+ PointerMethods["onPointerDrop"] = "onPointerDrop";
22548
+ return PointerMethods;
22549
+ }({});
22550
+
22551
+ /**
22552
+ * Describes a contact point where the collision occurs.
22553
+ */ var ContactPoint = function ContactPoint() {
22554
+ /** The position of the contact point between the shapes, in world space. */ this.position = new engineMath.Vector3();
22555
+ /** The normal of the contacting surfaces at the contact point. The normal direction points from the other shape to the self shape. */ this.normal = new engineMath.Vector3();
22556
+ /** The impulse applied at the contact point, in world space. Divide by the simulation time step to get a force value. */ this.impulse = new engineMath.Vector3();
22557
+ };
22558
+
22559
+ /**
22560
+ * Collision information between two shapes when they collide.
22561
+ */ var Collision = /*#__PURE__*/ function() {
22562
+ function Collision() {}
22563
+ var _proto = Collision.prototype;
22564
+ /**
22565
+ * Get contact points.
22566
+ * @param outContacts - The result of contact points
22567
+ * @returns The actual count of contact points
22568
+ *
22569
+ * @remarks To optimize performance, the engine does not modify the length of the array you pass.
22570
+ * You need to obtain the actual number of contact points from the function's return value.
22571
+ */ _proto.getContacts = function getContacts(outContacts) {
22572
+ var nativeCollision = this._nativeCollision;
22573
+ var factor = this.shape.id === nativeCollision.shape1Id ? 1 : -1;
22574
+ var nativeContactPoints = nativeCollision.getContacts();
22575
+ var length = nativeContactPoints.size();
22576
+ for(var i = 0; i < length; i++){
22577
+ var _outContacts, _i;
22578
+ var nativeContractPoint = nativeContactPoints.get(i);
22579
+ var contact = (_outContacts = outContacts)[_i = i] || (_outContacts[_i] = new ContactPoint());
22580
+ contact.position.copyFrom(nativeContractPoint.position);
22581
+ contact.normal.copyFrom(nativeContractPoint.normal).scale(factor);
22582
+ contact.impulse.copyFrom(nativeContractPoint.impulse).scale(factor);
22583
+ contact.separation = nativeContractPoint.separation;
22584
+ }
22585
+ return length;
22586
+ };
22587
+ _create_class(Collision, [
22588
+ {
22589
+ key: "contactCount",
22590
+ get: /**
22591
+ * Count of contact points.
22592
+ */ function get() {
22593
+ return this._nativeCollision.contactCount;
22594
+ }
22595
+ }
22596
+ ]);
22597
+ return Collision;
22598
+ }();
22599
+
22600
+ /**
22601
+ * A physics scene is a collection of colliders and constraints which can interact.
22602
+ */ var PhysicsScene = /*#__PURE__*/ function() {
22603
+ function PhysicsScene(scene) {
22604
+ this._restTime = 0;
22605
+ this._fixedTimeStep = 1 / 60;
22606
+ this._colliders = new DisorderedArray();
22607
+ this._gravity = new engineMath.Vector3(0, -9.81, 0);
22608
+ this._scene = scene;
22609
+ this._setGravity = this._setGravity.bind(this);
22610
+ //@ts-ignore
22611
+ this._gravity._onValueChanged = this._setGravity;
22612
+ var engine = scene.engine;
22613
+ if (engine._physicsInitialized) {
22614
+ this._nativePhysicsScene = Engine._nativePhysics.createPhysicsScene(engine._nativePhysicsManager);
22615
+ }
22616
+ }
22617
+ var _proto = PhysicsScene.prototype;
22618
+ /**
22619
+ * Get whether two colliders can collide with each other.
22620
+ * @param layer1 - The first collision layer
22621
+ * @param layer2 - The second collision layer
22622
+ * @returns Whether the colliders should collide
22623
+ */ _proto.getColliderLayerCollision = function getColliderLayerCollision(layer1, layer2) {
22624
+ var index1 = Math.log2(layer1);
22625
+ var index2 = Math.log2(layer2);
22626
+ if (!Number.isInteger(index1) || !Number.isInteger(index1)) {
22627
+ throw new Error("Collision layer must be a single layer (Layer.Layer0 to Layer.Layer31)");
22628
+ }
22629
+ return Engine._nativePhysics.getColliderLayerCollision(index1, index2);
22630
+ };
22631
+ /**
22632
+ * Set whether two colliders can collide with each other.
22633
+ * @param layer1 - The first collision layer
22634
+ * @param layer2 - The second collision layer
22635
+ * @param isCollide - Whether the colliders should collide
22636
+ */ _proto.setColliderLayerCollision = function setColliderLayerCollision(layer1, layer2, isCollide) {
22637
+ var index1 = Math.log2(layer1);
22638
+ var index2 = Math.log2(layer2);
22639
+ if (!Number.isInteger(index1) || !Number.isInteger(index1)) {
22640
+ throw new Error("Collision layer must be a single layer (Layer.Layer0 to Layer.Layer31)");
22641
+ }
22642
+ Engine._nativePhysics.setColliderLayerCollision(index1, index2, isCollide);
22643
+ };
22644
+ _proto.raycast = function raycast(ray, distanceOrResult, layerMaskOrResult, outHitResult) {
22305
22645
  var hitResult;
22306
22646
  var distance = Number.MAX_VALUE;
22307
22647
  if (typeof distanceOrResult === "number") {
@@ -22481,6 +22821,7 @@ __decorate([
22481
22821
  for(var i = 0; i < step; i++){
22482
22822
  componentsManager.callScriptOnPhysicsUpdate();
22483
22823
  this._callColliderOnUpdate();
22824
+ nativePhysicsManager.setContactEventEnabled(this._hasCollisionEventConsumers());
22484
22825
  nativePhysicsManager.update(fixedTimeStep);
22485
22826
  this._callColliderOnLateUpdate();
22486
22827
  this._dispatchEvents(nativePhysicsManager.updateEvents());
@@ -22643,6 +22984,21 @@ __decorate([
22643
22984
  // Dispatch trigger events
22644
22985
  for(var i1 = 0, n1 = triggerEvents.length; i1 < n1; i1++)_loop1(i1);
22645
22986
  };
22987
+ _proto._hasCollisionEventConsumers = function _hasCollisionEventConsumers() {
22988
+ var _this__colliders = this._colliders, colliders = _this__colliders._elements;
22989
+ var _Script_prototype = Script.prototype, onCollisionEnter = _Script_prototype.onCollisionEnter, onCollisionExit = _Script_prototype.onCollisionExit, onCollisionStay = _Script_prototype.onCollisionStay;
22990
+ for(var i = this._colliders.length - 1; i >= 0; --i){
22991
+ var scripts = colliders[i].entity._scripts;
22992
+ var scriptElements = scripts._elements;
22993
+ for(var j = scripts.length - 1; j >= 0; --j){
22994
+ var script = scriptElements[j];
22995
+ if (script.onCollisionEnter !== onCollisionEnter || script.onCollisionExit !== onCollisionExit || script.onCollisionStay !== onCollisionStay) {
22996
+ return true;
22997
+ }
22998
+ }
22999
+ }
23000
+ return false;
23001
+ };
22646
23002
  _proto._setGravity = function _setGravity() {
22647
23003
  this._nativePhysicsScene.setGravity(this._gravity);
22648
23004
  };
@@ -31017,257 +31373,6 @@ Scene._fogColorProperty = ShaderProperty.getByName("scene_FogColor");
31017
31373
  Scene._fogParamsProperty = ShaderProperty.getByName("scene_FogParams");
31018
31374
  Scene._prefilterdDFGProperty = ShaderProperty.getByName("scene_PrefilteredDFG");
31019
31375
 
31020
- function _array_like_to_array(arr, len) {
31021
- if (len == null || len > arr.length) len = arr.length;
31022
-
31023
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
31024
-
31025
- return arr2;
31026
- }
31027
-
31028
- function _unsupported_iterable_to_array(o, minLen) {
31029
- if (!o) return;
31030
- if (typeof o === "string") return _array_like_to_array(o, minLen);
31031
-
31032
- var n = Object.prototype.toString.call(o).slice(8, -1);
31033
-
31034
- if (n === "Object" && o.constructor) n = o.constructor.name;
31035
- if (n === "Map" || n === "Set") return Array.from(n);
31036
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
31037
- }
31038
-
31039
- function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
31040
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
31041
-
31042
- if (it) return (it = it.call(o)).next.bind(it);
31043
- // Fallback for engines without symbol support
31044
- if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
31045
- if (it) o = it;
31046
-
31047
- var i = 0;
31048
-
31049
- return function() {
31050
- if (i >= o.length) return { done: true };
31051
-
31052
- return { done: false, value: o[i++] };
31053
- };
31054
- }
31055
-
31056
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
31057
- }
31058
-
31059
- /**
31060
- * Script class, used for logic writing.
31061
- */ var Script = /*#__PURE__*/ function(Component) {
31062
- _inherits(Script, Component);
31063
- function Script() {
31064
- var _this;
31065
- _this = Component.apply(this, arguments) || this, /** @internal */ _this._started = false, /** @internal */ _this._onStartIndex = -1, /** @internal */ _this._onUpdateIndex = -1, /** @internal */ _this._onLateUpdateIndex = -1, /** @internal */ _this._onPhysicsUpdateIndex = -1, /** @internal */ _this._onPreRenderIndex = -1, /** @internal */ _this._onPostRenderIndex = -1, /** @internal */ _this._entityScriptsIndex = -1;
31066
- return _this;
31067
- }
31068
- var _proto = Script.prototype;
31069
- /**
31070
- * Called when be enabled first time, only once.
31071
- */ _proto.onAwake = function onAwake() {};
31072
- /**
31073
- * Called when be enabled.
31074
- */ _proto.onEnable = function onEnable() {};
31075
- /**
31076
- * Called before the frame-level loop start for the first time, only once.
31077
- */ _proto.onStart = function onStart() {};
31078
- /**
31079
- * The main loop, called frame by frame.
31080
- * @param deltaTime - The delta time since last frame in seconds
31081
- */ _proto.onUpdate = function onUpdate(deltaTime) {};
31082
- /**
31083
- * Called after the onUpdate finished, called frame by frame.
31084
- * @param deltaTime - The delta time since last frame in seconds
31085
- */ _proto.onLateUpdate = function onLateUpdate(deltaTime) {};
31086
- /**
31087
- * Called before camera rendering, called per camera.
31088
- * @param camera - Current camera.
31089
- */ _proto.onBeginRender = function onBeginRender(camera) {};
31090
- /**
31091
- * Called after camera rendering, called per camera.
31092
- * @param camera - Current camera.
31093
- */ _proto.onEndRender = function onEndRender(camera) {};
31094
- /**
31095
- * Called before physics calculations, the number of times is related to the physical update frequency.
31096
- */ _proto.onPhysicsUpdate = function onPhysicsUpdate() {};
31097
- /**
31098
- * Called when the trigger enter.
31099
- * @param other - ColliderShape
31100
- */ _proto.onTriggerEnter = function onTriggerEnter(other) {};
31101
- /**
31102
- * Called when the trigger exit.
31103
- * @param other - ColliderShape
31104
- */ _proto.onTriggerExit = function onTriggerExit(other) {};
31105
- /**
31106
- * Called when the trigger stay.
31107
- * @remarks onTriggerStay is called every frame while the trigger stay.
31108
- * @param other - ColliderShape
31109
- */ _proto.onTriggerStay = function onTriggerStay(other) {};
31110
- /**
31111
- * Called when the collision enter.
31112
- * @param other - The Collision data associated with this collision event
31113
- * @remarks The Collision data will be invalid after this call, you should copy the data if needed.
31114
- */ _proto.onCollisionEnter = function onCollisionEnter(other) {};
31115
- /**
31116
- * Called when the collision exit.
31117
- * @param other - The Collision data associated with this collision event
31118
- * @remarks The Collision data will be invalid after this call, you should copy the data if needed.
31119
- */ _proto.onCollisionExit = function onCollisionExit(other) {};
31120
- /**
31121
- * Called when the collision stay.
31122
- * @param other - The Collision data associated with this collision event
31123
- * @remarks The Collision data will be invalid after this call, you should copy the data if needed.
31124
- */ _proto.onCollisionStay = function onCollisionStay(other) {};
31125
- /**
31126
- * Called when the pointer is down while over the ColliderShape.
31127
- * @param eventData - The pointer event data that triggered this callback
31128
- */ _proto.onPointerDown = function onPointerDown(eventData) {};
31129
- /**
31130
- * Called when the pointer is up while over the ColliderShape.
31131
- * @param eventData - The pointer event data that triggered this callback
31132
- */ _proto.onPointerUp = function onPointerUp(eventData) {};
31133
- /**
31134
- * Called when the pointer is down and up with the same collider.
31135
- * @param eventData - The pointer event data that triggered this callback
31136
- */ _proto.onPointerClick = function onPointerClick(eventData) {};
31137
- /**
31138
- * Called when the pointer enters the ColliderShape.
31139
- * @param eventData - The pointer event data that triggered this callback
31140
- */ _proto.onPointerEnter = function onPointerEnter(eventData) {};
31141
- /**
31142
- * Called when the pointer exits the ColliderShape.
31143
- * @param eventData - The pointer event data that triggered this callback
31144
- */ _proto.onPointerExit = function onPointerExit(eventData) {};
31145
- /**
31146
- * This function will be called when the pointer is pressed on the collider.
31147
- * @param eventData - The pointer event data that triggered this callback
31148
- */ _proto.onPointerBeginDrag = function onPointerBeginDrag(eventData) {};
31149
- /**
31150
- * When a drag collision occurs on the pointer, this function will be called every time it moves.
31151
- * @param eventData - The pointer event data that triggered this callback
31152
- */ _proto.onPointerDrag = function onPointerDrag(eventData) {};
31153
- /**
31154
- * When dragging ends, this function will be called (Dragged object).
31155
- * @param eventData - The pointer event data that triggered this callback
31156
- */ _proto.onPointerEndDrag = function onPointerEndDrag(eventData) {};
31157
- /**
31158
- * When dragging ends, this function will be called (Receiving object).
31159
- * @param eventData - The pointer event data that triggered this callback
31160
- */ _proto.onPointerDrop = function onPointerDrop(eventData) {};
31161
- /**
31162
- * Called when be disabled.
31163
- */ _proto.onDisable = function onDisable() {};
31164
- /**
31165
- * Called at the end of the destroyed frame.
31166
- */ _proto.onDestroy = function onDestroy() {};
31167
- /**
31168
- * @internal
31169
- */ _proto._onAwake = function _onAwake() {
31170
- this.onAwake();
31171
- };
31172
- /**
31173
- * @internal
31174
- */ _proto._onEnable = function _onEnable() {
31175
- this.onEnable();
31176
- };
31177
- /**
31178
- * @internal
31179
- */ _proto._onDisable = function _onDisable() {
31180
- this.onDisable();
31181
- };
31182
- /**
31183
- * @internal
31184
- */ _proto._onEnableInScene = function _onEnableInScene() {
31185
- var _this_scene = this.scene, componentsManager = _this_scene._componentsManager;
31186
- var prototype = Script.prototype;
31187
- if (!this._started) {
31188
- componentsManager.addOnStartScript(this);
31189
- }
31190
- if (this.onUpdate !== prototype.onUpdate) {
31191
- componentsManager.addOnUpdateScript(this);
31192
- }
31193
- if (this.onLateUpdate !== prototype.onLateUpdate) {
31194
- componentsManager.addOnLateUpdateScript(this);
31195
- }
31196
- if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
31197
- componentsManager.addOnPhysicsUpdateScript(this);
31198
- }
31199
- for(var _iterator = _create_for_of_iterator_helper_loose(Object.values(PointerMethods)), _step; !(_step = _iterator()).done;){
31200
- var pointerMethod = _step.value;
31201
- if (this[pointerMethod] === prototype[pointerMethod]) {
31202
- this[pointerMethod] = null;
31203
- }
31204
- }
31205
- this._entity._addScript(this);
31206
- };
31207
- /**
31208
- * @internal
31209
- */ _proto._onDisableInScene = function _onDisableInScene() {
31210
- var componentsManager = this.scene._componentsManager;
31211
- var prototype = Script.prototype;
31212
- if (!this._started) {
31213
- componentsManager.removeOnStartScript(this);
31214
- }
31215
- if (this.onUpdate !== prototype.onUpdate) {
31216
- componentsManager.removeOnUpdateScript(this);
31217
- }
31218
- if (this.onLateUpdate !== prototype.onLateUpdate) {
31219
- componentsManager.removeOnLateUpdateScript(this);
31220
- }
31221
- if (this.onPhysicsUpdate !== prototype.onPhysicsUpdate) {
31222
- componentsManager.removeOnPhysicsUpdateScript(this);
31223
- }
31224
- this._entity._removeScript(this);
31225
- };
31226
- /**
31227
- * @internal
31228
- */ _proto._onDestroy = function _onDestroy() {
31229
- Component.prototype._onDestroy.call(this);
31230
- this.onDestroy();
31231
- };
31232
- return Script;
31233
- }(Component);
31234
- __decorate([
31235
- ignoreClone
31236
- ], Script.prototype, "_started", void 0);
31237
- __decorate([
31238
- ignoreClone
31239
- ], Script.prototype, "_onStartIndex", void 0);
31240
- __decorate([
31241
- ignoreClone
31242
- ], Script.prototype, "_onUpdateIndex", void 0);
31243
- __decorate([
31244
- ignoreClone
31245
- ], Script.prototype, "_onLateUpdateIndex", void 0);
31246
- __decorate([
31247
- ignoreClone
31248
- ], Script.prototype, "_onPhysicsUpdateIndex", void 0);
31249
- __decorate([
31250
- ignoreClone
31251
- ], Script.prototype, "_onPreRenderIndex", void 0);
31252
- __decorate([
31253
- ignoreClone
31254
- ], Script.prototype, "_onPostRenderIndex", void 0);
31255
- __decorate([
31256
- ignoreClone
31257
- ], Script.prototype, "_entityScriptsIndex", void 0);
31258
- var PointerMethods = /*#__PURE__*/ function(PointerMethods) {
31259
- PointerMethods["onPointerDown"] = "onPointerDown";
31260
- PointerMethods["onPointerUp"] = "onPointerUp";
31261
- PointerMethods["onPointerClick"] = "onPointerClick";
31262
- PointerMethods["onPointerEnter"] = "onPointerEnter";
31263
- PointerMethods["onPointerExit"] = "onPointerExit";
31264
- PointerMethods["onPointerBeginDrag"] = "onPointerBeginDrag";
31265
- PointerMethods["onPointerDrag"] = "onPointerDrag";
31266
- PointerMethods["onPointerEndDrag"] = "onPointerEndDrag";
31267
- PointerMethods["onPointerDrop"] = "onPointerDrop";
31268
- return PointerMethods;
31269
- }({});
31270
-
31271
31376
  /**
31272
31377
  * Signal is a typed event mechanism for Galacean Engine.
31273
31378
  * @typeParam T - Tuple type of the signal arguments