@galacean/effects-threejs 1.1.0-alpha.0 → 1.1.0-alpha.1

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: v1.1.0-alpha.0
6
+ * Version: v1.1.0-alpha.1
7
7
  */
8
8
 
9
9
  'use strict';
@@ -19203,7 +19203,7 @@ var InteractVFXItem = /** @class */ (function (_super) {
19203
19203
  (_b = event.origin) === null || _b === void 0 ? void 0 : _b.preventDefault();
19204
19204
  }
19205
19205
  }
19206
- this.composition.camera.position.set(nx, ny, depth);
19206
+ this.composition.camera.position = new Vector3(nx, ny, depth);
19207
19207
  };
19208
19208
  return InteractVFXItem;
19209
19209
  }(VFXItem));
@@ -29920,7 +29920,8 @@ var CompVFXItem = /** @class */ (function (_super) {
29920
29920
  configurable: true
29921
29921
  });
29922
29922
  CompVFXItem.prototype.onConstructed = function (props) {
29923
- var _a = props.items, items = _a === void 0 ? [] : _a, _b = props.startTime, startTime = _b === void 0 ? 0 : _b, content = props.content;
29923
+ var _a = props.items, items = _a === void 0 ? [] : _a, _b = props.startTime, startTime = _b === void 0 ? 0 : _b, content = props.content, refId = props.refId;
29924
+ this.refId = refId;
29924
29925
  this.itemProps = items;
29925
29926
  this.contentProps = content;
29926
29927
  var endBehavior = this.endBehavior;
@@ -29947,13 +29948,8 @@ var CompVFXItem = /** @class */ (function (_super) {
29947
29948
  if (!props) {
29948
29949
  throw new Error("\u5F15\u7528\u7684Id: ".concat(refId, " \u7684\u9884\u5408\u6210\u4E0D\u5B58\u5728"));
29949
29950
  }
29950
- props.name = itemProps.name;
29951
- props.duration = itemProps.duration;
29952
- props.endBehavior = itemProps.endBehavior;
29953
- props.delay = itemProps.delay;
29954
- props.parentId = itemProps.parentId;
29955
29951
  props.content = itemProps.content;
29956
- item = new CompVFXItem(props, this.composition);
29952
+ item = new CompVFXItem(__assign$1(__assign$1({}, props), { refId: refId, id: itemProps.id, name: itemProps.name, duration: itemProps.duration, endBehavior: itemProps.endBehavior, parentId: itemProps.parentId, transform: itemProps.transform }), this.composition);
29957
29953
  item.contentProps = itemProps.content;
29958
29954
  item.transform.parentTransform = this.transform;
29959
29955
  this.composition.refContent.push(item);
@@ -30208,6 +30204,74 @@ var CompVFXItem = /** @class */ (function (_super) {
30208
30204
  }
30209
30205
  return res;
30210
30206
  };
30207
+ CompVFXItem.prototype.hitTest = function (ray, x, y, regions, force, options) {
30208
+ var hitPositions = [];
30209
+ var stop = (options === null || options === void 0 ? void 0 : options.stop) || noop;
30210
+ var skip = (options === null || options === void 0 ? void 0 : options.skip) || noop;
30211
+ var maxCount = (options === null || options === void 0 ? void 0 : options.maxCount) || this.items.length;
30212
+ for (var i = 0; i < this.items.length && regions.length < maxCount; i++) {
30213
+ var item = this.items[i];
30214
+ if (item.lifetime >= 0 && item.lifetime <= 1 && !VFXItem.isComposition(item) && !skip(item)) {
30215
+ var hitParams = item.getHitTestParams(force);
30216
+ if (hitParams) {
30217
+ var success = false;
30218
+ var intersectPoint = new Vector3();
30219
+ if (hitParams.type === exports.HitTestType.triangle) {
30220
+ var triangles = hitParams.triangles, backfaceCulling = hitParams.backfaceCulling;
30221
+ for (var j = 0; j < triangles.length; j++) {
30222
+ var triangle = triangles[j];
30223
+ if (ray.intersectTriangle(triangle, intersectPoint, backfaceCulling)) {
30224
+ success = true;
30225
+ hitPositions.push(intersectPoint);
30226
+ break;
30227
+ }
30228
+ }
30229
+ }
30230
+ else if (hitParams.type === exports.HitTestType.box) {
30231
+ var center = hitParams.center, size = hitParams.size;
30232
+ var boxMin = center.clone().addScaledVector(size, 0.5);
30233
+ var boxMax = center.clone().addScaledVector(size, -0.5);
30234
+ if (ray.intersectBox({ min: boxMin, max: boxMax }, intersectPoint)) {
30235
+ success = true;
30236
+ hitPositions.push(intersectPoint);
30237
+ }
30238
+ }
30239
+ else if (hitParams.type === exports.HitTestType.sphere) {
30240
+ var center = hitParams.center, radius = hitParams.radius;
30241
+ if (ray.intersectSphere({ center: center, radius: radius }, intersectPoint)) {
30242
+ success = true;
30243
+ hitPositions.push(intersectPoint);
30244
+ }
30245
+ }
30246
+ else if (hitParams.type === exports.HitTestType.custom) {
30247
+ var tempPosition = hitParams.collect(ray, new Vector2(x, y));
30248
+ if (tempPosition && tempPosition.length > 0) {
30249
+ tempPosition.forEach(function (pos) {
30250
+ hitPositions.push(pos);
30251
+ });
30252
+ success = true;
30253
+ }
30254
+ }
30255
+ if (success) {
30256
+ var region = {
30257
+ compContent: this,
30258
+ id: item.id,
30259
+ name: item.name,
30260
+ position: hitPositions[hitPositions.length - 1],
30261
+ parentId: item.parentId,
30262
+ hitPositions: hitPositions,
30263
+ behavior: hitParams.behavior,
30264
+ };
30265
+ regions.push(region);
30266
+ if (stop(region)) {
30267
+ return regions;
30268
+ }
30269
+ }
30270
+ }
30271
+ }
30272
+ }
30273
+ return regions;
30274
+ };
30211
30275
  CompVFXItem.prototype.isEnded = function (now) {
30212
30276
  return now >= this.durInms;
30213
30277
  };
@@ -30671,7 +30735,7 @@ var Composition = /** @class */ (function () {
30671
30735
  this.pluginSystem.plugins.forEach(func);
30672
30736
  };
30673
30737
  /**
30674
- *
30738
+ * 获取指定位置和相机连成的射线
30675
30739
  * @param x
30676
30740
  * @param y
30677
30741
  * @returns
@@ -30699,73 +30763,12 @@ var Composition = /** @class */ (function () {
30699
30763
  if (this.isDestroyed) {
30700
30764
  return [];
30701
30765
  }
30702
- var hitPositions = [];
30703
30766
  var regions = [];
30704
- var _a = this.renderFrame.editorTransform, a = _a.x, b = _a.y, c = _a.z, d = _a.w;
30705
- var ray = setRayFromCamera((x - c) / a, (y - d) / b, this.camera);
30706
- var stop = (options === null || options === void 0 ? void 0 : options.stop) || noop;
30707
- var skip = (options === null || options === void 0 ? void 0 : options.skip) || noop;
30708
- var maxCount = (options === null || options === void 0 ? void 0 : options.maxCount) || this.items.length;
30709
- for (var i = 0; i < this.items.length && regions.length < maxCount; i++) {
30710
- var item = this.items[i];
30711
- if (item.lifetime >= 0 && item.lifetime <= 1 && !skip(item)) {
30712
- var hitParams = item.getHitTestParams(force);
30713
- if (hitParams) {
30714
- var success = false;
30715
- var intersectPoint = new Vector3();
30716
- if (hitParams.type === exports.HitTestType.triangle) {
30717
- var triangles = hitParams.triangles, backfaceCulling = hitParams.backfaceCulling;
30718
- for (var j = 0; j < triangles.length; j++) {
30719
- var triangle = triangles[j];
30720
- if (ray.intersectTriangle(triangle, intersectPoint, backfaceCulling)) {
30721
- success = true;
30722
- hitPositions.push(intersectPoint);
30723
- break;
30724
- }
30725
- }
30726
- }
30727
- else if (hitParams.type === exports.HitTestType.box) {
30728
- var center = hitParams.center, size = hitParams.size;
30729
- var boxMin = center.clone().addScaledVector(size, 0.5);
30730
- var boxMax = center.clone().addScaledVector(size, -0.5);
30731
- if (ray.intersectBox({ min: boxMin, max: boxMax }, intersectPoint)) {
30732
- success = true;
30733
- hitPositions.push(intersectPoint);
30734
- }
30735
- }
30736
- else if (hitParams.type === exports.HitTestType.sphere) {
30737
- var center = hitParams.center, radius = hitParams.radius;
30738
- if (ray.intersectSphere({ center: center, radius: radius }, intersectPoint)) {
30739
- success = true;
30740
- hitPositions.push(intersectPoint);
30741
- }
30742
- }
30743
- else if (hitParams.type === exports.HitTestType.custom) {
30744
- var tempPosition = hitParams.collect(ray, new Vector2(x, y));
30745
- if (tempPosition && tempPosition.length > 0) {
30746
- tempPosition.forEach(function (pos) {
30747
- hitPositions.push(pos);
30748
- });
30749
- success = true;
30750
- }
30751
- }
30752
- if (success) {
30753
- var region = {
30754
- id: item.id,
30755
- name: item.name,
30756
- position: hitPositions[hitPositions.length - 1],
30757
- parentId: item.parentId,
30758
- hitPositions: hitPositions,
30759
- behavior: hitParams.behavior,
30760
- };
30761
- regions.push(region);
30762
- if (stop(region)) {
30763
- return regions;
30764
- }
30765
- }
30766
- }
30767
- }
30768
- }
30767
+ var ray = this.getHitTestRay(x, y);
30768
+ this.content.hitTest(ray, x, y, regions, force, options);
30769
+ this.refContent.forEach(function (ref) {
30770
+ ref.hitTest(ray, x, y, regions, force, options);
30771
+ });
30769
30772
  return regions;
30770
30773
  };
30771
30774
  /**
@@ -32736,9 +32739,9 @@ Geometry.create = function (engine, options) {
32736
32739
  Mesh.create = function (engine, props) {
32737
32740
  return new ThreeMesh(engine, props);
32738
32741
  };
32739
- var version = "1.1.0-alpha.0";
32742
+ var version = "1.1.0-alpha.1";
32740
32743
  console.info({
32741
- content: '[Galacean Effects THREEJS] version: ' + "1.1.0-alpha.0",
32744
+ content: '[Galacean Effects THREEJS] version: ' + "1.1.0-alpha.1",
32742
32745
  type: LOG_TYPE,
32743
32746
  });
32744
32747