@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/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MathUtil
|
|
1
|
+
import { MathUtil, Vector2, BoundingBox, Rect, Vector4, Quaternion, Vector3, Matrix3x3, Matrix, Color, Ray, Plane, BoundingSphere, FrustumFace, CollisionUtil, BoundingFrustum, Rand } from '@galacean/engine-math';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The platform (including operating system and hardware) is running on.
|
|
@@ -55,347 +55,6 @@ function _inherits(subClass, superClass) {
|
|
|
55
55
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
* Common utility methods for math operations.
|
|
60
|
-
*/ var MathUtil = /*#__PURE__*/ function() {
|
|
61
|
-
function MathUtil() {}
|
|
62
|
-
/**
|
|
63
|
-
* Clamps the specified value.
|
|
64
|
-
* @param v - The specified value
|
|
65
|
-
* @param min - The min value
|
|
66
|
-
* @param max - The max value
|
|
67
|
-
* @returns The result of clamping a value between min and max
|
|
68
|
-
*/ MathUtil.clamp = function clamp(v, min, max) {
|
|
69
|
-
return Math.max(min, Math.min(max, v));
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Checks if a and b are almost equals.
|
|
73
|
-
* The absolute value of the difference between a and b is close to zero.
|
|
74
|
-
* @param a - The left value to compare
|
|
75
|
-
* @param b - The right value to compare
|
|
76
|
-
* @returns True if a almost equal to b, false otherwise
|
|
77
|
-
*/ MathUtil.equals = function equals(a, b) {
|
|
78
|
-
return Math.abs(a - b) <= MathUtil.zeroTolerance;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Determines whether the specified v is pow2.
|
|
82
|
-
* @param v - The specified v
|
|
83
|
-
* @returns True if the specified v is pow2, false otherwise
|
|
84
|
-
*/ MathUtil.isPowerOf2 = function isPowerOf2(v) {
|
|
85
|
-
return (v & v - 1) === 0;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Modify the specified r from radian to degree.
|
|
89
|
-
* @param r - The specified r
|
|
90
|
-
* @returns The degree value
|
|
91
|
-
*/ MathUtil.radianToDegree = function radianToDegree(r) {
|
|
92
|
-
return r * MathUtil.radToDegreeFactor;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Modify the specified d from degree to radian.
|
|
96
|
-
* @param d - The specified d
|
|
97
|
-
* @returns The radian value
|
|
98
|
-
*/ MathUtil.degreeToRadian = function degreeToRadian(d) {
|
|
99
|
-
return d * MathUtil.degreeToRadFactor;
|
|
100
|
-
};
|
|
101
|
-
return MathUtil;
|
|
102
|
-
}();
|
|
103
|
-
(function() {
|
|
104
|
-
/** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
|
|
105
|
-
})();
|
|
106
|
-
(function() {
|
|
107
|
-
/** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
|
|
108
|
-
})();
|
|
109
|
-
(function() {
|
|
110
|
-
/** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
|
|
111
|
-
})();
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Describes a color in the from of RGBA (in order: R, G, B, A).
|
|
115
|
-
*/ var Color = /*#__PURE__*/ function() {
|
|
116
|
-
function Color(r, g, b, a) {
|
|
117
|
-
if (r === void 0) r = 1;
|
|
118
|
-
if (g === void 0) g = 1;
|
|
119
|
-
if (b === void 0) b = 1;
|
|
120
|
-
if (a === void 0) a = 1;
|
|
121
|
-
/** @internal */ this._onValueChanged = null;
|
|
122
|
-
this._r = r;
|
|
123
|
-
this._g = g;
|
|
124
|
-
this._b = b;
|
|
125
|
-
this._a = a;
|
|
126
|
-
}
|
|
127
|
-
var _proto = Color.prototype;
|
|
128
|
-
/**
|
|
129
|
-
* Set the value of this color.
|
|
130
|
-
* @param r - The red component of the color
|
|
131
|
-
* @param g - The green component of the color
|
|
132
|
-
* @param b - The blue component of the color
|
|
133
|
-
* @param a - The alpha component of the color
|
|
134
|
-
* @returns This color.
|
|
135
|
-
*/ _proto.set = function set(r, g, b, a) {
|
|
136
|
-
this._r = r;
|
|
137
|
-
this._g = g;
|
|
138
|
-
this._b = b;
|
|
139
|
-
this._a = a;
|
|
140
|
-
this._onValueChanged && this._onValueChanged();
|
|
141
|
-
return this;
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* Determines the sum of this color and the specified color.
|
|
145
|
-
* @param color - The specified color
|
|
146
|
-
* @returns The added color
|
|
147
|
-
*/ _proto.add = function add(color) {
|
|
148
|
-
this._r += color._r;
|
|
149
|
-
this._g += color._g;
|
|
150
|
-
this._b += color._b;
|
|
151
|
-
this._a += color._a;
|
|
152
|
-
this._onValueChanged && this._onValueChanged();
|
|
153
|
-
return this;
|
|
154
|
-
};
|
|
155
|
-
/**
|
|
156
|
-
* Scale this color by the given value.
|
|
157
|
-
* @param s - The amount by which to scale the color
|
|
158
|
-
* @returns The scaled color
|
|
159
|
-
*/ _proto.scale = function scale(s) {
|
|
160
|
-
this._r *= s;
|
|
161
|
-
this._g *= s;
|
|
162
|
-
this._b *= s;
|
|
163
|
-
this._a *= s;
|
|
164
|
-
this._onValueChanged && this._onValueChanged();
|
|
165
|
-
return this;
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* Creates a clone of this color.
|
|
169
|
-
* @returns A clone of this color
|
|
170
|
-
*/ _proto.clone = function clone() {
|
|
171
|
-
var ret = new Color(this._r, this._g, this._b, this._a);
|
|
172
|
-
return ret;
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Copy from color like object.
|
|
176
|
-
* @param source - Color like object.
|
|
177
|
-
* @returns This vector
|
|
178
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
179
|
-
this._r = source.r;
|
|
180
|
-
this._g = source.g;
|
|
181
|
-
this._b = source.b;
|
|
182
|
-
this._a = source.a;
|
|
183
|
-
this._onValueChanged && this._onValueChanged();
|
|
184
|
-
return this;
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* Copy from array like object.
|
|
188
|
-
* @param source - Array like object
|
|
189
|
-
* @param offset - The start offset
|
|
190
|
-
* @returns This color
|
|
191
|
-
*/ _proto.copyFromArray = function copyFromArray(source, offset) {
|
|
192
|
-
if (offset === void 0) offset = 0;
|
|
193
|
-
this._r = source[offset];
|
|
194
|
-
this._g = source[offset + 1];
|
|
195
|
-
this._b = source[offset + 2];
|
|
196
|
-
this._a = source[offset + 3];
|
|
197
|
-
this._onValueChanged && this._onValueChanged();
|
|
198
|
-
return this;
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* Copy the value of this color to an array.
|
|
202
|
-
* @param out - The color
|
|
203
|
-
* @param outOffset - The start offset
|
|
204
|
-
*/ _proto.copyToArray = function copyToArray(out, outOffset) {
|
|
205
|
-
if (outOffset === void 0) outOffset = 0;
|
|
206
|
-
out[outOffset] = this._r;
|
|
207
|
-
out[outOffset + 1] = this._g;
|
|
208
|
-
out[outOffset + 2] = this._b;
|
|
209
|
-
out[outOffset + 3] = this._a;
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* Modify components (r, g, b) of this color from gamma space to linear space.
|
|
213
|
-
* @param out - The color in linear space
|
|
214
|
-
* @returns The color in linear space
|
|
215
|
-
*/ _proto.toLinear = function toLinear(out) {
|
|
216
|
-
out._r = Color.gammaToLinearSpace(this._r);
|
|
217
|
-
out._g = Color.gammaToLinearSpace(this._g);
|
|
218
|
-
out._b = Color.gammaToLinearSpace(this._b);
|
|
219
|
-
this._onValueChanged && this._onValueChanged();
|
|
220
|
-
return out;
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* Modify components (r, g, b) of this color from linear space to gamma space.
|
|
224
|
-
* @param out - The color in gamma space
|
|
225
|
-
* @returns The color in gamma space
|
|
226
|
-
*/ _proto.toGamma = function toGamma(out) {
|
|
227
|
-
out._r = Color.linearToGammaSpace(this._r);
|
|
228
|
-
out._g = Color.linearToGammaSpace(this._g);
|
|
229
|
-
out._b = Color.linearToGammaSpace(this._b);
|
|
230
|
-
this._onValueChanged && this._onValueChanged();
|
|
231
|
-
return out;
|
|
232
|
-
};
|
|
233
|
-
/**
|
|
234
|
-
* Gets the brightness.
|
|
235
|
-
* @returns The Hue-Saturation-Brightness (HSB) saturation for this
|
|
236
|
-
*/ _proto.getBrightness = function getBrightness() {
|
|
237
|
-
var r = this.r;
|
|
238
|
-
var g = this.g;
|
|
239
|
-
var b = this.b;
|
|
240
|
-
var max = r;
|
|
241
|
-
var min = r;
|
|
242
|
-
if (g > max) max = g;
|
|
243
|
-
if (b > max) max = b;
|
|
244
|
-
if (g < min) min = g;
|
|
245
|
-
if (b < min) min = b;
|
|
246
|
-
return (max + min) / 2;
|
|
247
|
-
};
|
|
248
|
-
/**
|
|
249
|
-
* Serialize this color to a JSON representation.
|
|
250
|
-
* @return A JSON representation of this color
|
|
251
|
-
*/ _proto.toJSON = function toJSON() {
|
|
252
|
-
return {
|
|
253
|
-
r: this._r,
|
|
254
|
-
g: this._g,
|
|
255
|
-
b: this._b,
|
|
256
|
-
a: this._a
|
|
257
|
-
};
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* Modify a value from the gamma space to the linear space.
|
|
261
|
-
* @param value - The value in gamma space
|
|
262
|
-
* @returns The value in linear space
|
|
263
|
-
*/ Color.gammaToLinearSpace = function gammaToLinearSpace(value) {
|
|
264
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
|
|
265
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
|
|
266
|
-
if (value <= 0.0) return 0.0;
|
|
267
|
-
else if (value <= 0.04045) return value / 12.92;
|
|
268
|
-
else if (value < 1.0) return Math.pow((value + 0.055) / 1.055, 2.4);
|
|
269
|
-
else return Math.pow(value, 2.4);
|
|
270
|
-
};
|
|
271
|
-
/**
|
|
272
|
-
* Modify a value from the linear space to the gamma space.
|
|
273
|
-
* @param value - The value in linear space
|
|
274
|
-
* @returns The value in gamma space
|
|
275
|
-
*/ Color.linearToGammaSpace = function linearToGammaSpace(value) {
|
|
276
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
|
|
277
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
|
|
278
|
-
if (value <= 0.0) return 0.0;
|
|
279
|
-
else if (value < 0.0031308) return 12.92 * value;
|
|
280
|
-
else if (value < 1.0) return 1.055 * Math.pow(value, 0.41666) - 0.055;
|
|
281
|
-
else return Math.pow(value, 0.41666);
|
|
282
|
-
};
|
|
283
|
-
/**
|
|
284
|
-
* Determines whether the specified colors are equals.
|
|
285
|
-
* @param left - The first color to compare
|
|
286
|
-
* @param right - The second color to compare
|
|
287
|
-
* @returns True if the specified colors are equals, false otherwise
|
|
288
|
-
*/ Color.equals = function equals(left, right) {
|
|
289
|
-
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);
|
|
290
|
-
};
|
|
291
|
-
/**
|
|
292
|
-
* Determines the sum of two colors.
|
|
293
|
-
* @param left - The first color to add
|
|
294
|
-
* @param right - The second color to add
|
|
295
|
-
* @param out - The sum of two colors
|
|
296
|
-
* @returns The added color
|
|
297
|
-
*/ Color.add = function add(left, right, out) {
|
|
298
|
-
out._r = left._r + right._r;
|
|
299
|
-
out._g = left._g + right._g;
|
|
300
|
-
out._b = left._b + right._b;
|
|
301
|
-
out._a = left._a + right._a;
|
|
302
|
-
out._onValueChanged && out._onValueChanged();
|
|
303
|
-
return out;
|
|
304
|
-
};
|
|
305
|
-
/**
|
|
306
|
-
* Determines the difference between two colors.
|
|
307
|
-
* @param left - The first color to subtract
|
|
308
|
-
* @param right - The second color to subtract
|
|
309
|
-
* @param out - The difference between two colors
|
|
310
|
-
*/ Color.subtract = function subtract(left, right, out) {
|
|
311
|
-
out._r = left._r - right._r;
|
|
312
|
-
out._g = left._g - right._g;
|
|
313
|
-
out._b = left._b - right._b;
|
|
314
|
-
out._a = left._a - right._a;
|
|
315
|
-
out._onValueChanged && out._onValueChanged();
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* Scale a color by the given value.
|
|
319
|
-
* @param left - The color to scale
|
|
320
|
-
* @param s - The amount by which to scale the color
|
|
321
|
-
* @param out - The scaled color
|
|
322
|
-
* @returns The scaled color
|
|
323
|
-
*/ Color.scale = function scale(left, s, out) {
|
|
324
|
-
out._r = left._r * s;
|
|
325
|
-
out._g = left._g * s;
|
|
326
|
-
out._b = left._b * s;
|
|
327
|
-
out._a = left._a * s;
|
|
328
|
-
out._onValueChanged && out._onValueChanged();
|
|
329
|
-
return out;
|
|
330
|
-
};
|
|
331
|
-
/**
|
|
332
|
-
* Performs a linear interpolation between two color.
|
|
333
|
-
* @param start - The first color
|
|
334
|
-
* @param end - The second color
|
|
335
|
-
* @param t - The blend amount where 0 returns start and 1 end
|
|
336
|
-
* @param out - The result of linear blending between two color
|
|
337
|
-
*/ Color.lerp = function lerp(start, end, t, out) {
|
|
338
|
-
var _r = start._r, _g = start._g, _b = start._b, _a = start._a;
|
|
339
|
-
out._r = _r + (end._r - _r) * t;
|
|
340
|
-
out._g = _g + (end._g - _g) * t;
|
|
341
|
-
out._b = _b + (end._b - _b) * t;
|
|
342
|
-
out._a = _a + (end._a - _a) * t;
|
|
343
|
-
out._onValueChanged && out._onValueChanged();
|
|
344
|
-
return out;
|
|
345
|
-
};
|
|
346
|
-
_create_class(Color, [
|
|
347
|
-
{
|
|
348
|
-
key: "r",
|
|
349
|
-
get: /**
|
|
350
|
-
* The red component of the color, 0~1.
|
|
351
|
-
*/ function get() {
|
|
352
|
-
return this._r;
|
|
353
|
-
},
|
|
354
|
-
set: function set(value) {
|
|
355
|
-
this._r = value;
|
|
356
|
-
this._onValueChanged && this._onValueChanged();
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
key: "g",
|
|
361
|
-
get: /**
|
|
362
|
-
* The green component of the color, 0~1.
|
|
363
|
-
*/ function get() {
|
|
364
|
-
return this._g;
|
|
365
|
-
},
|
|
366
|
-
set: function set(value) {
|
|
367
|
-
this._g = value;
|
|
368
|
-
this._onValueChanged && this._onValueChanged();
|
|
369
|
-
}
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
key: "b",
|
|
373
|
-
get: /**
|
|
374
|
-
* The blue component of the color, 0~1.
|
|
375
|
-
*/ function get() {
|
|
376
|
-
return this._b;
|
|
377
|
-
},
|
|
378
|
-
set: function set(value) {
|
|
379
|
-
this._b = value;
|
|
380
|
-
this._onValueChanged && this._onValueChanged();
|
|
381
|
-
}
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
key: "a",
|
|
385
|
-
get: /**
|
|
386
|
-
* The alpha component of the color, 0~1.
|
|
387
|
-
*/ function get() {
|
|
388
|
-
return this._a;
|
|
389
|
-
},
|
|
390
|
-
set: function set(value) {
|
|
391
|
-
this._a = value;
|
|
392
|
-
this._onValueChanged && this._onValueChanged();
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
]);
|
|
396
|
-
return Color;
|
|
397
|
-
}();
|
|
398
|
-
|
|
399
58
|
/**
|
|
400
59
|
* Sprite mask interaction.
|
|
401
60
|
*/ var SpriteMaskInteraction;
|
|
@@ -936,7 +595,14 @@ var Utils = /*#__PURE__*/ function() {
|
|
|
936
595
|
* @param url - The url to be judged.
|
|
937
596
|
* @returns Whether the url is absolute url.
|
|
938
597
|
*/ Utils.isAbsoluteUrl = function isAbsoluteUrl(url) {
|
|
939
|
-
return /^(
|
|
598
|
+
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
|
599
|
+
};
|
|
600
|
+
/**
|
|
601
|
+
* Judge whether the url is base64 url.
|
|
602
|
+
* @param url - The url to be judged.
|
|
603
|
+
* @returns Whether the url is base64 url.
|
|
604
|
+
*/ Utils.isBase64Url = function isBase64Url(url) {
|
|
605
|
+
return /^data:.*,.*$/i.test(url);
|
|
940
606
|
};
|
|
941
607
|
/**
|
|
942
608
|
* Get the values of an object.
|
|
@@ -954,7 +620,10 @@ var Utils = /*#__PURE__*/ function() {
|
|
|
954
620
|
if (Utils.isAbsoluteUrl(relativeUrl)) {
|
|
955
621
|
return relativeUrl;
|
|
956
622
|
}
|
|
957
|
-
|
|
623
|
+
if (Utils.isBase64Url(relativeUrl)) {
|
|
624
|
+
return relativeUrl;
|
|
625
|
+
}
|
|
626
|
+
return relativeUrl ? baseUrl.replace(/\/+$/, "") + "/" + relativeUrl.replace(/^\/+/, "") : baseUrl;
|
|
958
627
|
};
|
|
959
628
|
/**
|
|
960
629
|
* @internal
|
|
@@ -1400,9 +1069,9 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
1400
1069
|
var _this = this, region = _this._region;
|
|
1401
1070
|
// @ts-ignore
|
|
1402
1071
|
region._onValueChanged = null;
|
|
1403
|
-
var x = MathUtil
|
|
1404
|
-
var y = MathUtil
|
|
1405
|
-
region.set(x, y, MathUtil
|
|
1072
|
+
var x = MathUtil.clamp(region.x, 0, 1);
|
|
1073
|
+
var y = MathUtil.clamp(region.y, 0, 1);
|
|
1074
|
+
region.set(x, y, MathUtil.clamp(region.width, 0, 1 - x), MathUtil.clamp(region.height, 0, 1 - y));
|
|
1406
1075
|
this._dispatchSpriteChange(SpriteModifyFlags.region);
|
|
1407
1076
|
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
1408
1077
|
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
@@ -1417,9 +1086,9 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
1417
1086
|
var _this = this, border = _this._border;
|
|
1418
1087
|
// @ts-ignore
|
|
1419
1088
|
border._onValueChanged = null;
|
|
1420
|
-
var x = MathUtil
|
|
1421
|
-
var y = MathUtil
|
|
1422
|
-
border.set(x, y, MathUtil
|
|
1089
|
+
var x = MathUtil.clamp(border.x, 0, 1);
|
|
1090
|
+
var y = MathUtil.clamp(border.y, 0, 1);
|
|
1091
|
+
border.set(x, y, MathUtil.clamp(border.z, 0, 1 - x), MathUtil.clamp(border.w, 0, 1 - y));
|
|
1423
1092
|
this._dispatchSpriteChange(SpriteModifyFlags.border);
|
|
1424
1093
|
// @ts-ignore
|
|
1425
1094
|
border._onValueChanged = this._onBorderChange;
|
|
@@ -1509,9 +1178,9 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
1509
1178
|
return this._atlasRegion;
|
|
1510
1179
|
},
|
|
1511
1180
|
set: function set(value) {
|
|
1512
|
-
var x = MathUtil
|
|
1513
|
-
var y = MathUtil
|
|
1514
|
-
this._atlasRegion.set(x, y, MathUtil
|
|
1181
|
+
var x = MathUtil.clamp(value.x, 0, 1);
|
|
1182
|
+
var y = MathUtil.clamp(value.y, 0, 1);
|
|
1183
|
+
this._atlasRegion.set(x, y, MathUtil.clamp(value.width, 0, 1 - x), MathUtil.clamp(value.height, 0, 1 - y));
|
|
1515
1184
|
this._dispatchSpriteChange(SpriteModifyFlags.atlasRegion);
|
|
1516
1185
|
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
1517
1186
|
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
@@ -1526,9 +1195,9 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
1526
1195
|
return this._atlasRegionOffset;
|
|
1527
1196
|
},
|
|
1528
1197
|
set: function set(value) {
|
|
1529
|
-
var x = MathUtil
|
|
1530
|
-
var y = MathUtil
|
|
1531
|
-
this._atlasRegionOffset.set(x, y, MathUtil
|
|
1198
|
+
var x = MathUtil.clamp(value.x, 0, 1);
|
|
1199
|
+
var y = MathUtil.clamp(value.y, 0, 1);
|
|
1200
|
+
this._atlasRegionOffset.set(x, y, MathUtil.clamp(value.z, 0, 1 - x), MathUtil.clamp(value.w, 0, 1 - y));
|
|
1532
1201
|
this._dispatchSpriteChange(SpriteModifyFlags.atlasRegionOffset);
|
|
1533
1202
|
if (this._customWidth === undefined || this._customHeight === undefined) {
|
|
1534
1203
|
this._dispatchSpriteChange(SpriteModifyFlags.size);
|
|
@@ -2116,20 +1785,28 @@ var ActiveChangeFlag;
|
|
|
2116
1785
|
this._enabled = value;
|
|
2117
1786
|
if (this._entity._isActiveInScene) {
|
|
2118
1787
|
if (value) {
|
|
2119
|
-
this._phasedActiveInScene
|
|
2120
|
-
|
|
1788
|
+
if (!this._phasedActiveInScene) {
|
|
1789
|
+
this._phasedActiveInScene = true;
|
|
1790
|
+
this._onEnableInScene();
|
|
1791
|
+
}
|
|
2121
1792
|
} else {
|
|
2122
|
-
this._phasedActiveInScene
|
|
2123
|
-
|
|
1793
|
+
if (this._phasedActiveInScene) {
|
|
1794
|
+
this._phasedActiveInScene = false;
|
|
1795
|
+
this._onDisableInScene();
|
|
1796
|
+
}
|
|
2124
1797
|
}
|
|
2125
1798
|
}
|
|
2126
1799
|
if (this._entity.isActiveInHierarchy) {
|
|
2127
1800
|
if (value) {
|
|
2128
|
-
this._phasedActive
|
|
2129
|
-
|
|
1801
|
+
if (!this._phasedActive) {
|
|
1802
|
+
this._phasedActive = true;
|
|
1803
|
+
this._onEnable();
|
|
1804
|
+
}
|
|
2130
1805
|
} else {
|
|
2131
|
-
this._phasedActive
|
|
2132
|
-
|
|
1806
|
+
if (this._phasedActive) {
|
|
1807
|
+
this._phasedActive = false;
|
|
1808
|
+
this._onDisable();
|
|
1809
|
+
}
|
|
2133
1810
|
}
|
|
2134
1811
|
}
|
|
2135
1812
|
}
|
|
@@ -2442,7 +2119,7 @@ var DependentMode;
|
|
|
2442
2119
|
* @param relativeToLocal = `true` - Relative to local space
|
|
2443
2120
|
*/ _proto.rotateByAxis = function rotateByAxis(axis, angle, relativeToLocal) {
|
|
2444
2121
|
if (relativeToLocal === void 0) relativeToLocal = true;
|
|
2445
|
-
var rad = angle * MathUtil
|
|
2122
|
+
var rad = angle * MathUtil.degreeToRadFactor;
|
|
2446
2123
|
Quaternion.rotationAxisAngle(axis, rad, Transform._tempQuat0);
|
|
2447
2124
|
this._rotateByQuat(Transform._tempQuat0, relativeToLocal);
|
|
2448
2125
|
};
|
|
@@ -2454,7 +2131,7 @@ var DependentMode;
|
|
|
2454
2131
|
var zAxis = Transform._tempVec30;
|
|
2455
2132
|
Vector3.subtract(this.worldPosition, targetPosition, zAxis);
|
|
2456
2133
|
var axisLen = zAxis.length();
|
|
2457
|
-
if (axisLen <= MathUtil
|
|
2134
|
+
if (axisLen <= MathUtil.zeroTolerance) {
|
|
2458
2135
|
// The current position and the target position are almost the same.
|
|
2459
2136
|
return;
|
|
2460
2137
|
}
|
|
@@ -2466,7 +2143,7 @@ var DependentMode;
|
|
|
2466
2143
|
xAxis.set(zAxis.z, 0, -zAxis.x);
|
|
2467
2144
|
}
|
|
2468
2145
|
axisLen = xAxis.length();
|
|
2469
|
-
if (axisLen <= MathUtil
|
|
2146
|
+
if (axisLen <= MathUtil.zeroTolerance) {
|
|
2470
2147
|
// @todo:
|
|
2471
2148
|
// 1.worldUp is(0,0,0)
|
|
2472
2149
|
// 2.worldUp is parallel to zAxis
|
|
@@ -2673,7 +2350,7 @@ var DependentMode;
|
|
|
2673
2350
|
};
|
|
2674
2351
|
_proto._rotateXYZ = function _rotateXYZ(x, y, z, relativeToLocal) {
|
|
2675
2352
|
if (relativeToLocal === void 0) relativeToLocal = true;
|
|
2676
|
-
var radFactor = MathUtil
|
|
2353
|
+
var radFactor = MathUtil.degreeToRadFactor;
|
|
2677
2354
|
var rotQuat = Transform._tempQuat0;
|
|
2678
2355
|
Quaternion.rotationEuler(x * radFactor, y * radFactor, z * radFactor, rotQuat);
|
|
2679
2356
|
this._rotateByQuat(rotQuat, relativeToLocal);
|
|
@@ -2700,7 +2377,7 @@ var DependentMode;
|
|
|
2700
2377
|
};
|
|
2701
2378
|
_proto._onWorldRotationChanged = function _onWorldRotationChanged() {
|
|
2702
2379
|
var worldRotation = this._worldRotation;
|
|
2703
|
-
Quaternion.rotationEuler(MathUtil
|
|
2380
|
+
Quaternion.rotationEuler(MathUtil.degreeToRadian(worldRotation.x), MathUtil.degreeToRadian(worldRotation.y), MathUtil.degreeToRadian(worldRotation.z), this._worldRotationQuaternion);
|
|
2704
2381
|
this._setDirtyFlagFalse(0x8);
|
|
2705
2382
|
};
|
|
2706
2383
|
_proto._onRotationQuaternionChanged = function _onRotationQuaternionChanged() {
|
|
@@ -2775,7 +2452,7 @@ var DependentMode;
|
|
|
2775
2452
|
//@ts-ignore
|
|
2776
2453
|
rotation._onValueChanged = null;
|
|
2777
2454
|
this._rotationQuaternion.toEuler(rotation);
|
|
2778
|
-
rotation.scale(MathUtil
|
|
2455
|
+
rotation.scale(MathUtil.radToDegreeFactor); // radians to degrees
|
|
2779
2456
|
//@ts-ignore
|
|
2780
2457
|
rotation._onValueChanged = this._onRotationChanged;
|
|
2781
2458
|
this._setDirtyFlagFalse(0x1);
|
|
@@ -2799,7 +2476,7 @@ var DependentMode;
|
|
|
2799
2476
|
//@ts-ignore
|
|
2800
2477
|
worldRotation._onValueChanged = null;
|
|
2801
2478
|
this.worldRotationQuaternion.toEuler(worldRotation);
|
|
2802
|
-
worldRotation.scale(MathUtil
|
|
2479
|
+
worldRotation.scale(MathUtil.radToDegreeFactor); // Radian to angle
|
|
2803
2480
|
//@ts-ignore
|
|
2804
2481
|
worldRotation._onValueChanged = this._onWorldRotationChanged;
|
|
2805
2482
|
this._setDirtyFlagFalse(0x8);
|
|
@@ -2821,7 +2498,7 @@ var DependentMode;
|
|
|
2821
2498
|
if (this._isContainDirtyFlag(0x2)) {
|
|
2822
2499
|
//@ts-ignore
|
|
2823
2500
|
rotationQuaternion._onValueChanged = null;
|
|
2824
|
-
Quaternion.rotationEuler(MathUtil
|
|
2501
|
+
Quaternion.rotationEuler(MathUtil.degreeToRadian(this._rotation.x), MathUtil.degreeToRadian(this._rotation.y), MathUtil.degreeToRadian(this._rotation.z), rotationQuaternion);
|
|
2825
2502
|
//@ts-ignore
|
|
2826
2503
|
rotationQuaternion._onValueChanged = this._onRotationQuaternionChanged;
|
|
2827
2504
|
this._setDirtyFlagFalse(0x2);
|
|
@@ -3502,7 +3179,7 @@ function _extends() {
|
|
|
3502
3179
|
return _extends.apply(this, arguments);
|
|
3503
3180
|
}
|
|
3504
3181
|
|
|
3505
|
-
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;"; // eslint-disable-line
|
|
3182
|
+
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;"; // eslint-disable-line
|
|
3506
3183
|
|
|
3507
3184
|
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
|
|
3508
3185
|
|
|
@@ -3552,7 +3229,7 @@ var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 material_EmissiveCol
|
|
|
3552
3229
|
|
|
3553
3230
|
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
|
|
3554
3231
|
|
|
3555
|
-
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
|
|
3232
|
+
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
|
|
3556
3233
|
|
|
3557
3234
|
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
|
|
3558
3235
|
|
|
@@ -3590,7 +3267,7 @@ var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec
|
|
|
3590
3267
|
|
|
3591
3268
|
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
|
|
3592
3269
|
|
|
3593
|
-
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
|
|
3270
|
+
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
|
|
3594
3271
|
|
|
3595
3272
|
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
|
|
3596
3273
|
|
|
@@ -3726,7 +3403,11 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
3726
3403
|
}
|
|
3727
3404
|
ShaderLib[includeName] = includeSource;
|
|
3728
3405
|
};
|
|
3729
|
-
|
|
3406
|
+
/**
|
|
3407
|
+
* @param regex The default regex is for engine's builtin glsl `#include` syntax,
|
|
3408
|
+
* since `ShaderLab` use the same parsing function but different syntax for `#include` --- `/^[ \t]*#include +"([\w\d.]+)"/gm`
|
|
3409
|
+
*/ ShaderFactory.parseIncludes = function parseIncludes(src, regex) {
|
|
3410
|
+
if (regex === void 0) regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
|
|
3730
3411
|
var replace = function replace(match, slice) {
|
|
3731
3412
|
var replace = ShaderLib[slice];
|
|
3732
3413
|
if (replace === undefined) {
|
|
@@ -3735,7 +3416,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
3735
3416
|
}
|
|
3736
3417
|
return ShaderFactory.parseIncludes(replace);
|
|
3737
3418
|
};
|
|
3738
|
-
var regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
|
|
3739
3419
|
return src.replace(regex, replace);
|
|
3740
3420
|
};
|
|
3741
3421
|
/**
|
|
@@ -3890,7 +3570,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
3890
3570
|
if (value.r !== undefined) {
|
|
3891
3571
|
if (cacheValue.x !== value.r || cacheValue.y !== value.g) {
|
|
3892
3572
|
if (this._colorSpace === ColorSpace.Linear) {
|
|
3893
|
-
this._gl.uniform2f(shaderUniform.location, Color
|
|
3573
|
+
this._gl.uniform2f(shaderUniform.location, Color.gammaToLinearSpace(value.r), Color.gammaToLinearSpace(value.g));
|
|
3894
3574
|
} else {
|
|
3895
3575
|
this._gl.uniform2f(shaderUniform.location, value.r, value.g);
|
|
3896
3576
|
}
|
|
@@ -3913,7 +3593,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
3913
3593
|
if (value.r !== undefined) {
|
|
3914
3594
|
if (cacheValue.x !== value.r || cacheValue.y !== value.g || cacheValue.z !== value.b) {
|
|
3915
3595
|
if (this._colorSpace === ColorSpace.Linear) {
|
|
3916
|
-
this._gl.uniform3f(shaderUniform.location, Color
|
|
3596
|
+
this._gl.uniform3f(shaderUniform.location, Color.gammaToLinearSpace(value.r), Color.gammaToLinearSpace(value.g), Color.gammaToLinearSpace(value.b));
|
|
3917
3597
|
} else {
|
|
3918
3598
|
this._gl.uniform3f(shaderUniform.location, value.r, value.g, value.b);
|
|
3919
3599
|
}
|
|
@@ -3938,7 +3618,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
3938
3618
|
if (value.r !== undefined) {
|
|
3939
3619
|
if (cacheValue.x !== value.r || cacheValue.y !== value.g || cacheValue.z !== value.b || cacheValue.w !== value.a) {
|
|
3940
3620
|
if (this._colorSpace === ColorSpace.Linear) {
|
|
3941
|
-
this._gl.uniform4f(shaderUniform.location, Color
|
|
3621
|
+
this._gl.uniform4f(shaderUniform.location, Color.gammaToLinearSpace(value.r), Color.gammaToLinearSpace(value.g), Color.gammaToLinearSpace(value.b), value.a);
|
|
3942
3622
|
} else {
|
|
3943
3623
|
this._gl.uniform4f(shaderUniform.location, value.r, value.g, value.b, value.a);
|
|
3944
3624
|
}
|
|
@@ -4589,7 +4269,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
4589
4269
|
*/ var BlendState = /*#__PURE__*/ function() {
|
|
4590
4270
|
function BlendState() {
|
|
4591
4271
|
/** The blend state of the render target. */ this.targetBlendState = new RenderTargetBlendState();
|
|
4592
|
-
/** Constant blend color. */ this.blendColor = new Color
|
|
4272
|
+
/** Constant blend color. */ this.blendColor = new Color(0, 0, 0, 0);
|
|
4593
4273
|
/** Whether to use (Alpha-to-Coverage) technology. */ this.alphaToCoverage = false;
|
|
4594
4274
|
}
|
|
4595
4275
|
var _proto = BlendState.prototype;
|
|
@@ -4683,7 +4363,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
4683
4363
|
}
|
|
4684
4364
|
// apply blend color.
|
|
4685
4365
|
var blendColor = this.blendColor;
|
|
4686
|
-
if (!Color
|
|
4366
|
+
if (!Color.equals(lastState.blendColor, blendColor)) {
|
|
4687
4367
|
gl.blendColor(blendColor.r, blendColor.g, blendColor.b, blendColor.a);
|
|
4688
4368
|
lastState.blendColor.copyFrom(blendColor);
|
|
4689
4369
|
}
|
|
@@ -6717,7 +6397,7 @@ SlicedSpriteAssembler = __decorate([
|
|
|
6717
6397
|
_this._byteLength = byteLength;
|
|
6718
6398
|
_this._platformBuffer = engine._hardwareRenderer.createPlatformBuffer(type, byteLength, bufferUsage, data);
|
|
6719
6399
|
if (readable) {
|
|
6720
|
-
var buffer =
|
|
6400
|
+
var buffer = data.constructor === ArrayBuffer ? data.slice(0) : data.buffer.slice(data.byteOffset, data.byteOffset + byteLength);
|
|
6721
6401
|
_this._data = new Uint8Array(buffer);
|
|
6722
6402
|
}
|
|
6723
6403
|
}
|
|
@@ -9438,7 +9118,7 @@ var /**
|
|
|
9438
9118
|
};
|
|
9439
9119
|
_proto._readColorVertexData = function _readColorVertexData(attributeType) {
|
|
9440
9120
|
return this._readVertexData(attributeType, function(dataReader, offset) {
|
|
9441
|
-
return new Color
|
|
9121
|
+
return new Color(dataReader[offset], dataReader[offset + 1], dataReader[offset + 2], dataReader[offset + 3]);
|
|
9442
9122
|
});
|
|
9443
9123
|
};
|
|
9444
9124
|
_proto._readVertexData = function _readVertexData(attributeType, onVertexParse) {
|
|
@@ -9926,6 +9606,10 @@ var VertexElementIndex;
|
|
|
9926
9606
|
var sphereInfo = primitiveInfo;
|
|
9927
9607
|
PrimitiveMesh._setSphereData(this.resource, sphereInfo.radius, sphereInfo.segments, sphereInfo.noLongerAccessible, true, sphereInfo.vertexBuffer);
|
|
9928
9608
|
break;
|
|
9609
|
+
case 7:
|
|
9610
|
+
var CCSphereInfo = primitiveInfo;
|
|
9611
|
+
PrimitiveMesh._setSubdivisionSurfaceSphereData(this.resource, CCSphereInfo.radius, CCSphereInfo.step, CCSphereInfo.noLongerAccessible, true, CCSphereInfo.vertexBuffer);
|
|
9612
|
+
break;
|
|
9929
9613
|
case 1:
|
|
9930
9614
|
var cuboidInfo = primitiveInfo;
|
|
9931
9615
|
PrimitiveMesh._setCuboidData(this.resource, cuboidInfo.width, cuboidInfo.height, cuboidInfo.depth, cuboidInfo.noLongerAccessible, true, cuboidInfo.vertexBuffer);
|
|
@@ -9963,6 +9647,7 @@ var PrimitiveType;
|
|
|
9963
9647
|
PrimitiveType[PrimitiveType["Torus"] = 4] = "Torus";
|
|
9964
9648
|
PrimitiveType[PrimitiveType["Cone"] = 5] = "Cone";
|
|
9965
9649
|
PrimitiveType[PrimitiveType["Capsule"] = 6] = "Capsule";
|
|
9650
|
+
PrimitiveType[PrimitiveType["CCSphere"] = 7] = "CCSphere";
|
|
9966
9651
|
})(PrimitiveType || (PrimitiveType = {}));
|
|
9967
9652
|
/**
|
|
9968
9653
|
* @internal
|
|
@@ -9984,6 +9669,19 @@ var PrimitiveType;
|
|
|
9984
9669
|
}
|
|
9985
9670
|
return SphereRestoreInfo;
|
|
9986
9671
|
}(PrimitiveRestoreInfo);
|
|
9672
|
+
/**
|
|
9673
|
+
* @internal
|
|
9674
|
+
*/ var SubdivisionSurfaceSphereRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
|
|
9675
|
+
_inherits(SubdivisionSurfaceSphereRestoreInfo, PrimitiveRestoreInfo);
|
|
9676
|
+
function SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible) {
|
|
9677
|
+
var _this;
|
|
9678
|
+
_this = PrimitiveRestoreInfo.call(this, 7, vertexBuffer, noLongerAccessible) || this;
|
|
9679
|
+
_this.radius = radius;
|
|
9680
|
+
_this.step = step;
|
|
9681
|
+
return _this;
|
|
9682
|
+
}
|
|
9683
|
+
return SubdivisionSurfaceSphereRestoreInfo;
|
|
9684
|
+
}(PrimitiveRestoreInfo);
|
|
9987
9685
|
/**
|
|
9988
9686
|
* @internal
|
|
9989
9687
|
*/ var CuboidRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
|
|
@@ -10098,6 +9796,24 @@ var PrimitiveType;
|
|
|
10098
9796
|
return sphereMesh;
|
|
10099
9797
|
};
|
|
10100
9798
|
/**
|
|
9799
|
+
* Create a sphere mesh by implementing Catmull-Clark Surface Subdivision Algorithm.
|
|
9800
|
+
* Max step is limited to 6.
|
|
9801
|
+
* @param engine - Engine
|
|
9802
|
+
* @param radius - Sphere radius
|
|
9803
|
+
* @param step - Number of subdiv steps
|
|
9804
|
+
* @param noLongerAccessible - No longer access the vertices of the mesh after creation
|
|
9805
|
+
* @returns Sphere model mesh
|
|
9806
|
+
*/ PrimitiveMesh.createSubdivisionSurfaceSphere = function createSubdivisionSurfaceSphere(engine, radius, step, noLongerAccessible) {
|
|
9807
|
+
if (radius === void 0) radius = 0.5;
|
|
9808
|
+
if (step === void 0) step = 3;
|
|
9809
|
+
if (noLongerAccessible === void 0) noLongerAccessible = true;
|
|
9810
|
+
var sphereMesh = new ModelMesh(engine);
|
|
9811
|
+
PrimitiveMesh._setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, false);
|
|
9812
|
+
var vertexBuffer = sphereMesh.vertexBufferBindings[0].buffer;
|
|
9813
|
+
engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(sphereMesh, new SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible)));
|
|
9814
|
+
return sphereMesh;
|
|
9815
|
+
};
|
|
9816
|
+
/**
|
|
10101
9817
|
* Create a cuboid mesh.
|
|
10102
9818
|
* @param engine - Engine
|
|
10103
9819
|
* @param width - Cuboid width
|
|
@@ -10227,6 +9943,90 @@ var PrimitiveType;
|
|
|
10227
9943
|
};
|
|
10228
9944
|
/**
|
|
10229
9945
|
* @internal
|
|
9946
|
+
*/ PrimitiveMesh._setSubdivisionSurfaceSphereData = function _setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
9947
|
+
// Max step is limited to 6. Because 7 step will generate a single mesh with over 98306 vertices
|
|
9948
|
+
step = MathUtil.clamp(Math.floor(step), 1, 6);
|
|
9949
|
+
var positions = new Float32Array(3 * (6 * Math.pow(4, step) + 2));
|
|
9950
|
+
var cells = new Float32Array(24 * Math.pow(4, step));
|
|
9951
|
+
PrimitiveMesh._subdiveCatmullClark(step, positions, cells);
|
|
9952
|
+
var positionCount = positions.length / 3;
|
|
9953
|
+
var cellsCount = cells.length / 4;
|
|
9954
|
+
var poleOffset = positionCount + Math.pow(2, step + 1) - 1;
|
|
9955
|
+
// 16 extra vertices for pole uv
|
|
9956
|
+
// 2 vertices at each pole are idle
|
|
9957
|
+
var vertexCount = poleOffset + 16;
|
|
9958
|
+
var vertices = new Float32Array(vertexCount * 8);
|
|
9959
|
+
var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, positionCount, cellsCount * 6);
|
|
9960
|
+
var seamCount = 0;
|
|
9961
|
+
var seamVertices = {};
|
|
9962
|
+
// Get normals, uvs, and scale to radius
|
|
9963
|
+
for(var i = 0; i < positionCount; i++){
|
|
9964
|
+
var offset = 3 * i;
|
|
9965
|
+
var x = positions[offset];
|
|
9966
|
+
var y = positions[offset + 1];
|
|
9967
|
+
var z = positions[offset + 2];
|
|
9968
|
+
var reciprocalLength = 1 / Math.sqrt(x * x + y * y + z * z);
|
|
9969
|
+
x *= reciprocalLength;
|
|
9970
|
+
y *= reciprocalLength;
|
|
9971
|
+
z *= reciprocalLength;
|
|
9972
|
+
offset = 8 * i;
|
|
9973
|
+
vertices[offset] = x * radius;
|
|
9974
|
+
vertices[offset + 1] = y * radius;
|
|
9975
|
+
vertices[offset + 2] = z * radius;
|
|
9976
|
+
vertices[offset + 3] = x;
|
|
9977
|
+
vertices[offset + 4] = y;
|
|
9978
|
+
vertices[offset + 5] = z;
|
|
9979
|
+
vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
|
|
9980
|
+
vertices[offset + 7] = Math.acos(y) / Math.PI;
|
|
9981
|
+
if (vertices[offset + 6] === 0) {
|
|
9982
|
+
// Generate seam vertex
|
|
9983
|
+
var seamOffset = 8 * (positionCount + seamCount++);
|
|
9984
|
+
vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
|
|
9985
|
+
vertices[seamOffset + 6] = 1.0;
|
|
9986
|
+
// Cache seam vertex
|
|
9987
|
+
seamVertices[offset / 8] = seamOffset / 8;
|
|
9988
|
+
}
|
|
9989
|
+
}
|
|
9990
|
+
// Get indices
|
|
9991
|
+
var offset1 = 0;
|
|
9992
|
+
this._spherePoleIdx = 0;
|
|
9993
|
+
for(var i1 = 0; i1 < cellsCount; i1++){
|
|
9994
|
+
var idx = 4 * i1;
|
|
9995
|
+
var indexA = cells[idx];
|
|
9996
|
+
var indexB = cells[idx + 1];
|
|
9997
|
+
var indexC = cells[idx + 2];
|
|
9998
|
+
var indexD = cells[idx + 3];
|
|
9999
|
+
// Handle seam by replacing vertex index to seam vertex index if necessary
|
|
10000
|
+
var floatIndexA = 8 * indexA;
|
|
10001
|
+
var floatIndexB = 8 * indexB;
|
|
10002
|
+
var floatIndexC = 8 * indexC;
|
|
10003
|
+
var floatIndexD = 8 * indexD;
|
|
10004
|
+
// If center Z is negative
|
|
10005
|
+
if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
|
|
10006
|
+
vertices[floatIndexA + 6] === 0 && (indexA = seamVertices[indexA]);
|
|
10007
|
+
vertices[floatIndexB + 6] === 0 && (indexB = seamVertices[indexB]);
|
|
10008
|
+
vertices[floatIndexC + 6] === 0 && (indexC = seamVertices[indexC]);
|
|
10009
|
+
vertices[floatIndexD + 6] === 0 && (indexD = seamVertices[indexD]);
|
|
10010
|
+
}
|
|
10011
|
+
indices[offset1] = indexA;
|
|
10012
|
+
indices[offset1 + 1] = indexB;
|
|
10013
|
+
indices[offset1 + 2] = indexC;
|
|
10014
|
+
this._generateAndReplacePoleUV(indices, vertices, offset1, poleOffset);
|
|
10015
|
+
indices[offset1 + 3] = indexA;
|
|
10016
|
+
indices[offset1 + 4] = indexC;
|
|
10017
|
+
indices[offset1 + 5] = indexD;
|
|
10018
|
+
this._generateAndReplacePoleUV(indices, vertices, offset1 + 3, poleOffset);
|
|
10019
|
+
offset1 += 6;
|
|
10020
|
+
}
|
|
10021
|
+
if (!isRestoreMode) {
|
|
10022
|
+
var bounds = sphereMesh.bounds;
|
|
10023
|
+
bounds.min.set(-radius, -radius, -radius);
|
|
10024
|
+
bounds.max.set(radius, radius, radius);
|
|
10025
|
+
}
|
|
10026
|
+
PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
10027
|
+
};
|
|
10028
|
+
/**
|
|
10029
|
+
* @internal
|
|
10230
10030
|
*/ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
10231
10031
|
segments = Math.max(2, Math.floor(segments));
|
|
10232
10032
|
var count = segments + 1;
|
|
@@ -10287,6 +10087,135 @@ var PrimitiveType;
|
|
|
10287
10087
|
};
|
|
10288
10088
|
/**
|
|
10289
10089
|
* @internal
|
|
10090
|
+
*/ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
|
|
10091
|
+
var edges = new Map();
|
|
10092
|
+
var faces = new Array();
|
|
10093
|
+
positions.set(PrimitiveMesh._sphereSeedPositions);
|
|
10094
|
+
cells.set(PrimitiveMesh._sphereSeedCells);
|
|
10095
|
+
for(var i = 0; i < step; i++){
|
|
10096
|
+
var cellCount = 6 * Math.pow(4, i);
|
|
10097
|
+
var positionCount = 4 * cellCount + 2;
|
|
10098
|
+
edges.clear();
|
|
10099
|
+
faces.length = 0;
|
|
10100
|
+
// Get cell face's facePoint
|
|
10101
|
+
for(var j = 0; j < cellCount; j++){
|
|
10102
|
+
var face = faces[j] = {
|
|
10103
|
+
facePoint: new Vector3(),
|
|
10104
|
+
adjacentEdges: new Array(4)
|
|
10105
|
+
};
|
|
10106
|
+
// Get cell's edgePoint
|
|
10107
|
+
for(var k = 0; k < 4; k++){
|
|
10108
|
+
var offset = 3 * cells[4 * j + k];
|
|
10109
|
+
face.facePoint.x += 0.25 * positions[offset];
|
|
10110
|
+
face.facePoint.y += 0.25 * positions[offset + 1];
|
|
10111
|
+
face.facePoint.z += 0.25 * positions[offset + 2];
|
|
10112
|
+
}
|
|
10113
|
+
// Get cell edges
|
|
10114
|
+
for(var k1 = 0; k1 < 4; k1++){
|
|
10115
|
+
var vertexIdxA = cells[4 * j + k1];
|
|
10116
|
+
var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
|
|
10117
|
+
var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
|
|
10118
|
+
if (!edges.has(edgeIdxKey)) {
|
|
10119
|
+
var edge = {
|
|
10120
|
+
edgePoint: new Vector3(),
|
|
10121
|
+
edgePointIndex: undefined
|
|
10122
|
+
};
|
|
10123
|
+
var offsetA = 3 * vertexIdxA;
|
|
10124
|
+
var offsetB = 3 * vertexIdxB;
|
|
10125
|
+
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]));
|
|
10126
|
+
edges.set(edgeIdxKey, edge);
|
|
10127
|
+
}
|
|
10128
|
+
var edge1 = edges.get(edgeIdxKey);
|
|
10129
|
+
face.adjacentEdges[k1] = edge1;
|
|
10130
|
+
var edgePoint = edge1.edgePoint;
|
|
10131
|
+
var facePoint = face.facePoint;
|
|
10132
|
+
edgePoint.x += 0.25 * facePoint.x;
|
|
10133
|
+
edgePoint.y += 0.25 * facePoint.y;
|
|
10134
|
+
edgePoint.z += 0.25 * facePoint.z;
|
|
10135
|
+
}
|
|
10136
|
+
}
|
|
10137
|
+
var prePointCount = cellCount + 2;
|
|
10138
|
+
var edgePointOffset = prePointCount + cellCount;
|
|
10139
|
+
var pointIdx = 0;
|
|
10140
|
+
this._sphereEdgeIdx = 0;
|
|
10141
|
+
var preCells = cells.slice(0, 4 * cellCount);
|
|
10142
|
+
// Get New positions, which consists of updated positions of existing points, face points and edge points
|
|
10143
|
+
for(var j1 = 0; j1 < cellCount; j1++){
|
|
10144
|
+
// Add face point to new positions
|
|
10145
|
+
var face1 = faces[j1];
|
|
10146
|
+
face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
|
|
10147
|
+
// Get the face point index
|
|
10148
|
+
var ic = prePointCount + j1;
|
|
10149
|
+
var id = void 0, ib = void 0, temp = void 0;
|
|
10150
|
+
// ia -- id -- ia
|
|
10151
|
+
// | | |
|
|
10152
|
+
// ib -- ic -- ib
|
|
10153
|
+
// | | |
|
|
10154
|
+
// ia -- id -- ia
|
|
10155
|
+
for(var k2 = 0; k2 < 4; k2++){
|
|
10156
|
+
// Get the updated existing point index
|
|
10157
|
+
var ia = preCells[pointIdx++];
|
|
10158
|
+
// ib and id share four edge points in one cell
|
|
10159
|
+
switch(k2){
|
|
10160
|
+
case 0:
|
|
10161
|
+
{
|
|
10162
|
+
var edgeB = face1.adjacentEdges[k2 % 4];
|
|
10163
|
+
var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
|
|
10164
|
+
ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
|
|
10165
|
+
id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
|
|
10166
|
+
temp = id;
|
|
10167
|
+
break;
|
|
10168
|
+
}
|
|
10169
|
+
case 1:
|
|
10170
|
+
case 2:
|
|
10171
|
+
{
|
|
10172
|
+
var edgeB1 = face1.adjacentEdges[k2 % 4];
|
|
10173
|
+
id = ib;
|
|
10174
|
+
ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
|
|
10175
|
+
break;
|
|
10176
|
+
}
|
|
10177
|
+
case 3:
|
|
10178
|
+
{
|
|
10179
|
+
id = ib;
|
|
10180
|
+
ib = temp;
|
|
10181
|
+
break;
|
|
10182
|
+
}
|
|
10183
|
+
}
|
|
10184
|
+
var idx = 4 * (4 * j1 + k2);
|
|
10185
|
+
cells[idx] = ia;
|
|
10186
|
+
cells[idx + 1] = ib;
|
|
10187
|
+
cells[idx + 2] = ic;
|
|
10188
|
+
cells[idx + 3] = id;
|
|
10189
|
+
}
|
|
10190
|
+
}
|
|
10191
|
+
}
|
|
10192
|
+
};
|
|
10193
|
+
/**
|
|
10194
|
+
* Duplicate vertices at the poles and adjust their UV coordinates.
|
|
10195
|
+
*/ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
|
|
10196
|
+
var v = vertices[8 * indices[idx] + 7];
|
|
10197
|
+
if (v === 0 || v === 1) {
|
|
10198
|
+
var offset = 8 * indices[idx];
|
|
10199
|
+
var addedOffset = 8 * (poleOffset + this._spherePoleIdx);
|
|
10200
|
+
vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
|
|
10201
|
+
vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
|
|
10202
|
+
indices[idx] = poleOffset + this._spherePoleIdx++;
|
|
10203
|
+
}
|
|
10204
|
+
};
|
|
10205
|
+
/**
|
|
10206
|
+
* Get edge point index for subdivision surface sphere.
|
|
10207
|
+
*/ PrimitiveMesh._calculateEdgeIndex = function _calculateEdgeIndex(positions, edge, offset) {
|
|
10208
|
+
if (edge.edgePointIndex !== undefined) {
|
|
10209
|
+
return edge.edgePointIndex;
|
|
10210
|
+
} else {
|
|
10211
|
+
edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
|
|
10212
|
+
var index = offset + PrimitiveMesh._sphereEdgeIdx++;
|
|
10213
|
+
edge.edgePointIndex = index;
|
|
10214
|
+
return index;
|
|
10215
|
+
}
|
|
10216
|
+
};
|
|
10217
|
+
/**
|
|
10218
|
+
* @internal
|
|
10290
10219
|
*/ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
10291
10220
|
var halfWidth = width / 2;
|
|
10292
10221
|
var halfHeight = height / 2;
|
|
@@ -10916,6 +10845,68 @@ var PrimitiveType;
|
|
|
10916
10845
|
(function() {
|
|
10917
10846
|
PrimitiveMesh._tempVec30 = new Vector3();
|
|
10918
10847
|
})();
|
|
10848
|
+
(function() {
|
|
10849
|
+
PrimitiveMesh._sphereSeedPositions = new Float32Array([
|
|
10850
|
+
-1,
|
|
10851
|
+
1,
|
|
10852
|
+
1,
|
|
10853
|
+
-1,
|
|
10854
|
+
-1,
|
|
10855
|
+
1,
|
|
10856
|
+
1,
|
|
10857
|
+
-1,
|
|
10858
|
+
1,
|
|
10859
|
+
1,
|
|
10860
|
+
1,
|
|
10861
|
+
1,
|
|
10862
|
+
1,
|
|
10863
|
+
-1,
|
|
10864
|
+
-1,
|
|
10865
|
+
1,
|
|
10866
|
+
1,
|
|
10867
|
+
-1,
|
|
10868
|
+
-1,
|
|
10869
|
+
-1,
|
|
10870
|
+
-1,
|
|
10871
|
+
-1,
|
|
10872
|
+
1,
|
|
10873
|
+
-1
|
|
10874
|
+
]);
|
|
10875
|
+
})();
|
|
10876
|
+
(function() {
|
|
10877
|
+
PrimitiveMesh._sphereSeedCells = new Float32Array([
|
|
10878
|
+
0,
|
|
10879
|
+
1,
|
|
10880
|
+
2,
|
|
10881
|
+
3,
|
|
10882
|
+
3,
|
|
10883
|
+
2,
|
|
10884
|
+
4,
|
|
10885
|
+
5,
|
|
10886
|
+
5,
|
|
10887
|
+
4,
|
|
10888
|
+
6,
|
|
10889
|
+
7,
|
|
10890
|
+
7,
|
|
10891
|
+
0,
|
|
10892
|
+
3,
|
|
10893
|
+
5,
|
|
10894
|
+
7,
|
|
10895
|
+
6,
|
|
10896
|
+
1,
|
|
10897
|
+
0,
|
|
10898
|
+
6,
|
|
10899
|
+
4,
|
|
10900
|
+
2,
|
|
10901
|
+
1
|
|
10902
|
+
]);
|
|
10903
|
+
})();
|
|
10904
|
+
(function() {
|
|
10905
|
+
PrimitiveMesh._sphereEdgeIdx = 0;
|
|
10906
|
+
})();
|
|
10907
|
+
(function() {
|
|
10908
|
+
PrimitiveMesh._spherePoleIdx = 0;
|
|
10909
|
+
})();
|
|
10919
10910
|
|
|
10920
10911
|
/**
|
|
10921
10912
|
* Mesh skin data, equal glTF skins define
|
|
@@ -11460,8 +11451,10 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
|
|
|
11460
11451
|
}
|
|
11461
11452
|
mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
|
|
11462
11453
|
batchedQueue[curMeshIndex] = preElement;
|
|
11463
|
-
|
|
11464
|
-
|
|
11454
|
+
// Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
|
|
11455
|
+
// Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
|
|
11456
|
+
this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, SetDataOptions.Discard);
|
|
11457
|
+
this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, SetDataOptions.Discard);
|
|
11465
11458
|
};
|
|
11466
11459
|
_proto._getSubMeshFromPool = function _getSubMeshFromPool(start, count) {
|
|
11467
11460
|
var subMesh = this._subMeshPool.getFromPool();
|
|
@@ -11608,7 +11601,7 @@ var TiledSpriteAssembler = (_TiledSpriteAssembler = /*#__PURE__*/ function() {
|
|
|
11608
11601
|
rVertCount = 3;
|
|
11609
11602
|
rType = 0;
|
|
11610
11603
|
} else {
|
|
11611
|
-
if (fixedCW > MathUtil
|
|
11604
|
+
if (fixedCW > MathUtil.zeroTolerance) {
|
|
11612
11605
|
rRepeatCount = (width - fixedLR) / fixedCW;
|
|
11613
11606
|
rRepeatCount = rRepeatCount % 1 >= threshold ? Math.ceil(rRepeatCount) : Math.floor(rRepeatCount);
|
|
11614
11607
|
rVertCount = 4 + rRepeatCount - 1;
|
|
@@ -11622,7 +11615,7 @@ var TiledSpriteAssembler = (_TiledSpriteAssembler = /*#__PURE__*/ function() {
|
|
|
11622
11615
|
cVertCount = 3;
|
|
11623
11616
|
cType = 0;
|
|
11624
11617
|
} else {
|
|
11625
|
-
if (fixedCH > MathUtil
|
|
11618
|
+
if (fixedCH > MathUtil.zeroTolerance) {
|
|
11626
11619
|
cRepeatCount = (height - fixedTB) / fixedCH;
|
|
11627
11620
|
cRepeatCount = cRepeatCount % 1 >= threshold ? Math.ceil(cRepeatCount) : Math.floor(cRepeatCount);
|
|
11628
11621
|
cVertCount = 4 + cRepeatCount - 1;
|
|
@@ -11713,7 +11706,7 @@ var TiledSpriteAssembler = (_TiledSpriteAssembler = /*#__PURE__*/ function() {
|
|
|
11713
11706
|
rVertCount = 3;
|
|
11714
11707
|
rType = 0;
|
|
11715
11708
|
} else {
|
|
11716
|
-
if (fixedCW > MathUtil
|
|
11709
|
+
if (fixedCW > MathUtil.zeroTolerance) {
|
|
11717
11710
|
rRepeatCount = (width - fixedLR) / fixedCW;
|
|
11718
11711
|
rVertCount = 4 + (rRepeatCount | 0);
|
|
11719
11712
|
rType = 2;
|
|
@@ -11726,7 +11719,7 @@ var TiledSpriteAssembler = (_TiledSpriteAssembler = /*#__PURE__*/ function() {
|
|
|
11726
11719
|
cVertCount = 3;
|
|
11727
11720
|
cType = 0;
|
|
11728
11721
|
} else {
|
|
11729
|
-
if (fixedCH > MathUtil
|
|
11722
|
+
if (fixedCH > MathUtil.zeroTolerance) {
|
|
11730
11723
|
cRepeatCount = (height - fixedTB) / fixedCH;
|
|
11731
11724
|
cVertCount = 4 + (cRepeatCount | 0);
|
|
11732
11725
|
cType = 2;
|
|
@@ -11839,7 +11832,7 @@ var TiledType;
|
|
|
11839
11832
|
_this = Renderer1.call(this, entity) || this;
|
|
11840
11833
|
_this._tileMode = SpriteTileMode.Continuous;
|
|
11841
11834
|
_this._tiledAdaptiveThreshold = 0.5;
|
|
11842
|
-
_this._color = new Color
|
|
11835
|
+
_this._color = new Color(1, 1, 1, 1);
|
|
11843
11836
|
_this._sprite = null;
|
|
11844
11837
|
_this._automaticWidth = 0;
|
|
11845
11838
|
_this._automaticHeight = 0;
|
|
@@ -12039,7 +12032,7 @@ var TiledType;
|
|
|
12039
12032
|
},
|
|
12040
12033
|
set: function set(value) {
|
|
12041
12034
|
if (value !== this._tiledAdaptiveThreshold) {
|
|
12042
|
-
value = MathUtil
|
|
12035
|
+
value = MathUtil.clamp(value, 0, 1);
|
|
12043
12036
|
this._tiledAdaptiveThreshold = value;
|
|
12044
12037
|
if (this.drawMode === SpriteDrawMode.Tiled) {
|
|
12045
12038
|
this._dirtyUpdateFlag |= 0x3;
|
|
@@ -12491,6 +12484,9 @@ var /**
|
|
|
12491
12484
|
__decorate([
|
|
12492
12485
|
assignmentClone
|
|
12493
12486
|
], SpriteMask.prototype, "influenceLayers", void 0);
|
|
12487
|
+
__decorate([
|
|
12488
|
+
ignoreClone
|
|
12489
|
+
], SpriteMask.prototype, "_verticesData", void 0);
|
|
12494
12490
|
__decorate([
|
|
12495
12491
|
ignoreClone
|
|
12496
12492
|
], SpriteMask.prototype, "_sprite", void 0);
|
|
@@ -12774,8 +12770,8 @@ var /**
|
|
|
12774
12770
|
} else {
|
|
12775
12771
|
word += char;
|
|
12776
12772
|
wordWidth += charInfo.xAdvance;
|
|
12777
|
-
wordMaxAscent =
|
|
12778
|
-
wordMaxDescent =
|
|
12773
|
+
wordMaxAscent = Math.max(wordMaxAscent, ascent);
|
|
12774
|
+
wordMaxDescent = Math.max(wordMaxDescent, descent);
|
|
12779
12775
|
}
|
|
12780
12776
|
}
|
|
12781
12777
|
}
|
|
@@ -12896,6 +12892,9 @@ var /**
|
|
|
12896
12892
|
var baseline = Math.ceil(context.measureText(TextUtils._measureBaseline).width);
|
|
12897
12893
|
var height = baseline * TextUtils._heightMultiplier;
|
|
12898
12894
|
baseline = TextUtils._baselineMultiplier * baseline | 0;
|
|
12895
|
+
var _extendHeight = TextUtils._extendHeight;
|
|
12896
|
+
height += _extendHeight;
|
|
12897
|
+
baseline += _extendHeight * 0.5;
|
|
12899
12898
|
canvas.width = width;
|
|
12900
12899
|
canvas.height = height;
|
|
12901
12900
|
context.font = fontString;
|
|
@@ -12930,6 +12929,7 @@ var /**
|
|
|
12930
12929
|
}
|
|
12931
12930
|
if (top !== -1 && bottom !== -1) {
|
|
12932
12931
|
ascent = baseline - top;
|
|
12932
|
+
// Baseline belong to descent
|
|
12933
12933
|
descent = bottom - baseline + 1;
|
|
12934
12934
|
size = ascent + descent;
|
|
12935
12935
|
}
|
|
@@ -13005,6 +13005,10 @@ var /**
|
|
|
13005
13005
|
"fangsong"
|
|
13006
13006
|
];
|
|
13007
13007
|
})();
|
|
13008
|
+
(function() {
|
|
13009
|
+
// _extendHeight used to extend the height of canvas, because in miniprogram performance is different from h5.
|
|
13010
|
+
/** @internal */ TextUtils._extendHeight = 0;
|
|
13011
|
+
})();
|
|
13008
13012
|
(function() {
|
|
13009
13013
|
/** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
|
|
13010
13014
|
})();
|
|
@@ -13095,7 +13099,8 @@ var /**
|
|
|
13095
13099
|
_proto._createFontAtlas = function _createFontAtlas() {
|
|
13096
13100
|
var _this = this, engine = _this._engine;
|
|
13097
13101
|
var fontAtlas = new FontAtlas(engine);
|
|
13098
|
-
var texture = new Texture2D(engine, 256, 256);
|
|
13102
|
+
var texture = new Texture2D(engine, 256, 256, TextureFormat.R8G8B8A8, false);
|
|
13103
|
+
texture.filterMode = TextureFilterMode.Bilinear;
|
|
13099
13104
|
fontAtlas.texture = texture;
|
|
13100
13105
|
fontAtlas.isGCIgnored = texture.isGCIgnored = true;
|
|
13101
13106
|
this._fontAtlases.push(fontAtlas);
|
|
@@ -13253,7 +13258,7 @@ var /**
|
|
|
13253
13258
|
/** @internal */ _this._subFont = null;
|
|
13254
13259
|
/** @internal */ _this._charRenderDatas = [];
|
|
13255
13260
|
_this._dirtyFlag = 15;
|
|
13256
|
-
_this._color = new Color
|
|
13261
|
+
_this._color = new Color(1, 1, 1, 1);
|
|
13257
13262
|
_this._text = "";
|
|
13258
13263
|
_this._width = 0;
|
|
13259
13264
|
_this._height = 0;
|
|
@@ -13333,7 +13338,7 @@ var /**
|
|
|
13333
13338
|
/**
|
|
13334
13339
|
* @internal
|
|
13335
13340
|
*/ _proto._render = function _render(context) {
|
|
13336
|
-
if (this.
|
|
13341
|
+
if (this._isTextNoVisible()) {
|
|
13337
13342
|
return;
|
|
13338
13343
|
}
|
|
13339
13344
|
if (this._isContainDirtyFlag(0x10)) {
|
|
@@ -13425,8 +13430,8 @@ var /**
|
|
|
13425
13430
|
}
|
|
13426
13431
|
};
|
|
13427
13432
|
_proto._updateLocalData = function _updateLocalData() {
|
|
13428
|
-
var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
|
|
13429
13433
|
var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
|
|
13434
|
+
var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
|
|
13430
13435
|
var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
|
|
13431
13436
|
var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
|
|
13432
13437
|
var charRenderDataPool = TextRenderer._charRenderDataPool;
|
|
@@ -13494,7 +13499,7 @@ var /**
|
|
|
13494
13499
|
var left = startX * pixelsPerUnitReciprocal;
|
|
13495
13500
|
var right = (startX + w) * pixelsPerUnitReciprocal;
|
|
13496
13501
|
var top = (startY + ascent) * pixelsPerUnitReciprocal;
|
|
13497
|
-
var bottom = (startY - descent
|
|
13502
|
+
var bottom = (startY - descent) * pixelsPerUnitReciprocal;
|
|
13498
13503
|
localPositions.set(left, top, right, bottom);
|
|
13499
13504
|
i === firstLine && (maxY = Math.max(maxY, top));
|
|
13500
13505
|
minY = Math.min(minY, bottom);
|
|
@@ -13535,6 +13540,9 @@ var /**
|
|
|
13535
13540
|
Renderer1.prototype._onTransformChanged.call(this, bit);
|
|
13536
13541
|
this._setDirtyFlagTrue(0x4 | 0x8);
|
|
13537
13542
|
};
|
|
13543
|
+
_proto._isTextNoVisible = function _isTextNoVisible() {
|
|
13544
|
+
return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === OverflowMode.Truncate && this.height <= 0;
|
|
13545
|
+
};
|
|
13538
13546
|
_create_class(TextRenderer, [
|
|
13539
13547
|
{
|
|
13540
13548
|
key: "color",
|
|
@@ -13737,6 +13745,16 @@ var /**
|
|
|
13737
13745
|
get: /**
|
|
13738
13746
|
* The bounding volume of the TextRenderer.
|
|
13739
13747
|
*/ function get() {
|
|
13748
|
+
if (this._isTextNoVisible()) {
|
|
13749
|
+
if (this._isContainDirtyFlag(0x8)) {
|
|
13750
|
+
var localBounds = this._localBounds;
|
|
13751
|
+
localBounds.min.set(0, 0, 0);
|
|
13752
|
+
localBounds.max.set(0, 0, 0);
|
|
13753
|
+
this._updateBounds(this._bounds);
|
|
13754
|
+
this._setDirtyFlagFalse(0x8);
|
|
13755
|
+
}
|
|
13756
|
+
return this._bounds;
|
|
13757
|
+
}
|
|
13740
13758
|
this._isContainDirtyFlag(0x1) && this._resetSubFont();
|
|
13741
13759
|
this._isContainDirtyFlag(0x2) && this._updateLocalData();
|
|
13742
13760
|
this._isContainDirtyFlag(0x4) && this._updatePosition();
|
|
@@ -14758,6 +14776,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData1) {
|
|
|
14758
14776
|
AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
|
|
14759
14777
|
AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
|
|
14760
14778
|
AssetType[/** Sprite. */ "Sprite"] = "Sprite";
|
|
14779
|
+
AssetType[/** PrimitiveMesh. */ "PrimitiveMesh"] = "PrimitiveMesh";
|
|
14761
14780
|
AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
|
|
14762
14781
|
AssetType[/** Ambient light. */ "Env"] = "Environment";
|
|
14763
14782
|
AssetType[/** Scene. */ "Scene"] = "Scene";
|
|
@@ -15143,6 +15162,7 @@ var /** @internal */ PromiseState;
|
|
|
15143
15162
|
this./** The number of retries after failing to load assets. */ retryCount = 1;
|
|
15144
15163
|
this./** Retry delay time after failed to load assets, in milliseconds. */ retryInterval = 0;
|
|
15145
15164
|
this./** The default timeout period for loading assets, in milliseconds. */ timeout = Infinity;
|
|
15165
|
+
this./** Base url for loading assets. */ baseUrl = null;
|
|
15146
15166
|
this._loadingPromises = {};
|
|
15147
15167
|
this._assetPool = Object.create(null);
|
|
15148
15168
|
this._assetUrlPool = Object.create(null);
|
|
@@ -15346,6 +15366,8 @@ var /** @internal */ PromiseState;
|
|
|
15346
15366
|
// Check url mapping
|
|
15347
15367
|
var itemURL = item.url;
|
|
15348
15368
|
var url = this._virtualPathMap[itemURL] ? this._virtualPathMap[itemURL] : itemURL;
|
|
15369
|
+
// Not absolute and base url is set
|
|
15370
|
+
if (!Utils.isAbsoluteUrl(url) && this.baseUrl) url = Utils.resolveAbsoluteUrl(this.baseUrl, url);
|
|
15349
15371
|
// Parse url
|
|
15350
15372
|
var _this__parseURL = this._parseURL(url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
|
|
15351
15373
|
var paths = queryPath ? this._parseQueryPath(queryPath) : [];
|
|
@@ -15725,6 +15747,66 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
15725
15747
|
}
|
|
15726
15748
|
}
|
|
15727
15749
|
};
|
|
15750
|
+
/**
|
|
15751
|
+
* @internal
|
|
15752
|
+
*/ SystemInfo._detectSIMDSupported = function _detectSIMDSupported() {
|
|
15753
|
+
if (this._simdSupported === null) {
|
|
15754
|
+
this._simdSupported = WebAssembly.validate(new Uint8Array([
|
|
15755
|
+
0,
|
|
15756
|
+
97,
|
|
15757
|
+
115,
|
|
15758
|
+
109,
|
|
15759
|
+
1,
|
|
15760
|
+
0,
|
|
15761
|
+
0,
|
|
15762
|
+
0,
|
|
15763
|
+
1,
|
|
15764
|
+
4,
|
|
15765
|
+
1,
|
|
15766
|
+
96,
|
|
15767
|
+
0,
|
|
15768
|
+
0,
|
|
15769
|
+
3,
|
|
15770
|
+
3,
|
|
15771
|
+
2,
|
|
15772
|
+
0,
|
|
15773
|
+
0,
|
|
15774
|
+
5,
|
|
15775
|
+
3,
|
|
15776
|
+
1,
|
|
15777
|
+
0,
|
|
15778
|
+
1,
|
|
15779
|
+
12,
|
|
15780
|
+
1,
|
|
15781
|
+
0,
|
|
15782
|
+
10,
|
|
15783
|
+
22,
|
|
15784
|
+
2,
|
|
15785
|
+
12,
|
|
15786
|
+
0,
|
|
15787
|
+
65,
|
|
15788
|
+
0,
|
|
15789
|
+
65,
|
|
15790
|
+
0,
|
|
15791
|
+
65,
|
|
15792
|
+
0,
|
|
15793
|
+
252,
|
|
15794
|
+
10,
|
|
15795
|
+
0,
|
|
15796
|
+
0,
|
|
15797
|
+
11,
|
|
15798
|
+
7,
|
|
15799
|
+
0,
|
|
15800
|
+
65,
|
|
15801
|
+
0,
|
|
15802
|
+
253,
|
|
15803
|
+
15,
|
|
15804
|
+
26,
|
|
15805
|
+
11
|
|
15806
|
+
]));
|
|
15807
|
+
}
|
|
15808
|
+
return this._simdSupported;
|
|
15809
|
+
};
|
|
15728
15810
|
_create_class(SystemInfo, null, [
|
|
15729
15811
|
{
|
|
15730
15812
|
key: "devicePixelRatio",
|
|
@@ -15743,6 +15825,9 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
15743
15825
|
(function() {
|
|
15744
15826
|
/** The operating system is running on. */ SystemInfo.operatingSystem = "";
|
|
15745
15827
|
})();
|
|
15828
|
+
(function() {
|
|
15829
|
+
/** Whether the system support SIMD. */ SystemInfo._simdSupported = null;
|
|
15830
|
+
})();
|
|
15746
15831
|
SystemInfo._initialize();
|
|
15747
15832
|
|
|
15748
15833
|
/**
|
|
@@ -15973,7 +16058,7 @@ SystemInfo._initialize();
|
|
|
15973
16058
|
* Keyboard Manager.
|
|
15974
16059
|
* @internal
|
|
15975
16060
|
*/ var KeyboardManager = /*#__PURE__*/ function() {
|
|
15976
|
-
function KeyboardManager(engine) {
|
|
16061
|
+
function KeyboardManager(engine, target) {
|
|
15977
16062
|
/** @internal */ this._curHeldDownKeyToIndexMap = [];
|
|
15978
16063
|
/** @internal */ this._upKeyToFrameCountMap = [];
|
|
15979
16064
|
/** @internal */ this._downKeyToFrameCountMap = [];
|
|
@@ -15981,17 +16066,11 @@ SystemInfo._initialize();
|
|
|
15981
16066
|
/** @internal */ this._curFrameDownList = new DisorderedArray();
|
|
15982
16067
|
/** @internal */ this._curFrameUpList = new DisorderedArray();
|
|
15983
16068
|
this._nativeEvents = [];
|
|
15984
|
-
this._hadListener = false;
|
|
15985
|
-
// @ts-ignore
|
|
15986
|
-
var htmlCanvas = engine._canvas._webCanvas;
|
|
15987
16069
|
this._engine = engine;
|
|
15988
|
-
this.
|
|
15989
|
-
// Need to set tabIndex to make the canvas focus.
|
|
15990
|
-
htmlCanvas.tabIndex = htmlCanvas.tabIndex;
|
|
16070
|
+
this._onBlur = this._onBlur.bind(this);
|
|
15991
16071
|
this._onKeyEvent = this._onKeyEvent.bind(this);
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
this._hadListener = true;
|
|
16072
|
+
this._target = target;
|
|
16073
|
+
this._addEventListener();
|
|
15995
16074
|
}
|
|
15996
16075
|
var _proto = KeyboardManager.prototype;
|
|
15997
16076
|
/**
|
|
@@ -16043,35 +16122,8 @@ SystemInfo._initialize();
|
|
|
16043
16122
|
};
|
|
16044
16123
|
/**
|
|
16045
16124
|
* @internal
|
|
16046
|
-
*/ _proto._onFocus = function _onFocus() {
|
|
16047
|
-
if (!this._hadListener) {
|
|
16048
|
-
this._htmlCanvas.addEventListener("keydown", this._onKeyEvent);
|
|
16049
|
-
this._htmlCanvas.addEventListener("keyup", this._onKeyEvent);
|
|
16050
|
-
this._hadListener = true;
|
|
16051
|
-
}
|
|
16052
|
-
};
|
|
16053
|
-
/**
|
|
16054
|
-
* @internal
|
|
16055
|
-
*/ _proto._onBlur = function _onBlur() {
|
|
16056
|
-
if (this._hadListener) {
|
|
16057
|
-
this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
|
|
16058
|
-
this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
|
|
16059
|
-
this._curHeldDownKeyToIndexMap.length = 0;
|
|
16060
|
-
this._curFrameHeldDownList.length = 0;
|
|
16061
|
-
this._curFrameDownList.length = 0;
|
|
16062
|
-
this._curFrameUpList.length = 0;
|
|
16063
|
-
this._nativeEvents.length = 0;
|
|
16064
|
-
this._hadListener = false;
|
|
16065
|
-
}
|
|
16066
|
-
};
|
|
16067
|
-
/**
|
|
16068
|
-
* @internal
|
|
16069
16125
|
*/ _proto._destroy = function _destroy() {
|
|
16070
|
-
|
|
16071
|
-
this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
|
|
16072
|
-
this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
|
|
16073
|
-
this._hadListener = false;
|
|
16074
|
-
}
|
|
16126
|
+
this._removeEventListener();
|
|
16075
16127
|
this._curHeldDownKeyToIndexMap.length = 0;
|
|
16076
16128
|
this._curHeldDownKeyToIndexMap = null;
|
|
16077
16129
|
this._upKeyToFrameCountMap.length = 0;
|
|
@@ -16086,12 +16138,30 @@ SystemInfo._initialize();
|
|
|
16086
16138
|
this._curFrameDownList = null;
|
|
16087
16139
|
this._curFrameUpList.length = 0;
|
|
16088
16140
|
this._curFrameUpList = null;
|
|
16089
|
-
this._htmlCanvas = null;
|
|
16090
16141
|
this._engine = null;
|
|
16091
16142
|
};
|
|
16143
|
+
_proto._onBlur = function _onBlur() {
|
|
16144
|
+
this._curHeldDownKeyToIndexMap.length = 0;
|
|
16145
|
+
this._curFrameHeldDownList.length = 0;
|
|
16146
|
+
this._curFrameDownList.length = 0;
|
|
16147
|
+
this._curFrameUpList.length = 0;
|
|
16148
|
+
this._nativeEvents.length = 0;
|
|
16149
|
+
};
|
|
16092
16150
|
_proto._onKeyEvent = function _onKeyEvent(evt) {
|
|
16093
16151
|
this._nativeEvents.push(evt);
|
|
16094
16152
|
};
|
|
16153
|
+
_proto._addEventListener = function _addEventListener() {
|
|
16154
|
+
var _this = this, target = _this._target;
|
|
16155
|
+
target.addEventListener("keydown", this._onKeyEvent);
|
|
16156
|
+
target.addEventListener("keyup", this._onKeyEvent);
|
|
16157
|
+
target.addEventListener("blur", this._onBlur);
|
|
16158
|
+
};
|
|
16159
|
+
_proto._removeEventListener = function _removeEventListener() {
|
|
16160
|
+
var _this = this, target = _this._target;
|
|
16161
|
+
target.removeEventListener("keydown", this._onKeyEvent);
|
|
16162
|
+
target.removeEventListener("keyup", this._onKeyEvent);
|
|
16163
|
+
target.removeEventListener("blur", this._onBlur);
|
|
16164
|
+
};
|
|
16095
16165
|
return KeyboardManager;
|
|
16096
16166
|
}();
|
|
16097
16167
|
|
|
@@ -16533,7 +16603,7 @@ var Collision = function Collision() {
|
|
|
16533
16603
|
return this._fixedTimeStep;
|
|
16534
16604
|
},
|
|
16535
16605
|
set: function set(value) {
|
|
16536
|
-
this._fixedTimeStep = Math.max(value, MathUtil
|
|
16606
|
+
this._fixedTimeStep = Math.max(value, MathUtil.zeroTolerance);
|
|
16537
16607
|
}
|
|
16538
16608
|
}
|
|
16539
16609
|
]);
|
|
@@ -18055,7 +18125,7 @@ __decorate([
|
|
|
18055
18125
|
* Pointer Manager.
|
|
18056
18126
|
* @internal
|
|
18057
18127
|
*/ var PointerManager = /*#__PURE__*/ function() {
|
|
18058
|
-
function PointerManager(engine) {
|
|
18128
|
+
function PointerManager(engine, target) {
|
|
18059
18129
|
/** @internal */ this._pointers = [];
|
|
18060
18130
|
/** @internal */ this._multiPointerEnabled = true;
|
|
18061
18131
|
/** @internal */ this._buttons = PointerButton.None;
|
|
@@ -18064,16 +18134,18 @@ __decorate([
|
|
|
18064
18134
|
/** @internal */ this._upList = new DisorderedArray();
|
|
18065
18135
|
/** @internal */ this._downList = new DisorderedArray();
|
|
18066
18136
|
this._nativeEvents = [];
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
|
|
18137
|
+
if (_instanceof(target, Window)) {
|
|
18138
|
+
throw "Do not set window as target because window cannot listen to pointer leave event.";
|
|
18139
|
+
}
|
|
18070
18140
|
this._engine = engine;
|
|
18141
|
+
this._target = target;
|
|
18071
18142
|
this._canvas = engine.canvas;
|
|
18072
|
-
|
|
18073
|
-
this.
|
|
18074
|
-
this._onFocus();
|
|
18143
|
+
// @ts-ignore
|
|
18144
|
+
this._htmlCanvas = engine._canvas._webCanvas;
|
|
18075
18145
|
// If there are no compatibility issues, navigator.maxTouchPoints should be used here
|
|
18076
18146
|
this._pointerPool = new Array(11);
|
|
18147
|
+
this._onPointerEvent = this._onPointerEvent.bind(this);
|
|
18148
|
+
this._addEventListener();
|
|
18077
18149
|
}
|
|
18078
18150
|
var _proto = PointerManager.prototype;
|
|
18079
18151
|
/**
|
|
@@ -18143,7 +18215,8 @@ __decorate([
|
|
|
18143
18215
|
var length = events.length;
|
|
18144
18216
|
if (length > 0) {
|
|
18145
18217
|
for(var i1 = 0; i1 < length; i1++){
|
|
18146
|
-
|
|
18218
|
+
var event = events[i1];
|
|
18219
|
+
switch(event.type){
|
|
18147
18220
|
case "pointerdown":
|
|
18148
18221
|
pointer.phase = PointerPhase.Down;
|
|
18149
18222
|
pointer._firePointerDown(rayCastEntity);
|
|
@@ -18165,66 +18238,14 @@ __decorate([
|
|
|
18165
18238
|
};
|
|
18166
18239
|
/**
|
|
18167
18240
|
* @internal
|
|
18168
|
-
*/ _proto._onFocus = function _onFocus() {
|
|
18169
|
-
if (!this._hadListener) {
|
|
18170
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
18171
|
-
htmlCanvas.addEventListener("pointerdown", onPointerEvent);
|
|
18172
|
-
htmlCanvas.addEventListener("pointerup", onPointerEvent);
|
|
18173
|
-
htmlCanvas.addEventListener("pointerleave", onPointerEvent);
|
|
18174
|
-
htmlCanvas.addEventListener("pointermove", onPointerEvent);
|
|
18175
|
-
htmlCanvas.addEventListener("pointercancel", onPointerEvent);
|
|
18176
|
-
this._hadListener = true;
|
|
18177
|
-
}
|
|
18178
|
-
};
|
|
18179
|
-
/**
|
|
18180
|
-
* @internal
|
|
18181
|
-
*/ _proto._onBlur = function _onBlur() {
|
|
18182
|
-
if (this._hadListener) {
|
|
18183
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
18184
|
-
htmlCanvas.removeEventListener("pointerdown", onPointerEvent);
|
|
18185
|
-
htmlCanvas.removeEventListener("pointerup", onPointerEvent);
|
|
18186
|
-
htmlCanvas.removeEventListener("pointerleave", onPointerEvent);
|
|
18187
|
-
htmlCanvas.removeEventListener("pointermove", onPointerEvent);
|
|
18188
|
-
htmlCanvas.removeEventListener("pointercancel", onPointerEvent);
|
|
18189
|
-
this._hadListener = false;
|
|
18190
|
-
this._pointers.length = 0;
|
|
18191
|
-
this._downList.length = 0;
|
|
18192
|
-
this._upList.length = 0;
|
|
18193
|
-
}
|
|
18194
|
-
};
|
|
18195
|
-
/**
|
|
18196
|
-
* @internal
|
|
18197
18241
|
*/ _proto._destroy = function _destroy() {
|
|
18198
|
-
|
|
18199
|
-
if (this._hadListener) {
|
|
18200
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
18201
|
-
htmlCanvas.removeEventListener("pointerdown", onPointerEvent);
|
|
18202
|
-
htmlCanvas.removeEventListener("pointerup", onPointerEvent);
|
|
18203
|
-
htmlCanvas.removeEventListener("pointerleave", onPointerEvent);
|
|
18204
|
-
htmlCanvas.removeEventListener("pointermove", onPointerEvent);
|
|
18205
|
-
htmlCanvas.removeEventListener("pointercancel", onPointerEvent);
|
|
18206
|
-
this._hadListener = false;
|
|
18207
|
-
}
|
|
18242
|
+
this._removeEventListener();
|
|
18208
18243
|
this._pointerPool.length = 0;
|
|
18209
|
-
this._pointerPool = null;
|
|
18210
|
-
this._pointers.length = 0;
|
|
18211
|
-
this._pointers = null;
|
|
18212
|
-
this._downList.length = 0;
|
|
18213
|
-
this._downList = null;
|
|
18214
|
-
this._upList.length = 0;
|
|
18215
|
-
this._upList = null;
|
|
18216
18244
|
this._nativeEvents.length = 0;
|
|
18217
|
-
this._nativeEvents = null;
|
|
18218
|
-
this._upMap.length = 0;
|
|
18219
|
-
this._upMap = null;
|
|
18220
18245
|
this._downMap.length = 0;
|
|
18221
|
-
this.
|
|
18222
|
-
this._htmlCanvas = null;
|
|
18223
|
-
this._canvas = null;
|
|
18224
|
-
this._engine = null;
|
|
18246
|
+
this._upMap.length = 0;
|
|
18225
18247
|
};
|
|
18226
18248
|
_proto._onPointerEvent = function _onPointerEvent(evt) {
|
|
18227
|
-
evt.type === "pointerdown" && this._htmlCanvas.focus();
|
|
18228
18249
|
this._nativeEvents.push(evt);
|
|
18229
18250
|
};
|
|
18230
18251
|
_proto._getPointerByID = function _getPointerByID(pointerId) {
|
|
@@ -18307,6 +18328,26 @@ __decorate([
|
|
|
18307
18328
|
}
|
|
18308
18329
|
return null;
|
|
18309
18330
|
};
|
|
18331
|
+
_proto._addEventListener = function _addEventListener() {
|
|
18332
|
+
var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
|
|
18333
|
+
target.addEventListener("pointerdown", onPointerEvent);
|
|
18334
|
+
target.addEventListener("pointerup", onPointerEvent);
|
|
18335
|
+
target.addEventListener("pointerleave", onPointerEvent);
|
|
18336
|
+
target.addEventListener("pointermove", onPointerEvent);
|
|
18337
|
+
target.addEventListener("pointercancel", onPointerEvent);
|
|
18338
|
+
};
|
|
18339
|
+
_proto._removeEventListener = function _removeEventListener() {
|
|
18340
|
+
var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
|
|
18341
|
+
target.removeEventListener("pointerdown", onPointerEvent);
|
|
18342
|
+
target.removeEventListener("pointerup", onPointerEvent);
|
|
18343
|
+
target.removeEventListener("pointerleave", onPointerEvent);
|
|
18344
|
+
target.removeEventListener("pointermove", onPointerEvent);
|
|
18345
|
+
target.removeEventListener("pointercancel", onPointerEvent);
|
|
18346
|
+
this._nativeEvents.length = 0;
|
|
18347
|
+
this._pointers.length = 0;
|
|
18348
|
+
this._downList.length = 0;
|
|
18349
|
+
this._upList.length = 0;
|
|
18350
|
+
};
|
|
18310
18351
|
return PointerManager;
|
|
18311
18352
|
}();
|
|
18312
18353
|
(function() {
|
|
@@ -18323,15 +18364,12 @@ __decorate([
|
|
|
18323
18364
|
* Wheel Manager.
|
|
18324
18365
|
* @internal
|
|
18325
18366
|
*/ var WheelManager = /*#__PURE__*/ function() {
|
|
18326
|
-
function WheelManager(engine) {
|
|
18367
|
+
function WheelManager(engine, target) {
|
|
18327
18368
|
/** @internal */ this._delta = new Vector3();
|
|
18328
18369
|
this._nativeEvents = [];
|
|
18329
|
-
// @ts-ignore
|
|
18330
|
-
var htmlCanvas = engine._canvas._webCanvas;
|
|
18331
18370
|
this._onWheelEvent = this._onWheelEvent.bind(this);
|
|
18332
|
-
|
|
18333
|
-
this.
|
|
18334
|
-
this._hadListener = true;
|
|
18371
|
+
this._target = target;
|
|
18372
|
+
this._addEventListener();
|
|
18335
18373
|
}
|
|
18336
18374
|
var _proto = WheelManager.prototype;
|
|
18337
18375
|
/**
|
|
@@ -18352,35 +18390,24 @@ __decorate([
|
|
|
18352
18390
|
};
|
|
18353
18391
|
/**
|
|
18354
18392
|
* @internal
|
|
18355
|
-
*/ _proto.
|
|
18356
|
-
|
|
18357
|
-
this._canvas.addEventListener("wheel", this._onWheelEvent);
|
|
18358
|
-
this._hadListener = true;
|
|
18359
|
-
}
|
|
18393
|
+
*/ _proto._addEventListener = function _addEventListener() {
|
|
18394
|
+
this._target.addEventListener("wheel", this._onWheelEvent);
|
|
18360
18395
|
};
|
|
18361
18396
|
/**
|
|
18362
18397
|
* @internal
|
|
18363
|
-
*/ _proto.
|
|
18364
|
-
|
|
18365
|
-
|
|
18366
|
-
|
|
18367
|
-
this._delta.set(0, 0, 0);
|
|
18368
|
-
this._hadListener = false;
|
|
18369
|
-
}
|
|
18398
|
+
*/ _proto._removeEventListener = function _removeEventListener() {
|
|
18399
|
+
this._target.removeEventListener("wheel", this._onWheelEvent);
|
|
18400
|
+
this._nativeEvents.length = 0;
|
|
18401
|
+
this._delta.set(0, 0, 0);
|
|
18370
18402
|
};
|
|
18371
18403
|
/**
|
|
18372
18404
|
* @internal
|
|
18373
18405
|
*/ _proto._destroy = function _destroy() {
|
|
18374
|
-
|
|
18375
|
-
this._canvas.removeEventListener("wheel", this._onWheelEvent);
|
|
18376
|
-
this._hadListener = false;
|
|
18377
|
-
}
|
|
18406
|
+
this._removeEventListener();
|
|
18378
18407
|
this._nativeEvents = null;
|
|
18379
|
-
this._canvas = null;
|
|
18380
18408
|
this._delta = null;
|
|
18381
18409
|
};
|
|
18382
18410
|
_proto._onWheelEvent = function _onWheelEvent(evt) {
|
|
18383
|
-
evt.cancelable && evt.preventDefault();
|
|
18384
18411
|
this._nativeEvents.push(evt);
|
|
18385
18412
|
};
|
|
18386
18413
|
return WheelManager;
|
|
@@ -18389,19 +18416,19 @@ __decorate([
|
|
|
18389
18416
|
/**
|
|
18390
18417
|
* InputManager manages device input such as mouse, touch, keyboard, etc.
|
|
18391
18418
|
*/ var InputManager = /*#__PURE__*/ function() {
|
|
18392
|
-
function InputManager(engine) {
|
|
18419
|
+
function InputManager(engine, inputOptions) {
|
|
18393
18420
|
/** Sometimes the input module will not be initialized, such as off-screen rendering. */ this._initialized = false;
|
|
18394
18421
|
this._engine = engine;
|
|
18395
18422
|
// @ts-ignore
|
|
18396
18423
|
var canvas = engine._canvas._webCanvas;
|
|
18397
18424
|
if (typeof OffscreenCanvas === "undefined" || !_instanceof(canvas, OffscreenCanvas)) {
|
|
18398
|
-
|
|
18399
|
-
|
|
18400
|
-
this.
|
|
18401
|
-
|
|
18402
|
-
|
|
18403
|
-
|
|
18404
|
-
|
|
18425
|
+
var _inputOptions, _inputOptions1, _inputOptions2;
|
|
18426
|
+
var _inputOptions_wheelTarget;
|
|
18427
|
+
this._wheelManager = new WheelManager(engine, (_inputOptions_wheelTarget = (_inputOptions = inputOptions) == null ? void 0 : _inputOptions.wheelTarget) != null ? _inputOptions_wheelTarget : canvas);
|
|
18428
|
+
var _inputOptions_pointerTarget;
|
|
18429
|
+
this._pointerManager = new PointerManager(engine, (_inputOptions_pointerTarget = (_inputOptions1 = inputOptions) == null ? void 0 : _inputOptions1.pointerTarget) != null ? _inputOptions_pointerTarget : canvas);
|
|
18430
|
+
var _inputOptions_keyboardTarget;
|
|
18431
|
+
this._keyboardManager = new KeyboardManager(engine, (_inputOptions_keyboardTarget = (_inputOptions2 = inputOptions) == null ? void 0 : _inputOptions2.keyboardTarget) != null ? _inputOptions_keyboardTarget : window);
|
|
18405
18432
|
this._initialized = true;
|
|
18406
18433
|
}
|
|
18407
18434
|
}
|
|
@@ -18514,8 +18541,6 @@ __decorate([
|
|
|
18514
18541
|
* @internal
|
|
18515
18542
|
*/ _proto._destroy = function _destroy() {
|
|
18516
18543
|
if (this._initialized) {
|
|
18517
|
-
window.removeEventListener("blur", this._onBlur);
|
|
18518
|
-
window.removeEventListener("focus", this._onFocus);
|
|
18519
18544
|
this._wheelManager._destroy();
|
|
18520
18545
|
this._wheelManager = null;
|
|
18521
18546
|
this._pointerManager._destroy();
|
|
@@ -18524,16 +18549,6 @@ __decorate([
|
|
|
18524
18549
|
this._keyboardManager = null;
|
|
18525
18550
|
}
|
|
18526
18551
|
};
|
|
18527
|
-
_proto._onBlur = function _onBlur() {
|
|
18528
|
-
this._wheelManager._onBlur();
|
|
18529
|
-
this._pointerManager._onBlur();
|
|
18530
|
-
this._keyboardManager._onBlur();
|
|
18531
|
-
};
|
|
18532
|
-
_proto._onFocus = function _onFocus() {
|
|
18533
|
-
this._wheelManager._onFocus();
|
|
18534
|
-
this._pointerManager._onFocus();
|
|
18535
|
-
this._keyboardManager._onFocus();
|
|
18536
|
-
};
|
|
18537
18552
|
_create_class(InputManager, [
|
|
18538
18553
|
{
|
|
18539
18554
|
key: "pointers",
|
|
@@ -18576,6 +18591,8 @@ __decorate([
|
|
|
18576
18591
|
_this = ReferResource1.call(this, engine) || this;
|
|
18577
18592
|
/** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
|
|
18578
18593
|
;
|
|
18594
|
+
/** @internal */ _this._priority = 0 // todo: temporary resolution of submesh rendering order issue.
|
|
18595
|
+
;
|
|
18579
18596
|
_this._shaderData = new ShaderData(ShaderDataGroup.Material);
|
|
18580
18597
|
_this.shader = shader;
|
|
18581
18598
|
return _this;
|
|
@@ -19029,7 +19046,7 @@ ShaderPool.init();
|
|
|
19029
19046
|
_this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
|
|
19030
19047
|
_this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
|
|
19031
19048
|
_this._textDefaultFont.isGCIgnored = true;
|
|
19032
|
-
_this.inputManager = new InputManager(_assert_this_initialized(_this));
|
|
19049
|
+
_this.inputManager = new InputManager(_assert_this_initialized(_this), configuration.input);
|
|
19033
19050
|
var xrDevice = configuration.xrDevice;
|
|
19034
19051
|
if (xrDevice) {
|
|
19035
19052
|
_this.xrManager = new XRManager();
|
|
@@ -19652,7 +19669,7 @@ ShaderPool.init();
|
|
|
19652
19669
|
var e = viewProjMatrix.elements;
|
|
19653
19670
|
e[12] = e[13] = e[14] = 0;
|
|
19654
19671
|
// epsilon-infinity projection matrix http://terathon.com/gdc07_lengyel.pdf
|
|
19655
|
-
var f = 1.0 / Math.tan(MathUtil
|
|
19672
|
+
var f = 1.0 / Math.tan(MathUtil.degreeToRadian(fieldOfView) / 2);
|
|
19656
19673
|
projectionMatrix.elements[0] = f / aspectRatio;
|
|
19657
19674
|
projectionMatrix.elements[5] = f;
|
|
19658
19675
|
// view-proj matrix
|
|
@@ -19733,7 +19750,7 @@ ShaderPool.init();
|
|
|
19733
19750
|
* Background solid color.
|
|
19734
19751
|
* @defaultValue `new Color(0.25, 0.25, 0.25, 1.0)`
|
|
19735
19752
|
* @remarks When `mode` is `BackgroundMode.SolidColor`, the property will take effects.
|
|
19736
|
-
*/ solidColor = new Color
|
|
19753
|
+
*/ solidColor = new Color(0.25, 0.25, 0.25, 1.0);
|
|
19737
19754
|
this.sky = new Sky();
|
|
19738
19755
|
this./** @internal */ _textureFillMode = BackgroundTextureFillMode.AspectFitHeight;
|
|
19739
19756
|
this._texture = null;
|
|
@@ -20094,7 +20111,7 @@ ShaderPool.init();
|
|
|
20094
20111
|
function AmbientLight(engine) {
|
|
20095
20112
|
var _this;
|
|
20096
20113
|
_this = ReferResource1.call(this, engine) || this;
|
|
20097
|
-
_this._diffuseSolidColor = new Color
|
|
20114
|
+
_this._diffuseSolidColor = new Color(0.212, 0.227, 0.259);
|
|
20098
20115
|
_this._diffuseIntensity = 1.0;
|
|
20099
20116
|
_this._specularIntensity = 1.0;
|
|
20100
20117
|
_this._diffuseMode = DiffuseMode.SolidColor;
|
|
@@ -20391,8 +20408,8 @@ ShaderPool.init();
|
|
|
20391
20408
|
/** Near plane value to use for shadow frustums. */ _this.shadowNearPlane = 0.1;
|
|
20392
20409
|
/** Shadow intensity, the larger the value, the clearer and darker the shadow. */ _this.shadowStrength = 1.0;
|
|
20393
20410
|
/** @internal */ _this._lightIndex = -1;
|
|
20394
|
-
/** @internal */ _this._lightColor = new Color
|
|
20395
|
-
_this._color = new Color
|
|
20411
|
+
/** @internal */ _this._lightColor = new Color();
|
|
20412
|
+
_this._color = new Color(1, 1, 1, 1);
|
|
20396
20413
|
return _this;
|
|
20397
20414
|
}
|
|
20398
20415
|
var _proto = Light.prototype;
|
|
@@ -20470,9 +20487,9 @@ __decorate([
|
|
|
20470
20487
|
data.cullingMask[cullingMaskStart] = cullingMask & 65535;
|
|
20471
20488
|
data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
|
|
20472
20489
|
if (this.engine.settings.colorSpace === ColorSpace.Linear) {
|
|
20473
|
-
data.color[colorStart] = Color
|
|
20474
|
-
data.color[colorStart + 1] = Color
|
|
20475
|
-
data.color[colorStart + 2] = Color
|
|
20490
|
+
data.color[colorStart] = Color.gammaToLinearSpace(lightColor.r);
|
|
20491
|
+
data.color[colorStart + 1] = Color.gammaToLinearSpace(lightColor.g);
|
|
20492
|
+
data.color[colorStart + 2] = Color.gammaToLinearSpace(lightColor.b);
|
|
20476
20493
|
} else {
|
|
20477
20494
|
data.color[colorStart] = lightColor.r;
|
|
20478
20495
|
data.color[colorStart + 1] = lightColor.g;
|
|
@@ -20562,9 +20579,9 @@ __decorate([
|
|
|
20562
20579
|
data.cullingMask[cullingMaskStart] = cullingMask & 65535;
|
|
20563
20580
|
data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
|
|
20564
20581
|
if (this.engine.settings.colorSpace === ColorSpace.Linear) {
|
|
20565
|
-
data.color[colorStart] = Color
|
|
20566
|
-
data.color[colorStart + 1] = Color
|
|
20567
|
-
data.color[colorStart + 2] = Color
|
|
20582
|
+
data.color[colorStart] = Color.gammaToLinearSpace(lightColor.r);
|
|
20583
|
+
data.color[colorStart + 1] = Color.gammaToLinearSpace(lightColor.g);
|
|
20584
|
+
data.color[colorStart + 2] = Color.gammaToLinearSpace(lightColor.b);
|
|
20568
20585
|
} else {
|
|
20569
20586
|
data.color[colorStart] = lightColor.r;
|
|
20570
20587
|
data.color[colorStart + 1] = lightColor.g;
|
|
@@ -20658,9 +20675,9 @@ __decorate([
|
|
|
20658
20675
|
data.cullingMask[cullingMaskStart] = cullingMask & 65535;
|
|
20659
20676
|
data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
|
|
20660
20677
|
if (this.engine.settings.colorSpace === ColorSpace.Linear) {
|
|
20661
|
-
data.color[colorStart] = Color
|
|
20662
|
-
data.color[colorStart + 1] = Color
|
|
20663
|
-
data.color[colorStart + 2] = Color
|
|
20678
|
+
data.color[colorStart] = Color.gammaToLinearSpace(lightColor.r);
|
|
20679
|
+
data.color[colorStart + 1] = Color.gammaToLinearSpace(lightColor.g);
|
|
20680
|
+
data.color[colorStart + 2] = Color.gammaToLinearSpace(lightColor.b);
|
|
20664
20681
|
} else {
|
|
20665
20682
|
data.color[colorStart] = lightColor.r;
|
|
20666
20683
|
data.color[colorStart + 1] = lightColor.g;
|
|
@@ -20949,7 +20966,7 @@ __decorate([
|
|
|
20949
20966
|
_this._shaderData = new ShaderData(ShaderDataGroup.Scene);
|
|
20950
20967
|
_this._shadowCascades = ShadowCascadesMode.NoCascades;
|
|
20951
20968
|
_this._fogMode = FogMode.None;
|
|
20952
|
-
_this._fogColor = new Color
|
|
20969
|
+
_this._fogColor = new Color(0.5, 0.5, 0.5, 1.0);
|
|
20953
20970
|
_this._fogStart = 0;
|
|
20954
20971
|
_this._fogEnd = 300;
|
|
20955
20972
|
_this._fogDensity = 0.01;
|
|
@@ -21865,12 +21882,48 @@ var passNum = 0;
|
|
|
21865
21882
|
/**
|
|
21866
21883
|
* @internal
|
|
21867
21884
|
*/ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
|
|
21868
|
-
|
|
21885
|
+
var dataA = a.data;
|
|
21886
|
+
var dataB = b.data;
|
|
21887
|
+
var componentA = dataA.component;
|
|
21888
|
+
var componentB = dataB.component;
|
|
21889
|
+
var priorityOrder = componentA.priority - componentB.priority;
|
|
21890
|
+
if (priorityOrder !== 0) {
|
|
21891
|
+
return priorityOrder;
|
|
21892
|
+
}
|
|
21893
|
+
// make suer from the same renderer.
|
|
21894
|
+
if (componentA.instanceId === componentB.instanceId) {
|
|
21895
|
+
return dataA.material._priority - dataB.material._priority || componentA._distanceForSort - componentB._distanceForSort;
|
|
21896
|
+
} else {
|
|
21897
|
+
var distanceDiff = componentA._distanceForSort - componentB._distanceForSort;
|
|
21898
|
+
if (distanceDiff === 0) {
|
|
21899
|
+
return componentA.instanceId - componentB.instanceId;
|
|
21900
|
+
} else {
|
|
21901
|
+
return distanceDiff;
|
|
21902
|
+
}
|
|
21903
|
+
}
|
|
21869
21904
|
};
|
|
21870
21905
|
/**
|
|
21871
21906
|
* @internal
|
|
21872
21907
|
*/ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
|
|
21873
|
-
|
|
21908
|
+
var dataA = a.data;
|
|
21909
|
+
var dataB = b.data;
|
|
21910
|
+
var componentA = dataA.component;
|
|
21911
|
+
var componentB = dataB.component;
|
|
21912
|
+
var priorityOrder = componentA.priority - componentB.priority;
|
|
21913
|
+
if (priorityOrder !== 0) {
|
|
21914
|
+
return priorityOrder;
|
|
21915
|
+
}
|
|
21916
|
+
// make suer from the same renderer.
|
|
21917
|
+
if (componentA.instanceId === componentB.instanceId) {
|
|
21918
|
+
return dataA.material._priority - dataB.material._priority || componentB._distanceForSort - componentA._distanceForSort;
|
|
21919
|
+
} else {
|
|
21920
|
+
var distanceDiff = componentB._distanceForSort - componentA._distanceForSort;
|
|
21921
|
+
if (distanceDiff === 0) {
|
|
21922
|
+
return componentA.instanceId - componentB.instanceId;
|
|
21923
|
+
} else {
|
|
21924
|
+
return distanceDiff;
|
|
21925
|
+
}
|
|
21926
|
+
}
|
|
21874
21927
|
};
|
|
21875
21928
|
return RenderQueue;
|
|
21876
21929
|
}();
|
|
@@ -22025,7 +22078,7 @@ var /**
|
|
|
22025
22078
|
// https://lxjk.github.io/2017/04/15/Calculate-Minimal-Bounding-Sphere-of-Frustum.html
|
|
22026
22079
|
var centerZ;
|
|
22027
22080
|
var radius;
|
|
22028
|
-
var k = Math.sqrt(1.0 + aspectRatio * aspectRatio) * Math.tan(MathUtil
|
|
22081
|
+
var k = Math.sqrt(1.0 + aspectRatio * aspectRatio) * Math.tan(MathUtil.degreeToRadian(fieldOfView) / 2.0);
|
|
22029
22082
|
var k2 = k * k;
|
|
22030
22083
|
var farSNear = far - near;
|
|
22031
22084
|
var farANear = far + near;
|
|
@@ -22607,7 +22660,7 @@ var /**
|
|
|
22607
22660
|
var _this__camera = this._camera, nearClipPlane = _this__camera.nearClipPlane, aspectRatio = _this__camera.aspectRatio, fieldOfView = _this__camera.fieldOfView;
|
|
22608
22661
|
cascadesSplitDistance[0] = nearClipPlane;
|
|
22609
22662
|
var range = shadowFar - nearClipPlane;
|
|
22610
|
-
var tFov = Math.tan(MathUtil
|
|
22663
|
+
var tFov = Math.tan(MathUtil.degreeToRadian(fieldOfView) * 0.5);
|
|
22611
22664
|
var denominator = 1.0 + tFov * tFov * (aspectRatio * aspectRatio + 1.0);
|
|
22612
22665
|
switch(shadowCascades){
|
|
22613
22666
|
case ShadowCascadesMode.NoCascades:
|
|
@@ -22710,7 +22763,7 @@ var /**
|
|
|
22710
22763
|
CascadedShadowCasterPass._viewport = new Vector4(0, 0, 1, 1);
|
|
22711
22764
|
})();
|
|
22712
22765
|
(function() {
|
|
22713
|
-
CascadedShadowCasterPass._clearColor = new Color
|
|
22766
|
+
CascadedShadowCasterPass._clearColor = new Color(1, 1, 1, 1);
|
|
22714
22767
|
})();
|
|
22715
22768
|
(function() {
|
|
22716
22769
|
CascadedShadowCasterPass._tempVector = new Vector3();
|
|
@@ -23083,14 +23136,14 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23083
23136
|
/** @internal */ _this._cameraIndex = -1;
|
|
23084
23137
|
_this._priority = 0;
|
|
23085
23138
|
_this._shaderData = new ShaderData(ShaderDataGroup.Camera);
|
|
23086
|
-
_this.
|
|
23139
|
+
_this._isCustomViewMatrix = false;
|
|
23140
|
+
_this._isCustomProjectionMatrix = false;
|
|
23087
23141
|
_this._nearClipPlane = 0.1;
|
|
23088
23142
|
_this._farClipPlane = 100;
|
|
23089
23143
|
_this._fieldOfView = 45;
|
|
23090
23144
|
_this._orthographicSize = 10;
|
|
23091
23145
|
_this._isProjectionDirty = true;
|
|
23092
23146
|
_this._isInvProjMatDirty = true;
|
|
23093
|
-
_this._isFrustumProjectDirty = true;
|
|
23094
23147
|
_this._customAspectRatio = undefined;
|
|
23095
23148
|
_this._renderTarget = null;
|
|
23096
23149
|
_this._depthBufferParams = new Vector4();
|
|
@@ -23102,7 +23155,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23102
23155
|
_this._transform = transform;
|
|
23103
23156
|
_this._isViewMatrixDirty = transform.registerWorldChangeFlag();
|
|
23104
23157
|
_this._isInvViewProjDirty = transform.registerWorldChangeFlag();
|
|
23105
|
-
_this.
|
|
23158
|
+
_this._frustumChangeFlag = transform.registerWorldChangeFlag();
|
|
23106
23159
|
_this._renderPipeline = new BasicRenderPipeline(_assert_this_initialized(_this));
|
|
23107
23160
|
_this._addResourceReferCount(_this.shaderData, 1);
|
|
23108
23161
|
_this._updatePixelViewport();
|
|
@@ -23114,16 +23167,22 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23114
23167
|
}
|
|
23115
23168
|
var _proto = Camera1.prototype;
|
|
23116
23169
|
/**
|
|
23170
|
+
* Restore the view matrix to the world matrix of the entity.
|
|
23171
|
+
*/ _proto.resetViewMatrix = function resetViewMatrix() {
|
|
23172
|
+
this._isCustomViewMatrix = false;
|
|
23173
|
+
this._viewMatrixChange();
|
|
23174
|
+
};
|
|
23175
|
+
/**
|
|
23117
23176
|
* Restore the automatic calculation of projection matrix through fieldOfView, nearClipPlane and farClipPlane.
|
|
23118
23177
|
*/ _proto.resetProjectionMatrix = function resetProjectionMatrix() {
|
|
23119
|
-
this.
|
|
23120
|
-
this.
|
|
23178
|
+
this._isCustomProjectionMatrix = false;
|
|
23179
|
+
this._projectionMatrixChange();
|
|
23121
23180
|
};
|
|
23122
23181
|
/**
|
|
23123
23182
|
* Restore the automatic calculation of the aspect ratio through the viewport aspect ratio.
|
|
23124
23183
|
*/ _proto.resetAspectRatio = function resetAspectRatio() {
|
|
23125
23184
|
this._customAspectRatio = undefined;
|
|
23126
|
-
this.
|
|
23185
|
+
this._projectionMatrixChange();
|
|
23127
23186
|
};
|
|
23128
23187
|
/**
|
|
23129
23188
|
* Transform a point from world space to viewport space.
|
|
@@ -23170,7 +23229,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23170
23229
|
// Use the intersection of the near clipping plane as the origin point.
|
|
23171
23230
|
var origin = this._innerViewportToWorldPoint(point.x, point.y, 0.0, invViewProjMat, out.origin);
|
|
23172
23231
|
// Use the intersection of the far clipping plane as the origin point.
|
|
23173
|
-
var direction = this._innerViewportToWorldPoint(point.x, point.y, 1 - MathUtil
|
|
23232
|
+
var direction = this._innerViewportToWorldPoint(point.x, point.y, 1 - MathUtil.zeroTolerance, invViewProjMat, out.direction);
|
|
23174
23233
|
Vector3.subtract(direction, origin, direction);
|
|
23175
23234
|
direction.normalize();
|
|
23176
23235
|
return out;
|
|
@@ -23253,10 +23312,9 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23253
23312
|
context.replacementShader = this._replacementShader;
|
|
23254
23313
|
context.replacementTag = this._replacementSubShaderTag;
|
|
23255
23314
|
// compute cull frustum.
|
|
23256
|
-
if (this.enableFrustumCulling &&
|
|
23315
|
+
if (this.enableFrustumCulling && this._frustumChangeFlag.flag) {
|
|
23257
23316
|
this._frustum.calculateFromMatrix(virtualCamera.viewProjectionMatrix);
|
|
23258
|
-
this.
|
|
23259
|
-
this._isFrustumProjectDirty = false;
|
|
23317
|
+
this._frustumChangeFlag.flag = false;
|
|
23260
23318
|
}
|
|
23261
23319
|
this._updateShaderData();
|
|
23262
23320
|
// union scene and camera macro.
|
|
@@ -23311,7 +23369,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23311
23369
|
this._renderPipeline = null;
|
|
23312
23370
|
this._virtualCamera = null;
|
|
23313
23371
|
this._shaderData = null;
|
|
23314
|
-
this.
|
|
23372
|
+
this._frustumChangeFlag = null;
|
|
23315
23373
|
this._transform = null;
|
|
23316
23374
|
this._isViewMatrixDirty = null;
|
|
23317
23375
|
this._isInvViewProjDirty = null;
|
|
@@ -23333,11 +23391,16 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23333
23391
|
var viewport = this._viewport;
|
|
23334
23392
|
this._pixelViewport.set(viewport.x * width, viewport.y * height, viewport.z * width, viewport.w * height);
|
|
23335
23393
|
};
|
|
23336
|
-
_proto.
|
|
23337
|
-
this.
|
|
23394
|
+
_proto._viewMatrixChange = function _viewMatrixChange() {
|
|
23395
|
+
this._isViewMatrixDirty.flag = true;
|
|
23396
|
+
this._isInvViewProjDirty.flag = true;
|
|
23397
|
+
this._frustumChangeFlag.flag = true;
|
|
23398
|
+
};
|
|
23399
|
+
_proto._projectionMatrixChange = function _projectionMatrixChange() {
|
|
23338
23400
|
this._isProjectionDirty = true;
|
|
23339
23401
|
this._isInvProjMatDirty = true;
|
|
23340
23402
|
this._isInvViewProjDirty.flag = true;
|
|
23403
|
+
this._frustumChangeFlag.flag = true;
|
|
23341
23404
|
};
|
|
23342
23405
|
_proto._innerViewportToWorldPoint = function _innerViewportToWorldPoint(x, y, z, invViewProjMat, out) {
|
|
23343
23406
|
// Depth is a normalized value, 0 is nearPlane, 1 is farClipPlane.
|
|
@@ -23380,7 +23443,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23380
23443
|
_proto._onPixelViewportChanged = function _onPixelViewportChanged() {
|
|
23381
23444
|
this._updatePixelViewport();
|
|
23382
23445
|
var _this__customAspectRatio;
|
|
23383
|
-
(_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this.
|
|
23446
|
+
(_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this._projectionMatrixChange();
|
|
23384
23447
|
};
|
|
23385
23448
|
_create_class(Camera1, [
|
|
23386
23449
|
{
|
|
@@ -23400,7 +23463,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23400
23463
|
},
|
|
23401
23464
|
set: function set(value) {
|
|
23402
23465
|
this._nearClipPlane = value;
|
|
23403
|
-
this.
|
|
23466
|
+
this._projectionMatrixChange();
|
|
23404
23467
|
}
|
|
23405
23468
|
},
|
|
23406
23469
|
{
|
|
@@ -23412,7 +23475,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23412
23475
|
},
|
|
23413
23476
|
set: function set(value) {
|
|
23414
23477
|
this._farClipPlane = value;
|
|
23415
|
-
this.
|
|
23478
|
+
this._projectionMatrixChange();
|
|
23416
23479
|
}
|
|
23417
23480
|
},
|
|
23418
23481
|
{
|
|
@@ -23424,7 +23487,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23424
23487
|
},
|
|
23425
23488
|
set: function set(value) {
|
|
23426
23489
|
this._fieldOfView = value;
|
|
23427
|
-
this.
|
|
23490
|
+
this._projectionMatrixChange();
|
|
23428
23491
|
}
|
|
23429
23492
|
},
|
|
23430
23493
|
{
|
|
@@ -23439,7 +23502,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23439
23502
|
},
|
|
23440
23503
|
set: function set(value) {
|
|
23441
23504
|
this._customAspectRatio = value;
|
|
23442
|
-
this.
|
|
23505
|
+
this._projectionMatrixChange();
|
|
23443
23506
|
}
|
|
23444
23507
|
},
|
|
23445
23508
|
{
|
|
@@ -23491,7 +23554,12 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23491
23554
|
},
|
|
23492
23555
|
set: function set(value) {
|
|
23493
23556
|
this._virtualCamera.isOrthographic = value;
|
|
23494
|
-
this.
|
|
23557
|
+
this._projectionMatrixChange();
|
|
23558
|
+
if (value) {
|
|
23559
|
+
this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC");
|
|
23560
|
+
} else {
|
|
23561
|
+
this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC");
|
|
23562
|
+
}
|
|
23495
23563
|
}
|
|
23496
23564
|
},
|
|
23497
23565
|
{
|
|
@@ -23503,7 +23571,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23503
23571
|
},
|
|
23504
23572
|
set: function set(value) {
|
|
23505
23573
|
this._orthographicSize = value;
|
|
23506
|
-
this.
|
|
23574
|
+
this._projectionMatrixChange();
|
|
23507
23575
|
}
|
|
23508
23576
|
},
|
|
23509
23577
|
{
|
|
@@ -23512,28 +23580,37 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23512
23580
|
* View matrix.
|
|
23513
23581
|
*/ function get() {
|
|
23514
23582
|
var viewMatrix = this._virtualCamera.viewMatrix;
|
|
23515
|
-
if (this._isViewMatrixDirty.flag) {
|
|
23516
|
-
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23521
|
-
|
|
23583
|
+
if (!this._isViewMatrixDirty.flag || this._isCustomViewMatrix) {
|
|
23584
|
+
return viewMatrix;
|
|
23585
|
+
}
|
|
23586
|
+
this._isViewMatrixDirty.flag = false;
|
|
23587
|
+
// Ignore scale
|
|
23588
|
+
var transform = this._transform;
|
|
23589
|
+
Matrix.rotationTranslation(transform.worldRotationQuaternion, transform.worldPosition, viewMatrix);
|
|
23590
|
+
viewMatrix.invert();
|
|
23522
23591
|
return viewMatrix;
|
|
23592
|
+
},
|
|
23593
|
+
set: function set(value) {
|
|
23594
|
+
this._virtualCamera.viewMatrix.copyFrom(value);
|
|
23595
|
+
this._isCustomViewMatrix = true;
|
|
23596
|
+
this._viewMatrixChange();
|
|
23523
23597
|
}
|
|
23524
23598
|
},
|
|
23525
23599
|
{
|
|
23526
23600
|
key: "projectionMatrix",
|
|
23527
|
-
get:
|
|
23601
|
+
get: /**
|
|
23602
|
+
* The projection matrix is calculated by the relevant parameters of the camera by default.
|
|
23603
|
+
* If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
|
|
23604
|
+
*/ function get() {
|
|
23528
23605
|
var virtualCamera = this._virtualCamera;
|
|
23529
23606
|
var projectionMatrix = virtualCamera.projectionMatrix;
|
|
23530
|
-
if (!this._isProjectionDirty || this.
|
|
23607
|
+
if (!this._isProjectionDirty || this._isCustomProjectionMatrix) {
|
|
23531
23608
|
return projectionMatrix;
|
|
23532
23609
|
}
|
|
23533
23610
|
this._isProjectionDirty = false;
|
|
23534
23611
|
var aspectRatio = this.aspectRatio;
|
|
23535
23612
|
if (!virtualCamera.isOrthographic) {
|
|
23536
|
-
Matrix.perspective(MathUtil
|
|
23613
|
+
Matrix.perspective(MathUtil.degreeToRadian(this._fieldOfView), aspectRatio, this._nearClipPlane, this._farClipPlane, projectionMatrix);
|
|
23537
23614
|
} else {
|
|
23538
23615
|
var width = this._orthographicSize * aspectRatio;
|
|
23539
23616
|
var height = this._orthographicSize;
|
|
@@ -23541,13 +23618,10 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23541
23618
|
}
|
|
23542
23619
|
return projectionMatrix;
|
|
23543
23620
|
},
|
|
23544
|
-
set:
|
|
23545
|
-
* The projection matrix is calculated by the relevant parameters of the camera by default.
|
|
23546
|
-
* If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
|
|
23547
|
-
*/ function set(value) {
|
|
23621
|
+
set: function set(value) {
|
|
23548
23622
|
this._virtualCamera.projectionMatrix.copyFrom(value);
|
|
23549
|
-
this.
|
|
23550
|
-
this.
|
|
23623
|
+
this._isCustomProjectionMatrix = true;
|
|
23624
|
+
this._projectionMatrixChange();
|
|
23551
23625
|
}
|
|
23552
23626
|
},
|
|
23553
23627
|
{
|
|
@@ -23608,7 +23682,7 @@ __decorate([
|
|
|
23608
23682
|
], Camera.prototype, "_cameraIndex", void 0);
|
|
23609
23683
|
__decorate([
|
|
23610
23684
|
ignoreClone
|
|
23611
|
-
], Camera.prototype, "
|
|
23685
|
+
], Camera.prototype, "_frustumChangeFlag", void 0);
|
|
23612
23686
|
__decorate([
|
|
23613
23687
|
ignoreClone
|
|
23614
23688
|
], Camera.prototype, "_transform", void 0);
|
|
@@ -24084,9 +24158,9 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
|
|
|
24084
24158
|
var shaderData = _this.shaderData;
|
|
24085
24159
|
shaderData.enableMacro("MATERIAL_NEED_WORLD_POS");
|
|
24086
24160
|
shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
|
|
24087
|
-
shaderData.setColor(BlinnPhongMaterial._baseColorProp, new Color
|
|
24088
|
-
shaderData.setColor(BlinnPhongMaterial._specularColorProp, new Color
|
|
24089
|
-
shaderData.setColor(BlinnPhongMaterial._emissiveColorProp, new Color
|
|
24161
|
+
shaderData.setColor(BlinnPhongMaterial._baseColorProp, new Color(1, 1, 1, 1));
|
|
24162
|
+
shaderData.setColor(BlinnPhongMaterial._specularColorProp, new Color(1, 1, 1, 1));
|
|
24163
|
+
shaderData.setColor(BlinnPhongMaterial._emissiveColorProp, new Color(0, 0, 0, 1));
|
|
24090
24164
|
shaderData.setVector4(BlinnPhongMaterial._tilingOffsetProp, new Vector4(1, 1, 0, 0));
|
|
24091
24165
|
shaderData.setFloat(BlinnPhongMaterial._shininessProp, 16);
|
|
24092
24166
|
shaderData.setFloat(BlinnPhongMaterial._normalIntensityProp, 1);
|
|
@@ -24278,8 +24352,8 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
|
|
|
24278
24352
|
var shaderData = _this.shaderData;
|
|
24279
24353
|
shaderData.enableMacro("MATERIAL_NEED_WORLD_POS");
|
|
24280
24354
|
shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
|
|
24281
|
-
shaderData.setColor(PBRBaseMaterial._baseColorProp, new Color
|
|
24282
|
-
shaderData.setColor(PBRBaseMaterial._emissiveColorProp, new Color
|
|
24355
|
+
shaderData.setColor(PBRBaseMaterial._baseColorProp, new Color(1, 1, 1, 1));
|
|
24356
|
+
shaderData.setColor(PBRBaseMaterial._emissiveColorProp, new Color(0, 0, 0, 1));
|
|
24283
24357
|
shaderData.setVector4(PBRBaseMaterial._tilingOffsetProp, new Vector4(1, 1, 0, 0));
|
|
24284
24358
|
shaderData.setFloat(PBRBaseMaterial._normalIntensityProp, 1);
|
|
24285
24359
|
shaderData.setFloat(PBRBaseMaterial._occlusionTextureIntensityProp, 1);
|
|
@@ -24646,7 +24720,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
|
|
|
24646
24720
|
if (this._anisotropyRotation !== value) {
|
|
24647
24721
|
this._anisotropyRotation = value;
|
|
24648
24722
|
var anisotropyInfo = this.shaderData.getVector3(PBRMaterial._anisotropyInfoProp);
|
|
24649
|
-
var rad = MathUtil
|
|
24723
|
+
var rad = MathUtil.degreeToRadFactor * value;
|
|
24650
24724
|
anisotropyInfo.x = Math.cos(rad);
|
|
24651
24725
|
anisotropyInfo.y = Math.sin(rad);
|
|
24652
24726
|
}
|
|
@@ -24700,7 +24774,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
|
|
|
24700
24774
|
function PBRSpecularMaterial(engine) {
|
|
24701
24775
|
var _this;
|
|
24702
24776
|
_this = PBRBaseMaterial1.call(this, engine, Shader.find("pbr-specular")) || this;
|
|
24703
|
-
_this.shaderData.setColor(PBRSpecularMaterial._specularColorProp, new Color
|
|
24777
|
+
_this.shaderData.setColor(PBRSpecularMaterial._specularColorProp, new Color(1, 1, 1, 1));
|
|
24704
24778
|
_this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, 1.0);
|
|
24705
24779
|
return _this;
|
|
24706
24780
|
}
|
|
@@ -24781,7 +24855,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
|
|
|
24781
24855
|
var shaderData = _this.shaderData;
|
|
24782
24856
|
shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
|
|
24783
24857
|
shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
|
|
24784
|
-
shaderData.setColor(UnlitMaterial._baseColorProp, new Color
|
|
24858
|
+
shaderData.setColor(UnlitMaterial._baseColorProp, new Color(1, 1, 1, 1));
|
|
24785
24859
|
shaderData.setVector4(UnlitMaterial._tilingOffsetProp, new Vector4(1, 1, 0, 0));
|
|
24786
24860
|
return _this;
|
|
24787
24861
|
}
|
|
@@ -25241,6 +25315,7 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
25241
25315
|
_this = EngineObject1.call(this, null) || this;
|
|
25242
25316
|
_this.name = name;
|
|
25243
25317
|
_this./** @internal */ _curveBindings = [];
|
|
25318
|
+
_this./** @internal */ _updateFlagManager = new UpdateFlagManager();
|
|
25244
25319
|
_this._length = 0;
|
|
25245
25320
|
_this._events = [];
|
|
25246
25321
|
return _this;
|
|
@@ -25268,11 +25343,13 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
25268
25343
|
while(--index >= 0 && eventTime < events[index].time);
|
|
25269
25344
|
events.splice(index + 1, 0, newEvent);
|
|
25270
25345
|
}
|
|
25346
|
+
this._updateFlagManager.dispatch();
|
|
25271
25347
|
};
|
|
25272
25348
|
/**
|
|
25273
25349
|
* Clears all events from the clip.
|
|
25274
25350
|
*/ _proto.clearEvents = function clearEvents() {
|
|
25275
25351
|
this._events.length = 0;
|
|
25352
|
+
this._updateFlagManager.dispatch();
|
|
25276
25353
|
};
|
|
25277
25354
|
_proto.addCurveBinding = function addCurveBinding(entityPath, componentType, propertyOrSetPropertyPathOrComponentIndex, curveOrSetPropertyPathOrGetPropertyPath, curveOrGetPropertyPath, curve) {
|
|
25278
25355
|
var curveBinding = new AnimationClipCurveBinding();
|
|
@@ -25669,32 +25746,32 @@ var AnimationColorCurve = (_AnimationColorCurve = /*#__PURE__*/ function(Animati
|
|
|
25669
25746
|
function AnimationColorCurve() {
|
|
25670
25747
|
var _this;
|
|
25671
25748
|
_this = AnimationCurve1.call(this) || this;
|
|
25672
|
-
_this._evaluateData.value = new Color
|
|
25749
|
+
_this._evaluateData.value = new Color();
|
|
25673
25750
|
return _this;
|
|
25674
25751
|
}
|
|
25675
25752
|
/**
|
|
25676
25753
|
* @internal
|
|
25677
25754
|
*/ AnimationColorCurve._initializeOwner = function _initializeOwner(owner) {
|
|
25678
|
-
owner.defaultValue = new Color
|
|
25679
|
-
owner.fixedPoseValue = new Color
|
|
25680
|
-
owner.baseEvaluateData.value = new Color
|
|
25681
|
-
owner.crossEvaluateData.value = new Color
|
|
25755
|
+
owner.defaultValue = new Color();
|
|
25756
|
+
owner.fixedPoseValue = new Color();
|
|
25757
|
+
owner.baseEvaluateData.value = new Color();
|
|
25758
|
+
owner.crossEvaluateData.value = new Color();
|
|
25682
25759
|
};
|
|
25683
25760
|
/**
|
|
25684
25761
|
* @internal
|
|
25685
25762
|
*/ AnimationColorCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
|
|
25686
|
-
owner.finalValue = new Color
|
|
25763
|
+
owner.finalValue = new Color();
|
|
25687
25764
|
};
|
|
25688
25765
|
/**
|
|
25689
25766
|
* @internal
|
|
25690
25767
|
*/ AnimationColorCurve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
|
|
25691
|
-
Color
|
|
25768
|
+
Color.lerp(srcValue, destValue, weight, out);
|
|
25692
25769
|
return out;
|
|
25693
25770
|
};
|
|
25694
25771
|
/**
|
|
25695
25772
|
* @internal
|
|
25696
25773
|
*/ AnimationColorCurve._subtractValue = function _subtractValue(src, base, out) {
|
|
25697
|
-
Color
|
|
25774
|
+
Color.subtract(src, base, out);
|
|
25698
25775
|
return out;
|
|
25699
25776
|
};
|
|
25700
25777
|
/**
|
|
@@ -25706,8 +25783,8 @@ var AnimationColorCurve = (_AnimationColorCurve = /*#__PURE__*/ function(Animati
|
|
|
25706
25783
|
/**
|
|
25707
25784
|
* @internal
|
|
25708
25785
|
*/ AnimationColorCurve._additiveValue = function _additiveValue(value, weight, out) {
|
|
25709
|
-
Color
|
|
25710
|
-
Color
|
|
25786
|
+
Color.scale(value, weight, value);
|
|
25787
|
+
Color.add(out, value, out);
|
|
25711
25788
|
return out;
|
|
25712
25789
|
};
|
|
25713
25790
|
/**
|
|
@@ -26829,26 +26906,31 @@ var AnimatorLayerBlendingMode;
|
|
|
26829
26906
|
}
|
|
26830
26907
|
};
|
|
26831
26908
|
_proto._saveAnimatorEventHandlers = function _saveAnimatorEventHandlers(state, animatorStateData) {
|
|
26909
|
+
var _this = this;
|
|
26832
26910
|
var eventHandlerPool = this._animationEventHandlerPool;
|
|
26833
26911
|
var scripts = [];
|
|
26834
|
-
this._entity.getComponents(Script, scripts);
|
|
26835
|
-
var scriptCount = scripts.length;
|
|
26836
26912
|
var eventHandlers = animatorStateData.eventHandlers;
|
|
26837
|
-
var
|
|
26838
|
-
|
|
26839
|
-
|
|
26840
|
-
var
|
|
26841
|
-
|
|
26842
|
-
var
|
|
26843
|
-
|
|
26844
|
-
|
|
26845
|
-
|
|
26846
|
-
|
|
26847
|
-
|
|
26848
|
-
|
|
26913
|
+
var clipChangedListener = function() {
|
|
26914
|
+
_this._entity.getComponents(Script, scripts);
|
|
26915
|
+
var scriptCount = scripts.length;
|
|
26916
|
+
var events = state.clip.events;
|
|
26917
|
+
eventHandlers.length = 0;
|
|
26918
|
+
for(var i = 0, n = events.length; i < n; i++){
|
|
26919
|
+
var event = events[i];
|
|
26920
|
+
var eventHandler = eventHandlerPool.getFromPool();
|
|
26921
|
+
var funcName = event.functionName;
|
|
26922
|
+
var handlers = eventHandler.handlers;
|
|
26923
|
+
eventHandler.event = event;
|
|
26924
|
+
handlers.length = 0;
|
|
26925
|
+
for(var j = scriptCount - 1; j >= 0; j--){
|
|
26926
|
+
var handler = scripts[j][funcName];
|
|
26927
|
+
handler && handlers.push(handler);
|
|
26928
|
+
}
|
|
26929
|
+
eventHandlers.push(eventHandler);
|
|
26849
26930
|
}
|
|
26850
|
-
|
|
26851
|
-
|
|
26931
|
+
};
|
|
26932
|
+
clipChangedListener();
|
|
26933
|
+
state._updateFlagManager.addListener(clipChangedListener);
|
|
26852
26934
|
};
|
|
26853
26935
|
_proto._clearCrossData = function _clearCrossData(animatorLayerData) {
|
|
26854
26936
|
animatorLayerData.crossCurveMark++;
|
|
@@ -27459,9 +27541,11 @@ __decorate([
|
|
|
27459
27541
|
this./** @internal */ _onStateEnterScripts = [];
|
|
27460
27542
|
this./** @internal */ _onStateUpdateScripts = [];
|
|
27461
27543
|
this./** @internal */ _onStateExitScripts = [];
|
|
27544
|
+
this./** @internal */ _updateFlagManager = new UpdateFlagManager();
|
|
27462
27545
|
this._clipStartTime = 0;
|
|
27463
27546
|
this._clipEndTime = 1;
|
|
27464
27547
|
this._transitions = [];
|
|
27548
|
+
this._onClipChanged = this._onClipChanged.bind(this);
|
|
27465
27549
|
}
|
|
27466
27550
|
var _proto = AnimatorState.prototype;
|
|
27467
27551
|
/**
|
|
@@ -27535,6 +27619,11 @@ __decorate([
|
|
|
27535
27619
|
index2 !== -1 && this._onStateExitScripts.splice(index2, 1);
|
|
27536
27620
|
}
|
|
27537
27621
|
};
|
|
27622
|
+
/**
|
|
27623
|
+
* @internal
|
|
27624
|
+
*/ _proto._onClipChanged = function _onClipChanged() {
|
|
27625
|
+
this._updateFlagManager.dispatch();
|
|
27626
|
+
};
|
|
27538
27627
|
_create_class(AnimatorState, [
|
|
27539
27628
|
{
|
|
27540
27629
|
key: "transitions",
|
|
@@ -27552,8 +27641,17 @@ __decorate([
|
|
|
27552
27641
|
return this._clip;
|
|
27553
27642
|
},
|
|
27554
27643
|
set: function set(clip) {
|
|
27644
|
+
var lastClip = this._clip;
|
|
27645
|
+
if (lastClip === clip) {
|
|
27646
|
+
return;
|
|
27647
|
+
}
|
|
27648
|
+
if (lastClip) {
|
|
27649
|
+
lastClip._updateFlagManager.removeListener(this._onClipChanged);
|
|
27650
|
+
}
|
|
27555
27651
|
this._clip = clip;
|
|
27556
27652
|
this._clipEndTime = Math.min(this._clipEndTime, 1);
|
|
27653
|
+
this._onClipChanged();
|
|
27654
|
+
clip._updateFlagManager.addListener(this._onClipChanged);
|
|
27557
27655
|
}
|
|
27558
27656
|
},
|
|
27559
27657
|
{
|
|
@@ -27764,7 +27862,7 @@ var AnimatorConditionMode;
|
|
|
27764
27862
|
var _this;
|
|
27765
27863
|
_this = Material1.call(this, engine, Shader.find("skybox")) || this;
|
|
27766
27864
|
_this._textureDecodeRGBM = false;
|
|
27767
|
-
_this._tintColor = new Color
|
|
27865
|
+
_this._tintColor = new Color(1, 1, 1, 1);
|
|
27768
27866
|
_this.renderState.rasterState.cullMode = CullMode.Off;
|
|
27769
27867
|
_this.renderState.depthState.compareFunction = CompareFunction.LessEqual;
|
|
27770
27868
|
_this.shaderData.setFloat(SkyBoxMaterial._rotationProp, 0);
|
|
@@ -27877,8 +27975,8 @@ var SunMode;
|
|
|
27877
27975
|
_this.sunSize = 0.04;
|
|
27878
27976
|
_this.sunSizeConvergence = 5;
|
|
27879
27977
|
_this.atmosphereThickness = 1.0;
|
|
27880
|
-
_this.skyTint = new Color
|
|
27881
|
-
_this.groundTint = new Color
|
|
27978
|
+
_this.skyTint = new Color(0.5, 0.5, 0.5, 1.0);
|
|
27979
|
+
_this.groundTint = new Color(0.369, 0.349, 0.341, 1.0);
|
|
27882
27980
|
_this.exposure = 1.3;
|
|
27883
27981
|
_this.renderState.rasterState.cullMode = CullMode.Off;
|
|
27884
27982
|
_this.renderState.depthState.compareFunction = CompareFunction.LessEqual;
|
|
@@ -28358,9 +28456,9 @@ __decorate([
|
|
|
28358
28456
|
typeArray[offset] = key.time;
|
|
28359
28457
|
var color = key.color;
|
|
28360
28458
|
if (colorSpace === ColorSpace.Linear) {
|
|
28361
|
-
typeArray[offset + 1] = Color
|
|
28362
|
-
typeArray[offset + 2] = Color
|
|
28363
|
-
typeArray[offset + 3] = Color
|
|
28459
|
+
typeArray[offset + 1] = Color.gammaToLinearSpace(color.r);
|
|
28460
|
+
typeArray[offset + 2] = Color.gammaToLinearSpace(color.g);
|
|
28461
|
+
typeArray[offset + 3] = Color.gammaToLinearSpace(color.b);
|
|
28364
28462
|
} else {
|
|
28365
28463
|
typeArray[offset + 1] = color.r;
|
|
28366
28464
|
typeArray[offset + 2] = color.g;
|
|
@@ -28445,7 +28543,7 @@ __decorate([
|
|
|
28445
28543
|
*/ var GradientColorKey = /*#__PURE__*/ function() {
|
|
28446
28544
|
function GradientColorKey(time, color) {
|
|
28447
28545
|
/** @internal */ this._onValueChanged = null;
|
|
28448
|
-
this._color = new Color
|
|
28546
|
+
this._color = new Color();
|
|
28449
28547
|
this._time = time;
|
|
28450
28548
|
color && this._color.copyFrom(color);
|
|
28451
28549
|
// @ts-ignore
|
|
@@ -28522,11 +28620,11 @@ __decorate([
|
|
|
28522
28620
|
*/ var ParticleCompositeGradient = /*#__PURE__*/ function() {
|
|
28523
28621
|
function ParticleCompositeGradient(constantOrGradient, constantMaxOrGradientMax) {
|
|
28524
28622
|
/** The gradient mode. */ this.mode = ParticleGradientMode.Constant;
|
|
28525
|
-
/* The min constant color used by the gradient if mode is set to `TwoConstants`. */ this.constantMin = new Color
|
|
28526
|
-
/* The max constant color used by the gradient if mode is set to `TwoConstants`. */ this.constantMax = new Color
|
|
28623
|
+
/* The min constant color used by the gradient if mode is set to `TwoConstants`. */ this.constantMin = new Color();
|
|
28624
|
+
/* The max constant color used by the gradient if mode is set to `TwoConstants`. */ this.constantMax = new Color();
|
|
28527
28625
|
/** The min gradient used by the gradient if mode is set to `Gradient`. */ this.gradientMin = new ParticleGradient();
|
|
28528
28626
|
/** The max gradient used by the gradient if mode is set to `Gradient`. */ this.gradientMax = new ParticleGradient();
|
|
28529
|
-
if (constantOrGradient.constructor === Color
|
|
28627
|
+
if (constantOrGradient.constructor === Color) {
|
|
28530
28628
|
if (constantMaxOrGradientMax) {
|
|
28531
28629
|
this.constantMin.copyFrom(constantOrGradient);
|
|
28532
28630
|
this.constantMax.copyFrom(constantMaxOrGradientMax);
|
|
@@ -28558,7 +28656,7 @@ __decorate([
|
|
|
28558
28656
|
out.copyFrom(this.constant);
|
|
28559
28657
|
break;
|
|
28560
28658
|
case ParticleGradientMode.TwoConstants:
|
|
28561
|
-
Color
|
|
28659
|
+
Color.lerp(this.constantMin, this.constantMax, lerpFactor, out);
|
|
28562
28660
|
break;
|
|
28563
28661
|
}
|
|
28564
28662
|
};
|
|
@@ -28630,8 +28728,8 @@ __decorate([
|
|
|
28630
28728
|
var _this;
|
|
28631
28729
|
_this = ParticleGeneratorModule1.apply(this, arguments) || this;
|
|
28632
28730
|
/** Color gradient over lifetime. */ _this.color = new ParticleCompositeGradient(new ParticleGradient([
|
|
28633
|
-
new GradientColorKey(0.0, new Color
|
|
28634
|
-
new GradientColorKey(1.0, new Color
|
|
28731
|
+
new GradientColorKey(0.0, new Color(1, 1, 1)),
|
|
28732
|
+
new GradientColorKey(1.0, new Color(1, 1, 1))
|
|
28635
28733
|
], [
|
|
28636
28734
|
new GradientAlphaKey(0, 1),
|
|
28637
28735
|
new GradientAlphaKey(1, 1)
|
|
@@ -28961,7 +29059,7 @@ var MainModule = /*#__PURE__*/ function() {
|
|
|
28961
29059
|
/** The initial rotation of particles around the y-axis when emitted. */ this.startRotationY = new ParticleCompositeCurve(0);
|
|
28962
29060
|
/** The initial rotation of particles around the z-axis when emitted. */ this.startRotationZ = new ParticleCompositeCurve(0);
|
|
28963
29061
|
/** Makes some particles spin in the opposite direction. */ this.flipRotation = 0;
|
|
28964
|
-
/** The mode of start color */ this.startColor = new ParticleCompositeGradient(new Color
|
|
29062
|
+
/** The mode of start color */ this.startColor = new ParticleCompositeGradient(new Color(1, 1, 1, 1));
|
|
28965
29063
|
/** A scale that this Particle Generator applies to gravity, defined by Physics.gravity. */ this.gravityModifier = new ParticleCompositeCurve(0);
|
|
28966
29064
|
/** This selects the space in which to simulate particles. It can be either world or local space. */ this.simulationSpace = ParticleSimulationSpace.Local;
|
|
28967
29065
|
/** Override the default playback speed of the Particle Generator. */ this.simulationSpeed = 1.0;
|
|
@@ -29206,11 +29304,11 @@ __decorate([
|
|
|
29206
29304
|
isCurveMacro = RotationOverLifetimeModule._curveModeMacro;
|
|
29207
29305
|
} else {
|
|
29208
29306
|
var constantMax = this._rotationMaxConstant;
|
|
29209
|
-
constantMax.set(MathUtil
|
|
29307
|
+
constantMax.set(MathUtil.degreeToRadian(rotationX.constantMax), MathUtil.degreeToRadian(rotationY.constantMax), MathUtil.degreeToRadian(rotationZ.constantMax));
|
|
29210
29308
|
shaderData.setVector3(RotationOverLifetimeModule._maxConstantProperty, constantMax);
|
|
29211
29309
|
if (separateAxes ? rotationX.mode === ParticleCurveMode.TwoConstants && rotationY.mode === ParticleCurveMode.TwoConstants && rotationZ.mode === ParticleCurveMode.TwoConstants : rotationZ.mode === ParticleCurveMode.TwoConstants) {
|
|
29212
29310
|
var constantMin = this._rotationMinConstant;
|
|
29213
|
-
constantMin.set(MathUtil
|
|
29311
|
+
constantMin.set(MathUtil.degreeToRadian(rotationX.constantMin), MathUtil.degreeToRadian(rotationY.constantMin), MathUtil.degreeToRadian(rotationZ.constantMin));
|
|
29214
29312
|
shaderData.setVector3(RotationOverLifetimeModule._minConstantProperty, constantMin);
|
|
29215
29313
|
isRandomTwoMacro = RotationOverLifetimeModule._isRandomTwoMacro;
|
|
29216
29314
|
}
|
|
@@ -30094,11 +30192,11 @@ __decorate([
|
|
|
30094
30192
|
// Start rotation
|
|
30095
30193
|
var startRotationRand = main._startRotationRand;
|
|
30096
30194
|
if (main.startRotation3D) {
|
|
30097
|
-
instanceVertices[offset + 15] = MathUtil
|
|
30098
|
-
instanceVertices[offset + 16] = MathUtil
|
|
30099
|
-
instanceVertices[offset + 17] = MathUtil
|
|
30195
|
+
instanceVertices[offset + 15] = MathUtil.degreeToRadian(main.startRotationX.evaluate(undefined, startRotationRand.random()));
|
|
30196
|
+
instanceVertices[offset + 16] = MathUtil.degreeToRadian(main.startRotationY.evaluate(undefined, startRotationRand.random()));
|
|
30197
|
+
instanceVertices[offset + 17] = MathUtil.degreeToRadian(main.startRotationZ.evaluate(undefined, startRotationRand.random()));
|
|
30100
30198
|
} else {
|
|
30101
|
-
instanceVertices[offset + 15] = MathUtil
|
|
30199
|
+
instanceVertices[offset + 15] = MathUtil.degreeToRadian(main.startRotationZ.evaluate(undefined, startRotationRand.random()));
|
|
30102
30200
|
}
|
|
30103
30201
|
// Start speed
|
|
30104
30202
|
instanceVertices[offset + 18] = startSpeed;
|
|
@@ -30261,7 +30359,7 @@ __decorate([
|
|
|
30261
30359
|
/** @internal */ ParticleGenerator._tempVector31 = new Vector3();
|
|
30262
30360
|
})();
|
|
30263
30361
|
(function() {
|
|
30264
|
-
/** @internal */ ParticleGenerator._tempColor0 = new Color
|
|
30362
|
+
/** @internal */ ParticleGenerator._tempColor0 = new Color();
|
|
30265
30363
|
})();
|
|
30266
30364
|
(function() {
|
|
30267
30365
|
/** @internal */ ParticleGenerator._tempParticleRenderers = new Array();
|
|
@@ -30341,7 +30439,7 @@ __decorate([
|
|
|
30341
30439
|
var _this;
|
|
30342
30440
|
_this = BaseMaterial1.call(this, engine, Shader.find("particle-shader")) || this;
|
|
30343
30441
|
var shaderData = _this.shaderData;
|
|
30344
|
-
shaderData.setColor(BaseMaterial._baseColorProp, new Color
|
|
30442
|
+
shaderData.setColor(BaseMaterial._baseColorProp, new Color(1, 1, 1, 1));
|
|
30345
30443
|
_this.isTransparent = true;
|
|
30346
30444
|
return _this;
|
|
30347
30445
|
}
|
|
@@ -30536,12 +30634,12 @@ __decorate([
|
|
|
30536
30634
|
switch(this.arcMode){
|
|
30537
30635
|
case ParticleShapeArcMode.Loop:
|
|
30538
30636
|
var normalizedEmitTime = emitTime * this.arcSpeed * (360 / this.arc) % 1;
|
|
30539
|
-
var radian = MathUtil
|
|
30637
|
+
var radian = MathUtil.degreeToRadian(this.arc * normalizedEmitTime);
|
|
30540
30638
|
positionPoint.set(Math.cos(radian), Math.sin(radian));
|
|
30541
30639
|
positionPoint.scale(rand.random());
|
|
30542
30640
|
break;
|
|
30543
30641
|
case ParticleShapeArcMode.Random:
|
|
30544
|
-
ShapeUtils.randomPointInsideUnitArcCircle(MathUtil
|
|
30642
|
+
ShapeUtils.randomPointInsideUnitArcCircle(MathUtil.degreeToRadian(this.arc), positionPoint, rand);
|
|
30545
30643
|
break;
|
|
30546
30644
|
}
|
|
30547
30645
|
position.set(positionPoint.x, positionPoint.y, 0);
|
|
@@ -30574,7 +30672,7 @@ __decorate([
|
|
|
30574
30672
|
* @internal
|
|
30575
30673
|
*/ _proto._generatePositionAndDirection = function _generatePositionAndDirection(rand, emitTime, position, direction) {
|
|
30576
30674
|
var unitPosition = ConeShape._tempVector20;
|
|
30577
|
-
var radian = MathUtil
|
|
30675
|
+
var radian = MathUtil.degreeToRadian(this.angle);
|
|
30578
30676
|
var dirSinA = Math.sin(radian);
|
|
30579
30677
|
var dirCosA = Math.cos(radian);
|
|
30580
30678
|
switch(this.emitType){
|