three-base 2.0.137 → 2.0.145
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/DirectionalLight.d.ts +2 -2
- package/DirectionalLight.js +1 -1
- package/DirectionalLight.ts +70 -0
- package/EventMap.d.ts +103 -0
- package/EventMap.js +17 -0
- package/EventMap.ts +139 -0
- package/EventMesh.ts +60 -0
- package/ExtrudeMesh.js +1 -25
- package/ExtrudeMesh.ts +553 -0
- package/FPScontrol.d.ts +448 -15
- package/FPScontrol.js +1448 -266
- package/FPScontrol.ts +1855 -0
- package/Fire/Fire.d.ts +4 -4
- package/Fire/Fire.js +8 -7
- package/Fire/Fire.ts +89 -0
- package/Fire/{FireGromtry.d.ts → FireGeometry.d.ts} +2 -2
- package/Fire/{FireGromtry.js → FireGeometry.js} +1 -1
- package/Fire/FireGeometry.ts +40 -0
- package/Fire/FireMaterial.d.ts +3 -3
- package/Fire/FireMaterial.js +1 -1
- package/Fire/FireMaterial.ts +89 -0
- package/Fire/index.d.ts +1 -0
- package/Fire/index.js +1 -0
- package/Fire/index.ts +2 -0
- package/GLTFDracoLoader.d.ts +71 -0
- package/GLTFDracoLoader.js +266 -0
- package/GLTFDracoLoader.ts +430 -0
- package/Grass/Grass.d.ts +2 -2
- package/Grass/Grass.ts +38 -0
- package/Grass/index.d.ts +1 -0
- package/Grass/index.js +1 -0
- package/Grass/index.ts +2 -0
- package/Ground1/Ground1.d.ts +2 -3
- package/Ground1/Ground1.js +64 -60
- package/Ground1/Ground1.ts +114 -0
- package/Ground1/index.ts +1 -0
- package/MeshBase.d.ts +1 -0
- package/MeshBase.js +37 -13
- package/MeshBase.ts +253 -0
- package/Mirror.d.ts +3 -3
- package/Mirror.js +7 -3
- package/Mirror.ts +203 -0
- package/MktMesh/MktMesh.d.ts +301 -0
- package/MktMesh/MktMesh.js +1064 -0
- package/MktMesh/MktMesh.ts +1096 -0
- package/MktMesh/assetUrl.d.ts +59 -0
- package/MktMesh/assetUrl.js +154 -0
- package/MktMesh/assetUrl.ts +155 -0
- package/MktMesh/mktMappingShader.d.ts +12 -0
- package/MktMesh/mktMappingShader.js +139 -0
- package/MktMesh/mktMappingShader.ts +139 -0
- package/MktMesh/mktShader.d.ts +263 -0
- package/MktMesh/mktShader.js +1248 -0
- package/MktMesh/mktShader.ts +1344 -0
- package/MktMesh/panoBitmapTexture.d.ts +25 -0
- package/MktMesh/panoBitmapTexture.js +52 -0
- package/MktMesh/panoBitmapTexture.ts +54 -0
- package/MktMesh/panoSlotBind.d.ts +29 -0
- package/MktMesh/panoSlotBind.js +106 -0
- package/MktMesh/panoSlotBind.ts +153 -0
- package/MktMesh/panoSlotRoster.d.ts +22 -0
- package/MktMesh/panoSlotRoster.js +169 -0
- package/MktMesh/panoSlotRoster.ts +168 -0
- package/MktMesh/panoTileStitcher.d.ts +119 -0
- package/MktMesh/panoTileStitcher.js +533 -0
- package/MktMesh/panoTileStitcher.ts +616 -0
- package/MktMesh/types.d.ts +75 -0
- package/MktMesh/types.js +1 -0
- package/MktMesh/types.ts +87 -0
- package/MktMesh/wallCapTessellate.d.ts +33 -0
- package/MktMesh/wallCapTessellate.js +97 -0
- package/MktMesh/wallCapTessellate.ts +68 -0
- package/PipeMesh/PathGeometry.js +9 -2
- package/PipeMesh/PathGeometry.ts +343 -0
- package/PipeMesh/PathPoint.ts +36 -0
- package/PipeMesh/PathPointList.js +1 -0
- package/PipeMesh/PathPointList.ts +227 -0
- package/PipeMesh/PathTubeGeometry.ts +146 -0
- package/PipeMesh/PipeMesh.d.ts +1 -1
- package/PipeMesh/PipeMesh.js +1 -1
- package/PipeMesh/PipeMesh.ts +76 -0
- package/PipeMesh/index.ts +1 -0
- package/PlaneModal1/PlaneModal1.d.ts +16 -13
- package/PlaneModal1/PlaneModal1.js +4 -0
- package/PlaneModal1/PlaneModal1.ts +138 -0
- package/PlaneModal1/index.ts +1 -0
- package/PlaneText.d.ts +2 -14
- package/PlaneText.js +7 -2
- package/PlaneText.ts +55 -0
- package/PlaneWithHtml.d.ts +4 -2
- package/PlaneWithHtml.js +2 -1
- package/PlaneWithHtml.ts +70 -0
- package/PointLight/PointLight.d.ts +3 -4
- package/PointLight/PointLight.js +1 -7
- package/PointLight/PointLight.ts +67 -0
- package/PointLight/index.ts +1 -0
- package/README.md +110 -79
- package/Sky/Sky.ts +22 -0
- package/Sky/index.ts +1 -0
- package/SpotLight.d.ts +2 -2
- package/SpotLight.js +1 -1
- package/SpotLight.ts +74 -0
- package/SpriteModal1/SpriteModal1.d.ts +16 -13
- package/SpriteModal1/SpriteModal1.js +8 -2
- package/SpriteModal1/SpriteModal1.ts +146 -0
- package/SpriteModal1/index.ts +1 -0
- package/SpriteText.d.ts +14 -13
- package/SpriteText.js +22 -9
- package/SpriteText.ts +205 -0
- package/SpriteText2.d.ts +9 -8
- package/SpriteText2.js +57 -32
- package/SpriteText2.ts +258 -0
- package/SpriteText3.d.ts +86 -0
- package/SpriteText3.js +519 -0
- package/SpriteText3.ts +599 -0
- package/SpriteWithHtml.d.ts +4 -2
- package/SpriteWithHtml.ts +50 -0
- package/Text3D/Text3D.js +17 -21
- package/Text3D/Text3D.ts +77 -0
- package/Text3D/fontController.d.ts +10 -9
- package/Text3D/fontController.js +17 -50
- package/Text3D/fontController.ts +209 -0
- package/Text3D/index.ts +1 -0
- package/ThreeBase.d.ts +168 -31
- package/ThreeBase.js +663 -117
- package/ThreeBase.ts +1314 -0
- package/ThreeMouse.d.ts +20 -7
- package/ThreeMouse.js +78 -32
- package/ThreeMouse.ts +472 -0
- package/Transition.d.ts +12 -7
- package/Transition.js +26 -27
- package/Transition.ts +242 -0
- package/Water/Water.js +21 -3
- package/Water/Water.ts +45 -0
- package/Water/index.d.ts +2 -0
- package/Water/index.js +2 -0
- package/Water/index.ts +2 -0
- package/WaterFlow/FloatingDuck.d.ts +88 -0
- package/WaterFlow/FloatingDuck.js +307 -0
- package/WaterFlow/FloatingDuck.ts +445 -0
- package/WaterFlow/GPUFluidSimulation.d.ts +56 -0
- package/WaterFlow/GPUFluidSimulation.js +785 -0
- package/WaterFlow/GPUFluidSimulation.ts +827 -0
- package/WaterFlow/ReservoirSystem.d.ts +106 -0
- package/WaterFlow/ReservoirSystem.js +621 -0
- package/WaterFlow/ReservoirSystem.ts +754 -0
- package/WaterFlow/SPHField.d.ts +35 -0
- package/WaterFlow/SPHField.js +204 -0
- package/WaterFlow/SPHField.ts +228 -0
- package/WaterFlow/ScreenSpaceFluidPass.d.ts +69 -0
- package/WaterFlow/ScreenSpaceFluidPass.js +736 -0
- package/WaterFlow/ScreenSpaceFluidPass.ts +789 -0
- package/WaterFlow/ShallowWaterSurface.d.ts +45 -0
- package/WaterFlow/ShallowWaterSurface.js +441 -0
- package/WaterFlow/ShallowWaterSurface.ts +510 -0
- package/WaterFlow/WaterFlow.d.ts +87 -0
- package/WaterFlow/WaterFlow.js +171 -0
- package/WaterFlow/WaterFlow.ts +219 -0
- package/WaterFlow/types.d.ts +161 -0
- package/WaterFlow/types.js +1 -0
- package/WaterFlow/types.ts +189 -0
- package/WaterFlow/waterFlowPass.d.ts +3 -0
- package/WaterFlow/waterFlowPass.js +20 -0
- package/WaterFlow/waterFlowPass.ts +40 -0
- package/collisionOBB.d.ts +42 -0
- package/collisionOBB.js +112 -0
- package/collisionOBB.ts +108 -0
- package/declare.d.ts +25 -167
- package/index.js +0 -1
- package/index.ts +1 -0
- package/instanced/InstancedBatch.d.ts +57 -0
- package/instanced/InstancedBatch.js +348 -0
- package/instanced/InstancedBatch.ts +406 -0
- package/instanced/InstancedChild.d.ts +174 -0
- package/instanced/InstancedChild.js +264 -0
- package/instanced/InstancedChild.ts +327 -0
- package/instanced/InstancedGroup.d.ts +43 -0
- package/instanced/InstancedGroup.js +126 -0
- package/instanced/InstancedGroup.ts +137 -0
- package/{InstancedMeshBase.d.ts → instanced/InstancedMeshBase.d.ts} +6 -7
- package/{InstancedMeshBase.js → instanced/InstancedMeshBase.js} +36 -47
- package/instanced/InstancedMeshBase.ts +292 -0
- package/instanced/InstancedTemplate.d.ts +46 -0
- package/instanced/InstancedTemplate.js +125 -0
- package/instanced/InstancedTemplate.ts +188 -0
- package/keyControls.d.ts +29 -0
- package/{keyContorls.js → keyControls.js} +10 -7
- package/keyControls.ts +107 -0
- package/lensflare/LensFlare.d.ts +39 -0
- package/lensflare/LensFlare.js +373 -0
- package/lensflare/LensFlare.ts +448 -0
- package/lensflare/lensflare0.png +0 -0
- package/lensflare/lensflare3.png +0 -0
- package/lensflare/lensflare_custom.png +0 -0
- package/lensflare/lensflare_hex_ghost.png +0 -0
- package/lensflare/lensflare_hex_main.png +0 -0
- package/package.json +104 -25
- package/pass/bloom_pass.d.ts +1 -1
- package/pass/bloom_pass.js +127 -40
- package/pass/bloom_pass.ts +243 -0
- package/pass/cover_pass.d.ts +1 -1
- package/pass/cover_pass.js +55 -32
- package/pass/cover_pass.ts +182 -0
- package/pass/debugDepthState.d.ts +20 -0
- package/pass/debugDepthState.js +9 -0
- package/pass/debugDepthState.ts +22 -0
- package/pass/depthTestBias.d.ts +12 -0
- package/pass/depthTestBias.js +12 -0
- package/pass/depthTestBias.ts +12 -0
- package/pass/effectUserData.d.ts +27 -0
- package/pass/effectUserData.js +1 -0
- package/pass/effectUserData.ts +46 -0
- package/pass/frosted_glass_pass.d.ts +1 -1
- package/pass/frosted_glass_pass.js +45 -64
- package/pass/frosted_glass_pass.ts +288 -0
- package/pass/fsQuad.d.ts +2 -2
- package/pass/fsQuad.ts +34 -0
- package/pass/glow_pass.d.ts +1 -1
- package/pass/glow_pass.js +288 -72
- package/pass/glow_pass.ts +654 -0
- package/pass/screen_bloom_pass.d.ts +11 -0
- package/pass/screen_bloom_pass.js +235 -0
- package/pass/screen_bloom_pass.ts +263 -0
- package/pass/ssao_pass.d.ts +78 -3
- package/pass/ssao_pass.js +642 -206
- package/pass/ssao_pass.ts +918 -0
- package/pass/stroke_pass.d.ts +1 -1
- package/pass/stroke_pass.js +187 -116
- package/pass/stroke_pass.ts +638 -0
- package/shaders/FXAAShaderMaterial.js +5 -48
- package/shaders/FXAAShaderMaterial.ts +201 -0
- package/shaders/baseDepthVisShader.d.ts +11 -0
- package/shaders/baseDepthVisShader.js +36 -0
- package/shaders/baseDepthVisShader.ts +36 -0
- package/shaders/baseTextureToRenderShader.js +46 -51
- package/shaders/baseTextureToRenderShader.ts +232 -0
- package/shaders/copyShader.js +2 -3
- package/shaders/copyShader.ts +32 -0
- package/shaders/debugDepthCompareShader.d.ts +14 -0
- package/shaders/debugDepthCompareShader.js +49 -0
- package/shaders/debugDepthCompareShader.ts +50 -0
- package/shaders/debugDepthJudgeShader.d.ts +18 -0
- package/shaders/debugDepthJudgeShader.js +52 -0
- package/shaders/debugDepthJudgeShader.ts +54 -0
- package/shaders/debugExcludedShader.d.ts +13 -0
- package/shaders/debugExcludedShader.js +46 -0
- package/shaders/debugExcludedShader.ts +48 -0
- package/spriteTextBg.d.ts +1 -0
- package/spriteTextBg.js +20 -0
- package/spriteTextBg.ts +20 -0
- package/threeLoader.d.ts +8 -7
- package/threeLoader.js +58 -67
- package/threeLoader.ts +525 -0
- package/threeUtils.d.ts +2 -1
- package/threeUtils.js +24 -25
- package/threeUtils.ts +373 -0
- package/types.d.ts +2 -0
- package/types.js +6 -0
- package/types.ts +8 -0
- package/ApngTexture.d.ts +0 -13
- package/ApngTexture.js +0 -61
- package/ApngTextureManage.d.ts +0 -18
- package/ApngTextureManage.js +0 -87
- package/KeyFrameAnimation.d.ts +0 -25
- package/KeyFrameAnimation.js +0 -78
- package/keyContorls.d.ts +0 -25
- package/lib/draco/draco_decoder.js +0 -34
- package/lib/draco/draco_decoder.wasm +0 -0
- package/lib/draco/draco_wasm_wrapper.js +0 -117
- package/pass/emissive_ao_pass.d.ts +0 -13
- package/pass/emissive_ao_pass.js +0 -370
- package/shaders.d.ts +0 -5
- package/shaders.js +0 -93
package/ThreeMouse.ts
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
//
|
|
2
|
+
//
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
//
|
|
6
|
+
// 启动鼠标事件
|
|
7
|
+
import { Camera, InstancedMesh, Intersection, Mesh, Object3D, Raycaster, Scene, Vector2, WebGLRenderer } from "three";
|
|
8
|
+
import { debounce } from "lodash";
|
|
9
|
+
import { computeBoundsTree, acceleratedRaycast } from "three-mesh-bvh";
|
|
10
|
+
import type InstancedGroup from "./instanced/InstancedGroup";
|
|
11
|
+
|
|
12
|
+
/** 安全地分发事件到 Object3D 对象 */
|
|
13
|
+
function dispatchObjectEvent<T extends { type: string }>(object: Object3D, event: T): void {
|
|
14
|
+
// 使用双重断言来安全地传递事件对象
|
|
15
|
+
object.dispatchEvent(event as unknown as Parameters<Object3D["dispatchEvent"]>[0]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Patch Mesh.raycast with BVH acceleration. Call once before using ThreeMouse. */
|
|
19
|
+
export function initBVHRaycast(): void {
|
|
20
|
+
if (Mesh.prototype.raycast !== acceleratedRaycast) {
|
|
21
|
+
Mesh.prototype.raycast = acceleratedRaycast;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { computeBoundsTree, acceleratedRaycast };
|
|
26
|
+
|
|
27
|
+
export interface ThreeMouseEvent extends Intersection {
|
|
28
|
+
e: MouseEvent;
|
|
29
|
+
renderer: WebGLRenderer;
|
|
30
|
+
camera: Camera;
|
|
31
|
+
type: string;
|
|
32
|
+
offsetX: number;
|
|
33
|
+
offsetY: number;
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type MouseEventType = "leftclick" | "rightclick" | "click" | "dbclick" | "mouseenter" | "mouseleave" | "mousemove" | "mousedown" | "mouseup";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* js 专用的鼠标拾取模型对象
|
|
42
|
+
*/
|
|
43
|
+
export default class ThreeMouse {
|
|
44
|
+
constructor(renderer: WebGLRenderer, camera: Camera, scene: Scene) {
|
|
45
|
+
this._renderer = renderer;
|
|
46
|
+
this._camera = camera;
|
|
47
|
+
this._scene = scene;
|
|
48
|
+
this._frame = this._renderer.info.render.frame;
|
|
49
|
+
this._renderer.domElement.addEventListener("mouseenter", () => {
|
|
50
|
+
this._mouseInRenderer = true;
|
|
51
|
+
}, true); //鼠标进入开启拾取
|
|
52
|
+
this._renderer.domElement.addEventListener("mouseleave", this._mouseleave, true); //鼠标离开停止拾取
|
|
53
|
+
this._renderer.domElement.addEventListener("mousemove", this._mousemove, true); //鼠标移动监听事件
|
|
54
|
+
this._renderer.domElement.addEventListener("pointerdown", this._mousedown, true); //鼠标按下监听事件
|
|
55
|
+
this._renderer.domElement.addEventListener("pointerup", this._mouseup, true); //鼠标弹起监听事件
|
|
56
|
+
}
|
|
57
|
+
// 渲染器
|
|
58
|
+
_renderer: WebGLRenderer;
|
|
59
|
+
_camera: Camera;
|
|
60
|
+
_scene: Scene;
|
|
61
|
+
// 固定的实例化分组器(由 ThreeBase 注入),用于把 InstancedMesh 命中路由到 InstancedChild
|
|
62
|
+
instancedGroup?: InstancedGroup;
|
|
63
|
+
// 鼠标在渲染器上面的位置
|
|
64
|
+
_mosePosition: Vector2 = new Vector2(0, 0);
|
|
65
|
+
// 鼠标按下的位置 如果和鼠标弹起的位置相同 才算一次有效的点击事件
|
|
66
|
+
_mouseDownPosition: Vector2 = new Vector2(0, 0);
|
|
67
|
+
//当前鼠标指针上的对象
|
|
68
|
+
_mesh_on?: Object3D;
|
|
69
|
+
//鼠标按下的对象
|
|
70
|
+
_mesh_Down?: Object3D;
|
|
71
|
+
//射线拾取器
|
|
72
|
+
_raycaster: Raycaster = new Raycaster();
|
|
73
|
+
// 当前渲染的帧数 ( 鼠标滑动事件 一帧只需要执行费一次即可 )
|
|
74
|
+
_frame: number = 0;
|
|
75
|
+
//鼠标是否在渲染器上
|
|
76
|
+
_mouseInRenderer: boolean = false;
|
|
77
|
+
// 鼠标滑动的事件
|
|
78
|
+
_mousemoveEvent?: MouseEvent | PointerEvent;
|
|
79
|
+
// 鼠标事件
|
|
80
|
+
_mouseEvent?: MouseEvent | PointerEvent;
|
|
81
|
+
// 需要被拾取的对象数组
|
|
82
|
+
_object3ds: Object3D[] = [];
|
|
83
|
+
// 点击次数
|
|
84
|
+
_click_num: number = 0;
|
|
85
|
+
// 获取拾取到的对象
|
|
86
|
+
_getSelected(object3ds: Object3D[]): Intersection | undefined {
|
|
87
|
+
let intersection: Intersection | undefined;
|
|
88
|
+
if (object3ds.length) {
|
|
89
|
+
intersection = this._raycaster.intersectObjects(object3ds, false)[0];
|
|
90
|
+
}
|
|
91
|
+
return intersection;
|
|
92
|
+
}
|
|
93
|
+
// 判断对象上面是否有事件
|
|
94
|
+
hasEvent(object?: Object3D, types: Array<MouseEventType> = []): boolean {
|
|
95
|
+
if (!object) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
// 如果 启用事件为关闭的话就不执行事件
|
|
99
|
+
if (object["userData"] && object["userData"]["enableEvent"] === false) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
// 注意:three 的 hasEventListener(type, null) 因 indexOf(null) 永远 -1 而恒返回 false,
|
|
103
|
+
// 无法用来判断"是否存在任意监听器"。改为直接读取私有 _listeners 表判断该类型是否有监听。
|
|
104
|
+
const listeners = (object as unknown as { _listeners?: Record<string, unknown[]> })._listeners;
|
|
105
|
+
const hasevent = types.some((type) => {
|
|
106
|
+
return !!(listeners && listeners[type] && listeners[type].length > 0);
|
|
107
|
+
});
|
|
108
|
+
return hasevent;
|
|
109
|
+
}
|
|
110
|
+
// 判断对象上是否有鼠标样式
|
|
111
|
+
hasCursor(object?: Object3D): boolean | undefined {
|
|
112
|
+
if (!object) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
// 如果 启用事件为关闭的话就不执行事件
|
|
116
|
+
if (object["userData"] && object["userData"]["enableEvent"] === false) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (object["userData"] && object["userData"]["cursor"]) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// 把命中的对象解析为事件派发目标:若命中 InstancedMesh 且属于某个 batch,
|
|
124
|
+
// 则路由到对应的 InstancedChild(逻辑实例),使实例成为透明事件接收端。
|
|
125
|
+
private resolveTarget(object: Object3D, instanceId?: number): Object3D {
|
|
126
|
+
if (object instanceof InstancedMesh && this.instancedGroup) {
|
|
127
|
+
const child = this.instancedGroup.resolveInstance(object, instanceId);
|
|
128
|
+
if (child) {
|
|
129
|
+
return child;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return object;
|
|
133
|
+
}
|
|
134
|
+
// 分发鼠标拾取事件
|
|
135
|
+
dispatchEvent(): void {
|
|
136
|
+
// 提取有事件的对象
|
|
137
|
+
const meshs: Object3D[] = [];
|
|
138
|
+
this._scene.traverseVisible((mesh: Object3D) => {
|
|
139
|
+
// 逻辑实例节点(InstancedChild)自身不渲染、无几何,跳过收集(命中由 InstancedMesh 路由回来)
|
|
140
|
+
if ((mesh as unknown as { userData?: { __instancedChild?: boolean } }).userData?.__instancedChild) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
// 判断对象是否有指定的事件
|
|
144
|
+
if (this.hasCursor(mesh) ||
|
|
145
|
+
this.hasEvent(mesh, [
|
|
146
|
+
"leftclick",
|
|
147
|
+
"rightclick",
|
|
148
|
+
"click",
|
|
149
|
+
"dbclick",
|
|
150
|
+
"mouseenter",
|
|
151
|
+
"mouseleave",
|
|
152
|
+
"mousemove",
|
|
153
|
+
"mousedown",
|
|
154
|
+
"mouseup",
|
|
155
|
+
])) {
|
|
156
|
+
if (mesh instanceof Mesh &&
|
|
157
|
+
!mesh.geometry.boundsTree &&
|
|
158
|
+
mesh.geometry.attributes.position &&
|
|
159
|
+
mesh.geometry.attributes.position.count > 0) {
|
|
160
|
+
computeBoundsTree.apply(mesh.geometry);
|
|
161
|
+
// disposeBoundsTree.apply((mesh as Mesh).geometry);
|
|
162
|
+
}
|
|
163
|
+
meshs.push(mesh);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
this._object3ds = meshs;
|
|
167
|
+
// 收集可拾取的 InstancedMesh(仅含注册了监听的已就绪 batch)
|
|
168
|
+
if (this.instancedGroup) {
|
|
169
|
+
this.instancedGroup.collectPickable(meshs);
|
|
170
|
+
}
|
|
171
|
+
// 没有鼠标事件就不往下执行了
|
|
172
|
+
if (!this._mousemoveEvent || !this._mouseInRenderer) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// 拾取模型
|
|
176
|
+
let intersection = this._getSelected(meshs);
|
|
177
|
+
if (intersection) {
|
|
178
|
+
const { face, object } = intersection;
|
|
179
|
+
// face && face.normal.applyMatrix4(object.matrixWorld);
|
|
180
|
+
const MouseEvent: ThreeMouseEvent = Object.assign(intersection, {
|
|
181
|
+
// 将来可能用到的对象
|
|
182
|
+
e: this._mousemoveEvent,
|
|
183
|
+
renderer: this._renderer,
|
|
184
|
+
camera: this._camera,
|
|
185
|
+
object: intersection.object,
|
|
186
|
+
type: this._mousemoveEvent.type,
|
|
187
|
+
offsetX: this._mousemoveEvent.offsetX,
|
|
188
|
+
offsetY: this._mousemoveEvent.offsetY,
|
|
189
|
+
x: this._mousemoveEvent.x,
|
|
190
|
+
y: this._mousemoveEvent.y,
|
|
191
|
+
});
|
|
192
|
+
// 命中 InstancedMesh 时,把派发目标重定向到对应的 InstancedChild
|
|
193
|
+
const _target = this.resolveTarget(intersection.object, intersection.instanceId);
|
|
194
|
+
if (_target) (MouseEvent as unknown as { object: Object3D }).object = _target;
|
|
195
|
+
// 触发滑动事件
|
|
196
|
+
if (this._mesh_on === MouseEvent.object) {
|
|
197
|
+
if (this.hasEvent(MouseEvent.object, ["mousemove"])) {
|
|
198
|
+
MouseEvent.type = "mousemove";
|
|
199
|
+
dispatchObjectEvent(MouseEvent.object, MouseEvent);
|
|
200
|
+
}
|
|
201
|
+
// 鼠标划入滑出事件
|
|
202
|
+
}
|
|
203
|
+
else if (this._mesh_on !== MouseEvent.object) {
|
|
204
|
+
if (this.hasEvent(this._mesh_on, ["mouseleave"])) {
|
|
205
|
+
MouseEvent.type = "mouseleave";
|
|
206
|
+
dispatchObjectEvent(this._mesh_on!, MouseEvent);
|
|
207
|
+
}
|
|
208
|
+
if (this.hasEvent(MouseEvent.object, ["mouseenter"])) {
|
|
209
|
+
MouseEvent.type = "mouseenter";
|
|
210
|
+
dispatchObjectEvent(MouseEvent.object, MouseEvent);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
this._mesh_on = MouseEvent.object || undefined; // 设置为当前鼠标上的对象
|
|
214
|
+
// 鼠标样式
|
|
215
|
+
if (this._mesh_on &&
|
|
216
|
+
this._mesh_on.userData &&
|
|
217
|
+
this._mesh_on.userData.cursor) {
|
|
218
|
+
this._renderer.domElement.style.cursor = this._mesh_on.userData.cursor;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
this._renderer.domElement.style.cursor = "auto";
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
if (this.hasEvent(this._mesh_on, ["mouseleave"])) {
|
|
226
|
+
// 鼠标离开事件
|
|
227
|
+
dispatchObjectEvent(this._mesh_on!, {
|
|
228
|
+
e: this._mouseEvent,
|
|
229
|
+
renderer: this._renderer,
|
|
230
|
+
camera: this._camera,
|
|
231
|
+
object: this._mesh_on,
|
|
232
|
+
type: "mouseleave",
|
|
233
|
+
offsetX: this._mousemoveEvent!.offsetX,
|
|
234
|
+
offsetY: this._mousemoveEvent!.offsetY,
|
|
235
|
+
x: this._mousemoveEvent!.x,
|
|
236
|
+
y: this._mousemoveEvent!.y,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
// 置空当前鼠标上面的对象
|
|
240
|
+
this._mesh_on = undefined;
|
|
241
|
+
this._renderer.domElement.style.cursor = "auto"; // 鼠标样式
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// 鼠标离开事件
|
|
245
|
+
_mouseleave = (e: MouseEvent): void => {
|
|
246
|
+
this._mouseEvent = e;
|
|
247
|
+
this._mouseInRenderer = false;
|
|
248
|
+
// 鼠标离开事件
|
|
249
|
+
if (this._mousemoveEvent && this.hasEvent(this._mesh_on, ["mouseleave"])) {
|
|
250
|
+
dispatchObjectEvent(this._mesh_on!, {
|
|
251
|
+
e: this._mouseEvent,
|
|
252
|
+
renderer: this._renderer,
|
|
253
|
+
camera: this._camera,
|
|
254
|
+
object: this._mesh_on,
|
|
255
|
+
type: "mouseleave",
|
|
256
|
+
offsetX: this._mousemoveEvent.offsetX,
|
|
257
|
+
offsetY: this._mousemoveEvent.offsetY,
|
|
258
|
+
x: this._mousemoveEvent.x,
|
|
259
|
+
y: this._mousemoveEvent.y,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
// 置空当前鼠标上面的对象
|
|
263
|
+
this._mesh_on = undefined;
|
|
264
|
+
this._renderer.domElement.style.cursor = "auto"; // 鼠标样式
|
|
265
|
+
};
|
|
266
|
+
// 鼠标滑动 设置鼠标位置
|
|
267
|
+
_mousemove = (e: MouseEvent): void => {
|
|
268
|
+
this._mousemoveEvent = e;
|
|
269
|
+
this._frame = this._renderer.info.render.frame;
|
|
270
|
+
if (document.pointerLockElement) {
|
|
271
|
+
// 如果当前有元素 锁住了鼠标
|
|
272
|
+
this._mosePosition.set(0, 0); // 鼠标就指向canvas 的正中心
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
this._mosePosition.x = (e.offsetX / this._renderer.domElement.offsetWidth) * 2 - 1;
|
|
276
|
+
this._mosePosition.y = -(e.offsetY / this._renderer.domElement.offsetHeight) * 2 + 1;
|
|
277
|
+
}
|
|
278
|
+
this._raycaster.setFromCamera(this._mosePosition, this._camera); // 设置射线拾取的参数
|
|
279
|
+
};
|
|
280
|
+
// 鼠标按下事件
|
|
281
|
+
_mousedown = (e: PointerEvent): void => {
|
|
282
|
+
this._mouseEvent = e;
|
|
283
|
+
// 记录按下的位置
|
|
284
|
+
this._mouseDownPosition.set(e.offsetX, e.offsetY);
|
|
285
|
+
this._mousemove(e);
|
|
286
|
+
let intersection = this._getSelected(this._object3ds);
|
|
287
|
+
if (!intersection || !this._mousemoveEvent) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
// 命中 InstancedMesh 时把派发目标重定向到 InstancedChild,并改写 intersection.object
|
|
291
|
+
this._mesh_Down = this._mesh_on = this.resolveTarget(intersection.object, intersection.instanceId);
|
|
292
|
+
(intersection as unknown as { object: Object3D }).object = this._mesh_Down;
|
|
293
|
+
// 触发鼠标按下事件
|
|
294
|
+
if (this.hasEvent(this._mesh_Down, ["mousedown"])) {
|
|
295
|
+
dispatchObjectEvent(this._mesh_Down, {
|
|
296
|
+
e: this._mouseEvent,
|
|
297
|
+
...intersection,
|
|
298
|
+
renderer: this._renderer,
|
|
299
|
+
camera: this._camera,
|
|
300
|
+
object: intersection.object,
|
|
301
|
+
type: "mousedown",
|
|
302
|
+
offsetX: this._mousemoveEvent!.offsetX,
|
|
303
|
+
offsetY: this._mousemoveEvent!.offsetY,
|
|
304
|
+
x: this._mousemoveEvent!.x,
|
|
305
|
+
y: this._mousemoveEvent!.y,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
// 鼠标弹起事件
|
|
310
|
+
_mouseup = debounce(async (e: PointerEvent) => {
|
|
311
|
+
this._mouseEvent = e;
|
|
312
|
+
// 提取有事件的对象
|
|
313
|
+
const meshs: Object3D[] = [];
|
|
314
|
+
let intersection = this._getSelected(this._object3ds);
|
|
315
|
+
if (!intersection || !this._mousemoveEvent) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
// 命中 InstancedMesh 时把派发目标重定向到 InstancedChild,并改写 intersection.object
|
|
319
|
+
this._mesh_on = this.resolveTarget(intersection.object, intersection.instanceId);
|
|
320
|
+
(intersection as unknown as { object: Object3D }).object = this._mesh_on;
|
|
321
|
+
if (this.hasEvent(this._mesh_on, ["mouseup"])) {
|
|
322
|
+
dispatchObjectEvent(this._mesh_on, {
|
|
323
|
+
e: this._mouseEvent,
|
|
324
|
+
...intersection,
|
|
325
|
+
renderer: this._renderer,
|
|
326
|
+
camera: this._camera,
|
|
327
|
+
object: intersection.object,
|
|
328
|
+
type: "mouseup",
|
|
329
|
+
offsetX: this._mousemoveEvent!.offsetX,
|
|
330
|
+
offsetY: this._mousemoveEvent!.offsetY,
|
|
331
|
+
x: this._mousemoveEvent!.x,
|
|
332
|
+
y: this._mousemoveEvent!.y,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
// 触发鼠标弹起事件
|
|
336
|
+
if (this._mesh_Down &&
|
|
337
|
+
this._mesh_Down === this._mesh_on &&
|
|
338
|
+
Math.abs(this._mouseDownPosition.x - e.offsetX) < 5 &&
|
|
339
|
+
Math.abs(this._mouseDownPosition.y - e.offsetY) < 5) {
|
|
340
|
+
// 是否有双击事件
|
|
341
|
+
if (this.hasEvent(this._mesh_Down, ["dbclick"])) {
|
|
342
|
+
this._click_num++;
|
|
343
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
344
|
+
// 只点击了一次
|
|
345
|
+
if (this._click_num === 1) {
|
|
346
|
+
if (this.hasEvent(this._mesh_Down, ["click"])) {
|
|
347
|
+
dispatchObjectEvent(this._mesh_Down, {
|
|
348
|
+
e: this._mouseEvent,
|
|
349
|
+
...intersection,
|
|
350
|
+
renderer: this._renderer,
|
|
351
|
+
camera: this._camera,
|
|
352
|
+
object: intersection.object,
|
|
353
|
+
type: "click",
|
|
354
|
+
offsetX: this._mousemoveEvent!.offsetX,
|
|
355
|
+
offsetY: this._mousemoveEvent!.offsetY,
|
|
356
|
+
x: this._mousemoveEvent!.x,
|
|
357
|
+
y: this._mousemoveEvent!.y,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
if (this.hasEvent(this._mesh_Down, ["leftclick"]) && e.button === 0) {
|
|
361
|
+
dispatchObjectEvent(this._mesh_Down, {
|
|
362
|
+
e: this._mouseEvent,
|
|
363
|
+
...intersection,
|
|
364
|
+
renderer: this._renderer,
|
|
365
|
+
camera: this._camera,
|
|
366
|
+
object: intersection.object,
|
|
367
|
+
type: "leftclick",
|
|
368
|
+
offsetX: this._mousemoveEvent!.offsetX,
|
|
369
|
+
offsetY: this._mousemoveEvent!.offsetY,
|
|
370
|
+
x: this._mousemoveEvent!.x,
|
|
371
|
+
y: this._mousemoveEvent!.y,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
if (this.hasEvent(this._mesh_Down, ["rightclick"]) &&
|
|
375
|
+
e.button === 2) {
|
|
376
|
+
dispatchObjectEvent(this._mesh_Down, {
|
|
377
|
+
e: this._mouseEvent,
|
|
378
|
+
...intersection,
|
|
379
|
+
renderer: this._renderer,
|
|
380
|
+
camera: this._camera,
|
|
381
|
+
object: intersection.object,
|
|
382
|
+
type: "rightclick",
|
|
383
|
+
offsetX: this._mousemoveEvent!.offsetX,
|
|
384
|
+
offsetY: this._mousemoveEvent!.offsetY,
|
|
385
|
+
x: this._mousemoveEvent!.x,
|
|
386
|
+
y: this._mousemoveEvent!.y,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
else if (this._click_num > 1) {
|
|
391
|
+
if (this.hasEvent(this._mesh_Down, ["dbclick"]) &&
|
|
392
|
+
new Date().valueOf() - this._click_num > 1 &&
|
|
393
|
+
e.button === 0) {
|
|
394
|
+
dispatchObjectEvent(this._mesh_Down, {
|
|
395
|
+
e: this._mouseEvent,
|
|
396
|
+
...intersection,
|
|
397
|
+
renderer: this._renderer,
|
|
398
|
+
camera: this._camera,
|
|
399
|
+
object: intersection.object,
|
|
400
|
+
type: "dbclick",
|
|
401
|
+
offsetX: this._mousemoveEvent!.offsetX,
|
|
402
|
+
offsetY: this._mousemoveEvent!.offsetY,
|
|
403
|
+
x: this._mousemoveEvent!.x,
|
|
404
|
+
y: this._mousemoveEvent!.y,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
if (this.hasEvent(this._mesh_Down, ["click"])) {
|
|
411
|
+
dispatchObjectEvent(this._mesh_Down, {
|
|
412
|
+
e: this._mouseEvent,
|
|
413
|
+
...intersection,
|
|
414
|
+
renderer: this._renderer,
|
|
415
|
+
camera: this._camera,
|
|
416
|
+
object: intersection.object,
|
|
417
|
+
type: "click",
|
|
418
|
+
offsetX: this._mousemoveEvent!.offsetX,
|
|
419
|
+
offsetY: this._mousemoveEvent!.offsetY,
|
|
420
|
+
x: this._mousemoveEvent!.x,
|
|
421
|
+
y: this._mousemoveEvent!.y,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
if (this.hasEvent(this._mesh_Down, ["leftclick"]) && e.button === 0) {
|
|
425
|
+
dispatchObjectEvent(this._mesh_Down, {
|
|
426
|
+
e: this._mouseEvent,
|
|
427
|
+
...intersection,
|
|
428
|
+
renderer: this._renderer,
|
|
429
|
+
camera: this._camera,
|
|
430
|
+
object: intersection.object,
|
|
431
|
+
type: "leftclick",
|
|
432
|
+
offsetX: this._mousemoveEvent!.offsetX,
|
|
433
|
+
offsetY: this._mousemoveEvent!.offsetY,
|
|
434
|
+
x: this._mousemoveEvent!.x,
|
|
435
|
+
y: this._mousemoveEvent!.y,
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
if (this.hasEvent(this._mesh_Down, ["rightclick"]) && e.button === 2) {
|
|
439
|
+
dispatchObjectEvent(this._mesh_Down, {
|
|
440
|
+
e: this._mouseEvent,
|
|
441
|
+
...intersection,
|
|
442
|
+
renderer: this._renderer,
|
|
443
|
+
camera: this._camera,
|
|
444
|
+
object: intersection.object,
|
|
445
|
+
type: "rightclick",
|
|
446
|
+
offsetX: this._mousemoveEvent!.offsetX,
|
|
447
|
+
offsetY: this._mousemoveEvent!.offsetY,
|
|
448
|
+
x: this._mousemoveEvent!.x,
|
|
449
|
+
y: this._mousemoveEvent!.y,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
this._click_num = 0;
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
/** 设置 Points(点云)拾取阈值(世界单位),数值越大越容易点中。
|
|
458
|
+
* 全景纹理标记改用 Points 后,通过它调节点击命中范围。 */
|
|
459
|
+
setPointsThreshold(threshold: number): void {
|
|
460
|
+
this._raycaster.params.Points.threshold = threshold;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/** 移除 canvas 上的所有鼠标/指针事件监听(渲染器销毁时调用)。
|
|
464
|
+
* 注:mouseenter 为内联匿名监听,销毁时 canvas 已脱离 DOM,无需显式移除。 */
|
|
465
|
+
dispose(): void {
|
|
466
|
+
const dom = this._renderer.domElement;
|
|
467
|
+
dom.removeEventListener("mouseleave", this._mouseleave, true);
|
|
468
|
+
dom.removeEventListener("mousemove", this._mousemove, true);
|
|
469
|
+
dom.removeEventListener("pointerdown", this._mousedown, true);
|
|
470
|
+
dom.removeEventListener("pointerup", this._mouseup, true);
|
|
471
|
+
}
|
|
472
|
+
}
|
package/Transition.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type TransitionParame = {
|
|
2
2
|
[key: string]: number;
|
|
3
3
|
};
|
|
4
|
-
export default class Transition<T extends TransitionParame, K extends Extract<keyof T, string>> {
|
|
4
|
+
export default class Transition<T extends TransitionParame, K extends Extract<keyof T, string> = Extract<keyof T, string>> {
|
|
5
5
|
/**
|
|
6
6
|
*Creates an instance of transition.
|
|
7
7
|
* @param {{ [key: string]: number }} // 初始值
|
|
@@ -10,7 +10,7 @@ export default class Transition<T extends TransitionParame, K extends Extract<ke
|
|
|
10
10
|
* @memberof transition
|
|
11
11
|
*/
|
|
12
12
|
constructor(param: T, bezier?: [number, number, number, number], duration?: number);
|
|
13
|
-
_keys:
|
|
13
|
+
_keys: K[];
|
|
14
14
|
_bezier: [number, number, number, number];
|
|
15
15
|
_Xbezier: [number, number, number, number];
|
|
16
16
|
_Ybezier: [number, number, number, number];
|
|
@@ -25,15 +25,20 @@ export default class Transition<T extends TransitionParame, K extends Extract<ke
|
|
|
25
25
|
};
|
|
26
26
|
private onChangeCall;
|
|
27
27
|
private onDoneCall;
|
|
28
|
-
run({ timeTemp }:
|
|
29
|
-
|
|
28
|
+
run({ timeTemp }: {
|
|
29
|
+
timeTemp: number;
|
|
30
|
+
}): this;
|
|
31
|
+
runbindThis: ((event: {
|
|
32
|
+
timeTemp: number;
|
|
33
|
+
accumulate: number;
|
|
34
|
+
}) => void);
|
|
30
35
|
onChange(onChangeCall: (josn: T) => void): this;
|
|
31
36
|
onDone(onDoneCall: (josn: T) => void): this;
|
|
32
|
-
get(key:
|
|
37
|
+
get(key: K): T[K];
|
|
33
38
|
set(param: Partial<T>): Promise<this>;
|
|
34
39
|
reset(param: Partial<T>): this;
|
|
35
|
-
getKeys():
|
|
36
|
-
hasKey(key:
|
|
40
|
+
getKeys(): K[];
|
|
41
|
+
hasKey(key: K): boolean;
|
|
37
42
|
getJson(): T;
|
|
38
43
|
_isDone: boolean;
|
|
39
44
|
isDone(): boolean;
|
package/Transition.js
CHANGED
|
@@ -47,9 +47,7 @@ export default class Transition {
|
|
|
47
47
|
_delay = 0;
|
|
48
48
|
// 设置过渡时间
|
|
49
49
|
setDuration(duration = 500) {
|
|
50
|
-
|
|
51
|
-
this._duration = duration;
|
|
52
|
-
}, 0);
|
|
50
|
+
this._duration = duration;
|
|
53
51
|
return this;
|
|
54
52
|
}
|
|
55
53
|
// 设置延时
|
|
@@ -87,11 +85,11 @@ export default class Transition {
|
|
|
87
85
|
}
|
|
88
86
|
// 计算当前 key 的值
|
|
89
87
|
get(key) {
|
|
90
|
-
|
|
91
|
-
if (this._keys.includes(
|
|
92
|
-
let start = this._[
|
|
93
|
-
let end = this._[
|
|
94
|
-
let timeProgress = Math.min(1, Math.max(0, (this.timeTemp - this._[
|
|
88
|
+
const keyStr = String(key);
|
|
89
|
+
if (this._keys.includes(keyStr) && this.timeTemp < (this._[`${keyStr}_startTime`] + this._duration)) {
|
|
90
|
+
let start = this._[`${keyStr}_start`];
|
|
91
|
+
let end = this._[`${keyStr}_end`];
|
|
92
|
+
let timeProgress = Math.min(1, Math.max(0, (this.timeTemp - this._[`${keyStr}_startTime`]) / this._duration));
|
|
95
93
|
// 斜率
|
|
96
94
|
let t = 0;
|
|
97
95
|
// 微分法 求斜率t
|
|
@@ -111,36 +109,36 @@ export default class Transition {
|
|
|
111
109
|
// 通过斜率求y值
|
|
112
110
|
return (bezier(this._Ybezier, t) * (end - start)) + start;
|
|
113
111
|
}
|
|
114
|
-
else if (this._keys.includes(
|
|
115
|
-
return this._[
|
|
112
|
+
else if (this._keys.includes(keyStr) && this.timeTemp >= (this._[`${keyStr}_startTime`] + this._duration)) {
|
|
113
|
+
return this._[`${keyStr}_end`];
|
|
116
114
|
}
|
|
117
115
|
// `没有 ${ key } 的值`;
|
|
118
116
|
return 0;
|
|
119
117
|
}
|
|
120
118
|
async set(param) {
|
|
121
119
|
let timetemp = performance.now() + this._delay;
|
|
122
|
-
;
|
|
123
120
|
for (let key in param) {
|
|
121
|
+
const keyStr = key;
|
|
124
122
|
// 有就赋值
|
|
125
|
-
if (this._keys.includes(
|
|
126
|
-
this._[
|
|
127
|
-
this._[
|
|
123
|
+
if (this._keys.includes(keyStr) && Math.abs(param[key] - this._[`${keyStr}_end`]) > 0.0001) {
|
|
124
|
+
this._[`${keyStr}_start`] = this.get(keyStr);
|
|
125
|
+
this._[`${keyStr}_end`] = param[key];
|
|
128
126
|
// 起始时间
|
|
129
|
-
this._[
|
|
127
|
+
this._[`${keyStr}_startTime`] = timetemp;
|
|
130
128
|
// 执行状态未完成
|
|
131
129
|
this._isDone = false;
|
|
132
130
|
// 没有就添加一个
|
|
133
131
|
}
|
|
134
|
-
else if (!this._keys.includes(
|
|
135
|
-
this._[
|
|
136
|
-
this._[
|
|
132
|
+
else if (!this._keys.includes(keyStr)) {
|
|
133
|
+
this._[`${keyStr}_start`] = param[key];
|
|
134
|
+
this._[`${keyStr}_end`] = param[key];
|
|
137
135
|
// 起始时间
|
|
138
|
-
this._[
|
|
136
|
+
this._[`${keyStr}_startTime`] = timetemp - this._duration;
|
|
139
137
|
// 执行状态未完成
|
|
140
138
|
this._isDone = false;
|
|
141
139
|
}
|
|
142
|
-
if (!this._keys.includes(
|
|
143
|
-
this._keys.push(
|
|
140
|
+
if (!this._keys.includes(keyStr)) {
|
|
141
|
+
this._keys.push(keyStr);
|
|
144
142
|
}
|
|
145
143
|
// // 执行状态未完成
|
|
146
144
|
// this._isDone = false;
|
|
@@ -156,12 +154,13 @@ export default class Transition {
|
|
|
156
154
|
// 重置起始和终止位置
|
|
157
155
|
reset(param) {
|
|
158
156
|
for (let key in param) {
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
const keyStr = key;
|
|
158
|
+
if (!this._keys.includes(keyStr)) {
|
|
159
|
+
this._keys.push(keyStr);
|
|
161
160
|
}
|
|
162
|
-
this._[
|
|
163
|
-
this._[
|
|
164
|
-
this._[
|
|
161
|
+
this._[`${keyStr}_start`] = param[key];
|
|
162
|
+
this._[`${keyStr}_end`] = param[key];
|
|
163
|
+
this._[`${keyStr}_startTime`] = -this._duration;
|
|
165
164
|
}
|
|
166
165
|
if (this.onChangeCall) {
|
|
167
166
|
this.onChangeCall(this.getJson());
|
|
@@ -195,7 +194,7 @@ export default class Transition {
|
|
|
195
194
|
}
|
|
196
195
|
let isisDone = false;
|
|
197
196
|
for (let i in this._keys) {
|
|
198
|
-
isisDone = this._[this._keys[i]
|
|
197
|
+
isisDone = this._[`${this._keys[i]}_startTime`] + this._duration < this.timeTemp;
|
|
199
198
|
// 只要有一个没有完成 都算没有完成 过渡
|
|
200
199
|
if (!isisDone) {
|
|
201
200
|
return false;
|