@galacean/effects-core 2.0.0-alpha.27 → 2.0.0-alpha.28

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/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.0.0-alpha.27
6
+ * Version: v2.0.0-alpha.28
7
7
  */
8
8
 
9
9
  'use strict';
@@ -444,16 +444,27 @@ function isIOS() {
444
444
  // real ios device not in simulator
445
445
  return !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
446
446
  }
447
+ function isIOSByUA() {
448
+ var str = navigator.userAgent.toLowerCase();
449
+ var ver = str.match(/cpu (iphone )?os (.*?) like mac os/);
450
+ return ver ? parseInt(ver[2], 10) : 0;
451
+ }
447
452
  function isAndroid() {
448
453
  return /\b[Aa]ndroid\b/.test(navigator.userAgent);
449
454
  }
450
455
  function isSimulatorCellPhone() {
451
456
  return isAndroid() || /\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent);
452
457
  }
458
+ function isMiniProgram() {
459
+ return isAlipayMiniApp() || isWechatMiniApp();
460
+ }
453
461
  function isAlipayMiniApp() {
454
462
  var _my;
455
463
  return typeof my !== "undefined" && ((_my = my) == null ? void 0 : _my.renderTarget) === "web";
456
464
  }
465
+ function isWechatMiniApp() {
466
+ return window.__wxjs_environment === "miniprogram";
467
+ }
457
468
 
458
469
  function imageDataFromColor(value) {
459
470
  if (isString(value)) {
@@ -8133,31 +8144,35 @@ function deserializeMipmapTexture(textureOptions, bins, engine) {
8133
8144
  }
8134
8145
  function _deserializeMipmapTexture() {
8135
8146
  _deserializeMipmapTexture = _async_to_generator(function(textureOptions, bins, engine, files) {
8136
- var mipmaps, target, loadedMipmaps, _iterator, _step, level, newLevel, _iterator1, _step1, face, loadedImageAsset, mipmaps1, target1, jobs, loadedMipmaps1, bin;
8147
+ var mipmaps, target, jobs, loadedMipmaps, mipmaps1, target1, jobs1, loadedMipmaps1, bin;
8137
8148
  return __generator(this, function(_state) {
8138
8149
  switch(_state.label){
8139
8150
  case 0:
8140
8151
  if (files === void 0) files = [];
8141
8152
  if (!(textureOptions.target === 34067)) return [
8142
8153
  3,
8143
- 1
8154
+ 2
8144
8155
  ];
8145
8156
  mipmaps = textureOptions.mipmaps, target = textureOptions.target;
8146
- // const jobs = mipmaps.map(mipmap => Promise.all(mipmap.map(pointer => loadMipmapImage(pointer, bins))));
8147
- loadedMipmaps = [];
8148
- for(_iterator = _create_for_of_iterator_helper_loose(mipmaps); !(_step = _iterator()).done;){
8149
- level = _step.value;
8150
- newLevel = [];
8151
- for(_iterator1 = _create_for_of_iterator_helper_loose(level); !(_step1 = _iterator1()).done;){
8152
- face = _step1.value;
8153
- // @ts-expect-error
8154
- loadedImageAsset = engine.assetLoader.loadGUID(face.id);
8157
+ jobs = mipmaps.map(function(mipmap) {
8158
+ return Promise.all(mipmap.map(function(pointer) {
8155
8159
  // @ts-expect-error
8156
- newLevel.push(loadedImageAsset.data);
8157
- }
8158
- loadedMipmaps.push(newLevel);
8159
- }
8160
- // const bin = files[mipmaps[0][0][1][0]].url;
8160
+ if (pointer.id) {
8161
+ // @ts-expect-error
8162
+ var loadedImageAsset = engine.assetLoader.loadGUID(pointer.id);
8163
+ // @ts-expect-error
8164
+ return loadedImageAsset.data;
8165
+ } else {
8166
+ return loadMipmapImage(pointer, bins);
8167
+ }
8168
+ }));
8169
+ });
8170
+ return [
8171
+ 4,
8172
+ Promise.all(jobs)
8173
+ ];
8174
+ case 1:
8175
+ loadedMipmaps = _state.sent();
8161
8176
  return [
8162
8177
  2,
8163
8178
  _extends({
@@ -8171,17 +8186,17 @@ function _deserializeMipmapTexture() {
8171
8186
  }
8172
8187
  })
8173
8188
  ];
8174
- case 1:
8189
+ case 2:
8175
8190
  // TODO: 补充测试用例
8176
8191
  mipmaps1 = textureOptions.mipmaps, target1 = textureOptions.target;
8177
- jobs = mipmaps1.map(function(pointer) {
8192
+ jobs1 = mipmaps1.map(function(pointer) {
8178
8193
  return loadMipmapImage(pointer, bins);
8179
8194
  });
8180
8195
  return [
8181
8196
  4,
8182
- Promise.all(jobs)
8197
+ Promise.all(jobs1)
8183
8198
  ];
8184
- case 2:
8199
+ case 3:
8185
8200
  loadedMipmaps1 = _state.sent();
8186
8201
  bin = files[mipmaps1[0][1][0]].url;
8187
8202
  return [
@@ -8204,7 +8219,7 @@ function _deserializeMipmapTexture() {
8204
8219
  }
8205
8220
  })
8206
8221
  ];
8207
- case 3:
8222
+ case 4:
8208
8223
  return [
8209
8224
  2
8210
8225
  ];
@@ -11559,7 +11574,7 @@ var valueDefine = "#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValu
11559
11574
 
11560
11575
  var screenMeshVert = "precision highp float;attribute vec2 aPos;varying vec2 uv;void main(){gl_Position=vec4(aPos,0.,1.0);uv=(aPos+vec2(1.0))/2.;}";
11561
11576
 
11562
- var colorGradingFrag = "precision highp float;\n#define HALF_MAX 60000.0\n#define ACEScc_MIDGRAY 0.4135884\nvarying vec2 uv;uniform sampler2D _GaussianTex;uniform sampler2D _SceneTex;uniform float _BloomIntensity;uniform float _Brightness;uniform float _Saturation;uniform float _Contrast;uniform bool _UseBloom;uniform bool _UseToneMapping;uniform vec3 _VignetteColor;uniform vec2 _VignetteCenter;uniform float _VignetteIntensity;uniform float _VignetteSmoothness;uniform float _VignetteRoundness;mat3 LinearToACES=mat3(0.59719,0.07600,0.02840,0.35458,0.90834,0.13383,0.04823,0.01566,0.83777);mat3 ACESToLinear=mat3(1.60475,-0.10208,-0.00327,-0.53108,1.10813,-0.07276,-0.07367,-0.00605,1.07602);float log10(float x){return log(x)/log(10.0);}vec3 log10(vec3 v){return vec3(log10(v.x),log10(v.y),log10(v.z));}vec3 LinearToLogC(vec3 x){return 0.244161*log10(5.555556*x+0.047996)+0.386036;}vec3 LogCToLinear(vec3 x){return(pow(vec3(10.0),(x-0.386036)/0.244161)-0.047996)/5.555556;}vec3 rrt_and_odt_fit(vec3 col){vec3 a=col*(col+0.0245786)-0.000090537;vec3 b=col*(0.983729*col+0.4329510)+0.238081;return a/b;}vec3 ACESToneMapping(vec3 col){vec3 aces=LinearToACES*col;aces=rrt_and_odt_fit(aces);col=ACESToLinear*aces;return col;}vec3 LinearToSrgb(vec3 c){return mix(1.055*pow(c,vec3(1./2.4))-0.055,12.92*c,step(c,vec3(0.0031308)));}vec3 GammaCorrection(vec3 c){return pow(c,vec3(1.0/2.2));}vec3 ApplyVignette(vec3 inputColor,vec2 uv,vec2 center,float intensity,float roundness,float smoothness,vec3 color){vec2 dist=abs(uv-center)*intensity;dist.x*=roundness;float vfactor=pow(clamp((1.0-dot(dist,dist)),0.0,1.0),smoothness);return inputColor*mix(color,vec3(1.0),vfactor);}void main(){vec4 hdrColor=texture2D(_SceneTex,uv);hdrColor.rgb=pow(hdrColor.rgb,vec3(2.2));vec3 finalColor=hdrColor.rgb;if(_UseBloom){vec4 bloomColor=texture2D(_GaussianTex,uv);bloomColor.rgb*=_BloomIntensity;finalColor+=bloomColor.rgb;}if(_VignetteIntensity>0.0){finalColor=ApplyVignette(finalColor,uv,_VignetteCenter,_VignetteIntensity,_VignetteRoundness,_VignetteSmoothness,_VignetteColor);}finalColor=finalColor*_Brightness;vec3 colorLog=LinearToLogC(finalColor);colorLog=(colorLog-ACEScc_MIDGRAY)*_Contrast+ACEScc_MIDGRAY;finalColor=LogCToLinear(colorLog);finalColor=max(finalColor,0.0);float luminance=0.2125*finalColor.r+0.7154*finalColor.g+0.0721*finalColor.b;vec3 luminanceColor=vec3(luminance,luminance,luminance);finalColor=(finalColor-luminanceColor)*_Saturation+luminanceColor;finalColor=max(finalColor,0.0);if(_UseToneMapping){finalColor=max(vec3(0.0),ACESToneMapping(finalColor));}gl_FragColor=vec4(clamp(GammaCorrection(finalColor),0.0,1.0),1.0);}";
11577
+ var colorGradingFrag = "precision highp float;\n#define HALF_MAX 60000.0\n#define ACEScc_MIDGRAY 0.4135884\nvarying vec2 uv;uniform sampler2D _GaussianTex;uniform sampler2D _SceneTex;uniform float _BloomIntensity;uniform float _Brightness;uniform float _Saturation;uniform float _Contrast;uniform bool _UseBloom;uniform bool _UseToneMapping;uniform vec3 _VignetteColor;uniform vec2 _VignetteCenter;uniform float _VignetteIntensity;uniform float _VignetteSmoothness;uniform float _VignetteRoundness;mat3 LinearToACES=mat3(0.59719,0.07600,0.02840,0.35458,0.90834,0.13383,0.04823,0.01566,0.83777);mat3 ACESToLinear=mat3(1.60475,-0.10208,-0.00327,-0.53108,1.10813,-0.07276,-0.07367,-0.00605,1.07602);float log10(float x){return log(x)/log(10.0);}vec3 log10(vec3 v){return vec3(log10(v.x),log10(v.y),log10(v.z));}vec3 LinearToLogC(vec3 x){return 0.244161*log10(5.555556*x+0.047996)+0.386036;}vec3 LogCToLinear(vec3 x){return(pow(vec3(10.0),(x-0.386036)/0.244161)-0.047996)/5.555556;}vec3 rrt_and_odt_fit(vec3 col){vec3 a=col*(col+0.0245786)-0.000090537;vec3 b=col*(0.983729*col+0.4329510)+0.238081;return a/b;}vec3 ACESToneMapping(vec3 col){vec3 aces=LinearToACES*col;aces=rrt_and_odt_fit(aces);col=ACESToLinear*aces;return col;}vec3 LinearToSrgb(vec3 c){return mix(1.055*pow(c,vec3(1./2.4))-0.055,12.92*c,step(c,vec3(0.0031308)));}vec3 GammaCorrection(vec3 c){return pow(c,vec3(1.0/2.2));}vec3 ApplyVignette(vec3 inputColor,vec2 uv,vec2 center,float intensity,float roundness,float smoothness,vec3 color){vec2 dist=abs(uv-center)*intensity;dist.x*=roundness;float vfactor=pow(clamp((1.0-dot(dist,dist)),0.0,1.0),smoothness);return inputColor*mix(color,vec3(1.0),vfactor);}void main(){vec4 hdrColor=texture2D(_SceneTex,uv);hdrColor*=hdrColor.a;hdrColor.rgb=pow(hdrColor.rgb,vec3(2.2));vec3 finalColor=hdrColor.rgb;if(_UseBloom){vec4 bloomColor=texture2D(_GaussianTex,uv);bloomColor.rgb*=_BloomIntensity;finalColor+=bloomColor.rgb;}if(_VignetteIntensity>0.0){finalColor=ApplyVignette(finalColor,uv,_VignetteCenter,_VignetteIntensity,_VignetteRoundness,_VignetteSmoothness,_VignetteColor);}finalColor=finalColor*_Brightness;vec3 colorLog=LinearToLogC(finalColor);colorLog=(colorLog-ACEScc_MIDGRAY)*_Contrast+ACEScc_MIDGRAY;finalColor=LogCToLinear(colorLog);finalColor=max(finalColor,0.0);float luminance=0.2125*finalColor.r+0.7154*finalColor.g+0.0721*finalColor.b;vec3 luminanceColor=vec3(luminance,luminance,luminance);finalColor=(finalColor-luminanceColor)*_Saturation+luminanceColor;finalColor=max(finalColor,0.0);if(_UseToneMapping){finalColor=max(vec3(0.0),ACESToneMapping(finalColor));}gl_FragColor=vec4(clamp(GammaCorrection(finalColor),0.0,1.0),1.0);}";
11563
11578
 
11564
11579
  var gaussianDown_frag = "precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform vec2 _TextureSize;float GaussWeight2D(float x,float y,float sigma){float PI=3.14159265358;float E=2.71828182846;float sigma_2=pow(sigma,2.0);float a=-(x*x+y*y)/(2.0*sigma_2);return pow(E,a)/(2.0*PI*sigma_2);}vec3 GaussNxN(sampler2D tex,vec2 uv,vec2 stride,float sigma){vec3 color=vec3(0.,0.,0.);const int r=5/2;float weight=0.0;for(int i=-r;i<=r;i++){for(int j=-r;j<=r;j++){float w=GaussWeight2D(float(i),float(j),sigma);vec2 coord=uv+vec2(i,j)*stride;color+=texture2D(tex,coord).rgb*w;weight+=w;}}color/=weight;return color;}void main(){vec4 mainColor=texture2D(_MainTex,uv);vec3 color=mainColor.rgb;color=GaussNxN(_MainTex,uv,1.0/_TextureSize,1.0);gl_FragColor=vec4(color,1.0);}";
11565
11580
 
@@ -11847,7 +11862,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
11847
11862
  this.screenMesh.material.setFloat("_Brightness", brightness);
11848
11863
  this.screenMesh.material.setFloat("_Saturation", saturation);
11849
11864
  this.screenMesh.material.setFloat("_Contrast", contrast);
11850
- this.screenMesh.material.setInt("_UseBloom", useBloom);
11865
+ this.screenMesh.material.setInt("_UseBloom", Number(useBloom));
11851
11866
  if (useBloom) {
11852
11867
  this.screenMesh.material.setTexture("_GaussianTex", this.mainTexture);
11853
11868
  this.screenMesh.material.setFloat("_BloomIntensity", bloomIntensity);
@@ -11859,7 +11874,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
11859
11874
  this.screenMesh.material.setVector2("_VignetteCenter", new Vector2(0.5, 0.5));
11860
11875
  this.screenMesh.material.setVector3("_VignetteColor", new Vector3(0.0, 0.0, 0.0));
11861
11876
  }
11862
- this.screenMesh.material.setInt("_UseToneMapping", useToneMapping);
11877
+ this.screenMesh.material.setInt("_UseToneMapping", Number(useToneMapping));
11863
11878
  renderer.renderMeshes([
11864
11879
  this.screenMesh
11865
11880
  ]);
@@ -11871,9 +11886,8 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
11871
11886
  * 后处理配置
11872
11887
  */ var defaultGlobalVolume = {
11873
11888
  useHDR: false,
11874
- usePostProcessing: false,
11875
11889
  /***** Material Uniform *****/ // Bloom
11876
- useBloom: 1.0,
11890
+ useBloom: true,
11877
11891
  threshold: 1.0,
11878
11892
  bloomIntensity: 1.0,
11879
11893
  // ColorAdjustments
@@ -11887,7 +11901,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
11887
11901
  vignetteSmoothness: 0.4,
11888
11902
  vignetteRoundness: 1.0,
11889
11903
  // ToneMapping
11890
- useToneMapping: 1
11904
+ useToneMapping: true
11891
11905
  };
11892
11906
 
11893
11907
  var RENDER_PASS_NAME_PREFIX = "_effects_default_";
@@ -11956,20 +11970,36 @@ var seed$5 = 1;
11956
11970
  ];
11957
11971
  this.setRenderPasses(renderPasses);
11958
11972
  if (this.globalVolume) {
11959
- var useBloom = this.globalVolume.useBloom;
11960
11973
  var sceneTextureHandle = new RenderTargetHandle(engine); //保存后处理前的屏幕图像
11961
- if (useBloom) {
11962
- var gaussianStep = 7; // 高斯模糊的迭代次数,次数越高模糊范围越大
11963
- var viewport = [
11964
- 0,
11965
- 0,
11966
- this.renderer.getWidth() / 2,
11967
- this.renderer.getHeight() / 2
11968
- ];
11969
- var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
11970
- var textureType1 = this.globalVolume.useHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
11971
- var bloomThresholdPass = new BloomThresholdPass(renderer, {
11972
- name: "BloomThresholdPass",
11974
+ var gaussianStep = 7; // 高斯模糊的迭代次数,次数越高模糊范围越大
11975
+ var viewport = [
11976
+ 0,
11977
+ 0,
11978
+ this.renderer.getWidth() / 2,
11979
+ this.renderer.getHeight() / 2
11980
+ ];
11981
+ var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
11982
+ var textureType1 = this.globalVolume.useHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
11983
+ var bloomThresholdPass = new BloomThresholdPass(renderer, {
11984
+ name: "BloomThresholdPass",
11985
+ attachments: [
11986
+ {
11987
+ texture: {
11988
+ format: glContext.RGBA,
11989
+ type: textureType1,
11990
+ minFilter: glContext.LINEAR,
11991
+ magFilter: glContext.LINEAR
11992
+ }
11993
+ }
11994
+ ]
11995
+ });
11996
+ bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
11997
+ this.addRenderPass(bloomThresholdPass);
11998
+ for(var i = 0; i < gaussianStep; i++){
11999
+ gaussianDownResults[i] = new RenderTargetHandle(engine);
12000
+ var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", {
12001
+ name: "GaussianDownPassH" + i,
12002
+ viewport: viewport,
11973
12003
  attachments: [
11974
12004
  {
11975
12005
  texture: {
@@ -11981,74 +12011,50 @@ var seed$5 = 1;
11981
12011
  }
11982
12012
  ]
11983
12013
  });
11984
- bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
11985
- this.addRenderPass(bloomThresholdPass);
11986
- for(var i = 0; i < gaussianStep; i++){
11987
- gaussianDownResults[i] = new RenderTargetHandle(engine);
11988
- var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", {
11989
- name: "GaussianDownPassH" + i,
11990
- viewport: viewport,
11991
- attachments: [
11992
- {
11993
- texture: {
11994
- format: glContext.RGBA,
11995
- type: textureType1,
11996
- minFilter: glContext.LINEAR,
11997
- magFilter: glContext.LINEAR
11998
- }
11999
- }
12000
- ]
12001
- });
12002
- var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", {
12003
- name: "GaussianDownPassV" + i,
12004
- viewport: viewport,
12005
- attachments: [
12006
- {
12007
- texture: {
12008
- format: glContext.RGBA,
12009
- type: textureType1,
12010
- minFilter: glContext.LINEAR,
12011
- magFilter: glContext.LINEAR
12012
- }
12014
+ var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", {
12015
+ name: "GaussianDownPassV" + i,
12016
+ viewport: viewport,
12017
+ attachments: [
12018
+ {
12019
+ texture: {
12020
+ format: glContext.RGBA,
12021
+ type: textureType1,
12022
+ minFilter: glContext.LINEAR,
12023
+ magFilter: glContext.LINEAR
12013
12024
  }
12014
- ]
12015
- });
12016
- gaussianDownVPass.gaussianResult = gaussianDownResults[i];
12017
- this.addRenderPass(gaussianDownHPass);
12018
- this.addRenderPass(gaussianDownVPass);
12019
- viewport[2] /= 2;
12020
- viewport[3] /= 2;
12021
- // TODO 限制最大迭代
12022
- }
12023
- viewport[2] *= 4;
12024
- viewport[3] *= 4;
12025
- for(var i1 = 0; i1 < gaussianStep - 1; i1++){
12026
- var gaussianUpPass = new HQGaussianUpSamplePass(renderer, {
12027
- name: "GaussianUpPass" + i1,
12028
- viewport: viewport,
12029
- attachments: [
12030
- {
12031
- texture: {
12032
- format: glContext.RGBA,
12033
- type: textureType1,
12034
- minFilter: glContext.LINEAR,
12035
- magFilter: glContext.LINEAR
12036
- }
12025
+ }
12026
+ ]
12027
+ });
12028
+ gaussianDownVPass.gaussianResult = gaussianDownResults[i];
12029
+ this.addRenderPass(gaussianDownHPass);
12030
+ this.addRenderPass(gaussianDownVPass);
12031
+ viewport[2] /= 2;
12032
+ viewport[3] /= 2;
12033
+ // TODO 限制最大迭代
12034
+ }
12035
+ viewport[2] *= 4;
12036
+ viewport[3] *= 4;
12037
+ for(var i1 = 0; i1 < gaussianStep - 1; i1++){
12038
+ var gaussianUpPass = new HQGaussianUpSamplePass(renderer, {
12039
+ name: "GaussianUpPass" + i1,
12040
+ viewport: viewport,
12041
+ attachments: [
12042
+ {
12043
+ texture: {
12044
+ format: glContext.RGBA,
12045
+ type: textureType1,
12046
+ minFilter: glContext.LINEAR,
12047
+ magFilter: glContext.LINEAR
12037
12048
  }
12038
- ]
12039
- });
12040
- gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
12041
- this.addRenderPass(gaussianUpPass);
12042
- viewport[2] *= 2;
12043
- viewport[3] *= 2;
12044
- }
12045
- }
12046
- var postProcessPass;
12047
- if (useBloom) {
12048
- postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
12049
- } else {
12050
- postProcessPass = new ToneMappingPass(renderer);
12049
+ }
12050
+ ]
12051
+ });
12052
+ gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
12053
+ this.addRenderPass(gaussianUpPass);
12054
+ viewport[2] *= 2;
12055
+ viewport[3] *= 2;
12051
12056
  }
12057
+ var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
12052
12058
  this.addRenderPass(postProcessPass);
12053
12059
  }
12054
12060
  this.semantics = new SemanticMap(options.semantics);
@@ -13085,6 +13091,7 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13085
13091
  1
13086
13092
  ];
13087
13093
  /** 是否响应点击和拖拽交互事件 */ _this._interactive = true;
13094
+ _this.hasBeenAddedToComposition = false;
13088
13095
  _this.getHitTestParams = function(force) {
13089
13096
  if (!_this.clickable) {
13090
13097
  return;
@@ -13103,7 +13110,6 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13103
13110
  }
13104
13111
  var _proto = InteractComponent.prototype;
13105
13112
  _proto.start = function start() {
13106
- var _this = this;
13107
13113
  var options = this.item.props.content.options;
13108
13114
  var env = this.item.engine.renderer.env;
13109
13115
  var composition = this.item.composition;
@@ -13115,10 +13121,6 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13115
13121
  this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
13116
13122
  }
13117
13123
  }
13118
- composition.addInteractiveItem(this.item, options.type);
13119
- this.item.onEnd = function() {
13120
- return composition.removeInteractiveItem(_this.item, options.type);
13121
- };
13122
13124
  if (options.type === InteractType.DRAG) {
13123
13125
  if (env !== PLAYER_OPTIONS_ENV_EDITOR || options.enableInEditor) {
13124
13126
  composition.event && this.beginDragTarget(options, composition.event);
@@ -13133,6 +13135,11 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13133
13135
  _proto.update = function update(dt) {
13134
13136
  var _this_previewContent;
13135
13137
  (_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.updateMesh();
13138
+ if (!this.hasBeenAddedToComposition && this.item.composition) {
13139
+ var options = this.item.props.content.options;
13140
+ this.item.composition.addInteractiveItem(this.item, options.type);
13141
+ this.hasBeenAddedToComposition = true;
13142
+ }
13136
13143
  if (!this.dragEvent || !this.bouncingArg) {
13137
13144
  return;
13138
13145
  }
@@ -14856,8 +14863,7 @@ var RectangleEdge = /*#__PURE__*/ function() {
14856
14863
  }();
14857
14864
  var Edge = /*#__PURE__*/ function() {
14858
14865
  function Edge(args) {
14859
- // TODO: 为通过帧对比暂时使用老计算,修复粒子发射器直线宽度问题下面一行改为: this._d = args.width || 1 ;
14860
- this._d = (args.width || 1) / 2;
14866
+ this._d = args.width || 1;
14861
14867
  this.arcMode = args.arcMode;
14862
14868
  }
14863
14869
  var _proto = Edge.prototype;
@@ -20182,6 +20188,105 @@ function geometryToTriangles(geometry) {
20182
20188
  return res;
20183
20189
  }
20184
20190
 
20191
+ exports.PostProcessVolume = /*#__PURE__*/ function(ItemBehaviour) {
20192
+ _inherits(PostProcessVolume, ItemBehaviour);
20193
+ function PostProcessVolume() {
20194
+ var _this;
20195
+ _this = ItemBehaviour.apply(this, arguments) || this;
20196
+ _this.useHDR = true;
20197
+ // Bloom
20198
+ _this.useBloom = true;
20199
+ _this.threshold = 1.0;
20200
+ _this.bloomIntensity = 1.0;
20201
+ // ColorAdjustments
20202
+ _this.brightness = 1.0;
20203
+ _this.saturation = 1.0;
20204
+ _this.contrast = 1.0;
20205
+ // Vignette
20206
+ _this.vignetteIntensity = 0.2;
20207
+ _this.vignetteSmoothness = 0.4;
20208
+ _this.vignetteRoundness = 1.0;
20209
+ // ToneMapping
20210
+ _this.useToneMapping = true // 1: true, 0: false
20211
+ ;
20212
+ return _this;
20213
+ }
20214
+ var _proto = PostProcessVolume.prototype;
20215
+ _proto.start = function start() {
20216
+ var composition = this.item.composition;
20217
+ if (composition) {
20218
+ composition.globalVolume = {
20219
+ useHDR: this.useHDR,
20220
+ useBloom: this.useBloom,
20221
+ threshold: this.threshold,
20222
+ bloomIntensity: this.bloomIntensity,
20223
+ brightness: this.brightness,
20224
+ saturation: this.saturation,
20225
+ contrast: this.contrast,
20226
+ vignetteIntensity: this.vignetteIntensity,
20227
+ vignetteSmoothness: this.vignetteSmoothness,
20228
+ vignetteRoundness: this.vignetteRoundness,
20229
+ useToneMapping: this.useToneMapping
20230
+ };
20231
+ composition.createRenderFrame();
20232
+ }
20233
+ };
20234
+ _proto.update = function update(dt) {
20235
+ var composition = this.item.composition;
20236
+ if (composition) {
20237
+ var globalVolume = composition.renderFrame.globalVolume;
20238
+ globalVolume.useHDR = this.useHDR;
20239
+ globalVolume.useBloom = this.useBloom;
20240
+ globalVolume.threshold = this.threshold;
20241
+ globalVolume.bloomIntensity = this.bloomIntensity;
20242
+ globalVolume.brightness = this.brightness;
20243
+ globalVolume.saturation = this.saturation;
20244
+ globalVolume.contrast = this.contrast;
20245
+ globalVolume.vignetteIntensity = this.vignetteIntensity;
20246
+ globalVolume.vignetteSmoothness = this.vignetteSmoothness;
20247
+ globalVolume.vignetteRoundness = this.vignetteRoundness;
20248
+ globalVolume.useToneMapping = this.useToneMapping;
20249
+ }
20250
+ };
20251
+ return PostProcessVolume;
20252
+ }(ItemBehaviour);
20253
+ __decorate([
20254
+ serialize()
20255
+ ], exports.PostProcessVolume.prototype, "useHDR", void 0);
20256
+ __decorate([
20257
+ serialize()
20258
+ ], exports.PostProcessVolume.prototype, "useBloom", void 0);
20259
+ __decorate([
20260
+ serialize()
20261
+ ], exports.PostProcessVolume.prototype, "threshold", void 0);
20262
+ __decorate([
20263
+ serialize()
20264
+ ], exports.PostProcessVolume.prototype, "bloomIntensity", void 0);
20265
+ __decorate([
20266
+ serialize()
20267
+ ], exports.PostProcessVolume.prototype, "brightness", void 0);
20268
+ __decorate([
20269
+ serialize()
20270
+ ], exports.PostProcessVolume.prototype, "saturation", void 0);
20271
+ __decorate([
20272
+ serialize()
20273
+ ], exports.PostProcessVolume.prototype, "contrast", void 0);
20274
+ __decorate([
20275
+ serialize()
20276
+ ], exports.PostProcessVolume.prototype, "vignetteIntensity", void 0);
20277
+ __decorate([
20278
+ serialize()
20279
+ ], exports.PostProcessVolume.prototype, "vignetteSmoothness", void 0);
20280
+ __decorate([
20281
+ serialize()
20282
+ ], exports.PostProcessVolume.prototype, "vignetteRoundness", void 0);
20283
+ __decorate([
20284
+ serialize()
20285
+ ], exports.PostProcessVolume.prototype, "useToneMapping", void 0);
20286
+ exports.PostProcessVolume = __decorate([
20287
+ effectsClass("PostProcessVolume")
20288
+ ], exports.PostProcessVolume);
20289
+
20185
20290
  exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
20186
20291
  _inherits(VFXItem, EffectsObject);
20187
20292
  function VFXItem(engine, props) {
@@ -20405,7 +20510,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
20405
20510
  /**
20406
20511
  * 获取元素用于计算光线投射的面片类型和参数
20407
20512
  * @override
20408
- * @param force 元素没有开启交互也返回参数
20513
+ * @param force - 元素没有开启交互也返回参数
20409
20514
  */ _proto.getHitTestParams = function getHitTestParams(force) {
20410
20515
  // OVERRIDE
20411
20516
  };
@@ -20655,42 +20760,6 @@ exports.Item = void 0;
20655
20760
  }
20656
20761
  Item.isNull = isNull;
20657
20762
  })(exports.Item || (exports.Item = {}));
20658
- /**
20659
- * (待废弃) 根据元素的类型创建对应的 `VFXItem` 实例
20660
- * @param props
20661
- * @param composition
20662
- */ function createVFXItem(props, composition) {
20663
- var type = props.type;
20664
- var pluginName = props.pluginName;
20665
- if (!pluginName) {
20666
- switch(type){
20667
- case ItemType.null:
20668
- pluginName = "cal";
20669
- break;
20670
- case ItemType.sprite:
20671
- pluginName = "sprite";
20672
- break;
20673
- case ItemType.particle:
20674
- pluginName = "particle";
20675
- break;
20676
- case ItemType.interact:
20677
- pluginName = "interact";
20678
- break;
20679
- case ItemType.camera:
20680
- pluginName = "camera";
20681
- break;
20682
- case ItemType.text:
20683
- pluginName = "text";
20684
- break;
20685
- case ItemType.tree:
20686
- pluginName = "tree";
20687
- break;
20688
- default:
20689
- throw new Error("Invalid vfx item type.");
20690
- }
20691
- }
20692
- return composition.pluginSystem.createPluginItem(pluginName, props, composition);
20693
- }
20694
20763
 
20695
20764
  var pluginLoaderMap = {};
20696
20765
  var defaultPlugins = [];
@@ -20703,6 +20772,9 @@ var pluginCtrlMap = {};
20703
20772
  * @param isDefault load
20704
20773
  */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20705
20774
  function registerPlugin(name, pluginClass, itemClass, isDefault) {
20775
+ if (pluginCtrlMap[name]) {
20776
+ logger.error("Duplicate registration for plugin " + name + ".");
20777
+ }
20706
20778
  pluginCtrlMap[name] = itemClass;
20707
20779
  pluginLoaderMap[name] = pluginClass;
20708
20780
  if (isDefault) {
@@ -21281,8 +21353,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
21281
21353
  if (this.engine.objectInstance[guid]) {
21282
21354
  return this.engine.objectInstance[guid];
21283
21355
  }
21284
- var effectsObject;
21285
21356
  var effectsObjectData = this.findData(guid);
21357
+ var effectsObject;
21286
21358
  if (!effectsObjectData) {
21287
21359
  console.error("Object data with uuid: " + guid + " not found.");
21288
21360
  return undefined;
@@ -21318,7 +21390,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
21318
21390
  _proto.loadGUIDAsync = function loadGUIDAsync(guid) {
21319
21391
  var _this = this;
21320
21392
  return _async_to_generator(function() {
21321
- var effectsObject, effectsObjectData, classConstructor;
21393
+ var effectsObjectData, effectsObject, classConstructor;
21322
21394
  return __generator(this, function(_state) {
21323
21395
  switch(_state.label){
21324
21396
  case 0:
@@ -23583,14 +23655,6 @@ var seed = 1;
23583
23655
  case 0:
23584
23656
  // TODO: 后面切换到新的数据版本,就不用掉用 getStandardJSON 做转换了
23585
23657
  jsonScene = getStandardJSON(json);
23586
- // FIXME: hack globalVolume,specification 更新后需移除
23587
- // @ts-expect-error
23588
- json.compositions.forEach(function(composition, i) {
23589
- if (composition.globalVolume) {
23590
- // @ts-expect-error
23591
- jsonScene.compositions[i].globalVolume = composition.globalVolume;
23592
- }
23593
- });
23594
23658
  _jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
23595
23659
  pluginSystem = new PluginSystem(plugins);
23596
23660
  return [
@@ -24378,9 +24442,7 @@ var listOrder = 0;
24378
24442
  }
24379
24443
  var _proto = CompositionSourceManager.prototype;
24380
24444
  _proto.getContent = function getContent(composition) {
24381
- // TODO: specification 中补充 globalVolume 类型
24382
- // @ts-expect-error
24383
- var id = composition.id, duration = composition.duration, name = composition.name, endBehavior = composition.endBehavior, camera = composition.camera, globalVolume = composition.globalVolume, _composition_startTime = composition.startTime, startTime = _composition_startTime === void 0 ? 0 : _composition_startTime;
24445
+ var id = composition.id, duration = composition.duration, name = composition.name, endBehavior = composition.endBehavior, camera = composition.camera, _composition_startTime = composition.startTime, startTime = _composition_startTime === void 0 ? 0 : _composition_startTime;
24384
24446
  var items = this.assembleItems(composition);
24385
24447
  return _extends({}, composition, {
24386
24448
  id: id,
@@ -24390,8 +24452,7 @@ var listOrder = 0;
24390
24452
  // looping,
24391
24453
  items: items,
24392
24454
  camera: camera,
24393
- startTime: startTime,
24394
- globalVolume: globalVolume
24455
+ startTime: startTime
24395
24456
  });
24396
24457
  };
24397
24458
  _proto.assembleItems = function assembleItems(composition) {
@@ -24553,7 +24614,6 @@ var listOrder = 0;
24553
24614
  this.rootComposition = this.rootItem.addComponent(CompositionComponent);
24554
24615
  this.rootComposition.data = sourceContent;
24555
24616
  var imageUsage = !reusable && imgUsage;
24556
- this.globalVolume = sourceContent.globalVolume;
24557
24617
  this.width = width;
24558
24618
  this.height = height;
24559
24619
  this.renderOrder = baseRenderOrder;
@@ -26758,7 +26818,10 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
26758
26818
  return FBGeometryDataT;
26759
26819
  }();
26760
26820
 
26761
- var EffectsPackage = /*#__PURE__*/ function() {
26821
+ /**
26822
+ * @since 2.0.0
26823
+ * @internal
26824
+ */ var EffectsPackage = /*#__PURE__*/ function() {
26762
26825
  function EffectsPackage() {
26763
26826
  this.exportObjectDatas = [];
26764
26827
  }
@@ -26783,8 +26846,7 @@ var EffectsPackage = /*#__PURE__*/ function() {
26783
26846
  }
26784
26847
  effectsPackage.exportObjects = exportObjects;
26785
26848
  FBEffectsPackageData.finishFBEffectsPackageDataBuffer(fbb, effectsPackage.pack(fbb));
26786
- var buffer = fbb.asUint8Array(); // Of type `Uint8Array`.
26787
- return buffer;
26849
+ return fbb.asUint8Array(); // Of type `Uint8Array`.
26788
26850
  };
26789
26851
  _proto.deserializeFromBinary = function deserializeFromBinary(buffer) {
26790
26852
  var buf = new ByteBuffer(buffer);
@@ -26812,37 +26874,35 @@ var EffectsPackage = /*#__PURE__*/ function() {
26812
26874
  _proto.geometryDataToBinary = function geometryDataToBinary(geometryData) {
26813
26875
  var fbb = new Builder(1);
26814
26876
  var fbGeometryData = new FBGeometryDataT();
26815
- fbGeometryData.indexFormat = geometryData.indexFormat;
26816
- fbGeometryData.indexOffset = geometryData.indexOffset;
26817
- fbGeometryData.mode = geometryData.mode;
26818
- fbGeometryData.id = geometryData.id;
26819
- var _geometryData_boneNames;
26820
- fbGeometryData.boneNames = (_geometryData_boneNames = geometryData.boneNames) != null ? _geometryData_boneNames : [];
26821
- var _geometryData_rootBoneName;
26822
- fbGeometryData.rootBoneName = (_geometryData_rootBoneName = geometryData.rootBoneName) != null ? _geometryData_rootBoneName : "";
26823
- var _geometryData_inverseBindMatrices;
26824
- fbGeometryData.inverseBindMatrices = (_geometryData_inverseBindMatrices = geometryData.inverseBindMatrices) != null ? _geometryData_inverseBindMatrices : [];
26825
- var _geometryData_binaryData;
26826
- fbGeometryData.binaryData = (_geometryData_binaryData = geometryData.binaryData) != null ? _geometryData_binaryData : [];
26877
+ var indexFormat = geometryData.indexFormat, indexOffset = geometryData.indexOffset, mode = geometryData.mode, id = geometryData.id, vertexData = geometryData.vertexData, _geometryData_boneNames = geometryData.boneNames, boneNames = _geometryData_boneNames === void 0 ? [] : _geometryData_boneNames, _geometryData_rootBoneName = geometryData.rootBoneName, rootBoneName = _geometryData_rootBoneName === void 0 ? "" : _geometryData_rootBoneName, _geometryData_inverseBindMatrices = geometryData.inverseBindMatrices, inverseBindMatrices = _geometryData_inverseBindMatrices === void 0 ? [] : _geometryData_inverseBindMatrices, _geometryData_binaryData = geometryData.binaryData, binaryData = _geometryData_binaryData === void 0 ? [] : _geometryData_binaryData;
26878
+ fbGeometryData.indexFormat = indexFormat;
26879
+ fbGeometryData.indexOffset = indexOffset;
26880
+ fbGeometryData.mode = mode;
26881
+ fbGeometryData.id = id;
26882
+ fbGeometryData.boneNames = boneNames;
26883
+ fbGeometryData.rootBoneName = rootBoneName;
26884
+ fbGeometryData.inverseBindMatrices = inverseBindMatrices;
26885
+ fbGeometryData.binaryData = binaryData;
26827
26886
  var fbVertexdata = new FBVertexDataT();
26828
- fbVertexdata.vertexCount = geometryData.vertexData.vertexCount;
26887
+ fbVertexdata.vertexCount = vertexData.vertexCount;
26829
26888
  fbVertexdata.channels = [];
26830
- for(var _iterator = _create_for_of_iterator_helper_loose(geometryData.vertexData.channels), _step; !(_step = _iterator()).done;){
26889
+ for(var _iterator = _create_for_of_iterator_helper_loose(vertexData.channels), _step; !(_step = _iterator()).done;){
26831
26890
  var channel = _step.value;
26832
- var fbChannel = new FBVertexChannelT(channel.semantic, channel.offset, channel.format, channel.dimension, channel.normalize);
26891
+ var semantic = channel.semantic, offset = channel.offset, format = channel.format, dimension = channel.dimension, normalize = channel.normalize;
26892
+ var fbChannel = new FBVertexChannelT(semantic, offset, format, dimension, normalize);
26833
26893
  fbVertexdata.channels.push(fbChannel);
26834
26894
  }
26835
26895
  fbGeometryData.vertexData = fbVertexdata;
26836
26896
  var fbSubMeshes = [];
26837
26897
  for(var _iterator1 = _create_for_of_iterator_helper_loose(geometryData.subMeshes), _step1; !(_step1 = _iterator1()).done;){
26838
26898
  var subMesh = _step1.value;
26839
- var fbSubMesh = new FBSubMeshT(subMesh.offset, subMesh.indexCount, subMesh.vertexCount);
26899
+ var offset1 = subMesh.offset, indexCount = subMesh.indexCount, vertexCount = subMesh.vertexCount;
26900
+ var fbSubMesh = new FBSubMeshT(offset1, indexCount, vertexCount);
26840
26901
  fbSubMeshes.push(fbSubMesh);
26841
26902
  }
26842
26903
  fbGeometryData.subMeshes = fbSubMeshes;
26843
26904
  FBEffectsPackageData.finishFBEffectsPackageDataBuffer(fbb, fbGeometryData.pack(fbb));
26844
- var buffer = fbb.asUint8Array(); // Of type `Uint8Array`.
26845
- return buffer;
26905
+ return fbb.asUint8Array(); // Of type `Uint8Array`.
26846
26906
  };
26847
26907
  _proto.binaryToGeometryData = function binaryToGeometryData(buffer) {
26848
26908
  var buf = new ByteBuffer(buffer);
@@ -26864,7 +26924,8 @@ var EffectsPackage = /*#__PURE__*/ function() {
26864
26924
  semantic: (_channel_semantic = channel.semantic()) != null ? _channel_semantic : "",
26865
26925
  offset: channel.offset(),
26866
26926
  format: channel.format(),
26867
- dimension: channel.dimension()
26927
+ dimension: channel.dimension(),
26928
+ normalize: channel.normalize()
26868
26929
  };
26869
26930
  vertexData.channels.push(vertexChannel);
26870
26931
  }
@@ -26877,7 +26938,8 @@ var EffectsPackage = /*#__PURE__*/ function() {
26877
26938
  }
26878
26939
  var subMesh = {
26879
26940
  offset: fbSubMesh.offset(),
26880
- vertexCount: fbSubMesh.vertexCount()
26941
+ vertexCount: fbSubMesh.vertexCount(),
26942
+ indexCount: fbSubMesh.indexCount()
26881
26943
  };
26882
26944
  subMeshes.push(subMesh);
26883
26945
  }
@@ -27306,7 +27368,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
27306
27368
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
27307
27369
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
27308
27370
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
27309
- var version = "2.0.0-alpha.27";
27371
+ var version = "2.0.0-alpha.28";
27310
27372
  logger.info("Core version: " + version + ".");
27311
27373
 
27312
27374
  exports.AbstractPlugin = AbstractPlugin;
@@ -27429,7 +27491,6 @@ exports.createGLContext = createGLContext;
27429
27491
  exports.createKeyFrameMeta = createKeyFrameMeta;
27430
27492
  exports.createShaderWithMacros = createShaderWithMacros;
27431
27493
  exports.createShape = createShape;
27432
- exports.createVFXItem = createVFXItem;
27433
27494
  exports.createValueGetter = createValueGetter;
27434
27495
  exports.decimalEqual = decimalEqual;
27435
27496
  exports.defaultGlobalVolume = defaultGlobalVolume;
@@ -27485,6 +27546,8 @@ exports.isArray = isArray;
27485
27546
  exports.isCanvas = isCanvas;
27486
27547
  exports.isFunction = isFunction;
27487
27548
  exports.isIOS = isIOS;
27549
+ exports.isIOSByUA = isIOSByUA;
27550
+ exports.isMiniProgram = isMiniProgram;
27488
27551
  exports.isObject = isObject;
27489
27552
  exports.isSceneJSON = isSceneJSON;
27490
27553
  exports.isSceneURL = isSceneURL;
@@ -27495,6 +27558,7 @@ exports.isUniformStruct = isUniformStruct;
27495
27558
  exports.isUniformStructArray = isUniformStructArray;
27496
27559
  exports.isValidFontFamily = isValidFontFamily;
27497
27560
  exports.isWebGL2 = isWebGL2;
27561
+ exports.isWechatMiniApp = isWechatMiniApp;
27498
27562
  exports.itemFrag = itemFrag;
27499
27563
  exports.itemFrameFrag = itemFrameFrag;
27500
27564
  exports.itemVert = itemVert;