@galacean/effects-threejs 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 threejs plugin 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';
@@ -466,16 +466,27 @@ function isIOS() {
466
466
  // real ios device not in simulator
467
467
  return !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
468
468
  }
469
+ function isIOSByUA() {
470
+ var str = navigator.userAgent.toLowerCase();
471
+ var ver = str.match(/cpu (iphone )?os (.*?) like mac os/);
472
+ return ver ? parseInt(ver[2], 10) : 0;
473
+ }
469
474
  function isAndroid() {
470
475
  return /\b[Aa]ndroid\b/.test(navigator.userAgent);
471
476
  }
472
477
  function isSimulatorCellPhone() {
473
478
  return isAndroid() || /\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent);
474
479
  }
480
+ function isMiniProgram() {
481
+ return isAlipayMiniApp() || isWechatMiniApp();
482
+ }
475
483
  function isAlipayMiniApp() {
476
484
  var _my;
477
485
  return typeof my !== "undefined" && ((_my = my) == null ? void 0 : _my.renderTarget) === "web";
478
486
  }
487
+ function isWechatMiniApp() {
488
+ return window.__wxjs_environment === "miniprogram";
489
+ }
479
490
 
480
491
  function imageDataFromColor(value) {
481
492
  if (isString(value)) {
@@ -8155,31 +8166,35 @@ function deserializeMipmapTexture(textureOptions, bins, engine) {
8155
8166
  }
8156
8167
  function _deserializeMipmapTexture() {
8157
8168
  _deserializeMipmapTexture = _async_to_generator(function(textureOptions, bins, engine, files) {
8158
- var mipmaps, target, loadedMipmaps, _iterator, _step, level, newLevel, _iterator1, _step1, face, loadedImageAsset, mipmaps1, target1, jobs, loadedMipmaps1, bin;
8169
+ var mipmaps, target, jobs, loadedMipmaps, mipmaps1, target1, jobs1, loadedMipmaps1, bin;
8159
8170
  return __generator(this, function(_state) {
8160
8171
  switch(_state.label){
8161
8172
  case 0:
8162
8173
  if (files === void 0) files = [];
8163
8174
  if (!(textureOptions.target === 34067)) return [
8164
8175
  3,
8165
- 1
8176
+ 2
8166
8177
  ];
8167
8178
  mipmaps = textureOptions.mipmaps, target = textureOptions.target;
8168
- // const jobs = mipmaps.map(mipmap => Promise.all(mipmap.map(pointer => loadMipmapImage(pointer, bins))));
8169
- loadedMipmaps = [];
8170
- for(_iterator = _create_for_of_iterator_helper_loose(mipmaps); !(_step = _iterator()).done;){
8171
- level = _step.value;
8172
- newLevel = [];
8173
- for(_iterator1 = _create_for_of_iterator_helper_loose(level); !(_step1 = _iterator1()).done;){
8174
- face = _step1.value;
8175
- // @ts-expect-error
8176
- loadedImageAsset = engine.assetLoader.loadGUID(face.id);
8179
+ jobs = mipmaps.map(function(mipmap) {
8180
+ return Promise.all(mipmap.map(function(pointer) {
8177
8181
  // @ts-expect-error
8178
- newLevel.push(loadedImageAsset.data);
8179
- }
8180
- loadedMipmaps.push(newLevel);
8181
- }
8182
- // const bin = files[mipmaps[0][0][1][0]].url;
8182
+ if (pointer.id) {
8183
+ // @ts-expect-error
8184
+ var loadedImageAsset = engine.assetLoader.loadGUID(pointer.id);
8185
+ // @ts-expect-error
8186
+ return loadedImageAsset.data;
8187
+ } else {
8188
+ return loadMipmapImage(pointer, bins);
8189
+ }
8190
+ }));
8191
+ });
8192
+ return [
8193
+ 4,
8194
+ Promise.all(jobs)
8195
+ ];
8196
+ case 1:
8197
+ loadedMipmaps = _state.sent();
8183
8198
  return [
8184
8199
  2,
8185
8200
  _extends({
@@ -8193,17 +8208,17 @@ function _deserializeMipmapTexture() {
8193
8208
  }
8194
8209
  })
8195
8210
  ];
8196
- case 1:
8211
+ case 2:
8197
8212
  // TODO: 补充测试用例
8198
8213
  mipmaps1 = textureOptions.mipmaps, target1 = textureOptions.target;
8199
- jobs = mipmaps1.map(function(pointer) {
8214
+ jobs1 = mipmaps1.map(function(pointer) {
8200
8215
  return loadMipmapImage(pointer, bins);
8201
8216
  });
8202
8217
  return [
8203
8218
  4,
8204
- Promise.all(jobs)
8219
+ Promise.all(jobs1)
8205
8220
  ];
8206
- case 2:
8221
+ case 3:
8207
8222
  loadedMipmaps1 = _state.sent();
8208
8223
  bin = files[mipmaps1[0][1][0]].url;
8209
8224
  return [
@@ -8226,7 +8241,7 @@ function _deserializeMipmapTexture() {
8226
8241
  }
8227
8242
  })
8228
8243
  ];
8229
- case 3:
8244
+ case 4:
8230
8245
  return [
8231
8246
  2
8232
8247
  ];
@@ -11581,7 +11596,7 @@ var valueDefine = "#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValu
11581
11596
 
11582
11597
  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.;}";
11583
11598
 
11584
- 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);}";
11599
+ 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);}";
11585
11600
 
11586
11601
  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);}";
11587
11602
 
@@ -11869,7 +11884,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
11869
11884
  this.screenMesh.material.setFloat("_Brightness", brightness);
11870
11885
  this.screenMesh.material.setFloat("_Saturation", saturation);
11871
11886
  this.screenMesh.material.setFloat("_Contrast", contrast);
11872
- this.screenMesh.material.setInt("_UseBloom", useBloom);
11887
+ this.screenMesh.material.setInt("_UseBloom", Number(useBloom));
11873
11888
  if (useBloom) {
11874
11889
  this.screenMesh.material.setTexture("_GaussianTex", this.mainTexture);
11875
11890
  this.screenMesh.material.setFloat("_BloomIntensity", bloomIntensity);
@@ -11881,7 +11896,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
11881
11896
  this.screenMesh.material.setVector2("_VignetteCenter", new Vector2(0.5, 0.5));
11882
11897
  this.screenMesh.material.setVector3("_VignetteColor", new Vector3(0.0, 0.0, 0.0));
11883
11898
  }
11884
- this.screenMesh.material.setInt("_UseToneMapping", useToneMapping);
11899
+ this.screenMesh.material.setInt("_UseToneMapping", Number(useToneMapping));
11885
11900
  renderer.renderMeshes([
11886
11901
  this.screenMesh
11887
11902
  ]);
@@ -11893,9 +11908,8 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
11893
11908
  * 后处理配置
11894
11909
  */ var defaultGlobalVolume = {
11895
11910
  useHDR: false,
11896
- usePostProcessing: false,
11897
11911
  /***** Material Uniform *****/ // Bloom
11898
- useBloom: 1.0,
11912
+ useBloom: true,
11899
11913
  threshold: 1.0,
11900
11914
  bloomIntensity: 1.0,
11901
11915
  // ColorAdjustments
@@ -11909,7 +11923,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
11909
11923
  vignetteSmoothness: 0.4,
11910
11924
  vignetteRoundness: 1.0,
11911
11925
  // ToneMapping
11912
- useToneMapping: 1
11926
+ useToneMapping: true
11913
11927
  };
11914
11928
 
11915
11929
  var RENDER_PASS_NAME_PREFIX = "_effects_default_";
@@ -11978,20 +11992,36 @@ var seed$6 = 1;
11978
11992
  ];
11979
11993
  this.setRenderPasses(renderPasses);
11980
11994
  if (this.globalVolume) {
11981
- var useBloom = this.globalVolume.useBloom;
11982
11995
  var sceneTextureHandle = new RenderTargetHandle(engine); //保存后处理前的屏幕图像
11983
- if (useBloom) {
11984
- var gaussianStep = 7; // 高斯模糊的迭代次数,次数越高模糊范围越大
11985
- var viewport = [
11986
- 0,
11987
- 0,
11988
- this.renderer.getWidth() / 2,
11989
- this.renderer.getHeight() / 2
11990
- ];
11991
- var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
11992
- var textureType1 = this.globalVolume.useHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
11993
- var bloomThresholdPass = new BloomThresholdPass(renderer, {
11994
- name: "BloomThresholdPass",
11996
+ var gaussianStep = 7; // 高斯模糊的迭代次数,次数越高模糊范围越大
11997
+ var viewport = [
11998
+ 0,
11999
+ 0,
12000
+ this.renderer.getWidth() / 2,
12001
+ this.renderer.getHeight() / 2
12002
+ ];
12003
+ var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
12004
+ var textureType1 = this.globalVolume.useHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
12005
+ var bloomThresholdPass = new BloomThresholdPass(renderer, {
12006
+ name: "BloomThresholdPass",
12007
+ attachments: [
12008
+ {
12009
+ texture: {
12010
+ format: glContext.RGBA,
12011
+ type: textureType1,
12012
+ minFilter: glContext.LINEAR,
12013
+ magFilter: glContext.LINEAR
12014
+ }
12015
+ }
12016
+ ]
12017
+ });
12018
+ bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
12019
+ this.addRenderPass(bloomThresholdPass);
12020
+ for(var i = 0; i < gaussianStep; i++){
12021
+ gaussianDownResults[i] = new RenderTargetHandle(engine);
12022
+ var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", {
12023
+ name: "GaussianDownPassH" + i,
12024
+ viewport: viewport,
11995
12025
  attachments: [
11996
12026
  {
11997
12027
  texture: {
@@ -12003,74 +12033,50 @@ var seed$6 = 1;
12003
12033
  }
12004
12034
  ]
12005
12035
  });
12006
- bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
12007
- this.addRenderPass(bloomThresholdPass);
12008
- for(var i = 0; i < gaussianStep; i++){
12009
- gaussianDownResults[i] = new RenderTargetHandle(engine);
12010
- var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", {
12011
- name: "GaussianDownPassH" + i,
12012
- viewport: viewport,
12013
- attachments: [
12014
- {
12015
- texture: {
12016
- format: glContext.RGBA,
12017
- type: textureType1,
12018
- minFilter: glContext.LINEAR,
12019
- magFilter: glContext.LINEAR
12020
- }
12021
- }
12022
- ]
12023
- });
12024
- var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", {
12025
- name: "GaussianDownPassV" + i,
12026
- viewport: viewport,
12027
- attachments: [
12028
- {
12029
- texture: {
12030
- format: glContext.RGBA,
12031
- type: textureType1,
12032
- minFilter: glContext.LINEAR,
12033
- magFilter: glContext.LINEAR
12034
- }
12036
+ var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", {
12037
+ name: "GaussianDownPassV" + i,
12038
+ viewport: viewport,
12039
+ attachments: [
12040
+ {
12041
+ texture: {
12042
+ format: glContext.RGBA,
12043
+ type: textureType1,
12044
+ minFilter: glContext.LINEAR,
12045
+ magFilter: glContext.LINEAR
12035
12046
  }
12036
- ]
12037
- });
12038
- gaussianDownVPass.gaussianResult = gaussianDownResults[i];
12039
- this.addRenderPass(gaussianDownHPass);
12040
- this.addRenderPass(gaussianDownVPass);
12041
- viewport[2] /= 2;
12042
- viewport[3] /= 2;
12043
- // TODO 限制最大迭代
12044
- }
12045
- viewport[2] *= 4;
12046
- viewport[3] *= 4;
12047
- for(var i1 = 0; i1 < gaussianStep - 1; i1++){
12048
- var gaussianUpPass = new HQGaussianUpSamplePass(renderer, {
12049
- name: "GaussianUpPass" + i1,
12050
- viewport: viewport,
12051
- attachments: [
12052
- {
12053
- texture: {
12054
- format: glContext.RGBA,
12055
- type: textureType1,
12056
- minFilter: glContext.LINEAR,
12057
- magFilter: glContext.LINEAR
12058
- }
12047
+ }
12048
+ ]
12049
+ });
12050
+ gaussianDownVPass.gaussianResult = gaussianDownResults[i];
12051
+ this.addRenderPass(gaussianDownHPass);
12052
+ this.addRenderPass(gaussianDownVPass);
12053
+ viewport[2] /= 2;
12054
+ viewport[3] /= 2;
12055
+ // TODO 限制最大迭代
12056
+ }
12057
+ viewport[2] *= 4;
12058
+ viewport[3] *= 4;
12059
+ for(var i1 = 0; i1 < gaussianStep - 1; i1++){
12060
+ var gaussianUpPass = new HQGaussianUpSamplePass(renderer, {
12061
+ name: "GaussianUpPass" + i1,
12062
+ viewport: viewport,
12063
+ attachments: [
12064
+ {
12065
+ texture: {
12066
+ format: glContext.RGBA,
12067
+ type: textureType1,
12068
+ minFilter: glContext.LINEAR,
12069
+ magFilter: glContext.LINEAR
12059
12070
  }
12060
- ]
12061
- });
12062
- gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
12063
- this.addRenderPass(gaussianUpPass);
12064
- viewport[2] *= 2;
12065
- viewport[3] *= 2;
12066
- }
12067
- }
12068
- var postProcessPass;
12069
- if (useBloom) {
12070
- postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
12071
- } else {
12072
- postProcessPass = new ToneMappingPass(renderer);
12071
+ }
12072
+ ]
12073
+ });
12074
+ gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
12075
+ this.addRenderPass(gaussianUpPass);
12076
+ viewport[2] *= 2;
12077
+ viewport[3] *= 2;
12073
12078
  }
12079
+ var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
12074
12080
  this.addRenderPass(postProcessPass);
12075
12081
  }
12076
12082
  this.semantics = new SemanticMap(options.semantics);
@@ -13107,6 +13113,7 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13107
13113
  1
13108
13114
  ];
13109
13115
  /** 是否响应点击和拖拽交互事件 */ _this._interactive = true;
13116
+ _this.hasBeenAddedToComposition = false;
13110
13117
  _this.getHitTestParams = function(force) {
13111
13118
  if (!_this.clickable) {
13112
13119
  return;
@@ -13125,7 +13132,6 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13125
13132
  }
13126
13133
  var _proto = InteractComponent.prototype;
13127
13134
  _proto.start = function start() {
13128
- var _this = this;
13129
13135
  var options = this.item.props.content.options;
13130
13136
  var env = this.item.engine.renderer.env;
13131
13137
  var composition = this.item.composition;
@@ -13137,10 +13143,6 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13137
13143
  this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
13138
13144
  }
13139
13145
  }
13140
- composition.addInteractiveItem(this.item, options.type);
13141
- this.item.onEnd = function() {
13142
- return composition.removeInteractiveItem(_this.item, options.type);
13143
- };
13144
13146
  if (options.type === InteractType.DRAG) {
13145
13147
  if (env !== PLAYER_OPTIONS_ENV_EDITOR || options.enableInEditor) {
13146
13148
  composition.event && this.beginDragTarget(options, composition.event);
@@ -13155,6 +13157,11 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
13155
13157
  _proto.update = function update(dt) {
13156
13158
  var _this_previewContent;
13157
13159
  (_this_previewContent = this.previewContent) == null ? void 0 : _this_previewContent.updateMesh();
13160
+ if (!this.hasBeenAddedToComposition && this.item.composition) {
13161
+ var options = this.item.props.content.options;
13162
+ this.item.composition.addInteractiveItem(this.item, options.type);
13163
+ this.hasBeenAddedToComposition = true;
13164
+ }
13158
13165
  if (!this.dragEvent || !this.bouncingArg) {
13159
13166
  return;
13160
13167
  }
@@ -14878,8 +14885,7 @@ var RectangleEdge = /*#__PURE__*/ function() {
14878
14885
  }();
14879
14886
  var Edge = /*#__PURE__*/ function() {
14880
14887
  function Edge(args) {
14881
- // TODO: 为通过帧对比暂时使用老计算,修复粒子发射器直线宽度问题下面一行改为: this._d = args.width || 1 ;
14882
- this._d = (args.width || 1) / 2;
14888
+ this._d = args.width || 1;
14883
14889
  this.arcMode = args.arcMode;
14884
14890
  }
14885
14891
  var _proto = Edge.prototype;
@@ -20204,6 +20210,105 @@ function geometryToTriangles(geometry) {
20204
20210
  return res;
20205
20211
  }
20206
20212
 
20213
+ exports.PostProcessVolume = /*#__PURE__*/ function(ItemBehaviour) {
20214
+ _inherits(PostProcessVolume, ItemBehaviour);
20215
+ function PostProcessVolume() {
20216
+ var _this;
20217
+ _this = ItemBehaviour.apply(this, arguments) || this;
20218
+ _this.useHDR = true;
20219
+ // Bloom
20220
+ _this.useBloom = true;
20221
+ _this.threshold = 1.0;
20222
+ _this.bloomIntensity = 1.0;
20223
+ // ColorAdjustments
20224
+ _this.brightness = 1.0;
20225
+ _this.saturation = 1.0;
20226
+ _this.contrast = 1.0;
20227
+ // Vignette
20228
+ _this.vignetteIntensity = 0.2;
20229
+ _this.vignetteSmoothness = 0.4;
20230
+ _this.vignetteRoundness = 1.0;
20231
+ // ToneMapping
20232
+ _this.useToneMapping = true // 1: true, 0: false
20233
+ ;
20234
+ return _this;
20235
+ }
20236
+ var _proto = PostProcessVolume.prototype;
20237
+ _proto.start = function start() {
20238
+ var composition = this.item.composition;
20239
+ if (composition) {
20240
+ composition.globalVolume = {
20241
+ useHDR: this.useHDR,
20242
+ useBloom: this.useBloom,
20243
+ threshold: this.threshold,
20244
+ bloomIntensity: this.bloomIntensity,
20245
+ brightness: this.brightness,
20246
+ saturation: this.saturation,
20247
+ contrast: this.contrast,
20248
+ vignetteIntensity: this.vignetteIntensity,
20249
+ vignetteSmoothness: this.vignetteSmoothness,
20250
+ vignetteRoundness: this.vignetteRoundness,
20251
+ useToneMapping: this.useToneMapping
20252
+ };
20253
+ composition.createRenderFrame();
20254
+ }
20255
+ };
20256
+ _proto.update = function update(dt) {
20257
+ var composition = this.item.composition;
20258
+ if (composition) {
20259
+ var globalVolume = composition.renderFrame.globalVolume;
20260
+ globalVolume.useHDR = this.useHDR;
20261
+ globalVolume.useBloom = this.useBloom;
20262
+ globalVolume.threshold = this.threshold;
20263
+ globalVolume.bloomIntensity = this.bloomIntensity;
20264
+ globalVolume.brightness = this.brightness;
20265
+ globalVolume.saturation = this.saturation;
20266
+ globalVolume.contrast = this.contrast;
20267
+ globalVolume.vignetteIntensity = this.vignetteIntensity;
20268
+ globalVolume.vignetteSmoothness = this.vignetteSmoothness;
20269
+ globalVolume.vignetteRoundness = this.vignetteRoundness;
20270
+ globalVolume.useToneMapping = this.useToneMapping;
20271
+ }
20272
+ };
20273
+ return PostProcessVolume;
20274
+ }(ItemBehaviour);
20275
+ __decorate([
20276
+ serialize()
20277
+ ], exports.PostProcessVolume.prototype, "useHDR", void 0);
20278
+ __decorate([
20279
+ serialize()
20280
+ ], exports.PostProcessVolume.prototype, "useBloom", void 0);
20281
+ __decorate([
20282
+ serialize()
20283
+ ], exports.PostProcessVolume.prototype, "threshold", void 0);
20284
+ __decorate([
20285
+ serialize()
20286
+ ], exports.PostProcessVolume.prototype, "bloomIntensity", void 0);
20287
+ __decorate([
20288
+ serialize()
20289
+ ], exports.PostProcessVolume.prototype, "brightness", void 0);
20290
+ __decorate([
20291
+ serialize()
20292
+ ], exports.PostProcessVolume.prototype, "saturation", void 0);
20293
+ __decorate([
20294
+ serialize()
20295
+ ], exports.PostProcessVolume.prototype, "contrast", void 0);
20296
+ __decorate([
20297
+ serialize()
20298
+ ], exports.PostProcessVolume.prototype, "vignetteIntensity", void 0);
20299
+ __decorate([
20300
+ serialize()
20301
+ ], exports.PostProcessVolume.prototype, "vignetteSmoothness", void 0);
20302
+ __decorate([
20303
+ serialize()
20304
+ ], exports.PostProcessVolume.prototype, "vignetteRoundness", void 0);
20305
+ __decorate([
20306
+ serialize()
20307
+ ], exports.PostProcessVolume.prototype, "useToneMapping", void 0);
20308
+ exports.PostProcessVolume = __decorate([
20309
+ effectsClass("PostProcessVolume")
20310
+ ], exports.PostProcessVolume);
20311
+
20207
20312
  exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
20208
20313
  _inherits(VFXItem, EffectsObject);
20209
20314
  function VFXItem(engine, props) {
@@ -20427,7 +20532,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
20427
20532
  /**
20428
20533
  * 获取元素用于计算光线投射的面片类型和参数
20429
20534
  * @override
20430
- * @param force 元素没有开启交互也返回参数
20535
+ * @param force - 元素没有开启交互也返回参数
20431
20536
  */ _proto.getHitTestParams = function getHitTestParams(force) {
20432
20537
  // OVERRIDE
20433
20538
  };
@@ -20677,42 +20782,6 @@ exports.Item = void 0;
20677
20782
  }
20678
20783
  Item.isNull = isNull;
20679
20784
  })(exports.Item || (exports.Item = {}));
20680
- /**
20681
- * (待废弃) 根据元素的类型创建对应的 `VFXItem` 实例
20682
- * @param props
20683
- * @param composition
20684
- */ function createVFXItem(props, composition) {
20685
- var type = props.type;
20686
- var pluginName = props.pluginName;
20687
- if (!pluginName) {
20688
- switch(type){
20689
- case ItemType.null:
20690
- pluginName = "cal";
20691
- break;
20692
- case ItemType.sprite:
20693
- pluginName = "sprite";
20694
- break;
20695
- case ItemType.particle:
20696
- pluginName = "particle";
20697
- break;
20698
- case ItemType.interact:
20699
- pluginName = "interact";
20700
- break;
20701
- case ItemType.camera:
20702
- pluginName = "camera";
20703
- break;
20704
- case ItemType.text:
20705
- pluginName = "text";
20706
- break;
20707
- case ItemType.tree:
20708
- pluginName = "tree";
20709
- break;
20710
- default:
20711
- throw new Error("Invalid vfx item type.");
20712
- }
20713
- }
20714
- return composition.pluginSystem.createPluginItem(pluginName, props, composition);
20715
- }
20716
20785
 
20717
20786
  var pluginLoaderMap = {};
20718
20787
  var defaultPlugins = [];
@@ -20725,6 +20794,9 @@ var pluginCtrlMap = {};
20725
20794
  * @param isDefault load
20726
20795
  */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20727
20796
  function registerPlugin(name, pluginClass, itemClass, isDefault) {
20797
+ if (pluginCtrlMap[name]) {
20798
+ logger.error("Duplicate registration for plugin " + name + ".");
20799
+ }
20728
20800
  pluginCtrlMap[name] = itemClass;
20729
20801
  pluginLoaderMap[name] = pluginClass;
20730
20802
  if (isDefault) {
@@ -21303,8 +21375,8 @@ var SerializationHelper = /*#__PURE__*/ function() {
21303
21375
  if (this.engine.objectInstance[guid]) {
21304
21376
  return this.engine.objectInstance[guid];
21305
21377
  }
21306
- var effectsObject;
21307
21378
  var effectsObjectData = this.findData(guid);
21379
+ var effectsObject;
21308
21380
  if (!effectsObjectData) {
21309
21381
  console.error("Object data with uuid: " + guid + " not found.");
21310
21382
  return undefined;
@@ -21340,7 +21412,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
21340
21412
  _proto.loadGUIDAsync = function loadGUIDAsync(guid) {
21341
21413
  var _this = this;
21342
21414
  return _async_to_generator(function() {
21343
- var effectsObject, effectsObjectData, classConstructor;
21415
+ var effectsObjectData, effectsObject, classConstructor;
21344
21416
  return __generator(this, function(_state) {
21345
21417
  switch(_state.label){
21346
21418
  case 0:
@@ -23605,14 +23677,6 @@ var seed$1 = 1;
23605
23677
  case 0:
23606
23678
  // TODO: 后面切换到新的数据版本,就不用掉用 getStandardJSON 做转换了
23607
23679
  jsonScene = getStandardJSON(json);
23608
- // FIXME: hack globalVolume,specification 更新后需移除
23609
- // @ts-expect-error
23610
- json.compositions.forEach(function(composition, i) {
23611
- if (composition.globalVolume) {
23612
- // @ts-expect-error
23613
- jsonScene.compositions[i].globalVolume = composition.globalVolume;
23614
- }
23615
- });
23616
23680
  _jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
23617
23681
  pluginSystem = new PluginSystem(plugins);
23618
23682
  return [
@@ -24400,9 +24464,7 @@ var listOrder = 0;
24400
24464
  }
24401
24465
  var _proto = CompositionSourceManager.prototype;
24402
24466
  _proto.getContent = function getContent(composition) {
24403
- // TODO: specification 中补充 globalVolume 类型
24404
- // @ts-expect-error
24405
- 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;
24467
+ 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;
24406
24468
  var items = this.assembleItems(composition);
24407
24469
  return _extends({}, composition, {
24408
24470
  id: id,
@@ -24412,8 +24474,7 @@ var listOrder = 0;
24412
24474
  // looping,
24413
24475
  items: items,
24414
24476
  camera: camera,
24415
- startTime: startTime,
24416
- globalVolume: globalVolume
24477
+ startTime: startTime
24417
24478
  });
24418
24479
  };
24419
24480
  _proto.assembleItems = function assembleItems(composition) {
@@ -24575,7 +24636,6 @@ var listOrder = 0;
24575
24636
  this.rootComposition = this.rootItem.addComponent(CompositionComponent);
24576
24637
  this.rootComposition.data = sourceContent;
24577
24638
  var imageUsage = !reusable && imgUsage;
24578
- this.globalVolume = sourceContent.globalVolume;
24579
24639
  this.width = width;
24580
24640
  this.height = height;
24581
24641
  this.renderOrder = baseRenderOrder;
@@ -26780,7 +26840,10 @@ var FBGeometryDataT = /*#__PURE__*/ function() {
26780
26840
  return FBGeometryDataT;
26781
26841
  }();
26782
26842
 
26783
- var EffectsPackage = /*#__PURE__*/ function() {
26843
+ /**
26844
+ * @since 2.0.0
26845
+ * @internal
26846
+ */ var EffectsPackage = /*#__PURE__*/ function() {
26784
26847
  function EffectsPackage() {
26785
26848
  this.exportObjectDatas = [];
26786
26849
  }
@@ -26805,8 +26868,7 @@ var EffectsPackage = /*#__PURE__*/ function() {
26805
26868
  }
26806
26869
  effectsPackage.exportObjects = exportObjects;
26807
26870
  FBEffectsPackageData.finishFBEffectsPackageDataBuffer(fbb, effectsPackage.pack(fbb));
26808
- var buffer = fbb.asUint8Array(); // Of type `Uint8Array`.
26809
- return buffer;
26871
+ return fbb.asUint8Array(); // Of type `Uint8Array`.
26810
26872
  };
26811
26873
  _proto.deserializeFromBinary = function deserializeFromBinary(buffer) {
26812
26874
  var buf = new ByteBuffer(buffer);
@@ -26834,37 +26896,35 @@ var EffectsPackage = /*#__PURE__*/ function() {
26834
26896
  _proto.geometryDataToBinary = function geometryDataToBinary(geometryData) {
26835
26897
  var fbb = new Builder(1);
26836
26898
  var fbGeometryData = new FBGeometryDataT();
26837
- fbGeometryData.indexFormat = geometryData.indexFormat;
26838
- fbGeometryData.indexOffset = geometryData.indexOffset;
26839
- fbGeometryData.mode = geometryData.mode;
26840
- fbGeometryData.id = geometryData.id;
26841
- var _geometryData_boneNames;
26842
- fbGeometryData.boneNames = (_geometryData_boneNames = geometryData.boneNames) != null ? _geometryData_boneNames : [];
26843
- var _geometryData_rootBoneName;
26844
- fbGeometryData.rootBoneName = (_geometryData_rootBoneName = geometryData.rootBoneName) != null ? _geometryData_rootBoneName : "";
26845
- var _geometryData_inverseBindMatrices;
26846
- fbGeometryData.inverseBindMatrices = (_geometryData_inverseBindMatrices = geometryData.inverseBindMatrices) != null ? _geometryData_inverseBindMatrices : [];
26847
- var _geometryData_binaryData;
26848
- fbGeometryData.binaryData = (_geometryData_binaryData = geometryData.binaryData) != null ? _geometryData_binaryData : [];
26899
+ 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;
26900
+ fbGeometryData.indexFormat = indexFormat;
26901
+ fbGeometryData.indexOffset = indexOffset;
26902
+ fbGeometryData.mode = mode;
26903
+ fbGeometryData.id = id;
26904
+ fbGeometryData.boneNames = boneNames;
26905
+ fbGeometryData.rootBoneName = rootBoneName;
26906
+ fbGeometryData.inverseBindMatrices = inverseBindMatrices;
26907
+ fbGeometryData.binaryData = binaryData;
26849
26908
  var fbVertexdata = new FBVertexDataT();
26850
- fbVertexdata.vertexCount = geometryData.vertexData.vertexCount;
26909
+ fbVertexdata.vertexCount = vertexData.vertexCount;
26851
26910
  fbVertexdata.channels = [];
26852
- for(var _iterator = _create_for_of_iterator_helper_loose(geometryData.vertexData.channels), _step; !(_step = _iterator()).done;){
26911
+ for(var _iterator = _create_for_of_iterator_helper_loose(vertexData.channels), _step; !(_step = _iterator()).done;){
26853
26912
  var channel = _step.value;
26854
- var fbChannel = new FBVertexChannelT(channel.semantic, channel.offset, channel.format, channel.dimension, channel.normalize);
26913
+ var semantic = channel.semantic, offset = channel.offset, format = channel.format, dimension = channel.dimension, normalize = channel.normalize;
26914
+ var fbChannel = new FBVertexChannelT(semantic, offset, format, dimension, normalize);
26855
26915
  fbVertexdata.channels.push(fbChannel);
26856
26916
  }
26857
26917
  fbGeometryData.vertexData = fbVertexdata;
26858
26918
  var fbSubMeshes = [];
26859
26919
  for(var _iterator1 = _create_for_of_iterator_helper_loose(geometryData.subMeshes), _step1; !(_step1 = _iterator1()).done;){
26860
26920
  var subMesh = _step1.value;
26861
- var fbSubMesh = new FBSubMeshT(subMesh.offset, subMesh.indexCount, subMesh.vertexCount);
26921
+ var offset1 = subMesh.offset, indexCount = subMesh.indexCount, vertexCount = subMesh.vertexCount;
26922
+ var fbSubMesh = new FBSubMeshT(offset1, indexCount, vertexCount);
26862
26923
  fbSubMeshes.push(fbSubMesh);
26863
26924
  }
26864
26925
  fbGeometryData.subMeshes = fbSubMeshes;
26865
26926
  FBEffectsPackageData.finishFBEffectsPackageDataBuffer(fbb, fbGeometryData.pack(fbb));
26866
- var buffer = fbb.asUint8Array(); // Of type `Uint8Array`.
26867
- return buffer;
26927
+ return fbb.asUint8Array(); // Of type `Uint8Array`.
26868
26928
  };
26869
26929
  _proto.binaryToGeometryData = function binaryToGeometryData(buffer) {
26870
26930
  var buf = new ByteBuffer(buffer);
@@ -26886,7 +26946,8 @@ var EffectsPackage = /*#__PURE__*/ function() {
26886
26946
  semantic: (_channel_semantic = channel.semantic()) != null ? _channel_semantic : "",
26887
26947
  offset: channel.offset(),
26888
26948
  format: channel.format(),
26889
- dimension: channel.dimension()
26949
+ dimension: channel.dimension(),
26950
+ normalize: channel.normalize()
26890
26951
  };
26891
26952
  vertexData.channels.push(vertexChannel);
26892
26953
  }
@@ -26899,7 +26960,8 @@ var EffectsPackage = /*#__PURE__*/ function() {
26899
26960
  }
26900
26961
  var subMesh = {
26901
26962
  offset: fbSubMesh.offset(),
26902
- vertexCount: fbSubMesh.vertexCount()
26963
+ vertexCount: fbSubMesh.vertexCount(),
26964
+ indexCount: fbSubMesh.indexCount()
26903
26965
  };
26904
26966
  subMeshes.push(subMesh);
26905
26967
  }
@@ -27328,7 +27390,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
27328
27390
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
27329
27391
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
27330
27392
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
27331
- var version$1 = "2.0.0-alpha.27";
27393
+ var version$1 = "2.0.0-alpha.28";
27332
27394
  logger.info("Core version: " + version$1 + ".");
27333
27395
 
27334
27396
  var _obj;
@@ -28961,7 +29023,7 @@ setMaxSpriteMeshItemCount(8);
28961
29023
  */ Mesh.create = function(engine, props) {
28962
29024
  return new ThreeMesh(engine, props);
28963
29025
  };
28964
- var version = "2.0.0-alpha.27";
29026
+ var version = "2.0.0-alpha.28";
28965
29027
  logger.info("THREEJS plugin version: " + version + ".");
28966
29028
 
28967
29029
  exports.AbstractPlugin = AbstractPlugin;
@@ -29094,7 +29156,6 @@ exports.createGLContext = createGLContext;
29094
29156
  exports.createKeyFrameMeta = createKeyFrameMeta;
29095
29157
  exports.createShaderWithMacros = createShaderWithMacros;
29096
29158
  exports.createShape = createShape;
29097
- exports.createVFXItem = createVFXItem;
29098
29159
  exports.createValueGetter = createValueGetter;
29099
29160
  exports.decimalEqual = decimalEqual;
29100
29161
  exports.defaultGlobalVolume = defaultGlobalVolume;
@@ -29150,6 +29211,8 @@ exports.isArray = isArray;
29150
29211
  exports.isCanvas = isCanvas;
29151
29212
  exports.isFunction = isFunction;
29152
29213
  exports.isIOS = isIOS;
29214
+ exports.isIOSByUA = isIOSByUA;
29215
+ exports.isMiniProgram = isMiniProgram;
29153
29216
  exports.isObject = isObject;
29154
29217
  exports.isSceneJSON = isSceneJSON;
29155
29218
  exports.isSceneURL = isSceneURL;
@@ -29160,6 +29223,7 @@ exports.isUniformStruct = isUniformStruct;
29160
29223
  exports.isUniformStructArray = isUniformStructArray;
29161
29224
  exports.isValidFontFamily = isValidFontFamily;
29162
29225
  exports.isWebGL2 = isWebGL2;
29226
+ exports.isWechatMiniApp = isWechatMiniApp;
29163
29227
  exports.itemFrag = itemFrag;
29164
29228
  exports.itemFrameFrag = itemFrameFrag;
29165
29229
  exports.itemVert = itemVert;