@galacean/engine-core 1.2.0-alpha.0 → 1.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +494 -380
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +494 -380
- package/dist/module.js +590 -476
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/2d/atlas/types.d.ts +2 -0
- package/types/2d/text/TextRenderer.d.ts +1 -0
- package/types/SystemInfo.d.ts +2 -0
- package/types/mesh/PrimitiveMesh.d.ts +22 -0
- package/types/xr/XRPose.d.ts +15 -0
- package/types/xr/feature/XRFeature.d.ts +16 -0
- package/types/xr/feature/XRFeatureManager.d.ts +65 -0
- package/types/xr/feature/XRFeatureType.d.ts +13 -0
- package/types/xr/feature/camera/XRCameraManager.d.ts +26 -0
- package/types/xr/feature/hitTest/TrackableType.d.ts +10 -0
- package/types/xr/feature/hitTest/XRHitResult.d.ts +19 -0
- package/types/xr/feature/hitTest/XRHitTest.d.ts +39 -0
- package/types/xr/feature/hitTest/XRHitTestManager.d.ts +38 -0
- package/types/xr/feature/hitTest/XRHitTestType.d.ts +16 -0
- package/types/xr/feature/movementTracking/XRMovementTracking.d.ts +18 -0
- package/types/xr/feature/movementTracking/XRMovementTrackingManager.d.ts +10 -0
- package/types/xr/feature/movementTracking/XRMovementTrackingMode.d.ts +5 -0
- package/types/xr/feature/trackable/XRRequestTrackingState.d.ts +11 -0
- package/types/xr/feature/trackable/XRTrackableFeature.d.ts +38 -0
- package/types/xr/feature/trackable/XRTrackableManager.d.ts +41 -0
- package/types/xr/feature/trackable/XRTracked.d.ts +1 -0
- package/types/xr/feature/trackable/anchor/XRAnchor.d.ts +6 -0
- package/types/xr/feature/trackable/anchor/XRAnchorTracking.d.ts +37 -0
- package/types/xr/feature/trackable/anchor/XRAnchorTrackingManager.d.ts +20 -0
- package/types/xr/feature/trackable/anchor/XRRequestAnchor.d.ts +15 -0
- package/types/xr/feature/trackable/image/XRImageTracking.d.ts +24 -0
- package/types/xr/feature/trackable/image/XRImageTrackingManager.d.ts +31 -0
- package/types/xr/feature/trackable/image/XRReferenceImage.d.ts +11 -0
- package/types/xr/feature/trackable/image/XRRequestImage.d.ts +13 -0
- package/types/xr/feature/trackable/image/XRTrackedImage.d.ts +8 -0
- package/types/xr/feature/trackable/plane/XRPlaneMode.d.ts +13 -0
- package/types/xr/feature/trackable/plane/XRPlaneTracking.d.ts +23 -0
- package/types/xr/feature/trackable/plane/XRPlaneTrackingManager.d.ts +11 -0
- package/types/xr/feature/trackable/plane/XRRequestPlane.d.ts +12 -0
- package/types/xr/feature/trackable/plane/XRTrackedPlane.d.ts +20 -0
- package/types/xr/index.d.ts +25 -0
- package/types/xr/input/XRCamera.d.ts +15 -0
- package/types/xr/input/XRController.d.ts +38 -0
- package/types/xr/input/XRControllerPoseMode.d.ts +9 -0
- package/types/xr/input/XRInput.d.ts +8 -0
- package/types/xr/input/XRInputButton.d.ts +19 -0
- package/types/xr/input/XRInputEvent.d.ts +24 -0
- package/types/xr/input/XRInputEventType.d.ts +11 -0
- package/types/xr/input/XRInputManager.d.ts +31 -0
- package/types/xr/input/XRInputType.d.ts +23 -0
- package/types/xr/input/XRTargetRayMode.d.ts +12 -0
- package/types/xr/input/XRTrackedInputDevice.d.ts +21 -0
- package/types/xr/input/XRTrackedUpdateFlag.d.ts +11 -0
- package/types/xr/input/XRTrackingState.d.ts +11 -0
- package/types/xr/session/XRSessionManager.d.ts +45 -0
- package/types/xr/session/XRSessionMode.d.ts +8 -0
- package/types/xr/session/XRSessionState.d.ts +13 -0
- package/types/RenderPipeline/MeshRenderElement.d.ts +0 -19
- package/types/RenderPipeline/SpriteElement.d.ts +0 -15
- package/types/RenderPipeline/SpriteMaskElement.d.ts +0 -12
- package/types/RenderPipeline/TextRenderElement.d.ts +0 -8
- package/types/asset/IRefObject.d.ts +0 -2
- package/types/asset/RefObject.d.ts +0 -27
- package/types/base/Event.d.ts +0 -24
- package/types/base/Util.d.ts +0 -14
- /package/types/{2d/data/RenderData2D.d.ts → xr/feature/trackable/XRRequestTracking.d.ts} +0 -0
package/dist/miniprogram.js
CHANGED
|
@@ -60,347 +60,6 @@ function _inherits(subClass, superClass) {
|
|
|
60
60
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
* Common utility methods for math operations.
|
|
65
|
-
*/ var MathUtil = /*#__PURE__*/ function() {
|
|
66
|
-
function MathUtil() {}
|
|
67
|
-
/**
|
|
68
|
-
* Clamps the specified value.
|
|
69
|
-
* @param v - The specified value
|
|
70
|
-
* @param min - The min value
|
|
71
|
-
* @param max - The max value
|
|
72
|
-
* @returns The result of clamping a value between min and max
|
|
73
|
-
*/ MathUtil.clamp = function clamp(v, min, max) {
|
|
74
|
-
return Math.max(min, Math.min(max, v));
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Checks if a and b are almost equals.
|
|
78
|
-
* The absolute value of the difference between a and b is close to zero.
|
|
79
|
-
* @param a - The left value to compare
|
|
80
|
-
* @param b - The right value to compare
|
|
81
|
-
* @returns True if a almost equal to b, false otherwise
|
|
82
|
-
*/ MathUtil.equals = function equals(a, b) {
|
|
83
|
-
return Math.abs(a - b) <= MathUtil.zeroTolerance;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Determines whether the specified v is pow2.
|
|
87
|
-
* @param v - The specified v
|
|
88
|
-
* @returns True if the specified v is pow2, false otherwise
|
|
89
|
-
*/ MathUtil.isPowerOf2 = function isPowerOf2(v) {
|
|
90
|
-
return (v & v - 1) === 0;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Modify the specified r from radian to degree.
|
|
94
|
-
* @param r - The specified r
|
|
95
|
-
* @returns The degree value
|
|
96
|
-
*/ MathUtil.radianToDegree = function radianToDegree(r) {
|
|
97
|
-
return r * MathUtil.radToDegreeFactor;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Modify the specified d from degree to radian.
|
|
101
|
-
* @param d - The specified d
|
|
102
|
-
* @returns The radian value
|
|
103
|
-
*/ MathUtil.degreeToRadian = function degreeToRadian(d) {
|
|
104
|
-
return d * MathUtil.degreeToRadFactor;
|
|
105
|
-
};
|
|
106
|
-
return MathUtil;
|
|
107
|
-
}();
|
|
108
|
-
(function() {
|
|
109
|
-
/** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
|
|
110
|
-
})();
|
|
111
|
-
(function() {
|
|
112
|
-
/** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
|
|
113
|
-
})();
|
|
114
|
-
(function() {
|
|
115
|
-
/** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
|
|
116
|
-
})();
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Describes a color in the from of RGBA (in order: R, G, B, A).
|
|
120
|
-
*/ var Color = /*#__PURE__*/ function() {
|
|
121
|
-
function Color(r, g, b, a) {
|
|
122
|
-
if (r === void 0) r = 1;
|
|
123
|
-
if (g === void 0) g = 1;
|
|
124
|
-
if (b === void 0) b = 1;
|
|
125
|
-
if (a === void 0) a = 1;
|
|
126
|
-
/** @internal */ this._onValueChanged = null;
|
|
127
|
-
this._r = r;
|
|
128
|
-
this._g = g;
|
|
129
|
-
this._b = b;
|
|
130
|
-
this._a = a;
|
|
131
|
-
}
|
|
132
|
-
var _proto = Color.prototype;
|
|
133
|
-
/**
|
|
134
|
-
* Set the value of this color.
|
|
135
|
-
* @param r - The red component of the color
|
|
136
|
-
* @param g - The green component of the color
|
|
137
|
-
* @param b - The blue component of the color
|
|
138
|
-
* @param a - The alpha component of the color
|
|
139
|
-
* @returns This color.
|
|
140
|
-
*/ _proto.set = function set(r, g, b, a) {
|
|
141
|
-
this._r = r;
|
|
142
|
-
this._g = g;
|
|
143
|
-
this._b = b;
|
|
144
|
-
this._a = a;
|
|
145
|
-
this._onValueChanged && this._onValueChanged();
|
|
146
|
-
return this;
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* Determines the sum of this color and the specified color.
|
|
150
|
-
* @param color - The specified color
|
|
151
|
-
* @returns The added color
|
|
152
|
-
*/ _proto.add = function add(color) {
|
|
153
|
-
this._r += color._r;
|
|
154
|
-
this._g += color._g;
|
|
155
|
-
this._b += color._b;
|
|
156
|
-
this._a += color._a;
|
|
157
|
-
this._onValueChanged && this._onValueChanged();
|
|
158
|
-
return this;
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* Scale this color by the given value.
|
|
162
|
-
* @param s - The amount by which to scale the color
|
|
163
|
-
* @returns The scaled color
|
|
164
|
-
*/ _proto.scale = function scale(s) {
|
|
165
|
-
this._r *= s;
|
|
166
|
-
this._g *= s;
|
|
167
|
-
this._b *= s;
|
|
168
|
-
this._a *= s;
|
|
169
|
-
this._onValueChanged && this._onValueChanged();
|
|
170
|
-
return this;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Creates a clone of this color.
|
|
174
|
-
* @returns A clone of this color
|
|
175
|
-
*/ _proto.clone = function clone() {
|
|
176
|
-
var ret = new Color(this._r, this._g, this._b, this._a);
|
|
177
|
-
return ret;
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Copy from color like object.
|
|
181
|
-
* @param source - Color like object.
|
|
182
|
-
* @returns This vector
|
|
183
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
184
|
-
this._r = source.r;
|
|
185
|
-
this._g = source.g;
|
|
186
|
-
this._b = source.b;
|
|
187
|
-
this._a = source.a;
|
|
188
|
-
this._onValueChanged && this._onValueChanged();
|
|
189
|
-
return this;
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* Copy from array like object.
|
|
193
|
-
* @param source - Array like object
|
|
194
|
-
* @param offset - The start offset
|
|
195
|
-
* @returns This color
|
|
196
|
-
*/ _proto.copyFromArray = function copyFromArray(source, offset) {
|
|
197
|
-
if (offset === void 0) offset = 0;
|
|
198
|
-
this._r = source[offset];
|
|
199
|
-
this._g = source[offset + 1];
|
|
200
|
-
this._b = source[offset + 2];
|
|
201
|
-
this._a = source[offset + 3];
|
|
202
|
-
this._onValueChanged && this._onValueChanged();
|
|
203
|
-
return this;
|
|
204
|
-
};
|
|
205
|
-
/**
|
|
206
|
-
* Copy the value of this color to an array.
|
|
207
|
-
* @param out - The color
|
|
208
|
-
* @param outOffset - The start offset
|
|
209
|
-
*/ _proto.copyToArray = function copyToArray(out, outOffset) {
|
|
210
|
-
if (outOffset === void 0) outOffset = 0;
|
|
211
|
-
out[outOffset] = this._r;
|
|
212
|
-
out[outOffset + 1] = this._g;
|
|
213
|
-
out[outOffset + 2] = this._b;
|
|
214
|
-
out[outOffset + 3] = this._a;
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Modify components (r, g, b) of this color from gamma space to linear space.
|
|
218
|
-
* @param out - The color in linear space
|
|
219
|
-
* @returns The color in linear space
|
|
220
|
-
*/ _proto.toLinear = function toLinear(out) {
|
|
221
|
-
out._r = Color.gammaToLinearSpace(this._r);
|
|
222
|
-
out._g = Color.gammaToLinearSpace(this._g);
|
|
223
|
-
out._b = Color.gammaToLinearSpace(this._b);
|
|
224
|
-
this._onValueChanged && this._onValueChanged();
|
|
225
|
-
return out;
|
|
226
|
-
};
|
|
227
|
-
/**
|
|
228
|
-
* Modify components (r, g, b) of this color from linear space to gamma space.
|
|
229
|
-
* @param out - The color in gamma space
|
|
230
|
-
* @returns The color in gamma space
|
|
231
|
-
*/ _proto.toGamma = function toGamma(out) {
|
|
232
|
-
out._r = Color.linearToGammaSpace(this._r);
|
|
233
|
-
out._g = Color.linearToGammaSpace(this._g);
|
|
234
|
-
out._b = Color.linearToGammaSpace(this._b);
|
|
235
|
-
this._onValueChanged && this._onValueChanged();
|
|
236
|
-
return out;
|
|
237
|
-
};
|
|
238
|
-
/**
|
|
239
|
-
* Gets the brightness.
|
|
240
|
-
* @returns The Hue-Saturation-Brightness (HSB) saturation for this
|
|
241
|
-
*/ _proto.getBrightness = function getBrightness() {
|
|
242
|
-
var r = this.r;
|
|
243
|
-
var g = this.g;
|
|
244
|
-
var b = this.b;
|
|
245
|
-
var max = r;
|
|
246
|
-
var min = r;
|
|
247
|
-
if (g > max) max = g;
|
|
248
|
-
if (b > max) max = b;
|
|
249
|
-
if (g < min) min = g;
|
|
250
|
-
if (b < min) min = b;
|
|
251
|
-
return (max + min) / 2;
|
|
252
|
-
};
|
|
253
|
-
/**
|
|
254
|
-
* Serialize this color to a JSON representation.
|
|
255
|
-
* @return A JSON representation of this color
|
|
256
|
-
*/ _proto.toJSON = function toJSON() {
|
|
257
|
-
return {
|
|
258
|
-
r: this._r,
|
|
259
|
-
g: this._g,
|
|
260
|
-
b: this._b,
|
|
261
|
-
a: this._a
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
/**
|
|
265
|
-
* Modify a value from the gamma space to the linear space.
|
|
266
|
-
* @param value - The value in gamma space
|
|
267
|
-
* @returns The value in linear space
|
|
268
|
-
*/ Color.gammaToLinearSpace = function gammaToLinearSpace(value) {
|
|
269
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
|
|
270
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
|
|
271
|
-
if (value <= 0.0) return 0.0;
|
|
272
|
-
else if (value <= 0.04045) return value / 12.92;
|
|
273
|
-
else if (value < 1.0) return Math.pow((value + 0.055) / 1.055, 2.4);
|
|
274
|
-
else return Math.pow(value, 2.4);
|
|
275
|
-
};
|
|
276
|
-
/**
|
|
277
|
-
* Modify a value from the linear space to the gamma space.
|
|
278
|
-
* @param value - The value in linear space
|
|
279
|
-
* @returns The value in gamma space
|
|
280
|
-
*/ Color.linearToGammaSpace = function linearToGammaSpace(value) {
|
|
281
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
|
|
282
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
|
|
283
|
-
if (value <= 0.0) return 0.0;
|
|
284
|
-
else if (value < 0.0031308) return 12.92 * value;
|
|
285
|
-
else if (value < 1.0) return 1.055 * Math.pow(value, 0.41666) - 0.055;
|
|
286
|
-
else return Math.pow(value, 0.41666);
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
* Determines whether the specified colors are equals.
|
|
290
|
-
* @param left - The first color to compare
|
|
291
|
-
* @param right - The second color to compare
|
|
292
|
-
* @returns True if the specified colors are equals, false otherwise
|
|
293
|
-
*/ Color.equals = function equals(left, right) {
|
|
294
|
-
return MathUtil.equals(left._r, right._r) && MathUtil.equals(left._g, right._g) && MathUtil.equals(left._b, right._b) && MathUtil.equals(left._a, right._a);
|
|
295
|
-
};
|
|
296
|
-
/**
|
|
297
|
-
* Determines the sum of two colors.
|
|
298
|
-
* @param left - The first color to add
|
|
299
|
-
* @param right - The second color to add
|
|
300
|
-
* @param out - The sum of two colors
|
|
301
|
-
* @returns The added color
|
|
302
|
-
*/ Color.add = function add(left, right, out) {
|
|
303
|
-
out._r = left._r + right._r;
|
|
304
|
-
out._g = left._g + right._g;
|
|
305
|
-
out._b = left._b + right._b;
|
|
306
|
-
out._a = left._a + right._a;
|
|
307
|
-
out._onValueChanged && out._onValueChanged();
|
|
308
|
-
return out;
|
|
309
|
-
};
|
|
310
|
-
/**
|
|
311
|
-
* Determines the difference between two colors.
|
|
312
|
-
* @param left - The first color to subtract
|
|
313
|
-
* @param right - The second color to subtract
|
|
314
|
-
* @param out - The difference between two colors
|
|
315
|
-
*/ Color.subtract = function subtract(left, right, out) {
|
|
316
|
-
out._r = left._r - right._r;
|
|
317
|
-
out._g = left._g - right._g;
|
|
318
|
-
out._b = left._b - right._b;
|
|
319
|
-
out._a = left._a - right._a;
|
|
320
|
-
out._onValueChanged && out._onValueChanged();
|
|
321
|
-
};
|
|
322
|
-
/**
|
|
323
|
-
* Scale a color by the given value.
|
|
324
|
-
* @param left - The color to scale
|
|
325
|
-
* @param s - The amount by which to scale the color
|
|
326
|
-
* @param out - The scaled color
|
|
327
|
-
* @returns The scaled color
|
|
328
|
-
*/ Color.scale = function scale(left, s, out) {
|
|
329
|
-
out._r = left._r * s;
|
|
330
|
-
out._g = left._g * s;
|
|
331
|
-
out._b = left._b * s;
|
|
332
|
-
out._a = left._a * s;
|
|
333
|
-
out._onValueChanged && out._onValueChanged();
|
|
334
|
-
return out;
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* Performs a linear interpolation between two color.
|
|
338
|
-
* @param start - The first color
|
|
339
|
-
* @param end - The second color
|
|
340
|
-
* @param t - The blend amount where 0 returns start and 1 end
|
|
341
|
-
* @param out - The result of linear blending between two color
|
|
342
|
-
*/ Color.lerp = function lerp(start, end, t, out) {
|
|
343
|
-
var _r = start._r, _g = start._g, _b = start._b, _a = start._a;
|
|
344
|
-
out._r = _r + (end._r - _r) * t;
|
|
345
|
-
out._g = _g + (end._g - _g) * t;
|
|
346
|
-
out._b = _b + (end._b - _b) * t;
|
|
347
|
-
out._a = _a + (end._a - _a) * t;
|
|
348
|
-
out._onValueChanged && out._onValueChanged();
|
|
349
|
-
return out;
|
|
350
|
-
};
|
|
351
|
-
_create_class(Color, [
|
|
352
|
-
{
|
|
353
|
-
key: "r",
|
|
354
|
-
get: /**
|
|
355
|
-
* The red component of the color, 0~1.
|
|
356
|
-
*/ function get() {
|
|
357
|
-
return this._r;
|
|
358
|
-
},
|
|
359
|
-
set: function set(value) {
|
|
360
|
-
this._r = value;
|
|
361
|
-
this._onValueChanged && this._onValueChanged();
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
key: "g",
|
|
366
|
-
get: /**
|
|
367
|
-
* The green component of the color, 0~1.
|
|
368
|
-
*/ function get() {
|
|
369
|
-
return this._g;
|
|
370
|
-
},
|
|
371
|
-
set: function set(value) {
|
|
372
|
-
this._g = value;
|
|
373
|
-
this._onValueChanged && this._onValueChanged();
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
key: "b",
|
|
378
|
-
get: /**
|
|
379
|
-
* The blue component of the color, 0~1.
|
|
380
|
-
*/ function get() {
|
|
381
|
-
return this._b;
|
|
382
|
-
},
|
|
383
|
-
set: function set(value) {
|
|
384
|
-
this._b = value;
|
|
385
|
-
this._onValueChanged && this._onValueChanged();
|
|
386
|
-
}
|
|
387
|
-
},
|
|
388
|
-
{
|
|
389
|
-
key: "a",
|
|
390
|
-
get: /**
|
|
391
|
-
* The alpha component of the color, 0~1.
|
|
392
|
-
*/ function get() {
|
|
393
|
-
return this._a;
|
|
394
|
-
},
|
|
395
|
-
set: function set(value) {
|
|
396
|
-
this._a = value;
|
|
397
|
-
this._onValueChanged && this._onValueChanged();
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
]);
|
|
401
|
-
return Color;
|
|
402
|
-
}();
|
|
403
|
-
|
|
404
63
|
/**
|
|
405
64
|
* Sprite mask interaction.
|
|
406
65
|
*/ exports.SpriteMaskInteraction = void 0;
|
|
@@ -2121,20 +1780,28 @@ var ActiveChangeFlag;
|
|
|
2121
1780
|
this._enabled = value;
|
|
2122
1781
|
if (this._entity._isActiveInScene) {
|
|
2123
1782
|
if (value) {
|
|
2124
|
-
this._phasedActiveInScene
|
|
2125
|
-
|
|
1783
|
+
if (!this._phasedActiveInScene) {
|
|
1784
|
+
this._phasedActiveInScene = true;
|
|
1785
|
+
this._onEnableInScene();
|
|
1786
|
+
}
|
|
2126
1787
|
} else {
|
|
2127
|
-
this._phasedActiveInScene
|
|
2128
|
-
|
|
1788
|
+
if (this._phasedActiveInScene) {
|
|
1789
|
+
this._phasedActiveInScene = false;
|
|
1790
|
+
this._onDisableInScene();
|
|
1791
|
+
}
|
|
2129
1792
|
}
|
|
2130
1793
|
}
|
|
2131
1794
|
if (this._entity.isActiveInHierarchy) {
|
|
2132
1795
|
if (value) {
|
|
2133
|
-
this._phasedActive
|
|
2134
|
-
|
|
1796
|
+
if (!this._phasedActive) {
|
|
1797
|
+
this._phasedActive = true;
|
|
1798
|
+
this._onEnable();
|
|
1799
|
+
}
|
|
2135
1800
|
} else {
|
|
2136
|
-
this._phasedActive
|
|
2137
|
-
|
|
1801
|
+
if (this._phasedActive) {
|
|
1802
|
+
this._phasedActive = false;
|
|
1803
|
+
this._onDisable();
|
|
1804
|
+
}
|
|
2138
1805
|
}
|
|
2139
1806
|
}
|
|
2140
1807
|
}
|
|
@@ -9931,6 +9598,10 @@ var VertexElementIndex;
|
|
|
9931
9598
|
var sphereInfo = primitiveInfo;
|
|
9932
9599
|
PrimitiveMesh._setSphereData(this.resource, sphereInfo.radius, sphereInfo.segments, sphereInfo.noLongerAccessible, true, sphereInfo.vertexBuffer);
|
|
9933
9600
|
break;
|
|
9601
|
+
case 7:
|
|
9602
|
+
var CCSphereInfo = primitiveInfo;
|
|
9603
|
+
PrimitiveMesh._setSubdivisionSurfaceSphereData(this.resource, CCSphereInfo.radius, CCSphereInfo.step, CCSphereInfo.noLongerAccessible, true, CCSphereInfo.vertexBuffer);
|
|
9604
|
+
break;
|
|
9934
9605
|
case 1:
|
|
9935
9606
|
var cuboidInfo = primitiveInfo;
|
|
9936
9607
|
PrimitiveMesh._setCuboidData(this.resource, cuboidInfo.width, cuboidInfo.height, cuboidInfo.depth, cuboidInfo.noLongerAccessible, true, cuboidInfo.vertexBuffer);
|
|
@@ -9968,6 +9639,7 @@ var PrimitiveType;
|
|
|
9968
9639
|
PrimitiveType[PrimitiveType["Torus"] = 4] = "Torus";
|
|
9969
9640
|
PrimitiveType[PrimitiveType["Cone"] = 5] = "Cone";
|
|
9970
9641
|
PrimitiveType[PrimitiveType["Capsule"] = 6] = "Capsule";
|
|
9642
|
+
PrimitiveType[PrimitiveType["CCSphere"] = 7] = "CCSphere";
|
|
9971
9643
|
})(PrimitiveType || (PrimitiveType = {}));
|
|
9972
9644
|
/**
|
|
9973
9645
|
* @internal
|
|
@@ -9989,6 +9661,19 @@ var PrimitiveType;
|
|
|
9989
9661
|
}
|
|
9990
9662
|
return SphereRestoreInfo;
|
|
9991
9663
|
}(PrimitiveRestoreInfo);
|
|
9664
|
+
/**
|
|
9665
|
+
* @internal
|
|
9666
|
+
*/ var SubdivisionSurfaceSphereRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
|
|
9667
|
+
_inherits(SubdivisionSurfaceSphereRestoreInfo, PrimitiveRestoreInfo);
|
|
9668
|
+
function SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible) {
|
|
9669
|
+
var _this;
|
|
9670
|
+
_this = PrimitiveRestoreInfo.call(this, 7, vertexBuffer, noLongerAccessible) || this;
|
|
9671
|
+
_this.radius = radius;
|
|
9672
|
+
_this.step = step;
|
|
9673
|
+
return _this;
|
|
9674
|
+
}
|
|
9675
|
+
return SubdivisionSurfaceSphereRestoreInfo;
|
|
9676
|
+
}(PrimitiveRestoreInfo);
|
|
9992
9677
|
/**
|
|
9993
9678
|
* @internal
|
|
9994
9679
|
*/ var CuboidRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
|
|
@@ -10103,6 +9788,24 @@ var PrimitiveType;
|
|
|
10103
9788
|
return sphereMesh;
|
|
10104
9789
|
};
|
|
10105
9790
|
/**
|
|
9791
|
+
* Create a sphere mesh by implementing Catmull-Clark Surface Subdivision Algorithm.
|
|
9792
|
+
* Max step is limited to 6.
|
|
9793
|
+
* @param engine - Engine
|
|
9794
|
+
* @param radius - Sphere radius
|
|
9795
|
+
* @param step - Number of subdiv steps
|
|
9796
|
+
* @param noLongerAccessible - No longer access the vertices of the mesh after creation
|
|
9797
|
+
* @returns Sphere model mesh
|
|
9798
|
+
*/ PrimitiveMesh.createSubdivisionSurfaceSphere = function createSubdivisionSurfaceSphere(engine, radius, step, noLongerAccessible) {
|
|
9799
|
+
if (radius === void 0) radius = 0.5;
|
|
9800
|
+
if (step === void 0) step = 3;
|
|
9801
|
+
if (noLongerAccessible === void 0) noLongerAccessible = true;
|
|
9802
|
+
var sphereMesh = new ModelMesh(engine);
|
|
9803
|
+
PrimitiveMesh._setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, false);
|
|
9804
|
+
var vertexBuffer = sphereMesh.vertexBufferBindings[0].buffer;
|
|
9805
|
+
engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(sphereMesh, new SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible)));
|
|
9806
|
+
return sphereMesh;
|
|
9807
|
+
};
|
|
9808
|
+
/**
|
|
10106
9809
|
* Create a cuboid mesh.
|
|
10107
9810
|
* @param engine - Engine
|
|
10108
9811
|
* @param width - Cuboid width
|
|
@@ -10232,6 +9935,90 @@ var PrimitiveType;
|
|
|
10232
9935
|
};
|
|
10233
9936
|
/**
|
|
10234
9937
|
* @internal
|
|
9938
|
+
*/ PrimitiveMesh._setSubdivisionSurfaceSphereData = function _setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
9939
|
+
// Max step is limited to 6. Because 7 step will generate a single mesh with over 98306 vertices
|
|
9940
|
+
step = miniprogram.MathUtil.clamp(Math.floor(step), 1, 6);
|
|
9941
|
+
var positions = new Float32Array(3 * (6 * Math.pow(4, step) + 2));
|
|
9942
|
+
var cells = new Float32Array(24 * Math.pow(4, step));
|
|
9943
|
+
PrimitiveMesh._subdiveCatmullClark(step, positions, cells);
|
|
9944
|
+
var positionCount = positions.length / 3;
|
|
9945
|
+
var cellsCount = cells.length / 4;
|
|
9946
|
+
var poleOffset = positionCount + Math.pow(2, step + 1) - 1;
|
|
9947
|
+
// 16 extra vertices for pole uv
|
|
9948
|
+
// 2 vertices at each pole are idle
|
|
9949
|
+
var vertexCount = poleOffset + 16;
|
|
9950
|
+
var vertices = new Float32Array(vertexCount * 8);
|
|
9951
|
+
var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, positionCount, cellsCount * 6);
|
|
9952
|
+
var seamCount = 0;
|
|
9953
|
+
var seamVertices = {};
|
|
9954
|
+
// Get normals, uvs, and scale to radius
|
|
9955
|
+
for(var i = 0; i < positionCount; i++){
|
|
9956
|
+
var offset = 3 * i;
|
|
9957
|
+
var x = positions[offset];
|
|
9958
|
+
var y = positions[offset + 1];
|
|
9959
|
+
var z = positions[offset + 2];
|
|
9960
|
+
var reciprocalLength = 1 / Math.sqrt(x * x + y * y + z * z);
|
|
9961
|
+
x *= reciprocalLength;
|
|
9962
|
+
y *= reciprocalLength;
|
|
9963
|
+
z *= reciprocalLength;
|
|
9964
|
+
offset = 8 * i;
|
|
9965
|
+
vertices[offset] = x * radius;
|
|
9966
|
+
vertices[offset + 1] = y * radius;
|
|
9967
|
+
vertices[offset + 2] = z * radius;
|
|
9968
|
+
vertices[offset + 3] = x;
|
|
9969
|
+
vertices[offset + 4] = y;
|
|
9970
|
+
vertices[offset + 5] = z;
|
|
9971
|
+
vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
|
|
9972
|
+
vertices[offset + 7] = Math.acos(y) / Math.PI;
|
|
9973
|
+
if (vertices[offset + 6] === 0) {
|
|
9974
|
+
// Generate seam vertex
|
|
9975
|
+
var seamOffset = 8 * (positionCount + seamCount++);
|
|
9976
|
+
vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
|
|
9977
|
+
vertices[seamOffset + 6] = 1.0;
|
|
9978
|
+
// Cache seam vertex
|
|
9979
|
+
seamVertices[offset / 8] = seamOffset / 8;
|
|
9980
|
+
}
|
|
9981
|
+
}
|
|
9982
|
+
// Get indices
|
|
9983
|
+
var offset1 = 0;
|
|
9984
|
+
this._spherePoleIdx = 0;
|
|
9985
|
+
for(var i1 = 0; i1 < cellsCount; i1++){
|
|
9986
|
+
var idx = 4 * i1;
|
|
9987
|
+
var indexA = cells[idx];
|
|
9988
|
+
var indexB = cells[idx + 1];
|
|
9989
|
+
var indexC = cells[idx + 2];
|
|
9990
|
+
var indexD = cells[idx + 3];
|
|
9991
|
+
// Handle seam by replacing vertex index to seam vertex index if necessary
|
|
9992
|
+
var floatIndexA = 8 * indexA;
|
|
9993
|
+
var floatIndexB = 8 * indexB;
|
|
9994
|
+
var floatIndexC = 8 * indexC;
|
|
9995
|
+
var floatIndexD = 8 * indexD;
|
|
9996
|
+
// If center Z is negative
|
|
9997
|
+
if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
|
|
9998
|
+
vertices[floatIndexA + 6] === 0 && (indexA = seamVertices[indexA]);
|
|
9999
|
+
vertices[floatIndexB + 6] === 0 && (indexB = seamVertices[indexB]);
|
|
10000
|
+
vertices[floatIndexC + 6] === 0 && (indexC = seamVertices[indexC]);
|
|
10001
|
+
vertices[floatIndexD + 6] === 0 && (indexD = seamVertices[indexD]);
|
|
10002
|
+
}
|
|
10003
|
+
indices[offset1] = indexA;
|
|
10004
|
+
indices[offset1 + 1] = indexB;
|
|
10005
|
+
indices[offset1 + 2] = indexC;
|
|
10006
|
+
this._generateAndReplacePoleUV(indices, vertices, offset1, poleOffset);
|
|
10007
|
+
indices[offset1 + 3] = indexA;
|
|
10008
|
+
indices[offset1 + 4] = indexC;
|
|
10009
|
+
indices[offset1 + 5] = indexD;
|
|
10010
|
+
this._generateAndReplacePoleUV(indices, vertices, offset1 + 3, poleOffset);
|
|
10011
|
+
offset1 += 6;
|
|
10012
|
+
}
|
|
10013
|
+
if (!isRestoreMode) {
|
|
10014
|
+
var bounds = sphereMesh.bounds;
|
|
10015
|
+
bounds.min.set(-radius, -radius, -radius);
|
|
10016
|
+
bounds.max.set(radius, radius, radius);
|
|
10017
|
+
}
|
|
10018
|
+
PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
10019
|
+
};
|
|
10020
|
+
/**
|
|
10021
|
+
* @internal
|
|
10235
10022
|
*/ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
10236
10023
|
segments = Math.max(2, Math.floor(segments));
|
|
10237
10024
|
var count = segments + 1;
|
|
@@ -10292,6 +10079,135 @@ var PrimitiveType;
|
|
|
10292
10079
|
};
|
|
10293
10080
|
/**
|
|
10294
10081
|
* @internal
|
|
10082
|
+
*/ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
|
|
10083
|
+
var edges = new Map();
|
|
10084
|
+
var faces = new Array();
|
|
10085
|
+
positions.set(PrimitiveMesh._sphereSeedPositions);
|
|
10086
|
+
cells.set(PrimitiveMesh._sphereSeedCells);
|
|
10087
|
+
for(var i = 0; i < step; i++){
|
|
10088
|
+
var cellCount = 6 * Math.pow(4, i);
|
|
10089
|
+
var positionCount = 4 * cellCount + 2;
|
|
10090
|
+
edges.clear();
|
|
10091
|
+
faces.length = 0;
|
|
10092
|
+
// Get cell face's facePoint
|
|
10093
|
+
for(var j = 0; j < cellCount; j++){
|
|
10094
|
+
var face = faces[j] = {
|
|
10095
|
+
facePoint: new miniprogram.Vector3(),
|
|
10096
|
+
adjacentEdges: new Array(4)
|
|
10097
|
+
};
|
|
10098
|
+
// Get cell's edgePoint
|
|
10099
|
+
for(var k = 0; k < 4; k++){
|
|
10100
|
+
var offset = 3 * cells[4 * j + k];
|
|
10101
|
+
face.facePoint.x += 0.25 * positions[offset];
|
|
10102
|
+
face.facePoint.y += 0.25 * positions[offset + 1];
|
|
10103
|
+
face.facePoint.z += 0.25 * positions[offset + 2];
|
|
10104
|
+
}
|
|
10105
|
+
// Get cell edges
|
|
10106
|
+
for(var k1 = 0; k1 < 4; k1++){
|
|
10107
|
+
var vertexIdxA = cells[4 * j + k1];
|
|
10108
|
+
var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
|
|
10109
|
+
var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
|
|
10110
|
+
if (!edges.has(edgeIdxKey)) {
|
|
10111
|
+
var edge = {
|
|
10112
|
+
edgePoint: new miniprogram.Vector3(),
|
|
10113
|
+
edgePointIndex: undefined
|
|
10114
|
+
};
|
|
10115
|
+
var offsetA = 3 * vertexIdxA;
|
|
10116
|
+
var offsetB = 3 * vertexIdxB;
|
|
10117
|
+
edge.edgePoint.set(0.25 * (positions[offsetA] + positions[offsetB]), 0.25 * (positions[offsetA + 1] + positions[offsetB + 1]), 0.25 * (positions[offsetA + 2] + positions[offsetB + 2]));
|
|
10118
|
+
edges.set(edgeIdxKey, edge);
|
|
10119
|
+
}
|
|
10120
|
+
var edge1 = edges.get(edgeIdxKey);
|
|
10121
|
+
face.adjacentEdges[k1] = edge1;
|
|
10122
|
+
var edgePoint = edge1.edgePoint;
|
|
10123
|
+
var facePoint = face.facePoint;
|
|
10124
|
+
edgePoint.x += 0.25 * facePoint.x;
|
|
10125
|
+
edgePoint.y += 0.25 * facePoint.y;
|
|
10126
|
+
edgePoint.z += 0.25 * facePoint.z;
|
|
10127
|
+
}
|
|
10128
|
+
}
|
|
10129
|
+
var prePointCount = cellCount + 2;
|
|
10130
|
+
var edgePointOffset = prePointCount + cellCount;
|
|
10131
|
+
var pointIdx = 0;
|
|
10132
|
+
this._sphereEdgeIdx = 0;
|
|
10133
|
+
var preCells = cells.slice(0, 4 * cellCount);
|
|
10134
|
+
// Get New positions, which consists of updated positions of existing points, face points and edge points
|
|
10135
|
+
for(var j1 = 0; j1 < cellCount; j1++){
|
|
10136
|
+
// Add face point to new positions
|
|
10137
|
+
var face1 = faces[j1];
|
|
10138
|
+
face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
|
|
10139
|
+
// Get the face point index
|
|
10140
|
+
var ic = prePointCount + j1;
|
|
10141
|
+
var id = void 0, ib = void 0, temp = void 0;
|
|
10142
|
+
// ia -- id -- ia
|
|
10143
|
+
// | | |
|
|
10144
|
+
// ib -- ic -- ib
|
|
10145
|
+
// | | |
|
|
10146
|
+
// ia -- id -- ia
|
|
10147
|
+
for(var k2 = 0; k2 < 4; k2++){
|
|
10148
|
+
// Get the updated existing point index
|
|
10149
|
+
var ia = preCells[pointIdx++];
|
|
10150
|
+
// ib and id share four edge points in one cell
|
|
10151
|
+
switch(k2){
|
|
10152
|
+
case 0:
|
|
10153
|
+
{
|
|
10154
|
+
var edgeB = face1.adjacentEdges[k2 % 4];
|
|
10155
|
+
var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
|
|
10156
|
+
ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
|
|
10157
|
+
id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
|
|
10158
|
+
temp = id;
|
|
10159
|
+
break;
|
|
10160
|
+
}
|
|
10161
|
+
case 1:
|
|
10162
|
+
case 2:
|
|
10163
|
+
{
|
|
10164
|
+
var edgeB1 = face1.adjacentEdges[k2 % 4];
|
|
10165
|
+
id = ib;
|
|
10166
|
+
ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
|
|
10167
|
+
break;
|
|
10168
|
+
}
|
|
10169
|
+
case 3:
|
|
10170
|
+
{
|
|
10171
|
+
id = ib;
|
|
10172
|
+
ib = temp;
|
|
10173
|
+
break;
|
|
10174
|
+
}
|
|
10175
|
+
}
|
|
10176
|
+
var idx = 4 * (4 * j1 + k2);
|
|
10177
|
+
cells[idx] = ia;
|
|
10178
|
+
cells[idx + 1] = ib;
|
|
10179
|
+
cells[idx + 2] = ic;
|
|
10180
|
+
cells[idx + 3] = id;
|
|
10181
|
+
}
|
|
10182
|
+
}
|
|
10183
|
+
}
|
|
10184
|
+
};
|
|
10185
|
+
/**
|
|
10186
|
+
* Duplicate vertices at the poles and adjust their UV coordinates.
|
|
10187
|
+
*/ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
|
|
10188
|
+
var v = vertices[8 * indices[idx] + 7];
|
|
10189
|
+
if (v === 0 || v === 1) {
|
|
10190
|
+
var offset = 8 * indices[idx];
|
|
10191
|
+
var addedOffset = 8 * (poleOffset + this._spherePoleIdx);
|
|
10192
|
+
vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
|
|
10193
|
+
vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
|
|
10194
|
+
indices[idx] = poleOffset + this._spherePoleIdx++;
|
|
10195
|
+
}
|
|
10196
|
+
};
|
|
10197
|
+
/**
|
|
10198
|
+
* Get edge point index for subdivision surface sphere.
|
|
10199
|
+
*/ PrimitiveMesh._calculateEdgeIndex = function _calculateEdgeIndex(positions, edge, offset) {
|
|
10200
|
+
if (edge.edgePointIndex !== undefined) {
|
|
10201
|
+
return edge.edgePointIndex;
|
|
10202
|
+
} else {
|
|
10203
|
+
edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
|
|
10204
|
+
var index = offset + PrimitiveMesh._sphereEdgeIdx++;
|
|
10205
|
+
edge.edgePointIndex = index;
|
|
10206
|
+
return index;
|
|
10207
|
+
}
|
|
10208
|
+
};
|
|
10209
|
+
/**
|
|
10210
|
+
* @internal
|
|
10295
10211
|
*/ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
10296
10212
|
var halfWidth = width / 2;
|
|
10297
10213
|
var halfHeight = height / 2;
|
|
@@ -10921,6 +10837,68 @@ var PrimitiveType;
|
|
|
10921
10837
|
(function() {
|
|
10922
10838
|
PrimitiveMesh._tempVec30 = new miniprogram.Vector3();
|
|
10923
10839
|
})();
|
|
10840
|
+
(function() {
|
|
10841
|
+
PrimitiveMesh._sphereSeedPositions = new Float32Array([
|
|
10842
|
+
-1,
|
|
10843
|
+
1,
|
|
10844
|
+
1,
|
|
10845
|
+
-1,
|
|
10846
|
+
-1,
|
|
10847
|
+
1,
|
|
10848
|
+
1,
|
|
10849
|
+
-1,
|
|
10850
|
+
1,
|
|
10851
|
+
1,
|
|
10852
|
+
1,
|
|
10853
|
+
1,
|
|
10854
|
+
1,
|
|
10855
|
+
-1,
|
|
10856
|
+
-1,
|
|
10857
|
+
1,
|
|
10858
|
+
1,
|
|
10859
|
+
-1,
|
|
10860
|
+
-1,
|
|
10861
|
+
-1,
|
|
10862
|
+
-1,
|
|
10863
|
+
-1,
|
|
10864
|
+
1,
|
|
10865
|
+
-1
|
|
10866
|
+
]);
|
|
10867
|
+
})();
|
|
10868
|
+
(function() {
|
|
10869
|
+
PrimitiveMesh._sphereSeedCells = new Float32Array([
|
|
10870
|
+
0,
|
|
10871
|
+
1,
|
|
10872
|
+
2,
|
|
10873
|
+
3,
|
|
10874
|
+
3,
|
|
10875
|
+
2,
|
|
10876
|
+
4,
|
|
10877
|
+
5,
|
|
10878
|
+
5,
|
|
10879
|
+
4,
|
|
10880
|
+
6,
|
|
10881
|
+
7,
|
|
10882
|
+
7,
|
|
10883
|
+
0,
|
|
10884
|
+
3,
|
|
10885
|
+
5,
|
|
10886
|
+
7,
|
|
10887
|
+
6,
|
|
10888
|
+
1,
|
|
10889
|
+
0,
|
|
10890
|
+
6,
|
|
10891
|
+
4,
|
|
10892
|
+
2,
|
|
10893
|
+
1
|
|
10894
|
+
]);
|
|
10895
|
+
})();
|
|
10896
|
+
(function() {
|
|
10897
|
+
PrimitiveMesh._sphereEdgeIdx = 0;
|
|
10898
|
+
})();
|
|
10899
|
+
(function() {
|
|
10900
|
+
PrimitiveMesh._spherePoleIdx = 0;
|
|
10901
|
+
})();
|
|
10924
10902
|
|
|
10925
10903
|
/**
|
|
10926
10904
|
* Mesh skin data, equal glTF skins define
|
|
@@ -11465,8 +11443,10 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
|
|
|
11465
11443
|
}
|
|
11466
11444
|
mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
|
|
11467
11445
|
batchedQueue[curMeshIndex] = preElement;
|
|
11468
|
-
|
|
11469
|
-
|
|
11446
|
+
// Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
|
|
11447
|
+
// Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
|
|
11448
|
+
this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, exports.SetDataOptions.Discard);
|
|
11449
|
+
this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, exports.SetDataOptions.Discard);
|
|
11470
11450
|
};
|
|
11471
11451
|
_proto._getSubMeshFromPool = function _getSubMeshFromPool(start, count) {
|
|
11472
11452
|
var subMesh = this._subMeshPool.getFromPool();
|
|
@@ -12496,6 +12476,9 @@ var /**
|
|
|
12496
12476
|
__decorate([
|
|
12497
12477
|
assignmentClone
|
|
12498
12478
|
], SpriteMask.prototype, "influenceLayers", void 0);
|
|
12479
|
+
__decorate([
|
|
12480
|
+
ignoreClone
|
|
12481
|
+
], SpriteMask.prototype, "_verticesData", void 0);
|
|
12499
12482
|
__decorate([
|
|
12500
12483
|
ignoreClone
|
|
12501
12484
|
], SpriteMask.prototype, "_sprite", void 0);
|
|
@@ -12779,8 +12762,8 @@ var /**
|
|
|
12779
12762
|
} else {
|
|
12780
12763
|
word += char;
|
|
12781
12764
|
wordWidth += charInfo.xAdvance;
|
|
12782
|
-
wordMaxAscent =
|
|
12783
|
-
wordMaxDescent =
|
|
12765
|
+
wordMaxAscent = Math.max(wordMaxAscent, ascent);
|
|
12766
|
+
wordMaxDescent = Math.max(wordMaxDescent, descent);
|
|
12784
12767
|
}
|
|
12785
12768
|
}
|
|
12786
12769
|
}
|
|
@@ -13011,13 +12994,15 @@ var /**
|
|
|
13011
12994
|
];
|
|
13012
12995
|
})();
|
|
13013
12996
|
(function() {
|
|
13014
|
-
|
|
12997
|
+
// _heightMultiplier used to measure the height of text, but in miniprogram performance is different from h5.
|
|
12998
|
+
// so can set _heightMultiplier to adapt miniprogram, the larger the value, the worse the performance.
|
|
12999
|
+
/** @internal */ TextUtils._heightMultiplier = 2;
|
|
13015
13000
|
})();
|
|
13016
13001
|
(function() {
|
|
13017
|
-
TextUtils.
|
|
13002
|
+
/** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
|
|
13018
13003
|
})();
|
|
13019
13004
|
(function() {
|
|
13020
|
-
TextUtils.
|
|
13005
|
+
TextUtils._measureBaseline = "M";
|
|
13021
13006
|
})();
|
|
13022
13007
|
(function() {
|
|
13023
13008
|
TextUtils._baselineMultiplier = 1.4;
|
|
@@ -13100,7 +13085,8 @@ var /**
|
|
|
13100
13085
|
_proto._createFontAtlas = function _createFontAtlas() {
|
|
13101
13086
|
var _this = this, engine = _this._engine;
|
|
13102
13087
|
var fontAtlas = new FontAtlas(engine);
|
|
13103
|
-
var texture = new Texture2D(engine, 256, 256);
|
|
13088
|
+
var texture = new Texture2D(engine, 256, 256, exports.TextureFormat.R8G8B8A8, false);
|
|
13089
|
+
texture.filterMode = exports.TextureFilterMode.Bilinear;
|
|
13104
13090
|
fontAtlas.texture = texture;
|
|
13105
13091
|
fontAtlas.isGCIgnored = texture.isGCIgnored = true;
|
|
13106
13092
|
this._fontAtlases.push(fontAtlas);
|
|
@@ -13338,7 +13324,7 @@ var /**
|
|
|
13338
13324
|
/**
|
|
13339
13325
|
* @internal
|
|
13340
13326
|
*/ _proto._render = function _render(context) {
|
|
13341
|
-
if (this.
|
|
13327
|
+
if (this._isTextNoVisible()) {
|
|
13342
13328
|
return;
|
|
13343
13329
|
}
|
|
13344
13330
|
if (this._isContainDirtyFlag(0x10)) {
|
|
@@ -13430,8 +13416,8 @@ var /**
|
|
|
13430
13416
|
}
|
|
13431
13417
|
};
|
|
13432
13418
|
_proto._updateLocalData = function _updateLocalData() {
|
|
13433
|
-
var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
|
|
13434
13419
|
var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
|
|
13420
|
+
var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
|
|
13435
13421
|
var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
|
|
13436
13422
|
var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
|
|
13437
13423
|
var charRenderDataPool = TextRenderer._charRenderDataPool;
|
|
@@ -13499,7 +13485,7 @@ var /**
|
|
|
13499
13485
|
var left = startX * pixelsPerUnitReciprocal;
|
|
13500
13486
|
var right = (startX + w) * pixelsPerUnitReciprocal;
|
|
13501
13487
|
var top = (startY + ascent) * pixelsPerUnitReciprocal;
|
|
13502
|
-
var bottom = (startY - descent
|
|
13488
|
+
var bottom = (startY - descent) * pixelsPerUnitReciprocal;
|
|
13503
13489
|
localPositions.set(left, top, right, bottom);
|
|
13504
13490
|
i === firstLine && (maxY = Math.max(maxY, top));
|
|
13505
13491
|
minY = Math.min(minY, bottom);
|
|
@@ -13540,6 +13526,9 @@ var /**
|
|
|
13540
13526
|
Renderer1.prototype._onTransformChanged.call(this, bit);
|
|
13541
13527
|
this._setDirtyFlagTrue(0x4 | 0x8);
|
|
13542
13528
|
};
|
|
13529
|
+
_proto._isTextNoVisible = function _isTextNoVisible() {
|
|
13530
|
+
return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0;
|
|
13531
|
+
};
|
|
13543
13532
|
_create_class(TextRenderer, [
|
|
13544
13533
|
{
|
|
13545
13534
|
key: "color",
|
|
@@ -13742,6 +13731,16 @@ var /**
|
|
|
13742
13731
|
get: /**
|
|
13743
13732
|
* The bounding volume of the TextRenderer.
|
|
13744
13733
|
*/ function get() {
|
|
13734
|
+
if (this._isTextNoVisible()) {
|
|
13735
|
+
if (this._isContainDirtyFlag(0x8)) {
|
|
13736
|
+
var localBounds = this._localBounds;
|
|
13737
|
+
localBounds.min.set(0, 0, 0);
|
|
13738
|
+
localBounds.max.set(0, 0, 0);
|
|
13739
|
+
this._updateBounds(this._bounds);
|
|
13740
|
+
this._setDirtyFlagFalse(0x8);
|
|
13741
|
+
}
|
|
13742
|
+
return this._bounds;
|
|
13743
|
+
}
|
|
13745
13744
|
this._isContainDirtyFlag(0x1) && this._resetSubFont();
|
|
13746
13745
|
this._isContainDirtyFlag(0x2) && this._updateLocalData();
|
|
13747
13746
|
this._isContainDirtyFlag(0x4) && this._updatePosition();
|
|
@@ -15730,6 +15729,66 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
15730
15729
|
}
|
|
15731
15730
|
}
|
|
15732
15731
|
};
|
|
15732
|
+
/**
|
|
15733
|
+
* @internal
|
|
15734
|
+
*/ SystemInfo._detectSIMDSupported = function _detectSIMDSupported() {
|
|
15735
|
+
if (this._simdSupported === null) {
|
|
15736
|
+
this._simdSupported = WebAssembly.validate(new Uint8Array([
|
|
15737
|
+
0,
|
|
15738
|
+
97,
|
|
15739
|
+
115,
|
|
15740
|
+
109,
|
|
15741
|
+
1,
|
|
15742
|
+
0,
|
|
15743
|
+
0,
|
|
15744
|
+
0,
|
|
15745
|
+
1,
|
|
15746
|
+
4,
|
|
15747
|
+
1,
|
|
15748
|
+
96,
|
|
15749
|
+
0,
|
|
15750
|
+
0,
|
|
15751
|
+
3,
|
|
15752
|
+
3,
|
|
15753
|
+
2,
|
|
15754
|
+
0,
|
|
15755
|
+
0,
|
|
15756
|
+
5,
|
|
15757
|
+
3,
|
|
15758
|
+
1,
|
|
15759
|
+
0,
|
|
15760
|
+
1,
|
|
15761
|
+
12,
|
|
15762
|
+
1,
|
|
15763
|
+
0,
|
|
15764
|
+
10,
|
|
15765
|
+
22,
|
|
15766
|
+
2,
|
|
15767
|
+
12,
|
|
15768
|
+
0,
|
|
15769
|
+
65,
|
|
15770
|
+
0,
|
|
15771
|
+
65,
|
|
15772
|
+
0,
|
|
15773
|
+
65,
|
|
15774
|
+
0,
|
|
15775
|
+
252,
|
|
15776
|
+
10,
|
|
15777
|
+
0,
|
|
15778
|
+
0,
|
|
15779
|
+
11,
|
|
15780
|
+
7,
|
|
15781
|
+
0,
|
|
15782
|
+
65,
|
|
15783
|
+
0,
|
|
15784
|
+
253,
|
|
15785
|
+
15,
|
|
15786
|
+
26,
|
|
15787
|
+
11
|
|
15788
|
+
]));
|
|
15789
|
+
}
|
|
15790
|
+
return this._simdSupported;
|
|
15791
|
+
};
|
|
15733
15792
|
_create_class(SystemInfo, null, [
|
|
15734
15793
|
{
|
|
15735
15794
|
key: "devicePixelRatio",
|
|
@@ -15748,6 +15807,9 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
15748
15807
|
(function() {
|
|
15749
15808
|
/** The operating system is running on. */ SystemInfo.operatingSystem = "";
|
|
15750
15809
|
})();
|
|
15810
|
+
(function() {
|
|
15811
|
+
/** Whether the system support SIMD. */ SystemInfo._simdSupported = null;
|
|
15812
|
+
})();
|
|
15751
15813
|
SystemInfo._initialize();
|
|
15752
15814
|
|
|
15753
15815
|
/**
|
|
@@ -18581,6 +18643,8 @@ __decorate([
|
|
|
18581
18643
|
_this = ReferResource1.call(this, engine) || this;
|
|
18582
18644
|
/** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
|
|
18583
18645
|
;
|
|
18646
|
+
/** @internal */ _this._priority = 0 // todo: temporary resolution of submesh rendering order issue.
|
|
18647
|
+
;
|
|
18584
18648
|
_this._shaderData = new ShaderData(ShaderDataGroup.Material);
|
|
18585
18649
|
_this.shader = shader;
|
|
18586
18650
|
return _this;
|
|
@@ -19050,11 +19114,11 @@ ShaderPool.init();
|
|
|
19050
19114
|
}
|
|
19051
19115
|
var meshMagentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("unlit"));
|
|
19052
19116
|
meshMagentaMaterial.isGCIgnored = true;
|
|
19053
|
-
meshMagentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
|
|
19117
|
+
meshMagentaMaterial.shaderData.setColor("material_BaseColor", new miniprogram.Color(1.0, 0.0, 1.01, 1.0));
|
|
19054
19118
|
_this._meshMagentaMaterial = meshMagentaMaterial;
|
|
19055
19119
|
var particleMagentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("particle-shader"));
|
|
19056
19120
|
particleMagentaMaterial.isGCIgnored = true;
|
|
19057
|
-
particleMagentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
|
|
19121
|
+
particleMagentaMaterial.shaderData.setColor("material_BaseColor", new miniprogram.Color(1.0, 0.0, 1.01, 1.0));
|
|
19058
19122
|
_this._particleMagentaMaterial = particleMagentaMaterial;
|
|
19059
19123
|
var innerSettings = _this._settings;
|
|
19060
19124
|
var colorSpace = configuration.colorSpace || exports.ColorSpace.Linear;
|
|
@@ -21870,12 +21934,38 @@ var passNum = 0;
|
|
|
21870
21934
|
/**
|
|
21871
21935
|
* @internal
|
|
21872
21936
|
*/ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
|
|
21873
|
-
|
|
21937
|
+
var dataA = a.data;
|
|
21938
|
+
var dataB = b.data;
|
|
21939
|
+
var componentA = dataA.component;
|
|
21940
|
+
var componentB = dataB.component;
|
|
21941
|
+
var priorityOrder = componentA.priority - componentB.priority;
|
|
21942
|
+
if (priorityOrder !== 0) {
|
|
21943
|
+
return priorityOrder;
|
|
21944
|
+
}
|
|
21945
|
+
// make suer from the same renderer.
|
|
21946
|
+
if (componentA.instanceId === componentB.instanceId) {
|
|
21947
|
+
return dataA.material._priority - dataB.material._priority || componentA._distanceForSort - componentB._distanceForSort;
|
|
21948
|
+
} else {
|
|
21949
|
+
return componentA._distanceForSort - componentB._distanceForSort;
|
|
21950
|
+
}
|
|
21874
21951
|
};
|
|
21875
21952
|
/**
|
|
21876
21953
|
* @internal
|
|
21877
21954
|
*/ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
|
|
21878
|
-
|
|
21955
|
+
var dataA = a.data;
|
|
21956
|
+
var dataB = b.data;
|
|
21957
|
+
var componentA = dataA.component;
|
|
21958
|
+
var componentB = dataB.component;
|
|
21959
|
+
var priorityOrder = componentA.priority - componentB.priority;
|
|
21960
|
+
if (priorityOrder !== 0) {
|
|
21961
|
+
return priorityOrder;
|
|
21962
|
+
}
|
|
21963
|
+
// make suer from the same renderer.
|
|
21964
|
+
if (componentA.instanceId === componentB.instanceId) {
|
|
21965
|
+
return dataA.material._priority - dataB.material._priority || componentB._distanceForSort - componentA._distanceForSort;
|
|
21966
|
+
} else {
|
|
21967
|
+
return componentB._distanceForSort - componentA._distanceForSort;
|
|
21968
|
+
}
|
|
21879
21969
|
};
|
|
21880
21970
|
return RenderQueue;
|
|
21881
21971
|
}();
|
|
@@ -25246,6 +25336,7 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
25246
25336
|
_this = EngineObject1.call(this, null) || this;
|
|
25247
25337
|
_this.name = name;
|
|
25248
25338
|
_this./** @internal */ _curveBindings = [];
|
|
25339
|
+
_this./** @internal */ _updateFlagManager = new UpdateFlagManager();
|
|
25249
25340
|
_this._length = 0;
|
|
25250
25341
|
_this._events = [];
|
|
25251
25342
|
return _this;
|
|
@@ -25273,11 +25364,13 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
25273
25364
|
while(--index >= 0 && eventTime < events[index].time);
|
|
25274
25365
|
events.splice(index + 1, 0, newEvent);
|
|
25275
25366
|
}
|
|
25367
|
+
this._updateFlagManager.dispatch();
|
|
25276
25368
|
};
|
|
25277
25369
|
/**
|
|
25278
25370
|
* Clears all events from the clip.
|
|
25279
25371
|
*/ _proto.clearEvents = function clearEvents() {
|
|
25280
25372
|
this._events.length = 0;
|
|
25373
|
+
this._updateFlagManager.dispatch();
|
|
25281
25374
|
};
|
|
25282
25375
|
_proto.addCurveBinding = function addCurveBinding(entityPath, componentType, propertyOrSetPropertyPathOrComponentIndex, curveOrSetPropertyPathOrGetPropertyPath, curveOrGetPropertyPath, curve) {
|
|
25283
25376
|
var curveBinding = new AnimationClipCurveBinding();
|
|
@@ -26834,26 +26927,31 @@ exports.AnimatorLayerBlendingMode = void 0;
|
|
|
26834
26927
|
}
|
|
26835
26928
|
};
|
|
26836
26929
|
_proto._saveAnimatorEventHandlers = function _saveAnimatorEventHandlers(state, animatorStateData) {
|
|
26930
|
+
var _this = this;
|
|
26837
26931
|
var eventHandlerPool = this._animationEventHandlerPool;
|
|
26838
26932
|
var scripts = [];
|
|
26839
|
-
this._entity.getComponents(Script, scripts);
|
|
26840
|
-
var scriptCount = scripts.length;
|
|
26841
26933
|
var eventHandlers = animatorStateData.eventHandlers;
|
|
26842
|
-
var
|
|
26843
|
-
|
|
26844
|
-
|
|
26845
|
-
var
|
|
26846
|
-
|
|
26847
|
-
var
|
|
26848
|
-
|
|
26849
|
-
|
|
26850
|
-
|
|
26851
|
-
|
|
26852
|
-
|
|
26853
|
-
|
|
26934
|
+
var clipChangedListener = function() {
|
|
26935
|
+
_this._entity.getComponents(Script, scripts);
|
|
26936
|
+
var scriptCount = scripts.length;
|
|
26937
|
+
var events = state.clip.events;
|
|
26938
|
+
eventHandlers.length = 0;
|
|
26939
|
+
for(var i = 0, n = events.length; i < n; i++){
|
|
26940
|
+
var event = events[i];
|
|
26941
|
+
var eventHandler = eventHandlerPool.getFromPool();
|
|
26942
|
+
var funcName = event.functionName;
|
|
26943
|
+
var handlers = eventHandler.handlers;
|
|
26944
|
+
eventHandler.event = event;
|
|
26945
|
+
handlers.length = 0;
|
|
26946
|
+
for(var j = scriptCount - 1; j >= 0; j--){
|
|
26947
|
+
var handler = scripts[j][funcName];
|
|
26948
|
+
handler && handlers.push(handler);
|
|
26949
|
+
}
|
|
26950
|
+
eventHandlers.push(eventHandler);
|
|
26854
26951
|
}
|
|
26855
|
-
|
|
26856
|
-
|
|
26952
|
+
};
|
|
26953
|
+
clipChangedListener();
|
|
26954
|
+
state._updateFlagManager.addListener(clipChangedListener);
|
|
26857
26955
|
};
|
|
26858
26956
|
_proto._clearCrossData = function _clearCrossData(animatorLayerData) {
|
|
26859
26957
|
animatorLayerData.crossCurveMark++;
|
|
@@ -27464,9 +27562,11 @@ __decorate([
|
|
|
27464
27562
|
this./** @internal */ _onStateEnterScripts = [];
|
|
27465
27563
|
this./** @internal */ _onStateUpdateScripts = [];
|
|
27466
27564
|
this./** @internal */ _onStateExitScripts = [];
|
|
27565
|
+
this./** @internal */ _updateFlagManager = new UpdateFlagManager();
|
|
27467
27566
|
this._clipStartTime = 0;
|
|
27468
27567
|
this._clipEndTime = 1;
|
|
27469
27568
|
this._transitions = [];
|
|
27569
|
+
this._onClipChanged = this._onClipChanged.bind(this);
|
|
27470
27570
|
}
|
|
27471
27571
|
var _proto = AnimatorState.prototype;
|
|
27472
27572
|
/**
|
|
@@ -27540,6 +27640,11 @@ __decorate([
|
|
|
27540
27640
|
index2 !== -1 && this._onStateExitScripts.splice(index2, 1);
|
|
27541
27641
|
}
|
|
27542
27642
|
};
|
|
27643
|
+
/**
|
|
27644
|
+
* @internal
|
|
27645
|
+
*/ _proto._onClipChanged = function _onClipChanged() {
|
|
27646
|
+
this._updateFlagManager.dispatch();
|
|
27647
|
+
};
|
|
27543
27648
|
_create_class(AnimatorState, [
|
|
27544
27649
|
{
|
|
27545
27650
|
key: "transitions",
|
|
@@ -27557,8 +27662,17 @@ __decorate([
|
|
|
27557
27662
|
return this._clip;
|
|
27558
27663
|
},
|
|
27559
27664
|
set: function set(clip) {
|
|
27665
|
+
var lastClip = this._clip;
|
|
27666
|
+
if (lastClip === clip) {
|
|
27667
|
+
return;
|
|
27668
|
+
}
|
|
27669
|
+
if (lastClip) {
|
|
27670
|
+
lastClip._updateFlagManager.removeListener(this._onClipChanged);
|
|
27671
|
+
}
|
|
27560
27672
|
this._clip = clip;
|
|
27561
27673
|
this._clipEndTime = Math.min(this._clipEndTime, 1);
|
|
27674
|
+
this._onClipChanged();
|
|
27675
|
+
clip._updateFlagManager.addListener(this._onClipChanged);
|
|
27562
27676
|
}
|
|
27563
27677
|
},
|
|
27564
27678
|
{
|