@predy-js/render-interface 0.3.4-beta.15 → 0.3.4-beta.16

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
@@ -2,7 +2,7 @@
2
2
  * Name: @predy-js/render-interface
3
3
  * Description: undefined
4
4
  * Author: undefined
5
- * Version: v0.3.4-beta.15
5
+ * Version: v0.3.4-beta.16
6
6
  */
7
7
 
8
8
  /******************************************************************************
@@ -193,6 +193,12 @@ var EVENT_TYPE_TOUCH_START = 'touchstart';
193
193
  var EVENT_TYPE_TOUCH_MOVE = 'touchmove';
194
194
  var EVENT_TYPE_TOUCH_END = 'touchend';
195
195
  var EVENT_TYPE_TOUCH_CANCEL = 'touchcancel';
196
+ var PredyNativeEventType;
197
+ (function (PredyNativeEventType) {
198
+ PredyNativeEventType[PredyNativeEventType["touchstart"] = 1] = "touchstart";
199
+ PredyNativeEventType[PredyNativeEventType["touchmove"] = 2] = "touchmove";
200
+ PredyNativeEventType[PredyNativeEventType["touchend"] = 3] = "touchend";
201
+ })(PredyNativeEventType || (PredyNativeEventType = {}));
196
202
  // // 扩展事件类型
197
203
  // export enum EVENT_TYPE {
198
204
  // // 基础事件
@@ -6035,15 +6041,17 @@ var WebHandler = /** @class */ (function () {
6035
6041
  };
6036
6042
  WebHandler.prototype.handleEvent = function (type, e) {
6037
6043
  e.preventDefault();
6038
- var np = this.getNormalizedPos(e);
6044
+ // const np = this.getNormalizedPos(e);
6045
+ var rect = e.target.getBoundingClientRect();
6039
6046
  var pointer = {
6040
6047
  id: e.pointerId,
6041
- x: np[0],
6042
- y: np[1],
6043
- clientX: e.clientX,
6044
- clientY: e.clientY,
6045
- force: 1,
6048
+ x: e.clientX - rect.left,
6049
+ y: e.clientY - rect.top,
6046
6050
  ts: this.timeStamp,
6051
+ layout: {
6052
+ width: rect.width,
6053
+ height: rect.height,
6054
+ },
6047
6055
  };
6048
6056
  // 更新触点集合
6049
6057
  if (type === EVENT_TYPE_TOUCH_END) {
@@ -6070,7 +6078,12 @@ var WebHandler = /** @class */ (function () {
6070
6078
 
6071
6079
  var RNHandler = /** @class */ (function () {
6072
6080
  function RNHandler(system) {
6081
+ var _this = this;
6073
6082
  this.system = system;
6083
+ this.handleTouch = function (e) {
6084
+ e.preventDefault();
6085
+ _this.system.handleBaseEvent(e);
6086
+ };
6074
6087
  this.timeOrigin = Date.now();
6075
6088
  }
6076
6089
  Object.defineProperty(RNHandler.prototype, "timeStamp", {
@@ -6081,10 +6094,16 @@ var RNHandler = /** @class */ (function () {
6081
6094
  configurable: true
6082
6095
  });
6083
6096
  RNHandler.prototype.setup = function () {
6084
- throw new Error('Method not implemented.');
6097
+ var target = this.system.target;
6098
+ target.addEventListener('touchstart', this.handleTouch);
6099
+ target.addEventListener('touchmove', this.handleTouch);
6100
+ target.addEventListener('touchend', this.handleTouch);
6085
6101
  };
6086
6102
  RNHandler.prototype.teardown = function () {
6087
- throw new Error('Method not implemented.');
6103
+ var target = this.system.target;
6104
+ target.removeEventListener('touchstart', this.handleTouch);
6105
+ target.removeEventListener('touchmove', this.handleTouch);
6106
+ target.removeEventListener('touchend', this.handleTouch);
6088
6107
  };
6089
6108
  return RNHandler;
6090
6109
  }());
@@ -6099,7 +6118,7 @@ var H5Handler = /** @class */ (function () {
6099
6118
  var event = {
6100
6119
  type: type,
6101
6120
  timestamp: _this.timeStamp,
6102
- target: e.target,
6121
+ // target: e.target,
6103
6122
  touches: _this.encapsulate(e.targetTouches),
6104
6123
  changedTouches: _this.encapsulate(e.changedTouches),
6105
6124
  preventDefault: function () { return e.preventDefault(); },
@@ -6145,15 +6164,17 @@ var H5Handler = /** @class */ (function () {
6145
6164
  var touches = [];
6146
6165
  for (var i = 0; i < list.length; i++) {
6147
6166
  var touch = list[i];
6148
- var _a = this.getNormalizedPos(touch), x = _a[0], y = _a[1];
6167
+ // const [x, y] = this.getNormalizedPos(touch);
6168
+ var rect = touch.target.getBoundingClientRect();
6149
6169
  touches.push({
6150
6170
  id: touch.identifier,
6151
- x: x,
6152
- y: y,
6153
- clientX: touch.clientX,
6154
- clientY: touch.clientY,
6155
- force: 1,
6171
+ x: touch.clientX - rect.left,
6172
+ y: touch.clientY - rect.top,
6156
6173
  ts: this.timeStamp,
6174
+ layout: {
6175
+ width: rect.width,
6176
+ height: rect.height,
6177
+ },
6157
6178
  });
6158
6179
  }
6159
6180
  return touches;
@@ -6211,7 +6232,7 @@ var UniversalRecognizer = /** @class */ (function () {
6211
6232
  this.gestureStartTime = event.timestamp;
6212
6233
  this.trackedTouches.clear();
6213
6234
  event.touches.forEach(function (t) { return _this.trackedTouches.set(t.id, t); });
6214
- this.startPositions = event.touches.map(function (t) { return [t.clientX, t.clientY]; });
6235
+ this.startPositions = event.touches.map(function (t) { return [t.x, t.y]; });
6215
6236
  // 初始化多指手势数据
6216
6237
  if (this.options.touchCount > 1) {
6217
6238
  this.initialCenter = this.calculateCenter(event.touches);
@@ -6331,8 +6352,8 @@ var UniversalRecognizer = /** @class */ (function () {
6331
6352
  // 计算多点触控的平均移动量
6332
6353
  var totalDelta = [0, 0];
6333
6354
  event.touches.forEach(function (t, idx) {
6334
- totalDelta[0] += t.clientX - _this.startPositions[idx][0];
6335
- totalDelta[1] += t.clientY - _this.startPositions[idx][1];
6355
+ totalDelta[0] += t.x - _this.startPositions[idx][0];
6356
+ totalDelta[1] += t.y - _this.startPositions[idx][1];
6336
6357
  });
6337
6358
  return [totalDelta[0] / event.touches.length, totalDelta[1] / event.touches.length];
6338
6359
  };
@@ -6344,7 +6365,7 @@ var UniversalRecognizer = /** @class */ (function () {
6344
6365
  var currentCentroid = this.calculateCenter(touches);
6345
6366
  // 计算所有触点到中心点的平均距离
6346
6367
  var currentDistances = touches.map(function (t) {
6347
- return Math.hypot(t.clientX - currentCentroid[0], t.clientY - currentCentroid[1]);
6368
+ return Math.hypot(t.x - currentCentroid[0], t.y - currentCentroid[1]);
6348
6369
  });
6349
6370
  var currentAvgDistance = currentDistances.reduce(function (a, b) { return a + b; }) / touches.length;
6350
6371
  // 初始平均距离(从startPositions计算)
@@ -6363,7 +6384,7 @@ var UniversalRecognizer = /** @class */ (function () {
6363
6384
  var totalAngleChange = 0;
6364
6385
  touches.forEach(function (t, index) {
6365
6386
  // 当前触点角度
6366
- var currentAngle = Math.atan2(t.clientY - currentCentroid[1], t.clientX - currentCentroid[0]);
6387
+ var currentAngle = Math.atan2(t.y - currentCentroid[1], t.x - currentCentroid[0]);
6367
6388
  // 初始触点角度
6368
6389
  var initialPos = _this.startPositions[index];
6369
6390
  var initialAngle = Math.atan2(initialPos[1] - _this.initialCenter[1], initialPos[0] - _this.initialCenter[0]);
@@ -6384,14 +6405,14 @@ var UniversalRecognizer = /** @class */ (function () {
6384
6405
  UniversalRecognizer.prototype.calculateCenter = function (touchList) {
6385
6406
  var pointersLength = touchList.length;
6386
6407
  if (pointersLength === 1) {
6387
- return [touchList[0].clientX, touchList[0].clientY];
6408
+ return [touchList[0].x, touchList[0].y];
6388
6409
  }
6389
6410
  var x = 0;
6390
6411
  var y = 0;
6391
6412
  var i = 0;
6392
6413
  while (i < pointersLength) {
6393
- x += touchList[i].clientX;
6394
- y += touchList[i].clientY;
6414
+ x += touchList[i].x;
6415
+ y += touchList[i].y;
6395
6416
  i++;
6396
6417
  }
6397
6418
  return [x / pointersLength, y / pointersLength];
@@ -6575,7 +6596,7 @@ var BaseRecognizer = /** @class */ (function () {
6575
6596
  return BaseRecognizer;
6576
6597
  }());
6577
6598
 
6578
- consoleLog('version: ' + "0.3.4-beta.15");
6599
+ consoleLog('version: ' + "0.3.4-beta.16");
6579
6600
  var ModuleMsg = 'RI Package: @predy-js/render-interface';
6580
6601
 
6581
6602
  var RI = /*#__PURE__*/Object.freeze({
@@ -6618,6 +6639,7 @@ var RI = /*#__PURE__*/Object.freeze({
6618
6639
  EVENT_TYPE_TOUCH_MOVE: EVENT_TYPE_TOUCH_MOVE,
6619
6640
  EVENT_TYPE_TOUCH_END: EVENT_TYPE_TOUCH_END,
6620
6641
  EVENT_TYPE_TOUCH_CANCEL: EVENT_TYPE_TOUCH_CANCEL,
6642
+ get PredyNativeEventType () { return PredyNativeEventType; },
6621
6643
  get GESTURE_DIRECTION () { return GESTURE_DIRECTION; },
6622
6644
  get ShaderCompileResultStatus () { return ShaderCompileResultStatus; },
6623
6645
  ShaderLibraryEmpty: ShaderLibraryEmpty
@@ -6630,5 +6652,5 @@ else if (typeof global === 'object') {
6630
6652
  global.PredyRI = RI;
6631
6653
  }
6632
6654
 
6633
- export { DestroyOptions, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_CANCEL, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, PredyEventSystem as EventSystem, EventSystemEnv, GESTURE_DIRECTION, GPUBufferOptionsMemoryShared, MarsGeometry as Geometry, MarsInstancedMesh as InstancedMesh, MarsTextureFactory, MarsMaterial as Material, MarsMaterialDataBlock as MaterialDataBlock, MarsMesh as Mesh, ModuleMsg, PredyResourceCacheStatus, PredyTextEncoding, PredyVideoCodec, RecognizerState, MarsRenderFrame as RenderFrame, MarsRenderPass as RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassMeshOrder, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, MarsRenderer as Renderer, ShaderCompileResultStatus, ShaderLibraryEmpty, MarsSharedGeometry as SharedGeometry, MarsTexture as Texture, TextureLoadAction, TextureSourceType, TextureStoreAction, constants, getDefaultGPUCapability, getDefaultTextureFactory, setDefaultTextureFactory };
6655
+ export { DestroyOptions, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_CANCEL, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, PredyEventSystem as EventSystem, EventSystemEnv, GESTURE_DIRECTION, GPUBufferOptionsMemoryShared, MarsGeometry as Geometry, MarsInstancedMesh as InstancedMesh, MarsTextureFactory, MarsMaterial as Material, MarsMaterialDataBlock as MaterialDataBlock, MarsMesh as Mesh, ModuleMsg, PredyNativeEventType, PredyResourceCacheStatus, PredyTextEncoding, PredyVideoCodec, RecognizerState, MarsRenderFrame as RenderFrame, MarsRenderPass as RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassMeshOrder, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, MarsRenderer as Renderer, ShaderCompileResultStatus, ShaderLibraryEmpty, MarsSharedGeometry as SharedGeometry, MarsTexture as Texture, TextureLoadAction, TextureSourceType, TextureStoreAction, constants, getDefaultGPUCapability, getDefaultTextureFactory, setDefaultTextureFactory };
6634
6656
  //# sourceMappingURL=index.mjs.map