@galacean/effects-threejs 1.2.3 → 1.2.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/index.mjs 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: v1.2.3
6
+ * Version: v1.2.5
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -9245,10 +9245,10 @@ var VFXItem = /** @class */ (function () {
9245
9245
  };
9246
9246
  VFXItem.prototype.translateByPixel = function (x, y) {
9247
9247
  if (this.composition) {
9248
+ // @ts-expect-error
9249
+ var _a = this.composition.renderer.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
9248
9250
  var z = this.transform.getWorldPosition().z;
9249
- var _a = this.composition.camera.getInverseVPRatio(z), rx = _a.x, ry = _a.y;
9250
- var width = this.composition.renderer.getWidth() / 2;
9251
- var height = this.composition.renderer.getHeight() / 2;
9251
+ var _b = this.composition.camera.getInverseVPRatio(z), rx = _b.x, ry = _b.y;
9252
9252
  this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
9253
9253
  }
9254
9254
  };
@@ -13144,9 +13144,13 @@ var InteractVFXItem = /** @class */ (function (_super) {
13144
13144
  this.handleDragMove(this.dragEvent, this.bouncingArg);
13145
13145
  }
13146
13146
  };
13147
- InteractVFXItem.prototype.onItemRemoved = function (composition) {
13147
+ InteractVFXItem.prototype.onEnd = function () {
13148
+ if (this.composition) {
13149
+ this.composition.removeInteractiveItem(this, this.ui.options.type);
13150
+ }
13151
+ };
13152
+ InteractVFXItem.prototype.onItemRemoved = function () {
13148
13153
  var _a;
13149
- composition.removeInteractiveItem(this, this.ui.options.type);
13150
13154
  this.clickable = false;
13151
13155
  (_a = this.previewContent) === null || _a === void 0 ? void 0 : _a.mesh.dispose();
13152
13156
  this.endDragTarget();
@@ -21354,8 +21358,9 @@ var Camera = /** @class */ (function () {
21354
21358
  Camera.prototype.getInverseVPRatio = function (z) {
21355
21359
  var pos = new Vector3(0, 0, z);
21356
21360
  var mat = this.getViewProjectionMatrix();
21357
- var nz = pos.applyMatrix(mat).z;
21358
- return new Vector3(1, 1, nz).applyMatrix(mat);
21361
+ var inverseVP = this.getInverseViewProjectionMatrix();
21362
+ var nz = mat.projectPoint(pos).z;
21363
+ return inverseVP.projectPoint(new Vector3(1, 1, nz));
21359
21364
  };
21360
21365
  /**
21361
21366
  * 设置相机的旋转四元数
@@ -21367,7 +21372,6 @@ var Camera = /** @class */ (function () {
21367
21372
  this.dirty = true;
21368
21373
  }
21369
21374
  else {
21370
- this.options.quat;
21371
21375
  if (!this.options.quat.equals(value)) {
21372
21376
  this.options.quat.copyFrom(value);
21373
21377
  this.dirty = true;
@@ -23699,16 +23703,17 @@ var AssetManager = /** @class */ (function () {
23699
23703
  };
23700
23704
  AssetManager.prototype.processBins = function (bins) {
23701
23705
  return __awaiter(this, void 0, void 0, function () {
23702
- var renderLevel, jobs;
23706
+ var renderLevel, baseUrl, jobs;
23703
23707
  var _this = this;
23704
23708
  return __generator(this, function (_a) {
23705
23709
  renderLevel = this.options.renderLevel;
23710
+ baseUrl = this.baseUrl;
23706
23711
  jobs = bins.map(function (bin) {
23707
23712
  if (bin instanceof ArrayBuffer) {
23708
23713
  return bin;
23709
23714
  }
23710
23715
  if (passRenderLevel(bin.renderLevel, renderLevel)) {
23711
- return _this.loadBins(bin.url);
23716
+ return _this.loadBins(new URL(bin.url, baseUrl).href);
23712
23717
  }
23713
23718
  throw new Error("Invalid bins source: ".concat(JSON.stringify(bins)));
23714
23719
  });
@@ -23726,13 +23731,14 @@ var AssetManager = /** @class */ (function () {
23726
23731
  return [2 /*return*/];
23727
23732
  }
23728
23733
  jobs = fonts.map(function (font) { return __awaiter(_this, void 0, void 0, function () {
23729
- var fontFace;
23734
+ var url, fontFace;
23730
23735
  var _a;
23731
23736
  return __generator(this, function (_b) {
23732
23737
  switch (_b.label) {
23733
23738
  case 0:
23734
23739
  if (!(font.fontURL && !AssetManager.fonts.has(font.fontFamily))) return [3 /*break*/, 4];
23735
- fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + font.fontURL + ')');
23740
+ url = new URL(font.fontURL, this.baseUrl).href;
23741
+ fontFace = new FontFace((_a = font.fontFamily) !== null && _a !== void 0 ? _a : '', 'url(' + url + ')');
23736
23742
  _b.label = 1;
23737
23743
  case 1:
23738
23744
  _b.trys.push([1, 3, , 4]);
@@ -23745,7 +23751,7 @@ var AssetManager = /** @class */ (function () {
23745
23751
  return [3 /*break*/, 4];
23746
23752
  case 3:
23747
23753
  _b.sent();
23748
- logger.warn("Invalid fonts source: ".concat(JSON.stringify(font.fontURL)));
23754
+ logger.warn("Invalid fonts source: ".concat(JSON.stringify(url)));
23749
23755
  return [3 /*break*/, 4];
23750
23756
  case 4: return [2 /*return*/];
23751
23757
  }
@@ -23977,7 +23983,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
23977
23983
  return image.source;
23978
23984
  }
23979
23985
  else if (image instanceof HTMLImageElement ||
23980
- image instanceof HTMLCanvasElement) {
23986
+ isCanvas(image)) {
23981
23987
  return {
23982
23988
  image: image,
23983
23989
  sourceType: TextureSourceType.image,
@@ -24014,6 +24020,11 @@ function createTextureOptionsBySource(image, sourceFrom) {
24014
24020
  }
24015
24021
  throw new Error('Invalid texture options');
24016
24022
  }
24023
+ function isCanvas(cavnas) {
24024
+ var _a;
24025
+ // 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
24026
+ return typeof cavnas === 'object' && cavnas !== null && ((_a = cavnas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
24027
+ }
24017
24028
 
24018
24029
  var CompVFXItem = /** @class */ (function (_super) {
24019
24030
  __extends(CompVFXItem, _super);
@@ -26911,7 +26922,7 @@ Geometry.create = function (engine, options) {
26911
26922
  Mesh.create = function (engine, props) {
26912
26923
  return new ThreeMesh(engine, props);
26913
26924
  };
26914
- var version = "1.2.3";
26925
+ var version = "1.2.5";
26915
26926
  logger.info('THREEJS plugin version: ' + version);
26916
26927
 
26917
26928
  export { AbstractPlugin, AssetManager, BYTES_TYPE_MAP, BezierSegments, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateItem, CalculateLoader, CalculateVFXItem, Camera, CameraController, CameraVFXItem, CameraVFXItemLoader, Composition, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, FilterSpriteVFXItem, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractItem, InteractLoader, InteractMesh, InteractVFXItem, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleLoader, ParticleMesh, ParticleSystem, ParticleVFXItem, PassTextureCache, PathSegments, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, Shader, ShaderCompileResultStatus, ShaderType, SpriteItem, SpriteLoader, SpriteMesh, SpriteVFXItem, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextItem, TextLoader, TextMesh, TextVFXItem, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeMaterial, ThreeTexture, Ticker, TimelineComponent, Transform, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrameFrag, alphaMaskFrag, assertExist, asserts, blend, bloomMixVert, bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, convertAnchor, copyFrag, createCopyShader, createFilter, createFilterShaders, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delayFrag, deserializeMipmapTexture, distortionFrag, distortionVert, earcut, enlargeBuffer, ensureVec3, filters, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAndroid, isArray, isFunction, isIOS, isObject, isScene, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isWebGL2, item_define as itemDefine, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap, particleVert, pluginLoaderMap, random, registerFilter, registerFilters, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version };