@galacean/engine-core 1.2.0-alpha.0 → 1.2.0-alpha.2
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 +664 -566
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +664 -566
- package/dist/module.js +760 -662
- 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/Camera.d.ts +11 -5
- package/types/Engine.d.ts +4 -2
- package/types/SystemInfo.d.ts +2 -0
- package/types/Utils.d.ts +6 -0
- package/types/asset/AssetType.d.ts +2 -0
- package/types/asset/ResourceManager.d.ts +2 -0
- package/types/input/InputManager.d.ts +0 -2
- package/types/input/interface/IInput.d.ts +0 -8
- package/types/mesh/PrimitiveMesh.d.ts +22 -0
- package/types/shaderlib/ShaderFactory.d.ts +5 -1
- 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/main.js
CHANGED
|
@@ -59,347 +59,6 @@ function _inherits(subClass, superClass) {
|
|
|
59
59
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
* Common utility methods for math operations.
|
|
64
|
-
*/ var MathUtil = /*#__PURE__*/ function() {
|
|
65
|
-
function MathUtil() {}
|
|
66
|
-
/**
|
|
67
|
-
* Clamps the specified value.
|
|
68
|
-
* @param v - The specified value
|
|
69
|
-
* @param min - The min value
|
|
70
|
-
* @param max - The max value
|
|
71
|
-
* @returns The result of clamping a value between min and max
|
|
72
|
-
*/ MathUtil.clamp = function clamp(v, min, max) {
|
|
73
|
-
return Math.max(min, Math.min(max, v));
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Checks if a and b are almost equals.
|
|
77
|
-
* The absolute value of the difference between a and b is close to zero.
|
|
78
|
-
* @param a - The left value to compare
|
|
79
|
-
* @param b - The right value to compare
|
|
80
|
-
* @returns True if a almost equal to b, false otherwise
|
|
81
|
-
*/ MathUtil.equals = function equals(a, b) {
|
|
82
|
-
return Math.abs(a - b) <= MathUtil.zeroTolerance;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Determines whether the specified v is pow2.
|
|
86
|
-
* @param v - The specified v
|
|
87
|
-
* @returns True if the specified v is pow2, false otherwise
|
|
88
|
-
*/ MathUtil.isPowerOf2 = function isPowerOf2(v) {
|
|
89
|
-
return (v & v - 1) === 0;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Modify the specified r from radian to degree.
|
|
93
|
-
* @param r - The specified r
|
|
94
|
-
* @returns The degree value
|
|
95
|
-
*/ MathUtil.radianToDegree = function radianToDegree(r) {
|
|
96
|
-
return r * MathUtil.radToDegreeFactor;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Modify the specified d from degree to radian.
|
|
100
|
-
* @param d - The specified d
|
|
101
|
-
* @returns The radian value
|
|
102
|
-
*/ MathUtil.degreeToRadian = function degreeToRadian(d) {
|
|
103
|
-
return d * MathUtil.degreeToRadFactor;
|
|
104
|
-
};
|
|
105
|
-
return MathUtil;
|
|
106
|
-
}();
|
|
107
|
-
(function() {
|
|
108
|
-
/** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
|
|
109
|
-
})();
|
|
110
|
-
(function() {
|
|
111
|
-
/** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
|
|
112
|
-
})();
|
|
113
|
-
(function() {
|
|
114
|
-
/** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
|
|
115
|
-
})();
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Describes a color in the from of RGBA (in order: R, G, B, A).
|
|
119
|
-
*/ var Color = /*#__PURE__*/ function() {
|
|
120
|
-
function Color(r, g, b, a) {
|
|
121
|
-
if (r === void 0) r = 1;
|
|
122
|
-
if (g === void 0) g = 1;
|
|
123
|
-
if (b === void 0) b = 1;
|
|
124
|
-
if (a === void 0) a = 1;
|
|
125
|
-
/** @internal */ this._onValueChanged = null;
|
|
126
|
-
this._r = r;
|
|
127
|
-
this._g = g;
|
|
128
|
-
this._b = b;
|
|
129
|
-
this._a = a;
|
|
130
|
-
}
|
|
131
|
-
var _proto = Color.prototype;
|
|
132
|
-
/**
|
|
133
|
-
* Set the value of this color.
|
|
134
|
-
* @param r - The red component of the color
|
|
135
|
-
* @param g - The green component of the color
|
|
136
|
-
* @param b - The blue component of the color
|
|
137
|
-
* @param a - The alpha component of the color
|
|
138
|
-
* @returns This color.
|
|
139
|
-
*/ _proto.set = function set(r, g, b, a) {
|
|
140
|
-
this._r = r;
|
|
141
|
-
this._g = g;
|
|
142
|
-
this._b = b;
|
|
143
|
-
this._a = a;
|
|
144
|
-
this._onValueChanged && this._onValueChanged();
|
|
145
|
-
return this;
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Determines the sum of this color and the specified color.
|
|
149
|
-
* @param color - The specified color
|
|
150
|
-
* @returns The added color
|
|
151
|
-
*/ _proto.add = function add(color) {
|
|
152
|
-
this._r += color._r;
|
|
153
|
-
this._g += color._g;
|
|
154
|
-
this._b += color._b;
|
|
155
|
-
this._a += color._a;
|
|
156
|
-
this._onValueChanged && this._onValueChanged();
|
|
157
|
-
return this;
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Scale this color by the given value.
|
|
161
|
-
* @param s - The amount by which to scale the color
|
|
162
|
-
* @returns The scaled color
|
|
163
|
-
*/ _proto.scale = function scale(s) {
|
|
164
|
-
this._r *= s;
|
|
165
|
-
this._g *= s;
|
|
166
|
-
this._b *= s;
|
|
167
|
-
this._a *= s;
|
|
168
|
-
this._onValueChanged && this._onValueChanged();
|
|
169
|
-
return this;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Creates a clone of this color.
|
|
173
|
-
* @returns A clone of this color
|
|
174
|
-
*/ _proto.clone = function clone() {
|
|
175
|
-
var ret = new Color(this._r, this._g, this._b, this._a);
|
|
176
|
-
return ret;
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* Copy from color like object.
|
|
180
|
-
* @param source - Color like object.
|
|
181
|
-
* @returns This vector
|
|
182
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
183
|
-
this._r = source.r;
|
|
184
|
-
this._g = source.g;
|
|
185
|
-
this._b = source.b;
|
|
186
|
-
this._a = source.a;
|
|
187
|
-
this._onValueChanged && this._onValueChanged();
|
|
188
|
-
return this;
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* Copy from array like object.
|
|
192
|
-
* @param source - Array like object
|
|
193
|
-
* @param offset - The start offset
|
|
194
|
-
* @returns This color
|
|
195
|
-
*/ _proto.copyFromArray = function copyFromArray(source, offset) {
|
|
196
|
-
if (offset === void 0) offset = 0;
|
|
197
|
-
this._r = source[offset];
|
|
198
|
-
this._g = source[offset + 1];
|
|
199
|
-
this._b = source[offset + 2];
|
|
200
|
-
this._a = source[offset + 3];
|
|
201
|
-
this._onValueChanged && this._onValueChanged();
|
|
202
|
-
return this;
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* Copy the value of this color to an array.
|
|
206
|
-
* @param out - The color
|
|
207
|
-
* @param outOffset - The start offset
|
|
208
|
-
*/ _proto.copyToArray = function copyToArray(out, outOffset) {
|
|
209
|
-
if (outOffset === void 0) outOffset = 0;
|
|
210
|
-
out[outOffset] = this._r;
|
|
211
|
-
out[outOffset + 1] = this._g;
|
|
212
|
-
out[outOffset + 2] = this._b;
|
|
213
|
-
out[outOffset + 3] = this._a;
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* Modify components (r, g, b) of this color from gamma space to linear space.
|
|
217
|
-
* @param out - The color in linear space
|
|
218
|
-
* @returns The color in linear space
|
|
219
|
-
*/ _proto.toLinear = function toLinear(out) {
|
|
220
|
-
out._r = Color.gammaToLinearSpace(this._r);
|
|
221
|
-
out._g = Color.gammaToLinearSpace(this._g);
|
|
222
|
-
out._b = Color.gammaToLinearSpace(this._b);
|
|
223
|
-
this._onValueChanged && this._onValueChanged();
|
|
224
|
-
return out;
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* Modify components (r, g, b) of this color from linear space to gamma space.
|
|
228
|
-
* @param out - The color in gamma space
|
|
229
|
-
* @returns The color in gamma space
|
|
230
|
-
*/ _proto.toGamma = function toGamma(out) {
|
|
231
|
-
out._r = Color.linearToGammaSpace(this._r);
|
|
232
|
-
out._g = Color.linearToGammaSpace(this._g);
|
|
233
|
-
out._b = Color.linearToGammaSpace(this._b);
|
|
234
|
-
this._onValueChanged && this._onValueChanged();
|
|
235
|
-
return out;
|
|
236
|
-
};
|
|
237
|
-
/**
|
|
238
|
-
* Gets the brightness.
|
|
239
|
-
* @returns The Hue-Saturation-Brightness (HSB) saturation for this
|
|
240
|
-
*/ _proto.getBrightness = function getBrightness() {
|
|
241
|
-
var r = this.r;
|
|
242
|
-
var g = this.g;
|
|
243
|
-
var b = this.b;
|
|
244
|
-
var max = r;
|
|
245
|
-
var min = r;
|
|
246
|
-
if (g > max) max = g;
|
|
247
|
-
if (b > max) max = b;
|
|
248
|
-
if (g < min) min = g;
|
|
249
|
-
if (b < min) min = b;
|
|
250
|
-
return (max + min) / 2;
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* Serialize this color to a JSON representation.
|
|
254
|
-
* @return A JSON representation of this color
|
|
255
|
-
*/ _proto.toJSON = function toJSON() {
|
|
256
|
-
return {
|
|
257
|
-
r: this._r,
|
|
258
|
-
g: this._g,
|
|
259
|
-
b: this._b,
|
|
260
|
-
a: this._a
|
|
261
|
-
};
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* Modify a value from the gamma space to the linear space.
|
|
265
|
-
* @param value - The value in gamma space
|
|
266
|
-
* @returns The value in linear space
|
|
267
|
-
*/ Color.gammaToLinearSpace = function gammaToLinearSpace(value) {
|
|
268
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
|
|
269
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
|
|
270
|
-
if (value <= 0.0) return 0.0;
|
|
271
|
-
else if (value <= 0.04045) return value / 12.92;
|
|
272
|
-
else if (value < 1.0) return Math.pow((value + 0.055) / 1.055, 2.4);
|
|
273
|
-
else return Math.pow(value, 2.4);
|
|
274
|
-
};
|
|
275
|
-
/**
|
|
276
|
-
* Modify a value from the linear space to the gamma space.
|
|
277
|
-
* @param value - The value in linear space
|
|
278
|
-
* @returns The value in gamma space
|
|
279
|
-
*/ Color.linearToGammaSpace = function linearToGammaSpace(value) {
|
|
280
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
|
|
281
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
|
|
282
|
-
if (value <= 0.0) return 0.0;
|
|
283
|
-
else if (value < 0.0031308) return 12.92 * value;
|
|
284
|
-
else if (value < 1.0) return 1.055 * Math.pow(value, 0.41666) - 0.055;
|
|
285
|
-
else return Math.pow(value, 0.41666);
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* Determines whether the specified colors are equals.
|
|
289
|
-
* @param left - The first color to compare
|
|
290
|
-
* @param right - The second color to compare
|
|
291
|
-
* @returns True if the specified colors are equals, false otherwise
|
|
292
|
-
*/ Color.equals = function equals(left, right) {
|
|
293
|
-
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);
|
|
294
|
-
};
|
|
295
|
-
/**
|
|
296
|
-
* Determines the sum of two colors.
|
|
297
|
-
* @param left - The first color to add
|
|
298
|
-
* @param right - The second color to add
|
|
299
|
-
* @param out - The sum of two colors
|
|
300
|
-
* @returns The added color
|
|
301
|
-
*/ Color.add = function add(left, right, out) {
|
|
302
|
-
out._r = left._r + right._r;
|
|
303
|
-
out._g = left._g + right._g;
|
|
304
|
-
out._b = left._b + right._b;
|
|
305
|
-
out._a = left._a + right._a;
|
|
306
|
-
out._onValueChanged && out._onValueChanged();
|
|
307
|
-
return out;
|
|
308
|
-
};
|
|
309
|
-
/**
|
|
310
|
-
* Determines the difference between two colors.
|
|
311
|
-
* @param left - The first color to subtract
|
|
312
|
-
* @param right - The second color to subtract
|
|
313
|
-
* @param out - The difference between two colors
|
|
314
|
-
*/ Color.subtract = function subtract(left, right, out) {
|
|
315
|
-
out._r = left._r - right._r;
|
|
316
|
-
out._g = left._g - right._g;
|
|
317
|
-
out._b = left._b - right._b;
|
|
318
|
-
out._a = left._a - right._a;
|
|
319
|
-
out._onValueChanged && out._onValueChanged();
|
|
320
|
-
};
|
|
321
|
-
/**
|
|
322
|
-
* Scale a color by the given value.
|
|
323
|
-
* @param left - The color to scale
|
|
324
|
-
* @param s - The amount by which to scale the color
|
|
325
|
-
* @param out - The scaled color
|
|
326
|
-
* @returns The scaled color
|
|
327
|
-
*/ Color.scale = function scale(left, s, out) {
|
|
328
|
-
out._r = left._r * s;
|
|
329
|
-
out._g = left._g * s;
|
|
330
|
-
out._b = left._b * s;
|
|
331
|
-
out._a = left._a * s;
|
|
332
|
-
out._onValueChanged && out._onValueChanged();
|
|
333
|
-
return out;
|
|
334
|
-
};
|
|
335
|
-
/**
|
|
336
|
-
* Performs a linear interpolation between two color.
|
|
337
|
-
* @param start - The first color
|
|
338
|
-
* @param end - The second color
|
|
339
|
-
* @param t - The blend amount where 0 returns start and 1 end
|
|
340
|
-
* @param out - The result of linear blending between two color
|
|
341
|
-
*/ Color.lerp = function lerp(start, end, t, out) {
|
|
342
|
-
var _r = start._r, _g = start._g, _b = start._b, _a = start._a;
|
|
343
|
-
out._r = _r + (end._r - _r) * t;
|
|
344
|
-
out._g = _g + (end._g - _g) * t;
|
|
345
|
-
out._b = _b + (end._b - _b) * t;
|
|
346
|
-
out._a = _a + (end._a - _a) * t;
|
|
347
|
-
out._onValueChanged && out._onValueChanged();
|
|
348
|
-
return out;
|
|
349
|
-
};
|
|
350
|
-
_create_class(Color, [
|
|
351
|
-
{
|
|
352
|
-
key: "r",
|
|
353
|
-
get: /**
|
|
354
|
-
* The red component of the color, 0~1.
|
|
355
|
-
*/ function get() {
|
|
356
|
-
return this._r;
|
|
357
|
-
},
|
|
358
|
-
set: function set(value) {
|
|
359
|
-
this._r = value;
|
|
360
|
-
this._onValueChanged && this._onValueChanged();
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
key: "g",
|
|
365
|
-
get: /**
|
|
366
|
-
* The green component of the color, 0~1.
|
|
367
|
-
*/ function get() {
|
|
368
|
-
return this._g;
|
|
369
|
-
},
|
|
370
|
-
set: function set(value) {
|
|
371
|
-
this._g = value;
|
|
372
|
-
this._onValueChanged && this._onValueChanged();
|
|
373
|
-
}
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
key: "b",
|
|
377
|
-
get: /**
|
|
378
|
-
* The blue component of the color, 0~1.
|
|
379
|
-
*/ function get() {
|
|
380
|
-
return this._b;
|
|
381
|
-
},
|
|
382
|
-
set: function set(value) {
|
|
383
|
-
this._b = value;
|
|
384
|
-
this._onValueChanged && this._onValueChanged();
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
key: "a",
|
|
389
|
-
get: /**
|
|
390
|
-
* The alpha component of the color, 0~1.
|
|
391
|
-
*/ function get() {
|
|
392
|
-
return this._a;
|
|
393
|
-
},
|
|
394
|
-
set: function set(value) {
|
|
395
|
-
this._a = value;
|
|
396
|
-
this._onValueChanged && this._onValueChanged();
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
]);
|
|
400
|
-
return Color;
|
|
401
|
-
}();
|
|
402
|
-
|
|
403
62
|
/**
|
|
404
63
|
* Sprite mask interaction.
|
|
405
64
|
*/ exports.SpriteMaskInteraction = void 0;
|
|
@@ -940,7 +599,14 @@ var Utils = /*#__PURE__*/ function() {
|
|
|
940
599
|
* @param url - The url to be judged.
|
|
941
600
|
* @returns Whether the url is absolute url.
|
|
942
601
|
*/ Utils.isAbsoluteUrl = function isAbsoluteUrl(url) {
|
|
943
|
-
return /^(
|
|
602
|
+
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
|
603
|
+
};
|
|
604
|
+
/**
|
|
605
|
+
* Judge whether the url is base64 url.
|
|
606
|
+
* @param url - The url to be judged.
|
|
607
|
+
* @returns Whether the url is base64 url.
|
|
608
|
+
*/ Utils.isBase64Url = function isBase64Url(url) {
|
|
609
|
+
return /^data:.*,.*$/i.test(url);
|
|
944
610
|
};
|
|
945
611
|
/**
|
|
946
612
|
* Get the values of an object.
|
|
@@ -958,7 +624,10 @@ var Utils = /*#__PURE__*/ function() {
|
|
|
958
624
|
if (Utils.isAbsoluteUrl(relativeUrl)) {
|
|
959
625
|
return relativeUrl;
|
|
960
626
|
}
|
|
961
|
-
|
|
627
|
+
if (Utils.isBase64Url(relativeUrl)) {
|
|
628
|
+
return relativeUrl;
|
|
629
|
+
}
|
|
630
|
+
return relativeUrl ? baseUrl.replace(/\/+$/, "") + "/" + relativeUrl.replace(/^\/+/, "") : baseUrl;
|
|
962
631
|
};
|
|
963
632
|
/**
|
|
964
633
|
* @internal
|
|
@@ -2120,20 +1789,28 @@ var ActiveChangeFlag;
|
|
|
2120
1789
|
this._enabled = value;
|
|
2121
1790
|
if (this._entity._isActiveInScene) {
|
|
2122
1791
|
if (value) {
|
|
2123
|
-
this._phasedActiveInScene
|
|
2124
|
-
|
|
1792
|
+
if (!this._phasedActiveInScene) {
|
|
1793
|
+
this._phasedActiveInScene = true;
|
|
1794
|
+
this._onEnableInScene();
|
|
1795
|
+
}
|
|
2125
1796
|
} else {
|
|
2126
|
-
this._phasedActiveInScene
|
|
2127
|
-
|
|
1797
|
+
if (this._phasedActiveInScene) {
|
|
1798
|
+
this._phasedActiveInScene = false;
|
|
1799
|
+
this._onDisableInScene();
|
|
1800
|
+
}
|
|
2128
1801
|
}
|
|
2129
1802
|
}
|
|
2130
1803
|
if (this._entity.isActiveInHierarchy) {
|
|
2131
1804
|
if (value) {
|
|
2132
|
-
this._phasedActive
|
|
2133
|
-
|
|
1805
|
+
if (!this._phasedActive) {
|
|
1806
|
+
this._phasedActive = true;
|
|
1807
|
+
this._onEnable();
|
|
1808
|
+
}
|
|
2134
1809
|
} else {
|
|
2135
|
-
this._phasedActive
|
|
2136
|
-
|
|
1810
|
+
if (this._phasedActive) {
|
|
1811
|
+
this._phasedActive = false;
|
|
1812
|
+
this._onDisable();
|
|
1813
|
+
}
|
|
2137
1814
|
}
|
|
2138
1815
|
}
|
|
2139
1816
|
}
|
|
@@ -3506,7 +3183,7 @@ function _extends() {
|
|
|
3506
3183
|
return _extends.apply(this, arguments);
|
|
3507
3184
|
}
|
|
3508
3185
|
|
|
3509
|
-
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;"; // eslint-disable-line
|
|
3186
|
+
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;"; // eslint-disable-line
|
|
3510
3187
|
|
|
3511
3188
|
var common = "#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n"; // eslint-disable-line
|
|
3512
3189
|
|
|
@@ -3556,7 +3233,7 @@ var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 material_EmissiveCol
|
|
|
3556
3233
|
|
|
3557
3234
|
var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;"; // eslint-disable-line
|
|
3558
3235
|
|
|
3559
|
-
var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n"; // eslint-disable-line
|
|
3236
|
+
var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\nvec3 V=-camera_Forward;\n#else\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n#endif\n"; // eslint-disable-line
|
|
3560
3237
|
|
|
3561
3238
|
var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n"; // eslint-disable-line
|
|
3562
3239
|
|
|
@@ -3594,7 +3271,7 @@ var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec
|
|
|
3594
3271
|
|
|
3595
3272
|
var pbr_frag_define = "#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};"; // eslint-disable-line
|
|
3596
3273
|
|
|
3597
|
-
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return MIN_PERCEPTUAL_ROUGHNESS+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn MIN_PERCEPTUAL_ROUGHNESS;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos
|
|
3274
|
+
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return MIN_PERCEPTUAL_ROUGHNESS+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn MIN_PERCEPTUAL_ROUGHNESS;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=texture2D(material_AnisotropyTexture,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
|
|
3598
3275
|
|
|
3599
3276
|
var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;highp vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);highp float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}"; // eslint-disable-line
|
|
3600
3277
|
|
|
@@ -3730,7 +3407,11 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
3730
3407
|
}
|
|
3731
3408
|
ShaderLib[includeName] = includeSource;
|
|
3732
3409
|
};
|
|
3733
|
-
|
|
3410
|
+
/**
|
|
3411
|
+
* @param regex The default regex is for engine's builtin glsl `#include` syntax,
|
|
3412
|
+
* since `ShaderLab` use the same parsing function but different syntax for `#include` --- `/^[ \t]*#include +"([\w\d.]+)"/gm`
|
|
3413
|
+
*/ ShaderFactory.parseIncludes = function parseIncludes(src, regex) {
|
|
3414
|
+
if (regex === void 0) regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
|
|
3734
3415
|
var replace = function replace(match, slice) {
|
|
3735
3416
|
var replace = ShaderLib[slice];
|
|
3736
3417
|
if (replace === undefined) {
|
|
@@ -3739,7 +3420,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
3739
3420
|
}
|
|
3740
3421
|
return ShaderFactory.parseIncludes(replace);
|
|
3741
3422
|
};
|
|
3742
|
-
var regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
|
|
3743
3423
|
return src.replace(regex, replace);
|
|
3744
3424
|
};
|
|
3745
3425
|
/**
|
|
@@ -6721,7 +6401,7 @@ SlicedSpriteAssembler = __decorate([
|
|
|
6721
6401
|
_this._byteLength = byteLength;
|
|
6722
6402
|
_this._platformBuffer = engine._hardwareRenderer.createPlatformBuffer(type, byteLength, bufferUsage, data);
|
|
6723
6403
|
if (readable) {
|
|
6724
|
-
var buffer =
|
|
6404
|
+
var buffer = data.constructor === ArrayBuffer ? data.slice(0) : data.buffer.slice(data.byteOffset, data.byteOffset + byteLength);
|
|
6725
6405
|
_this._data = new Uint8Array(buffer);
|
|
6726
6406
|
}
|
|
6727
6407
|
}
|
|
@@ -9930,6 +9610,10 @@ var VertexElementIndex;
|
|
|
9930
9610
|
var sphereInfo = primitiveInfo;
|
|
9931
9611
|
PrimitiveMesh._setSphereData(this.resource, sphereInfo.radius, sphereInfo.segments, sphereInfo.noLongerAccessible, true, sphereInfo.vertexBuffer);
|
|
9932
9612
|
break;
|
|
9613
|
+
case 7:
|
|
9614
|
+
var CCSphereInfo = primitiveInfo;
|
|
9615
|
+
PrimitiveMesh._setSubdivisionSurfaceSphereData(this.resource, CCSphereInfo.radius, CCSphereInfo.step, CCSphereInfo.noLongerAccessible, true, CCSphereInfo.vertexBuffer);
|
|
9616
|
+
break;
|
|
9933
9617
|
case 1:
|
|
9934
9618
|
var cuboidInfo = primitiveInfo;
|
|
9935
9619
|
PrimitiveMesh._setCuboidData(this.resource, cuboidInfo.width, cuboidInfo.height, cuboidInfo.depth, cuboidInfo.noLongerAccessible, true, cuboidInfo.vertexBuffer);
|
|
@@ -9967,6 +9651,7 @@ var PrimitiveType;
|
|
|
9967
9651
|
PrimitiveType[PrimitiveType["Torus"] = 4] = "Torus";
|
|
9968
9652
|
PrimitiveType[PrimitiveType["Cone"] = 5] = "Cone";
|
|
9969
9653
|
PrimitiveType[PrimitiveType["Capsule"] = 6] = "Capsule";
|
|
9654
|
+
PrimitiveType[PrimitiveType["CCSphere"] = 7] = "CCSphere";
|
|
9970
9655
|
})(PrimitiveType || (PrimitiveType = {}));
|
|
9971
9656
|
/**
|
|
9972
9657
|
* @internal
|
|
@@ -9988,6 +9673,19 @@ var PrimitiveType;
|
|
|
9988
9673
|
}
|
|
9989
9674
|
return SphereRestoreInfo;
|
|
9990
9675
|
}(PrimitiveRestoreInfo);
|
|
9676
|
+
/**
|
|
9677
|
+
* @internal
|
|
9678
|
+
*/ var SubdivisionSurfaceSphereRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
|
|
9679
|
+
_inherits(SubdivisionSurfaceSphereRestoreInfo, PrimitiveRestoreInfo);
|
|
9680
|
+
function SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible) {
|
|
9681
|
+
var _this;
|
|
9682
|
+
_this = PrimitiveRestoreInfo.call(this, 7, vertexBuffer, noLongerAccessible) || this;
|
|
9683
|
+
_this.radius = radius;
|
|
9684
|
+
_this.step = step;
|
|
9685
|
+
return _this;
|
|
9686
|
+
}
|
|
9687
|
+
return SubdivisionSurfaceSphereRestoreInfo;
|
|
9688
|
+
}(PrimitiveRestoreInfo);
|
|
9991
9689
|
/**
|
|
9992
9690
|
* @internal
|
|
9993
9691
|
*/ var CuboidRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
|
|
@@ -10102,6 +9800,24 @@ var PrimitiveType;
|
|
|
10102
9800
|
return sphereMesh;
|
|
10103
9801
|
};
|
|
10104
9802
|
/**
|
|
9803
|
+
* Create a sphere mesh by implementing Catmull-Clark Surface Subdivision Algorithm.
|
|
9804
|
+
* Max step is limited to 6.
|
|
9805
|
+
* @param engine - Engine
|
|
9806
|
+
* @param radius - Sphere radius
|
|
9807
|
+
* @param step - Number of subdiv steps
|
|
9808
|
+
* @param noLongerAccessible - No longer access the vertices of the mesh after creation
|
|
9809
|
+
* @returns Sphere model mesh
|
|
9810
|
+
*/ PrimitiveMesh.createSubdivisionSurfaceSphere = function createSubdivisionSurfaceSphere(engine, radius, step, noLongerAccessible) {
|
|
9811
|
+
if (radius === void 0) radius = 0.5;
|
|
9812
|
+
if (step === void 0) step = 3;
|
|
9813
|
+
if (noLongerAccessible === void 0) noLongerAccessible = true;
|
|
9814
|
+
var sphereMesh = new ModelMesh(engine);
|
|
9815
|
+
PrimitiveMesh._setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, false);
|
|
9816
|
+
var vertexBuffer = sphereMesh.vertexBufferBindings[0].buffer;
|
|
9817
|
+
engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(sphereMesh, new SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible)));
|
|
9818
|
+
return sphereMesh;
|
|
9819
|
+
};
|
|
9820
|
+
/**
|
|
10105
9821
|
* Create a cuboid mesh.
|
|
10106
9822
|
* @param engine - Engine
|
|
10107
9823
|
* @param width - Cuboid width
|
|
@@ -10231,6 +9947,90 @@ var PrimitiveType;
|
|
|
10231
9947
|
};
|
|
10232
9948
|
/**
|
|
10233
9949
|
* @internal
|
|
9950
|
+
*/ PrimitiveMesh._setSubdivisionSurfaceSphereData = function _setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
9951
|
+
// Max step is limited to 6. Because 7 step will generate a single mesh with over 98306 vertices
|
|
9952
|
+
step = engineMath.MathUtil.clamp(Math.floor(step), 1, 6);
|
|
9953
|
+
var positions = new Float32Array(3 * (6 * Math.pow(4, step) + 2));
|
|
9954
|
+
var cells = new Float32Array(24 * Math.pow(4, step));
|
|
9955
|
+
PrimitiveMesh._subdiveCatmullClark(step, positions, cells);
|
|
9956
|
+
var positionCount = positions.length / 3;
|
|
9957
|
+
var cellsCount = cells.length / 4;
|
|
9958
|
+
var poleOffset = positionCount + Math.pow(2, step + 1) - 1;
|
|
9959
|
+
// 16 extra vertices for pole uv
|
|
9960
|
+
// 2 vertices at each pole are idle
|
|
9961
|
+
var vertexCount = poleOffset + 16;
|
|
9962
|
+
var vertices = new Float32Array(vertexCount * 8);
|
|
9963
|
+
var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, positionCount, cellsCount * 6);
|
|
9964
|
+
var seamCount = 0;
|
|
9965
|
+
var seamVertices = {};
|
|
9966
|
+
// Get normals, uvs, and scale to radius
|
|
9967
|
+
for(var i = 0; i < positionCount; i++){
|
|
9968
|
+
var offset = 3 * i;
|
|
9969
|
+
var x = positions[offset];
|
|
9970
|
+
var y = positions[offset + 1];
|
|
9971
|
+
var z = positions[offset + 2];
|
|
9972
|
+
var reciprocalLength = 1 / Math.sqrt(x * x + y * y + z * z);
|
|
9973
|
+
x *= reciprocalLength;
|
|
9974
|
+
y *= reciprocalLength;
|
|
9975
|
+
z *= reciprocalLength;
|
|
9976
|
+
offset = 8 * i;
|
|
9977
|
+
vertices[offset] = x * radius;
|
|
9978
|
+
vertices[offset + 1] = y * radius;
|
|
9979
|
+
vertices[offset + 2] = z * radius;
|
|
9980
|
+
vertices[offset + 3] = x;
|
|
9981
|
+
vertices[offset + 4] = y;
|
|
9982
|
+
vertices[offset + 5] = z;
|
|
9983
|
+
vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
|
|
9984
|
+
vertices[offset + 7] = Math.acos(y) / Math.PI;
|
|
9985
|
+
if (vertices[offset + 6] === 0) {
|
|
9986
|
+
// Generate seam vertex
|
|
9987
|
+
var seamOffset = 8 * (positionCount + seamCount++);
|
|
9988
|
+
vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
|
|
9989
|
+
vertices[seamOffset + 6] = 1.0;
|
|
9990
|
+
// Cache seam vertex
|
|
9991
|
+
seamVertices[offset / 8] = seamOffset / 8;
|
|
9992
|
+
}
|
|
9993
|
+
}
|
|
9994
|
+
// Get indices
|
|
9995
|
+
var offset1 = 0;
|
|
9996
|
+
this._spherePoleIdx = 0;
|
|
9997
|
+
for(var i1 = 0; i1 < cellsCount; i1++){
|
|
9998
|
+
var idx = 4 * i1;
|
|
9999
|
+
var indexA = cells[idx];
|
|
10000
|
+
var indexB = cells[idx + 1];
|
|
10001
|
+
var indexC = cells[idx + 2];
|
|
10002
|
+
var indexD = cells[idx + 3];
|
|
10003
|
+
// Handle seam by replacing vertex index to seam vertex index if necessary
|
|
10004
|
+
var floatIndexA = 8 * indexA;
|
|
10005
|
+
var floatIndexB = 8 * indexB;
|
|
10006
|
+
var floatIndexC = 8 * indexC;
|
|
10007
|
+
var floatIndexD = 8 * indexD;
|
|
10008
|
+
// If center Z is negative
|
|
10009
|
+
if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
|
|
10010
|
+
vertices[floatIndexA + 6] === 0 && (indexA = seamVertices[indexA]);
|
|
10011
|
+
vertices[floatIndexB + 6] === 0 && (indexB = seamVertices[indexB]);
|
|
10012
|
+
vertices[floatIndexC + 6] === 0 && (indexC = seamVertices[indexC]);
|
|
10013
|
+
vertices[floatIndexD + 6] === 0 && (indexD = seamVertices[indexD]);
|
|
10014
|
+
}
|
|
10015
|
+
indices[offset1] = indexA;
|
|
10016
|
+
indices[offset1 + 1] = indexB;
|
|
10017
|
+
indices[offset1 + 2] = indexC;
|
|
10018
|
+
this._generateAndReplacePoleUV(indices, vertices, offset1, poleOffset);
|
|
10019
|
+
indices[offset1 + 3] = indexA;
|
|
10020
|
+
indices[offset1 + 4] = indexC;
|
|
10021
|
+
indices[offset1 + 5] = indexD;
|
|
10022
|
+
this._generateAndReplacePoleUV(indices, vertices, offset1 + 3, poleOffset);
|
|
10023
|
+
offset1 += 6;
|
|
10024
|
+
}
|
|
10025
|
+
if (!isRestoreMode) {
|
|
10026
|
+
var bounds = sphereMesh.bounds;
|
|
10027
|
+
bounds.min.set(-radius, -radius, -radius);
|
|
10028
|
+
bounds.max.set(radius, radius, radius);
|
|
10029
|
+
}
|
|
10030
|
+
PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
10031
|
+
};
|
|
10032
|
+
/**
|
|
10033
|
+
* @internal
|
|
10234
10034
|
*/ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
10235
10035
|
segments = Math.max(2, Math.floor(segments));
|
|
10236
10036
|
var count = segments + 1;
|
|
@@ -10291,6 +10091,135 @@ var PrimitiveType;
|
|
|
10291
10091
|
};
|
|
10292
10092
|
/**
|
|
10293
10093
|
* @internal
|
|
10094
|
+
*/ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
|
|
10095
|
+
var edges = new Map();
|
|
10096
|
+
var faces = new Array();
|
|
10097
|
+
positions.set(PrimitiveMesh._sphereSeedPositions);
|
|
10098
|
+
cells.set(PrimitiveMesh._sphereSeedCells);
|
|
10099
|
+
for(var i = 0; i < step; i++){
|
|
10100
|
+
var cellCount = 6 * Math.pow(4, i);
|
|
10101
|
+
var positionCount = 4 * cellCount + 2;
|
|
10102
|
+
edges.clear();
|
|
10103
|
+
faces.length = 0;
|
|
10104
|
+
// Get cell face's facePoint
|
|
10105
|
+
for(var j = 0; j < cellCount; j++){
|
|
10106
|
+
var face = faces[j] = {
|
|
10107
|
+
facePoint: new engineMath.Vector3(),
|
|
10108
|
+
adjacentEdges: new Array(4)
|
|
10109
|
+
};
|
|
10110
|
+
// Get cell's edgePoint
|
|
10111
|
+
for(var k = 0; k < 4; k++){
|
|
10112
|
+
var offset = 3 * cells[4 * j + k];
|
|
10113
|
+
face.facePoint.x += 0.25 * positions[offset];
|
|
10114
|
+
face.facePoint.y += 0.25 * positions[offset + 1];
|
|
10115
|
+
face.facePoint.z += 0.25 * positions[offset + 2];
|
|
10116
|
+
}
|
|
10117
|
+
// Get cell edges
|
|
10118
|
+
for(var k1 = 0; k1 < 4; k1++){
|
|
10119
|
+
var vertexIdxA = cells[4 * j + k1];
|
|
10120
|
+
var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
|
|
10121
|
+
var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
|
|
10122
|
+
if (!edges.has(edgeIdxKey)) {
|
|
10123
|
+
var edge = {
|
|
10124
|
+
edgePoint: new engineMath.Vector3(),
|
|
10125
|
+
edgePointIndex: undefined
|
|
10126
|
+
};
|
|
10127
|
+
var offsetA = 3 * vertexIdxA;
|
|
10128
|
+
var offsetB = 3 * vertexIdxB;
|
|
10129
|
+
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]));
|
|
10130
|
+
edges.set(edgeIdxKey, edge);
|
|
10131
|
+
}
|
|
10132
|
+
var edge1 = edges.get(edgeIdxKey);
|
|
10133
|
+
face.adjacentEdges[k1] = edge1;
|
|
10134
|
+
var edgePoint = edge1.edgePoint;
|
|
10135
|
+
var facePoint = face.facePoint;
|
|
10136
|
+
edgePoint.x += 0.25 * facePoint.x;
|
|
10137
|
+
edgePoint.y += 0.25 * facePoint.y;
|
|
10138
|
+
edgePoint.z += 0.25 * facePoint.z;
|
|
10139
|
+
}
|
|
10140
|
+
}
|
|
10141
|
+
var prePointCount = cellCount + 2;
|
|
10142
|
+
var edgePointOffset = prePointCount + cellCount;
|
|
10143
|
+
var pointIdx = 0;
|
|
10144
|
+
this._sphereEdgeIdx = 0;
|
|
10145
|
+
var preCells = cells.slice(0, 4 * cellCount);
|
|
10146
|
+
// Get New positions, which consists of updated positions of existing points, face points and edge points
|
|
10147
|
+
for(var j1 = 0; j1 < cellCount; j1++){
|
|
10148
|
+
// Add face point to new positions
|
|
10149
|
+
var face1 = faces[j1];
|
|
10150
|
+
face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
|
|
10151
|
+
// Get the face point index
|
|
10152
|
+
var ic = prePointCount + j1;
|
|
10153
|
+
var id = void 0, ib = void 0, temp = void 0;
|
|
10154
|
+
// ia -- id -- ia
|
|
10155
|
+
// | | |
|
|
10156
|
+
// ib -- ic -- ib
|
|
10157
|
+
// | | |
|
|
10158
|
+
// ia -- id -- ia
|
|
10159
|
+
for(var k2 = 0; k2 < 4; k2++){
|
|
10160
|
+
// Get the updated existing point index
|
|
10161
|
+
var ia = preCells[pointIdx++];
|
|
10162
|
+
// ib and id share four edge points in one cell
|
|
10163
|
+
switch(k2){
|
|
10164
|
+
case 0:
|
|
10165
|
+
{
|
|
10166
|
+
var edgeB = face1.adjacentEdges[k2 % 4];
|
|
10167
|
+
var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
|
|
10168
|
+
ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
|
|
10169
|
+
id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
|
|
10170
|
+
temp = id;
|
|
10171
|
+
break;
|
|
10172
|
+
}
|
|
10173
|
+
case 1:
|
|
10174
|
+
case 2:
|
|
10175
|
+
{
|
|
10176
|
+
var edgeB1 = face1.adjacentEdges[k2 % 4];
|
|
10177
|
+
id = ib;
|
|
10178
|
+
ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
|
|
10179
|
+
break;
|
|
10180
|
+
}
|
|
10181
|
+
case 3:
|
|
10182
|
+
{
|
|
10183
|
+
id = ib;
|
|
10184
|
+
ib = temp;
|
|
10185
|
+
break;
|
|
10186
|
+
}
|
|
10187
|
+
}
|
|
10188
|
+
var idx = 4 * (4 * j1 + k2);
|
|
10189
|
+
cells[idx] = ia;
|
|
10190
|
+
cells[idx + 1] = ib;
|
|
10191
|
+
cells[idx + 2] = ic;
|
|
10192
|
+
cells[idx + 3] = id;
|
|
10193
|
+
}
|
|
10194
|
+
}
|
|
10195
|
+
}
|
|
10196
|
+
};
|
|
10197
|
+
/**
|
|
10198
|
+
* Duplicate vertices at the poles and adjust their UV coordinates.
|
|
10199
|
+
*/ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
|
|
10200
|
+
var v = vertices[8 * indices[idx] + 7];
|
|
10201
|
+
if (v === 0 || v === 1) {
|
|
10202
|
+
var offset = 8 * indices[idx];
|
|
10203
|
+
var addedOffset = 8 * (poleOffset + this._spherePoleIdx);
|
|
10204
|
+
vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
|
|
10205
|
+
vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
|
|
10206
|
+
indices[idx] = poleOffset + this._spherePoleIdx++;
|
|
10207
|
+
}
|
|
10208
|
+
};
|
|
10209
|
+
/**
|
|
10210
|
+
* Get edge point index for subdivision surface sphere.
|
|
10211
|
+
*/ PrimitiveMesh._calculateEdgeIndex = function _calculateEdgeIndex(positions, edge, offset) {
|
|
10212
|
+
if (edge.edgePointIndex !== undefined) {
|
|
10213
|
+
return edge.edgePointIndex;
|
|
10214
|
+
} else {
|
|
10215
|
+
edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
|
|
10216
|
+
var index = offset + PrimitiveMesh._sphereEdgeIdx++;
|
|
10217
|
+
edge.edgePointIndex = index;
|
|
10218
|
+
return index;
|
|
10219
|
+
}
|
|
10220
|
+
};
|
|
10221
|
+
/**
|
|
10222
|
+
* @internal
|
|
10294
10223
|
*/ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
10295
10224
|
var halfWidth = width / 2;
|
|
10296
10225
|
var halfHeight = height / 2;
|
|
@@ -10920,6 +10849,68 @@ var PrimitiveType;
|
|
|
10920
10849
|
(function() {
|
|
10921
10850
|
PrimitiveMesh._tempVec30 = new engineMath.Vector3();
|
|
10922
10851
|
})();
|
|
10852
|
+
(function() {
|
|
10853
|
+
PrimitiveMesh._sphereSeedPositions = new Float32Array([
|
|
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
|
+
1,
|
|
10867
|
+
-1,
|
|
10868
|
+
-1,
|
|
10869
|
+
1,
|
|
10870
|
+
1,
|
|
10871
|
+
-1,
|
|
10872
|
+
-1,
|
|
10873
|
+
-1,
|
|
10874
|
+
-1,
|
|
10875
|
+
-1,
|
|
10876
|
+
1,
|
|
10877
|
+
-1
|
|
10878
|
+
]);
|
|
10879
|
+
})();
|
|
10880
|
+
(function() {
|
|
10881
|
+
PrimitiveMesh._sphereSeedCells = new Float32Array([
|
|
10882
|
+
0,
|
|
10883
|
+
1,
|
|
10884
|
+
2,
|
|
10885
|
+
3,
|
|
10886
|
+
3,
|
|
10887
|
+
2,
|
|
10888
|
+
4,
|
|
10889
|
+
5,
|
|
10890
|
+
5,
|
|
10891
|
+
4,
|
|
10892
|
+
6,
|
|
10893
|
+
7,
|
|
10894
|
+
7,
|
|
10895
|
+
0,
|
|
10896
|
+
3,
|
|
10897
|
+
5,
|
|
10898
|
+
7,
|
|
10899
|
+
6,
|
|
10900
|
+
1,
|
|
10901
|
+
0,
|
|
10902
|
+
6,
|
|
10903
|
+
4,
|
|
10904
|
+
2,
|
|
10905
|
+
1
|
|
10906
|
+
]);
|
|
10907
|
+
})();
|
|
10908
|
+
(function() {
|
|
10909
|
+
PrimitiveMesh._sphereEdgeIdx = 0;
|
|
10910
|
+
})();
|
|
10911
|
+
(function() {
|
|
10912
|
+
PrimitiveMesh._spherePoleIdx = 0;
|
|
10913
|
+
})();
|
|
10923
10914
|
|
|
10924
10915
|
/**
|
|
10925
10916
|
* Mesh skin data, equal glTF skins define
|
|
@@ -11464,8 +11455,10 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
|
|
|
11464
11455
|
}
|
|
11465
11456
|
mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
|
|
11466
11457
|
batchedQueue[curMeshIndex] = preElement;
|
|
11467
|
-
|
|
11468
|
-
|
|
11458
|
+
// Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
|
|
11459
|
+
// Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
|
|
11460
|
+
this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, exports.SetDataOptions.Discard);
|
|
11461
|
+
this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, exports.SetDataOptions.Discard);
|
|
11469
11462
|
};
|
|
11470
11463
|
_proto._getSubMeshFromPool = function _getSubMeshFromPool(start, count) {
|
|
11471
11464
|
var subMesh = this._subMeshPool.getFromPool();
|
|
@@ -12495,6 +12488,9 @@ var /**
|
|
|
12495
12488
|
__decorate([
|
|
12496
12489
|
assignmentClone
|
|
12497
12490
|
], SpriteMask.prototype, "influenceLayers", void 0);
|
|
12491
|
+
__decorate([
|
|
12492
|
+
ignoreClone
|
|
12493
|
+
], SpriteMask.prototype, "_verticesData", void 0);
|
|
12498
12494
|
__decorate([
|
|
12499
12495
|
ignoreClone
|
|
12500
12496
|
], SpriteMask.prototype, "_sprite", void 0);
|
|
@@ -12778,8 +12774,8 @@ var /**
|
|
|
12778
12774
|
} else {
|
|
12779
12775
|
word += char;
|
|
12780
12776
|
wordWidth += charInfo.xAdvance;
|
|
12781
|
-
wordMaxAscent =
|
|
12782
|
-
wordMaxDescent =
|
|
12777
|
+
wordMaxAscent = Math.max(wordMaxAscent, ascent);
|
|
12778
|
+
wordMaxDescent = Math.max(wordMaxDescent, descent);
|
|
12783
12779
|
}
|
|
12784
12780
|
}
|
|
12785
12781
|
}
|
|
@@ -12900,6 +12896,9 @@ var /**
|
|
|
12900
12896
|
var baseline = Math.ceil(context.measureText(TextUtils._measureBaseline).width);
|
|
12901
12897
|
var height = baseline * TextUtils._heightMultiplier;
|
|
12902
12898
|
baseline = TextUtils._baselineMultiplier * baseline | 0;
|
|
12899
|
+
var _extendHeight = TextUtils._extendHeight;
|
|
12900
|
+
height += _extendHeight;
|
|
12901
|
+
baseline += _extendHeight * 0.5;
|
|
12903
12902
|
canvas.width = width;
|
|
12904
12903
|
canvas.height = height;
|
|
12905
12904
|
context.font = fontString;
|
|
@@ -12934,6 +12933,7 @@ var /**
|
|
|
12934
12933
|
}
|
|
12935
12934
|
if (top !== -1 && bottom !== -1) {
|
|
12936
12935
|
ascent = baseline - top;
|
|
12936
|
+
// Baseline belong to descent
|
|
12937
12937
|
descent = bottom - baseline + 1;
|
|
12938
12938
|
size = ascent + descent;
|
|
12939
12939
|
}
|
|
@@ -13009,6 +13009,10 @@ var /**
|
|
|
13009
13009
|
"fangsong"
|
|
13010
13010
|
];
|
|
13011
13011
|
})();
|
|
13012
|
+
(function() {
|
|
13013
|
+
// _extendHeight used to extend the height of canvas, because in miniprogram performance is different from h5.
|
|
13014
|
+
/** @internal */ TextUtils._extendHeight = 0;
|
|
13015
|
+
})();
|
|
13012
13016
|
(function() {
|
|
13013
13017
|
/** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
|
|
13014
13018
|
})();
|
|
@@ -13099,7 +13103,8 @@ var /**
|
|
|
13099
13103
|
_proto._createFontAtlas = function _createFontAtlas() {
|
|
13100
13104
|
var _this = this, engine = _this._engine;
|
|
13101
13105
|
var fontAtlas = new FontAtlas(engine);
|
|
13102
|
-
var texture = new Texture2D(engine, 256, 256);
|
|
13106
|
+
var texture = new Texture2D(engine, 256, 256, exports.TextureFormat.R8G8B8A8, false);
|
|
13107
|
+
texture.filterMode = exports.TextureFilterMode.Bilinear;
|
|
13103
13108
|
fontAtlas.texture = texture;
|
|
13104
13109
|
fontAtlas.isGCIgnored = texture.isGCIgnored = true;
|
|
13105
13110
|
this._fontAtlases.push(fontAtlas);
|
|
@@ -13337,7 +13342,7 @@ var /**
|
|
|
13337
13342
|
/**
|
|
13338
13343
|
* @internal
|
|
13339
13344
|
*/ _proto._render = function _render(context) {
|
|
13340
|
-
if (this.
|
|
13345
|
+
if (this._isTextNoVisible()) {
|
|
13341
13346
|
return;
|
|
13342
13347
|
}
|
|
13343
13348
|
if (this._isContainDirtyFlag(0x10)) {
|
|
@@ -13429,8 +13434,8 @@ var /**
|
|
|
13429
13434
|
}
|
|
13430
13435
|
};
|
|
13431
13436
|
_proto._updateLocalData = function _updateLocalData() {
|
|
13432
|
-
var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
|
|
13433
13437
|
var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
|
|
13438
|
+
var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
|
|
13434
13439
|
var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
|
|
13435
13440
|
var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
|
|
13436
13441
|
var charRenderDataPool = TextRenderer._charRenderDataPool;
|
|
@@ -13498,7 +13503,7 @@ var /**
|
|
|
13498
13503
|
var left = startX * pixelsPerUnitReciprocal;
|
|
13499
13504
|
var right = (startX + w) * pixelsPerUnitReciprocal;
|
|
13500
13505
|
var top = (startY + ascent) * pixelsPerUnitReciprocal;
|
|
13501
|
-
var bottom = (startY - descent
|
|
13506
|
+
var bottom = (startY - descent) * pixelsPerUnitReciprocal;
|
|
13502
13507
|
localPositions.set(left, top, right, bottom);
|
|
13503
13508
|
i === firstLine && (maxY = Math.max(maxY, top));
|
|
13504
13509
|
minY = Math.min(minY, bottom);
|
|
@@ -13539,6 +13544,9 @@ var /**
|
|
|
13539
13544
|
Renderer1.prototype._onTransformChanged.call(this, bit);
|
|
13540
13545
|
this._setDirtyFlagTrue(0x4 | 0x8);
|
|
13541
13546
|
};
|
|
13547
|
+
_proto._isTextNoVisible = function _isTextNoVisible() {
|
|
13548
|
+
return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0;
|
|
13549
|
+
};
|
|
13542
13550
|
_create_class(TextRenderer, [
|
|
13543
13551
|
{
|
|
13544
13552
|
key: "color",
|
|
@@ -13741,6 +13749,16 @@ var /**
|
|
|
13741
13749
|
get: /**
|
|
13742
13750
|
* The bounding volume of the TextRenderer.
|
|
13743
13751
|
*/ function get() {
|
|
13752
|
+
if (this._isTextNoVisible()) {
|
|
13753
|
+
if (this._isContainDirtyFlag(0x8)) {
|
|
13754
|
+
var localBounds = this._localBounds;
|
|
13755
|
+
localBounds.min.set(0, 0, 0);
|
|
13756
|
+
localBounds.max.set(0, 0, 0);
|
|
13757
|
+
this._updateBounds(this._bounds);
|
|
13758
|
+
this._setDirtyFlagFalse(0x8);
|
|
13759
|
+
}
|
|
13760
|
+
return this._bounds;
|
|
13761
|
+
}
|
|
13744
13762
|
this._isContainDirtyFlag(0x1) && this._resetSubFont();
|
|
13745
13763
|
this._isContainDirtyFlag(0x2) && this._updateLocalData();
|
|
13746
13764
|
this._isContainDirtyFlag(0x4) && this._updatePosition();
|
|
@@ -14762,6 +14780,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData1) {
|
|
|
14762
14780
|
AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
|
|
14763
14781
|
AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
|
|
14764
14782
|
AssetType[/** Sprite. */ "Sprite"] = "Sprite";
|
|
14783
|
+
AssetType[/** PrimitiveMesh. */ "PrimitiveMesh"] = "PrimitiveMesh";
|
|
14765
14784
|
AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
|
|
14766
14785
|
AssetType[/** Ambient light. */ "Env"] = "Environment";
|
|
14767
14786
|
AssetType[/** Scene. */ "Scene"] = "Scene";
|
|
@@ -15147,6 +15166,7 @@ var /** @internal */ PromiseState;
|
|
|
15147
15166
|
this./** The number of retries after failing to load assets. */ retryCount = 1;
|
|
15148
15167
|
this./** Retry delay time after failed to load assets, in milliseconds. */ retryInterval = 0;
|
|
15149
15168
|
this./** The default timeout period for loading assets, in milliseconds. */ timeout = Infinity;
|
|
15169
|
+
this./** Base url for loading assets. */ baseUrl = null;
|
|
15150
15170
|
this._loadingPromises = {};
|
|
15151
15171
|
this._assetPool = Object.create(null);
|
|
15152
15172
|
this._assetUrlPool = Object.create(null);
|
|
@@ -15350,6 +15370,8 @@ var /** @internal */ PromiseState;
|
|
|
15350
15370
|
// Check url mapping
|
|
15351
15371
|
var itemURL = item.url;
|
|
15352
15372
|
var url = this._virtualPathMap[itemURL] ? this._virtualPathMap[itemURL] : itemURL;
|
|
15373
|
+
// Not absolute and base url is set
|
|
15374
|
+
if (!Utils.isAbsoluteUrl(url) && this.baseUrl) url = Utils.resolveAbsoluteUrl(this.baseUrl, url);
|
|
15353
15375
|
// Parse url
|
|
15354
15376
|
var _this__parseURL = this._parseURL(url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
|
|
15355
15377
|
var paths = queryPath ? this._parseQueryPath(queryPath) : [];
|
|
@@ -15729,6 +15751,66 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
15729
15751
|
}
|
|
15730
15752
|
}
|
|
15731
15753
|
};
|
|
15754
|
+
/**
|
|
15755
|
+
* @internal
|
|
15756
|
+
*/ SystemInfo._detectSIMDSupported = function _detectSIMDSupported() {
|
|
15757
|
+
if (this._simdSupported === null) {
|
|
15758
|
+
this._simdSupported = WebAssembly.validate(new Uint8Array([
|
|
15759
|
+
0,
|
|
15760
|
+
97,
|
|
15761
|
+
115,
|
|
15762
|
+
109,
|
|
15763
|
+
1,
|
|
15764
|
+
0,
|
|
15765
|
+
0,
|
|
15766
|
+
0,
|
|
15767
|
+
1,
|
|
15768
|
+
4,
|
|
15769
|
+
1,
|
|
15770
|
+
96,
|
|
15771
|
+
0,
|
|
15772
|
+
0,
|
|
15773
|
+
3,
|
|
15774
|
+
3,
|
|
15775
|
+
2,
|
|
15776
|
+
0,
|
|
15777
|
+
0,
|
|
15778
|
+
5,
|
|
15779
|
+
3,
|
|
15780
|
+
1,
|
|
15781
|
+
0,
|
|
15782
|
+
1,
|
|
15783
|
+
12,
|
|
15784
|
+
1,
|
|
15785
|
+
0,
|
|
15786
|
+
10,
|
|
15787
|
+
22,
|
|
15788
|
+
2,
|
|
15789
|
+
12,
|
|
15790
|
+
0,
|
|
15791
|
+
65,
|
|
15792
|
+
0,
|
|
15793
|
+
65,
|
|
15794
|
+
0,
|
|
15795
|
+
65,
|
|
15796
|
+
0,
|
|
15797
|
+
252,
|
|
15798
|
+
10,
|
|
15799
|
+
0,
|
|
15800
|
+
0,
|
|
15801
|
+
11,
|
|
15802
|
+
7,
|
|
15803
|
+
0,
|
|
15804
|
+
65,
|
|
15805
|
+
0,
|
|
15806
|
+
253,
|
|
15807
|
+
15,
|
|
15808
|
+
26,
|
|
15809
|
+
11
|
|
15810
|
+
]));
|
|
15811
|
+
}
|
|
15812
|
+
return this._simdSupported;
|
|
15813
|
+
};
|
|
15732
15814
|
_create_class(SystemInfo, null, [
|
|
15733
15815
|
{
|
|
15734
15816
|
key: "devicePixelRatio",
|
|
@@ -15747,6 +15829,9 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
15747
15829
|
(function() {
|
|
15748
15830
|
/** The operating system is running on. */ SystemInfo.operatingSystem = "";
|
|
15749
15831
|
})();
|
|
15832
|
+
(function() {
|
|
15833
|
+
/** Whether the system support SIMD. */ SystemInfo._simdSupported = null;
|
|
15834
|
+
})();
|
|
15750
15835
|
SystemInfo._initialize();
|
|
15751
15836
|
|
|
15752
15837
|
/**
|
|
@@ -15977,7 +16062,7 @@ SystemInfo._initialize();
|
|
|
15977
16062
|
* Keyboard Manager.
|
|
15978
16063
|
* @internal
|
|
15979
16064
|
*/ var KeyboardManager = /*#__PURE__*/ function() {
|
|
15980
|
-
function KeyboardManager(engine) {
|
|
16065
|
+
function KeyboardManager(engine, target) {
|
|
15981
16066
|
/** @internal */ this._curHeldDownKeyToIndexMap = [];
|
|
15982
16067
|
/** @internal */ this._upKeyToFrameCountMap = [];
|
|
15983
16068
|
/** @internal */ this._downKeyToFrameCountMap = [];
|
|
@@ -15985,17 +16070,11 @@ SystemInfo._initialize();
|
|
|
15985
16070
|
/** @internal */ this._curFrameDownList = new DisorderedArray();
|
|
15986
16071
|
/** @internal */ this._curFrameUpList = new DisorderedArray();
|
|
15987
16072
|
this._nativeEvents = [];
|
|
15988
|
-
this._hadListener = false;
|
|
15989
|
-
// @ts-ignore
|
|
15990
|
-
var htmlCanvas = engine._canvas._webCanvas;
|
|
15991
16073
|
this._engine = engine;
|
|
15992
|
-
this.
|
|
15993
|
-
// Need to set tabIndex to make the canvas focus.
|
|
15994
|
-
htmlCanvas.tabIndex = htmlCanvas.tabIndex;
|
|
16074
|
+
this._onBlur = this._onBlur.bind(this);
|
|
15995
16075
|
this._onKeyEvent = this._onKeyEvent.bind(this);
|
|
15996
|
-
|
|
15997
|
-
|
|
15998
|
-
this._hadListener = true;
|
|
16076
|
+
this._target = target;
|
|
16077
|
+
this._addEventListener();
|
|
15999
16078
|
}
|
|
16000
16079
|
var _proto = KeyboardManager.prototype;
|
|
16001
16080
|
/**
|
|
@@ -16047,35 +16126,8 @@ SystemInfo._initialize();
|
|
|
16047
16126
|
};
|
|
16048
16127
|
/**
|
|
16049
16128
|
* @internal
|
|
16050
|
-
*/ _proto._onFocus = function _onFocus() {
|
|
16051
|
-
if (!this._hadListener) {
|
|
16052
|
-
this._htmlCanvas.addEventListener("keydown", this._onKeyEvent);
|
|
16053
|
-
this._htmlCanvas.addEventListener("keyup", this._onKeyEvent);
|
|
16054
|
-
this._hadListener = true;
|
|
16055
|
-
}
|
|
16056
|
-
};
|
|
16057
|
-
/**
|
|
16058
|
-
* @internal
|
|
16059
|
-
*/ _proto._onBlur = function _onBlur() {
|
|
16060
|
-
if (this._hadListener) {
|
|
16061
|
-
this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
|
|
16062
|
-
this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
|
|
16063
|
-
this._curHeldDownKeyToIndexMap.length = 0;
|
|
16064
|
-
this._curFrameHeldDownList.length = 0;
|
|
16065
|
-
this._curFrameDownList.length = 0;
|
|
16066
|
-
this._curFrameUpList.length = 0;
|
|
16067
|
-
this._nativeEvents.length = 0;
|
|
16068
|
-
this._hadListener = false;
|
|
16069
|
-
}
|
|
16070
|
-
};
|
|
16071
|
-
/**
|
|
16072
|
-
* @internal
|
|
16073
16129
|
*/ _proto._destroy = function _destroy() {
|
|
16074
|
-
|
|
16075
|
-
this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
|
|
16076
|
-
this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
|
|
16077
|
-
this._hadListener = false;
|
|
16078
|
-
}
|
|
16130
|
+
this._removeEventListener();
|
|
16079
16131
|
this._curHeldDownKeyToIndexMap.length = 0;
|
|
16080
16132
|
this._curHeldDownKeyToIndexMap = null;
|
|
16081
16133
|
this._upKeyToFrameCountMap.length = 0;
|
|
@@ -16090,12 +16142,30 @@ SystemInfo._initialize();
|
|
|
16090
16142
|
this._curFrameDownList = null;
|
|
16091
16143
|
this._curFrameUpList.length = 0;
|
|
16092
16144
|
this._curFrameUpList = null;
|
|
16093
|
-
this._htmlCanvas = null;
|
|
16094
16145
|
this._engine = null;
|
|
16095
16146
|
};
|
|
16147
|
+
_proto._onBlur = function _onBlur() {
|
|
16148
|
+
this._curHeldDownKeyToIndexMap.length = 0;
|
|
16149
|
+
this._curFrameHeldDownList.length = 0;
|
|
16150
|
+
this._curFrameDownList.length = 0;
|
|
16151
|
+
this._curFrameUpList.length = 0;
|
|
16152
|
+
this._nativeEvents.length = 0;
|
|
16153
|
+
};
|
|
16096
16154
|
_proto._onKeyEvent = function _onKeyEvent(evt) {
|
|
16097
16155
|
this._nativeEvents.push(evt);
|
|
16098
16156
|
};
|
|
16157
|
+
_proto._addEventListener = function _addEventListener() {
|
|
16158
|
+
var _this = this, target = _this._target;
|
|
16159
|
+
target.addEventListener("keydown", this._onKeyEvent);
|
|
16160
|
+
target.addEventListener("keyup", this._onKeyEvent);
|
|
16161
|
+
target.addEventListener("blur", this._onBlur);
|
|
16162
|
+
};
|
|
16163
|
+
_proto._removeEventListener = function _removeEventListener() {
|
|
16164
|
+
var _this = this, target = _this._target;
|
|
16165
|
+
target.removeEventListener("keydown", this._onKeyEvent);
|
|
16166
|
+
target.removeEventListener("keyup", this._onKeyEvent);
|
|
16167
|
+
target.removeEventListener("blur", this._onBlur);
|
|
16168
|
+
};
|
|
16099
16169
|
return KeyboardManager;
|
|
16100
16170
|
}();
|
|
16101
16171
|
|
|
@@ -18059,7 +18129,7 @@ __decorate([
|
|
|
18059
18129
|
* Pointer Manager.
|
|
18060
18130
|
* @internal
|
|
18061
18131
|
*/ var PointerManager = /*#__PURE__*/ function() {
|
|
18062
|
-
function PointerManager(engine) {
|
|
18132
|
+
function PointerManager(engine, target) {
|
|
18063
18133
|
/** @internal */ this._pointers = [];
|
|
18064
18134
|
/** @internal */ this._multiPointerEnabled = true;
|
|
18065
18135
|
/** @internal */ this._buttons = exports.PointerButton.None;
|
|
@@ -18068,16 +18138,18 @@ __decorate([
|
|
|
18068
18138
|
/** @internal */ this._upList = new DisorderedArray();
|
|
18069
18139
|
/** @internal */ this._downList = new DisorderedArray();
|
|
18070
18140
|
this._nativeEvents = [];
|
|
18071
|
-
|
|
18072
|
-
|
|
18073
|
-
|
|
18141
|
+
if (_instanceof(target, Window)) {
|
|
18142
|
+
throw "Do not set window as target because window cannot listen to pointer leave event.";
|
|
18143
|
+
}
|
|
18074
18144
|
this._engine = engine;
|
|
18145
|
+
this._target = target;
|
|
18075
18146
|
this._canvas = engine.canvas;
|
|
18076
|
-
|
|
18077
|
-
this.
|
|
18078
|
-
this._onFocus();
|
|
18147
|
+
// @ts-ignore
|
|
18148
|
+
this._htmlCanvas = engine._canvas._webCanvas;
|
|
18079
18149
|
// If there are no compatibility issues, navigator.maxTouchPoints should be used here
|
|
18080
18150
|
this._pointerPool = new Array(11);
|
|
18151
|
+
this._onPointerEvent = this._onPointerEvent.bind(this);
|
|
18152
|
+
this._addEventListener();
|
|
18081
18153
|
}
|
|
18082
18154
|
var _proto = PointerManager.prototype;
|
|
18083
18155
|
/**
|
|
@@ -18147,7 +18219,8 @@ __decorate([
|
|
|
18147
18219
|
var length = events.length;
|
|
18148
18220
|
if (length > 0) {
|
|
18149
18221
|
for(var i1 = 0; i1 < length; i1++){
|
|
18150
|
-
|
|
18222
|
+
var event = events[i1];
|
|
18223
|
+
switch(event.type){
|
|
18151
18224
|
case "pointerdown":
|
|
18152
18225
|
pointer.phase = exports.PointerPhase.Down;
|
|
18153
18226
|
pointer._firePointerDown(rayCastEntity);
|
|
@@ -18169,66 +18242,14 @@ __decorate([
|
|
|
18169
18242
|
};
|
|
18170
18243
|
/**
|
|
18171
18244
|
* @internal
|
|
18172
|
-
*/ _proto._onFocus = function _onFocus() {
|
|
18173
|
-
if (!this._hadListener) {
|
|
18174
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
18175
|
-
htmlCanvas.addEventListener("pointerdown", onPointerEvent);
|
|
18176
|
-
htmlCanvas.addEventListener("pointerup", onPointerEvent);
|
|
18177
|
-
htmlCanvas.addEventListener("pointerleave", onPointerEvent);
|
|
18178
|
-
htmlCanvas.addEventListener("pointermove", onPointerEvent);
|
|
18179
|
-
htmlCanvas.addEventListener("pointercancel", onPointerEvent);
|
|
18180
|
-
this._hadListener = true;
|
|
18181
|
-
}
|
|
18182
|
-
};
|
|
18183
|
-
/**
|
|
18184
|
-
* @internal
|
|
18185
|
-
*/ _proto._onBlur = function _onBlur() {
|
|
18186
|
-
if (this._hadListener) {
|
|
18187
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
18188
|
-
htmlCanvas.removeEventListener("pointerdown", onPointerEvent);
|
|
18189
|
-
htmlCanvas.removeEventListener("pointerup", onPointerEvent);
|
|
18190
|
-
htmlCanvas.removeEventListener("pointerleave", onPointerEvent);
|
|
18191
|
-
htmlCanvas.removeEventListener("pointermove", onPointerEvent);
|
|
18192
|
-
htmlCanvas.removeEventListener("pointercancel", onPointerEvent);
|
|
18193
|
-
this._hadListener = false;
|
|
18194
|
-
this._pointers.length = 0;
|
|
18195
|
-
this._downList.length = 0;
|
|
18196
|
-
this._upList.length = 0;
|
|
18197
|
-
}
|
|
18198
|
-
};
|
|
18199
|
-
/**
|
|
18200
|
-
* @internal
|
|
18201
18245
|
*/ _proto._destroy = function _destroy() {
|
|
18202
|
-
|
|
18203
|
-
if (this._hadListener) {
|
|
18204
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
18205
|
-
htmlCanvas.removeEventListener("pointerdown", onPointerEvent);
|
|
18206
|
-
htmlCanvas.removeEventListener("pointerup", onPointerEvent);
|
|
18207
|
-
htmlCanvas.removeEventListener("pointerleave", onPointerEvent);
|
|
18208
|
-
htmlCanvas.removeEventListener("pointermove", onPointerEvent);
|
|
18209
|
-
htmlCanvas.removeEventListener("pointercancel", onPointerEvent);
|
|
18210
|
-
this._hadListener = false;
|
|
18211
|
-
}
|
|
18246
|
+
this._removeEventListener();
|
|
18212
18247
|
this._pointerPool.length = 0;
|
|
18213
|
-
this._pointerPool = null;
|
|
18214
|
-
this._pointers.length = 0;
|
|
18215
|
-
this._pointers = null;
|
|
18216
|
-
this._downList.length = 0;
|
|
18217
|
-
this._downList = null;
|
|
18218
|
-
this._upList.length = 0;
|
|
18219
|
-
this._upList = null;
|
|
18220
18248
|
this._nativeEvents.length = 0;
|
|
18221
|
-
this._nativeEvents = null;
|
|
18222
|
-
this._upMap.length = 0;
|
|
18223
|
-
this._upMap = null;
|
|
18224
18249
|
this._downMap.length = 0;
|
|
18225
|
-
this.
|
|
18226
|
-
this._htmlCanvas = null;
|
|
18227
|
-
this._canvas = null;
|
|
18228
|
-
this._engine = null;
|
|
18250
|
+
this._upMap.length = 0;
|
|
18229
18251
|
};
|
|
18230
18252
|
_proto._onPointerEvent = function _onPointerEvent(evt) {
|
|
18231
|
-
evt.type === "pointerdown" && this._htmlCanvas.focus();
|
|
18232
18253
|
this._nativeEvents.push(evt);
|
|
18233
18254
|
};
|
|
18234
18255
|
_proto._getPointerByID = function _getPointerByID(pointerId) {
|
|
@@ -18311,6 +18332,26 @@ __decorate([
|
|
|
18311
18332
|
}
|
|
18312
18333
|
return null;
|
|
18313
18334
|
};
|
|
18335
|
+
_proto._addEventListener = function _addEventListener() {
|
|
18336
|
+
var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
|
|
18337
|
+
target.addEventListener("pointerdown", onPointerEvent);
|
|
18338
|
+
target.addEventListener("pointerup", onPointerEvent);
|
|
18339
|
+
target.addEventListener("pointerleave", onPointerEvent);
|
|
18340
|
+
target.addEventListener("pointermove", onPointerEvent);
|
|
18341
|
+
target.addEventListener("pointercancel", onPointerEvent);
|
|
18342
|
+
};
|
|
18343
|
+
_proto._removeEventListener = function _removeEventListener() {
|
|
18344
|
+
var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
|
|
18345
|
+
target.removeEventListener("pointerdown", onPointerEvent);
|
|
18346
|
+
target.removeEventListener("pointerup", onPointerEvent);
|
|
18347
|
+
target.removeEventListener("pointerleave", onPointerEvent);
|
|
18348
|
+
target.removeEventListener("pointermove", onPointerEvent);
|
|
18349
|
+
target.removeEventListener("pointercancel", onPointerEvent);
|
|
18350
|
+
this._nativeEvents.length = 0;
|
|
18351
|
+
this._pointers.length = 0;
|
|
18352
|
+
this._downList.length = 0;
|
|
18353
|
+
this._upList.length = 0;
|
|
18354
|
+
};
|
|
18314
18355
|
return PointerManager;
|
|
18315
18356
|
}();
|
|
18316
18357
|
(function() {
|
|
@@ -18327,15 +18368,12 @@ __decorate([
|
|
|
18327
18368
|
* Wheel Manager.
|
|
18328
18369
|
* @internal
|
|
18329
18370
|
*/ var WheelManager = /*#__PURE__*/ function() {
|
|
18330
|
-
function WheelManager(engine) {
|
|
18371
|
+
function WheelManager(engine, target) {
|
|
18331
18372
|
/** @internal */ this._delta = new engineMath.Vector3();
|
|
18332
18373
|
this._nativeEvents = [];
|
|
18333
|
-
// @ts-ignore
|
|
18334
|
-
var htmlCanvas = engine._canvas._webCanvas;
|
|
18335
18374
|
this._onWheelEvent = this._onWheelEvent.bind(this);
|
|
18336
|
-
|
|
18337
|
-
this.
|
|
18338
|
-
this._hadListener = true;
|
|
18375
|
+
this._target = target;
|
|
18376
|
+
this._addEventListener();
|
|
18339
18377
|
}
|
|
18340
18378
|
var _proto = WheelManager.prototype;
|
|
18341
18379
|
/**
|
|
@@ -18356,35 +18394,24 @@ __decorate([
|
|
|
18356
18394
|
};
|
|
18357
18395
|
/**
|
|
18358
18396
|
* @internal
|
|
18359
|
-
*/ _proto.
|
|
18360
|
-
|
|
18361
|
-
this._canvas.addEventListener("wheel", this._onWheelEvent);
|
|
18362
|
-
this._hadListener = true;
|
|
18363
|
-
}
|
|
18397
|
+
*/ _proto._addEventListener = function _addEventListener() {
|
|
18398
|
+
this._target.addEventListener("wheel", this._onWheelEvent);
|
|
18364
18399
|
};
|
|
18365
18400
|
/**
|
|
18366
18401
|
* @internal
|
|
18367
|
-
*/ _proto.
|
|
18368
|
-
|
|
18369
|
-
|
|
18370
|
-
|
|
18371
|
-
this._delta.set(0, 0, 0);
|
|
18372
|
-
this._hadListener = false;
|
|
18373
|
-
}
|
|
18402
|
+
*/ _proto._removeEventListener = function _removeEventListener() {
|
|
18403
|
+
this._target.removeEventListener("wheel", this._onWheelEvent);
|
|
18404
|
+
this._nativeEvents.length = 0;
|
|
18405
|
+
this._delta.set(0, 0, 0);
|
|
18374
18406
|
};
|
|
18375
18407
|
/**
|
|
18376
18408
|
* @internal
|
|
18377
18409
|
*/ _proto._destroy = function _destroy() {
|
|
18378
|
-
|
|
18379
|
-
this._canvas.removeEventListener("wheel", this._onWheelEvent);
|
|
18380
|
-
this._hadListener = false;
|
|
18381
|
-
}
|
|
18410
|
+
this._removeEventListener();
|
|
18382
18411
|
this._nativeEvents = null;
|
|
18383
|
-
this._canvas = null;
|
|
18384
18412
|
this._delta = null;
|
|
18385
18413
|
};
|
|
18386
18414
|
_proto._onWheelEvent = function _onWheelEvent(evt) {
|
|
18387
|
-
evt.cancelable && evt.preventDefault();
|
|
18388
18415
|
this._nativeEvents.push(evt);
|
|
18389
18416
|
};
|
|
18390
18417
|
return WheelManager;
|
|
@@ -18393,19 +18420,19 @@ __decorate([
|
|
|
18393
18420
|
/**
|
|
18394
18421
|
* InputManager manages device input such as mouse, touch, keyboard, etc.
|
|
18395
18422
|
*/ var InputManager = /*#__PURE__*/ function() {
|
|
18396
|
-
function InputManager(engine) {
|
|
18423
|
+
function InputManager(engine, inputOptions) {
|
|
18397
18424
|
/** Sometimes the input module will not be initialized, such as off-screen rendering. */ this._initialized = false;
|
|
18398
18425
|
this._engine = engine;
|
|
18399
18426
|
// @ts-ignore
|
|
18400
18427
|
var canvas = engine._canvas._webCanvas;
|
|
18401
18428
|
if (typeof OffscreenCanvas === "undefined" || !_instanceof(canvas, OffscreenCanvas)) {
|
|
18402
|
-
|
|
18403
|
-
|
|
18404
|
-
this.
|
|
18405
|
-
|
|
18406
|
-
|
|
18407
|
-
|
|
18408
|
-
|
|
18429
|
+
var _inputOptions, _inputOptions1, _inputOptions2;
|
|
18430
|
+
var _inputOptions_wheelTarget;
|
|
18431
|
+
this._wheelManager = new WheelManager(engine, (_inputOptions_wheelTarget = (_inputOptions = inputOptions) == null ? void 0 : _inputOptions.wheelTarget) != null ? _inputOptions_wheelTarget : canvas);
|
|
18432
|
+
var _inputOptions_pointerTarget;
|
|
18433
|
+
this._pointerManager = new PointerManager(engine, (_inputOptions_pointerTarget = (_inputOptions1 = inputOptions) == null ? void 0 : _inputOptions1.pointerTarget) != null ? _inputOptions_pointerTarget : canvas);
|
|
18434
|
+
var _inputOptions_keyboardTarget;
|
|
18435
|
+
this._keyboardManager = new KeyboardManager(engine, (_inputOptions_keyboardTarget = (_inputOptions2 = inputOptions) == null ? void 0 : _inputOptions2.keyboardTarget) != null ? _inputOptions_keyboardTarget : window);
|
|
18409
18436
|
this._initialized = true;
|
|
18410
18437
|
}
|
|
18411
18438
|
}
|
|
@@ -18518,8 +18545,6 @@ __decorate([
|
|
|
18518
18545
|
* @internal
|
|
18519
18546
|
*/ _proto._destroy = function _destroy() {
|
|
18520
18547
|
if (this._initialized) {
|
|
18521
|
-
window.removeEventListener("blur", this._onBlur);
|
|
18522
|
-
window.removeEventListener("focus", this._onFocus);
|
|
18523
18548
|
this._wheelManager._destroy();
|
|
18524
18549
|
this._wheelManager = null;
|
|
18525
18550
|
this._pointerManager._destroy();
|
|
@@ -18528,16 +18553,6 @@ __decorate([
|
|
|
18528
18553
|
this._keyboardManager = null;
|
|
18529
18554
|
}
|
|
18530
18555
|
};
|
|
18531
|
-
_proto._onBlur = function _onBlur() {
|
|
18532
|
-
this._wheelManager._onBlur();
|
|
18533
|
-
this._pointerManager._onBlur();
|
|
18534
|
-
this._keyboardManager._onBlur();
|
|
18535
|
-
};
|
|
18536
|
-
_proto._onFocus = function _onFocus() {
|
|
18537
|
-
this._wheelManager._onFocus();
|
|
18538
|
-
this._pointerManager._onFocus();
|
|
18539
|
-
this._keyboardManager._onFocus();
|
|
18540
|
-
};
|
|
18541
18556
|
_create_class(InputManager, [
|
|
18542
18557
|
{
|
|
18543
18558
|
key: "pointers",
|
|
@@ -18580,6 +18595,8 @@ __decorate([
|
|
|
18580
18595
|
_this = ReferResource1.call(this, engine) || this;
|
|
18581
18596
|
/** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
|
|
18582
18597
|
;
|
|
18598
|
+
/** @internal */ _this._priority = 0 // todo: temporary resolution of submesh rendering order issue.
|
|
18599
|
+
;
|
|
18583
18600
|
_this._shaderData = new ShaderData(ShaderDataGroup.Material);
|
|
18584
18601
|
_this.shader = shader;
|
|
18585
18602
|
return _this;
|
|
@@ -19033,7 +19050,7 @@ ShaderPool.init();
|
|
|
19033
19050
|
_this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
|
|
19034
19051
|
_this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
|
|
19035
19052
|
_this._textDefaultFont.isGCIgnored = true;
|
|
19036
|
-
_this.inputManager = new InputManager(_assert_this_initialized(_this));
|
|
19053
|
+
_this.inputManager = new InputManager(_assert_this_initialized(_this), configuration.input);
|
|
19037
19054
|
var xrDevice = configuration.xrDevice;
|
|
19038
19055
|
if (xrDevice) {
|
|
19039
19056
|
_this.xrManager = new XRManager();
|
|
@@ -19049,11 +19066,11 @@ ShaderPool.init();
|
|
|
19049
19066
|
}
|
|
19050
19067
|
var meshMagentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("unlit"));
|
|
19051
19068
|
meshMagentaMaterial.isGCIgnored = true;
|
|
19052
|
-
meshMagentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
|
|
19069
|
+
meshMagentaMaterial.shaderData.setColor("material_BaseColor", new engineMath.Color(1.0, 0.0, 1.01, 1.0));
|
|
19053
19070
|
_this._meshMagentaMaterial = meshMagentaMaterial;
|
|
19054
19071
|
var particleMagentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("particle-shader"));
|
|
19055
19072
|
particleMagentaMaterial.isGCIgnored = true;
|
|
19056
|
-
particleMagentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
|
|
19073
|
+
particleMagentaMaterial.shaderData.setColor("material_BaseColor", new engineMath.Color(1.0, 0.0, 1.01, 1.0));
|
|
19057
19074
|
_this._particleMagentaMaterial = particleMagentaMaterial;
|
|
19058
19075
|
var innerSettings = _this._settings;
|
|
19059
19076
|
var colorSpace = configuration.colorSpace || exports.ColorSpace.Linear;
|
|
@@ -21869,12 +21886,48 @@ var passNum = 0;
|
|
|
21869
21886
|
/**
|
|
21870
21887
|
* @internal
|
|
21871
21888
|
*/ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
|
|
21872
|
-
|
|
21889
|
+
var dataA = a.data;
|
|
21890
|
+
var dataB = b.data;
|
|
21891
|
+
var componentA = dataA.component;
|
|
21892
|
+
var componentB = dataB.component;
|
|
21893
|
+
var priorityOrder = componentA.priority - componentB.priority;
|
|
21894
|
+
if (priorityOrder !== 0) {
|
|
21895
|
+
return priorityOrder;
|
|
21896
|
+
}
|
|
21897
|
+
// make suer from the same renderer.
|
|
21898
|
+
if (componentA.instanceId === componentB.instanceId) {
|
|
21899
|
+
return dataA.material._priority - dataB.material._priority || componentA._distanceForSort - componentB._distanceForSort;
|
|
21900
|
+
} else {
|
|
21901
|
+
var distanceDiff = componentA._distanceForSort - componentB._distanceForSort;
|
|
21902
|
+
if (distanceDiff === 0) {
|
|
21903
|
+
return componentA.instanceId - componentB.instanceId;
|
|
21904
|
+
} else {
|
|
21905
|
+
return distanceDiff;
|
|
21906
|
+
}
|
|
21907
|
+
}
|
|
21873
21908
|
};
|
|
21874
21909
|
/**
|
|
21875
21910
|
* @internal
|
|
21876
21911
|
*/ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
|
|
21877
|
-
|
|
21912
|
+
var dataA = a.data;
|
|
21913
|
+
var dataB = b.data;
|
|
21914
|
+
var componentA = dataA.component;
|
|
21915
|
+
var componentB = dataB.component;
|
|
21916
|
+
var priorityOrder = componentA.priority - componentB.priority;
|
|
21917
|
+
if (priorityOrder !== 0) {
|
|
21918
|
+
return priorityOrder;
|
|
21919
|
+
}
|
|
21920
|
+
// make suer from the same renderer.
|
|
21921
|
+
if (componentA.instanceId === componentB.instanceId) {
|
|
21922
|
+
return dataA.material._priority - dataB.material._priority || componentB._distanceForSort - componentA._distanceForSort;
|
|
21923
|
+
} else {
|
|
21924
|
+
var distanceDiff = componentB._distanceForSort - componentA._distanceForSort;
|
|
21925
|
+
if (distanceDiff === 0) {
|
|
21926
|
+
return componentA.instanceId - componentB.instanceId;
|
|
21927
|
+
} else {
|
|
21928
|
+
return distanceDiff;
|
|
21929
|
+
}
|
|
21930
|
+
}
|
|
21878
21931
|
};
|
|
21879
21932
|
return RenderQueue;
|
|
21880
21933
|
}();
|
|
@@ -23087,14 +23140,14 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23087
23140
|
/** @internal */ _this._cameraIndex = -1;
|
|
23088
23141
|
_this._priority = 0;
|
|
23089
23142
|
_this._shaderData = new ShaderData(ShaderDataGroup.Camera);
|
|
23090
|
-
_this.
|
|
23143
|
+
_this._isCustomViewMatrix = false;
|
|
23144
|
+
_this._isCustomProjectionMatrix = false;
|
|
23091
23145
|
_this._nearClipPlane = 0.1;
|
|
23092
23146
|
_this._farClipPlane = 100;
|
|
23093
23147
|
_this._fieldOfView = 45;
|
|
23094
23148
|
_this._orthographicSize = 10;
|
|
23095
23149
|
_this._isProjectionDirty = true;
|
|
23096
23150
|
_this._isInvProjMatDirty = true;
|
|
23097
|
-
_this._isFrustumProjectDirty = true;
|
|
23098
23151
|
_this._customAspectRatio = undefined;
|
|
23099
23152
|
_this._renderTarget = null;
|
|
23100
23153
|
_this._depthBufferParams = new engineMath.Vector4();
|
|
@@ -23106,7 +23159,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23106
23159
|
_this._transform = transform;
|
|
23107
23160
|
_this._isViewMatrixDirty = transform.registerWorldChangeFlag();
|
|
23108
23161
|
_this._isInvViewProjDirty = transform.registerWorldChangeFlag();
|
|
23109
|
-
_this.
|
|
23162
|
+
_this._frustumChangeFlag = transform.registerWorldChangeFlag();
|
|
23110
23163
|
_this._renderPipeline = new BasicRenderPipeline(_assert_this_initialized(_this));
|
|
23111
23164
|
_this._addResourceReferCount(_this.shaderData, 1);
|
|
23112
23165
|
_this._updatePixelViewport();
|
|
@@ -23118,16 +23171,22 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23118
23171
|
}
|
|
23119
23172
|
var _proto = Camera1.prototype;
|
|
23120
23173
|
/**
|
|
23174
|
+
* Restore the view matrix to the world matrix of the entity.
|
|
23175
|
+
*/ _proto.resetViewMatrix = function resetViewMatrix() {
|
|
23176
|
+
this._isCustomViewMatrix = false;
|
|
23177
|
+
this._viewMatrixChange();
|
|
23178
|
+
};
|
|
23179
|
+
/**
|
|
23121
23180
|
* Restore the automatic calculation of projection matrix through fieldOfView, nearClipPlane and farClipPlane.
|
|
23122
23181
|
*/ _proto.resetProjectionMatrix = function resetProjectionMatrix() {
|
|
23123
|
-
this.
|
|
23124
|
-
this.
|
|
23182
|
+
this._isCustomProjectionMatrix = false;
|
|
23183
|
+
this._projectionMatrixChange();
|
|
23125
23184
|
};
|
|
23126
23185
|
/**
|
|
23127
23186
|
* Restore the automatic calculation of the aspect ratio through the viewport aspect ratio.
|
|
23128
23187
|
*/ _proto.resetAspectRatio = function resetAspectRatio() {
|
|
23129
23188
|
this._customAspectRatio = undefined;
|
|
23130
|
-
this.
|
|
23189
|
+
this._projectionMatrixChange();
|
|
23131
23190
|
};
|
|
23132
23191
|
/**
|
|
23133
23192
|
* Transform a point from world space to viewport space.
|
|
@@ -23257,10 +23316,9 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23257
23316
|
context.replacementShader = this._replacementShader;
|
|
23258
23317
|
context.replacementTag = this._replacementSubShaderTag;
|
|
23259
23318
|
// compute cull frustum.
|
|
23260
|
-
if (this.enableFrustumCulling &&
|
|
23319
|
+
if (this.enableFrustumCulling && this._frustumChangeFlag.flag) {
|
|
23261
23320
|
this._frustum.calculateFromMatrix(virtualCamera.viewProjectionMatrix);
|
|
23262
|
-
this.
|
|
23263
|
-
this._isFrustumProjectDirty = false;
|
|
23321
|
+
this._frustumChangeFlag.flag = false;
|
|
23264
23322
|
}
|
|
23265
23323
|
this._updateShaderData();
|
|
23266
23324
|
// union scene and camera macro.
|
|
@@ -23315,7 +23373,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23315
23373
|
this._renderPipeline = null;
|
|
23316
23374
|
this._virtualCamera = null;
|
|
23317
23375
|
this._shaderData = null;
|
|
23318
|
-
this.
|
|
23376
|
+
this._frustumChangeFlag = null;
|
|
23319
23377
|
this._transform = null;
|
|
23320
23378
|
this._isViewMatrixDirty = null;
|
|
23321
23379
|
this._isInvViewProjDirty = null;
|
|
@@ -23337,11 +23395,16 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23337
23395
|
var viewport = this._viewport;
|
|
23338
23396
|
this._pixelViewport.set(viewport.x * width, viewport.y * height, viewport.z * width, viewport.w * height);
|
|
23339
23397
|
};
|
|
23340
|
-
_proto.
|
|
23341
|
-
this.
|
|
23398
|
+
_proto._viewMatrixChange = function _viewMatrixChange() {
|
|
23399
|
+
this._isViewMatrixDirty.flag = true;
|
|
23400
|
+
this._isInvViewProjDirty.flag = true;
|
|
23401
|
+
this._frustumChangeFlag.flag = true;
|
|
23402
|
+
};
|
|
23403
|
+
_proto._projectionMatrixChange = function _projectionMatrixChange() {
|
|
23342
23404
|
this._isProjectionDirty = true;
|
|
23343
23405
|
this._isInvProjMatDirty = true;
|
|
23344
23406
|
this._isInvViewProjDirty.flag = true;
|
|
23407
|
+
this._frustumChangeFlag.flag = true;
|
|
23345
23408
|
};
|
|
23346
23409
|
_proto._innerViewportToWorldPoint = function _innerViewportToWorldPoint(x, y, z, invViewProjMat, out) {
|
|
23347
23410
|
// Depth is a normalized value, 0 is nearPlane, 1 is farClipPlane.
|
|
@@ -23384,7 +23447,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23384
23447
|
_proto._onPixelViewportChanged = function _onPixelViewportChanged() {
|
|
23385
23448
|
this._updatePixelViewport();
|
|
23386
23449
|
var _this__customAspectRatio;
|
|
23387
|
-
(_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this.
|
|
23450
|
+
(_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this._projectionMatrixChange();
|
|
23388
23451
|
};
|
|
23389
23452
|
_create_class(Camera1, [
|
|
23390
23453
|
{
|
|
@@ -23404,7 +23467,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23404
23467
|
},
|
|
23405
23468
|
set: function set(value) {
|
|
23406
23469
|
this._nearClipPlane = value;
|
|
23407
|
-
this.
|
|
23470
|
+
this._projectionMatrixChange();
|
|
23408
23471
|
}
|
|
23409
23472
|
},
|
|
23410
23473
|
{
|
|
@@ -23416,7 +23479,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23416
23479
|
},
|
|
23417
23480
|
set: function set(value) {
|
|
23418
23481
|
this._farClipPlane = value;
|
|
23419
|
-
this.
|
|
23482
|
+
this._projectionMatrixChange();
|
|
23420
23483
|
}
|
|
23421
23484
|
},
|
|
23422
23485
|
{
|
|
@@ -23428,7 +23491,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23428
23491
|
},
|
|
23429
23492
|
set: function set(value) {
|
|
23430
23493
|
this._fieldOfView = value;
|
|
23431
|
-
this.
|
|
23494
|
+
this._projectionMatrixChange();
|
|
23432
23495
|
}
|
|
23433
23496
|
},
|
|
23434
23497
|
{
|
|
@@ -23443,7 +23506,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23443
23506
|
},
|
|
23444
23507
|
set: function set(value) {
|
|
23445
23508
|
this._customAspectRatio = value;
|
|
23446
|
-
this.
|
|
23509
|
+
this._projectionMatrixChange();
|
|
23447
23510
|
}
|
|
23448
23511
|
},
|
|
23449
23512
|
{
|
|
@@ -23495,7 +23558,12 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23495
23558
|
},
|
|
23496
23559
|
set: function set(value) {
|
|
23497
23560
|
this._virtualCamera.isOrthographic = value;
|
|
23498
|
-
this.
|
|
23561
|
+
this._projectionMatrixChange();
|
|
23562
|
+
if (value) {
|
|
23563
|
+
this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC");
|
|
23564
|
+
} else {
|
|
23565
|
+
this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC");
|
|
23566
|
+
}
|
|
23499
23567
|
}
|
|
23500
23568
|
},
|
|
23501
23569
|
{
|
|
@@ -23507,7 +23575,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23507
23575
|
},
|
|
23508
23576
|
set: function set(value) {
|
|
23509
23577
|
this._orthographicSize = value;
|
|
23510
|
-
this.
|
|
23578
|
+
this._projectionMatrixChange();
|
|
23511
23579
|
}
|
|
23512
23580
|
},
|
|
23513
23581
|
{
|
|
@@ -23516,22 +23584,31 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23516
23584
|
* View matrix.
|
|
23517
23585
|
*/ function get() {
|
|
23518
23586
|
var viewMatrix = this._virtualCamera.viewMatrix;
|
|
23519
|
-
if (this._isViewMatrixDirty.flag) {
|
|
23520
|
-
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23524
|
-
|
|
23525
|
-
|
|
23587
|
+
if (!this._isViewMatrixDirty.flag || this._isCustomViewMatrix) {
|
|
23588
|
+
return viewMatrix;
|
|
23589
|
+
}
|
|
23590
|
+
this._isViewMatrixDirty.flag = false;
|
|
23591
|
+
// Ignore scale
|
|
23592
|
+
var transform = this._transform;
|
|
23593
|
+
engineMath.Matrix.rotationTranslation(transform.worldRotationQuaternion, transform.worldPosition, viewMatrix);
|
|
23594
|
+
viewMatrix.invert();
|
|
23526
23595
|
return viewMatrix;
|
|
23596
|
+
},
|
|
23597
|
+
set: function set(value) {
|
|
23598
|
+
this._virtualCamera.viewMatrix.copyFrom(value);
|
|
23599
|
+
this._isCustomViewMatrix = true;
|
|
23600
|
+
this._viewMatrixChange();
|
|
23527
23601
|
}
|
|
23528
23602
|
},
|
|
23529
23603
|
{
|
|
23530
23604
|
key: "projectionMatrix",
|
|
23531
|
-
get:
|
|
23605
|
+
get: /**
|
|
23606
|
+
* The projection matrix is calculated by the relevant parameters of the camera by default.
|
|
23607
|
+
* If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
|
|
23608
|
+
*/ function get() {
|
|
23532
23609
|
var virtualCamera = this._virtualCamera;
|
|
23533
23610
|
var projectionMatrix = virtualCamera.projectionMatrix;
|
|
23534
|
-
if (!this._isProjectionDirty || this.
|
|
23611
|
+
if (!this._isProjectionDirty || this._isCustomProjectionMatrix) {
|
|
23535
23612
|
return projectionMatrix;
|
|
23536
23613
|
}
|
|
23537
23614
|
this._isProjectionDirty = false;
|
|
@@ -23545,13 +23622,10 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23545
23622
|
}
|
|
23546
23623
|
return projectionMatrix;
|
|
23547
23624
|
},
|
|
23548
|
-
set:
|
|
23549
|
-
* The projection matrix is calculated by the relevant parameters of the camera by default.
|
|
23550
|
-
* If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
|
|
23551
|
-
*/ function set(value) {
|
|
23625
|
+
set: function set(value) {
|
|
23552
23626
|
this._virtualCamera.projectionMatrix.copyFrom(value);
|
|
23553
|
-
this.
|
|
23554
|
-
this.
|
|
23627
|
+
this._isCustomProjectionMatrix = true;
|
|
23628
|
+
this._projectionMatrixChange();
|
|
23555
23629
|
}
|
|
23556
23630
|
},
|
|
23557
23631
|
{
|
|
@@ -23612,7 +23686,7 @@ __decorate([
|
|
|
23612
23686
|
], exports.Camera.prototype, "_cameraIndex", void 0);
|
|
23613
23687
|
__decorate([
|
|
23614
23688
|
ignoreClone
|
|
23615
|
-
], exports.Camera.prototype, "
|
|
23689
|
+
], exports.Camera.prototype, "_frustumChangeFlag", void 0);
|
|
23616
23690
|
__decorate([
|
|
23617
23691
|
ignoreClone
|
|
23618
23692
|
], exports.Camera.prototype, "_transform", void 0);
|
|
@@ -25245,6 +25319,7 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
25245
25319
|
_this = EngineObject1.call(this, null) || this;
|
|
25246
25320
|
_this.name = name;
|
|
25247
25321
|
_this./** @internal */ _curveBindings = [];
|
|
25322
|
+
_this./** @internal */ _updateFlagManager = new UpdateFlagManager();
|
|
25248
25323
|
_this._length = 0;
|
|
25249
25324
|
_this._events = [];
|
|
25250
25325
|
return _this;
|
|
@@ -25272,11 +25347,13 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
25272
25347
|
while(--index >= 0 && eventTime < events[index].time);
|
|
25273
25348
|
events.splice(index + 1, 0, newEvent);
|
|
25274
25349
|
}
|
|
25350
|
+
this._updateFlagManager.dispatch();
|
|
25275
25351
|
};
|
|
25276
25352
|
/**
|
|
25277
25353
|
* Clears all events from the clip.
|
|
25278
25354
|
*/ _proto.clearEvents = function clearEvents() {
|
|
25279
25355
|
this._events.length = 0;
|
|
25356
|
+
this._updateFlagManager.dispatch();
|
|
25280
25357
|
};
|
|
25281
25358
|
_proto.addCurveBinding = function addCurveBinding(entityPath, componentType, propertyOrSetPropertyPathOrComponentIndex, curveOrSetPropertyPathOrGetPropertyPath, curveOrGetPropertyPath, curve) {
|
|
25282
25359
|
var curveBinding = new AnimationClipCurveBinding();
|
|
@@ -26833,26 +26910,31 @@ exports.AnimatorLayerBlendingMode = void 0;
|
|
|
26833
26910
|
}
|
|
26834
26911
|
};
|
|
26835
26912
|
_proto._saveAnimatorEventHandlers = function _saveAnimatorEventHandlers(state, animatorStateData) {
|
|
26913
|
+
var _this = this;
|
|
26836
26914
|
var eventHandlerPool = this._animationEventHandlerPool;
|
|
26837
26915
|
var scripts = [];
|
|
26838
|
-
this._entity.getComponents(Script, scripts);
|
|
26839
|
-
var scriptCount = scripts.length;
|
|
26840
26916
|
var eventHandlers = animatorStateData.eventHandlers;
|
|
26841
|
-
var
|
|
26842
|
-
|
|
26843
|
-
|
|
26844
|
-
var
|
|
26845
|
-
|
|
26846
|
-
var
|
|
26847
|
-
|
|
26848
|
-
|
|
26849
|
-
|
|
26850
|
-
|
|
26851
|
-
|
|
26852
|
-
|
|
26917
|
+
var clipChangedListener = function() {
|
|
26918
|
+
_this._entity.getComponents(Script, scripts);
|
|
26919
|
+
var scriptCount = scripts.length;
|
|
26920
|
+
var events = state.clip.events;
|
|
26921
|
+
eventHandlers.length = 0;
|
|
26922
|
+
for(var i = 0, n = events.length; i < n; i++){
|
|
26923
|
+
var event = events[i];
|
|
26924
|
+
var eventHandler = eventHandlerPool.getFromPool();
|
|
26925
|
+
var funcName = event.functionName;
|
|
26926
|
+
var handlers = eventHandler.handlers;
|
|
26927
|
+
eventHandler.event = event;
|
|
26928
|
+
handlers.length = 0;
|
|
26929
|
+
for(var j = scriptCount - 1; j >= 0; j--){
|
|
26930
|
+
var handler = scripts[j][funcName];
|
|
26931
|
+
handler && handlers.push(handler);
|
|
26932
|
+
}
|
|
26933
|
+
eventHandlers.push(eventHandler);
|
|
26853
26934
|
}
|
|
26854
|
-
|
|
26855
|
-
|
|
26935
|
+
};
|
|
26936
|
+
clipChangedListener();
|
|
26937
|
+
state._updateFlagManager.addListener(clipChangedListener);
|
|
26856
26938
|
};
|
|
26857
26939
|
_proto._clearCrossData = function _clearCrossData(animatorLayerData) {
|
|
26858
26940
|
animatorLayerData.crossCurveMark++;
|
|
@@ -27463,9 +27545,11 @@ __decorate([
|
|
|
27463
27545
|
this./** @internal */ _onStateEnterScripts = [];
|
|
27464
27546
|
this./** @internal */ _onStateUpdateScripts = [];
|
|
27465
27547
|
this./** @internal */ _onStateExitScripts = [];
|
|
27548
|
+
this./** @internal */ _updateFlagManager = new UpdateFlagManager();
|
|
27466
27549
|
this._clipStartTime = 0;
|
|
27467
27550
|
this._clipEndTime = 1;
|
|
27468
27551
|
this._transitions = [];
|
|
27552
|
+
this._onClipChanged = this._onClipChanged.bind(this);
|
|
27469
27553
|
}
|
|
27470
27554
|
var _proto = AnimatorState.prototype;
|
|
27471
27555
|
/**
|
|
@@ -27539,6 +27623,11 @@ __decorate([
|
|
|
27539
27623
|
index2 !== -1 && this._onStateExitScripts.splice(index2, 1);
|
|
27540
27624
|
}
|
|
27541
27625
|
};
|
|
27626
|
+
/**
|
|
27627
|
+
* @internal
|
|
27628
|
+
*/ _proto._onClipChanged = function _onClipChanged() {
|
|
27629
|
+
this._updateFlagManager.dispatch();
|
|
27630
|
+
};
|
|
27542
27631
|
_create_class(AnimatorState, [
|
|
27543
27632
|
{
|
|
27544
27633
|
key: "transitions",
|
|
@@ -27556,8 +27645,17 @@ __decorate([
|
|
|
27556
27645
|
return this._clip;
|
|
27557
27646
|
},
|
|
27558
27647
|
set: function set(clip) {
|
|
27648
|
+
var lastClip = this._clip;
|
|
27649
|
+
if (lastClip === clip) {
|
|
27650
|
+
return;
|
|
27651
|
+
}
|
|
27652
|
+
if (lastClip) {
|
|
27653
|
+
lastClip._updateFlagManager.removeListener(this._onClipChanged);
|
|
27654
|
+
}
|
|
27559
27655
|
this._clip = clip;
|
|
27560
27656
|
this._clipEndTime = Math.min(this._clipEndTime, 1);
|
|
27657
|
+
this._onClipChanged();
|
|
27658
|
+
clip._updateFlagManager.addListener(this._onClipChanged);
|
|
27561
27659
|
}
|
|
27562
27660
|
},
|
|
27563
27661
|
{
|