@predy-js/render-interface 0.3.4-beta.13 → 0.3.4-beta.15
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 +102 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -124
- package/dist/index.mjs.map +1 -1
- package/dist/src/module.d.ts +0 -1
- package/dist/src/render/EventSystem.d.ts +2 -1
- package/dist/src/render/event/UniversalRecognizer.d.ts +3 -5
- package/dist/statistic.js +1 -1
- package/dist/types/EventSystem.d.ts +5 -9
- package/dist/types/native/GPUBufferInternal.d.ts +1 -0
- package/dist/types/native/PredyNativeInternal.d.ts +2 -0
- package/dist/types/native/index.d.ts +1 -0
- package/dist/types/native/motion.d.ts +20 -0
- package/package.json +1 -1
- package/types/EventSystem.ts +6 -10
- package/types/native/DataBlockInternal.ts +3 -0
- package/types/native/GPUBufferInternal.ts +1 -0
- package/types/native/PredyNativeInternal.ts +4 -0
- package/types/native/index.ts +1 -0
- package/types/native/motion.ts +26 -0
package/dist/index.js
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.
|
5
|
+
* Version: v0.3.4-beta.15
|
6
6
|
*/
|
7
7
|
|
8
8
|
'use strict';
|
@@ -6165,86 +6165,6 @@ var H5Handler = /** @class */ (function () {
|
|
6165
6165
|
return H5Handler;
|
6166
6166
|
}());
|
6167
6167
|
|
6168
|
-
var PredyEventSystem = /** @class */ (function () {
|
6169
|
-
function PredyEventSystem(target, env) {
|
6170
|
-
this._handlerMap = new Map();
|
6171
|
-
this._enabled = true;
|
6172
|
-
this.target = target;
|
6173
|
-
this._platformHandler = this.createPlatformHandler(env);
|
6174
|
-
this._platformHandler.setup();
|
6175
|
-
this.setRecognizer(new BaseRecognizer());
|
6176
|
-
}
|
6177
|
-
Object.defineProperty(PredyEventSystem.prototype, "enabled", {
|
6178
|
-
get: function () {
|
6179
|
-
return this._enabled;
|
6180
|
-
},
|
6181
|
-
set: function (value) {
|
6182
|
-
this._enabled = value;
|
6183
|
-
},
|
6184
|
-
enumerable: false,
|
6185
|
-
configurable: true
|
6186
|
-
});
|
6187
|
-
PredyEventSystem.prototype.createPlatformHandler = function (env) {
|
6188
|
-
switch (env) {
|
6189
|
-
case exports.EventSystemEnv.web:
|
6190
|
-
return new WebHandler(this);
|
6191
|
-
case exports.EventSystemEnv.rn:
|
6192
|
-
return new RNHandler(this);
|
6193
|
-
case exports.EventSystemEnv.h5:
|
6194
|
-
return new H5Handler(this);
|
6195
|
-
default:
|
6196
|
-
throw new Error("Unsupported platform ".concat(env));
|
6197
|
-
}
|
6198
|
-
};
|
6199
|
-
PredyEventSystem.prototype.setRecognizer = function (recognizer) {
|
6200
|
-
recognizer._callback = this.dispatch.bind(this);
|
6201
|
-
this.recognizer = recognizer;
|
6202
|
-
};
|
6203
|
-
// 事件分发入口
|
6204
|
-
PredyEventSystem.prototype.handleBaseEvent = function (event) {
|
6205
|
-
if (!this.enabled) {
|
6206
|
-
return;
|
6207
|
-
}
|
6208
|
-
// 识别手势
|
6209
|
-
var gestureType = this.recognizer.detect(event);
|
6210
|
-
if (gestureType) {
|
6211
|
-
this.dispatch(gestureType, event);
|
6212
|
-
}
|
6213
|
-
if (event.touches.length === 0) {
|
6214
|
-
this.recognizer.reset();
|
6215
|
-
}
|
6216
|
-
};
|
6217
|
-
PredyEventSystem.prototype.dispatch = function (type, event) {
|
6218
|
-
var _a;
|
6219
|
-
(_a = this._handlerMap.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(function (fn) { return fn(event); });
|
6220
|
-
};
|
6221
|
-
PredyEventSystem.prototype.addEventListener = function (type, handler) {
|
6222
|
-
var _this = this;
|
6223
|
-
var set = this._handlerMap.get(type) || new Set();
|
6224
|
-
set.add(handler);
|
6225
|
-
this._handlerMap.set(type, set);
|
6226
|
-
return function () { return _this.removeEventListener(type, handler); };
|
6227
|
-
};
|
6228
|
-
PredyEventSystem.prototype.removeEventListener = function (type, handler) {
|
6229
|
-
var _a;
|
6230
|
-
(_a = this._handlerMap.get(type)) === null || _a === void 0 ? void 0 : _a.delete(handler);
|
6231
|
-
};
|
6232
|
-
PredyEventSystem.prototype.destroy = function () {
|
6233
|
-
this._platformHandler.teardown();
|
6234
|
-
this._handlerMap.clear();
|
6235
|
-
};
|
6236
|
-
return PredyEventSystem;
|
6237
|
-
}());
|
6238
|
-
var BaseRecognizer = /** @class */ (function () {
|
6239
|
-
function BaseRecognizer() {
|
6240
|
-
}
|
6241
|
-
BaseRecognizer.prototype.detect = function (event) {
|
6242
|
-
return event.type;
|
6243
|
-
};
|
6244
|
-
BaseRecognizer.prototype.reset = function () { };
|
6245
|
-
return BaseRecognizer;
|
6246
|
-
}());
|
6247
|
-
|
6248
6168
|
var UniversalRecognizer = /** @class */ (function () {
|
6249
6169
|
function UniversalRecognizer(options) {
|
6250
6170
|
this._state = exports.RecognizerState.UNDETERMINED;
|
@@ -6307,16 +6227,26 @@ var UniversalRecognizer = /** @class */ (function () {
|
|
6307
6227
|
if (![exports.RecognizerState.BEGAN, exports.RecognizerState.ACTIVE].includes(this.state)) {
|
6308
6228
|
return;
|
6309
6229
|
}
|
6310
|
-
//
|
6311
|
-
if (
|
6230
|
+
// 验证触点数量
|
6231
|
+
if (!this.validateTouchCount(event)) {
|
6312
6232
|
this.reset();
|
6313
6233
|
return;
|
6314
6234
|
}
|
6315
|
-
//
|
6316
|
-
if (!this.
|
6235
|
+
// 验证时间区间
|
6236
|
+
if (!this.validateDuration(event)) {
|
6317
6237
|
this.handleFailure();
|
6318
6238
|
return;
|
6319
6239
|
}
|
6240
|
+
// 验证距离区间
|
6241
|
+
if (!this.validateDistance(event)) {
|
6242
|
+
return;
|
6243
|
+
}
|
6244
|
+
// 方向/路径验证
|
6245
|
+
if (this.options.direction !== undefined) {
|
6246
|
+
if (!this.validateDirection(event)) {
|
6247
|
+
return;
|
6248
|
+
}
|
6249
|
+
}
|
6320
6250
|
// 更新状态为持续活动
|
6321
6251
|
if (this.state === exports.RecognizerState.BEGAN) {
|
6322
6252
|
this.setState(exports.RecognizerState.ACTIVE);
|
@@ -6328,9 +6258,8 @@ var UniversalRecognizer = /** @class */ (function () {
|
|
6328
6258
|
if (![exports.RecognizerState.BEGAN, exports.RecognizerState.ACTIVE].includes(this.state)) {
|
6329
6259
|
return;
|
6330
6260
|
}
|
6331
|
-
//
|
6332
|
-
|
6333
|
-
if (isValid) {
|
6261
|
+
// 最终验证
|
6262
|
+
if (this.validateDuration(event)) {
|
6334
6263
|
this.setState(exports.RecognizerState.END);
|
6335
6264
|
if (this.validateThreshold(event)) {
|
6336
6265
|
this.trigger(event);
|
@@ -6344,26 +6273,6 @@ var UniversalRecognizer = /** @class */ (function () {
|
|
6344
6273
|
/**
|
6345
6274
|
* 手势识别核心算法
|
6346
6275
|
*/
|
6347
|
-
UniversalRecognizer.prototype.validateGesture = function (event) {
|
6348
|
-
// 基础验证
|
6349
|
-
if (!this.validateTouchCount(event)) {
|
6350
|
-
return false;
|
6351
|
-
}
|
6352
|
-
if (!this.validateDuration(event)) {
|
6353
|
-
return false;
|
6354
|
-
}
|
6355
|
-
if (!this.validateDistance(event)) {
|
6356
|
-
return false;
|
6357
|
-
}
|
6358
|
-
// 方向/路径验证
|
6359
|
-
if (this.options.direction !== undefined) {
|
6360
|
-
if (!this.validateDirection(event)) {
|
6361
|
-
return false;
|
6362
|
-
}
|
6363
|
-
}
|
6364
|
-
// 高级手势验证
|
6365
|
-
return true;
|
6366
|
-
};
|
6367
6276
|
UniversalRecognizer.prototype.validateTouchCount = function (event) {
|
6368
6277
|
return event.touches.length === this.options.touchCount;
|
6369
6278
|
};
|
@@ -6421,19 +6330,6 @@ var UniversalRecognizer = /** @class */ (function () {
|
|
6421
6330
|
return true;
|
6422
6331
|
}
|
6423
6332
|
};
|
6424
|
-
UniversalRecognizer.prototype.validateFinalConditions = function (event) {
|
6425
|
-
// 验证时间区间
|
6426
|
-
var duration = event.timestamp - this.gestureStartTime;
|
6427
|
-
if (this.options.minDuration && duration < this.options.minDuration) {
|
6428
|
-
return false;
|
6429
|
-
}
|
6430
|
-
if (this.options.maxDuration && duration > this.options.maxDuration) {
|
6431
|
-
return false;
|
6432
|
-
}
|
6433
|
-
// 验证点击次数(需要外部状态管理)
|
6434
|
-
// 此处需要结合外部计数器实现双击等逻辑
|
6435
|
-
return true;
|
6436
|
-
};
|
6437
6333
|
UniversalRecognizer.prototype.calculateOverallDelta = function (event) {
|
6438
6334
|
var _this = this;
|
6439
6335
|
// 计算多点触控的平均移动量
|
@@ -6599,7 +6495,91 @@ var UniversalRecognizer = /** @class */ (function () {
|
|
6599
6495
|
return UniversalRecognizer;
|
6600
6496
|
}());
|
6601
6497
|
|
6602
|
-
|
6498
|
+
var PredyEventSystem = /** @class */ (function () {
|
6499
|
+
function PredyEventSystem(target, env) {
|
6500
|
+
this._handlerMap = new Map();
|
6501
|
+
this._enabled = true;
|
6502
|
+
this.target = target;
|
6503
|
+
this._platformHandler = this.createPlatformHandler(env);
|
6504
|
+
this._platformHandler.setup();
|
6505
|
+
this.setRecognizer(new BaseRecognizer());
|
6506
|
+
}
|
6507
|
+
Object.defineProperty(PredyEventSystem.prototype, "enabled", {
|
6508
|
+
get: function () {
|
6509
|
+
return this._enabled;
|
6510
|
+
},
|
6511
|
+
set: function (value) {
|
6512
|
+
this._enabled = value;
|
6513
|
+
},
|
6514
|
+
enumerable: false,
|
6515
|
+
configurable: true
|
6516
|
+
});
|
6517
|
+
PredyEventSystem.prototype.createPlatformHandler = function (env) {
|
6518
|
+
switch (env) {
|
6519
|
+
case exports.EventSystemEnv.web:
|
6520
|
+
return new WebHandler(this);
|
6521
|
+
case exports.EventSystemEnv.rn:
|
6522
|
+
return new RNHandler(this);
|
6523
|
+
case exports.EventSystemEnv.h5:
|
6524
|
+
return new H5Handler(this);
|
6525
|
+
default:
|
6526
|
+
throw new Error("Unsupported platform ".concat(env));
|
6527
|
+
}
|
6528
|
+
};
|
6529
|
+
PredyEventSystem.prototype.setRecognizer = function (recognizer) {
|
6530
|
+
recognizer._callback = this.dispatch.bind(this);
|
6531
|
+
this.recognizer = recognizer;
|
6532
|
+
};
|
6533
|
+
PredyEventSystem.prototype.setUniversalRecognizer = function (options) {
|
6534
|
+
var r = new UniversalRecognizer(options);
|
6535
|
+
this.setRecognizer(r);
|
6536
|
+
};
|
6537
|
+
// 事件分发入口
|
6538
|
+
PredyEventSystem.prototype.handleBaseEvent = function (event) {
|
6539
|
+
if (!this.enabled) {
|
6540
|
+
return;
|
6541
|
+
}
|
6542
|
+
// 识别手势
|
6543
|
+
var gestureType = this.recognizer.detect(event);
|
6544
|
+
if (gestureType) {
|
6545
|
+
this.dispatch(gestureType, event);
|
6546
|
+
}
|
6547
|
+
if (event.touches.length === 0) {
|
6548
|
+
this.recognizer.reset();
|
6549
|
+
}
|
6550
|
+
};
|
6551
|
+
PredyEventSystem.prototype.dispatch = function (type, event) {
|
6552
|
+
var _a;
|
6553
|
+
(_a = this._handlerMap.get(type)) === null || _a === void 0 ? void 0 : _a.forEach(function (fn) { return fn(event); });
|
6554
|
+
};
|
6555
|
+
PredyEventSystem.prototype.addEventListener = function (type, handler) {
|
6556
|
+
var _this = this;
|
6557
|
+
var set = this._handlerMap.get(type) || new Set();
|
6558
|
+
set.add(handler);
|
6559
|
+
this._handlerMap.set(type, set);
|
6560
|
+
return function () { return _this.removeEventListener(type, handler); };
|
6561
|
+
};
|
6562
|
+
PredyEventSystem.prototype.removeEventListener = function (type, handler) {
|
6563
|
+
var _a;
|
6564
|
+
(_a = this._handlerMap.get(type)) === null || _a === void 0 ? void 0 : _a.delete(handler);
|
6565
|
+
};
|
6566
|
+
PredyEventSystem.prototype.destroy = function () {
|
6567
|
+
this._platformHandler.teardown();
|
6568
|
+
this._handlerMap.clear();
|
6569
|
+
};
|
6570
|
+
return PredyEventSystem;
|
6571
|
+
}());
|
6572
|
+
var BaseRecognizer = /** @class */ (function () {
|
6573
|
+
function BaseRecognizer() {
|
6574
|
+
}
|
6575
|
+
BaseRecognizer.prototype.detect = function (event) {
|
6576
|
+
return event.type;
|
6577
|
+
};
|
6578
|
+
BaseRecognizer.prototype.reset = function () { };
|
6579
|
+
return BaseRecognizer;
|
6580
|
+
}());
|
6581
|
+
|
6582
|
+
consoleLog('version: ' + "0.3.4-beta.15");
|
6603
6583
|
var ModuleMsg = 'RI Package: @predy-js/render-interface';
|
6604
6584
|
|
6605
6585
|
var RI = /*#__PURE__*/Object.freeze({
|
@@ -6621,7 +6601,6 @@ var RI = /*#__PURE__*/Object.freeze({
|
|
6621
6601
|
setDefaultTextureFactory: setDefaultTextureFactory,
|
6622
6602
|
MarsTextureFactory: MarsTextureFactory,
|
6623
6603
|
EventSystem: PredyEventSystem,
|
6624
|
-
PredyUniversalRecognizer: UniversalRecognizer,
|
6625
6604
|
get DestroyOptions () { return exports.DestroyOptions; },
|
6626
6605
|
get PredyTextEncoding () { return exports.PredyTextEncoding; },
|
6627
6606
|
get PredyVideoCodec () { return exports.PredyVideoCodec; },
|
@@ -6669,7 +6648,6 @@ exports.Material = MarsMaterial;
|
|
6669
6648
|
exports.MaterialDataBlock = MarsMaterialDataBlock;
|
6670
6649
|
exports.Mesh = MarsMesh;
|
6671
6650
|
exports.ModuleMsg = ModuleMsg;
|
6672
|
-
exports.PredyUniversalRecognizer = UniversalRecognizer;
|
6673
6651
|
exports.RenderFrame = MarsRenderFrame;
|
6674
6652
|
exports.RenderPass = MarsRenderPass;
|
6675
6653
|
exports.RenderPassPriorityNormal = RenderPassPriorityNormal;
|