three-base 1.0.13 → 1.0.14
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/lib/KeyFrameAnimation.ts +7 -0
- package/lib/threeLoader.ts +21 -4
- package/package.json +1 -1
package/lib/KeyFrameAnimation.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type Keyframe = {
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
export type KeyframeAnimationProps = {
|
|
23
|
+
speedScale?: number; // 速度调整
|
|
23
24
|
object3d: Object3D; // 需要移动的对象
|
|
24
25
|
keyframes: Array<Keyframe>,
|
|
25
26
|
}
|
|
@@ -30,6 +31,9 @@ export default class KeyframeAnimation extends Object3D {
|
|
|
30
31
|
constructor(props: KeyframeAnimationProps) {
|
|
31
32
|
super();
|
|
32
33
|
|
|
34
|
+
// 速度调整
|
|
35
|
+
this.speedScale = props.speedScale || 1;
|
|
36
|
+
|
|
33
37
|
// 设置关键帧对象数组
|
|
34
38
|
this.setKeyframes(props.keyframes);
|
|
35
39
|
|
|
@@ -39,6 +43,9 @@ export default class KeyframeAnimation extends Object3D {
|
|
|
39
43
|
|
|
40
44
|
}
|
|
41
45
|
|
|
46
|
+
// 速度调整
|
|
47
|
+
speedScale = 1;
|
|
48
|
+
|
|
42
49
|
// 需要需要移动的对象
|
|
43
50
|
object3d: Object3D;
|
|
44
51
|
|
package/lib/threeLoader.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @Last Modified time: 2023-02-07 11:11:48
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { DefaultLoadingManager, EventDispatcher, RepeatWrapping, Texture, TextureLoader } from "three";
|
|
8
|
+
import { DefaultLoadingManager, EventDispatcher, RepeatWrapping, Texture, TextureLoader, VideoTexture } from "three";
|
|
9
9
|
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader";
|
|
10
10
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
|
11
11
|
import { MTLLoader } from "three/examples/jsm/loaders/MTLLoader";
|
|
@@ -60,9 +60,26 @@ class ThreeLoader extends EventDispatcher {
|
|
|
60
60
|
let texture = this.textureMap.get(src);
|
|
61
61
|
|
|
62
62
|
if (!texture) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
if (/\.mp4$/.test(src)) {
|
|
64
|
+
const videoDom = document.createElement("video");
|
|
65
|
+
videoDom.autoplay = true;
|
|
66
|
+
videoDom.loop = true;
|
|
67
|
+
videoDom.muted = true;
|
|
68
|
+
videoDom.preload = "auto";
|
|
69
|
+
videoDom.playsInline = true;
|
|
70
|
+
videoDom.src = src;
|
|
71
|
+
document.addEventListener("pointerup", () => {
|
|
72
|
+
videoDom.pause();
|
|
73
|
+
videoDom.play();
|
|
74
|
+
});
|
|
75
|
+
texture = new VideoTexture(videoDom);
|
|
76
|
+
} else {
|
|
77
|
+
|
|
78
|
+
texture = this.textureLoader.load(src, tex => {
|
|
79
|
+
tex.image.crossOrigin = "anonymous";
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
66
83
|
this.textureMap.set(src, texture);
|
|
67
84
|
}
|
|
68
85
|
|