@shijiu/jsview-vue 2.2.128 → 2.2.201
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/bin/browser/BrowserApic.vue.mjs +2 -2
- package/bin/browser/BrowserApic2.vue.mjs +2 -2
- package/bin/browser/BrowserApicLib.mjs +8 -2
- package/bin/browser/BrowserJsvFragShaderView.vue.mjs +63 -0
- package/bin/jsview-vue.mjs +1604 -423
- package/bin/types/JsViewEngineWidget/JsvFocus/JsvFocusManager.d.ts +8 -6
- package/bin/types/JsViewEngineWidget/MetroWidget/Dispatcher.d.ts +10 -12
- package/bin/types/JsViewEngineWidget/MetroWidget/ListWidget.vue.d.ts +3 -3
- package/bin/types/JsViewEngineWidget/MetroWidget/MetroWidget.vue.d.ts +3 -3
- package/bin/types/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.d.ts +2 -2
- package/bin/types/JsViewEngineWidget/MetroWidget/RenderItem.d.ts +3 -0
- package/bin/types/JsViewEngineWidget/TemplateParser/ListMetroTemplate.d.ts +1 -0
- package/bin/types/JsViewEngineWidget/TemplateParser/TemplateItemAdder.d.ts +1 -1
- package/bin/types/JsViewEngineWidget/index.d.ts +10 -1
- package/bin/types/JsViewVueTools/ConstSymbol.d.ts +2 -2
- package/bin/types/JsViewVueTools/JsvFederationTools.d.ts +16 -0
- package/bin/types/JsViewVueTools/JsvPerformance.d.ts +5 -0
- package/bin/types/JsViewVueTools/JsvPreDownloader.d.ts +33 -0
- package/bin/types/JsViewVueTools/JsvTextureStore/JsvTextureStore.d.ts +45 -1
- package/bin/types/JsViewVueTools/index.d.ts +19 -11
- package/bin/types/JsViewVueWidget/JsvApic/JsvApic/BrowserApic.vue.d.ts +1 -1
- package/bin/types/JsViewVueWidget/JsvApic/JsvApic/JsvApic.vue.d.ts +1 -1
- package/bin/types/JsViewVueWidget/JsvApic/JsvApic2/BrowserApic2.vue.d.ts +1 -1
- package/bin/types/JsViewVueWidget/JsvApic/JsvApic2/JsvApic2.vue.d.ts +1 -1
- package/bin/types/JsViewVueWidget/JsvApic/JsvBrowserApicLib/Viewer.d.ts +2 -1
- package/bin/types/JsViewVueWidget/JsvClipDiv/JsvClipDiv.vue.d.ts +70 -0
- package/bin/types/JsViewVueWidget/JsvClipDiv/index.d.ts +1 -0
- package/bin/types/JsViewVueWidget/JsvDriftScope/JsvDriftScope.vue.d.ts +104 -0
- package/bin/types/JsViewVueWidget/JsvDriftScope/index.d.ts +1 -0
- package/bin/types/JsViewVueWidget/JsvFragShaderView/BrowserJsvFragShaderView.vue.d.ts +13 -0
- package/bin/types/JsViewVueWidget/JsvFragShaderView/JsvFragShaderView.vue.d.ts +13 -0
- package/bin/types/JsViewVueWidget/JsvFragShaderView/index.d.ts +2 -0
- package/bin/types/JsViewVueWidget/JsvFreeMoveActor/ActorControl.d.ts +43 -17
- package/bin/types/JsViewVueWidget/JsvFreeMoveActor/SetAction.d.ts +5 -5
- package/bin/types/JsViewVueWidget/JsvFreeMoveActor/SetCondition.d.ts +4 -2
- package/bin/types/JsViewVueWidget/JsvFreeMoveActor/SetState.d.ts +7 -7
- package/bin/types/JsViewVueWidget/JsvFreeMoveActor/SyncLinkManager.d.ts +18 -0
- package/bin/types/JsViewVueWidget/JsvFreeMoveActor/index.d.ts +2 -0
- package/bin/types/JsViewVueWidget/JsvNinePatch.vue.d.ts +1 -0
- package/bin/types/JsViewVueWidget/JsvScrollBox/JsvScrollBox.vue.d.ts +61 -1
- package/bin/types/JsViewVueWidget/JsvScrollBox/JsvScrollFollow.vue.d.ts +153 -0
- package/bin/types/JsViewVueWidget/JsvScrollBox/ScrollInnerSymbol.d.ts +4 -0
- package/bin/types/JsViewVueWidget/JsvScrollBox/ScrollSymbol.d.ts +9 -4
- package/bin/types/JsViewVueWidget/JsvScrollBox/index.d.ts +2 -0
- package/bin/types/JsViewVueWidget/index.d.ts +3 -0
- package/package.json +1 -1
- package/tools/config/rollup.config.mjs +1 -0
- package/utils/JsViewEngineWidget/JsvFocus/{JsvFocusManager.js → JsvFocusManager.ts} +12 -12
- package/utils/JsViewEngineWidget/MetroWidget/Dispatcher.ts +20 -0
- package/utils/JsViewEngineWidget/MetroWidget/ListWidget.vue +27 -10
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +42 -10
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.js +320 -203
- package/utils/JsViewEngineWidget/MetroWidget/RenderItem.ts +11 -0
- package/utils/JsViewEngineWidget/MetroWidget/TaskManager.ts +8 -0
- package/utils/JsViewEngineWidget/TemplateParser/CommonMetroTemplate.ts +20 -10
- package/utils/JsViewEngineWidget/TemplateParser/ListMetroTemplate.ts +18 -0
- package/utils/JsViewEngineWidget/TemplateParser/TemplateItemAdder.ts +7 -0
- package/utils/JsViewEngineWidget/{index.js → index.ts} +1 -1
- package/utils/JsViewPlugin/JsvAudio/AudioProxy.js +21 -2
- package/utils/JsViewVueTools/ConstSymbol.ts +2 -2
- package/utils/JsViewVueTools/JsvPreDownloader.ts +3 -3
- package/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.ts +1 -1
- package/utils/JsViewVueTools/index.js +19 -19
- package/utils/JsViewVueWidget/JsvApic/JsvApic/BrowserApic.vue +2 -2
- package/utils/JsViewVueWidget/JsvApic/JsvApic/JsvApic.vue +3 -3
- package/utils/JsViewVueWidget/JsvApic/JsvApic2/BrowserApic2.vue +2 -2
- package/utils/JsViewVueWidget/JsvApic/JsvApic2/JsvApic2.vue +3 -3
- package/utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/Viewer.js +8 -3
- package/utils/JsViewVueWidget/JsvClipDiv/JsvClipDiv.vue +42 -0
- package/utils/JsViewVueWidget/JsvClipDiv/index.ts +1 -0
- package/utils/JsViewVueWidget/JsvConnectLine/JsvConnectLine.vue +5 -1
- package/utils/JsViewVueWidget/JsvDriftScope/JsvDriftScope.vue +82 -0
- package/utils/JsViewVueWidget/JsvDriftScope/index.ts +1 -0
- package/utils/JsViewVueWidget/JsvFragShaderView/BrowserJsvFragShaderView.vue +48 -0
- package/utils/JsViewVueWidget/JsvFragShaderView/JsvFragShaderView.vue +145 -0
- package/utils/JsViewVueWidget/JsvFragShaderView/index.js +18 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorControl.ts +142 -63
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.ts +15 -6
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetCondition.ts +19 -7
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.ts +15 -11
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SyncLinkManager.ts +120 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/index.js +5 -1
- package/utils/JsViewVueWidget/JsvNinePatch.vue +13 -1
- package/utils/JsViewVueWidget/JsvScrollBox/JsvScrollBox.vue +257 -48
- package/utils/JsViewVueWidget/JsvScrollBox/JsvScrollFollow.vue +468 -0
- package/utils/JsViewVueWidget/JsvScrollBox/ScrollInnerSymbol.ts +9 -0
- package/utils/JsViewVueWidget/JsvScrollBox/ScrollSymbol.ts +13 -4
- package/utils/JsViewVueWidget/JsvScrollBox/index.ts +3 -0
- package/utils/JsViewVueWidget/index.js +3 -0
- package/utils/JsViewEngineWidget/MetroWidget/Dispatcher.js +0 -19
- package/utils/JsViewVueWidget/JsvScrollBox/index.js +0 -2
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
[模块 export 内容]
|
|
3
|
+
JsvFragShaderView:自定义Fragment shader的组件
|
|
4
|
+
props说明:
|
|
5
|
+
style {Object} (必填)left, top, width, height
|
|
6
|
+
shaderStr {String} (必填)shader的函数体
|
|
7
|
+
duration {int} 动画时长
|
|
8
|
+
autoplay {boolean} 自动播放
|
|
9
|
+
uniforms {Array} uniform参数, [{ name: string, value: number }]
|
|
10
|
+
textures {Array} texture参数, [{ name: string, resource: string }]
|
|
11
|
+
methods:
|
|
12
|
+
startAnim
|
|
13
|
+
@description 开始动画
|
|
14
|
+
@params {int} duration: 动画时长, 默认为props.duration
|
|
15
|
+
stopAnim
|
|
16
|
+
@description 停止动画
|
|
17
|
+
shader函数体说明:
|
|
18
|
+
参考网站: https://www.shadertoy.com
|
|
19
|
+
主函数:
|
|
20
|
+
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
|
21
|
+
@params {vec4} fragColor: 输出的片元颜色
|
|
22
|
+
@params {vec2} fragCoord: 片元坐标, 左下角为原点, 往右为x正, 往上为y正
|
|
23
|
+
注意事项:
|
|
24
|
+
* 盒子端使用OpenGL ES 2.0版本, 而网站 https://www.shadertoy.com 上使用WebGL, glsl支持的函数和操作符有区别.
|
|
25
|
+
* 由于坐标系的差异, texture()采样函数需要替换为jsvTexture2D()
|
|
26
|
+
* 盒子端的精度有限, 可能会出现精度导致的计算错误
|
|
27
|
+
|
|
28
|
+
-->
|
|
29
|
+
<script setup>
|
|
30
|
+
import { onMounted, onBeforeUnmount } from "vue";
|
|
31
|
+
import { Forge } from "@shijiu/jsview/dom/jsv-forge-define";
|
|
32
|
+
import ForgeHandles from "../../JsViewVueTools/ForgeHandles";
|
|
33
|
+
|
|
34
|
+
const props = defineProps({
|
|
35
|
+
style: {
|
|
36
|
+
type: Object,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
duration: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: -1,
|
|
42
|
+
},
|
|
43
|
+
autoplay: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: false,
|
|
46
|
+
},
|
|
47
|
+
shaderStr: {
|
|
48
|
+
type: String,
|
|
49
|
+
required: true,
|
|
50
|
+
},
|
|
51
|
+
// [{ name: string, value: number }]
|
|
52
|
+
uniforms: {
|
|
53
|
+
type: Array,
|
|
54
|
+
},
|
|
55
|
+
// [{ name: string, type: number, resource: string }]
|
|
56
|
+
textures: {
|
|
57
|
+
type: Array,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
//uniforms
|
|
62
|
+
let uniformList = [];
|
|
63
|
+
if (props.uniforms) {
|
|
64
|
+
for (let item of props.uniforms) {
|
|
65
|
+
uniformList.push({
|
|
66
|
+
name: item.name,
|
|
67
|
+
type: 1,
|
|
68
|
+
value: item.value,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//prepare texture
|
|
74
|
+
let textureList = [];
|
|
75
|
+
if (props.textures) {
|
|
76
|
+
const texture_manager = ForgeHandles.TextureManager;
|
|
77
|
+
for (let item of props.textures) {
|
|
78
|
+
if (typeof item.resource == "string") {
|
|
79
|
+
let image_url = item.resource;
|
|
80
|
+
if (item.resource && item.resource.trim().indexOf("url(") === 0) {
|
|
81
|
+
image_url = new window.JsView.Dom.UrlRef(image_url).href;
|
|
82
|
+
}
|
|
83
|
+
const texture = texture_manager.GetImage2(
|
|
84
|
+
image_url,
|
|
85
|
+
false,
|
|
86
|
+
null,
|
|
87
|
+
"RGB_8888",
|
|
88
|
+
null
|
|
89
|
+
);
|
|
90
|
+
textureList.push({
|
|
91
|
+
name: item.name,
|
|
92
|
+
id: texture.TexId,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const fragShaderView = new Forge.FragShaderView();
|
|
99
|
+
fragShaderView.SetShaderInfo(
|
|
100
|
+
props.shaderStr,
|
|
101
|
+
uniformList,
|
|
102
|
+
textureList,
|
|
103
|
+
(state, detail) => {
|
|
104
|
+
console.log("haha", state, detail);
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
let viewId = Forge.sViewStore.add(new Forge.ViewInfo(fragShaderView, ""));
|
|
108
|
+
|
|
109
|
+
const { left, top, width, height } = props.style;
|
|
110
|
+
|
|
111
|
+
const startAnim = (d) => {
|
|
112
|
+
let duration = typeof d == "number" ? d : props.duration;
|
|
113
|
+
if (duration > 0) {
|
|
114
|
+
let shaderAnimation = new Forge.ShaderAnimation(duration, null);
|
|
115
|
+
fragShaderView.StartAnimation(shaderAnimation);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const stopAnim = () => {
|
|
120
|
+
fragShaderView?.StopAnimation();
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
onMounted(() => {
|
|
124
|
+
if (props.autoplay) {
|
|
125
|
+
startAnim(props.duration);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
onBeforeUnmount(() => {
|
|
130
|
+
if (viewId != -1) {
|
|
131
|
+
Forge.sViewStore.remove(viewId);
|
|
132
|
+
viewId = -1;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
defineExpose({
|
|
136
|
+
startAnim,
|
|
137
|
+
stopAnim,
|
|
138
|
+
});
|
|
139
|
+
</script>
|
|
140
|
+
<template>
|
|
141
|
+
<div
|
|
142
|
+
:style="{ left, top, width, height }"
|
|
143
|
+
:data-jsv-vw-innerview="viewId"
|
|
144
|
+
></div>
|
|
145
|
+
</template>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2021-10-13 15:12:45
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2021-11-22 14:24:36
|
|
6
|
+
* @Description: file content
|
|
7
|
+
*/
|
|
8
|
+
//! 考虑到.vue文件除了export default的component外,还有可能export其他对象,因此使用import * as
|
|
9
|
+
import * as JsvFragShaderView from "./JsvFragShaderView.vue";
|
|
10
|
+
|
|
11
|
+
let _JsvFragShaderView;
|
|
12
|
+
if (window.JsView) {
|
|
13
|
+
_JsvFragShaderView = JsvFragShaderView.default;
|
|
14
|
+
} else {
|
|
15
|
+
const BrowserJsvFragShaderView = await import("./BrowserJsvFragShaderView.vue");
|
|
16
|
+
_JsvFragShaderView = BrowserJsvFragShaderView.default;
|
|
17
|
+
}
|
|
18
|
+
export default _JsvFragShaderView;
|
|
@@ -12,83 +12,36 @@ import ActionRefObject from "./ActionRefObject";
|
|
|
12
12
|
import { RunFreeMoveCmdPacks, FreeMoveAnimClass, FinishRenderBreak } from "./ForgeTypeDefine"
|
|
13
13
|
import { NexusNode, newNexus } from "./NexusNode";
|
|
14
14
|
|
|
15
|
+
interface CmdListCreator {
|
|
16
|
+
(builders: BuilderFactory): Array<Object>;
|
|
17
|
+
}
|
|
15
18
|
|
|
16
|
-
class
|
|
17
|
-
private _BindView: any;
|
|
18
|
-
private _BindAnim: any;
|
|
19
|
-
private _Callbacks: CallbackManager;
|
|
20
|
-
private _SelfNexusRecv: NexusNode;
|
|
21
|
-
private _SizeMode: Boolean = false;
|
|
22
|
-
|
|
19
|
+
class BuilderFactory {
|
|
23
20
|
private _SharedQuickConditionPackBuilder: ConditionPackBuilder;
|
|
24
21
|
private _SharedQuickActionPackBuilder: ActionPackBuilder;
|
|
25
22
|
private _StatePackBuilder: StatePackBuilder;
|
|
23
|
+
private _Callbacks: CallbackManager;
|
|
24
|
+
private _SelfNexusRecv: NexusNode;
|
|
25
|
+
private _OwnerControl: ActorControl;
|
|
26
26
|
|
|
27
|
-
constructor() {
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
this._SharedQuickConditionPackBuilder = new ConditionPackBuilder(this._Callbacks, this._SelfNexusRecv);
|
|
27
|
+
constructor(owner: ActorControl, callbackManager: CallbackManager, selfNexusRecv: NexusNode) {
|
|
28
|
+
this._OwnerControl = owner;
|
|
29
|
+
this._Callbacks = callbackManager;
|
|
30
|
+
this._SelfNexusRecv = selfNexusRecv;
|
|
31
|
+
|
|
32
|
+
this._SharedQuickConditionPackBuilder = new ConditionPackBuilder(this._Callbacks, this._SelfNexusRecv, this);
|
|
33
33
|
this._SharedQuickActionPackBuilder = new ActionPackBuilder(this._Callbacks, this._SelfNexusRecv);
|
|
34
34
|
this._StatePackBuilder = new StatePackBuilder();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
asSizeMode() {
|
|
38
|
-
if (this._BindAnim != null) {
|
|
39
|
-
console.error("error: asSizeMode should call before bindForgeView");
|
|
40
|
-
} else {
|
|
41
|
-
this._SizeMode = true;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// debugGetAnimId() {
|
|
46
|
-
// return this._BindAnim?.AnimNativeId;
|
|
47
|
-
// }
|
|
48
|
-
|
|
49
|
-
bindForgeView(bindView: any, instantActive: boolean) {
|
|
50
|
-
this._BindView = bindView;
|
|
51
|
-
|
|
52
|
-
if (instantActive) {
|
|
53
|
-
this._EnsureAnim();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* run 执行编排好的intent集合
|
|
59
|
-
*
|
|
60
|
-
* @param {Array} cmdPackList 内容来自 Condition(), State(), Action() 这些工厂类创建的Command pack
|
|
61
|
-
*/
|
|
62
|
-
run(cmdPackList: Array<Object>) {
|
|
63
|
-
if ((window as any).JsView) {
|
|
64
|
-
this._WrappedRun(cmdPackList);
|
|
65
|
-
} else {
|
|
66
|
-
// Browser场景DomProxy需要onReady调用
|
|
67
|
-
let that = this;
|
|
68
|
-
this._BindView.RegisterOnProxyReady(() => {
|
|
69
|
-
that._WrappedRun(cmdPackList);
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
_WrappedRun(cmdPackList: Array<Object>) {
|
|
75
|
-
this._EnsureAnim();
|
|
76
|
-
|
|
77
|
-
if (!(cmdPackList instanceof Array)) {
|
|
78
|
-
console.error("params error");
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
RunFreeMoveCmdPacks(this._BindView, cmdPackList);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
37
|
/**
|
|
86
38
|
* Condition
|
|
87
39
|
* 获取创建 ConditionPack 的工厂对象
|
|
88
40
|
* ConditionPack对应支持 .then(cmdPackList), 可传入同 Run 的处理队列
|
|
89
41
|
* 可用方法见 ./SetCondition.js
|
|
90
42
|
* @param {int} group 可选参数,默认为0, 有效值为0~3, 对应默认组, 1组, 2组, 3组, 便于remove时,按组进行清理
|
|
91
|
-
* @param {boolean} multiTimes 可选参数,默认为false, 是否要多次执行,
|
|
43
|
+
* @param {boolean} multiTimes 可选参数,默认为false, 是否要多次执行,
|
|
44
|
+
* 若为单次, 当group未设定时自动作废,当group设定时,不作废但改为deactive状态
|
|
92
45
|
* @param {string} specName 可选参数,默认null, 命名condition, 用于指定名字进行active/deactive动作的场景
|
|
93
46
|
* @param {boolean} shoudRenderBreak 可选参数,默认false, 关联的回调是否会发起RenderBreak
|
|
94
47
|
* @return {ConditionPackBuilder} ConditionPack 的工厂对象
|
|
@@ -103,7 +56,7 @@ class ActorControl {
|
|
|
103
56
|
let builder: ConditionPackBuilder = this._SharedQuickConditionPackBuilder;
|
|
104
57
|
if (builder.isInUsing()) {
|
|
105
58
|
// 用于加速的builder被占用了,为了防止状态问题,使用新建builder
|
|
106
|
-
builder = new ConditionPackBuilder(this._Callbacks, this._SelfNexusRecv);
|
|
59
|
+
builder = new ConditionPackBuilder(this._Callbacks, this._SelfNexusRecv, this);
|
|
107
60
|
}
|
|
108
61
|
builder.updateCommandInfo(group, multiTimes, specName, shoudRenderBreak);
|
|
109
62
|
return builder;
|
|
@@ -148,6 +101,80 @@ class ActorControl {
|
|
|
148
101
|
state(): StatePackBuilder {
|
|
149
102
|
return this._StatePackBuilder;
|
|
150
103
|
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
class ActorControl {
|
|
107
|
+
private _BindView: any;
|
|
108
|
+
private _BindAnim: any;
|
|
109
|
+
private _Callbacks: CallbackManager;
|
|
110
|
+
private _SelfNexusRecv: NexusNode;
|
|
111
|
+
private _SizeMode: Boolean = false;
|
|
112
|
+
|
|
113
|
+
private _CondCycleStartList: Array<Function> | undefined = undefined;
|
|
114
|
+
private _CondCycleEndList: Array<Function> | undefined = undefined;
|
|
115
|
+
private _Builders: BuilderFactory;
|
|
116
|
+
|
|
117
|
+
constructor() {
|
|
118
|
+
this._BindView = null;
|
|
119
|
+
this._BindAnim = null;
|
|
120
|
+
this._Callbacks = new CallbackManager();
|
|
121
|
+
this._SelfNexusRecv = newNexus();
|
|
122
|
+
this._Builders = new BuilderFactory(this, this._Callbacks, this._SelfNexusRecv);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
asSizeMode() {
|
|
126
|
+
if (this._BindAnim != null) {
|
|
127
|
+
console.error("error: asSizeMode should call before bindForgeView");
|
|
128
|
+
} else {
|
|
129
|
+
this._SizeMode = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// debugGetAnimId() {
|
|
134
|
+
// return this._BindAnim?.AnimNativeId;
|
|
135
|
+
// }
|
|
136
|
+
|
|
137
|
+
bindForgeView(bindView: any, instantActive: boolean) {
|
|
138
|
+
this._BindView = bindView;
|
|
139
|
+
|
|
140
|
+
if (instantActive) {
|
|
141
|
+
this._EnsureAnim();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* run 执行编排好的intent集合
|
|
147
|
+
*
|
|
148
|
+
* @param {CmdListCreator} commandsCreator
|
|
149
|
+
* 命令指令队列创建回调
|
|
150
|
+
* 此回调返回值为一个数组,数组内容内容来自 Condition(), State(), Action()
|
|
151
|
+
* 这些工厂类创建的Command pack
|
|
152
|
+
*/
|
|
153
|
+
run(commandsCreator: CmdListCreator | undefined) {
|
|
154
|
+
if (commandsCreator) {
|
|
155
|
+
let cmdPackList = commandsCreator(this._Builders);
|
|
156
|
+
if ((window as any).JsView) {
|
|
157
|
+
this._WrappedRun(cmdPackList);
|
|
158
|
+
} else {
|
|
159
|
+
// Browser场景DomProxy需要onReady调用
|
|
160
|
+
let that = this;
|
|
161
|
+
this._BindView.RegisterOnProxyReady(() => {
|
|
162
|
+
that._WrappedRun(cmdPackList);
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_WrappedRun(cmdPackList: Array<Object>) {
|
|
169
|
+
this._EnsureAnim();
|
|
170
|
+
|
|
171
|
+
if (!(cmdPackList instanceof Array)) {
|
|
172
|
+
console.error("params error");
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
RunFreeMoveCmdPacks(this._BindView, cmdPackList);
|
|
177
|
+
}
|
|
151
178
|
|
|
152
179
|
getBindedAnim() {
|
|
153
180
|
this._EnsureAnim();
|
|
@@ -159,11 +186,58 @@ class ActorControl {
|
|
|
159
186
|
return this._BindView;
|
|
160
187
|
}
|
|
161
188
|
|
|
189
|
+
/**
|
|
190
|
+
* addCondCycleListener
|
|
191
|
+
* 追加 cond cycle listener,可以根据start和end来进行callback时序排序
|
|
192
|
+
*
|
|
193
|
+
* @param {Function} startCycleCallback 开始执行一帧的js回调(condition的callback)
|
|
194
|
+
* @param {Function} endCycleCallback 执行一帧的js回调完毕
|
|
195
|
+
*/
|
|
196
|
+
addCondCycleListener(startCycleCallback: Function, endCycleCallback: Function) {
|
|
197
|
+
if (startCycleCallback) {
|
|
198
|
+
if (!this._CondCycleStartList) {
|
|
199
|
+
this._CondCycleStartList = new Array();
|
|
200
|
+
}
|
|
201
|
+
this._CondCycleStartList!.push(startCycleCallback);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (endCycleCallback) {
|
|
205
|
+
if (!this._CondCycleEndList) {
|
|
206
|
+
this._CondCycleEndList = new Array();
|
|
207
|
+
}
|
|
208
|
+
this._CondCycleEndList!.push(endCycleCallback);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
removeCondCycleListener(startCycleCallback: Function, endCycleCallback: Function) {
|
|
213
|
+
if (startCycleCallback && this._CondCycleStartList) {
|
|
214
|
+
for (let i = 0; i < this._CondCycleStartList.length; i++) {
|
|
215
|
+
if (this._CondCycleStartList[i] == startCycleCallback) {
|
|
216
|
+
this._CondCycleStartList.splice(i, 1);
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (endCycleCallback && this._CondCycleEndList) {
|
|
222
|
+
for (let i = 0; i < this._CondCycleEndList.length; i++) {
|
|
223
|
+
if (this._CondCycleEndList[i] == endCycleCallback) {
|
|
224
|
+
this._CondCycleEndList.splice(i, 1);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
162
231
|
_OnEchoEvent(retJson: string) {
|
|
163
232
|
// 遇到layout后仍然会因为新broadcast有动作时,一帧中可能会有多次回调
|
|
164
233
|
let retJsonObject: any = JSON.parse(retJson);
|
|
165
234
|
let echoRetList: Array<any> = retJsonObject["retList"];
|
|
166
235
|
if (echoRetList) {
|
|
236
|
+
if (this._CondCycleStartList && this._CondCycleStartList.length > 0) {
|
|
237
|
+
for (let startCb of this._CondCycleStartList) {
|
|
238
|
+
startCb();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
167
241
|
for (let echoRet of echoRetList) {
|
|
168
242
|
let renderBreakId = echoRet["rbTkn"];
|
|
169
243
|
if (renderBreakId != 0) {
|
|
@@ -172,6 +246,11 @@ class ActorControl {
|
|
|
172
246
|
}
|
|
173
247
|
this._Callbacks.invokeCallback(echoRet["eTkn"], retJsonObject, echoRet["cds"], echoRet["ncds"]);
|
|
174
248
|
}
|
|
249
|
+
if (this._CondCycleEndList && this._CondCycleEndList.length > 0) {
|
|
250
|
+
for (let endCb of this._CondCycleEndList) {
|
|
251
|
+
endCb();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
175
254
|
}
|
|
176
255
|
}
|
|
177
256
|
|
|
@@ -484,22 +484,31 @@ class ActorPackBuilder {
|
|
|
484
484
|
* 只能放在 movementSync 的then中,用于将Sync同步信息按比例转化成
|
|
485
485
|
* (注意): 如果触发链条上有自己发出的信息,则将不再产生动作,规避循环触发
|
|
486
486
|
*
|
|
487
|
-
* @param {int}
|
|
488
|
-
* @param {int}
|
|
489
|
-
* @param {int}
|
|
490
|
-
* @param {int}
|
|
487
|
+
* @param {int} horizontalStart 横向运动识别区域的0%对应位置, 可以为负
|
|
488
|
+
* @param {int} horizontalEnd 横向运动识别区域的100%对应位置, 可以为负,可以小于start
|
|
489
|
+
* @param {int} verticalStart 纵向运动识别区域的0%对应位置, 可以为负
|
|
490
|
+
* @param {int} verticalEnd 纵向运动识别区域的100%对应位置, 可以为负,可以小于end
|
|
491
491
|
* @param {int} xyEnable x,y是否都触发, 0b01对应x, 0b10对应y, 可以或运算在一起
|
|
492
492
|
* @param {int} syncType 换算公式:
|
|
493
493
|
* 1: 正比公式:selfPercent = givenPercent
|
|
494
494
|
* 2: 反比公式:selfPercent = (1 - givenPercent)
|
|
495
495
|
*/
|
|
496
|
-
ackMovementSync(
|
|
496
|
+
ackMovementSync(
|
|
497
|
+
horizontalStart: number, horizontalEnd: number,
|
|
498
|
+
verticalStart: number, verticalEnd: number,
|
|
499
|
+
xyEnable: number, syncType: number) {
|
|
500
|
+
|
|
497
501
|
if (!this._BasicPreProcess("ackMovementSync")) {
|
|
498
502
|
return;
|
|
499
503
|
}
|
|
500
504
|
|
|
501
505
|
let cmdList: Array<Object> = [];
|
|
502
|
-
cmdList.push(ActionCmdBuilder.AckMovementSync(
|
|
506
|
+
cmdList.push(ActionCmdBuilder.AckMovementSync(
|
|
507
|
+
horizontalStart,
|
|
508
|
+
horizontalEnd,
|
|
509
|
+
verticalStart,
|
|
510
|
+
verticalEnd,
|
|
511
|
+
xyEnable, syncType));
|
|
503
512
|
return CmdPackBuilder.InitActCmdPack(this._SpeedKeeps, this._AccKeeps, this._NexusRecv?.token, cmdList);
|
|
504
513
|
}
|
|
505
514
|
|
|
@@ -31,12 +31,14 @@ class ConditionPackBuilder {
|
|
|
31
31
|
private _CommonInfo: Object;
|
|
32
32
|
private _CommonInfoValid: boolean;
|
|
33
33
|
private _ContorlSlefNexus: NexusNode;
|
|
34
|
+
private _BuildersFactory: any;
|
|
34
35
|
|
|
35
|
-
constructor(callbackManager: CallbackManager, selfNexus: NexusNode) {
|
|
36
|
+
constructor(callbackManager: CallbackManager, selfNexus: NexusNode, buildersFactory: any) {
|
|
36
37
|
this._Callbacks = callbackManager;
|
|
37
38
|
this._CommonInfo = ConditionSetBuilder.InitCommonInfo();
|
|
38
39
|
this._CommonInfoValid = false;
|
|
39
40
|
this._ContorlSlefNexus = selfNexus;
|
|
41
|
+
this._BuildersFactory = buildersFactory;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
isInUsing() {
|
|
@@ -143,7 +145,7 @@ class ConditionPackBuilder {
|
|
|
143
145
|
* @param {NexusNode} nexusRecv 由 FreeMoveFunc.newNexus() 创建, 作为通讯句柄,类似电话号,被fireNexusEvent调用
|
|
144
146
|
* @param {number} detailEventType 监听的事件类型, 类比与分机号,和fireNexusEvent发出的id约定, 自定义内容要求1000以上
|
|
145
147
|
*/
|
|
146
|
-
onNexusEvent(nexusRecv: NexusNode, detailEventType: number)
|
|
148
|
+
onNexusEvent(nexusRecv: NexusNode, detailEventType: number) {
|
|
147
149
|
// CommonInfo 只能使用一次,规避多次使用问题
|
|
148
150
|
if (!this._CheckCommonInfo()) {
|
|
149
151
|
return null;
|
|
@@ -179,6 +181,7 @@ class ConditionPackBuilder {
|
|
|
179
181
|
/**
|
|
180
182
|
* onNextTick
|
|
181
183
|
* 用于对一些Condition激活进行延迟,例如teleportTo处理后延迟激活 OnHitBlock 动作,规避teleportTo处理直接触发OnHitBlocker
|
|
184
|
+
* 特别场景: onNextTick(0) 可用于充当前帧命令执行完毕的回调,相当于为命令执行完毕做一个callback
|
|
182
185
|
*
|
|
183
186
|
*/
|
|
184
187
|
onNextTick(tickGap: number = 1) {
|
|
@@ -187,8 +190,8 @@ class ConditionPackBuilder {
|
|
|
187
190
|
return null;
|
|
188
191
|
}
|
|
189
192
|
this._CommonInfoValid = false;
|
|
190
|
-
if (tickGap
|
|
191
|
-
tickGap =
|
|
193
|
+
if (tickGap < 0) {
|
|
194
|
+
tickGap = 0;
|
|
192
195
|
}
|
|
193
196
|
|
|
194
197
|
return this._BuildPack(ConditionSetBuilder.OnNextTick(tickGap, this._CommonInfo));
|
|
@@ -347,10 +350,19 @@ class ConditionPackBuilder {
|
|
|
347
350
|
|
|
348
351
|
// 追加then处理
|
|
349
352
|
let callbackManager = this._Callbacks;
|
|
350
|
-
cmdPack["then"] = (
|
|
351
|
-
|
|
353
|
+
cmdPack["then"] = (creatorOrArray: Function | Array<Object> | undefined) => {
|
|
354
|
+
if (creatorOrArray) {
|
|
355
|
+
let childCmdPackList: Array<Object>;
|
|
356
|
+
if (typeof creatorOrArray == "function") {
|
|
357
|
+
childCmdPackList = creatorOrArray(this._BuildersFactory);
|
|
358
|
+
} else {
|
|
359
|
+
childCmdPackList = creatorOrArray;
|
|
360
|
+
}
|
|
361
|
+
setChildCommnadPackList(conditionSet, callbackManager, childCmdPackList);
|
|
362
|
+
return cmdPack;
|
|
363
|
+
}
|
|
352
364
|
return cmdPack;
|
|
353
|
-
}
|
|
365
|
+
}
|
|
354
366
|
|
|
355
367
|
return cmdPack;
|
|
356
368
|
}
|
|
@@ -123,26 +123,30 @@ class StatePackBuilder {
|
|
|
123
123
|
*
|
|
124
124
|
* 发出进度同步信号(可以一个FreeMove绑定多个信号发生器,但目前场景估计只需要一个发生器即可)
|
|
125
125
|
* 计算当前freeMove的postion和运动识别区域的比值
|
|
126
|
-
* xPercent = (xPos -
|
|
127
|
-
* yPercent = (yPos -
|
|
126
|
+
* xPercent = (xPos - horizontalStart) / (horizontalEnd - horizontalStart)
|
|
127
|
+
* yPercent = (yPos - verticalStart) / (verticalEnd - verticalStart)
|
|
128
128
|
* x和y可以为负数,也可能>100%
|
|
129
129
|
*
|
|
130
130
|
* 当多次调用时,nexusRef相同时,则为更新运动识别区域,nexusRef不同时则为新建信号发起器
|
|
131
131
|
*
|
|
132
132
|
* @param {NexusNode} nexusRef 绑定的nexus句柄,接受者用这个句柄来进行监听
|
|
133
|
-
* @param {int}
|
|
134
|
-
* @param {int}
|
|
135
|
-
* @param {int}
|
|
136
|
-
* @param {int}
|
|
133
|
+
* @param {int} horizontalStart 横向运动识别区域的0%对应位置, 可以为负
|
|
134
|
+
* @param {int} horizontalEnd 横向运动识别区域的100%对应位置, 可以为负,可以小于start
|
|
135
|
+
* @param {int} verticalStart 纵向运动识别区域的0%对应位置, 可以为负
|
|
136
|
+
* @param {int} verticalEnd 纵向运动识别区域的100%对应位置, 可以为负,可以小于end
|
|
137
137
|
* @param {int} xyEnable x,y是否都触发, 0b01对应x, 0b10对应y, 可以或运算在一起
|
|
138
138
|
*/
|
|
139
|
-
startMovementSync(nexusRef: NexusNode,
|
|
139
|
+
startMovementSync(nexusRef: NexusNode,
|
|
140
|
+
horizontalStart: number, horizontalEnd: number,
|
|
141
|
+
verticalStart: number, verticalEnd: number,
|
|
142
|
+
xyEnable: number) {
|
|
143
|
+
|
|
140
144
|
return CmdPackBuilder.InitStateCmdPack(StateCmdBuilder.StartMovementSync(
|
|
141
145
|
nexusRef?.token ? nexusRef.token : 0,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
horizontalStart,
|
|
147
|
+
horizontalEnd,
|
|
148
|
+
verticalStart,
|
|
149
|
+
verticalEnd,
|
|
146
150
|
xyEnable));
|
|
147
151
|
}
|
|
148
152
|
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
|
|
2
|
+
import { NexusNode } from "./NexusNode";
|
|
3
|
+
|
|
4
|
+
interface PendingPromise {
|
|
5
|
+
promiseRef: Promise<void> | null;
|
|
6
|
+
promiseResolve: Function | null;
|
|
7
|
+
linkName: String;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class SyncLinkSource {
|
|
11
|
+
nexusNode: NexusNode;
|
|
12
|
+
linkName: String;
|
|
13
|
+
|
|
14
|
+
constructor(name: string, node: NexusNode) {
|
|
15
|
+
this.nexusNode = node;
|
|
16
|
+
this.linkName = name;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class SyncLinkManager {
|
|
21
|
+
// 等待中的未回复的link
|
|
22
|
+
private pendingPromiseList: Array<PendingPromise> = [];
|
|
23
|
+
private syncSourceMap: Map<String, SyncLinkSource> = new Map();
|
|
24
|
+
|
|
25
|
+
constructor() {
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 将LinkSource加入map
|
|
30
|
+
SourceOnMounted(syncSource: SyncLinkSource | null) {
|
|
31
|
+
if (syncSource != null) {
|
|
32
|
+
let linkName = syncSource.linkName;
|
|
33
|
+
if (this.syncSourceMap.has(linkName)) {
|
|
34
|
+
// 重名内容不要添加,规避引起引用混乱
|
|
35
|
+
console.error(`Error: sync link name duplicate:${linkName}`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
this.syncSourceMap.set(linkName, syncSource);
|
|
41
|
+
|
|
42
|
+
if (this.pendingPromiseList.length != 0) {
|
|
43
|
+
// 找出pending内容,进行回调
|
|
44
|
+
for (let index = this.pendingPromiseList.length - 1; index >= 0; index--) {
|
|
45
|
+
let promiseItem = this.pendingPromiseList[index];
|
|
46
|
+
if (promiseItem.linkName == linkName) {
|
|
47
|
+
promiseItem.promiseResolve?.();
|
|
48
|
+
this.pendingPromiseList.splice(index, 1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 将LinkSource移出map
|
|
56
|
+
SourceOnUnmounted(linkName: String) {
|
|
57
|
+
if (this.syncSourceMap.has(linkName)) {
|
|
58
|
+
this.syncSourceMap.delete(linkName);
|
|
59
|
+
} else {
|
|
60
|
+
console.error(`ERROR: unmount linkname(${linkName}) not found`)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 加入wait处理在.then中再进行 GetSyncSource, 以保证节点完成了mounted
|
|
65
|
+
WaitSourceMounted(name: String): Promise<void> {
|
|
66
|
+
let newPromiseItem: PendingPromise = {
|
|
67
|
+
promiseRef: null,
|
|
68
|
+
promiseResolve: null,
|
|
69
|
+
linkName: name
|
|
70
|
+
}
|
|
71
|
+
newPromiseItem.promiseRef = new Promise((resolve) => {
|
|
72
|
+
newPromiseItem.promiseResolve = resolve;
|
|
73
|
+
if (this.syncSourceMap.has(name)) {
|
|
74
|
+
// 若已经有了则直接resolve
|
|
75
|
+
resolve();
|
|
76
|
+
} else {
|
|
77
|
+
// 加入到pending队列中
|
|
78
|
+
this.pendingPromiseList.push(newPromiseItem);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return newPromiseItem.promiseRef;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 取消 WaitSourceMounted 发起的Promise, 用在unmounted中, 规避内存泄漏
|
|
86
|
+
UnListen(waitPromise: Promise<void>) {
|
|
87
|
+
if (this.pendingPromiseList.length != 0) {
|
|
88
|
+
for (let index = this.pendingPromiseList.length; index >= 0; index--) {
|
|
89
|
+
let promiseItem = this.pendingPromiseList[index];
|
|
90
|
+
if (promiseItem.promiseRef == waitPromise) {
|
|
91
|
+
this.pendingPromiseList.splice(index, 1);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
GetSourceNexusNode(linkName: String): NexusNode | null {
|
|
99
|
+
let sourceItem = this.syncSourceMap.get(linkName);
|
|
100
|
+
if (sourceItem) {
|
|
101
|
+
return sourceItem.nexusNode;
|
|
102
|
+
} else {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let sSyncLinkManager: SyncLinkManager | null = null;
|
|
109
|
+
|
|
110
|
+
function GetSyncLinkManager(): SyncLinkManager {
|
|
111
|
+
if (sSyncLinkManager == null) {
|
|
112
|
+
sSyncLinkManager = new SyncLinkManager();
|
|
113
|
+
}
|
|
114
|
+
return sSyncLinkManager;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
GetSyncLinkManager,
|
|
119
|
+
SyncLinkSource
|
|
120
|
+
}
|