@galacean/engine 1.2.0-alpha.2 → 1.2.0-alpha.4
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/browser.js +606 -360
- package/dist/browser.min.js +1 -1
- package/dist/main.js +1 -1
- package/dist/miniprogram.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
package/dist/browser.js
CHANGED
|
@@ -8181,7 +8181,7 @@
|
|
|
8181
8181
|
pbr_frag: pbr_frag
|
|
8182
8182
|
};
|
|
8183
8183
|
var ShadowCoord = "#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}"; // eslint-disable-line
|
|
8184
|
-
var ShadowFragmentDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform
|
|
8184
|
+
var ShadowFragmentDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec4 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nfloat shadowFade=getShadowFade(v_pos);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);}return attenuation;}\n#endif\n"; // eslint-disable-line
|
|
8185
8185
|
var shadow_sample_tent = "#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}"; // eslint-disable-line
|
|
8186
8186
|
var ShadowVertexDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n"; // eslint-disable-line
|
|
8187
8187
|
var ShadowVertex = "#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"; // eslint-disable-line
|
|
@@ -23639,8 +23639,9 @@
|
|
|
23639
23639
|
}
|
|
23640
23640
|
return;
|
|
23641
23641
|
}
|
|
23642
|
+
++hierarchy;
|
|
23642
23643
|
for(var k1 in cacheMap){
|
|
23643
|
-
this._recursiveDestroy(
|
|
23644
|
+
this._recursiveDestroy(hierarchy, cacheMap[k1]);
|
|
23644
23645
|
}
|
|
23645
23646
|
};
|
|
23646
23647
|
_proto._resizeCacheMapHierarchy = function _resizeCacheMapHierarchy(cacheMap, hierarchy, currentHierarchy, increaseHierarchy) {
|
|
@@ -25649,6 +25650,10 @@
|
|
|
25649
25650
|
/** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
|
|
25650
25651
|
/** The splits of four cascade distribution. */ _this.shadowFourCascadeSplits = new Vector3(1.0 / 15, 3.0 / 15.0, 7.0 / 15.0);
|
|
25651
25652
|
/** Max Shadow distance. */ _this.shadowDistance = 50;
|
|
25653
|
+
/**
|
|
25654
|
+
* Last shadow fade distance in percentage, range [0,1].
|
|
25655
|
+
* @remarks Value 0 is used for no shadow fade.
|
|
25656
|
+
*/ _this.shadowFadeBorder = 0.1;
|
|
25652
25657
|
/* @internal */ _this._lightManager = new LightManager();
|
|
25653
25658
|
/* @internal */ _this._componentsManager = new ComponentsManager();
|
|
25654
25659
|
/** @internal */ _this._isActiveInEngine = false;
|
|
@@ -26270,47 +26275,65 @@
|
|
|
26270
26275
|
DepthTextureMode[DepthTextureMode[/* No depth texture. */ "None"] = 0] = "None";
|
|
26271
26276
|
DepthTextureMode[DepthTextureMode[/* Generate depth texture by pre-pass rendering. */ "PrePass"] = 1] = "PrePass";
|
|
26272
26277
|
})(exports.DepthTextureMode || (exports.DepthTextureMode = {}));
|
|
26273
|
-
var passNum = 0;
|
|
26274
26278
|
/**
|
|
26275
|
-
*
|
|
26276
|
-
*/ var
|
|
26277
|
-
|
|
26278
|
-
|
|
26279
|
-
|
|
26280
|
-
|
|
26281
|
-
|
|
26282
|
-
|
|
26283
|
-
this.name = name1;
|
|
26284
|
-
this.enabled = true;
|
|
26285
|
-
this.priority = priority;
|
|
26286
|
-
this.renderTarget = renderTarget;
|
|
26287
|
-
this.replaceMaterial = replaceMaterial;
|
|
26288
|
-
this.mask = mask || exports.Layer.Everything;
|
|
26289
|
-
this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
|
|
26290
|
-
};
|
|
26291
|
-
var _proto = RenderPass.prototype;
|
|
26292
|
-
/**
|
|
26293
|
-
* Rendering callback, will be executed if renderOverride is set to true.
|
|
26294
|
-
* @param camera - Camera
|
|
26295
|
-
* @param opaqueQueue - Opaque queue
|
|
26296
|
-
* @param alphaTestQueue - Alpha test queue
|
|
26297
|
-
* @param transparentQueue - Transparent queue
|
|
26298
|
-
*/ _proto.render = function render(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
26279
|
+
* PipelinePass is a base class for all pipeline passes.
|
|
26280
|
+
*/ var PipelinePass = function PipelinePass(engine) {
|
|
26281
|
+
this._engine = engine;
|
|
26282
|
+
};
|
|
26283
|
+
/**
|
|
26284
|
+
* @internal
|
|
26285
|
+
*/ var PipelineUtils = /*#__PURE__*/ function() {
|
|
26286
|
+
var PipelineUtils = function PipelineUtils() {};
|
|
26299
26287
|
/**
|
|
26300
|
-
*
|
|
26301
|
-
* @param
|
|
26302
|
-
* @param
|
|
26303
|
-
* @param
|
|
26304
|
-
* @param
|
|
26305
|
-
|
|
26288
|
+
* Recreate texture if needed.
|
|
26289
|
+
* @param engine - Engine
|
|
26290
|
+
* @param currentTexture - Current texture
|
|
26291
|
+
* @param width - Need texture width
|
|
26292
|
+
* @param height - Need texture height
|
|
26293
|
+
* @param format - Need texture format
|
|
26294
|
+
* @param mipmap - Need texture mipmap
|
|
26295
|
+
* @returns Texture
|
|
26296
|
+
*/ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
|
|
26297
|
+
if (currentTexture) {
|
|
26298
|
+
if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
|
|
26299
|
+
currentTexture.destroy();
|
|
26300
|
+
var texture = new Texture2D(engine, width, height, format, mipmap);
|
|
26301
|
+
texture.isGCIgnored = true;
|
|
26302
|
+
return texture;
|
|
26303
|
+
} else {
|
|
26304
|
+
return currentTexture;
|
|
26305
|
+
}
|
|
26306
|
+
} else {
|
|
26307
|
+
var texture1 = new Texture2D(engine, width, height, format, mipmap);
|
|
26308
|
+
texture1.isGCIgnored = true;
|
|
26309
|
+
return texture1;
|
|
26310
|
+
}
|
|
26311
|
+
};
|
|
26306
26312
|
/**
|
|
26307
|
-
*
|
|
26308
|
-
* @param
|
|
26309
|
-
* @param
|
|
26310
|
-
* @param
|
|
26311
|
-
* @param
|
|
26312
|
-
|
|
26313
|
-
|
|
26313
|
+
* Recreate render target if needed.
|
|
26314
|
+
* @param engine - Engine
|
|
26315
|
+
* @param currentRenderTarget - Current render target
|
|
26316
|
+
* @param width - Need render target width
|
|
26317
|
+
* @param height - Need render target height
|
|
26318
|
+
* @param colorFormat - Need render target color format
|
|
26319
|
+
* @param depthFormat - Need render target depth format
|
|
26320
|
+
* @param mipmap - Need render target mipmap
|
|
26321
|
+
* @returns Render target
|
|
26322
|
+
*/ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, mipmap) {
|
|
26323
|
+
var _currentRenderTarget, _currentRenderTarget1;
|
|
26324
|
+
var currentColorTexture = (_currentRenderTarget = currentRenderTarget) == null ? void 0 : _currentRenderTarget.getColorTexture(0);
|
|
26325
|
+
var currentDepthTexture = (_currentRenderTarget1 = currentRenderTarget) == null ? void 0 : _currentRenderTarget1.depthTexture;
|
|
26326
|
+
var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap) : null;
|
|
26327
|
+
var depthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
|
|
26328
|
+
if (currentColorTexture !== colorTexture || currentDepthTexture !== depthTexture) {
|
|
26329
|
+
var _currentRenderTarget2;
|
|
26330
|
+
(_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy();
|
|
26331
|
+
currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthTexture);
|
|
26332
|
+
currentRenderTarget.isGCIgnored = true;
|
|
26333
|
+
}
|
|
26334
|
+
return currentRenderTarget;
|
|
26335
|
+
};
|
|
26336
|
+
return PipelineUtils;
|
|
26314
26337
|
}();
|
|
26315
26338
|
/**
|
|
26316
26339
|
* @internal
|
|
@@ -26614,60 +26637,47 @@
|
|
|
26614
26637
|
};
|
|
26615
26638
|
return RenderQueue;
|
|
26616
26639
|
}();
|
|
26640
|
+
var passNum = 0;
|
|
26617
26641
|
/**
|
|
26618
|
-
*
|
|
26619
|
-
*/ var
|
|
26620
|
-
var
|
|
26621
|
-
|
|
26622
|
-
|
|
26623
|
-
|
|
26624
|
-
|
|
26625
|
-
|
|
26626
|
-
|
|
26627
|
-
|
|
26628
|
-
|
|
26629
|
-
|
|
26630
|
-
|
|
26631
|
-
|
|
26632
|
-
|
|
26633
|
-
currentTexture.destroy();
|
|
26634
|
-
var texture = new Texture2D(engine, width, height, format, mipmap);
|
|
26635
|
-
texture.isGCIgnored = true;
|
|
26636
|
-
return texture;
|
|
26637
|
-
} else {
|
|
26638
|
-
return currentTexture;
|
|
26639
|
-
}
|
|
26640
|
-
} else {
|
|
26641
|
-
var texture1 = new Texture2D(engine, width, height, format, mipmap);
|
|
26642
|
-
texture1.isGCIgnored = true;
|
|
26643
|
-
return texture1;
|
|
26644
|
-
}
|
|
26642
|
+
* RenderPass.
|
|
26643
|
+
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
26644
|
+
var RenderPass = function RenderPass(name1, priority, renderTarget, replaceMaterial, mask) {
|
|
26645
|
+
if (name1 === void 0) name1 = "RENDER_PASS" + passNum++;
|
|
26646
|
+
if (priority === void 0) priority = 0;
|
|
26647
|
+
if (renderTarget === void 0) renderTarget = null;
|
|
26648
|
+
if (replaceMaterial === void 0) replaceMaterial = null;
|
|
26649
|
+
if (mask === void 0) mask = null;
|
|
26650
|
+
this.name = name1;
|
|
26651
|
+
this.enabled = true;
|
|
26652
|
+
this.priority = priority;
|
|
26653
|
+
this.renderTarget = renderTarget;
|
|
26654
|
+
this.replaceMaterial = replaceMaterial;
|
|
26655
|
+
this.mask = mask || exports.Layer.Everything;
|
|
26656
|
+
this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
|
|
26645
26657
|
};
|
|
26658
|
+
var _proto = RenderPass.prototype;
|
|
26646
26659
|
/**
|
|
26647
|
-
*
|
|
26648
|
-
* @param
|
|
26649
|
-
* @param
|
|
26650
|
-
* @param
|
|
26651
|
-
* @param
|
|
26652
|
-
|
|
26653
|
-
|
|
26654
|
-
*
|
|
26655
|
-
* @
|
|
26656
|
-
|
|
26657
|
-
|
|
26658
|
-
|
|
26659
|
-
|
|
26660
|
-
|
|
26661
|
-
|
|
26662
|
-
|
|
26663
|
-
|
|
26664
|
-
|
|
26665
|
-
|
|
26666
|
-
|
|
26667
|
-
|
|
26668
|
-
return currentRenderTarget;
|
|
26669
|
-
};
|
|
26670
|
-
return PipelineUtils;
|
|
26660
|
+
* Rendering callback, will be executed if renderOverride is set to true.
|
|
26661
|
+
* @param camera - Camera
|
|
26662
|
+
* @param opaqueQueue - Opaque queue
|
|
26663
|
+
* @param alphaTestQueue - Alpha test queue
|
|
26664
|
+
* @param transparentQueue - Transparent queue
|
|
26665
|
+
*/ _proto.render = function render(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
26666
|
+
/**
|
|
26667
|
+
* Post rendering callback.
|
|
26668
|
+
* @param camera - Camera
|
|
26669
|
+
* @param opaqueQueue - Opaque queue
|
|
26670
|
+
* @param alphaTestQueue - Alpha test queue
|
|
26671
|
+
* @param transparentQueue - Transparent queue
|
|
26672
|
+
*/ _proto.preRender = function preRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
26673
|
+
/**
|
|
26674
|
+
* Post rendering callback.
|
|
26675
|
+
* @param camera - Camera
|
|
26676
|
+
* @param opaqueQueue - Opaque queue
|
|
26677
|
+
* @param alphaTestQueue - Alpha test queue
|
|
26678
|
+
* @param transparentQueue - Transparent queue
|
|
26679
|
+
*/ _proto.postRender = function postRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
26680
|
+
return RenderPass;
|
|
26671
26681
|
}();
|
|
26672
26682
|
/**
|
|
26673
26683
|
* @internal
|
|
@@ -26932,6 +26942,26 @@
|
|
|
26932
26942
|
var offset = cascadeIndex * 16;
|
|
26933
26943
|
Utils._floatMatrixMultiply(sliceMatrix, outShadowMatrices, offset, outShadowMatrices, offset);
|
|
26934
26944
|
};
|
|
26945
|
+
/**
|
|
26946
|
+
* Extract scale and bias from a fade distance to achieve a linear fading of the fade distance.
|
|
26947
|
+
*/ ShadowUtils.getScaleAndBiasForLinearDistanceFade = function getScaleAndBiasForLinearDistanceFade(fadeDistance, border, outInfo) {
|
|
26948
|
+
// (P^2-N^2)/(F^2-N^2)
|
|
26949
|
+
// To avoid division from zero
|
|
26950
|
+
// This values ensure that fade within cascade will be 0 and outside 1
|
|
26951
|
+
if (border < 0.0001) {
|
|
26952
|
+
var multiplier = 1000; // To avoid blending if difference is in fractions
|
|
26953
|
+
outInfo.z = multiplier;
|
|
26954
|
+
outInfo.w = -fadeDistance * multiplier;
|
|
26955
|
+
return;
|
|
26956
|
+
}
|
|
26957
|
+
border = 1 - border;
|
|
26958
|
+
border *= border;
|
|
26959
|
+
// Fade with distance calculation is just a linear fade from 90% of fade distance to fade distance. 90% arbitrarily chosen but should work well enough.
|
|
26960
|
+
var distanceFadeNear = border * fadeDistance;
|
|
26961
|
+
var fadeRange = fadeDistance - distanceFadeNear;
|
|
26962
|
+
outInfo.z = 1.0 / fadeRange;
|
|
26963
|
+
outInfo.w = -distanceFadeNear / fadeRange;
|
|
26964
|
+
};
|
|
26935
26965
|
return ShadowUtils;
|
|
26936
26966
|
}();
|
|
26937
26967
|
(function() {
|
|
@@ -27175,11 +27205,6 @@
|
|
|
27175
27205
|
//now max shadow sample tent is 5x5, atlas borderSize at least 3=ceil(2.5),and +1 pixel is for global border for no cascade mode.
|
|
27176
27206
|
ShadowUtils.atlasBorderSize = 4.0;
|
|
27177
27207
|
})();
|
|
27178
|
-
/**
|
|
27179
|
-
* PipelinePass is a base class for all pipeline passes.
|
|
27180
|
-
*/ var PipelinePass = function PipelinePass(engine) {
|
|
27181
|
-
this._engine = engine;
|
|
27182
|
-
};
|
|
27183
27208
|
/**
|
|
27184
27209
|
* Cascade shadow caster pass.
|
|
27185
27210
|
*/ var CascadedShadowCasterPass = /*#__PURE__*/ function(PipelinePass1) {
|
|
@@ -27192,11 +27217,10 @@
|
|
|
27192
27217
|
_this._shadowSliceData = new ShadowSliceData();
|
|
27193
27218
|
_this._lightUp = new Vector3();
|
|
27194
27219
|
_this._lightSide = new Vector3();
|
|
27195
|
-
_this._existShadowMap = false;
|
|
27196
27220
|
_this._splitBoundSpheres = new Float32Array(CascadedShadowCasterPass._maxCascades * 4);
|
|
27197
27221
|
/** The end is project precision problem in shader. */ _this._shadowMatrices = new Float32Array((CascadedShadowCasterPass._maxCascades + 1) * 16);
|
|
27198
|
-
//
|
|
27199
|
-
_this._shadowInfos = new
|
|
27222
|
+
// intensity, null, fadeScale, fadeBias
|
|
27223
|
+
_this._shadowInfos = new Vector4();
|
|
27200
27224
|
_this._viewportOffsets = [
|
|
27201
27225
|
new Vector2(),
|
|
27202
27226
|
new Vector2(),
|
|
@@ -27212,14 +27236,12 @@
|
|
|
27212
27236
|
/**
|
|
27213
27237
|
* @internal
|
|
27214
27238
|
*/ _proto.onRender = function onRender(context) {
|
|
27239
|
+
var light = this._camera.scene._lightManager._sunlight;
|
|
27215
27240
|
this._updateShadowSettings();
|
|
27216
|
-
this.
|
|
27217
|
-
this.
|
|
27218
|
-
if (this._existShadowMap) {
|
|
27219
|
-
this._updateReceiversShaderData();
|
|
27220
|
-
}
|
|
27241
|
+
this._renderDirectShadowMap(context, light);
|
|
27242
|
+
this._updateReceiversShaderData(light);
|
|
27221
27243
|
};
|
|
27222
|
-
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context) {
|
|
27244
|
+
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context, light) {
|
|
27223
27245
|
var _this = this, engine = _this._engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
|
|
27224
27246
|
var _camera__renderPipeline__cullingResults = camera._renderPipeline._cullingResults, opaqueQueue = _camera__renderPipeline__cullingResults.opaqueQueue, alphaTestQueue = _camera__renderPipeline__cullingResults.alphaTestQueue, transparentQueue = _camera__renderPipeline__cullingResults.transparentQueue;
|
|
27225
27247
|
var scene = camera.scene;
|
|
@@ -27233,91 +27255,87 @@
|
|
|
27233
27255
|
var lightUp = this._lightUp;
|
|
27234
27256
|
var lightSide = this._lightSide;
|
|
27235
27257
|
var lightForward = shadowSliceData.virtualCamera.forward;
|
|
27236
|
-
|
|
27237
|
-
|
|
27238
|
-
|
|
27239
|
-
|
|
27240
|
-
|
|
27241
|
-
|
|
27242
|
-
|
|
27243
|
-
|
|
27244
|
-
|
|
27245
|
-
|
|
27246
|
-
|
|
27247
|
-
|
|
27248
|
-
|
|
27249
|
-
|
|
27250
|
-
|
|
27251
|
-
|
|
27252
|
-
|
|
27253
|
-
|
|
27254
|
-
|
|
27255
|
-
|
|
27256
|
-
|
|
27257
|
-
|
|
27258
|
-
|
|
27259
|
-
rhi.
|
|
27260
|
-
|
|
27261
|
-
|
|
27262
|
-
|
|
27263
|
-
|
|
27264
|
-
|
|
27265
|
-
|
|
27266
|
-
|
|
27267
|
-
|
|
27268
|
-
|
|
27269
|
-
|
|
27270
|
-
|
|
27271
|
-
|
|
27272
|
-
|
|
27273
|
-
|
|
27274
|
-
|
|
27275
|
-
|
|
27276
|
-
|
|
27277
|
-
|
|
27278
|
-
|
|
27279
|
-
|
|
27280
|
-
|
|
27281
|
-
|
|
27282
|
-
|
|
27283
|
-
|
|
27284
|
-
|
|
27285
|
-
|
|
27286
|
-
|
|
27287
|
-
|
|
27288
|
-
|
|
27289
|
-
|
|
27290
|
-
|
|
27291
|
-
|
|
27292
|
-
|
|
27293
|
-
|
|
27294
|
-
|
|
27295
|
-
|
|
27296
|
-
|
|
27297
|
-
|
|
27298
|
-
|
|
27299
|
-
|
|
27300
|
-
|
|
27301
|
-
|
|
27302
|
-
|
|
27303
|
-
|
|
27304
|
-
|
|
27305
|
-
|
|
27306
|
-
|
|
27307
|
-
|
|
27308
|
-
|
|
27309
|
-
|
|
27310
|
-
|
|
27311
|
-
}
|
|
27312
|
-
}
|
|
27313
|
-
this._existShadowMap = true;
|
|
27314
|
-
}
|
|
27315
|
-
};
|
|
27316
|
-
_proto._updateReceiversShaderData = function _updateReceiversShaderData() {
|
|
27317
|
-
var scene = this._camera.scene;
|
|
27258
|
+
// Prepare render target
|
|
27259
|
+
var _this__shadowMapSize = this._shadowMapSize, width = _this__shadowMapSize.z, height = _this__shadowMapSize.w;
|
|
27260
|
+
var format = this._shadowMapFormat;
|
|
27261
|
+
var renderTarget;
|
|
27262
|
+
var shadowTexture;
|
|
27263
|
+
if (this._supportDepthTexture) {
|
|
27264
|
+
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, false);
|
|
27265
|
+
shadowTexture = renderTarget.depthTexture;
|
|
27266
|
+
} else {
|
|
27267
|
+
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false);
|
|
27268
|
+
shadowTexture = renderTarget.getColorTexture(0);
|
|
27269
|
+
}
|
|
27270
|
+
shadowTexture.wrapModeU = shadowTexture.wrapModeV = exports.TextureWrapMode.Clamp;
|
|
27271
|
+
if (engine._hardwareRenderer._isWebGL2) {
|
|
27272
|
+
shadowTexture.depthCompareFunction = exports.TextureDepthCompareFunction.Less;
|
|
27273
|
+
}
|
|
27274
|
+
this._renderTarget = renderTarget;
|
|
27275
|
+
this._depthTexture = shadowTexture;
|
|
27276
|
+
// @todo: shouldn't set viewport and scissor in activeRenderTarget
|
|
27277
|
+
rhi.activeRenderTarget(renderTarget, CascadedShadowCasterPass._viewport, 0);
|
|
27278
|
+
if (this._supportDepthTexture) {
|
|
27279
|
+
rhi.clearRenderTarget(engine, exports.CameraClearFlags.Depth, null);
|
|
27280
|
+
} else {
|
|
27281
|
+
rhi.clearRenderTarget(engine, exports.CameraClearFlags.All, CascadedShadowCasterPass._clearColor);
|
|
27282
|
+
}
|
|
27283
|
+
// prepare light and camera direction
|
|
27284
|
+
Matrix.rotationQuaternion(light.entity.transform.worldRotationQuaternion, lightWorld);
|
|
27285
|
+
lightSide.set(lightWorldE[0], lightWorldE[1], lightWorldE[2]);
|
|
27286
|
+
lightUp.set(lightWorldE[4], lightWorldE[5], lightWorldE[6]);
|
|
27287
|
+
lightForward.set(-lightWorldE[8], -lightWorldE[9], -lightWorldE[10]);
|
|
27288
|
+
var cameraForward = CascadedShadowCasterPass._tempVector;
|
|
27289
|
+
cameraForward.copyFrom(camera.entity.transform.worldForward);
|
|
27290
|
+
var shadowTileResolution = this._shadowTileResolution;
|
|
27291
|
+
for(var j = 0; j < shadowCascades; j++){
|
|
27292
|
+
ShadowUtils.getBoundSphereByFrustum(splitDistance[j], splitDistance[j + 1], camera, cameraForward, shadowSliceData);
|
|
27293
|
+
ShadowUtils.getDirectionLightShadowCullPlanes(camera._frustum, splitDistance[j], camera.nearClipPlane, lightForward, shadowSliceData);
|
|
27294
|
+
ShadowUtils.getDirectionalLightMatrices(lightUp, lightSide, lightForward, j, light.shadowNearPlane, shadowTileResolution, shadowSliceData, shadowMatrices);
|
|
27295
|
+
if (shadowCascades > 1) {
|
|
27296
|
+
ShadowUtils.applySliceTransform(shadowTileResolution, width, height, j, this._viewportOffsets[j], shadowMatrices);
|
|
27297
|
+
}
|
|
27298
|
+
this._updateSingleShadowCasterShaderData(light, shadowSliceData, context);
|
|
27299
|
+
// upload pre-cascade infos.
|
|
27300
|
+
var center = boundSphere.center;
|
|
27301
|
+
var radius = boundSphere.radius;
|
|
27302
|
+
var offset = j * 4;
|
|
27303
|
+
splitBoundSpheres[offset] = center.x;
|
|
27304
|
+
splitBoundSpheres[offset + 1] = center.y;
|
|
27305
|
+
splitBoundSpheres[offset + 2] = center.z;
|
|
27306
|
+
splitBoundSpheres[offset + 3] = radius * radius;
|
|
27307
|
+
opaqueQueue.clear();
|
|
27308
|
+
alphaTestQueue.clear();
|
|
27309
|
+
transparentQueue.clear();
|
|
27310
|
+
var renderers = componentsManager._renderers;
|
|
27311
|
+
var elements = renderers._elements;
|
|
27312
|
+
for(var k = renderers.length - 1; k >= 0; --k){
|
|
27313
|
+
ShadowUtils.shadowCullFrustum(context, light, elements[k], shadowSliceData);
|
|
27314
|
+
}
|
|
27315
|
+
if (opaqueQueue.elements.length || alphaTestQueue.elements.length) {
|
|
27316
|
+
opaqueQueue.sort(RenderQueue._compareFromNearToFar);
|
|
27317
|
+
alphaTestQueue.sort(RenderQueue._compareFromNearToFar);
|
|
27318
|
+
var _viewports_j = viewports[j], x = _viewports_j.x, y = _viewports_j.y;
|
|
27319
|
+
rhi.setGlobalDepthBias(1.0, 1.0);
|
|
27320
|
+
rhi.viewport(x, y, shadowTileResolution, shadowTileResolution);
|
|
27321
|
+
// for no cascade is for the edge,for cascade is for the beyond maxCascade pixel can use (0,0,0) trick sample the shadowMap
|
|
27322
|
+
rhi.scissor(x + 1, y + 1, shadowTileResolution - 2, shadowTileResolution - 2);
|
|
27323
|
+
engine._renderCount++;
|
|
27324
|
+
opaqueQueue.render(camera, exports.Layer.Everything, exports.PipelineStage.ShadowCaster);
|
|
27325
|
+
alphaTestQueue.render(camera, exports.Layer.Everything, exports.PipelineStage.ShadowCaster);
|
|
27326
|
+
rhi.setGlobalDepthBias(0, 0);
|
|
27327
|
+
}
|
|
27328
|
+
}
|
|
27329
|
+
};
|
|
27330
|
+
_proto._updateReceiversShaderData = function _updateReceiversShaderData(light) {
|
|
27331
|
+
var camera = this._camera;
|
|
27332
|
+
var scene = camera.scene;
|
|
27318
27333
|
var splitBoundSpheres = this._splitBoundSpheres;
|
|
27319
27334
|
var shadowMatrices = this._shadowMatrices;
|
|
27320
27335
|
var shadowCascades = scene.shadowCascades;
|
|
27336
|
+
var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
|
|
27337
|
+
ShadowUtils.getScaleAndBiasForLinearDistanceFade(Math.pow(shadowFar, 2), scene.shadowFadeBorder, this._shadowInfos);
|
|
27338
|
+
this._shadowInfos.x = light.shadowStrength;
|
|
27321
27339
|
// set zero matrix to project the index out of max cascade
|
|
27322
27340
|
if (shadowCascades > 1) {
|
|
27323
27341
|
for(var i = shadowCascades * 4, n = splitBoundSpheres.length; i < n; i++){
|
|
@@ -27330,7 +27348,7 @@
|
|
|
27330
27348
|
}
|
|
27331
27349
|
var shaderData = scene.shaderData;
|
|
27332
27350
|
shaderData.setFloatArray(CascadedShadowCasterPass._shadowMatricesProperty, this._shadowMatrices);
|
|
27333
|
-
shaderData.
|
|
27351
|
+
shaderData.setVector4(CascadedShadowCasterPass._shadowInfosProperty, this._shadowInfos);
|
|
27334
27352
|
shaderData.setTexture(CascadedShadowCasterPass._shadowMapsProperty, this._depthTexture);
|
|
27335
27353
|
shaderData.setFloatArray(CascadedShadowCasterPass._shadowSplitSpheresProperty, this._splitBoundSpheres);
|
|
27336
27354
|
shaderData.setVector4(CascadedShadowCasterPass._shadowMapSize, this._shadowMapSize);
|
|
@@ -27366,10 +27384,13 @@
|
|
|
27366
27384
|
return Math.sqrt(radius * radius / denominator);
|
|
27367
27385
|
};
|
|
27368
27386
|
_proto._updateShadowSettings = function _updateShadowSettings() {
|
|
27369
|
-
var
|
|
27387
|
+
var camera = this._camera;
|
|
27388
|
+
var scene = camera.scene;
|
|
27370
27389
|
var shadowFormat = ShadowUtils.shadowDepthFormat(scene.shadowResolution, this._supportDepthTexture);
|
|
27371
27390
|
var shadowResolution = ShadowUtils.shadowResolution(scene.shadowResolution);
|
|
27372
27391
|
var shadowCascades = scene.shadowCascades;
|
|
27392
|
+
var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
|
|
27393
|
+
this._getCascadesSplitDistance(shadowFar);
|
|
27373
27394
|
if (shadowFormat !== this._shadowMapFormat || shadowResolution !== this._shadowMapResolution || shadowCascades !== this._shadowCascadeMode) {
|
|
27374
27395
|
this._shadowMapFormat = shadowFormat;
|
|
27375
27396
|
this._shadowMapResolution = shadowResolution;
|
|
@@ -28542,6 +28563,7 @@
|
|
|
28542
28563
|
* @param obj - class object
|
|
28543
28564
|
*/ Loader.registerClass = function registerClass(className, classDefine) {
|
|
28544
28565
|
this._engineObjects[className] = classDefine;
|
|
28566
|
+
this._classNameMap.set(classDefine, className);
|
|
28545
28567
|
};
|
|
28546
28568
|
/**
|
|
28547
28569
|
* Get the class object by class name.
|
|
@@ -28550,11 +28572,21 @@
|
|
|
28550
28572
|
*/ Loader.getClass = function getClass(className) {
|
|
28551
28573
|
return this._engineObjects[className];
|
|
28552
28574
|
};
|
|
28575
|
+
/**
|
|
28576
|
+
* Get the class name by class object.
|
|
28577
|
+
* @param obj - class object
|
|
28578
|
+
* @returns class name
|
|
28579
|
+
*/ Loader.getClassName = function getClassName(obj) {
|
|
28580
|
+
return this._classNameMap.get(obj);
|
|
28581
|
+
};
|
|
28553
28582
|
return Loader;
|
|
28554
28583
|
}();
|
|
28555
28584
|
(function() {
|
|
28556
28585
|
Loader._engineObjects = {};
|
|
28557
28586
|
})();
|
|
28587
|
+
(function() {
|
|
28588
|
+
Loader._classNameMap = new Map();
|
|
28589
|
+
})();
|
|
28558
28590
|
/**
|
|
28559
28591
|
* Alpha blend mode.
|
|
28560
28592
|
*/ exports.BlendMode = void 0;
|
|
@@ -32275,7 +32307,7 @@
|
|
|
32275
32307
|
this._clip = clip;
|
|
32276
32308
|
this._clipEndTime = Math.min(this._clipEndTime, 1);
|
|
32277
32309
|
this._onClipChanged();
|
|
32278
|
-
clip._updateFlagManager.addListener(this._onClipChanged);
|
|
32310
|
+
clip && clip._updateFlagManager.addListener(this._onClipChanged);
|
|
32279
32311
|
}
|
|
32280
32312
|
},
|
|
32281
32313
|
{
|
|
@@ -32964,6 +32996,7 @@
|
|
|
32964
32996
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["RotationOverLifetime"] = 0x40eb95e4] = "RotationOverLifetime";
|
|
32965
32997
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["TextureSheetAnimation"] = 0xbc524e5] = "TextureSheetAnimation";
|
|
32966
32998
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["Shape"] = 0xaf502044] = "Shape";
|
|
32999
|
+
ParticleRandomSubSeeds[ParticleRandomSubSeeds["GravityModifier"] = 0xa47b8c4d] = "GravityModifier";
|
|
32967
33000
|
})(ParticleRandomSubSeeds || (ParticleRandomSubSeeds = {}));
|
|
32968
33001
|
/**
|
|
32969
33002
|
* Particle gradient.
|
|
@@ -33669,6 +33702,7 @@
|
|
|
33669
33702
|
/** @internal */ this._startColorRand = new Rand(0, ParticleRandomSubSeeds.StartColor);
|
|
33670
33703
|
/** @internal */ this._startSizeRand = new Rand(0, ParticleRandomSubSeeds.StartSize);
|
|
33671
33704
|
/** @internal */ this._startRotationRand = new Rand(0, ParticleRandomSubSeeds.StartRotation);
|
|
33705
|
+
this._gravityModifierRand = new Rand(0, ParticleRandomSubSeeds.GravityModifier);
|
|
33672
33706
|
this._gravity = new Vector3();
|
|
33673
33707
|
this._generator = generator;
|
|
33674
33708
|
};
|
|
@@ -33729,7 +33763,7 @@
|
|
|
33729
33763
|
break;
|
|
33730
33764
|
}
|
|
33731
33765
|
var particleGravity = this._gravity;
|
|
33732
|
-
var gravityModifierValue = this.gravityModifier.evaluate(undefined,
|
|
33766
|
+
var gravityModifierValue = this.gravityModifier.evaluate(undefined, this._gravityModifierRand.random());
|
|
33733
33767
|
Vector3.scale(renderer.scene.physics.gravity, gravityModifierValue, particleGravity);
|
|
33734
33768
|
shaderData.setVector3(MainModule._gravity, particleGravity);
|
|
33735
33769
|
shaderData.setInt(MainModule._simulationSpace, this.simulationSpace);
|
|
@@ -33848,6 +33882,9 @@
|
|
|
33848
33882
|
__decorate$1([
|
|
33849
33883
|
ignoreClone
|
|
33850
33884
|
], MainModule.prototype, "_startRotationRand", void 0);
|
|
33885
|
+
__decorate$1([
|
|
33886
|
+
ignoreClone
|
|
33887
|
+
], MainModule.prototype, "_gravityModifierRand", void 0);
|
|
33851
33888
|
__decorate$1([
|
|
33852
33889
|
ignoreClone
|
|
33853
33890
|
], MainModule.prototype, "_generator", void 0);
|
|
@@ -35151,22 +35188,22 @@
|
|
|
35151
35188
|
}();
|
|
35152
35189
|
/**
|
|
35153
35190
|
* The emission shape.
|
|
35154
|
-
*/
|
|
35191
|
+
*/ exports.ParticleShapeType = void 0;
|
|
35155
35192
|
(function(ParticleShapeType) {
|
|
35156
35193
|
ParticleShapeType[ParticleShapeType[/** Emit from the volume of a box. */ "Box"] = 0] = "Box";
|
|
35157
35194
|
ParticleShapeType[ParticleShapeType[/** Emit from a circle. */ "Circle"] = 1] = "Circle";
|
|
35158
35195
|
ParticleShapeType[ParticleShapeType[/** Emit from the base of a cone. */ "Cone"] = 2] = "Cone";
|
|
35159
35196
|
ParticleShapeType[ParticleShapeType[/** Emit from a half-sphere. */ "Hemisphere"] = 3] = "Hemisphere";
|
|
35160
35197
|
ParticleShapeType[ParticleShapeType[/** Emit from a sphere. */ "Sphere"] = 4] = "Sphere";
|
|
35161
|
-
})(ParticleShapeType || (ParticleShapeType = {}));
|
|
35198
|
+
})(exports.ParticleShapeType || (exports.ParticleShapeType = {}));
|
|
35162
35199
|
/**
|
|
35163
35200
|
* Particle shape that emits particles from a box.
|
|
35164
35201
|
*/ var BoxShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35165
35202
|
var BoxShape = function BoxShape() {
|
|
35166
35203
|
var _this;
|
|
35167
|
-
_this = BaseShape1.
|
|
35204
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35205
|
+
_this.shapeType = exports.ParticleShapeType.Box;
|
|
35168
35206
|
/** The size of the box. */ _this.size = new Vector3(1, 1, 1);
|
|
35169
|
-
_this.shapeType = ParticleShapeType.Box;
|
|
35170
35207
|
return _this;
|
|
35171
35208
|
};
|
|
35172
35209
|
_inherits$2(BoxShape, BaseShape1);
|
|
@@ -35201,12 +35238,12 @@
|
|
|
35201
35238
|
*/ var CircleShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35202
35239
|
var CircleShape = function CircleShape() {
|
|
35203
35240
|
var _this;
|
|
35204
|
-
_this = BaseShape1.
|
|
35241
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35242
|
+
_this.shapeType = exports.ParticleShapeType.Circle;
|
|
35205
35243
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35206
35244
|
/** Angle of the circle arc to emit particles from. */ _this.arc = 360.0;
|
|
35207
35245
|
/** The mode to generate particles around the arc. */ _this.arcMode = exports.ParticleShapeArcMode.Random;
|
|
35208
35246
|
/** The speed of complete 360 degree rotation. */ _this.arcSpeed = 1.0;
|
|
35209
|
-
_this.shapeType = ParticleShapeType.Circle;
|
|
35210
35247
|
return _this;
|
|
35211
35248
|
};
|
|
35212
35249
|
_inherits$2(CircleShape, BaseShape1);
|
|
@@ -35241,12 +35278,12 @@
|
|
|
35241
35278
|
*/ var ConeShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35242
35279
|
var ConeShape = function ConeShape() {
|
|
35243
35280
|
var _this;
|
|
35244
|
-
_this = BaseShape1.
|
|
35281
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35282
|
+
_this.shapeType = exports.ParticleShapeType.Cone;
|
|
35245
35283
|
/** Angle of the cone to emit particles from. */ _this.angle = 25.0;
|
|
35246
35284
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35247
35285
|
/** Length of the cone to emit particles from. */ _this.length = 5.0;
|
|
35248
35286
|
/** Cone emitter type. */ _this.emitType = /** Emit particles from the base of the cone. */ 0;
|
|
35249
|
-
_this.shapeType = ParticleShapeType.Cone;
|
|
35250
35287
|
return _this;
|
|
35251
35288
|
};
|
|
35252
35289
|
_inherits$2(ConeShape, BaseShape1);
|
|
@@ -35305,9 +35342,9 @@
|
|
|
35305
35342
|
*/ var HemisphereShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35306
35343
|
var HemisphereShape = function HemisphereShape() {
|
|
35307
35344
|
var _this;
|
|
35308
|
-
_this = BaseShape1.
|
|
35345
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35346
|
+
_this.shapeType = exports.ParticleShapeType.Hemisphere;
|
|
35309
35347
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35310
|
-
_this.shapeType = ParticleShapeType.Hemisphere;
|
|
35311
35348
|
return _this;
|
|
35312
35349
|
};
|
|
35313
35350
|
_inherits$2(HemisphereShape, BaseShape1);
|
|
@@ -35329,9 +35366,9 @@
|
|
|
35329
35366
|
*/ var SphereShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35330
35367
|
var SphereShape = function SphereShape() {
|
|
35331
35368
|
var _this;
|
|
35332
|
-
_this = BaseShape1.
|
|
35369
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35370
|
+
_this.shapeType = exports.ParticleShapeType.Sphere;
|
|
35333
35371
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35334
|
-
_this.shapeType = ParticleShapeType.Sphere;
|
|
35335
35372
|
return _this;
|
|
35336
35373
|
};
|
|
35337
35374
|
_inherits$2(SphereShape, BaseShape1);
|
|
@@ -35835,6 +35872,7 @@
|
|
|
35835
35872
|
ParticleRenderer: ParticleRenderer,
|
|
35836
35873
|
get ParticleScaleMode () { return exports.ParticleScaleMode; },
|
|
35837
35874
|
get ParticleShapeArcMode () { return exports.ParticleShapeArcMode; },
|
|
35875
|
+
get ParticleShapeType () { return exports.ParticleShapeType; },
|
|
35838
35876
|
get ParticleSimulationSpace () { return exports.ParticleSimulationSpace; },
|
|
35839
35877
|
get ParticleStopMode () { return exports.ParticleStopMode; },
|
|
35840
35878
|
PhysicsMaterial: PhysicsMaterial,
|
|
@@ -38626,8 +38664,7 @@
|
|
|
38626
38664
|
var assetRefId = entityConfig.assetRefId;
|
|
38627
38665
|
var engine = this._context.engine;
|
|
38628
38666
|
if (assetRefId) {
|
|
38629
|
-
return engine.resourceManager
|
|
38630
|
-
.getResourceByRef({
|
|
38667
|
+
return engine.resourceManager.getResourceByRef({
|
|
38631
38668
|
refId: assetRefId,
|
|
38632
38669
|
key: entityConfig.key,
|
|
38633
38670
|
isClone: entityConfig.isClone
|
|
@@ -38657,36 +38694,355 @@
|
|
|
38657
38694
|
(function() {
|
|
38658
38695
|
ReflectionParser.customParseComponentHandles = new Map();
|
|
38659
38696
|
})();
|
|
38660
|
-
|
|
38661
|
-
|
|
38662
|
-
|
|
38663
|
-
|
|
38697
|
+
/**
|
|
38698
|
+
* Parser context
|
|
38699
|
+
* @export
|
|
38700
|
+
* @abstract
|
|
38701
|
+
* @class ParserContext
|
|
38702
|
+
* @template T
|
|
38703
|
+
* @template I
|
|
38704
|
+
*/ var ParserContext = /*#__PURE__*/ function() {
|
|
38705
|
+
var ParserContext = function ParserContext(originalData, engine, target) {
|
|
38706
|
+
this.originalData = originalData;
|
|
38707
|
+
this.engine = engine;
|
|
38708
|
+
this.target = target;
|
|
38709
|
+
this.entityMap = new Map();
|
|
38710
|
+
this.components = new Map();
|
|
38711
|
+
this.assets = new Map();
|
|
38712
|
+
this.entityConfigMap = new Map();
|
|
38713
|
+
this.rootIds = [];
|
|
38714
|
+
this.strippedIds = [];
|
|
38715
|
+
this.resourceManager = engine.resourceManager;
|
|
38716
|
+
};
|
|
38717
|
+
var _proto = ParserContext.prototype;
|
|
38718
|
+
/**
|
|
38719
|
+
* Destroy the context.
|
|
38720
|
+
* @abstract
|
|
38721
|
+
* @memberof ParserContext
|
|
38722
|
+
*/ _proto.destroy = function destroy() {
|
|
38723
|
+
this.entityMap.clear();
|
|
38724
|
+
this.components.clear();
|
|
38725
|
+
this.assets.clear();
|
|
38726
|
+
this.entityConfigMap.clear();
|
|
38727
|
+
this.rootIds.length = 0;
|
|
38728
|
+
};
|
|
38729
|
+
return ParserContext;
|
|
38730
|
+
}();
|
|
38731
|
+
var PrefabParserContext = /*#__PURE__*/ function(ParserContext1) {
|
|
38732
|
+
var PrefabParserContext = function PrefabParserContext() {
|
|
38733
|
+
return ParserContext1.apply(this, arguments);
|
|
38734
|
+
};
|
|
38735
|
+
_inherits(PrefabParserContext, ParserContext1);
|
|
38736
|
+
return PrefabParserContext;
|
|
38737
|
+
}(ParserContext);
|
|
38738
|
+
function _array_like_to_array(arr, len) {
|
|
38739
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
38740
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
38741
|
+
return arr2;
|
|
38742
|
+
}
|
|
38743
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
38744
|
+
if (!o) return;
|
|
38745
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
38746
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
38747
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
38748
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
38749
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
38750
|
+
}
|
|
38751
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
38752
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
38753
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
38754
|
+
// Fallback for engines without symbol support
|
|
38755
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
38756
|
+
if (it) o = it;
|
|
38757
|
+
var i = 0;
|
|
38758
|
+
return function() {
|
|
38759
|
+
if (i >= o.length) return {
|
|
38760
|
+
done: true
|
|
38761
|
+
};
|
|
38762
|
+
return {
|
|
38763
|
+
done: false,
|
|
38764
|
+
value: o[i++]
|
|
38765
|
+
};
|
|
38766
|
+
};
|
|
38767
|
+
}
|
|
38768
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
38769
|
+
}
|
|
38770
|
+
var HierarchyParser = /*#__PURE__*/ function() {
|
|
38771
|
+
var HierarchyParser = function HierarchyParser(context) {
|
|
38772
|
+
var _this = this;
|
|
38773
|
+
this.context = context;
|
|
38774
|
+
this.prefabContextMap = new WeakMap();
|
|
38775
|
+
this.prefabPromiseMap = new Map();
|
|
38776
|
+
this._engine = this.context.engine;
|
|
38777
|
+
this._organizeEntities = this._organizeEntities.bind(this);
|
|
38778
|
+
this._parseComponents = this._parseComponents.bind(this);
|
|
38779
|
+
this._parsePrefabModification = this._parsePrefabModification.bind(this);
|
|
38780
|
+
this._parsePrefabRemovedEntities = this._parsePrefabRemovedEntities.bind(this);
|
|
38781
|
+
this._parsePrefabRemovedComponents = this._parsePrefabRemovedComponents.bind(this);
|
|
38782
|
+
this._clearAndResolve = this._clearAndResolve.bind(this);
|
|
38783
|
+
this.promise = new Promise(function(resolve, reject) {
|
|
38784
|
+
_this._reject = reject;
|
|
38785
|
+
_this._resolve = resolve;
|
|
38786
|
+
});
|
|
38787
|
+
this._reflectionParser = new ReflectionParser(context);
|
|
38788
|
+
};
|
|
38789
|
+
var _proto = HierarchyParser.prototype;
|
|
38790
|
+
/** start parse the scene or prefab or others */ _proto.start = function start() {
|
|
38791
|
+
this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject);
|
|
38792
|
+
};
|
|
38793
|
+
_proto._parseEntities = function _parseEntities() {
|
|
38794
|
+
var _this = this;
|
|
38795
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
38796
|
+
var entityConfigMap = this.context.entityConfigMap;
|
|
38797
|
+
var entityMap = this.context.entityMap;
|
|
38798
|
+
var engine = this._engine;
|
|
38799
|
+
var promises = entitiesConfig.map(function(entityConfig) {
|
|
38800
|
+
var _entityConfig_strippedId;
|
|
38801
|
+
var id = (_entityConfig_strippedId = entityConfig.strippedId) != null ? _entityConfig_strippedId : entityConfig.id;
|
|
38802
|
+
entityConfig.id = id;
|
|
38803
|
+
entityConfigMap.set(id, entityConfig);
|
|
38804
|
+
return _this._getEntityByConfig(entityConfig, engine);
|
|
38805
|
+
});
|
|
38806
|
+
return Promise.all(promises).then(function(entities) {
|
|
38807
|
+
for(var i = 0, l = entities.length; i < l; i++){
|
|
38808
|
+
entityMap.set(entitiesConfig[i].id, entities[i]);
|
|
38809
|
+
}
|
|
38810
|
+
return entities;
|
|
38811
|
+
});
|
|
38812
|
+
};
|
|
38813
|
+
_proto._parseComponents = function _parseComponents() {
|
|
38814
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
38815
|
+
var entityMap = this.context.entityMap;
|
|
38816
|
+
var components = this.context.components;
|
|
38817
|
+
var promises = [];
|
|
38818
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++){
|
|
38819
|
+
var entityConfig = entitiesConfig[i];
|
|
38820
|
+
var entity = entityMap.get(entityConfig.id);
|
|
38821
|
+
for(var i1 = 0; i1 < entityConfig.components.length; i1++){
|
|
38822
|
+
var componentConfig = entityConfig.components[i1];
|
|
38823
|
+
var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
|
|
38824
|
+
var component = entity.addComponent(Loader.getClass(key));
|
|
38825
|
+
components.set(componentConfig.id, component);
|
|
38826
|
+
var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
|
|
38827
|
+
promises.push(promise);
|
|
38828
|
+
}
|
|
38829
|
+
}
|
|
38830
|
+
return Promise.all(promises);
|
|
38831
|
+
};
|
|
38832
|
+
_proto._parsePrefabModification = function _parsePrefabModification() {
|
|
38833
|
+
var _loop = function _loop(i, l) {
|
|
38834
|
+
var _modifications;
|
|
38835
|
+
var entityConfig = entitiesConfig[i];
|
|
38836
|
+
var id = entityConfig.id, modifications = entityConfig.modifications;
|
|
38837
|
+
if ((_modifications = modifications) == null ? void 0 : _modifications.length) {
|
|
38838
|
+
var _promises;
|
|
38839
|
+
var rootEntity = entityMap.get(id);
|
|
38840
|
+
(_promises = promises).push.apply(_promises, [].concat(modifications.map(function(modification) {
|
|
38841
|
+
var target = modification.target, props = modification.props, methods = modification.methods;
|
|
38842
|
+
var entityId = target.entityId, componentId = target.componentId;
|
|
38843
|
+
var context = _this.prefabContextMap.get(rootEntity);
|
|
38844
|
+
var targetEntity = context.entityMap.get(entityId);
|
|
38845
|
+
var targetComponent = context.components.get(componentId);
|
|
38846
|
+
if (targetComponent) {
|
|
38847
|
+
return _this._reflectionParser.parsePropsAndMethods(targetComponent, {
|
|
38848
|
+
props: props,
|
|
38849
|
+
methods: methods
|
|
38850
|
+
});
|
|
38851
|
+
} else if (targetEntity) {
|
|
38852
|
+
return Promise.resolve(_this._applyEntityData(targetEntity, props));
|
|
38853
|
+
}
|
|
38854
|
+
})));
|
|
38855
|
+
}
|
|
38856
|
+
};
|
|
38857
|
+
var _this = this;
|
|
38858
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
38859
|
+
var entityMap = this.context.entityMap;
|
|
38860
|
+
var promises = [];
|
|
38861
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
|
|
38862
|
+
return Promise.all(promises);
|
|
38863
|
+
};
|
|
38864
|
+
_proto._parsePrefabRemovedEntities = function _parsePrefabRemovedEntities() {
|
|
38865
|
+
var _loop = function _loop(i, l) {
|
|
38866
|
+
var _removedEntities;
|
|
38867
|
+
var entityConfig = entitiesConfig[i];
|
|
38868
|
+
var id = entityConfig.id, removedEntities = entityConfig.removedEntities;
|
|
38869
|
+
if ((_removedEntities = removedEntities) == null ? void 0 : _removedEntities.length) {
|
|
38870
|
+
var _promises;
|
|
38871
|
+
var rootEntity = entityMap.get(id);
|
|
38872
|
+
(_promises = promises).push.apply(_promises, [].concat(removedEntities.map(function(target) {
|
|
38873
|
+
var entityId = target.entityId;
|
|
38874
|
+
var context = _this.prefabContextMap.get(rootEntity);
|
|
38875
|
+
var targetEntity = context.entityMap.get(entityId);
|
|
38876
|
+
if (targetEntity) {
|
|
38877
|
+
targetEntity.destroy();
|
|
38878
|
+
}
|
|
38879
|
+
})));
|
|
38880
|
+
}
|
|
38881
|
+
};
|
|
38882
|
+
var _this = this;
|
|
38883
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
38884
|
+
var entityMap = this.context.entityMap;
|
|
38885
|
+
var promises = [];
|
|
38886
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
|
|
38887
|
+
return Promise.all(promises);
|
|
38888
|
+
};
|
|
38889
|
+
_proto._parsePrefabRemovedComponents = function _parsePrefabRemovedComponents() {
|
|
38890
|
+
var _loop = function _loop(i, l) {
|
|
38891
|
+
var _removedComponents;
|
|
38892
|
+
var entityConfig = entitiesConfig[i];
|
|
38893
|
+
var id = entityConfig.id, removedComponents = entityConfig.removedComponents;
|
|
38894
|
+
if ((_removedComponents = removedComponents) == null ? void 0 : _removedComponents.length) {
|
|
38895
|
+
var _promises;
|
|
38896
|
+
var rootEntity = entityMap.get(id);
|
|
38897
|
+
(_promises = promises).concat.apply(_promises, [].concat(removedComponents.map(function(target) {
|
|
38898
|
+
var componentId = target.componentId;
|
|
38899
|
+
var context = _this.prefabContextMap.get(rootEntity);
|
|
38900
|
+
var targetComponent = context.components.get(componentId);
|
|
38901
|
+
if (targetComponent) {
|
|
38902
|
+
targetComponent.destroy();
|
|
38903
|
+
}
|
|
38904
|
+
})));
|
|
38905
|
+
}
|
|
38906
|
+
};
|
|
38907
|
+
var _this = this;
|
|
38908
|
+
var entitiesConfig = this.context.originalData.entities;
|
|
38909
|
+
var entityMap = this.context.entityMap;
|
|
38910
|
+
var promises = [];
|
|
38911
|
+
for(var i = 0, l = entitiesConfig.length; i < l; i++)_loop(i);
|
|
38912
|
+
return Promise.all(promises);
|
|
38913
|
+
};
|
|
38914
|
+
_proto._clearAndResolve = function _clearAndResolve() {
|
|
38915
|
+
var target = this.context.target;
|
|
38916
|
+
return target;
|
|
38917
|
+
};
|
|
38918
|
+
_proto._organizeEntities = function _organizeEntities() {
|
|
38919
|
+
var _this_context = this.context, rootIds = _this_context.rootIds, strippedIds = _this_context.strippedIds;
|
|
38920
|
+
var parentIds = rootIds.concat(strippedIds);
|
|
38921
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(parentIds), _step; !(_step = _iterator()).done;){
|
|
38922
|
+
var parentId = _step.value;
|
|
38923
|
+
this._parseChildren(parentId);
|
|
38924
|
+
}
|
|
38925
|
+
for(var i = 0; i < rootIds.length; i++){
|
|
38926
|
+
this.handleRootEntity(rootIds[i]);
|
|
38927
|
+
}
|
|
38928
|
+
};
|
|
38929
|
+
_proto._getEntityByConfig = function _getEntityByConfig(entityConfig, engine) {
|
|
38930
|
+
var _this = this;
|
|
38931
|
+
var entityPromise;
|
|
38932
|
+
if (entityConfig.assetRefId) {
|
|
38933
|
+
entityPromise = this._parseGLTF(entityConfig, engine);
|
|
38934
|
+
} else if (entityConfig.strippedId) {
|
|
38935
|
+
entityPromise = this._parseStrippedEntity(entityConfig);
|
|
38936
|
+
} else {
|
|
38937
|
+
entityPromise = this._parseEntity(entityConfig, engine);
|
|
38938
|
+
}
|
|
38939
|
+
return entityPromise.then(function(entity) {
|
|
38940
|
+
return _this._applyEntityData(entity, entityConfig);
|
|
38941
|
+
});
|
|
38942
|
+
};
|
|
38943
|
+
_proto._parseEntity = function _parseEntity(entityConfig, engine) {
|
|
38944
|
+
var entity = new Entity(engine, entityConfig.name);
|
|
38945
|
+
if (!entityConfig.parent) this.context.rootIds.push(entityConfig.id);
|
|
38946
|
+
return Promise.resolve(entity);
|
|
38947
|
+
};
|
|
38948
|
+
_proto._parseGLTF = function _parseGLTF(entityConfig, engine) {
|
|
38949
|
+
var _this = this;
|
|
38950
|
+
var assetRefId = entityConfig.assetRefId;
|
|
38951
|
+
var context = new ParserContext(null, engine);
|
|
38952
|
+
return engine.resourceManager // @ts-ignore
|
|
38953
|
+
.getResourceByRef({
|
|
38954
|
+
refId: assetRefId
|
|
38955
|
+
}).then(function(glTFResource) {
|
|
38956
|
+
var entity = glTFResource.instantiateSceneRoot();
|
|
38957
|
+
if (!entityConfig.parent) _this.context.rootIds.push(entityConfig.id);
|
|
38958
|
+
_this._traverseAddEntityToMap(entity, context, "");
|
|
38959
|
+
_this.prefabContextMap.set(entity, context);
|
|
38960
|
+
var cbArray = _this.prefabPromiseMap.get(entityConfig.id);
|
|
38961
|
+
cbArray && cbArray.forEach(function(cb) {
|
|
38962
|
+
cb.resolve(context);
|
|
38963
|
+
});
|
|
38964
|
+
return entity;
|
|
38965
|
+
});
|
|
38966
|
+
};
|
|
38967
|
+
_proto._parseStrippedEntity = function _parseStrippedEntity(entityConfig) {
|
|
38968
|
+
var _this = this;
|
|
38969
|
+
this.context.strippedIds.push(entityConfig.id);
|
|
38970
|
+
return new Promise(function(resolve, reject) {
|
|
38971
|
+
var _this_prefabPromiseMap_get;
|
|
38972
|
+
var cbArray = (_this_prefabPromiseMap_get = _this.prefabPromiseMap.get(entityConfig.prefabInstanceId)) != null ? _this_prefabPromiseMap_get : [];
|
|
38973
|
+
cbArray.push({
|
|
38974
|
+
resolve: resolve,
|
|
38975
|
+
reject: reject
|
|
38976
|
+
});
|
|
38977
|
+
_this.prefabPromiseMap.set(entityConfig.prefabInstanceId, cbArray);
|
|
38978
|
+
}).then(function(context) {
|
|
38979
|
+
var entityId = entityConfig.prefabSource.entityId;
|
|
38980
|
+
return context.entityMap.get(entityId);
|
|
38981
|
+
});
|
|
38982
|
+
};
|
|
38983
|
+
_proto._parseChildren = function _parseChildren(parentId) {
|
|
38984
|
+
var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap;
|
|
38985
|
+
var children = entityConfigMap.get(parentId).children;
|
|
38664
38986
|
if (children && children.length > 0) {
|
|
38665
|
-
var parent =
|
|
38987
|
+
var parent = entityMap.get(parentId);
|
|
38666
38988
|
for(var i = 0; i < children.length; i++){
|
|
38667
38989
|
var childId = children[i];
|
|
38668
|
-
var entity =
|
|
38990
|
+
var entity = entityMap.get(childId);
|
|
38669
38991
|
parent.addChild(entity);
|
|
38670
|
-
this.
|
|
38992
|
+
this._parseChildren(childId);
|
|
38671
38993
|
}
|
|
38672
38994
|
}
|
|
38673
38995
|
};
|
|
38674
|
-
|
|
38996
|
+
_proto._applyEntityData = function _applyEntityData(entity, entityConfig) {
|
|
38997
|
+
var _entityConfig_isActive;
|
|
38998
|
+
entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : entity.isActive;
|
|
38999
|
+
var _entityConfig_name;
|
|
39000
|
+
entity.name = (_entityConfig_name = entityConfig.name) != null ? _entityConfig_name : entity.name;
|
|
39001
|
+
var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
|
|
39002
|
+
if (position) entity.transform.position.copyFrom(position);
|
|
39003
|
+
if (rotation) entity.transform.rotation.copyFrom(rotation);
|
|
39004
|
+
if (scale) entity.transform.scale.copyFrom(scale);
|
|
39005
|
+
return entity;
|
|
39006
|
+
};
|
|
39007
|
+
_proto._traverseAddEntityToMap = function _traverseAddEntityToMap(entity, context, path) {
|
|
39008
|
+
var entityMap = context.entityMap, components = context.components;
|
|
39009
|
+
entityMap.set(path, entity);
|
|
39010
|
+
// @ts-ignore
|
|
39011
|
+
entity._components.forEach(function(component) {
|
|
39012
|
+
// @ts-ignore
|
|
39013
|
+
var name = Loader.getClassName(component.constructor);
|
|
39014
|
+
components.set(path + ":" + name, component);
|
|
39015
|
+
});
|
|
39016
|
+
for(var i = 0; i < entity.children.length; i++){
|
|
39017
|
+
var child = entity.children[i];
|
|
39018
|
+
var childPath = path ? path + "/" + child.name : child.name;
|
|
39019
|
+
this._traverseAddEntityToMap(child, context, childPath);
|
|
39020
|
+
}
|
|
39021
|
+
};
|
|
39022
|
+
return HierarchyParser;
|
|
38675
39023
|
}();
|
|
38676
|
-
var
|
|
38677
|
-
|
|
38678
|
-
|
|
38679
|
-
|
|
38680
|
-
|
|
38681
|
-
|
|
38682
|
-
|
|
38683
|
-
|
|
38684
|
-
|
|
38685
|
-
|
|
38686
|
-
|
|
38687
|
-
|
|
38688
|
-
|
|
38689
|
-
|
|
39024
|
+
var PrefabParser = /*#__PURE__*/ function(HierarchyParser1) {
|
|
39025
|
+
var PrefabParser = function PrefabParser() {
|
|
39026
|
+
return HierarchyParser1.apply(this, arguments);
|
|
39027
|
+
};
|
|
39028
|
+
_inherits(PrefabParser, HierarchyParser1);
|
|
39029
|
+
var _proto = PrefabParser.prototype;
|
|
39030
|
+
_proto.handleRootEntity = function handleRootEntity(id) {
|
|
39031
|
+
this.context.target = this.context.entityMap.get(id);
|
|
39032
|
+
};
|
|
39033
|
+
/**
|
|
39034
|
+
* Parse prefab data.
|
|
39035
|
+
* @param engine - the engine of the parser context
|
|
39036
|
+
* @param prefabData - prefab data which is exported by editor
|
|
39037
|
+
* @returns a promise of prefab
|
|
39038
|
+
*/ PrefabParser.parse = function parse(engine, prefabData) {
|
|
39039
|
+
var context = new PrefabParserContext(prefabData, engine);
|
|
39040
|
+
var parser = new PrefabParser(context);
|
|
39041
|
+
parser.start();
|
|
39042
|
+
return parser;
|
|
39043
|
+
};
|
|
39044
|
+
return PrefabParser;
|
|
39045
|
+
}(HierarchyParser);
|
|
38690
39046
|
exports.InterpolableValueType = void 0;
|
|
38691
39047
|
(function(InterpolableValueType) {
|
|
38692
39048
|
InterpolableValueType[InterpolableValueType["Float"] = 0] = "Float";
|
|
@@ -38719,7 +39075,7 @@
|
|
|
38719
39075
|
for(var i1 = 0; i1 < curveBindingsLen; ++i1){
|
|
38720
39076
|
var relativePath = bufferReader.nextStr();
|
|
38721
39077
|
var componentStr = bufferReader.nextStr();
|
|
38722
|
-
var componentType =
|
|
39078
|
+
var componentType = Loader.getClass(componentStr);
|
|
38723
39079
|
var property = bufferReader.nextStr();
|
|
38724
39080
|
var getProperty = bufferReader.nextStr();
|
|
38725
39081
|
var curve = void 0;
|
|
@@ -38896,137 +39252,27 @@
|
|
|
38896
39252
|
SpecularMode["Sky"] = "Sky";
|
|
38897
39253
|
SpecularMode["Custom"] = "Custom";
|
|
38898
39254
|
})(exports.SpecularMode || (exports.SpecularMode = {}));
|
|
38899
|
-
function
|
|
38900
|
-
|
|
38901
|
-
|
|
38902
|
-
|
|
38903
|
-
|
|
38904
|
-
|
|
38905
|
-
|
|
38906
|
-
|
|
38907
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
38908
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
38909
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
38910
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
38911
|
-
}
|
|
38912
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
38913
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
38914
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
38915
|
-
// Fallback for engines without symbol support
|
|
38916
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
38917
|
-
if (it) o = it;
|
|
38918
|
-
var i = 0;
|
|
38919
|
-
return function() {
|
|
38920
|
-
if (i >= o.length) return {
|
|
38921
|
-
done: true
|
|
38922
|
-
};
|
|
38923
|
-
return {
|
|
38924
|
-
done: false,
|
|
38925
|
-
value: o[i++]
|
|
38926
|
-
};
|
|
38927
|
-
};
|
|
38928
|
-
}
|
|
38929
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
38930
|
-
}
|
|
38931
|
-
var SceneParserContext = /*#__PURE__*/ function() {
|
|
38932
|
-
var SceneParserContext = function SceneParserContext(originalData, scene) {
|
|
38933
|
-
this.originalData = originalData;
|
|
38934
|
-
this.scene = scene;
|
|
38935
|
-
this.entityMap = new Map();
|
|
38936
|
-
this.components = new Map();
|
|
38937
|
-
this.assets = new Map();
|
|
38938
|
-
this.entityConfigMap = new Map();
|
|
38939
|
-
this.rootIds = [];
|
|
38940
|
-
this.engine = scene.engine;
|
|
38941
|
-
this.resourceManager = scene.engine.resourceManager;
|
|
38942
|
-
};
|
|
38943
|
-
var _proto = SceneParserContext.prototype;
|
|
38944
|
-
_proto.destroy = function destroy() {
|
|
38945
|
-
this.entityMap.clear();
|
|
38946
|
-
this.components.clear();
|
|
38947
|
-
this.assets.clear();
|
|
38948
|
-
this.entityConfigMap.clear();
|
|
38949
|
-
this.rootIds.length = 0;
|
|
39255
|
+
var SceneParserContext = /*#__PURE__*/ function(ParserContext1) {
|
|
39256
|
+
var SceneParserContext = function SceneParserContext(originalData, engine, scene) {
|
|
39257
|
+
var _this;
|
|
39258
|
+
_this = ParserContext1.call(this, originalData, engine, scene) || this;
|
|
39259
|
+
_this.originalData = originalData;
|
|
39260
|
+
_this.engine = engine;
|
|
39261
|
+
_this.scene = scene;
|
|
39262
|
+
return _this;
|
|
38950
39263
|
};
|
|
39264
|
+
_inherits(SceneParserContext, ParserContext1);
|
|
38951
39265
|
return SceneParserContext;
|
|
38952
|
-
}();
|
|
38953
|
-
/** @Internal */ var SceneParser = /*#__PURE__*/ function() {
|
|
38954
|
-
var SceneParser = function SceneParser(
|
|
38955
|
-
|
|
38956
|
-
this.context = context;
|
|
38957
|
-
this._engine = context.scene.engine;
|
|
38958
|
-
this._organizeEntities = this._organizeEntities.bind(this);
|
|
38959
|
-
this._parseComponents = this._parseComponents.bind(this);
|
|
38960
|
-
this._clearAndResolveScene = this._clearAndResolveScene.bind(this);
|
|
38961
|
-
this.promise = new Promise(function(resolve, reject) {
|
|
38962
|
-
_this._reject = reject;
|
|
38963
|
-
_this._resolve = resolve;
|
|
38964
|
-
});
|
|
38965
|
-
this._reflectionParser = new ReflectionParser(context);
|
|
39266
|
+
}(ParserContext);
|
|
39267
|
+
/** @Internal */ var SceneParser = /*#__PURE__*/ function(HierarchyParser1) {
|
|
39268
|
+
var SceneParser = function SceneParser() {
|
|
39269
|
+
return HierarchyParser1.apply(this, arguments);
|
|
38966
39270
|
};
|
|
39271
|
+
_inherits(SceneParser, HierarchyParser1);
|
|
38967
39272
|
var _proto = SceneParser.prototype;
|
|
38968
|
-
|
|
38969
|
-
this.
|
|
38970
|
-
|
|
38971
|
-
_proto._parseEntities = function _parseEntities() {
|
|
38972
|
-
var _this = this;
|
|
38973
|
-
var entitiesConfig = this.context.originalData.entities;
|
|
38974
|
-
var entityConfigMap = this.context.entityConfigMap;
|
|
38975
|
-
var entitiesMap = this.context.entityMap;
|
|
38976
|
-
var rootIds = this.context.rootIds;
|
|
38977
|
-
this._engine;
|
|
38978
|
-
var promises = entitiesConfig.map(function(entityConfig) {
|
|
38979
|
-
entityConfigMap.set(entityConfig.id, entityConfig);
|
|
38980
|
-
// record root entities
|
|
38981
|
-
if (!entityConfig.parent) rootIds.push(entityConfig.id);
|
|
38982
|
-
return _this._reflectionParser.parseEntity(entityConfig);
|
|
38983
|
-
});
|
|
38984
|
-
return Promise.all(promises).then(function(entities) {
|
|
38985
|
-
for(var i = 0, l = entities.length; i < l; i++){
|
|
38986
|
-
entitiesMap.set(entitiesConfig[i].id, entities[i]);
|
|
38987
|
-
}
|
|
38988
|
-
return entities;
|
|
38989
|
-
});
|
|
38990
|
-
};
|
|
38991
|
-
_proto._organizeEntities = function _organizeEntities() {
|
|
38992
|
-
var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap, scene = _this_context.scene, rootIds = _this_context.rootIds;
|
|
38993
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(rootIds), _step; !(_step = _iterator()).done;){
|
|
38994
|
-
var rootId = _step.value;
|
|
38995
|
-
PrefabParser.parseChildren(entityConfigMap, entityMap, rootId);
|
|
38996
|
-
}
|
|
38997
|
-
var rootEntities = rootIds.map(function(id) {
|
|
38998
|
-
return entityMap.get(id);
|
|
38999
|
-
});
|
|
39000
|
-
for(var i = 0; i < rootEntities.length; i++){
|
|
39001
|
-
scene.addRootEntity(rootEntities[i]);
|
|
39002
|
-
}
|
|
39003
|
-
};
|
|
39004
|
-
_proto._parseComponents = function _parseComponents() {
|
|
39005
|
-
var entitiesConfig = this.context.originalData.entities;
|
|
39006
|
-
var entityMap = this.context.entityMap;
|
|
39007
|
-
var promises = [];
|
|
39008
|
-
for(var i = 0, l = entitiesConfig.length; i < l; i++){
|
|
39009
|
-
var entityConfig = entitiesConfig[i];
|
|
39010
|
-
var entity = entityMap.get(entityConfig.id);
|
|
39011
|
-
for(var i1 = 0; i1 < entityConfig.components.length; i1++){
|
|
39012
|
-
var componentConfig = entityConfig.components[i1];
|
|
39013
|
-
var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
|
|
39014
|
-
var component = void 0;
|
|
39015
|
-
// TODO: remove hack code when support additional edit
|
|
39016
|
-
if (key === "Animator") {
|
|
39017
|
-
component = entity.getComponent(Loader.getClass(key));
|
|
39018
|
-
}
|
|
39019
|
-
component = component || entity.addComponent(Loader.getClass(key));
|
|
39020
|
-
var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
|
|
39021
|
-
promises.push(promise);
|
|
39022
|
-
}
|
|
39023
|
-
}
|
|
39024
|
-
return Promise.all(promises);
|
|
39025
|
-
};
|
|
39026
|
-
_proto._clearAndResolveScene = function _clearAndResolveScene() {
|
|
39027
|
-
var scene = this.context.scene;
|
|
39028
|
-
this.context.destroy();
|
|
39029
|
-
return scene;
|
|
39273
|
+
_proto.handleRootEntity = function handleRootEntity(id) {
|
|
39274
|
+
var _this_context = this.context, target = _this_context.target, entityMap = _this_context.entityMap;
|
|
39275
|
+
target.addRootEntity(entityMap.get(id));
|
|
39030
39276
|
};
|
|
39031
39277
|
/**
|
|
39032
39278
|
* Parse scene data.
|
|
@@ -39035,13 +39281,13 @@
|
|
|
39035
39281
|
* @returns a promise of scene
|
|
39036
39282
|
*/ SceneParser.parse = function parse(engine, sceneData) {
|
|
39037
39283
|
var scene = new Scene(engine);
|
|
39038
|
-
var context = new SceneParserContext(sceneData, scene);
|
|
39284
|
+
var context = new SceneParserContext(sceneData, engine, scene);
|
|
39039
39285
|
var parser = new SceneParser(context);
|
|
39040
39286
|
parser.start();
|
|
39041
39287
|
return parser.promise;
|
|
39042
39288
|
};
|
|
39043
39289
|
return SceneParser;
|
|
39044
|
-
}();
|
|
39290
|
+
}(HierarchyParser);
|
|
39045
39291
|
exports.MeshLoader = /*#__PURE__*/ function(Loader1) {
|
|
39046
39292
|
var MeshLoader = function MeshLoader() {
|
|
39047
39293
|
return Loader1.apply(this, arguments);
|
|
@@ -39142,7 +39388,7 @@
|
|
|
39142
39388
|
resourceManager // @ts-ignore
|
|
39143
39389
|
.getResourceByRef(value).then(function(asset) {
|
|
39144
39390
|
keyframe.value = asset;
|
|
39145
|
-
resolve(keyframe);
|
|
39391
|
+
resolve(keyframe.value);
|
|
39146
39392
|
});
|
|
39147
39393
|
});
|
|
39148
39394
|
} else {
|
|
@@ -44430,7 +44676,7 @@
|
|
|
44430
44676
|
], KHR_materials_anisotropy);
|
|
44431
44677
|
|
|
44432
44678
|
//@ts-ignore
|
|
44433
|
-
var version = "1.2.0-alpha.
|
|
44679
|
+
var version = "1.2.0-alpha.4";
|
|
44434
44680
|
console.log("Galacean engine version: " + version);
|
|
44435
44681
|
for(var key in CoreObjects){
|
|
44436
44682
|
Loader.registerClass(key, CoreObjects[key]);
|
|
@@ -44478,7 +44724,6 @@
|
|
|
44478
44724
|
exports.Color = Color;
|
|
44479
44725
|
exports.ColorOverLifetimeModule = ColorOverLifetimeModule;
|
|
44480
44726
|
exports.Component = Component;
|
|
44481
|
-
exports.ComponentMap = ComponentMap;
|
|
44482
44727
|
exports.ConeShape = ConeShape;
|
|
44483
44728
|
exports.ContentRestorer = ContentRestorer;
|
|
44484
44729
|
exports.CubeProbe = CubeProbe;
|
|
@@ -44522,6 +44767,7 @@
|
|
|
44522
44767
|
exports.PBRBaseMaterial = PBRBaseMaterial;
|
|
44523
44768
|
exports.PBRMaterial = PBRMaterial;
|
|
44524
44769
|
exports.PBRSpecularMaterial = PBRSpecularMaterial;
|
|
44770
|
+
exports.ParserContext = ParserContext;
|
|
44525
44771
|
exports.ParticleCompositeCurve = ParticleCompositeCurve;
|
|
44526
44772
|
exports.ParticleCompositeGradient = ParticleCompositeGradient;
|
|
44527
44773
|
exports.ParticleCurve = ParticleCurve;
|