@galacean/engine 1.2.0-alpha.3 → 1.2.0-alpha.5
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 +605 -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
|
|
@@ -8288,7 +8288,7 @@
|
|
|
8288
8288
|
Logger.error('Shader slice "' + match.trim() + '" not founded.');
|
|
8289
8289
|
return "";
|
|
8290
8290
|
}
|
|
8291
|
-
return ShaderFactory.parseIncludes(replace);
|
|
8291
|
+
return ShaderFactory.parseIncludes(replace, regex);
|
|
8292
8292
|
};
|
|
8293
8293
|
return src.replace(regex, replace);
|
|
8294
8294
|
};
|
|
@@ -25650,6 +25650,10 @@
|
|
|
25650
25650
|
/** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
|
|
25651
25651
|
/** The splits of four cascade distribution. */ _this.shadowFourCascadeSplits = new Vector3(1.0 / 15, 3.0 / 15.0, 7.0 / 15.0);
|
|
25652
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;
|
|
25653
25657
|
/* @internal */ _this._lightManager = new LightManager();
|
|
25654
25658
|
/* @internal */ _this._componentsManager = new ComponentsManager();
|
|
25655
25659
|
/** @internal */ _this._isActiveInEngine = false;
|
|
@@ -26271,47 +26275,65 @@
|
|
|
26271
26275
|
DepthTextureMode[DepthTextureMode[/* No depth texture. */ "None"] = 0] = "None";
|
|
26272
26276
|
DepthTextureMode[DepthTextureMode[/* Generate depth texture by pre-pass rendering. */ "PrePass"] = 1] = "PrePass";
|
|
26273
26277
|
})(exports.DepthTextureMode || (exports.DepthTextureMode = {}));
|
|
26274
|
-
var passNum = 0;
|
|
26275
26278
|
/**
|
|
26276
|
-
*
|
|
26277
|
-
*/ var
|
|
26278
|
-
|
|
26279
|
-
|
|
26280
|
-
|
|
26281
|
-
|
|
26282
|
-
|
|
26283
|
-
|
|
26284
|
-
this.name = name1;
|
|
26285
|
-
this.enabled = true;
|
|
26286
|
-
this.priority = priority;
|
|
26287
|
-
this.renderTarget = renderTarget;
|
|
26288
|
-
this.replaceMaterial = replaceMaterial;
|
|
26289
|
-
this.mask = mask || exports.Layer.Everything;
|
|
26290
|
-
this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
|
|
26291
|
-
};
|
|
26292
|
-
var _proto = RenderPass.prototype;
|
|
26293
|
-
/**
|
|
26294
|
-
* Rendering callback, will be executed if renderOverride is set to true.
|
|
26295
|
-
* @param camera - Camera
|
|
26296
|
-
* @param opaqueQueue - Opaque queue
|
|
26297
|
-
* @param alphaTestQueue - Alpha test queue
|
|
26298
|
-
* @param transparentQueue - Transparent queue
|
|
26299
|
-
*/ _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() {};
|
|
26300
26287
|
/**
|
|
26301
|
-
*
|
|
26302
|
-
* @param
|
|
26303
|
-
* @param
|
|
26304
|
-
* @param
|
|
26305
|
-
* @param
|
|
26306
|
-
|
|
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
|
+
};
|
|
26307
26312
|
/**
|
|
26308
|
-
*
|
|
26309
|
-
* @param
|
|
26310
|
-
* @param
|
|
26311
|
-
* @param
|
|
26312
|
-
* @param
|
|
26313
|
-
|
|
26314
|
-
|
|
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;
|
|
26315
26337
|
}();
|
|
26316
26338
|
/**
|
|
26317
26339
|
* @internal
|
|
@@ -26615,60 +26637,47 @@
|
|
|
26615
26637
|
};
|
|
26616
26638
|
return RenderQueue;
|
|
26617
26639
|
}();
|
|
26640
|
+
var passNum = 0;
|
|
26618
26641
|
/**
|
|
26619
|
-
*
|
|
26620
|
-
*/ var
|
|
26621
|
-
var
|
|
26622
|
-
|
|
26623
|
-
|
|
26624
|
-
|
|
26625
|
-
|
|
26626
|
-
|
|
26627
|
-
|
|
26628
|
-
|
|
26629
|
-
|
|
26630
|
-
|
|
26631
|
-
|
|
26632
|
-
|
|
26633
|
-
|
|
26634
|
-
currentTexture.destroy();
|
|
26635
|
-
var texture = new Texture2D(engine, width, height, format, mipmap);
|
|
26636
|
-
texture.isGCIgnored = true;
|
|
26637
|
-
return texture;
|
|
26638
|
-
} else {
|
|
26639
|
-
return currentTexture;
|
|
26640
|
-
}
|
|
26641
|
-
} else {
|
|
26642
|
-
var texture1 = new Texture2D(engine, width, height, format, mipmap);
|
|
26643
|
-
texture1.isGCIgnored = true;
|
|
26644
|
-
return texture1;
|
|
26645
|
-
}
|
|
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
|
|
26646
26657
|
};
|
|
26658
|
+
var _proto = RenderPass.prototype;
|
|
26647
26659
|
/**
|
|
26648
|
-
*
|
|
26649
|
-
* @param
|
|
26650
|
-
* @param
|
|
26651
|
-
* @param
|
|
26652
|
-
* @param
|
|
26653
|
-
|
|
26654
|
-
|
|
26655
|
-
*
|
|
26656
|
-
* @
|
|
26657
|
-
|
|
26658
|
-
|
|
26659
|
-
|
|
26660
|
-
|
|
26661
|
-
|
|
26662
|
-
|
|
26663
|
-
|
|
26664
|
-
|
|
26665
|
-
|
|
26666
|
-
|
|
26667
|
-
|
|
26668
|
-
|
|
26669
|
-
return currentRenderTarget;
|
|
26670
|
-
};
|
|
26671
|
-
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;
|
|
26672
26681
|
}();
|
|
26673
26682
|
/**
|
|
26674
26683
|
* @internal
|
|
@@ -26933,6 +26942,26 @@
|
|
|
26933
26942
|
var offset = cascadeIndex * 16;
|
|
26934
26943
|
Utils._floatMatrixMultiply(sliceMatrix, outShadowMatrices, offset, outShadowMatrices, offset);
|
|
26935
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
|
+
};
|
|
26936
26965
|
return ShadowUtils;
|
|
26937
26966
|
}();
|
|
26938
26967
|
(function() {
|
|
@@ -27176,11 +27205,6 @@
|
|
|
27176
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.
|
|
27177
27206
|
ShadowUtils.atlasBorderSize = 4.0;
|
|
27178
27207
|
})();
|
|
27179
|
-
/**
|
|
27180
|
-
* PipelinePass is a base class for all pipeline passes.
|
|
27181
|
-
*/ var PipelinePass = function PipelinePass(engine) {
|
|
27182
|
-
this._engine = engine;
|
|
27183
|
-
};
|
|
27184
27208
|
/**
|
|
27185
27209
|
* Cascade shadow caster pass.
|
|
27186
27210
|
*/ var CascadedShadowCasterPass = /*#__PURE__*/ function(PipelinePass1) {
|
|
@@ -27193,11 +27217,10 @@
|
|
|
27193
27217
|
_this._shadowSliceData = new ShadowSliceData();
|
|
27194
27218
|
_this._lightUp = new Vector3();
|
|
27195
27219
|
_this._lightSide = new Vector3();
|
|
27196
|
-
_this._existShadowMap = false;
|
|
27197
27220
|
_this._splitBoundSpheres = new Float32Array(CascadedShadowCasterPass._maxCascades * 4);
|
|
27198
27221
|
/** The end is project precision problem in shader. */ _this._shadowMatrices = new Float32Array((CascadedShadowCasterPass._maxCascades + 1) * 16);
|
|
27199
|
-
//
|
|
27200
|
-
_this._shadowInfos = new
|
|
27222
|
+
// intensity, null, fadeScale, fadeBias
|
|
27223
|
+
_this._shadowInfos = new Vector4();
|
|
27201
27224
|
_this._viewportOffsets = [
|
|
27202
27225
|
new Vector2(),
|
|
27203
27226
|
new Vector2(),
|
|
@@ -27213,14 +27236,12 @@
|
|
|
27213
27236
|
/**
|
|
27214
27237
|
* @internal
|
|
27215
27238
|
*/ _proto.onRender = function onRender(context) {
|
|
27239
|
+
var light = this._camera.scene._lightManager._sunlight;
|
|
27216
27240
|
this._updateShadowSettings();
|
|
27217
|
-
this.
|
|
27218
|
-
this.
|
|
27219
|
-
if (this._existShadowMap) {
|
|
27220
|
-
this._updateReceiversShaderData();
|
|
27221
|
-
}
|
|
27241
|
+
this._renderDirectShadowMap(context, light);
|
|
27242
|
+
this._updateReceiversShaderData(light);
|
|
27222
27243
|
};
|
|
27223
|
-
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context) {
|
|
27244
|
+
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context, light) {
|
|
27224
27245
|
var _this = this, engine = _this._engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
|
|
27225
27246
|
var _camera__renderPipeline__cullingResults = camera._renderPipeline._cullingResults, opaqueQueue = _camera__renderPipeline__cullingResults.opaqueQueue, alphaTestQueue = _camera__renderPipeline__cullingResults.alphaTestQueue, transparentQueue = _camera__renderPipeline__cullingResults.transparentQueue;
|
|
27226
27247
|
var scene = camera.scene;
|
|
@@ -27234,91 +27255,87 @@
|
|
|
27234
27255
|
var lightUp = this._lightUp;
|
|
27235
27256
|
var lightSide = this._lightSide;
|
|
27236
27257
|
var lightForward = shadowSliceData.virtualCamera.forward;
|
|
27237
|
-
|
|
27238
|
-
|
|
27239
|
-
|
|
27240
|
-
|
|
27241
|
-
|
|
27242
|
-
|
|
27243
|
-
|
|
27244
|
-
|
|
27245
|
-
|
|
27246
|
-
|
|
27247
|
-
|
|
27248
|
-
|
|
27249
|
-
|
|
27250
|
-
|
|
27251
|
-
|
|
27252
|
-
|
|
27253
|
-
|
|
27254
|
-
|
|
27255
|
-
|
|
27256
|
-
|
|
27257
|
-
|
|
27258
|
-
|
|
27259
|
-
|
|
27260
|
-
rhi.
|
|
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
|
-
}
|
|
27314
|
-
this._existShadowMap = true;
|
|
27315
|
-
}
|
|
27316
|
-
};
|
|
27317
|
-
_proto._updateReceiversShaderData = function _updateReceiversShaderData() {
|
|
27318
|
-
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;
|
|
27319
27333
|
var splitBoundSpheres = this._splitBoundSpheres;
|
|
27320
27334
|
var shadowMatrices = this._shadowMatrices;
|
|
27321
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;
|
|
27322
27339
|
// set zero matrix to project the index out of max cascade
|
|
27323
27340
|
if (shadowCascades > 1) {
|
|
27324
27341
|
for(var i = shadowCascades * 4, n = splitBoundSpheres.length; i < n; i++){
|
|
@@ -27331,7 +27348,7 @@
|
|
|
27331
27348
|
}
|
|
27332
27349
|
var shaderData = scene.shaderData;
|
|
27333
27350
|
shaderData.setFloatArray(CascadedShadowCasterPass._shadowMatricesProperty, this._shadowMatrices);
|
|
27334
|
-
shaderData.
|
|
27351
|
+
shaderData.setVector4(CascadedShadowCasterPass._shadowInfosProperty, this._shadowInfos);
|
|
27335
27352
|
shaderData.setTexture(CascadedShadowCasterPass._shadowMapsProperty, this._depthTexture);
|
|
27336
27353
|
shaderData.setFloatArray(CascadedShadowCasterPass._shadowSplitSpheresProperty, this._splitBoundSpheres);
|
|
27337
27354
|
shaderData.setVector4(CascadedShadowCasterPass._shadowMapSize, this._shadowMapSize);
|
|
@@ -27367,10 +27384,13 @@
|
|
|
27367
27384
|
return Math.sqrt(radius * radius / denominator);
|
|
27368
27385
|
};
|
|
27369
27386
|
_proto._updateShadowSettings = function _updateShadowSettings() {
|
|
27370
|
-
var
|
|
27387
|
+
var camera = this._camera;
|
|
27388
|
+
var scene = camera.scene;
|
|
27371
27389
|
var shadowFormat = ShadowUtils.shadowDepthFormat(scene.shadowResolution, this._supportDepthTexture);
|
|
27372
27390
|
var shadowResolution = ShadowUtils.shadowResolution(scene.shadowResolution);
|
|
27373
27391
|
var shadowCascades = scene.shadowCascades;
|
|
27392
|
+
var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
|
|
27393
|
+
this._getCascadesSplitDistance(shadowFar);
|
|
27374
27394
|
if (shadowFormat !== this._shadowMapFormat || shadowResolution !== this._shadowMapResolution || shadowCascades !== this._shadowCascadeMode) {
|
|
27375
27395
|
this._shadowMapFormat = shadowFormat;
|
|
27376
27396
|
this._shadowMapResolution = shadowResolution;
|
|
@@ -28543,6 +28563,7 @@
|
|
|
28543
28563
|
* @param obj - class object
|
|
28544
28564
|
*/ Loader.registerClass = function registerClass(className, classDefine) {
|
|
28545
28565
|
this._engineObjects[className] = classDefine;
|
|
28566
|
+
this._classNameMap.set(classDefine, className);
|
|
28546
28567
|
};
|
|
28547
28568
|
/**
|
|
28548
28569
|
* Get the class object by class name.
|
|
@@ -28551,11 +28572,21 @@
|
|
|
28551
28572
|
*/ Loader.getClass = function getClass(className) {
|
|
28552
28573
|
return this._engineObjects[className];
|
|
28553
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
|
+
};
|
|
28554
28582
|
return Loader;
|
|
28555
28583
|
}();
|
|
28556
28584
|
(function() {
|
|
28557
28585
|
Loader._engineObjects = {};
|
|
28558
28586
|
})();
|
|
28587
|
+
(function() {
|
|
28588
|
+
Loader._classNameMap = new Map();
|
|
28589
|
+
})();
|
|
28559
28590
|
/**
|
|
28560
28591
|
* Alpha blend mode.
|
|
28561
28592
|
*/ exports.BlendMode = void 0;
|
|
@@ -32276,7 +32307,7 @@
|
|
|
32276
32307
|
this._clip = clip;
|
|
32277
32308
|
this._clipEndTime = Math.min(this._clipEndTime, 1);
|
|
32278
32309
|
this._onClipChanged();
|
|
32279
|
-
clip._updateFlagManager.addListener(this._onClipChanged);
|
|
32310
|
+
clip && clip._updateFlagManager.addListener(this._onClipChanged);
|
|
32280
32311
|
}
|
|
32281
32312
|
},
|
|
32282
32313
|
{
|
|
@@ -32965,6 +32996,7 @@
|
|
|
32965
32996
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["RotationOverLifetime"] = 0x40eb95e4] = "RotationOverLifetime";
|
|
32966
32997
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["TextureSheetAnimation"] = 0xbc524e5] = "TextureSheetAnimation";
|
|
32967
32998
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["Shape"] = 0xaf502044] = "Shape";
|
|
32999
|
+
ParticleRandomSubSeeds[ParticleRandomSubSeeds["GravityModifier"] = 0xa47b8c4d] = "GravityModifier";
|
|
32968
33000
|
})(ParticleRandomSubSeeds || (ParticleRandomSubSeeds = {}));
|
|
32969
33001
|
/**
|
|
32970
33002
|
* Particle gradient.
|
|
@@ -33670,6 +33702,7 @@
|
|
|
33670
33702
|
/** @internal */ this._startColorRand = new Rand(0, ParticleRandomSubSeeds.StartColor);
|
|
33671
33703
|
/** @internal */ this._startSizeRand = new Rand(0, ParticleRandomSubSeeds.StartSize);
|
|
33672
33704
|
/** @internal */ this._startRotationRand = new Rand(0, ParticleRandomSubSeeds.StartRotation);
|
|
33705
|
+
this._gravityModifierRand = new Rand(0, ParticleRandomSubSeeds.GravityModifier);
|
|
33673
33706
|
this._gravity = new Vector3();
|
|
33674
33707
|
this._generator = generator;
|
|
33675
33708
|
};
|
|
@@ -33730,7 +33763,7 @@
|
|
|
33730
33763
|
break;
|
|
33731
33764
|
}
|
|
33732
33765
|
var particleGravity = this._gravity;
|
|
33733
|
-
var gravityModifierValue = this.gravityModifier.evaluate(undefined,
|
|
33766
|
+
var gravityModifierValue = this.gravityModifier.evaluate(undefined, this._gravityModifierRand.random());
|
|
33734
33767
|
Vector3.scale(renderer.scene.physics.gravity, gravityModifierValue, particleGravity);
|
|
33735
33768
|
shaderData.setVector3(MainModule._gravity, particleGravity);
|
|
33736
33769
|
shaderData.setInt(MainModule._simulationSpace, this.simulationSpace);
|
|
@@ -33849,6 +33882,9 @@
|
|
|
33849
33882
|
__decorate$1([
|
|
33850
33883
|
ignoreClone
|
|
33851
33884
|
], MainModule.prototype, "_startRotationRand", void 0);
|
|
33885
|
+
__decorate$1([
|
|
33886
|
+
ignoreClone
|
|
33887
|
+
], MainModule.prototype, "_gravityModifierRand", void 0);
|
|
33852
33888
|
__decorate$1([
|
|
33853
33889
|
ignoreClone
|
|
33854
33890
|
], MainModule.prototype, "_generator", void 0);
|
|
@@ -35152,22 +35188,22 @@
|
|
|
35152
35188
|
}();
|
|
35153
35189
|
/**
|
|
35154
35190
|
* The emission shape.
|
|
35155
|
-
*/
|
|
35191
|
+
*/ exports.ParticleShapeType = void 0;
|
|
35156
35192
|
(function(ParticleShapeType) {
|
|
35157
35193
|
ParticleShapeType[ParticleShapeType[/** Emit from the volume of a box. */ "Box"] = 0] = "Box";
|
|
35158
35194
|
ParticleShapeType[ParticleShapeType[/** Emit from a circle. */ "Circle"] = 1] = "Circle";
|
|
35159
35195
|
ParticleShapeType[ParticleShapeType[/** Emit from the base of a cone. */ "Cone"] = 2] = "Cone";
|
|
35160
35196
|
ParticleShapeType[ParticleShapeType[/** Emit from a half-sphere. */ "Hemisphere"] = 3] = "Hemisphere";
|
|
35161
35197
|
ParticleShapeType[ParticleShapeType[/** Emit from a sphere. */ "Sphere"] = 4] = "Sphere";
|
|
35162
|
-
})(ParticleShapeType || (ParticleShapeType = {}));
|
|
35198
|
+
})(exports.ParticleShapeType || (exports.ParticleShapeType = {}));
|
|
35163
35199
|
/**
|
|
35164
35200
|
* Particle shape that emits particles from a box.
|
|
35165
35201
|
*/ var BoxShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35166
35202
|
var BoxShape = function BoxShape() {
|
|
35167
35203
|
var _this;
|
|
35168
|
-
_this = BaseShape1.
|
|
35204
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35205
|
+
_this.shapeType = exports.ParticleShapeType.Box;
|
|
35169
35206
|
/** The size of the box. */ _this.size = new Vector3(1, 1, 1);
|
|
35170
|
-
_this.shapeType = ParticleShapeType.Box;
|
|
35171
35207
|
return _this;
|
|
35172
35208
|
};
|
|
35173
35209
|
_inherits$2(BoxShape, BaseShape1);
|
|
@@ -35202,12 +35238,12 @@
|
|
|
35202
35238
|
*/ var CircleShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35203
35239
|
var CircleShape = function CircleShape() {
|
|
35204
35240
|
var _this;
|
|
35205
|
-
_this = BaseShape1.
|
|
35241
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35242
|
+
_this.shapeType = exports.ParticleShapeType.Circle;
|
|
35206
35243
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35207
35244
|
/** Angle of the circle arc to emit particles from. */ _this.arc = 360.0;
|
|
35208
35245
|
/** The mode to generate particles around the arc. */ _this.arcMode = exports.ParticleShapeArcMode.Random;
|
|
35209
35246
|
/** The speed of complete 360 degree rotation. */ _this.arcSpeed = 1.0;
|
|
35210
|
-
_this.shapeType = ParticleShapeType.Circle;
|
|
35211
35247
|
return _this;
|
|
35212
35248
|
};
|
|
35213
35249
|
_inherits$2(CircleShape, BaseShape1);
|
|
@@ -35242,12 +35278,12 @@
|
|
|
35242
35278
|
*/ var ConeShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35243
35279
|
var ConeShape = function ConeShape() {
|
|
35244
35280
|
var _this;
|
|
35245
|
-
_this = BaseShape1.
|
|
35281
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35282
|
+
_this.shapeType = exports.ParticleShapeType.Cone;
|
|
35246
35283
|
/** Angle of the cone to emit particles from. */ _this.angle = 25.0;
|
|
35247
35284
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35248
35285
|
/** Length of the cone to emit particles from. */ _this.length = 5.0;
|
|
35249
35286
|
/** Cone emitter type. */ _this.emitType = /** Emit particles from the base of the cone. */ 0;
|
|
35250
|
-
_this.shapeType = ParticleShapeType.Cone;
|
|
35251
35287
|
return _this;
|
|
35252
35288
|
};
|
|
35253
35289
|
_inherits$2(ConeShape, BaseShape1);
|
|
@@ -35306,9 +35342,9 @@
|
|
|
35306
35342
|
*/ var HemisphereShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35307
35343
|
var HemisphereShape = function HemisphereShape() {
|
|
35308
35344
|
var _this;
|
|
35309
|
-
_this = BaseShape1.
|
|
35345
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35346
|
+
_this.shapeType = exports.ParticleShapeType.Hemisphere;
|
|
35310
35347
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35311
|
-
_this.shapeType = ParticleShapeType.Hemisphere;
|
|
35312
35348
|
return _this;
|
|
35313
35349
|
};
|
|
35314
35350
|
_inherits$2(HemisphereShape, BaseShape1);
|
|
@@ -35330,9 +35366,9 @@
|
|
|
35330
35366
|
*/ var SphereShape = /*#__PURE__*/ function(BaseShape1) {
|
|
35331
35367
|
var SphereShape = function SphereShape() {
|
|
35332
35368
|
var _this;
|
|
35333
|
-
_this = BaseShape1.
|
|
35369
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
35370
|
+
_this.shapeType = exports.ParticleShapeType.Sphere;
|
|
35334
35371
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
35335
|
-
_this.shapeType = ParticleShapeType.Sphere;
|
|
35336
35372
|
return _this;
|
|
35337
35373
|
};
|
|
35338
35374
|
_inherits$2(SphereShape, BaseShape1);
|
|
@@ -35836,6 +35872,7 @@
|
|
|
35836
35872
|
ParticleRenderer: ParticleRenderer,
|
|
35837
35873
|
get ParticleScaleMode () { return exports.ParticleScaleMode; },
|
|
35838
35874
|
get ParticleShapeArcMode () { return exports.ParticleShapeArcMode; },
|
|
35875
|
+
get ParticleShapeType () { return exports.ParticleShapeType; },
|
|
35839
35876
|
get ParticleSimulationSpace () { return exports.ParticleSimulationSpace; },
|
|
35840
35877
|
get ParticleStopMode () { return exports.ParticleStopMode; },
|
|
35841
35878
|
PhysicsMaterial: PhysicsMaterial,
|
|
@@ -38627,8 +38664,7 @@
|
|
|
38627
38664
|
var assetRefId = entityConfig.assetRefId;
|
|
38628
38665
|
var engine = this._context.engine;
|
|
38629
38666
|
if (assetRefId) {
|
|
38630
|
-
return engine.resourceManager
|
|
38631
|
-
.getResourceByRef({
|
|
38667
|
+
return engine.resourceManager.getResourceByRef({
|
|
38632
38668
|
refId: assetRefId,
|
|
38633
38669
|
key: entityConfig.key,
|
|
38634
38670
|
isClone: entityConfig.isClone
|
|
@@ -38658,36 +38694,355 @@
|
|
|
38658
38694
|
(function() {
|
|
38659
38695
|
ReflectionParser.customParseComponentHandles = new Map();
|
|
38660
38696
|
})();
|
|
38661
|
-
|
|
38662
|
-
|
|
38663
|
-
|
|
38664
|
-
|
|
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;
|
|
38665
38986
|
if (children && children.length > 0) {
|
|
38666
|
-
var parent =
|
|
38987
|
+
var parent = entityMap.get(parentId);
|
|
38667
38988
|
for(var i = 0; i < children.length; i++){
|
|
38668
38989
|
var childId = children[i];
|
|
38669
|
-
var entity =
|
|
38990
|
+
var entity = entityMap.get(childId);
|
|
38670
38991
|
parent.addChild(entity);
|
|
38671
|
-
this.
|
|
38992
|
+
this._parseChildren(childId);
|
|
38672
38993
|
}
|
|
38673
38994
|
}
|
|
38674
38995
|
};
|
|
38675
|
-
|
|
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;
|
|
38676
39023
|
}();
|
|
38677
|
-
var
|
|
38678
|
-
|
|
38679
|
-
|
|
38680
|
-
|
|
38681
|
-
|
|
38682
|
-
|
|
38683
|
-
|
|
38684
|
-
|
|
38685
|
-
|
|
38686
|
-
|
|
38687
|
-
|
|
38688
|
-
|
|
38689
|
-
|
|
38690
|
-
|
|
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);
|
|
38691
39046
|
exports.InterpolableValueType = void 0;
|
|
38692
39047
|
(function(InterpolableValueType) {
|
|
38693
39048
|
InterpolableValueType[InterpolableValueType["Float"] = 0] = "Float";
|
|
@@ -38720,7 +39075,7 @@
|
|
|
38720
39075
|
for(var i1 = 0; i1 < curveBindingsLen; ++i1){
|
|
38721
39076
|
var relativePath = bufferReader.nextStr();
|
|
38722
39077
|
var componentStr = bufferReader.nextStr();
|
|
38723
|
-
var componentType =
|
|
39078
|
+
var componentType = Loader.getClass(componentStr);
|
|
38724
39079
|
var property = bufferReader.nextStr();
|
|
38725
39080
|
var getProperty = bufferReader.nextStr();
|
|
38726
39081
|
var curve = void 0;
|
|
@@ -38897,137 +39252,27 @@
|
|
|
38897
39252
|
SpecularMode["Sky"] = "Sky";
|
|
38898
39253
|
SpecularMode["Custom"] = "Custom";
|
|
38899
39254
|
})(exports.SpecularMode || (exports.SpecularMode = {}));
|
|
38900
|
-
function
|
|
38901
|
-
|
|
38902
|
-
|
|
38903
|
-
|
|
38904
|
-
|
|
38905
|
-
|
|
38906
|
-
|
|
38907
|
-
|
|
38908
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
38909
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
38910
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
38911
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
38912
|
-
}
|
|
38913
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
38914
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
38915
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
38916
|
-
// Fallback for engines without symbol support
|
|
38917
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
38918
|
-
if (it) o = it;
|
|
38919
|
-
var i = 0;
|
|
38920
|
-
return function() {
|
|
38921
|
-
if (i >= o.length) return {
|
|
38922
|
-
done: true
|
|
38923
|
-
};
|
|
38924
|
-
return {
|
|
38925
|
-
done: false,
|
|
38926
|
-
value: o[i++]
|
|
38927
|
-
};
|
|
38928
|
-
};
|
|
38929
|
-
}
|
|
38930
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
38931
|
-
}
|
|
38932
|
-
var SceneParserContext = /*#__PURE__*/ function() {
|
|
38933
|
-
var SceneParserContext = function SceneParserContext(originalData, scene) {
|
|
38934
|
-
this.originalData = originalData;
|
|
38935
|
-
this.scene = scene;
|
|
38936
|
-
this.entityMap = new Map();
|
|
38937
|
-
this.components = new Map();
|
|
38938
|
-
this.assets = new Map();
|
|
38939
|
-
this.entityConfigMap = new Map();
|
|
38940
|
-
this.rootIds = [];
|
|
38941
|
-
this.engine = scene.engine;
|
|
38942
|
-
this.resourceManager = scene.engine.resourceManager;
|
|
38943
|
-
};
|
|
38944
|
-
var _proto = SceneParserContext.prototype;
|
|
38945
|
-
_proto.destroy = function destroy() {
|
|
38946
|
-
this.entityMap.clear();
|
|
38947
|
-
this.components.clear();
|
|
38948
|
-
this.assets.clear();
|
|
38949
|
-
this.entityConfigMap.clear();
|
|
38950
|
-
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;
|
|
38951
39263
|
};
|
|
39264
|
+
_inherits(SceneParserContext, ParserContext1);
|
|
38952
39265
|
return SceneParserContext;
|
|
38953
|
-
}();
|
|
38954
|
-
/** @Internal */ var SceneParser = /*#__PURE__*/ function() {
|
|
38955
|
-
var SceneParser = function SceneParser(
|
|
38956
|
-
|
|
38957
|
-
this.context = context;
|
|
38958
|
-
this._engine = context.scene.engine;
|
|
38959
|
-
this._organizeEntities = this._organizeEntities.bind(this);
|
|
38960
|
-
this._parseComponents = this._parseComponents.bind(this);
|
|
38961
|
-
this._clearAndResolveScene = this._clearAndResolveScene.bind(this);
|
|
38962
|
-
this.promise = new Promise(function(resolve, reject) {
|
|
38963
|
-
_this._reject = reject;
|
|
38964
|
-
_this._resolve = resolve;
|
|
38965
|
-
});
|
|
38966
|
-
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);
|
|
38967
39270
|
};
|
|
39271
|
+
_inherits(SceneParser, HierarchyParser1);
|
|
38968
39272
|
var _proto = SceneParser.prototype;
|
|
38969
|
-
|
|
38970
|
-
this.
|
|
38971
|
-
|
|
38972
|
-
_proto._parseEntities = function _parseEntities() {
|
|
38973
|
-
var _this = this;
|
|
38974
|
-
var entitiesConfig = this.context.originalData.entities;
|
|
38975
|
-
var entityConfigMap = this.context.entityConfigMap;
|
|
38976
|
-
var entitiesMap = this.context.entityMap;
|
|
38977
|
-
var rootIds = this.context.rootIds;
|
|
38978
|
-
this._engine;
|
|
38979
|
-
var promises = entitiesConfig.map(function(entityConfig) {
|
|
38980
|
-
entityConfigMap.set(entityConfig.id, entityConfig);
|
|
38981
|
-
// record root entities
|
|
38982
|
-
if (!entityConfig.parent) rootIds.push(entityConfig.id);
|
|
38983
|
-
return _this._reflectionParser.parseEntity(entityConfig);
|
|
38984
|
-
});
|
|
38985
|
-
return Promise.all(promises).then(function(entities) {
|
|
38986
|
-
for(var i = 0, l = entities.length; i < l; i++){
|
|
38987
|
-
entitiesMap.set(entitiesConfig[i].id, entities[i]);
|
|
38988
|
-
}
|
|
38989
|
-
return entities;
|
|
38990
|
-
});
|
|
38991
|
-
};
|
|
38992
|
-
_proto._organizeEntities = function _organizeEntities() {
|
|
38993
|
-
var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap, scene = _this_context.scene, rootIds = _this_context.rootIds;
|
|
38994
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(rootIds), _step; !(_step = _iterator()).done;){
|
|
38995
|
-
var rootId = _step.value;
|
|
38996
|
-
PrefabParser.parseChildren(entityConfigMap, entityMap, rootId);
|
|
38997
|
-
}
|
|
38998
|
-
var rootEntities = rootIds.map(function(id) {
|
|
38999
|
-
return entityMap.get(id);
|
|
39000
|
-
});
|
|
39001
|
-
for(var i = 0; i < rootEntities.length; i++){
|
|
39002
|
-
scene.addRootEntity(rootEntities[i]);
|
|
39003
|
-
}
|
|
39004
|
-
};
|
|
39005
|
-
_proto._parseComponents = function _parseComponents() {
|
|
39006
|
-
var entitiesConfig = this.context.originalData.entities;
|
|
39007
|
-
var entityMap = this.context.entityMap;
|
|
39008
|
-
var promises = [];
|
|
39009
|
-
for(var i = 0, l = entitiesConfig.length; i < l; i++){
|
|
39010
|
-
var entityConfig = entitiesConfig[i];
|
|
39011
|
-
var entity = entityMap.get(entityConfig.id);
|
|
39012
|
-
for(var i1 = 0; i1 < entityConfig.components.length; i1++){
|
|
39013
|
-
var componentConfig = entityConfig.components[i1];
|
|
39014
|
-
var key = !componentConfig.refId ? componentConfig.class : componentConfig.refId;
|
|
39015
|
-
var component = void 0;
|
|
39016
|
-
// TODO: remove hack code when support additional edit
|
|
39017
|
-
if (key === "Animator") {
|
|
39018
|
-
component = entity.getComponent(Loader.getClass(key));
|
|
39019
|
-
}
|
|
39020
|
-
component = component || entity.addComponent(Loader.getClass(key));
|
|
39021
|
-
var promise = this._reflectionParser.parsePropsAndMethods(component, componentConfig);
|
|
39022
|
-
promises.push(promise);
|
|
39023
|
-
}
|
|
39024
|
-
}
|
|
39025
|
-
return Promise.all(promises);
|
|
39026
|
-
};
|
|
39027
|
-
_proto._clearAndResolveScene = function _clearAndResolveScene() {
|
|
39028
|
-
var scene = this.context.scene;
|
|
39029
|
-
this.context.destroy();
|
|
39030
|
-
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));
|
|
39031
39276
|
};
|
|
39032
39277
|
/**
|
|
39033
39278
|
* Parse scene data.
|
|
@@ -39036,13 +39281,13 @@
|
|
|
39036
39281
|
* @returns a promise of scene
|
|
39037
39282
|
*/ SceneParser.parse = function parse(engine, sceneData) {
|
|
39038
39283
|
var scene = new Scene(engine);
|
|
39039
|
-
var context = new SceneParserContext(sceneData, scene);
|
|
39284
|
+
var context = new SceneParserContext(sceneData, engine, scene);
|
|
39040
39285
|
var parser = new SceneParser(context);
|
|
39041
39286
|
parser.start();
|
|
39042
39287
|
return parser.promise;
|
|
39043
39288
|
};
|
|
39044
39289
|
return SceneParser;
|
|
39045
|
-
}();
|
|
39290
|
+
}(HierarchyParser);
|
|
39046
39291
|
exports.MeshLoader = /*#__PURE__*/ function(Loader1) {
|
|
39047
39292
|
var MeshLoader = function MeshLoader() {
|
|
39048
39293
|
return Loader1.apply(this, arguments);
|
|
@@ -39143,7 +39388,7 @@
|
|
|
39143
39388
|
resourceManager // @ts-ignore
|
|
39144
39389
|
.getResourceByRef(value).then(function(asset) {
|
|
39145
39390
|
keyframe.value = asset;
|
|
39146
|
-
resolve(keyframe);
|
|
39391
|
+
resolve(keyframe.value);
|
|
39147
39392
|
});
|
|
39148
39393
|
});
|
|
39149
39394
|
} else {
|
|
@@ -44431,7 +44676,7 @@
|
|
|
44431
44676
|
], KHR_materials_anisotropy);
|
|
44432
44677
|
|
|
44433
44678
|
//@ts-ignore
|
|
44434
|
-
var version = "1.2.0-alpha.
|
|
44679
|
+
var version = "1.2.0-alpha.5";
|
|
44435
44680
|
console.log("Galacean engine version: " + version);
|
|
44436
44681
|
for(var key in CoreObjects){
|
|
44437
44682
|
Loader.registerClass(key, CoreObjects[key]);
|
|
@@ -44479,7 +44724,6 @@
|
|
|
44479
44724
|
exports.Color = Color;
|
|
44480
44725
|
exports.ColorOverLifetimeModule = ColorOverLifetimeModule;
|
|
44481
44726
|
exports.Component = Component;
|
|
44482
|
-
exports.ComponentMap = ComponentMap;
|
|
44483
44727
|
exports.ConeShape = ConeShape;
|
|
44484
44728
|
exports.ContentRestorer = ContentRestorer;
|
|
44485
44729
|
exports.CubeProbe = CubeProbe;
|
|
@@ -44523,6 +44767,7 @@
|
|
|
44523
44767
|
exports.PBRBaseMaterial = PBRBaseMaterial;
|
|
44524
44768
|
exports.PBRMaterial = PBRMaterial;
|
|
44525
44769
|
exports.PBRSpecularMaterial = PBRSpecularMaterial;
|
|
44770
|
+
exports.ParserContext = ParserContext;
|
|
44526
44771
|
exports.ParticleCompositeCurve = ParticleCompositeCurve;
|
|
44527
44772
|
exports.ParticleCompositeGradient = ParticleCompositeGradient;
|
|
44528
44773
|
exports.ParticleCurve = ParticleCurve;
|